Skip to content

S21: wire knowledge records into repo memory (SHIP_KNOWLEDGE_PROVENANCE=shadow|on) - #51

Merged
im-tyler merged 2 commits into
mainfrom
claude/w4-knowledge-wiring
Oct 4, 2026
Merged

im-tyler merged 2 commits into
mainfrom
claude/w4-knowledge-wiring

Conversation

@im-tyler

@im-tyler im-tyler commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Changes

  • New src/knowledge-store.ts: KnowledgeStore with in-memory, file (<state>/knowledge-records/*.jsonl) and Nucleus (NEW table ship_knowledge_records, CREATE TABLE IF NOT EXISTS, no migration, no ALTER) implementations. Provenance is a sidecar keyed by noteId; existing notes/rows are untouched.
  • New src/knowledge-provenance.ts: SHIP_KNOWLEDGE_PROVENANCE (off default | shadow | on), KnowledgeProvenance (recordNote, recordSummary, screen via visibleTo + freshness, redact via redactionPlan/applyRedactionPlan). Project is optional ("" = repo-only, since repoKeyOf is repo-only); documented in the header.
  • ScopedRepoMemory: optional provenance arg; record strips the hint and writes a hypothesis record (run as source); recent(..., {context}) screens only context reads (dashboard listing never filtered); remove(id, repo?) redacts derived records.
  • loadRepoContext: with mode != off resolves git rev-parse HEAD and labels notes (fresh|stale|unknown) only in on.
  • condenseIfNeeded: optional observe-only onSummary; durable records summaries as derivation:'summary', agent-claim, derivedFrom = injected note ids, idempotent by id.
  • durable publish note passes the pushed sha as revision only when mode != off. Dashboard Knowledge delete passes repo. runtime.ts builds the store only when mode != off.
  • Shadow: writes records, logs one JSON line per context retrieval (knowledge-provenance: wouldHide, wouldLabel, unrecorded); never changes retrieved context.

Checks

  • lint clean; root dist tests 2069/2069 (after merging main); web 165/165 + web build OK; scripts (excluding grader-sensitivity and pj-b-deploy-recovery, fixed port 8901) 117 pass, 1 skip.
  • 25 new tests (stores x3 contract, off byte-identical, shadow identical to off, on filtering/labels, fail-closed, redaction cascade, summary not evidence, real durable repo run with identical step sequence).
  • Negative controls (mutate, watch fail, restore): on ignoring visibility (7 fail), redaction skipping cascade (3), off still writing (1), unresolved head reported fresh (2), on failing open on store error (1), shadow returning screened list (1).

Not verified / still open

  • No live Nucleus (fake only); no verified-outcome. Freshness is coarse (head vs pushed sha: most older notes read stale).
  • Summary derivedFrom is exact only on first execution (replay keeps the first record). Legacy notes have no record: shown as unknown in on.
  • cli.ts notes get no revision hint. Embedding/export derivations have no producer yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VqsBNqvaWezf1DwQrAnVgX


Generated by Claude Code

claude added 2 commits October 4, 2026 03:23
…NCE (S21)

Sidecar provenance records (new ship_knowledge_records table / knowledge-records dir)
written alongside notes; shadow logs what retrieval would hide or label without
changing context; on hides invalidated/unverifiable notes and labels
fresh|stale|unknown. Run-publish notes record the run as source; condenser
summaries record as derivation:summary with derivedFrom; Knowledge delete
redacts derived records. Default off: no store built, nothing written.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VqsBNqvaWezf1DwQrAnVgX
@im-tyler
im-tyler merged commit c02cc61 into main Oct 4, 2026
4 checks 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.

2 participants