Commit 637fc01
authored
refactor: extract embedder into src/embeddings/ subsystem (ROADMAP 3.10) (#433)
* refactor: domain error hierarchy replacing ad-hoc error handling (ROADMAP 3.8)
Add structured domain errors (CodegraphError base + 7 subclasses) to
replace the mix of process.exit(1), throw new Error, and console.error
scattered across library code.
- New src/errors.js with ParseError, DbError, ConfigError, ResolutionError,
EngineError, AnalysisError, BoundaryError
- Library code throws domain errors instead of calling process.exit(1)
- CLI top-level catch formats CodegraphError with [CODE] prefix
- MCP catch returns structured { isError, code } responses
- CLI commands use parseAsync() so async errors propagate
- CI gate commands (check, manifesto) use process.exitCode instead of exit
- All error classes exported from public API (src/index.js)
Impact: 52 functions changed, 215 affected
* fix: address Greptile review feedback on PR #431
- Use expect.assertions(4) in db.test.js to prevent silent assertion skips
- Change snapshot "already exists" error from DbError to ConfigError
(it's a missing --force flag, not a database failure)
Impact: 1 functions changed, 0 affected
* refactor: extract embedder.js into src/embeddings/ subsystem (ROADMAP 3.10)
Split the monolithic 1,100-line embedder.js into a modular subsystem with
clear separation of concerns: models, generator, strategies, stores, and
search modules. Uses a pluggable VectorStore JSDoc contract for future ANN
backends. Reuses existing db/repository/embeddings.js for search preparation.
All 9 consumer import paths updated, old file deleted.
Impact: 26 functions changed, 16 affected
* fix: address review feedback on embedder extraction
- Remove dead _cos_sim variable from models.js (greptile)
- Fix embedding-benchmark.js import path (greptile)
- Update workflow path filters and cache keys for new directory (greptile)
- Update stale file references in test comments and CLAUDE.md (greptile)
Impact: 1 functions changed, 1 affected
* fix: harden prepareSearch with try/catch for DB leak and use getEmbeddingCount
- Wrap post-open logic in try/catch so DB is closed on unexpected exceptions
- Switch from hasEmbeddings to getEmbeddingCount for clearer zero-count check
Impact: 1 functions changed, 0 affected
* fix: guard cosineSim against zero-magnitude vectors returning NaN
Return 0 instead of NaN when either vector has zero magnitude (e.g.
corrupted DB row). In practice embed() stores L2-normalised vectors,
but this makes the contract explicit.
Impact: 1 functions changed, 0 affected
* fix: add @internal JSDoc tags to non-public model helpers
Mark getModelConfig, promptInstall, and loadTransformers as @internal
since they are exported only for sibling module use, not the public barrel.
* fix: unexport initEmbeddingsSchema — only used within generator.js
Impact: 1 functions changed, 1 affected1 parent 6b0f44d commit 637fc01
28 files changed
Lines changed: 1166 additions & 1116 deletions
File tree
- .github/workflows
- scripts
- src
- cli/commands
- embeddings
- search
- stores
- strategies
- mcp/tools
- tests
- search
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments