Skip to content

fix: harden CLI error semantics and WorkThread leases - #87

Merged
HarryHeYu merged 1 commit into
mainfrom
fix/r21-error-semantics
Dec 1, 2026
Merged

HarryHeYu merged 1 commit into
mainfrom
fix/r21-error-semantics

Conversation

@HarryHeYu

Copy link
Copy Markdown
Owner

Fixed

  • CLI --json failures now emit a machine-readable envelope on stdout:
    {"ok": false, "error": "...", "error_code": "...", "details": {...}}.
    The legacy string field error is preserved; success shapes are unchanged.
  • Read-only and locked SQLite databases map to stable codes DB_READ_ONLY /
    DB_LOCKED instead of leaking tracebacks. Human mode now gives actionable
    guidance, including a voyager thread list hint where relevant.
  • A live WorkThread lease is now exclusive even for the same holder. Concurrent
    same-holder continue / switch requests are refused with LEASE_HELD
    unless the caller explicitly uses steal semantics.
  • switch accepts --json. Refused handoff results now produce a non-zero
    exit code in JSON mode.
  • The CLI process contract is unchanged: cli.main() still raises
    SystemExit for process-style exits; no global SystemExit swallowing.

Regression coverage

  • New tests/test_r21_error_semantics.py with 10 contract tests covering JSON
    parseability, exit codes, legacy error compatibility, read-only DB, locked
    DB, lease refusal, explicit steal, lock-acquire failure, and switch --json.
  • Real subprocess probes for D1–D8 and I1–I5; post-fix concurrency run produced
    zero tracebacks and all competing requests were non-zero refused.
  • Mutation verification caught all three Core mutations: envelope shape,
    same-holder lease bypass, and refused-exit-code regression; sources restored
    byte-identically.

Compatibility

  • Additive JSON fields only; no success JSON contract change and no new public
    error-code union for the Plugin bridge.
  • No Store / Bridge schema change, no DB migration, no version bump.
  • Plugin bridge needs a diagnostics-only compatibility fix so its CLI_FAILED
    detail preserves the new stdout envelope; see the companion Plugin PR.

Not included

  • Bridge head-of-line blocking or large-request handling
  • provider parsing / provider hardening
  • path normalization
  • Unicode normalization
  • Native Resume
  • VS Code / Extension Host work
  • schema bump or DB migration
  • new CLI feature
  • release, tag, promotion, or HelloGitHub action

Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:26

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@HarryHeYu
HarryHeYu merged commit a0ad21c into main Dec 1, 2026
11 checks 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.

2 participants