Validate hosted CortexDB recall, then integrate it into TinyMemory and retire the embedded tinycortex engine
Description
Validate recall and the surrounding memory functionality against the hosted CortexDB engine (tinyhumansai/cortexdb-saas), then adopt it in TinyMemory as the engine, retiring the embedded tinycortex dependency.
Less of this is greenfield than it looks. tinymemory-remote/src/cortex_provider/ already adapts "CortexDB's native v1 experience, recall, and answer routes to TinyMemory's provider contracts", covering the mandatory key/value, recall and portability surface plus document, conversation, learning, raw-event and grounded-answer capabilities. A tinymemory-conformance crate with a suite and reference already exists as the vehicle for proving a provider equivalent. The work is to exercise that provider against the hosted service properly, then cut tinymemory-core over to it.
Repos: cortexdb-saas (Rust, private) · TinyMemory (vendor/tinymemory) · consumed by OpenHuman
Type: Migration task — the bug-report headings do not apply, so this uses Scope / Approach / Risks in their place
Current state
| Piece | Where | Status |
|---|---|---|
| Hosted engine + proxy, meter, credit gate | cortexdb-saas/src/{proxy,meter,scope,tenant,billing}.rs |
Exists; engine is a closed third-party binary (cortexdb/cortexdb, pinned by digest) |
| CortexDB provider for TinyMemory | tinymemory-remote/src/cortex_provider/ |
Exists — protocol translation in operations.rs, response validation in test.rs |
| Conformance suite | tinymemory-conformance/{suite,reference} |
Exists; the natural place to prove equivalence |
| Embedded engine being replaced | tinymemory-tinycortex/ adapter + direct tinycortex = { version = "0.1", features = ["obsidian","persona","people","sync"] } in tinymemory-core/Cargo.toml |
To retire |
| Coupling | 101 .rs files under crates/ reference tinycortex |
To assess — most should route through the adapter |
Scope
Phase 1 — prove the hosted engine. Run the conformance suite against a live cortexdb-saas deployment through CortexProvider, and establish parity with the embedded tinycortex reference for: recall (including recall_relevant_by_vector), key/value, portability, documents, conversations, learning, raw events, and grounded answers. Record recall quality and latency against the embedded engine, not just pass/fail.
Phase 2 — integrate and cut over. Make the hosted provider selectable in TinyMemory, then remove the direct tinycortex dependency from tinymemory-core and retire the tinymemory-tinycortex adapter.
Risks and open questions
- Scope enforcement is a known gap. The
cortexdb-saasREADME states that CortexDB v0.9.9 "does not enforce scope membership consistently", measured against a live engine, and documents which probes leak. The proxy compensates. Any conformance run must include cross-tenant and cross-scope probes so we are testing the boundary the proxy provides, not just the happy path. - Recall semantics may differ. The embedded engine and the hosted v1 recall routes are not guaranteed to rank identically. We need to decide whether parity means identical results or acceptable-quality results, and write that down before the cutover.
- Write semantics differ by design. Per the provider README, writes wait for CortexDB's indexed barrier and are attempted once because an ambiguous retry could duplicate an append; recall may retry. Behaviour under partial failure needs explicit coverage.
- Idempotency keys are payload-derived. Documents and conversation messages derive idempotency from their complete lossless payload, and CortexDB rejects a reused key with a different body as a conflict. Worth testing against real re-ingest and backfill paths.
- Network dependency. Memory becomes a network call. Offline and degraded-network behaviour needs a defined story — today the embedded engine cannot fail this way.
links = "git2".tinymemory-core/Cargo.tomlnotes that a tinycortex major-version conflict becomes a hard cargo error vialinks = "git2". Removing the dependency should relieve this, but check nothing else in the tree relies on that link.- Billing is now in the path. The credit gate and meter mean a recall can be refused for balance reasons. TinyMemory and its callers need to surface that distinctly from a genuine miss.
- Data migration. Whether existing embedded memory is migrated to the hosted engine, or the cutover applies to new data only, is undecided and affects every user with existing memory.
Acceptance Criteria
-
tinymemory-conformanceruns green against a livecortexdb-saasdeployment throughCortexProvider, covering key/value, recall, portability, documents, conversations, learning, raw events and grounded answers - Cross-tenant and cross-scope probes are part of that run, asserting the proxy denies what the engine does not
- Recall quality and latency are measured against the embedded
tinycortexreference and the results recorded on this issue; an explicit parity bar is agreed before cutover - Retry and partial-failure behaviour is covered: write-once semantics, recall retry, and idempotency-key conflicts on re-ingest
- A credit-gate refusal surfaces distinctly from an empty recall, end to end into OpenHuman
- Offline / unreachable-engine behaviour is defined and tested
-
tinymemory-coreno longer declarestinycortexas a dependency -
tinymemory-tinycortexis removed, or retained only as a documented fallback with a stated support horizon - A decision on migrating existing embedded memory is recorded, and implemented if the answer is yes
- OpenHuman builds and passes its memory E2E suite (
tests/memory_roundtrip_e2e.rs,tests/memory_sources_e2e.rs,tests/memory_graph_roundtrip_e2e.rs,tests/memory_tree_health_e2e.rs) against the hosted engine - Verified on an OpenHuman build after the cutover with memory persisting across a restart
Source: tinyhumansai/openhuman