Repository navigation
Conversation
Two fixes:
1. importFromContent() silently swallowed all embedding errors with
`catch { /* non-fatal */ }`, making it impossible to diagnose why
vector search returned poor results. Now logs a warning with the
error message.
2. embedPage() used find() + indexOf() per chunk to map embeddings
back, resulting in O(n²) complexity. Replaced with a Map lookup
matching the pattern already used by embedAll() in the same file.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Included in fix wave PR #65 (v0.9.1). O(n²) chunk lookup fix landed. Clean, surgical fix. Thanks sharziki! 🙏 |
garrytan
added a commit
that referenced
this pull request
Oct 16, 2026
…nable/complete/disable under the source lock (#7 #27 #16 #17), restore marks read purge-mirror's fields (#8), backfill outside drift (#15), read-only drift scan (#24), bounded routine scans (#28), one stale-preparation code (#29), ambient source (#37), lifetime cut (#41) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
importFromContent()instead of silently swallowing themfind()+indexOf()with Map lookup inembedPage(), matching the pattern already used byembedAll()in the same fileDetails
1. Silent embedding failure (
src/core/import-file.ts)importFromContent()had a barecatch { /* non-fatal */ }that swallowed all embedding errors — API rate limits, auth failures, timeouts, network issues. Pages got imported without embeddings but the user had no indication why vector search was returning poor results.Now logs:
The error is still non-fatal (page import continues without embeddings), but at least the user knows what happened and can run
gbrain embed --staleto fix it.2. O(n²) chunk lookup (
src/commands/embed.ts)embedPage()usedtoEmbed.find()+toEmbed.indexOf()for every chunk to map embeddings back — two linear scans per chunk. Replaced with a singleMap<number, Float32Array>lookup, matching the patternembedAll()already uses 30 lines below in the same file.Test plan
bun test— 0 failures)import-file.test.tstests pass🤖 Generated with Claude Code