Skip to content

feat(propose): bridge AnalystFinding → KnowledgeProposal#9

Merged
drewstone merged 1 commit into
mainfrom
feat/propose-from-finding
May 19, 2026
Merged

feat(propose): bridge AnalystFinding → KnowledgeProposal#9
drewstone merged 1 commit into
mainfrom
feat/propose-from-finding

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

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 typed KnowledgeProposal an operator (or auto-merge bot) can review and apply through the existing applyKnowledgeWriteBlocks pipeline.

Subject grammar (analyst-side convention, stamped in kind prompts)

Subject → Proposal kind
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 aren't knowledge-base concerns and the loop's improvement-applier handles them. A knowledge-base subject that's malformed throws KnowledgeProposalParseError (fail loud, never silently skip an analyst-prompt bug).

API

proposeFromFinding(finding: AnalystFinding): KnowledgeProposal | null
proposeFromFindings(findings): { proposals, skipped, errors }

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

  • agent-eval: priorFindings (this PR's proposeFromFinding consumes the typed findings)
  • agent-runtime: runAnalystLoop orchestrator (wires this proposeFromFindings as the KnowledgeAdapter)

Bumps @tangle-network/agent-eval to ^0.28.0.

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).
@drewstone drewstone force-pushed the feat/propose-from-finding branch from 0f6808d to 0d671f6 Compare May 19, 2026 11:57
@drewstone drewstone merged commit e3c3df9 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