Skip to content

fix(embeddings): persist model cache outside node_modules - #179

Open
HengYangDS wants to merge 5 commits into
obra:mainfrom
HengYangDS:fix/persistent-model-cache
Open

HengYangDS wants to merge 5 commits into
obra:mainfrom
HengYangDS:fix/persistent-model-cache

Conversation

@HengYangDS

@HengYangDS HengYangDS commented Sep 26, 2026 •

Copy link
Copy Markdown

Fixes #173. npm updates can remove embedding model files kept under node_modules, forcing another download. This stores the cache under Episodic Memory's durable configuration directory, with an absolute cache override and explicit offline mode passed through the existing Codex MCP allowlist.

Initialization preserves the host's existing local/remote loading restrictions. Offline mode only denies remote downloads; it never enables a permission the host disabled. The BGE model, q8 dtype, query prefix, output dimensions, lazy failure handling and thread controls stay intact. Sync reports errors without a misleading success headline and retains its exit semantics.

Transformers.js configuration is process-global. Hosts sharing that module must coordinate cache and permissions; this does not provide concurrent per-model isolation. The exact Transformers.js 4.2.0 constraint is a bounded compatibility choice. A later version needs its own model/ABI qualification.

Validation

Head: fedc911d4842aac6982f58ed8ab357617baf63d9; base: 7e06519357777badd7a115d2014a7ef845904310.

On macOS arm64, Node 24.19.0 (ABI 137), native npm and declared Vitest 3.2.7, six permission regressions failed before the correction. The final focused gate passed 22 tests; the full suite passed 371 tests across 66 files, including packaged MCP tests.

Seven actual-model regressions cover seeded offline loading, native host denial, empty/partial offline refusal with zero fetches, and fixture-transport recovery. Separate public Hub witnesses downloaded an empty cache in eight fetches and restored a missing ONNX file in two. Both produced finite normalized 384-dimensional embeddings with matching model-file hashes. The installation used a warmed package cache; it is not a cold package-network guarantee.

Native build output changes only the intended cache/initialization sections of the MCP bundle. Unrelated dependency churn was removed without hand-editing vendor code. Earlier socket-path and test-assertion failures remain retained; no host signing policy was changed.

Hosted Linux/Windows, later Node/Transformers versions, merge and installed-user acceptance remain pending. The existing workflow approval request on #180 covers this PR.

AndrewSpell added a commit to AndrewSpell/episodic-memory that referenced this pull request Oct 10, 2026
@HengYangDS

HengYangDS commented Oct 10, 2026 •

Copy link
Copy Markdown
Author

CI for this embedding cache location fix still awaits approval. The request on #180 has the current head and run link. Local validation remains in this PR’s description; hosted execution and installed use are unverified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant