All 13 emitter unit tests pass on re-verification. Implementation was already complete from prior run; this run confirms correctness and commits the bead close state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.9 KiB
1.9 KiB
Phase 8: Emitter — Completion Notes (bf-2f1)
Status
Phase 8 implementation was already present in commit bfb50da (Add Phase 8: Emitter).
Two bead runs verified correctness; all 13 tests confirmed passing on each run.
Verification
All 13 emitter unit tests pass:
test_text_correct_string_trailing_newline— text format emits{response}\ntest_text_no_extra_whitespace— no leading/trailing whitespace beyond newlinetest_json_valid_with_required_fields— all required fields present in JSON outputtest_json_claude_version_included—claude_versionfield emittedtest_json_usage_fields_are_integers— usage token counts are integers not stringstest_error_result_is_error_true_and_subtype— error JSON has correct structuretest_error_exit_code_nonzero— all error variants produce non-zero exit codestest_error_subtypes— subtype strings match plan spectest_error_exit_codes— exit codes: Setup→2, Timeout→124, Interrupted→130, AssistantError→1test_text_error_goes_to_stderr_not_stdout— text-mode errors go only to stderrtest_zero_token_counts_when_fallback— fallback path produces all-zero usage objecttest_stream_json_each_line_parses_as_json— forwarded JSONL lines are valid JSONtest_stream_json_disconnect_exits_immediately— reader thread exits cleanly on disconnect
Implementation Summary
src/emitter.rs (~185 LOC) provides:
emit_success()— routes totext/json/stream-jsonformat outputemit_error()— structured error output by format; text-mode errors to stderr onlyStreamJsonHandle— holds mpsc drain channel + thread join handlespawn_stream_json_reader()/spawn_stream_json_reader_to()— testable reader threadstream_json_reader_loop()— tails transcript JSONL from start_offset, forwards lines to stdout; retries file open if transcript not yet present; exits cleanly on drain signal or channel disconnect