Skip to content

feat(memory): add structured provenance metadata#141

Merged
BunsDev merged 1 commit into
mainfrom
feat/memory-provenance
Jul 7, 2026
Merged

feat(memory): add structured provenance metadata#141
BunsDev merged 1 commit into
mainfrom
feat/memory-provenance

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds structured memory provenance metadata and compact per-entry provenance rendering for durable auto-extracted memories and hosted candidates.
  • Extends hosted review memory artifacts to include memory ids plus file-level and per-entry provenance.
  • Bumps the headless contract to v3 for the required review memory provenance fields.

Context

Changes

  • Introduced MemoryProvenance with structured fields, compact rendering, frontmatter population helpers, and secure git context capture for session-memory extraction.
  • Changed memory candidates and session-memory persistence APIs to carry structured provenance instead of free-form strings.
  • Added hosted review artifact provenance reporting and updated headless v3 schema, fixtures, and docs.
  • Added tests for structured provenance persistence, candidate JSON round-trip, hosted provenance trust gating, URL secret stripping, and artifact provenance output.

Validation

Record exact commands and outcomes. Mark items N/A with a reason when they do not apply.

  • git diff --check — passed after rebase, exit 0.
  • cargo fmt --all — passed after rebase, exit 0.
  • cargo check --workspace — passed after rebase, exit 0.
  • cargo clippy --workspace --all-targets -- -D warnings — passed after rebase, exit 0.
  • cargo test --workspace — not run; targeted package tests covered touched Rust surfaces per issue instructions.
  • Targeted/manual checks:
    • cargo test --package claurst-query -- session_memory — 26 passed, 0 failed.
    • cargo test --package claurst-core -- claudemd memdir — 57 passed, 0 failed.
    • cargo test --package claurst -- headless — 40 passed, 0 failed.
    • Code review subagent — final blocker-only review reported no significant issues.
  • Not run: full workspace tests; scoped validation used because the requested checks and touched tests are targeted.

PR Readiness

  • Diff is limited to the intended files.
  • Generated files were not edited by hand.
  • User-facing docs/help were updated or are not needed.
  • No secrets, credentials, local paths, or unrelated logs are included.
  • Remaining risks or follow-up work are listed above.

fixes #106

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 13:30
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 7, 2026 1:30pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a structured MemoryProvenance record to replace ad-hoc provenance strings across session-memory extraction, hosted review memory candidates, and headless review artifacts, and bumps the headless contract to v3 to require provenance fields in review memory reporting.

Changes:

  • Add MemoryProvenance (structured fields + compact rendering) and extend memory frontmatter parsing/formatting to carry repository/commit/actor/session metadata.
  • Update session-memory persistence and hosted memory candidate JSON to store structured provenance, including best-effort git context capture.
  • Extend headless review artifacts/schema/docs to report memory IDs plus file-level provenance and inline per-entry provenance strings; bump contract to v3.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src-rust/crates/query/src/session_memory.rs Switch candidates and persistence APIs to MemoryProvenance; add frontmatter injection + provenance rendering in durable entries; add tests.
src-rust/crates/query/src/lib.rs Capture git/actor context to build structured provenance for session-memory extraction; add origin parsing tests.
src-rust/crates/core/src/claudemd.rs Add structured provenance type + new frontmatter fields; extend hosted prompt rendering and trust gating tests.
src-rust/crates/cli/tests/headless_contract/session-brief.schema.json Bump contract version constant to v3.
src-rust/crates/cli/tests/headless_contract/session-brief.example.json Update example to contract v3.
src-rust/crates/cli/tests/headless_contract/result.schema.json Bump to v3 and require provenance fields for review memory entries.
src-rust/crates/cli/tests/headless_contract/result.example.json Update example to contract v3.
src-rust/crates/cli/src/main.rs Update headless contract-version test fixtures to v3.
src-rust/crates/cli/src/headless.rs Bump contract constant; include structured provenance fields and inline provenance extraction in review artifacts; update tests.
docs/headless-contract.md Document contract v3 and the new memory provenance fields; add migration note.
docs/configuration.md Update memory-candidate and frontmatter docs to describe structured provenance and what is (not) stored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +664 to +667
let after_first = &existing[3..];
let Some(end) = after_first.find("\n---") else {
return format!("---\n{rendered_pairs}\n---\n{existing}");
};
Comment on lines +2104 to +2107
let memory_provenance = build_session_memory_provenance(
&session_id_clone,
&working_dir_clone,
);
@BunsDev
BunsDev merged commit d2edbd0 into main Jul 7, 2026
4 checks passed
@BunsDev
BunsDev deleted the feat/memory-provenance branch July 9, 2026 06:30
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.

Add provenance metadata to every memory entry

2 participants