Skip to content

Commit 920041c

Browse files
committed
Document the reactor.done vs inference.done distinction
Names the failure mode in the events table, cites the three defects it caused, and points at the onTurnBoundary / onReactorShutdown guards. States plainly that this is a naming convention rather than an enforced constraint: no lint tooling is configured in this repo to add a restricted-syntax rule, and a type-level fix would require modifying the vendored @intx/types / @intx/inference packages, which is off-limits.
1 parent bd87fdc commit 920041c

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

docs/ARCHITECTURE.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,33 @@ This repeats until the director emits `capabilities.done()`.
1818

1919
| Event | When it fires |
2020
|---|---|
21-
| `inference.done` | The LLM finished one assistant turn. Carries the full turn content. |
21+
| `inference.done` | The LLM finished one assistant turn. Carries the full turn content. Fires once per turn, every turn — this is the **turn boundary**. |
2222
| `tool.done` | One tool call completed. Carries the result and the original `callId`. |
23+
| `reactor.done` | The reactor loop shut down. Fires once, at the end of the run — not between turns. |
24+
25+
`inference.done` and `reactor.done` read as near-synonyms at a call site but
26+
answer different questions: "did a turn end" versus "did the reactor shut
27+
down." Three shipped defects came from code that needed a turn boundary but
28+
keyed off `reactor.done` instead: queued messages never dispatched because
29+
the send-queue drain waited for shutdown; `run.json`'s `turnsUsed` froze for
30+
an entire session because the mid-run snapshot only re-fired on shutdown;
31+
and the shell run state didn't return to idle between turns. Documentation
32+
didn't prevent the second and third instances, so code that needs to ask
33+
"did a turn end" or "did the reactor shut down" should go through the
34+
`onTurnBoundary` / `onReactorShutdown` guards in `src/agent/reactor-events.ts`
35+
rather than comparing `event.type` to a string directly — naming the
36+
question makes the right thing easier to write than the wrong one.
37+
38+
This is a convention, not an enforced constraint: nothing stops a future
39+
call site from writing `event.type === "reactor.done"` directly instead of
40+
reaching for the guard. Two enforcement routes were considered and both are
41+
out of scope here — a lint rule (`no-restricted-syntax` or similar) would
42+
mean standing up ESLint or Biome from scratch, since neither is configured
43+
anywhere in this repo, disproportionate for a Low-priority cleanup; and a
44+
type-level fix branding `event.type` would require modifying `@intx/types`
45+
or `@intx/inference`, which are vendored and off-limits. Reviewers should
46+
treat a bare `event.type === "reactor.done"` / `"inference.done"` comparison
47+
outside `reactor-events.ts` as a signal to ask why the guard wasn't used.
2348

2449
### ReactorActions
2550

0 commit comments

Comments
 (0)