Skip to content

feat(analyst-loop): onEvent sink with forwarded registry events#15

Merged
drewstone merged 2 commits into
mainfrom
feat/analyst-loop-events
May 19, 2026
Merged

feat(analyst-loop): onEvent sink with forwarded registry events#15
drewstone merged 2 commits into
mainfrom
feat/analyst-loop-events

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Summary

  • runAnalystLoop({ onEvent }) emits a discriminated-union AnalystLoopEvent for every phase of the loop: baseline-resolved → forwarded analyst events → findings-persisteddiff-computedknowledge-proposed / knowledge-appliedimprovement-proposed / improvement-appliedloop-completed.
  • Registry stream events are forwarded verbatim via { 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.
  • AnalystRegistryStreamingLike extends AnalystRegistryLike with an optional runStream — callers without it keep the previous registry.run() path; sinks then see only loop-level events.
  • The callback is awaited so slow subscribers apply backpressure to the loop.
  • Bumps the @tangle-network/agent-eval dep to ^0.29.0 for the new AnalystRunEvent type. Depends on agent-eval#59 being merged + published first.

Test plan

  • pnpm test — 97/97 pass (10 new under `describe('runAnalystLoop onEvent', ...)`)
  • pnpm typecheck
  • pnpm build
  • pnpm lint

- `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`.
@drewstone drewstone marked this pull request as draft May 19, 2026 14:53
@drewstone
Copy link
Copy Markdown
Contributor Author

Draft until agent-eval#59 merges and publishes v0.29.0. CI fails on pnpm install --frozen-lockfile because the manifest pins ^0.29.0 (for the new AnalystRunEvent type) but the lockfile still resolves to 0.28.0. Once 0.29.0 is on npm, regenerating the lockfile fixes CI.

@drewstone drewstone marked this pull request as ready for review May 19, 2026 15:17
@drewstone drewstone merged commit a0c09e5 into main May 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant