feat: add reuseKb option to preserve knowledge base across fresh starts#226
Merged
feat: add reuseKb option to preserve knowledge base across fresh starts#226
Conversation
When reuseKb is true and the migration starts fresh (not --resume), the checkpoint preserves KB-related state from the prior run: - Phase 0 (KB index): skipped via existing fingerprint guard - Phase 1 (task graph): completion marker carried forward - Phase 2 (knowledge-builder): completion marker carried forward - Flow checkpoint: KB step completions carried forward - Scaffold state: preserved to avoid re-scaffolding Everything else resets: planning, migration tasks, parity state, retries, token usage, and adjudication history. This lets users re-run migrations with changed guidance, config, or code without re-running the expensive knowledge-builder agent (~12+ min for large codebases). Also enables reuseKb in the zstd migration config fixture.
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.
Problem
Starting a fresh migration (not
--resume) always re-runs the knowledge-builder agent (Phase 2), which takes 12+ minutes for large codebases like zstd. When iterating on guidance, config, or migration strategy, the source code hasn't changed — the KB index and knowledge base are still valid and shouldn't need rebuilding.Solution
New config option
options.reuseKb(default:false). Whentrueand starting fresh:Everything else resets clean: planning (Phase 3), migration tasks (Phase 4), parity state, retries, token usage, and adjudication history.
Usage
{ "options": { "reuseKb": true } }Then run without
--resume:Logs:
Fresh start with reuseKb — preserved phases [0, 1, 2], resuming from Phase 3Changes
src/config/schema.ts— AddedreuseKboption with JSDocsrc/core/checkpoint.ts— Extendedload()to acceptreuseKb, addedloadPriorState()helper, logic to carry forward KB phases 0-2 while resetting everything else including flow checkpoint filteringsrc/core/runtime.ts— PassreuseKbthrough to checkpoint loadertests/core/checkpoint.test.ts— 3 new tests: reuseKb with prior state, reuseKb without prior checkpoint, fresh without reuseKbtests/fixtures/zstd-c-project/migration.config.json— EnabledreuseKb: trueTest Coverage
fresh start with reuseKb should preserve KB phases and reset everything elsefresh start with reuseKb but no prior checkpoint should start from scratchfresh start without reuseKb should ignore prior state entirelyAll 1505 tests pass.