Skip to content

feat: zero-download semantic fallback — algorithmic embeddings + code-aware FTS tokenizer #169

Closed

Description

@cdeust

From the codebase-memory-mcp analysis (2026-07-25): they ship semantic search with ZERO model download — 11-signal algorithmic embeddings (TF-IDF, Random Indexing with co-occurrence synonym bridging, MinHash, API/type signatures, AST profile, graph diffusion, Halstead-lite; verified src/semantic/semantic.h) optionally seeded by static int8 token vectors compiled into the binary. No sentence-transformers, no Ollama, no first-run cliff.

Cortex's SQLite-mode installs currently degrade until sentence-transformers finishes installing (session-start note: 'semantic search will improve next session'). Proposal: an algorithmic-embedding fallback engaged automatically when the neural model is absent — same 384-dim space contract, marked lower-fidelity in telemetry, upgraded transparently when the model arrives. Plus: camelCase/snake_case-aware FTS tokenization for code-flavored memories (their cbm_camel_split FTS5 tokenizer).

Zetetic gate: benchmark the fallback on LongMemEval-S/LoCoMo vs (a) no-vector baseline and (b) sentence-transformers — publish the three-way numbers; adopt only if fallback beats no-vector materially. Done criteria: fresh SQLite install answers a semantic recall correctly with zero network; benchmark table committed.

Activity

  1. cdeust commented on Jul 24, 2026

    @cdeust
    OwnerAuthor

    Implementation delivered: PR #172 (d5835c0). Three-way benchmark committed (LongMemEval-S, SQLite, n=50): no-vector 0.275 MRR / 46.0% R@10 → algorithmic fallback 0.378 / 66.0% → sentence-transformers 0.609 / 94.0%. Adoption criterion met (+0.102 MRR, +20pp R@10 over no-vector). Constants sourced (CBM semantic.h / Manning IR / Mikolov 2013 / Achlioptas 2003); mixed-store no-cross-rank invariant tested; telemetry marks fallback mode. Reported deviations accepted as justified: dedicated SQLite bench harness reusing the existing loader/scorer verbatim (PG harness cannot express the 3-way), and two pre-existing §13 items now filed as dated issues (embedding_engine split; test_rebuild_profiles live-data dependency). Merge on CI green.

  2. cdeust commented on Jul 24, 2026

    @cdeust
    OwnerAuthor

    PR #172 denied (see closing comment). Plan of record: Phase A refactor PR (seams, closes #173) → Phase B full #169 on the refactored base. The n=50 three-way benchmark result (no-vector 0.275/46.0% → fallback 0.378/66.0% → sentence-transformers 0.609/94.0%) remains valid evidence for the approach and carries into Phase B.

  3. cdeust commented on Jul 24, 2026

    @cdeust
    OwnerAuthor

    Phase A delivered: PR #175 (three seams: EmbeddingProvider protocol, ModelState lifecycle machine, composition-root factory; closes #173). Key finding from the seam work: PR #172's empty-stamp bug was in the SQLite store's _has_vec-gated stamp write, not the engine — the boundary now has an explicit seam and Phase B maps every lifecycle state to a provider so no state can leave an empty stamp. Behavior preservation proven: 56-test embedding suite unchanged, full suite green except the 3 documented #174 failures. Merge on CI green, then Phase B.

  4. added a commit that references this issue on Jul 24, 2026
  5. cdeust commented on Jul 25, 2026

    @cdeust
    OwnerAuthor

    COMPLETE — delivered across two PRs per the refactor-first rule: PR #175 (Phase A: EmbeddingProvider protocol, explicit ModelState lifecycle, factory seams; closed #173) and PR #181 (Phase B, merged 0db6b2e with 14/14 checks): total ModelState→provider map (no state can leave an empty stamp — the PR #172 denial's root cause is structurally unrepresentable), unconditional SQLite embedding_model stamp, loud engagement + telemetry embedding_mode, camelCase/snake_case tokenization on ALL recall paths, scheduled fallback→neural upgrade in consolidate with counts, genuine-absence subprocess integration test (import-hook, zero network), mixed-store no-cross-rank invariant. Benchmark (LongMemEval-S, SQLite, n=50, MANIFEST committed): no-vector 0.275 MRR/46% R@10 → algorithmic fallback 0.378/66% (+0.102/+20pp, adoption criterion met) → sentence-transformers 0.609/94%. Zero-download semantic search is live for SQLite-mode installs.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions