Skip to content

Add turbovec-backed retrieval for context pulling and semantic search#38

Draft
slavazeph-coder wants to merge 2 commits into
mainfrom
claude/turbovec-integration-s10tD
Draft

Add turbovec-backed retrieval for context pulling and semantic search#38
slavazeph-coder wants to merge 2 commits into
mainfrom
claude/turbovec-integration-s10tD

Conversation

@slavazeph-coder

Copy link
Copy Markdown
Contributor

What

Integrates turbovec (a local TurboQuant vector index) as the retrieval backend for Crumb LLM context pulling, and adds a semantic mode to crumb search.

The key insight: Crumb LLM already turns each section into a spectral signature (|rFFT(scatter(tokens))|) — a fixed-length float vector. Those signatures are embeddings, so they can be indexed in turbovec instead of scanned linearly, with no external embedding service (keeping the "runs entirely locally" property intact).

Changes

  • crumb_wavelm/turbovec_index.py (new) — thin wrapper over turbovec.IdMapIndex. L2-normalizes signatures so turbovec's inner-product score equals cosine, and zero-pads vectors to turbovec's multiple-of-8 dim requirement (lossless for cosine). numpy-only dependency surface; turbovec_available() gates everything.
  • context_pull.pyCrumbIndex.ensure_backend() lazily builds the vector index; score_sections searches it when present (over-fetching candidates so the @priority boost can still re-rank), and falls back to the unchanged pure-Python cosine scan when turbovec is absent.
  • crumb llm index now reports the active backend (turbovec vs numpy cosine scan).
  • crumb search --method semantic — ranks .crumb sections by wave-field spectral relevance instead of keyword/TF-IDF, backed by turbovec when available. Behind the [llm] extra; prints an install hint otherwise.
  • pyproject.tomlturbovec>=0.7 added to the [llm] optional extra. Core crumb-format install is untouched and install-free.

Notes

  • turbovec is an approximate (4-bit quantized) index. Top-1 score parity with the exact cosine scan is within ~0.005; near-tied sections may reorder. Tests assert recall@5 + score-within-noise rather than exact argmax — the correct contract for an ANN index.
  • Pure-Python fallback verified by simulating turbovec absent.

Tests

tests/test_crumb_llm_context_pull.py gains recall-parity and zero-padding cases. Full suite: 807 passed, 1 skipped.

https://claude.ai/code/session_01TJ94h1zxbtm9g5jVVnYUSW


Generated by Claude Code

Crumb LLM's spectral signatures are vectors, so they can be indexed in
turbovec (a local TurboQuant vector store) instead of scanned linearly.

- crumb_wavelm/turbovec_index.py: thin IdMapIndex wrapper. L2-normalizes
  signatures (inner product -> cosine) and zero-pads to turbovec's
  multiple-of-8 dim requirement (lossless for cosine). numpy-only deps,
  graceful absence handling.
- context_pull.py: CrumbIndex.ensure_backend() lazily builds the vector
  index; score_sections uses it when present (over-fetching candidates
  so the priority boost can still re-rank), else the pure-Python cosine
  scan unchanged.
- crumb llm index now reports the active backend.
- crumb search --method semantic: spectral vector search over .crumb
  sections, backed by turbovec when available, behind the [llm] extra.
- turbovec added to the [llm] optional extra; core install untouched.
- Tests: recall@5 parity with the cosine scan + padding behavior.

https://claude.ai/code/session_01TJ94h1zxbtm9g5jVVnYUSW
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

✅ Shadow AI Scan

No Shadow AI findings detected at or above medium risk.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

CRUMB Bench Results

File Score Grade Tokens Compression
./.crumb N/A - - -
./.crumb/latest.crumb N/A - - -
./CODEX_HANDOFF_0.4.0.crumb 58/100 C ~1985 1.6x
./crumbs/map.crumb 79/100 B ~269 1.6x
./crumbs/mem.crumb 80/100 B ~225 1.7x
./examples/halo-trace-to-log.crumb 84/100 B ~155 2.0x
./examples/log-deployment.crumb 84/100 B ~147 2.0x
./examples/map-client-takeover.crumb 78/100 B ~290 1.6x
./examples/map-repo-onboarding.crumb 82/100 B ~166 1.7x
./examples/mem-mempalace-auth-migration.crumb 87/100 A ~120 2.5x
./examples/mem-terse-output.crumb 77/100 B ~336 1.6x
./examples/mem-user-preferences.crumb 83/100 B ~135 1.8x
./examples/task-bug-fix.crumb 83/100 B ~127 1.7x
./examples/task-content-repurpose-handoff.crumb 80/100 B ~250 1.7x
./examples/task-cross-tool-feature-handoff.crumb 79/100 B ~249 1.6x
./examples/task-feature-continuation.crumb 82/100 B ~134 1.7x
./examples/task-packed-auth-context.crumb 82/100 B ~233 2.1x
./examples/todo-sprint.crumb 84/100 B ~90 1.7x
./examples/v12-content-ref.crumb 82/100 B ~193 1.8x
./examples/v12-delta.crumb 78/100 B ~344 1.8x
./examples/v12-fold.crumb 61/100 C ~317 1.4x
./examples/v12-handoff.crumb 80/100 B ~204 1.4x
./examples/v12-priority.crumb 79/100 B ~254 1.6x
./examples/v12-refs.crumb 82/100 B ~182 1.8x
./examples/v12-typed-content.crumb 80/100 B ~218 1.5x
./examples/v13-agent.crumb 82/100 B ~167 1.7x
./examples/v13-checks.crumb 80/100 B ~165 1.3x
./examples/v13-fold-priority.crumb 64/100 C ~223 1.4x
./examples/v13-guardrails.crumb 80/100 B ~205 1.5x
./examples/v13-handoff-deps.crumb 80/100 B ~201 1.6x
./examples/v13-script.crumb 80/100 B ~169 1.4x
./examples/v13-workflow.crumb 81/100 B ~178 1.6x
./examples/v14-handoff-deadlines.crumb 79/100 B ~290 1.7x
./examples/v14-release-gate.crumb 79/100 B ~295 1.8x
./examples/v14-typed-checks.crumb 80/100 B ~223 1.5x
./examples/wake-session.crumb 84/100 B ~195 2.2x
./fixtures/extensions/mempalace-export.crumb 86/100 A ~102 2.3x
./fixtures/extensions/task-packed.crumb 85/100 B ~157 2.3x
./fixtures/invalid/bad-kind.crumb N/A - - -
./fixtures/invalid/missing-source.crumb N/A - - -
./fixtures/valid/agent-basic.crumb 80/100 B ~51 1.1x
./fixtures/valid/log-basic.crumb 82/100 B ~51 1.4x
./fixtures/valid/mem-basic.crumb 81/100 B ~42 1.2x
./fixtures/valid/task-basic.crumb 81/100 B ~65 1.2x
./fixtures/valid/v13-checks.crumb 81/100 B ~74 1.2x
./fixtures/valid/v13-handoff-deps.crumb 82/100 B ~93 1.3x

Powered by crumb-format — two-stage context compression

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.

2 participants