Skip to content

feat(#53): real local neural embedder for recall = local (offline semantic) - #54

Open
veltri-23 wants to merge 1 commit into
task/vibebloat-mvpfrom
veltri-23/local-embedder
Open

feat(#53): real local neural embedder for recall = local (offline semantic)#54
veltri-23 wants to merge 1 commit into
task/vibebloat-mvpfrom
veltri-23/local-embedder

Conversation

@veltri-23

Copy link
Copy Markdown
Owner

No description provided.

veltri-23 added a commit that referenced this pull request Jul 21, 2026
…nxruntime-web approach) (#69)

* feat(#53): real local neural embedder for recall = local (offline semantic)

* fix(#54): direct onnxruntime-web dep + lazy import + tsc clean

* feat(#53): real local neural embedder via node sidecar

recall = local now runs genuine offline semantic recall. Root cause of the
prior blocker (PR #54): forcing onnxruntime-web in-process gives Bun an empty
execution-provider list ("Unsupported device: cpu"), and the transformers web
build has no fs under Bun. Only the transformers *node* build + onnxruntime-node
under real Node produces vectors — so the Bun CLI shells out to a `node`
sidecar (embed-worker.mjs) for embeddings and stays on the fast path.

- embed-worker.mjs: node sidecar, stdin texts -> stdout MiniLM vectors, model
  cached under the guard home, offline after first pull.
- recall-local.ts: rewritten to embed via the sidecar; rips out the broken
  onnxruntime-web override. Degrades to [] / no-embedding on any failure.
- Per-backend warn threshold: cosine on short commands lands ~0.3, so the
  Jaccard-calibrated 0.5 never fires. localRecallWarnThreshold=0.25 (calibration
  knob documented). runtime uses adapter.warnThreshold ?? global.
- Hook wired to async recallAdvisory on the allow path for local/embed, so a
  paraphrase-level warning fires live where the sync lexical hot path can't.
- transformers moved to optionalDependencies; onnxruntime-web dep dropped.
- Tests: recall-local.test.ts ported to the Embedder injection API (11 pass);
  new recall-local-realmodel.test.ts drives the REAL model — a zero-shared-token
  paraphrase recalls the incident above threshold where lexical scores 0 (2
  pass), skips honestly if the model can't load.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#53): harden hook advisory — cheap mode gate + crash-proof close

Testing the real CLI hook surfaced two issues on the allow path:

1. Double-close crash: close() was called in both the try and the catch, and
   IncidentStore.close(true) throws on a locked handle — the second throw (from
   the catch) escaped and killed the hook with exit 1. Enforcement must never
   crash. Now closes exactly once in `finally` with a swallowed error.
2. Per-hook cost: every allow-path hook opened the incident store before
   checking the mode. Now gates on the config mode first (one existsSync +
   small TOML read); lexical/off/no-config returns before any SQLite I/O.

Verified end to end through `bun src/cli.ts hook`: local mode + a seeded
incident + a zero-shared-token paraphrase prints the recall advisory (exit 0);
unrelated commands and the default lexical path stay silent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(#53): isolate recall from hook enforcement

* fix: keep CLI usable without local recall deps

* fix(#69): bound local embed worker execution

* fix(#53): calibrate local recall warning threshold

* fix: harden embedding worker trust boundary

* test(#69): align live model gate with secure worker protocol

* chore: normalize PR 69 changed lines

* test(#69): make optional dependency smoke portable

* fix(#69): prefilter local recall false positives

* test(#69): exercise optional recall after prefilter

* test(#69): use relative GNU tar destination

* test: isolate situational guards from checkout state

* fix(#69): emit one recall warning per hook

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@veltri-23

Copy link
Copy Markdown
Owner Author

PR #54 vibebloat: feat(#53): real local neural embedder for recall = local (offline semantic)

  • author: veltri-23 · draft: no · age: 16d
  • checks: 6 failure, 1 skipped · updated 2026-08-06 15:52 UTC
    Open on GitHub

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