Skip to content

AMS: governor pause/resume/status CLI error paths bypass the --json contract #5914

Description

@JSONbored

Context

packages/loopover-miner/lib/governor-pause-cli.js's runGovernorPause (lines 86-87, 112-113), runGovernorResume (lines ~120-121, 145-146), and runGovernorStatus (lines ~153-154, 168-169) each handle parse errors and catch-block errors with raw console.error(...); return 2;. Every sibling CLI module in packages/loopover-miner/lib/ (claim-ledger-cli.js, event-ledger-cli.js, governor-ledger-cli.js, governor-metrics-cli.js, loop-cli.js, metrics-cli.js, plan-store-cli.js, run-state-cli.js) instead routes error paths through the shared reportCliFailure(argsWantJson(args), ...) contract from cli-error.js, which emits a {ok:false,error} JSON envelope on stdout when --json was requested.

Because governor-pause-cli.js never imports or calls reportCliFailure/argsWantJson, running loopover-miner governor pause --reason x --json on an error path (a bad flag, or a real governor-state open/write failure) prints plain text to stderr instead of the documented JSON envelope — breaking any script or the MCP layer parsing --json output for this specific command family.

Requirements

  • runGovernorPause, runGovernorResume, and runGovernorStatus must route their parse-error and catch-error paths through reportCliFailure(argsWantJson(args) or parsed.json, ...), matching the convention already used by every sibling CLI module.
  • Behavior for non---json invocations must be unchanged (still prints a human-readable error to stderr with exit code 2).

Deliverables

  • Import argsWantJson/reportCliFailure/describeCliError from ./cli-error.js in governor-pause-cli.js.
  • Replace the 6 raw console.error(...); return 2; error paths across the three functions with the shared contract.
  • Regression tests in test/unit/miner-governor-pause-cli.test.ts covering each error path invoked WITH --json, asserting the JSON envelope shape (the existing error-path tests at lines 119-247 never pass --json alongside an error trigger).

Test Coverage Requirements

This repo's Codecov patch gate is 99%+ hard, branch-counted — both the --json and non---json arm of every touched error path need a direct test.

Expected Outcome

loopover-miner governor pause|resume|status --json on any error path (bad flag, governor-state failure) emits the standard {ok:false,error} JSON envelope on stdout, consistent with every other CLI module in this package.

Links & Resources

  • packages/loopover-miner/lib/cli-error.js — the shared contract to adopt.
  • packages/loopover-miner/lib/claim-ledger-cli.js — reference implementation already using reportCliFailure/argsWantJson correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.gittensor:priorityMaintainer-selected Gittensor priority — scores a 1.5x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions