Skip to content

refactor(durably): move scope middleware wiring into durably()#172

Open
taras wants to merge 1 commit intofeat/durablyfrom
refactor/durably-scope-wiring
Open

refactor(durably): move scope middleware wiring into durably()#172
taras wants to merge 1 commit intofeat/durablyfrom
refactor/durably-scope-wiring

Conversation

@taras
Copy link
Member

@taras taras commented Feb 26, 2026

Motivation

durably() already installs reducer middleware on its scope, but scope lifecycle middleware was installed indirectly inside DurableReducer.installScopeMiddleware(). This split middleware wiring across two modules and made the entrypoint/setup boundary less clear.

The halt-related tests were also relying on immediate halt after spawn in a few places, which can halt a task before it reaches suspend().

Approach

  • Refactor DurableReducer.installScopeMiddleware() into createScopeMiddleware(runScope) that returns the same scope middleware handlers while keeping reducer lifecycle/replay logic encapsulated.
  • Install scope middleware explicitly in durably() with scope.around(api.Scope, ..., { at: "max" }), so durably() owns all scope wiring.
  • Keep root scope registration/recording behavior inside the reducer middleware factory.
  • Update halt tests to spawn durable operations and yield once before halting so tasks reliably reach suspend().
  • Skip the known test for finally-on-halt error propagation pending upstream Effection behavior fix.
  • Include current local effection override updates in package.json and pnpm-lock.yaml from the working tree state.

Move scope middleware installation out of DurableReducer side effects and into durably(), so the entrypoint owns all scope wiring while DurableReducer continues to own lifecycle/replay logic.

Also update halt-related tests to spawn durably operations with an explicit startup yield before halting, and skip the known finally-on-halt assertion until the upstream Effection bug is fixed.
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/durably-scope-wiring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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