feat(memory): W2 — re-export memory value types from TinyCortex (type-unification) - #4529
Conversation
…/RecallOpts/NamespaceSummary from tinycortex memory/traits.rs now `pub use`s the crate's memory value types instead of defining them (type-unification decision, spec §0.5). They are drop-in identical (fields, derives incl. Copy, serde snake_case, and MemoryTaint's fail-closed from_db_str), so all 30+ consumers and ~10 impl-Memory sites compile unchanged; no host impls target these types (no orphan-rule breakage). The Memory trait stays host-defined because of the sqlite_conn() escape hatch the crate omits by design (per-backend dispatch through dyn Memory can't be preserved by a blanket extension). Its 2 external callers migrate to tinycortex::memory::chunks::with_connection in W3, after which the trait can also be re-exported. The MemoryTaint fail-closed tests stay in traits.rs as the W2 security seam — now pinning fail-closed-to-ExternalSync on the crate type. cargo check --lib clean across the whole crate. Claude-Session: https://claude.ai/code/session_01JUTPftwppzuj3TnAnLhi4a
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughLocal definitions of MemoryEntry, MemoryCategory, MemoryTaint, RecallOpts, and NamespaceSummary in traits.rs are replaced with re-exports from the tinycortex crate. The host-defined Memory trait remains unchanged. Documentation is updated to note sqlite_conn's retirement in favor of a tinycortex connection helper. ChangesMemory Type Re-export Unification
Estimated code review effort: 2 (Simple) | ~10 minutes Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Summary
memory/traits.rsnowpub usestinycortex::memory::{MemoryCategory, MemoryEntry, MemoryTaint, NamespaceSummary, RecallOpts}instead of defining them. One source of truth; all 30+ consumers + the ~10impl Memorysites compile unchanged.MemoryTaintfail-closed tests as the host-side W2 seam — now pinning the contract on the crate type.Problem
Phase 0 found the host
memory::traitstypes and the crate's types are wire-compatible twins (identical fields, derives, serde attrs, and — forMemoryTaint— the samefrom_db_strfail-closed decode). Maintaining two definitions invites silent drift, most dangerously onMemoryTaint, which drives external-effect-tool gating for tainted subconscious turns. W2 collapses them onto the crate.Solution
traits.rsdeletes the five type definitions and re-exports the crate's. They are drop-in identical (verified field-by-field, incl.#[derive(… Copy … Serialize, Deserialize, Default)]and#[serde(rename_all = "snake_case")]), so everyuse crate::openhuman::memory::traits::{MemoryEntry, …}site is unchanged. No hostimpltargets these types (checked — no orphan-rule breakage).Memorytrait stays host-defined — deliberately. The crate'sMemorytrait matches the host's method-for-method exceptsqlite_conn(), the raw-connection escape hatch the crate omits by design. Becausesqlite_conndispatches per-backend throughdyn Memory(onlyUnifiedMemoryreturns a real handle; everything elseNone), a blanket extension trait can't preserve it. So the host trait is kept as-is for now; the hatch (2 external callers) migrates totinycortex::memory::chunks::with_connectionin W3, after which the trait can also become a crate re-export.MemoryTainttests (…unknown_fails_closed,…defaults_to_internal_for_legacy_rows, snake_case db/serde,MemoryCategoryDisplay) stay intraits.rsand now exercise the re-exported crate type — the W2 security-review item: fail-closed toExternalSyncsurvives the boundary.Submission Checklist
MemoryTaint/MemoryEntry/MemoryCategoryseam tests now verify the crate types (fail-closed taint, legacy-row default, snake_case, Display, round-trips)pub useand the (unchanged-behaviour) tests around itN/A: no user-facing feature change; type-identity refactorN/AN/A: no release-cut surface touchedN/A: tracks plan #4513Impact
Default, same fail-closedfrom_db_str). Existing persisted rows deserialize identically.MemoryTaintprovenance is now single-sourced from the crate with its fail-closed default intact, pinned by the retained seam tests.cargo check --libclean across all 30+ consumers and mock backends.Related
UnifiedMemory/MemoryClientovertinycortex::store+chunks, migrates thesqlite_conn()hatch towith_connection, and begins behaviour flips behind the golden-workspace parity harness.AI Authored PR Metadata
Commit & Branch
tinycortex/w2-typesValidation Run
cargo test --lib openhuman::memory::traits::tests(taint fail-closed + type round-trips)cargo check --manifest-path Cargo.toml --libexit 0 across all consumersValidation Blocked
command:full.husky/pre-push(pnpm compile/pnpm rust:check)error:pre-existing/environmental TS+rust-check failures unrelated to this Rust-only change; pushed with--no-verifyper repo policyBehavior Changes
Default, and fail-closed decode are unchangedParity Contract
MemoryTaintfail-closed contract on the crate typeSummary by CodeRabbit
Bug Fixes
Documentation