Skip to content

fix(durable): Start and Recover start a compound state's services and actors - #286

Merged
reka18 merged 2 commits into
mainfrom
fix/state-start-effects-compound
Dec 2, 2026
Merged

reka18 merged 2 commits into
mainfrom
fix/state-start-effects-compound

Conversation

@reka18

@reka18 reka18 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

What was wrong

Instance.StartEffects covered only the active leaves. When a Fire entered a compound state, its services and actors started, because the kernel's entry path emits every entered state's invokes. When Start cast into that state, or Recover resumed in it, they didn't start. So a durable instance that started in a compound state, or recovered into one, ran without that state's services and actors.

#234 tried this widening and reverted it, to keep state's v1 behavior unchanged inside that PR. This PR brings it back on its own.

What changed

  • state: StartEffects now reports every state the active configuration makes active: each leaf and its compound and parallel ancestors, in entry order, each state once. ResumeEffects stays leaves-only, and its doc says why: a snapshot can't say which of a compound state's invokes already settled into one of its children.
  • durable: the widened StartEffects flows through Start and Recover. A compound state's service that settled lands in the checkpoint's EndedServices, and its ended actors land in EndedActors, the same as a leaf's. Recover's rule for unstarted and ended actors covers them too.
  • Tests:
    • Unskips the four fix(durable): don't journal a step whose context ended partway #234-era tests, each shown failing first. Before the fix, Start didn't spawn a superstate's actor, a settled compound service wasn't found in flight, the compound's actor wasn't spawned for a delivery, and Recover never retried a compound's unstarted actor.
    • Adds a pin for a compound state's ended actor landing in EndedActors. Recover leaves it ended whether it reads the journal, a checkpoint, or a checkpoint taken by a recovered Handle.
  • Removes durable/older_checkpoint_compound_test.go: those two tests pinned a guard for checkpoints written before the journal recorded ended services and actors. fix(durable): don't journal a step whose context ended partway #234 added that guard and then reverted it along with the widening. durable is greenfield, so this PR doesn't bring back an older-checkpoint gate.

How it's tested

  • In state and durable: go build, go test -race ./..., and golangci-lint with CI's config. All pass.
  • examples/fooddelivery and examples/dispatch both call StartEffects, and both pass.

Fixes #249

StartEffects covered the active leaves only, so a service or actor
declared on a compound state started when a Fire entered that state -
the kernel's entry path emits every entered state's invokes - but not
when a host cast into it or resumed in it. It now reports every state
the active configuration makes active, each leaf and its compound and
parallel ancestors, in entry order, each state once.

ResumeEffects stays leaves-only: a snapshot can't say which of a
compound state's invokes had already settled into one of its children,
so a host that re-arms from StartEffects alone after a Restore may run
one again; the durable runner records which settled and skips them
(#249).

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
… actors

Start and Recover started only the active leaves' invokes, while a Fire
that entered a compound state started its declares, so an instance that
started in, or recovered into, a compound state ran without that state's
services and actors. The widened StartEffects flows through: a compound
state's service that settled into one of its children lands in the
checkpoint's EndedServices as the leaves' do, its ended actors in
EndedActors, and the unstarted/ended rule covers its actors.

Unskips the four #234-era tests, each shown failing on the parent
branch: Start didn't spawn a superstate's actor, the settled compound
service wasn't found in flight, the compound's actor wasn't spawned for
a delivery, and Recover never retried a compound's unstarted actor.
Pins a compound state's ended actor landing in EndedActors, the actor
side of the settled rule, which no surviving test pinned: Recover
leaves it ended by the journal, by a checkpoint, and by one a recovered
Handle took.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18 reka18 added confirmed:correctness ACR clean: correctness confirmed:regression-safety ACR clean: regression-safety confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:replay-determinism ACR clean: replay-determinism confirmed:api-compatibility ACR clean: api-compatibility confirmed:missed-context ACR clean: missed-context confirmed:human-readability ACR clean: human-readability confirmed:probes ACR: the probes lens's latest round found no blocker ready All ACR dimensions confirmed - clear to merge labels Dec 2, 2026
@reka18
reka18 marked this pull request as ready for review December 2, 2026 15:35
@reka18
reka18 requested a review from joshua-temple December 2, 2026 15:56
@reka18
reka18 merged commit 7402106 into main Dec 2, 2026
123 checks passed
@reka18
reka18 deleted the fix/state-start-effects-compound branch December 2, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed:api-compatibility ACR clean: api-compatibility confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:correctness ACR clean: correctness confirmed:human-readability ACR clean: human-readability confirmed:missed-context ACR clean: missed-context confirmed:probes ACR: the probes lens's latest round found no blocker confirmed:regression-safety ACR clean: regression-safety confirmed:replay-determinism ACR clean: replay-determinism ready All ACR dimensions confirmed - clear to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

state: StartEffects leaves out a compound state's services and actors, so Start and Recover don't start them

2 participants