Skip to content

Refactor runtime resolution pipeline to Effect-based immutable state transitions#97

Open
danielbdyer wants to merge 1 commit into
mainfrom
codex/refactor-resolution-pipeline-and-phases
Open

Refactor runtime resolution pipeline to Effect-based immutable state transitions#97
danielbdyer wants to merge 1 commit into
mainfrom
codex/refactor-resolution-pipeline-and-phases

Conversation

@danielbdyer
Copy link
Copy Markdown
Owner

Motivation

  • Move the runtime resolution pipeline into the repository-wide Effect model so pipeline phases can be composed declaratively and tested as Effects.
  • Eliminate in-place mutations (Object.assign, accRef.current) and surface an immutable pipeline state to improve reasoning and enable pure state transitions.
  • Replace thrown generic errors with typed, tagged error values for clearer failure classification during DAG validation and strategy-totality checks.

Description

  • Change runResolutionPipeline and internal runPipelinePhases to return an Effect.Effect instead of Promise, and adapt the runtime wrapper to call Effect.runPromise when invoking the pipeline.
  • Introduce immutable value objects PipelineState and PipelineProgress carrying stage, accumulator, and emittedEvents, and replace mutable stage updates with pure transition helpers mergeStage, withInterpretation, and appendReceiptEvent.
  • Model each phase as a function from PipelineProgressEffect and fold the phases using Effect.reduce; replace the prior imperative strategy chain/accumulator mutation with runStrategies composed from Effect-returning attempts.
  • Add typed tagged error classes PipelineDagValidationError and StrategyTotalityError for DAG validation and missing-rung failures respectively, preserving existing precedence checks and event emission semantics.
  • Update tests and callers to execute the new Effect-returning API via Effect.runPromise, and add law-style determinism tests that assert identical receipts and event ordering for representative overlay and needs-human fallback scenarios.

Testing

  • Ran typecheck with npm run types and the build/type projection succeeded.
  • Ran focused test suite with npm test -- tests/runtime-agent-pipeline.spec.ts tests/precedence.laws.spec.ts tests/resolution-engine-contract.spec.ts tests/phase5-intent-interpretation.laws.spec.ts and all tests passed (31 passed).
  • New law-style determinism tests were added and executed as part of the run to assert stable receipt and event ordering for representative scenarios.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant