feat(engine): #422 slice 1 — typed event vocabulary + EngineSink inversion for agent_stream - #423
Merged
Merged
Conversation
…d ids (#422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
…tion, sequence} cursors (#422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
…ine cap, #422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
…der.zig (#422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
…only (#422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
…state the real slice-1 debt (#422) Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 1 of #422: the engine stops writing to the terminal and starts emitting typed events through a strict sink interface. First offender converted:
agent_stream.zignow has zero imports ofterm.zig/agent_render.zig/ansi.zig/anim.zig.What's in it
engine_events.zig— the new internal vocabulary: one tagged union covering every emissionagent_streamproduces (stream_begin,reasoning_delta,text_delta,thinking_fold_toggle,stream_aborted{interrupted|stalled|dropped},stream_complete,stream_finished) plusCursor{generation, sequence}.protocol_seq.writeEventStamped— cursor stamping integrates with the existing seq counter (durable events reserve ids inside the stdout lock; pulses observe) so the--jsonwire's gap-free numbering and bytes are unchanged. One counter, no duplication.engine_sink.zig— strictEngineSinkvtable (sinks receive events only).TuiSinkreproduces every old inline TTY branch gate-for-gate viaagent_stream_render.zig(spinner + live Thinking block moved verbatim);JsonSinkemits the existing wire lines byte-identically, pinned by test.agent_output.zig—say/sayApiError/emitmoved out ofagent.zig(now 538/600) with member aliases so call sites are untouched.Evidence it changes nothing
A before/after eval harness (goldens captured from v0.0.239
main, determinism proven by double-run) gates the change:--jsonprotocol: scripted session against a local mock Codex backend (tool call + two text turns + mode/effort controls) — full 22-event NDJSON stream, stderr, exit code, and backend request count byte-identical to baseline.zig build test: 981 → 989, delta exactly the 8 new unit tests (engine_events ×3, engine_sink ×4, protocol_seq ×1), all wired throughtest_hooks.zig; none removed.zig fmt --checkclean.Known slice-1 debt (documented in-code, on the epic's work list)
agent_ws.zigstill reaches spinner state via Agent aliases;agent_argstream.emitArgTextstill branches json/tty inline — next offenders.TuiSinkwraps*Agentas its render-state handle until the render state moves out.Cursor.bumpGenerationexists but nothing calls it yet — lands with the serve/attach slice (Local daemon: graff agents / graff attach — sessions that survive terminal close #420).Part of #422.