feat(analyst-loop): onEvent sink with forwarded registry events#15
Merged
Conversation
- `runAnalystLoop({ onEvent })` emits a discriminated-union `AnalystLoopEvent` at every phase: `baseline-resolved` → forwarded `analyst` events (when the registry supports `runStream`) → `findings-persisted` → `diff-computed` → `knowledge-proposed`/`knowledge-applied` → `improvement-proposed`/`improvement-applied` → `loop-completed`.
- Registry stream events are forwarded verbatim via `{ type: 'analyst', runId, event }` so consumers don't have to wire two streams.
- `AnalystRegistryStreamingLike` extends the existing `AnalystRegistryLike` with an optional `runStream` — callers without it (or without `onEvent`) keep the previous `registry.run()` path; sinks see only the loop-level events.
- The callback is awaited so slow subscribers (SSE write, JSONL append) apply backpressure to the loop's phases.
- Bumps `@tangle-network/agent-eval` peer to `^0.29.0` for the `AnalystRunEvent` export.
7 new tests in `tests/analyst-loop.test.ts`: clean-run ordering, runStream forwarding, no-baseline diff omission, knowledge proposed/applied counts, improvement proposed/applied without `apply`, awaited-callback backpressure, and `run()` fallback when no `runStream`.
Contributor
Author
|
Draft until agent-eval#59 merges and publishes v0.29.0. CI fails on |
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
runAnalystLoop({ onEvent })emits a discriminated-unionAnalystLoopEventfor every phase of the loop:baseline-resolved→ forwardedanalystevents →findings-persisted→diff-computed→knowledge-proposed/knowledge-applied→improvement-proposed/improvement-applied→loop-completed.{ type: 'analyst', runId, event }so a single sink (SSE, JSONL tail, in-process logger) sees per-analyst progress and loop-level milestones on one stream.AnalystRegistryStreamingLikeextendsAnalystRegistryLikewith an optionalrunStream— callers without it keep the previousregistry.run()path; sinks then see only loop-level events.@tangle-network/agent-evaldep to^0.29.0for the newAnalystRunEventtype. Depends on agent-eval#59 being merged + published first.Test plan
pnpm test— 97/97 pass (10 new under `describe('runAnalystLoop onEvent', ...)`)pnpm typecheckpnpm buildpnpm lint