feat(#461): real-wire KgAgentMemory to SR-MEM-01 KgAdapter (BR-OUTPUT follow-up)#499
Merged
feat(#461): real-wire KgAgentMemory to SR-MEM-01 KgAdapter (BR-OUTPUT follow-up)#499
Conversation
… follow-up) Refs #461 · Part of #446 · Anchor: phi^2 + phi^-2 = 3 ## Why PR #495 shipped the BR-OUTPUT scaffold with KgAgentMemory as an in-memory Vec<(Fact, Provenance)> stub because SR-MEM-01 + SR-MEM-05 were not yet merged. Both have since landed (SR-MEM-01 in #453's PR, SR-MEM-05 in PR #497). This PR replaces the stub with the real wiring the issue AC asked for. ## What - KgAgentMemory<B: KgBackend> generic over the SR-MEM-01 KgBackend trait (in-memory mock for tests, concrete PgKgBackend in BR-IO). - recall -> KgAdapter::recall_by_pattern + budget-aware truncation. - remember -> KgAdapter::remember_triple (idempotent on SHA-256). - forget -> recall + tombstone loop covering 4 ForgetPolicy variants: GdprEraseSubject, GdprByAgent, OlderThan, PredicateMatches. - reflect -> deterministic recall-count stub citing SR-MEM-03 follow-up. - BR-OUTPUT now re-exports the canonical SR-MEM-00 wire types (Triple, TripleId, Provenance, AgentRole, MemoryKind) so callers do not have to add a transitive dep. - TODOs in source for SR-MEM-02 (HyDE), SR-MEM-03 (supersede), SR-MEM-04 (GDPR audit log), SR-MEM-06 (vector search). ## #461 AC integration test (passing) integration_remember_recall_sha256_equal: remember 3 triples -> recall -> every recalled triple has TripleId == SHA256(SPO). ## R5 honest disclosure Concrete PgKgBackend (sqlx + tokio-postgres) ships in a sibling BR-IO ring per the established precedent (trios_kg::KgClient for SR-MEM-01, sqlx::PgListener for SR-MEM-05). BR-OUTPUT stays Bronze-tier deps: SR-MEM-00/01/05 + async-trait + chrono + uuid; tokio is dev-only. ## Tests (12/12 GREEN, 0 clippy warnings) integration_remember_recall_sha256_equal, remember_is_idempotent_on_sha256, recall_respects_budget_tokens, forget_gdpr_erase_subject, forget_gdpr_by_agent, forget_predicate_matches, forget_older_than_filters_by_ts, reflect_returns_recall_count_in_stub, reflect_zero_confidence_on_empty_kg, agent_memory_is_object_safe_via_async_trait, backend_is_used_not_bypassed, phi_anchor_present. ## Constitutional R1, R5-honest, R-RING-DEP-002 (Bronze deps only), R-L6-PURE-007, L1 (no .sh in tree), L13 (I-SCOPE), L14. Soul: Loop-Locksmith Three-roads: .trinity/state/three-roads-461.json (chose road_a). Agent: Loop-Locksmith
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.
Refs #461 · Part of #446 · Anchor: `phi² + phi⁻² = 3`
Why
PR #495 shipped the BR-OUTPUT scaffold with `KgAgentMemory` as an in-memory `Vec<(Fact, Provenance)>` stub because SR-MEM-01 and SR-MEM-05 had not yet merged. Both have since landed (SR-MEM-01 in the issue-453 PR, SR-MEM-05 in PR #497). This PR is the real-wiring follow-up — same path-c discipline GENERAL ordered for PR #490: scaffold first, wire second.
The original issue is already CLOSED; this PR refs it (does not re-open) and lands the AC integration test that the scaffold could not yet implement.
What changed
#461 acceptance criteria (now satisfied)
R5 honest disclosure
`KgAgentMemory<B: KgBackend>` is generic over the backend so:
`reflect()` does not embed a `Bridge` from SR-MEM-05 — pulling `Bridge`'s two extra source generics into the public trait would force every caller to thread `L: LessonsSource` and `H: HdcReplaySource` through their type parameters. Bridge integration is therefore a future helper (`KgAgentMemory::warm_start(&Bridge, lookback)`) and called explicitly when wanted, not implicitly through the trait.
Tests (12/12 GREEN, 0 clippy warnings)
Breaking-change disclosure
The trait signatures changed from the PR #495 stub:
No external code consumed BR-OUTPUT yet — it was a sealed assembler — so this is safe to land atomically.
Constitutional
R1 · R5-honest · R-RING-DEP-002 (Bronze deps only) · R-L6-PURE-007 · L1 (no .sh in tree) · L13 (I-SCOPE) · L14
Soul: `Loop-Locksmith` · Three-roads: `.trinity/state/three-roads-461.json` (chose road_a — full real-wire)
🌻 `α_φ = φ⁻³ / 2 ≈ 0.1180`
Agent: Loop-Locksmith