Skip to content

feat(flow): upgrade to @cadre-dev/framework 0.2.0 type-safe APIs#172

Merged
jafreck merged 2 commits intomainfrom
feat/cadre-framework-0.2.0
Mar 15, 2026
Merged

feat(flow): upgrade to @cadre-dev/framework 0.2.0 type-safe APIs#172
jafreck merged 2 commits intomainfrom
feat/cadre-framework-0.2.0

Conversation

@jafreck
Copy link
Owner

@jafreck jafreck commented Mar 15, 2026

Summary

Upgrades AAMF flow infrastructure to use @cadre-dev/framework 0.2.0 type-safe APIs, replacing workarounds from the 0.1.0 era.

Changes

WU1: Type-safe FlowRunner options

  • Replace Record<string, unknown> + as any cast with FlowRunnerOptions<MigrationFlowContext>
  • Restore onNodeStart/onNodeComplete/onNodeSkip hooks (now typed in 0.2.0)
  • Pass signal: this.abortController.signal for external cancellation support
  • KB server starts incrementally after Phase 0 via onNodeComplete hook
  • Phase completion tracking (checkpoint.completePhase, progress.updatePhase) fires per-node, not batch post-flow

WU2: Explicit dependsOn edges

  • Add dependsOn to every non-root node in the migration flow
  • Phase ordering is now explicitly declared via DAG edges

WU3: DataRef for Phase 1 to 5 handoff

  • Create TaskGraphOutput interface extending PhaseResult
  • Add fromStep("task-graph-construction") input to the iterative-migration step
  • 3-tier fallback: DataRef, then phase1TaskGraphResult, then filesystem

WU4: Nested FlowRunner for Phase 5

  • buildPerTaskFlow() builds a per-task nested flow with substep nodes (migrate, commit, parity, build, test, complete)
  • buildWaveBarrierFlow() builds a wave-barrier nested flow with parallel branches, convergence loops, and commit barriers
  • computeTopologicalWaves() groups tasks into dependency-ordered waves via Kahn's algorithm
  • Phase5CheckpointAdapter stores nested flow checkpoint under typed __phase5FlowCheckpoint field
  • Substep functions extracted: runMigrateSubstep, runCommitSubstep, runParitySubstep, runParityGateSubstep, runMinorRepassSubstep, runFormatSubstep, runBuildSubstep, runTestSubstep
  • Wave lifecycle events preserved (wave-started, wave-completed, wave-barrier-entered, wave-barrier-released)
  • completedTaskCount derived from flowResult.completedExecutionIds for accurate metrics
  • runWaveEndQualityGates fires after nested flow for non-enforce quality policies
  • __flowCheckpoint and __phase5FlowCheckpoint added to CheckpointState type (eliminates unsafe Record<string, unknown> casts)
  • queue parameter made optional in runCommandWithRecovery (was already unused in body)

Verification

  • npx tsc --noEmit — clean
  • npx vitest run — 1475 passed, 177 skipped, 0 failed

jafreck added 2 commits March 15, 2026 02:09
- Replace Record<string,unknown> + as-any cast with FlowRunnerOptions<T>
- Add explicit dependsOn edges to all non-root flow nodes
- Add TaskGraphOutput type and fromStep DataRef for phase1→5 handoff
- Create Phase5CheckpointAdapter for nested flow checkpoint
- Extract 7 substep functions from monolithic executeTask()
- Build per-task and wave-barrier flows via framework DSL
- Replace manual hasPhase5Substep/markPhase5Substep with framework checkpoint skip
- Add computeTopologicalWaves (Kahn's algorithm) for wave grouping
- Add convergence-check step to raise terminal exhaustion on wave failure
- Export Phase5CheckpointAdapter and TaskGraphOutput from flow module
- Update flow-dsl, step-phase-5, and step-phase-5-wave tests
- Restore onNodeStart/onNodeComplete/onNodeSkip hooks in runtime.ts
  so KB server starts after Phase 0, phase completion is tracked
  incrementally, and logger.setPhase() sets context per node
- Re-add signal: this.abortController.signal to FlowRunnerOptions
- Fix completedTaskCount to count actual completions from flow result
- Restore runWaveEndQualityGates call after nested flow completes
- Re-emit wave lifecycle events (wave-started, wave-completed,
  wave-barrier-entered, wave-barrier-released) in buildWaveBarrierFlow
- Add __flowCheckpoint and __phase5FlowCheckpoint to CheckpointState
  type; remove unsafe Record<string, unknown> casts in adapters
- Replace inline import() type with proper TaskGraphOutput import
- Update tests to use typed checkpoint state fields
@jafreck jafreck merged commit 404db39 into main Mar 15, 2026
1 check passed
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