refactor: extract shared consolidation drain helpers to reduce duplication#67
Open
dnnspaul wants to merge 2 commits intoMAnders333:mainfrom
Open
refactor: extract shared consolidation drain helpers to reduce duplication#67dnnspaul wants to merge 2 commits intoMAnders333:mainfrom
dnnspaul wants to merge 2 commits intoMAnders333:mainfrom
Conversation
…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.
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
process-inboxCLI command that runs the full pipeline (upload → consolidate → synthesize) in one shotsrc/commands/consolidation-drain.tsconsolidateandprocess-inboxcommands to use the shared helpers, eliminating ~80 lines of duplicated logicDetails
The consolidation drain loop (lock acquisition with timeout, batch processing, error handling) and the KB synthesis pass were copy-pasted between
consolidate.tsandprocess-inbox.ts. This PR extracts three reusable functions:runEmbeddingCheck(activation)— non-fatal embedding model consistency checkdrainConsolidation(consolidation)— full drain loop with lock timeout, returns aggregate statsrunSynthesisPass(consolidation)— locked synthesis with non-fatal error handlingThe server-side
runConsolidationDraininindex.tsis intentionally left as-is — it has different semantics (shutdown-aware, exponential backoff,loggervsconsole).Verification
tsc --noEmit— cleanbiome check— clean on all changed filesbun test— 498 pass, 1 pre-existing failure (config-file test, unrelated)