Confirm that emitter::spawn_stream_json_reader is correctly wired at the PROMPT_INJECTED transition in the event loop callback. The implementation at src/session.rs:358-376: - Detects phase change to PromptInjected - Only spawns when output_format is StreamJson - Captures start_offset from transcript file metadata - Calls spawn_stream_json_reader with correct arguments - Stores StreamJsonHandle for later joining All acceptance criteria met. Code compiles successfully.
2.1 KiB
2.1 KiB
bf-549b: Stream-Json Reader Spawn Verification
Task
Wire stream-json reader spawn at PROMPT_INJECTED transition.
Status
VERIFIED 2026-07-02 - Code is already present and working correctly.
Verification Summary
Verification
The stream-json reader spawn call is correctly implemented in src/session.rs at lines 359-377:
// Check if phase changed to PromptInjected and notify watchdog
let current_phase = startup.phase();
if last_phase != *current_phase && current_phase.is_prompt_injected() {
watchdog_state_clone.mark_prompt_injected();
// Spawn stream-json reader at PROMPT_INJECTED for stream-json output
if matches!(output_format, crate::cli::OutputFormat::StreamJson) {
// Calculate byte offset: current transcript file size, or 0 if not exists
let start_offset = std::fs::metadata(&transcript_path)
.map(|m| m.len())
.unwrap_or(0);
stream_json_handle = Some(emitter::spawn_stream_json_reader(
transcript_path.clone(),
start_offset,
));
stream_json_spawned_clone.store(true, std::sync::atomic::Ordering::SeqCst);
}
}
Acceptance Criteria - All Met
- ✅ Spawn call is in event loop callback at PROMPT_INJECTED
- ✅ Only spawns when output_format is StreamJson (line 364)
- ✅ Passes transcript_path correctly (line 371)
- ✅ Passes start_offset correctly (lines 366-368, captures current transcript size)
- ✅ Stores handle in stream_json_handle for later joining (line 370)
- ✅ Code compiles without errors (verified with
cargo check)
Cleanup Paths
The handle is properly joined on all exit paths:
- Success path (lines 442-446): Sends drain signal, joins
- Timeout path (lines 404-407): Drops without drain (immediate exit), joins
- Child exit path (lines 460-463): Drops without drain, joins
- Interrupt path (lines 469-472): Drops without drain, joins
Conclusion
This bead's work was already completed in a previous implementation. The code correctly wires the stream-json reader spawn at the PROMPT_INJECTED transition in the session flow's event loop callback.