Add Threadnote primitives#51
Merged
Merged
Conversation
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.
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.
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
references:frontmatter pluspr:,issue:, andci:handoff fields; recall resolves referenced memories one hop and share publish strips personal provenance.worksets:plus CLI/MCP recall expansion across named project sets.threadnote seed --graphto generate plain.graph.mdresources from deterministicpackage.jsonandgo.modfacts, with sibling-project[[links]]..graph.mdremains a normal resource in the existing manager Resources tree.init-manifestpreserves worksets, graph cache filenames are safe, and regex escaping handles*.Test plan
Dev-cycle re-review:
.context/dev-cycle/iter-5/summary.jsonreported 0 blocking findings.