# GATE 3 PRE-ANSWERED — DO NOT ASK AGAIN

Spec folder: `.opencode/specs/system-spec-kit/026-graph-and-context-optimization/014-local-embeddings-setup-a/022-local-llm-legacy-remediation`
Choice: A) Use existing spec folder

PROCEED DIRECTLY. Never ask Gate 3. Non-interactive --approval-policy=never.

---

# Batch 5 — Generated assets + test fixtures regeneration

CONTEXT (post-batches-1-4 state):
- Memory MCP hf-local default model is now `onnx-community/embeddinggemma-300m-ONNX` (768d, q8)
- CocoIndex sentence-transformers default is `google/embeddinggemma-300m` (768d, bf16)
- Voyage default in factory is `voyage-4` (1024d)
- OpenAI default in factory is `text-embedding-3-small` (1536d)
- Auto-cascade: VOYAGE_API_KEY -> OPENAI_API_KEY -> llama-cpp (when GGUF installed) -> hf-local
- All hardcoded `context-index.sqlite` paths replaced with profile-derived resolver
- ONNX runtime cleanup complete

This batch updates DERIVED assets (feature catalogs, manual testing playbooks) and TEST FIXTURES that still reference the OLD defaults (MiniLM, Nomic, 384-dim, etc.) to match the new ship state.

ALLOWED WRITE PATHS (touch ONLY these files; broad globs allowed under these dirs):
- `.opencode/skills/mcp-coco-index/feature_catalog/**/*.md`
- `.opencode/skills/mcp-coco-index/manual_testing_playbook/**/*.md`
- `.opencode/skills/mcp-coco-index/tests/test_config.py`
- `.opencode/skills/mcp-coco-index/tests/test_settings.py`
- `.opencode/skills/mcp-coco-index/references/tool_reference.md` (line ~400 MiniLM example)
- `.opencode/skills/system-spec-kit/feature_catalog/**/*.md`
- `.opencode/skills/system-spec-kit/manual_testing_playbook/**/*.md`
- `.opencode/skills/system-spec-kit/scripts/tests/test-embeddings-behavioral.js`
- `.opencode/skills/system-spec-kit/scripts/tests/test-embeddings-factory.js`
- `.opencode/skills/system-spec-kit/scripts/tests/memory-pipeline-regressions.vitest.ts`
- `.opencode/skills/system-spec-kit/scripts/tests/fixtures/manual-playbook-fixture.ts`
- `.opencode/skills/system-spec-kit/scripts/tests/test-utils.js`
- `.opencode/skills/system-spec-kit/mcp_server/tests/embeddings.vitest.ts`
- `.opencode/skills/system-spec-kit/mcp_server/tests/fixtures/sample-memories.json`
- `.opencode/skills/system-spec-kit/mcp_server/tests/fixtures/similarity-test-cases.json`

BANNED OPERATIONS:
- NO rm, NO mv, NO sed -i against any file
- NO git operations
- NO writes outside ALLOWED WRITE PATHS
- DO NOT touch the 021/022 packets
- DO NOT touch factory.ts, providers, profile.ts, or any code modified by batches 1-4
- DO NOT touch package.json files (batch 4 already handled)

REPLACEMENT RULES (apply consistently):

(A) Model identifiers:
   - `nomic-ai/nomic-embed-text-v1.5` -> `onnx-community/embeddinggemma-300m-ONNX`
   - `sentence-transformers/all-MiniLM-L6-v2` -> `google/embeddinggemma-300m`
   - `all-MiniLM-L6-v2` (standalone) -> `google/embeddinggemma-300m`
   - Reference to `MiniLM` as DEFAULT -> EmbeddingGemma 300m

(B) Dimensions:
   - `384[- ]?dim` or `384-dimensional` -> `768[- ]?dim` or `768-dimensional`
   - In MiniLM contexts: 384 -> 768
   - Voyage 1024 stays 1024
   - OpenAI 1536 stays 1536

(C) Generic sqlite filenames:
   - `context-index.sqlite` (when used as the default DB filename example) -> `context-index__hf-local__onnx-community_embeddinggemma-300m-onnx__768__q8.sqlite`
   - Or rewrite the surrounding prose to say "profile-derived filename (provider+model+dim+dtype-keyed)"
   - `context-index__voyage__voyage-4__1024.sqlite` references in disk-pressure / fresh-install fixtures -> describe the active hf-local default profile filename + note Voyage profile-specific filename exists only when VOYAGE_API_KEY is set

(D) Test fixture assertions:
   - `expect(profile.model).toBe('nomic-ai/nomic-embed-text-v1.5')` -> `expect(profile.model).toBe('onnx-community/embeddinggemma-300m-ONNX')`
   - `expect(MODEL_NAME).toBe('nomic-ai/nomic-embed-text-v1.5')` -> `expect(MODEL_NAME).toBe('onnx-community/embeddinggemma-300m-ONNX')`
   - `assert "all-MiniLM-L6-v2" in config.embedding_model` -> `assert "google/embeddinggemma-300m" in config.embedding_model`
   - `assertEqual(emb.MODEL_NAME, 'nomic-ai/nomic-embed-text-v1.5', ...)` -> `assertEqual(emb.MODEL_NAME, 'onnx-community/embeddinggemma-300m-ONNX', ...)`
   - Update the labels (e.g., "EB-003: MODEL_NAME is nomic default" -> "EB-003: MODEL_NAME is EmbeddingGemma default")

(E) Fixture content:
   - In `sample-memories.json`: `"Vector embeddings use 384 dimensions for semantic search"` -> `"Vector embeddings use 768 dimensions for semantic search"`
   - In `similarity-test-cases.json`: `"embeddingModel": "all-MiniLM-L6-v2"` -> `"embeddingModel": "google/embeddinggemma-300m"` (and `"dim": 384` -> `"dim": 768` if present in same record)

(F) Test-utils 384-dim helper:
   - `@returns {Array} 384-dimensional embedding vector` JSDoc -> `@returns {Array} 768-dimensional embedding vector`
   - If the helper hardcodes a 384-length array, update the array length to 768

(G) Feature catalog narrative:
   - "Default user settings use the local sentence-transformers provider and `all-MiniLM-L6-v2`" -> "Default user settings use the local sentence-transformers provider and `google/embeddinggemma-300m` (bf16, 768d)"
   - "The script targets the production memory database at `mcp_server/database/context-index.sqlite`" -> "The script targets the active Memory MCP database (profile-derived filename via shared/embeddings/profile.ts)"
   - References to ONNX backend probing in catalog entries -> remove (ONNX backend was rejected)

(H) Manual testing playbook:
   - Doctor-memory fresh-install: replace literal `mcp_server/database/context-index.sqlite` checks with profile-derived filename
   - Disk-pressure fixture: same
   - Long-pole-rebuild: same
   - SIGINT-cancellation: replace Voyage 1024 checksum fixture with hf-local EmbeddingGemma default DB

(I) Keyword metadata:
   - In SKILL.md keyword headers (if you reach any), drop MiniLM/voyage-code-3 as default-era anchors; add embeddinggemma
   - (But SKILL.md was handled in batch 2 — don't re-touch unless still in this batch's allow list; tool_reference.md is the one allowed here)

PRESERVE (do NOT change):
- Voyage cascade descriptions (correct per Q2=yes)
- Test assertions on Voyage/OpenAI behavior when API key is set
- Backward-compat test cases that explicitly test old-model handling (rare)
- Any 021/022 packet content
- Comments that document historical state (e.g., "previously default was MiniLM")

ACCEPTANCE CRITERIA:
- `rg 'all-MiniLM-L6-v2|nomic-ai/nomic-embed-text-v1\\.5' .opencode/skills/mcp-coco-index/{feature_catalog,manual_testing_playbook,tests,references} .opencode/skills/system-spec-kit/{feature_catalog,manual_testing_playbook,scripts/tests,mcp_server/tests}` returns 0 hits OR only intentional historical-context lines (must be marked in the report)
- `rg '"embeddingModel":\\s*"all-MiniLM-L6-v2"|"dim":\\s*384' .opencode/skills/system-spec-kit/mcp_server/tests/fixtures` returns 0 hits

AFTER ALL EDITS, output:

```
BATCH 5 REPORT
File: <path> — <N edits> — <one-line summary>
...
Intentional historical-context retained (path:line): <list>
Scope violations: <none | list>
Blocked writes: <none | list>
Total edits: <N>
```

Do NOT commit. Do NOT run git. Do NOT run vitest (main-agent will run post-batch). Stop after writing the report.
