embeddings: alternation patterns (a|b|c) skip the embedding daemon and fall back to lexical-only
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- search
Research direction
Start in src/hooks/grep-direct.ts and src/shell/grep-interceptor.ts, in patternIsSemanticFriendly and where it decides whether to call the embedding path (searchDeeplakeTables). Verify both copies match and that alternation handling is the same in each file before editing. Run the provided repro command with HIVEMIND_DEBUG=1 and inspect ~/.deeplake/hook-debug.log for summary_embedding <#> ARRAY activity. Completion is when the alternation query uses the embedding branch and the debug log shows embedding hits for paraphrase-style matches.
Written by the indexing model from the issue text.
Description
Severity
Medium-high — limits the embedding feature's main UX (synonym recall is exactly the case embeddings are designed for).
Where
src/hooks/grep-direct.ts:36-50—patternIsSemanticFriendlysrc/shell/grep-interceptor.ts:43-50— same function (duplicated)
Repro
On any workspace with embedding rows, ask Claude Code:
HIVEMIND_DEBUG=1 claude -p 'Search hivemind for sessions about silent data loss or concurrent-writer corruption. Use grep -r over the memory path.'
CC issues a Bash grep -r with an alternation pattern like silent data loss|data loss|concurrent writer|writer corruption|race condition|lost write. The debug log (~/.deeplake/hook-debug.log) shows zero summary_embedding <#> ARRAY[…] queries — only lexical ILIKE matches and path browses. CC's answer is correct only when the literal keywords match a summary; it misses paraphrases.
Root cause
patternIsSemanticFriendly rejects any pattern with more than 1 regex metacharacter, and | counts as a metacharacter:
const meta = pattern.match(/[|()\[\]{}+?^$\\]/g);
if (!meta) return true;
return meta.length <= 1;
When false, the dispatcher skips the embedding daemon call and searchDeeplakeTables runs the lexical-only branch.
But | is exactly the synonym-list use case where embeddings shine — different surface forms of the same concept. The original intent of the filter ("don't waste an embed call on regex like [a-z]+\.com") shouldn't reject synonym alternations.
Proposed fix
Drop | from the metacharacter blacklist + cap the alternative count to guard against pathological inputs:
function patternIsSemanticFriendly(pattern: string, fixedString: boolean): boolean {
if (!pattern || pattern.length < 2) return false;
if (fixedString) return true;
const meta = pattern.match(/[()\[\]{}+?^$\\]/g); // dropped `|`
if (meta && meta.length > 1) return false;
// Still gate on alternative count to avoid 50-element synonym blasts:
const altCount = pattern.split("|").length;
return altCount <= 8;
}
Apply to both grep-direct.ts and grep-interceptor.ts (or extract into a shared helper while we're at it).
Acceptance
After fix, the same repro prompt should produce ≥ 1 summary_embedding <#> ARRAY[…] query in the debug log, and CC's answer should include sessions matched by paraphrase (not just literal keyword).
Out of scope
- Recommending Grep tool over Bash grep in the SessionStart prompt (Bash grep already routes through
handleGrepDirect, which is the embedding path). - Removing the duplication between the two
patternIsSemanticFriendlydefinitions (separate refactor).
Found during the embedding_generation branch validation, see commits 4e956fa + f9f10f3.
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 107
- Avg merge
- 19h 25m
- Merged PRs (30d)
- 12
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from activeloopai/hivemind
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
activeloopai/hivemind#330 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
activeloopai/hivemind#200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
activeloopai/hivemind#184 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
activeloopai/hivemind#364 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 72/100
activeloopai/hivemind#361 · 1 comment ·
All issues in activeloopai/hivemind
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·