Skip to content

feat(memory): W1 — TinyCortex adapter seam (facade, config + embedding adapters)#4526

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:tinycortex/w1-seam
Jul 5, 2026
Merged

feat(memory): W1 — TinyCortex adapter seam (facade, config + embedding adapters)#4526
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:tinycortex/w1-seam

Conversation

@senamakel

@senamakel senamakel commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

  • W1 of the TinyCortex memory migration — scaffold the adapter seam src/openhuman/tinycortex/, mirroring src/openhuman/tinyagents/. Engine logic stays in the crate; this module adapts crate traits over OpenHuman services.
  • Activates the tinycortex dependency (patched to the vendored submodule, now at the merged native-dep-alignment commit 33dda94, tinycortex#59).
  • Lands the facade + the three compute-seam adapters (config, embeddings, chat) with unit tests. No behaviour flips — nothing routes through the crate yet; this is the linked-and-compiling foundation.

Scope (what's in W1 vs deferred)

The seam splits into two groups:

  • Compute seams (this PR): self-contained LLM/embedding compute the crate injects (it "never makes a network call"). All pass-through adapters over existing host services, unit-tested now:
    • config.rsConfigMemoryConfig
    • embeddings.rsEmbeddingProviderEmbeddingBackend + Embedder
    • chat.rsmemory::chat::ChatProvider → crate ChatProvider (via openhuman::inference). This also covers entity extraction: the crate builds LlmEntityExtractor directly from a ChatProvider.
  • Deferred to their workstreams (they wire to real store/tree/queue/ingest crate calls that don't exist host-side yet, so building them now would be throwaway stubs):
    • LLM Summariser impl → W5 (only exercised at seal time; the crate ships ConcatSummariser/fallback_summary as the inert default).
    • sinks.rs (TreeJobSink/TreeLeafSink/SnapshotItemSource/EntityOccurrenceIndex) → W3/W7.
    • queue_driver.rs (QueueDelegates + worker loop) → W4.
    • bus.rs (engine outcomes → DomainEvent) → alongside the flips that emit them.

Solution

  • mod.rs — facade with the ownership-boundary module doc + pub use tinycortex::memory::{…} re-exports (MemoryTaint, MemoryEntry, RecallOpts, …). This is the type-unification decision from spec §0.5 (re-export over From) so 30+ consumer import paths stay stable as internals flip. MemoryTaint was proven byte-identical (fail-closed to ExternalSync) in Phase 0.
  • config.rsmemory_config_from(&Config, workspace) -> MemoryConfig: embedding dim/model/strict from config.memory / config.memory_tree; tree/retrieval/sync_budget default to crate values that match the host engine constants (pinned by a unit test).
  • embeddings.rsSeamEmbedder wraps one Arc<dyn EmbeddingProvider> and implements both EmbeddingBackend (vector store) and Embedder (retrieval / seal scoring). Near-pure pass-through; signature() delegates to the provider for byte-identical embedding-space signatures (Per-(row, model) embedding storage for memory_tree + event_log + segments #1574).
  • chat.rsSeamChatProvider wraps the host memory::chat::ChatProvider and implements the crate ChatProvider; only conversion is ChatPrompt.temperature f64→f32. build_chat_provider(&Config) returns a crate provider directly.
  • chore(vendor) — submodule bumped to 33dda94 (merged tinycortex#59), version pin in lockstep.

Submission Checklist

  • Tests added — config (mapping + tree-default parity guard), embeddings (metadata/signature pass-through + batch/single embed), chat (prompt conversion + delegation)
  • Diff coverage ≥ 80% — each adapter carries unit tests in this PR; mod.rs is re-export shims + a doc; the vendor bump is a pointer
  • Coverage matrix updated — N/A: additive seam scaffolding, no user-facing feature yet
  • All affected feature IDs listed — N/A
  • No new external network dependencies — the crate injects compute; makes no network calls
  • Manual smoke checklist updated — N/A: no release-cut surface touched
  • Linked issue closed — N/A: tracks plan #4513

Impact

  • Runtime: none yet — nothing routes through the crate. Behaviour flips begin at W3 (store) behind the golden-workspace parity harness.
  • Build: the crate links in the root world (cargo check --lib clean); one bundled SQLite + one libgit2 confirmed via tinycortex#59.
  • Security: re-exports MemoryTaint from the crate — proven identical fail-closed semantics in Phase 0; the dedicated taint seam test lands in W2.

Related


AI Authored PR Metadata

Commit & Branch

  • Branch: tinycortex/w1-seam

Validation Run

  • Focused tests: cargo test --lib openhuman::tinycortex:: (config + embeddings + chat)
  • Rust check: cargo check --manifest-path Cargo.toml --lib exit 0; new files rustfmt-clean

Validation 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-verify per repo policy

Behavior Changes

  • None — additive seam, nothing routes through the crate yet

Parity Contract

senamakel added 2 commits July 4, 2026 23:58
…ycortex#59)

Moves the submodule to the merged upstream commit 33dda94 so the host links one
bundled SQLite + one libgit2 and can activate the `tinycortex` dependency.
Pairs with the version pin in Cargo.toml.

Claude-Session: https://claude.ai/code/session_01JUTPftwppzuj3TnAnLhi4a
…ding adapters

First slice of the memory-engine migration seam (src/openhuman/tinycortex/),
mirroring src/openhuman/tinyagents/. Engine logic stays in the crate; this
module adapts crate traits over OpenHuman services.

- Activate `tinycortex = "0.1"` (patched to the vendored submodule).
- mod.rs: facade with the ownership-boundary module doc + `pub use
  tinycortex::memory::{…}` re-exports (MemoryTaint et al.) — the type-unification
  decision from spec §0.5, so consumer import paths stay stable as internals flip.
- config.rs: `memory_config_from(&Config, workspace) -> MemoryConfig` — embedding
  dim/model/strict from config.memory / config.memory_tree; tree/retrieval/
  sync_budget default to crate values that match the host engine constants
  (pinned by a unit test).
- embeddings.rs: SeamEmbedder wraps Arc<dyn EmbeddingProvider> and implements
  both EmbeddingBackend (vector store) and Embedder (retrieval/seal). Near-pure
  pass-through; signature() delegates to the provider for byte-identical
  embedding-space signatures (tinyhumansai#1574).

Compiles clean (cargo check --lib exit 0) with the dep active + submodule at the
merged tinycortex#59. Remaining adapters (chat/summariser, sinks, queue_driver,
bus) land in follow-up W1 commits.

Claude-Session: https://claude.ai/code/session_01JUTPftwppzuj3TnAnLhi4a
@senamakel senamakel requested a review from a team July 5, 2026 00:01
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f174d87-1601-4f44-b94d-ece44d1153de

📥 Commits

Reviewing files that changed from the base of the PR and between 556192d and 085274b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml
  • src/openhuman/mod.rs
  • src/openhuman/tinycortex/chat.rs
  • src/openhuman/tinycortex/config.rs
  • src/openhuman/tinycortex/embeddings.rs
  • src/openhuman/tinycortex/mod.rs
  • vendor/tinycortex

Comment @coderabbitai help to get the list of available commands.

… crate ChatProvider

SeamChatProvider wraps the host memory::chat::ChatProvider (routed through
openhuman::inference: provider selection, credit metering, usage accounting) and
implements the crate's ChatProvider. Near-pure pass-through; the only conversion
is ChatPrompt.temperature f64 (host) -> f32 (crate). build_chat_provider(&Config)
gives callers a crate ChatProvider directly — the entry point the engine's LLM
entity extractor / summariser construct from.

Test: crate->host prompt conversion + delegation. cargo check --lib exit 0.

Claude-Session: https://claude.ai/code/session_01JUTPftwppzuj3TnAnLhi4a

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cd2bed56c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +83 to +84
async fn embed(&self, text: &str) -> anyhow::Result<Vec<f32>> {
self.provider.embed_one(text).await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep TinyCortex tree embeddings at 1024 dims

When this adapter is used through TinyCortex's Embedder path, it forwards the host provider's vector unchanged, but the submodule revision pinned by this commit still has TinyCortex's score embedding dimension at 768 while the current OpenHuman memory tree and default cloud provider use 1024 (src/openhuman/memory_tree/score/embed/mod.rs). With the default config, migrated ingest/seal calls will produce 1024-dimensional vectors for a crate path that validates/packs 768-dimensional tree embeddings, so rows will fail to persist once this seam is wired. Pin a TinyCortex revision with the same fixed dimension or keep a tree-specific adapter that enforces the crate's expected dimension.

Useful? React with 👍 / 👎.

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.

1 participant