Skip to content

fix: allow minimal scope in CLI commands#24

Merged
KHAEntertainment merged 3 commits intomasterfrom
fix/cli-minimal-scope
Mar 28, 2026
Merged

fix: allow minimal scope in CLI commands#24
KHAEntertainment merged 3 commits intomasterfrom
fix/cli-minimal-scope

Conversation

@KHAEntertainment
Copy link
Copy Markdown
Owner

@KHAEntertainment KHAEntertainment commented Mar 27, 2026

Fixes an oversight where --scope minimal was defined in the core and docs but not permitted by the CLI's click.Choice array.

Summary by CodeRabbit

  • New Features

    • Expanded scope choices for backup/list/clean/checkpoint commands to offer finer-grained selection ("minimal", "config", "config+session", "config+session+workspace").
  • Bug Fixes / Validation

    • Commands now prevent use of the "minimal" scope in contexts where it's unsupported (e.g., native source/backups) and present clear error messages when disallowed.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10eac652-b6b8-494d-8389-a6bdfdde89d2

📥 Commits

Reviewing files that changed from the base of the PR and between 78a0864 and a9a742c.

📒 Files selected for processing (1)
  • src/ocbs/cli.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ocbs/cli.py

Walkthrough

Added a SCOPE_CHOICES constant and expanded the --scope Click option to include "minimal" for backup, list, clean, and checkpoint subcommands; added guards that disallow "minimal" with backup --source native and in the native_backup command, raising click.ClickException on violation.

Changes

Cohort / File(s) Summary
CLI core
src/ocbs/cli.py
Added exported SCOPE_CHOICES = ['minimal','config','config+session','config+session+workspace']; updated --scope choices for backup, list, clean, and checkpoint subcommands; added validation to reject --scope minimal when backup is used with --source native and within native_backup, raising click.ClickException.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A tiny flag with big intent,
"minimal" joins the command event.
Guards stand firm where conflicts creep,
CLI rules tidy, tidy keep. 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: allow minimal scope in CLI commands' accurately describes the main change—enabling the minimal scope option that was previously missing from the CLI's choice array.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-minimal-scope

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/ocbs/cli.py (2)

26-33: ⚠️ Potential issue | 🟠 Major

backup --source native --scope minimal can still execute with non-minimal native flags.

Line 26 now allows minimal, but the native path (core._scope_to_native_args) has no explicit MINIMAL mapping, so it falls back to default flags. That’s like labeling a button “eco mode” while the engine still runs in sport mode. Please guard or explicitly map this combination before calling core.backup(...).

Suggested guard in CLI (prevents silent scope mismatch)
 def backup(ctx, scope, source, reason):
     """Create a backup."""
     core = ctx.obj['core']
     scope_enum = BackupScope(scope)
     source_enum = BackupSource(source) if source else None
+    effective_source = source_enum or core.get_default_source()
+
+    if scope_enum == BackupScope.MINIMAL and effective_source == BackupSource.NATIVE:
+        raise click.BadParameter(
+            "'minimal' scope is not supported for native backups yet. "
+            "Use '--source direct' or a broader scope."
+        )
     
     try:
         manifest = core.backup(scope_enum, reason, source=source_enum)

Also applies to: 39-43

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ocbs/cli.py` around lines 26 - 33, The CLI allows --scope minimal but
when --source is 'native' core._scope_to_native_args lacks a MINIMAL mapping so
native backups run with wrong flags; update the CLI handler that constructs
native args (before calling core.backup) to either explicitly map the 'minimal'
scope to the correct native flag set in core._scope_to_native_args or add a
guard that rejects/overrides the combination (e.g., error out or translate
'minimal' into the supported native flags) so core.backup is never called with a
silent scope mismatch; reference the code paths around
core._scope_to_native_args and the call site core.backup to find where to
implement the mapping/guard.

164-179: ⚠️ Potential issue | 🟠 Major

native_backup --scope minimal currently behaves as full scope.

At Line 164, minimal is accepted, but Lines 175-179 only special-case config and config+session; minimal falls through to “no flags” (full backup semantics). This violates user intent and can back up much more than requested.

Suggested fix (fail fast until native minimal semantics are defined)
 def native_backup(scope, verify, output):
@@
-    if scope == "config":
+    if scope == "minimal":
+        click.echo(
+            "Error: --scope minimal is not supported for native backup yet.",
+            err=True,
+        )
+        sys.exit(2)
+    elif scope == "config":
         args.append("--only-config")
     elif scope == "config+session":
         args.append("--no-include-workspace")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ocbs/cli.py` around lines 164 - 179, The native_backup command
incorrectly treats scope='minimal' as full scope; update the native_backup
function to explicitly handle the 'minimal' choice (the scope parameter and args
list in native_backup) and fail fast until minimal semantics are
implemented—e.g., detect if scope == 'minimal' and raise a click.ClickException
or click.BadParameter with a clear message so users cannot accidentally run a
full backup when they asked for minimal. Ensure you modify the conditional block
that currently checks scope == "config" and "config+session" to include the
'minimal' branch and return/abort accordingly.
🧹 Nitpick comments (1)
src/ocbs/cli.py (1)

26-27: Centralize scope choices to avoid future drift.

The same scope literal list is repeated 4 times. A shared constant (e.g., SCOPE_CHOICES) will keep command behavior in sync and prevent this exact mismatch from resurfacing.

Also applies to: 107-108, 127-128, 164-165

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ocbs/cli.py` around lines 26 - 27, Create a single shared constant (e.g.,
SCOPE_CHOICES = ['minimal', 'config', 'config+session',
'config+session+workspace']) and replace each repeated literal list in the
click.option('--scope', ...) declarations with type=click.Choice(SCOPE_CHOICES)
so all scope options (the various click.option('--scope', ...) occurrences in
src/ocbs/cli.py) reference the same list; update any imports/ordering as needed
so SCOPE_CHOICES is defined near the top of the module and used by each option
to prevent drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/ocbs/cli.py`:
- Around line 26-33: The CLI allows --scope minimal but when --source is
'native' core._scope_to_native_args lacks a MINIMAL mapping so native backups
run with wrong flags; update the CLI handler that constructs native args (before
calling core.backup) to either explicitly map the 'minimal' scope to the correct
native flag set in core._scope_to_native_args or add a guard that
rejects/overrides the combination (e.g., error out or translate 'minimal' into
the supported native flags) so core.backup is never called with a silent scope
mismatch; reference the code paths around core._scope_to_native_args and the
call site core.backup to find where to implement the mapping/guard.
- Around line 164-179: The native_backup command incorrectly treats
scope='minimal' as full scope; update the native_backup function to explicitly
handle the 'minimal' choice (the scope parameter and args list in native_backup)
and fail fast until minimal semantics are implemented—e.g., detect if scope ==
'minimal' and raise a click.ClickException or click.BadParameter with a clear
message so users cannot accidentally run a full backup when they asked for
minimal. Ensure you modify the conditional block that currently checks scope ==
"config" and "config+session" to include the 'minimal' branch and return/abort
accordingly.

---

Nitpick comments:
In `@src/ocbs/cli.py`:
- Around line 26-27: Create a single shared constant (e.g., SCOPE_CHOICES =
['minimal', 'config', 'config+session', 'config+session+workspace']) and replace
each repeated literal list in the click.option('--scope', ...) declarations with
type=click.Choice(SCOPE_CHOICES) so all scope options (the various
click.option('--scope', ...) occurrences in src/ocbs/cli.py) reference the same
list; update any imports/ordering as needed so SCOPE_CHOICES is defined near the
top of the module and used by each option to prevent drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c11a4ae0-4205-4b9e-a031-a90c6cf0b074

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7357f and 78a0864.

📒 Files selected for processing (1)
  • src/ocbs/cli.py

@KHAEntertainment KHAEntertainment merged commit 23f5606 into master Mar 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant