feat(0.29.0): AnalystRegistry.runStream — async event stream#59
Merged
Conversation
The registry now exposes a streaming counterpart to `run()`. UIs that
want to render progress (the 4-kind suite with maxDepth:3 takes minutes)
subscribe via `for await (const ev of registry.runStream(...))`;
consumers that just want the final envelope continue to await `run()`.
`run()` is a thin collector over `runStream()` — both share the same
loop body so they cannot drift on the invariants (isolation, hook
ordering, summary shape).
Event shape (`AnalystRunEvent` discriminated union):
- run-started { run_id, correlation_id, started_at, analyst_ids }
- analyst-skipped { summary } — missing input
- analyst-started { analyst_id, started_at }
- analyst-completed { summary, findings } — status: 'ok' | 'failed'
- run-completed { result: AnalystRunResult } — terminal
Per-finding events deliberately omitted — analyzers are batch
operations (an Ax actor returns the full `findings:json[]` at the end
of the responder), so streaming inside one analyst would only emit
partial JSON consumers can't render. The kind-completion event is the
right granularity.
Tests (5 new, 53 total in analyst suite):
- run-started → started → completed → run-completed for clean run
- analyst-skipped when input is missing
- analyst-completed with status=failed when analyst throws; siblings still run
- run() returns the same envelope as the run-completed event from runStream()
- back-pressure: slow consumer between events preserves ordering
`AnalystRunEvent` exported from index.ts. Hooks unchanged.
Merged
4 tasks
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.
Summary
AnalystRegistry.runStream(...)— async iterable that yieldsAnalystRunEventdiscriminated-union events (run-started,analyst-skipped,analyst-started,analyst-completed,run-completed) in real time as analysts execute. Subscribers iterate withfor await (const ev of registry.runStream(...)).AnalystRegistry.run(...)becomes a thin collector over the same stream so the two surfaces share invariants — there is no second code path to drift.per_analystsummary, so a failing analyst surfaces asanalyst-completedwithsummary.status === 'failed'(sibling isolation preserved).analyst.test.tscover: clean run event ordering, missing-input skip, throwing analyst → failed-status event,run()/runStream()envelope equivalence, and backpressure ordering.__version__); openapi spec rebuilds with the new version.Test plan
pnpm test— 1158/1158 pass on 128 filespnpm typecheckpnpm buildrebuildsdist/openapi.jsonwith version 0.29.0