Skip to content

refactor: extract shared consolidation drain helpers to reduce duplication#67

Open
dnnspaul wants to merge 2 commits intoMAnders333:mainfrom
dnnspaul:refactor/extract-consolidation-drain-helper
Open

refactor: extract shared consolidation drain helpers to reduce duplication#67
dnnspaul wants to merge 2 commits intoMAnders333:mainfrom
dnnspaul:refactor/extract-consolidation-drain-helper

Conversation

@dnnspaul
Copy link
Copy Markdown
Contributor

Summary

  • Adds process-inbox CLI command that runs the full pipeline (upload → consolidate → synthesize) in one shot
  • Extracts the duplicated consolidation drain loop, embedding check, and KB synthesis pass into shared helpers in src/commands/consolidation-drain.ts
  • Refactors both consolidate and process-inbox commands to use the shared helpers, eliminating ~80 lines of duplicated logic

Details

The consolidation drain loop (lock acquisition with timeout, batch processing, error handling) and the KB synthesis pass were copy-pasted between consolidate.ts and process-inbox.ts. This PR extracts three reusable functions:

  • runEmbeddingCheck(activation) — non-fatal embedding model consistency check
  • drainConsolidation(consolidation) — full drain loop with lock timeout, returns aggregate stats
  • runSynthesisPass(consolidation) — locked synthesis with non-fatal error handling

The server-side runConsolidationDrain in index.ts is intentionally left as-is — it has different semantics (shutdown-aware, exponential backoff, logger vs console).

Verification

  • tsc --noEmit — clean
  • biome check — clean on all changed files
  • bun test — 498 pass, 1 pre-existing failure (config-file test, unrelated)

…ation

Add process-inbox command and extract the consolidation drain loop,
embedding check, and KB synthesis pass into reusable helpers in
consolidation-drain.ts. Both consolidate and process-inbox commands
now delegate to these shared functions instead of duplicating ~80
lines of identical lock-acquire/batch/synthesis logic.
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