feat(propose): bridge AnalystFinding → KnowledgeProposal#9
Merged
Conversation
Closes the analysis → wiki side of the recursive-self-improvement
loop. A knowledge-gap or knowledge-poisoning finding produced by an
analyst now converts directly into a typed `KnowledgeProposal` an
operator (or auto-merge bot) can review and apply through the
existing `applyKnowledgeWriteBlocks` pipeline.
Subject grammar parsed (stamped in the analyst-kind prompts):
agent-knowledge:wiki:<page-slug> → create-page
agent-knowledge:wiki:<page-slug>#<heading> → append-section
agent-knowledge:claim:<topic> → create-claim (draft)
agent-knowledge:raw:<source-id> → lift-raw
agent-knowledge:stale:<page-slug> → mark-stale
Anything else (websearch:outdated:*, tool-doc:*, system-prompt:*,
memory:*) returns `null` — those loci aren't knowledge-base concerns
and the loop's improvement-applier (next PR, agent-runtime) handles
them. A knowledge-base subject that's malformed throws
`KnowledgeProposalParseError` rather than skipping — analyst-prompt
bugs fail loud, not silent.
API:
proposeFromFinding(finding): KnowledgeProposal | null
proposeFromFindings(findings): { proposals, skipped, errors }
Proposal id is stable per finding (`prop-${finding_id}`) so cross-run
diffs share an identity — proposing the same finding twice returns
the same proposal. `metadata` carries severity / confidence /
evidence_uri / analyst_id so reviewers see the source.
Markdown rendering:
- create-page emits frontmatter (title, status: draft,
drafted_from_finding, confidence) + body with H1 + rationale +
recommended-action sections
- append-section emits an H2 with the heading + inline H3
subsections so the appender doesn't clobber existing prose
- lift-raw and mark-stale emit their own canonical templates with
sourceId / supersedes pointers
Slugs are sanitised (lowercase, [^a-z0-9-] → -, trimmed to 200 chars)
so the existing `isSafeKnowledgePath` allow-list accepts the writes.
Tests (12 passing, plus 64 inherited green = 76 total):
- null for non-knowledge subjects (websearch / tool-doc / system-
prompt / memory / missing)
- each of the five wiki kinds round-trips path + content
- claim refs map AnalystFinding.evidence_refs → ClaimRef shape
- malformed `agent-knowledge:wiki:` throws KnowledgeProposalParseError
- unknown kind throws KnowledgeProposalParseError
- proposal id stable across re-runs
- unsafe slug characters sanitised
- batch helper partitions proposals / skipped / errors
Bumps `@tangle-network/agent-eval` peer to `^0.28.0` (AnalystFinding +
typed kinds shipped there in #56).
0f6808d to
0d671f6
Compare
3 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.
Closes piece 2/3 of the self-improvement loop (analysis → wiki bridge).
What this adds
proposeFromFinding(finding)turns a knowledge-shaped analyst finding into a typedKnowledgeProposalan operator (or auto-merge bot) can review and apply through the existingapplyKnowledgeWriteBlockspipeline.Subject grammar (analyst-side convention, stamped in kind prompts)
agent-knowledge:wiki:<page-slug>create-pageagent-knowledge:wiki:<page-slug>#<heading>append-sectionagent-knowledge:claim:<topic>create-claim(draft)agent-knowledge:raw:<source-id>lift-rawagent-knowledge:stale:<page-slug>mark-staleAnything else (
websearch:outdated:*,tool-doc:*,system-prompt:*,memory:*) returnsnull— those aren't knowledge-base concerns and the loop's improvement-applier handles them. A knowledge-base subject that's malformed throwsKnowledgeProposalParseError(fail loud, never silently skip an analyst-prompt bug).API
Proposal id is stable per finding (
prop-${finding_id}) so cross-run diffs share an identity.12 added tests; 76 total pass; typecheck clean.
Coordinated PRs
proposeFromFindingconsumes the typed findings)runAnalystLooporchestrator (wires thisproposeFromFindingsas theKnowledgeAdapter)Bumps
@tangle-network/agent-evalto^0.28.0.