Repository navigation
refactor(cli): describe each zova-ops action once in a table - #117
Merged
Merged
Conversation
The existing zova-ops test checks exit codes for one valid call per action and a few invalid ones. Before restructuring cbm_cmd_zova_ops, pin its full behaviour against the current code: - for every action, its required flags pass validation; dropping any required flag, or adding any flag the action does not accept, fails with "invalid flags for zova-ops action"; adding an optional flag (--replace for import-workspace, --workspace-id for health) passes; - each usage error's reason in the JSON report, including which error wins when several apply. Signed-off-by: ata-sesli <atasesli@protonmail.com>
cbm_cmd_zova_ops listed its 12 actions in three places: the known-action list, an if/else chain of per-action flag rules written as long "!input && !output && ..." expressions, and a second if/else chain that called the operation. Adding or changing an action meant editing all three consistently. Each action is now one row of cli_zova_ops_actions: its name, the flags it requires, the flags it also accepts, and a small wrapper that calls the Zova operation. The command parses the flags, looks up the action, compares the given flags against the row's masks, and runs it. Behaviour is unchanged: the same usage-error messages in the same order, the same exit codes and JSON report, and the health classification still only reported for the health action. Signed-off-by: ata-sesli <atasesli@protonmail.com>
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #112. Each
zova-opsaction is now described once, in a table, instead of in three separate places incbm_cmd_zova_ops.Stacked on #116. This PR's base is
simplify/build-source-check. Review and merge #116 first; GitHub then retargets this PR tomain.Problem
cbm_cmd_zova_ops(src/cli/cli.c), thecodebase-memory-mcp zova-ops <action>handler, listed its 12 actions three times:cli_zova_ops_action_known, which accepted or rejected the action name;if/else ifchain of flag rules, written as long!input && !output && …expressions;if/else ifchain that called the matchingcbm_zova_database_*orcbm_zova_workspace_*function.Adding or changing an action meant editing all three consistently. The code graph scored the function at cognitive complexity 182; the next highest function in
src/is at 58.Change
Two commits.
1. Characterization test (
test(cli): pin zova-ops flag rules and usage-error order). The existing test only checked exit codes, and only one forbidden-flag case. The new testcli_zova_ops_flag_rules_and_error_orderpasses against the old code and pins:invalid flags for zova-ops action; adding an optional flag (--replaceforimport-workspace,--workspace-idforhealth) passes;reasonin the JSON report for each usage error, including which error wins when several apply. For example, a missing--jsonis reported before an invalid--workspace-id, which is reported before an invalid--confirm-workspace.2. Refactor (
refactor(cli): describe each zova-ops action once in a table). Each row ofcli_zova_ops_actionsholds:requiredandoptionalbit masks over--input,--output,--workspace-id,--confirm-workspace,--repo-path,--confirm-replaceand--replace;cbm_cmd_zova_opsnow parses the flags (same parser as before), looks up the row, checks the given flags against its masks, and runs the wrapper. The function went from 104 lines to 71.cli.cis 69 lines longer overall, mostly the 12 three-line wrappers.Behaviour is unchanged: the same usage-error messages in the same order, the same exit codes, the same JSON report, and
health_classificationis still only reported forhealth.Verification
CBM_TEST_TIERS=all, macOS arm64: 6,449 passed, 0 failed.--repo-pathonhealthin the table made it fail. Reverted.git diff --checkpasses.