Skip to content

Remove code duplication across storage, hooks, and error handling#139

Merged
gvonness-apolitical merged 1 commit intomainfrom
cleanup/phase-2-duplication-removal
Feb 22, 2026
Merged

Remove code duplication across storage, hooks, and error handling#139
gvonness-apolitical merged 1 commit intomainfrom
cleanup/phase-2-duplication-removal

Conversation

@gvonness-apolitical
Copy link
Contributor

Summary

  • Extract sqlPlaceholders() utility in db.ts, replacing 20 inline ids.map(() => '?').join(', ') occurrences across 9 files
  • Extract errorMessage() utility in errors.ts, replacing 20 inline error instanceof Error ? error.message : String(error) occurrences across 8 files
  • Delegate insertChunkinsertChunks and createEdgecreateEdges to eliminate duplicated SQL logic in chunk-store and edge-store
  • Consolidate hook CLI logic into shared ingestionHookCli() in hook-utils.ts, deduplicating session-end and pre-compact CLI entry points

Skipped 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 cleanly
  • npm test — All 2053 tests pass
  • npm run lint — Zero errors, zero warnings
  • npm run format:check — Full Prettier compliance
  • Hook tests in test/hooks/ pass unchanged (mocks updated to importOriginal pattern)
  • No new lint suppressions added

- 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
@gvonness-apolitical gvonness-apolitical merged commit 2b5a076 into main Feb 22, 2026
3 checks passed
@gvonness-apolitical gvonness-apolitical deleted the cleanup/phase-2-duplication-removal branch February 22, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant