Skip to content

Add Threadnote primitives#51

Merged
Kashkovsky merged 4 commits into
mainfrom
polygraph-vs-threadnote-features
Jul 2, 2026
Merged

Add Threadnote primitives#51
Kashkovsky merged 4 commits into
mainfrom
polygraph-vs-threadnote-features

Conversation

@Kashkovsky

Copy link
Copy Markdown
Owner

Summary

Adds the Threadnote-native parts from the Polygraph feature-gap analysis: richer handoff metadata, read-only memory references, pre-compact trace capture, named multi-repo worksets, and seeded dependency-facts resources.

Detail

  • Adds references: frontmatter plus pr:, issue:, and ci: handoff fields; recall resolves referenced memories one hop and share publish strips personal provenance.
  • Adds best-effort PreCompact trace distillation, with full-intent scrubber checks before truncation and capped tail reads for large transcripts.
  • Adds manifest worksets: plus CLI/MCP recall expansion across named project sets.
  • Adds threadnote seed --graph to generate plain .graph.md resources from deterministic package.json and go.mod facts, with sibling-project [[links]].
  • Keeps graph projection/query/UI out of scope; .graph.md remains a normal resource in the existing manager Resources tree.
  • Hardens review-found edge cases: explicit workset typos fail before recall searches, init-manifest preserves worksets, graph cache filenames are safe, and regex escaping handles *.

Test plan

npx vitest run test/unit/memory.recall.test.ts
npx vitest run test/unit/manifest.worksets.test.ts test/unit/seeding.test.ts test/unit/trace.test.ts test/unit/graph.test.ts test/unit/utils.test.ts
npm run lint
npm run typecheck
npm test
npm run build
graphify update .

Dev-cycle re-review: .context/dev-cycle/iter-5/summary.json reported 0 blocking findings.

Phase 1 of the Polygraph gap plan — memory-native pieces that need no
harness. Two additions layered onto the existing markdown memory model:

- References (G2): a new one-way, read-only `references:` relation parallel
  to `supersedes:`/`archived_from:`. Emitted by all three formatMemoryDocument
  copies, parsed back by parseMemoryDocument via a multi-value headerValues
  reader, validated (viking:// + deduped) in buildHandoff and the store MCP
  tool. Recall resolves the pointers one hop, reads each referenced memory
  read-only from the local store, and appends a short excerpt (bounded, cap 5,
  missing refs degrade gracefully). Stripped from shared copies at publish.
  Surfaced via `threadnote handoff --reference <uri>` (repeatable) and the
  `references` field on remember_context/store.

- Review-state snapshot (G3): buildHandoff now records the exact HEAD `commit:`
  and optional caller-supplied `pr:`/`issue:`/`ci:` lines. These are captured
  strings, not a live status board — Threadnote has no GitHub client.
  Surfaced via `threadnote handoff --pr/--issue/--ci`.
…ksets

Phase 2 of the Polygraph gap plan — two adjacent extensions of the memory
layer, still no harness.

- Auto-captured trace (G1): the Claude PreCompact hook now reads its JSON stdin
  payload (session_id, transcript_path) and distills the transcript into a
  short, heuristic trace (event count, tools used, recent intents) via the new
  src/trace.ts. buildHandoff appends `session_id:` and a scrubbed `trace:` block
  to the existing auto-precompact handoff — no new episode entity. Capture is
  fully best-effort: TTY/empty stdin, unreadable transcript, unstable format, or
  a secret blocker all fall back to the prior state-only handoff, and nothing
  throws out of the hook (compaction must not block). The trace is run through
  the existing share scrubber (redact mode) before it is written.

- Worksets (G4): a named set of related manifest projects recalled as one
  working set. New `worksets:` manifest block (parsed strictly in manifest.ts),
  resolveWorkset/inferWorksetFromQuery resolvers, and a recall expansion in both
  runRecall (CLI) and runRecallTool (MCP) that pushes a durable + seeded scope
  pass per member (deduped, capped at MAX_WORKSET_PASSES; the existing merge
  dedupes hits). Surfaced via `threadnote recall --workset <name>`, the
  `workset` field on recall_context, and read-only `threadnote workset
  list`/`show`. Semantic recall only; exact-match tail stays single-project.
Phase 3 of the Polygraph gap plan — the memory-native kernel of cross-repo
dependency indexing (G5). The graph projection engine, a `graph` query
command/MCP tool, and a UI are deliberately deferred: recall over the seeded
`[[project]]` links covers the kernel, and building the query surface would
turn the memory layer into a graph product.

- New src/graph.ts (pure, tested): extractDependencyFacts parses declarative
  manifests — npm package.json and go.mod only, so edges are deterministic and
  never guessed (Cargo/TOML deferred rather than risk wrong edges). resolveGraphEdges
  maps deps to sibling projects by published name; buildGraphDocument renders a
  plain-Markdown resource with `provides:`, `ecosystems:`, `manifests:`, and
  in-workspace `[[project]]` edges.
- seeding.ts seedDependencyGraphs (behind `threadnote seed --graph`): extracts
  facts for every manifest project so cross-repo edges resolve even under
  --only, then seeds a `<project.uri>/.graph.md` resource per target. Stored as
  a plain resource (no MEMORY/kind header), and — since synthesized content has
  no source path — routed through the same detectSecretMatches scanner every
  seeded file passes before it can reach OpenViking.
- Documented worksets + the --graph resource in the example manifest.
@Kashkovsky Kashkovsky marked this pull request as ready for review July 2, 2026 15:17
@Kashkovsky Kashkovsky changed the title Add Polygraph-inspired Threadnote primitives Add Threadnote primitives Jul 2, 2026
@Kashkovsky Kashkovsky merged commit b74d13d into main Jul 2, 2026
7 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.

1 participant