Skip to content

fix: stop reporting success for unavailable CLI operations - #26

Merged
Jairogelpi merged 1 commit into
mainfrom
fix/cli-no-false-success
Sep 18, 2026
Merged

Jairogelpi merged 1 commit into
mainfrom
fix/cli-no-false-success

Conversation

@Jairogelpi

@Jairogelpi Jairogelpi commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Problem

Eight reserved CLI operations returned status: ok and exit 0 without performing work. warrant verify without an input also succeeded, and a tampered warrant printed ok in human mode despite its failing exit code.

Changes

  • Unavailable operations return exit 5 and command_unavailable; help/README state the boundary.
  • Missing/unreadable/malformed warrant inputs return exit 2 and structured errors without pretending verification occurred.
  • Real verification retains exit 0 for valid and exit 3 for invalid warrants, with truthful human output.
  • Remove the default successful fallback. Add subprocess acceptance tests for both output formats, actual generated/tampered warrants, and absence of side effects.
  • Strengthen the old interface test that expected false success; document compatibility in ADR 0004 and traceability.

Validation

23 new acceptance cases reproduced the missing behavior before the fix. The focused suite now passes 26 tests. All six CI matrix jobs passed (Linux Python 3.11/3.12 and Windows Python 3.12), including full quality, clean-wheel install, real MCP smoke, external evaluation, EMT, schemas and traceability. Full suite: 253 tests; Linux 3.12 branch-inclusive coverage: 95.89%. CodeQL passed. No thresholds changed.

CI: https://github.com/Jairogelpi/answerable_data/actions/runs/35315554564

Scope

This closes false success paths; it does not implement the reserved commands, a hosted web app, or independent/real-agent validation.

Copilot AI lite review requested due to automatic review settings September 18, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are a couple of correctness/contract issues to address (notably deterministic UTF-8 handling in the new tampering test, plus traceability status alignment with the repo’s “verified == delivered” rule).

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR hardens the answerable CLI to “fail closed” by returning non-zero exit codes and error payloads for reserved/unimplemented operations and for warrant verify misuse, preventing false “success” signals.

Changes:

  • Make reserved/unavailable CLI commands/actions return exit 5 with command_unavailable (and human-mode errors on stderr).
  • Require --warrant for warrant verify, returning exit 2 with structured error codes for missing/unreadable inputs, while preserving exit 0/3 for valid/invalid warrants.
  • Add subprocess-based CLI acceptance tests and update traceability/README/ADR documentation accordingly.
File summaries
File Description
tests/test_interfaces.py Updates the JSON/exit-code contract test for warrant verify with no input.
tests/test_cli_acceptance.py Adds subprocess acceptance coverage for unavailable commands and warrant verification behaviors.
src/answerable/cli.py Implements fail-closed behavior, new exit codes, structured errors, and corrected warrant human output.
requirements/traceability.yaml Adds the new acceptance test to FR-CLI-001 traceability.
README.md Documents reserved command boundaries, exit codes, and warrant verification semantics.
docs/adr/0004-cli-fail-closed.md Records the decision and compatibility notes for failing closed on CLI success paths.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +97 to +99
record = json.loads(path.read_text())
record["canonical_json"] += " "
path.write_text(json.dumps(record))
implementation: ["src/answerable/cli.py", "src/answerable/__init__.py"]
tests: ["tests/test_interfaces.py", "tests/test_distribution_version.py"]
tests: ["tests/test_interfaces.py", "tests/test_distribution_version.py", "tests/test_cli_acceptance.py"]
status: implemented
Comment thread src/answerable/cli.py
EXIT_INVALID_WARRANT = 3
EXIT_BENCHMARK_FAILED = 4
EXIT_UNAVAILABLE = 5
EXIT_USAGE = 2
@Jairogelpi
Jairogelpi merged commit e8ecc94 into main Sep 18, 2026
9 checks passed
Jairogelpi added a commit that referenced this pull request Sep 18, 2026
Rebased onto #26 (e8ecc94), which closed frame/plan/execute/inspect
and source add/test to exit 5 / command_unavailable, and made
warrant verify require --warrant. This adds the other half: warrant
show and warrant export were left unavailable there even though the
real logic (load_warrant, WarrantIssuer.export) already existed, so
this wires them up for real instead of stubbing them out too.
README and the ADR are updated to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0184ULwpMiFbdXnY51apP2xF
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.

2 participants