Remove code duplication across storage, hooks, and error handling#139
Merged
gvonness-apolitical merged 1 commit intomainfrom Feb 22, 2026
Merged
Conversation
- Extract sqlPlaceholders() utility in db.ts, replace 20 occurrences across 9 files - Extract errorMessage() utility in errors.ts, replace 20 occurrences across 8 files - Delegate insertChunk to insertChunks and createEdge to createEdges - Consolidate hook CLI logic into shared ingestionHookCli() in hook-utils.ts - Update test mocks to use importOriginal pattern for partial mocking
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
sqlPlaceholders()utility indb.ts, replacing 20 inlineids.map(() => '?').join(', ')occurrences across 9 fileserrorMessage()utility inerrors.ts, replacing 20 inlineerror instanceof Error ? error.message : String(error)occurrences across 8 filesinsertChunk→insertChunksandcreateEdge→createEdgesto eliminate duplicated SQL logic in chunk-store and edge-storeingestionHookCli()inhook-utils.ts, deduplicating session-end and pre-compact CLI entry pointsSkipped log-level filtering extraction (~5 lines, different architectural layers) and config validation consolidation (operates on different types) as marginal value.
20 files changed, 143 insertions, 168 deletions (net -25 lines)
Test plan
npm run build— TypeScript compiles cleanlynpm test— All 2053 tests passnpm run lint— Zero errors, zero warningsnpm run format:check— Full Prettier compliancetest/hooks/pass unchanged (mocks updated to importOriginal pattern)