feat(analyst): priorFindings context wiring + cross-run prompt rendering#58
Merged
Conversation
Analysts now read the previous run's findings as retrieval context, so
the self-improvement loop has memory: a failure-mode that reappears
without remediation gets caught and re-promoted; a knowledge gap that
the wiki failed to close stays on the report; the cross-run diff stays
stable because kinds carry forward the prior `finding_id` via id_basis.
Changes:
- `AnalystContext` gains a `priorFindings?: ReadonlyArray<AnalystFinding>`
field. Filtering is the operator's job: pass the slice that matches
this analyst, or pass everything and let the kind decide.
- `RegistryRunOpts.priorFindings` accepts two shapes:
- Array — each analyst sees only findings whose `analyst_id`
matches its own (per-kind history).
- Record — `{ '<id>': [...], '*': [...] }` so the wildcard fans
out for cross-kind chaining (the improvement analyst consumes
upstream failure / gap / poisoning findings via '*').
Analysts that get no matching slice see `undefined`, not an empty
array — the kind-factory's renderer treats `undefined` as "no prior
context" and emits no prompt block.
- `kind-factory.ts` exports `renderPriorFindings(prior)`. Caps at 40
rows (~2KB) and appends an overflow line when truncated. The actor
prompt now ends with:
PRIOR FINDINGS (from a previous run on related data):
When the work you do now matches a row below, REUSE the
`finding_id` (pass it as `id_basis`) so the cross-run diff stays
stable.
A finding that reappears with no remediation evidence SHOULD
raise its `confidence` and may justify a higher `severity`.
- id=<sha> <severity> [<subject>] <claim-truncated>
...
Tests (7 added, 1153 total pass):
- registry array form filters by analyst_id
- registry record form merges per-id with '*' wildcard
- undefined when no matching prior (not empty array)
- renderPriorFindings empty-input / typical / overflow paths
777668b to
2aa7550
Compare
drewstone
added a commit
that referenced
this pull request
May 19, 2026
… priorFindings Wraps two unreleased features into a single minor: - PR #57: kind-factory + 4 trace-analyst kinds (failure-mode, knowledge-gap, knowledge-poisoning, improvement) via Ax structured output + Zod-validated `RawAnalystFinding`. - PR #58: priorFindings context wiring so kinds chain across runs ('improvement' sees what 'failure-mode' surfaced). createTraceAnalystAdapter retains @deprecated marker pointing at the new kinds; kept for one minor while consumers migrate. 1153/1153 tests green.
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.
Closes piece 1/3 of the self-improvement loop (substrate side).
What this adds
Analysts now read the previous run's findings as retrieval context, so the loop has memory:
finding_idviaid_basisShape
AnalystContext.priorFindings?: ReadonlyArray<AnalystFinding>— analysts read these directlyRegistryRunOpts.priorFindingsaccepts two forms:analyst_id(per-kind history){ '<id>': [...], '*': [...] }→ '*' fans out to all analysts (for cross-kind chaining, e.g.improvementconsuming upstream failure / gap / poisoning)renderPriorFindings(prior)exported helper — emits a compactPRIOR FINDINGSprompt block (1 line per finding, 40-row cap with overflow line). The actor is instructed to (a) reuse the priorfinding_idviaid_basisso diffs stay stable, and (b) raise severity / confidence when a finding reappears with no remediation evidence.7 added tests; 1153 total pass; typecheck clean.
Coordinated PRs
proposeFromFindingbridge (this PR's findings → wiki proposals)runAnalystLooporchestrator (one call closes the loop)