Skip to content

Milestone knowledge capture: nomination inbox + binding prefilter - #39

Open
gmoon wants to merge 5 commits into
mainfrom
claude/agentic-memory-lattice-relation-ypr9te
Open

Milestone knowledge capture: nomination inbox + binding prefilter#39
gmoon wants to merge 5 commits into
mainfrom
claude/agentic-memory-lattice-relation-ypr9te

Conversation

@gmoon

@gmoon gmoon commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a lattice capture command group that surfaces lattice-worthy changes at git milestones (pre-commit, pre-push) without auto-writing the graph — the AI proposes typed nominations, a human accepts. This closes the "remember to remember" gap in lattice capture (today it relies on the agent choosing to run lattice add) while preserving curation discipline.

Design was captured in the lattice first (a thesis + five REQ-CAPTURE requirements), then implemented, per the repo's lattice-first workflow.

What's New

  • src/capture.rs — the deterministic core:
    • Binding-intersection prefilter (REQ-CAPTURE-002): intersects git-changed files with implementation bind paths and resolves affected requirements via satisfies edges. No model call — the cheap gate that decides whether AI nomination is even worth invoking.
    • Staging inbox (REQ-CAPTURE-001, -005): nominations live in lattice-inbox.yaml at the repo root, deliberately outside .lattice/. The graph is mutated only by explicit accept, which routes through the existing add_requirement/add_edge — the nominate-not-commit guardrail.
    • Library-level scan_bundle (agent contract), accept (materialization), and install_hooks (git hook generation), all unit-tested.
  • CLI (src/main.rs): lattice capture scan | add | list | show | accept | reject | gate | install-hooks.
  • Git hooks: non-blocking pre-commit scan; pre-push health --check hard gate + nomination review. Installer refuses to clobber unmanaged hooks without --force.

What's Changed

  • Extracted a shared diff::run_git_lines helper; capture and the health code-impact block now share one git-subprocess implementation (retires ~5 copies of the idiom).
  • CLAUDE.md: documented the new command group.

Lattice Impact

  • +1 source SRC-AGENT-MEMORY-HOOKS (Bratanic, Unified Agentic Memory Across Harnesses Using Hooks — the article that prompted this)
  • +1 thesis THX-MILESTONE-NOMINATION (draft; extends THX-CONTEXT-INFRA)
  • +5 requirements REQ-CAPTURE-001..005, all resolved verified
  • +5 implementations IMP-CAPTURE-001..005
  • lattice drift: clean · lattice health --strict --check: PASS

Testing

  • 7 capture unit tests (prefilter hit/miss, inbox roundtrip + outside-.lattice/ guardrail, id allocation, kind→edge mapping, accept guards, scan-bundle enrichment); 214 total tests pass
  • cargo fmt --check clean; clippy --all-targets -D warnings clean
  • End-to-end smoke: full add→accept→cleanup round-trips with zero residue in .lattice/; generated hooks validated with sh -n

Notes for reviewers

  • The AI judgment step in scan is intentionally agent-side; the Rust binary stays deterministic and never blocks a commit.
  • CI exercises the --all-features build (pulls the vector-search/ONNX dep); I couldn't run that path in the sandbox (network-blocked binary download), so it's unverified locally. Default-feature clippy/tests are green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T


Generated by Claude Code

claude added 5 commits July 17, 2026 23:12
Captures the design conversation on hook-based knowledge capture as
lattice nodes (design-first, before any code):

- SRC-AGENT-MEMORY-HOOKS: Bratanic's unified agentic memory article/repo
- THX-MILESTONE-NOMINATION: git milestones are higher-signal nomination
  points than session boundaries; capture should nominate, not auto-commit
  (extends THX-CONTEXT-INFRA)
- REQ-CAPTURE-001..005: staging surface, binding-intersection prefilter,
  pre-commit nominator, pre-push gate, nominate-not-commit guardrail

Implements REQ-CAPTURE-001 REQ-CAPTURE-002 REQ-CAPTURE-003
REQ-CAPTURE-004 REQ-CAPTURE-005 (as specifications; no code yet)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T
Adds a nomination pipeline that surfaces lattice-worthy changes at git
milestones without auto-writing the graph — the AI proposes, a human commits.

- src/capture.rs: deterministic binding-intersection prefilter (changed
  files → implementations → satisfied requirements, no model call), plus a
  staging Inbox held outside .lattice/ (load/save/add/remove nominations)
- lattice capture scan|add|list|show|accept|reject|gate|install-hooks
  wired in src/main.rs; accept materializes via existing add_requirement/
  add_edge, the only path that mutates the graph (guardrail)
- git pre-commit (non-blocking scan) and pre-push (health --check gate +
  nomination review) hook installer
- 5 unit tests (prefilter hit/miss, inbox roundtrip + outside-.lattice
  guardrail, id allocation, kind→edge mapping)

Recorded as IMP-CAPTURE-001..005; resolves REQ-CAPTURE-001..005; drift clean.

Implements REQ-CAPTURE-001 REQ-CAPTURE-002 REQ-CAPTURE-003 REQ-CAPTURE-004 REQ-CAPTURE-005

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T
Behavior-preserving cleanups from a 4-angle review of the capture code:

- Altitude: move nomination→graph materialization (accept), the agent
  scan bundle, and git-hook script generation out of the main.rs CLI
  handler into src/capture.rs, where they are unit-testable and sit with
  the pipeline they describe. handle_capture is now thin arg-marshalling.
- Efficiency: prefilter builds a single path→bindings index in one pass
  (was two passes + an id round-trip); accept loads/saves the inbox once
  (was a double read).
- Simplification: single Inbox::position() backs both get() and
  remove_nomination(); hook scripts use plain strings (no \x20 escapes).
- Consistency: capture reject routes errors through emit_error and gained
  --format, matching its sibling subcommands.

Adds accept-guard and scan_bundle unit tests. 214 tests pass; clippy -D
warnings clean; generated hooks validated with sh -n.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T
Collapses the "spawn git, collect non-empty stdout lines" idiom that was
duplicated in capture.rs (git_name_only) and the health command's
code-impact block into one public helper in diff.rs, next to the other git
helpers. capture's staged_files/changed_files_since and health's
changed-file detection now both call diff::run_git_lines.

Behavior-preserving; 214 tests pass, clippy -D warnings clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T
Entity resolution for the capture pipeline, adapted from knowledge-graph-
generation practice (dedup is a required post-processing stage there): at
'capture add' time, score the nomination's title+body against existing
nodes by token-overlap (Jaccard) and attach likely-duplicate IDs. list/show
surface them and add warns, so restatements of existing nodes reach the
reviewer flagged instead of silently entering the inbox. Deterministic first
pass; semantic dedup is a natural upgrade under the vector-search feature.

- src/capture.rs: find_duplicates + token_set/jaccard; Nomination gains
  possible_duplicates; unit test for hit + non-match
- src/main.rs: add handler computes/attaches duplicates and warns;
  list/show render them
- lattice: REQ-CAPTURE-003-A (refines REQ-CAPTURE-003), IMP-CAPTURE-006,
  resolved verified; drift clean, health PASS

Implements REQ-CAPTURE-003-A

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoEBdAc9emc4K3k3TfmX1T
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