Skip to content

[Test] Become.test.ts has four cases for the behavior stack and none of them crosses a restart #1381

Description

@pathosDev

Use case

The behavior stack has four tests:

tests/unit/Become.test.ts
  become replaces the current behaviour (default discardOld=true)
  become with discardOld=false pushes onto a stack
  unbecome pops the stack
  unbecome cannot empty the stack below the initial behaviour

The file does not contain the word "restart".

That is the gap, because the interesting behaviour of the stack is what happens when it meets the rest of the lifecycle. src/internal/ActorCell.ts:1637 resets the stack to a single entry on restart — a deliberate decision with real consequences: an actor that has swapped into a "draining" or "authenticated" behaviour and then fails is silently returned to its initial behaviour. Nothing tests that.

Neither is the interaction with stashing tested. Restart discards the stash to dead letters (ActorCell.ts:1596) and resets the stack, so a message stashed under one behaviour and unstashed after a restart would be handled by a different one — except it is dead-lettered instead. That ordering is load-bearing and unbound.

For comparison, the neighbouring core-semantics files are substantially deeper: tests/unit/DeathWatch.test.ts has 14 cases across 562 lines, tests/unit/Supervision.test.ts has 30, tests/unit/DeathWatchOnBoundedMailbox.test.ts has 14 more for one hard interaction. Four cases with no lifecycle crossing makes this the thinnest core-semantics coverage in the repository relative to its bug surface.

Proposed shape

Cases worth having:

  • A restart resets a stack several levels deep back to the initial behaviour.
  • A restart with stopChildrenOnRestart disabled does the same (the parked-restart resume path at ActorCell.ts:1640-1645 is a separate branch).
  • unbecome after a restart does not pop below the initial behaviour — the stack is genuinely reset, not merely truncated.
  • A message stashed under behaviour B is dead-lettered rather than delivered to behaviour A after a restart.
  • The typed behavior API reaches the same outcome, since src/typed/ has its own path.

Acceptance

  • The stack's behaviour across a restart is tested at more than one depth.
  • The stash interaction across a restart is tested.
  • The stopChildrenOnRestart: false resume path is covered.
  • Neutralising the stack reset at ActorCell.ts:1637 makes at least one new test fail.

Verification status

Confirmed by reading. The four test names are transcribed from tests/unit/Become.test.ts; grep -ci restart on that file returns 0. The reset site (ActorCell.ts:1637), the stash-discard site (:1596) and the parked-restart resume path (:1640-1645) were read. Case counts for the comparison files were counted from their sources.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions