docs(bf-549b): verify stream-json reader spawn at PROMPT_INJECTED

Verify that the stream-json reader spawn call is correctly wired
at the PROMPT_INJECTED transition in the event loop callback.

Code is already implemented in src/session.rs:359-377 with:
- Phase transition detection
- Output format check (StreamJson only)
- Transcript path and start_offset capture
- Handle storage for cleanup on all exit paths
- Compiles without errors
This commit is contained in:
jedarden 2026-07-02 09:58:39 -04:00
parent 4d09ce8a9a
commit cd2206f554

54
notes/bf-549b.md Normal file
View file

@ -0,0 +1,54 @@
# bf-549b: Stream-Json Reader Spawn Verification
## Task
Wire stream-json reader spawn at PROMPT_INJECTED transition.
## Status
**ALREADY IMPLEMENTED** - Code is already present and working correctly.
## Verification
The stream-json reader spawn call is correctly implemented in `src/session.rs` at lines 359-377:
```rust
// 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.