refactor(flow): replace Phase 5 step with Cadre subflow primitive#179
Open
refactor(flow): replace Phase 5 step with Cadre subflow primitive#179
Conversation
Replace the manual FlowRunner.run() inside executeIterativeMigration() with the framework's declarative subflow() node, which was added in @cadre-dev/framework v0.2.1. migration-flow.ts: - Import subflow from @cadre-dev/framework/flow - Replace step() for 'iterative-migration' with subflow() that uses a flow thunk to dynamically build the Phase 5 child flow - contextMap identity-maps MigrationFlowContext to the child - Shared mutable _phase5RunnerOpts ref populated by the thunk before the runner reads it (per runner execution contract) - Remove unused fromStep, PhaseResult imports migration.ts: - Extract discoverTasks() and sortTasksSccAware() helpers - Export buildPhase5Subflow() — task discovery, SCC-aware sort, cost projection, and child flow construction (per-task or wave-barrier) - Export computePhase5Concurrency() and computePhase5RunnerOptions() - Remove executeIterativeMigra- Remove executeIterativeMigra- Remove executeIterativeMigra- RemovTerminalExhaustionError imports Tests: - Replace al- Replace al- Replace al- Replace al- Replace al- Replace al- Rlpers th- Replace al- Replace al- Replace al- Replace al- Replace al- Rte as- Replace al- Replace al- (.su- Replace al- to FlowRunResult (.status)
503e1af to
f0f1222
Compare
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
Replace the manual
FlowRunner.run()insideexecuteIterativeMigration()with the framework's declarativesubflow()node from@cadre-dev/framework. Phase 5's iterative migration is now expressed as a first-class child flow in the pipeline DSL rather than an opaque step that internally spawns its own runner.Motivation
executeIterativeMigrationwas astep()that internally built aFlowDefinition, instantiated its ownFlowRunner, and managed checkpoint/concurrency manually — exactly the patternsubflow()was designed to replace. Withsubflow(), the parent flow's runner manages the child flow lifecycle, checkpoint propagation, abort signal forwarding, and error handling automatically.Changes
src/flow/migration-flow.tsstep()for'iterative-migration'withsubflow()using aflowthunkbuildPhase5Subflow()and populates runner options (checkpoint adapter + concurrency) before executioncontextMapidentity-mapsMigrationFlowContext(same type for parent and child)fromStep,PhaseResultimportssrc/flow/steps/migration.tsdiscoverTasks()andsortTasksSccAware()as internal helpersbuildPhase5Subflow()— task discovery, SCC-aware sort, cost projection, and child flow construction (per-task or wave-barrier)computePhase5Concurrency()andcomputePhase5RunnerOptions()executeIterativeMigration()— no longer neededTests
executeIterativeMigration()calls with localrunPhase5()helpers that callbuildPhase5Subflow()+FlowRunner.run()directlyPhaseResult(.success/.phase) toFlowRunResult(.status)Verification
tsc --noEmit— cleanexecuteIterativeMigrationin the codebase