mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-04-24 21:28:11 +08:00
Under --output-format json, error envelopes were emitted to stderr via eprintln!. This violated the emission contract: stdout should carry the contractual envelope (success OR error); stderr is reserved for non-contractual diagnostics. Cycle #87 controlled matrix audit found bootstrap/dump-manifests/state exhibited this pattern (exit 1, stdout 0 bytes, stderr N bytes under --output-format json). Fix: change eprintln! to println! for the JSON error envelope path in main(). Text mode continues to route errors to stderr (conventional). Verification: - bootstrap --output-format json: stdout now carries envelope, exit 1 - dump-manifests --output-format json: stdout now carries envelope, exit 1 - Text mode: errors still on stderr with [error-kind: ...] prefix (no regression) Tests: - Updated assert_json_error_envelope helper to read from stdout (was stderr) - Added error_envelope_emitted_to_stdout_under_output_format_json_168c regression test that asserts envelope on stdout + non-JSON on stderr - All 16 output_format_contract tests pass Phase 0 Task 1 complete: emission routing fixed across all error-path verbs. Phase 0 Task 2 (no-silent CI guarantee) remains. Refs: #168c (cycle #87 filing), cycle #88 emission contract framing