Skip to content

Names step buttons and checks them at start - #279

Merged
johnnyt merged 2 commits into
mainfrom
se-9p2o-step-outcomes
Nov 27, 2026
Merged

johnnyt merged 2 commits into
mainfrom
se-9p2o-step-outcomes

Conversation

@johnnyt

@johnnyt johnnyt commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What

The returnable step type (myapp.step, StatifierExamples.Signup.ReturnableStep) said its buttons under a config key named outcomes, the block type vocabulary's word for the ways a block can finish, while the step declares no outcomes/1 and finishes as done whichever button was pressed. Nothing checked that a step's configured buttons and responses agree with the screen it names.

  • The key is renamed to buttons. The type moves to version 2 (current_version/0), and migrate_config/2 renames outcomes to buttons in a version 1 block as it resolves. The moduledoc's "One outcome, done" section says why: outcomes is the block type vocabulary's word for the ways a block can finish, and this list is the screen's buttons. Declaring outcomes/1 with one outcome per button was the other open answer, and would have let a Path route on the button; the rename was taken on the same vocabulary ground, since a step's buttons are how the reader leaves its screen and a Path reads what was answered from responses.
  • Journey start refuses a disagreeing step. StatifierExamples.Signup.Journey.start/2 answers {:error, {:steps_disagree, disagreements}} for a Path with a myapp.step that disagrees with the screen it names, each disagreement {block_id, reason, name}. The reasons are a configured button the screen does not carry, a button on the screen the step does not configure, a configured response with no question of that key, and a question on the screen the step does not configure. A version 1 step is read through the migration, so its outcomes count as its buttons.
  • The documents that move: the patron registration steps, the branch onboarding and its three setups (catalogue sync, reading list import, card reader setup). Each myapp.step block in them is now at type_version 2 with buttons. No card or signup fixture carries the type, so none moves.

Tests

One test per refusal in ReturnableStepTest, plus a test that a version 1 step starts, and a test of the version and the migration. The validation test and the setups' agreement test read buttons. Each new test carries a sabotage note. Every mutation was applied, killed on an assertion and restored byte-equal before the next.

Gate

Full mix quality green on the committed tree: format, compile with warnings as errors, unused dependencies, credo, dialyzer, and the suite with 88.2% coverage.

Provenance

The choice between renaming the key and declaring outcomes/1 was engineering. The rename was taken on the vocabulary ground above. A second commit corrects the moduledoc, which first claimed that a step with a non-done outcome would stall its sequence; a sequence advances on a child's done event whichever final the child enters, so that reason did not hold and is gone. The same commit names the shared test helper start/1. The reverse checks (a button or question on the screen the step does not configure) follow the bead's description: such a press has no transition and such an answer is never recorded.

The returnable step type's config key for its buttons was called
outcomes, the block type vocabulary's word for the ways a block can
finish, while the step declares one outcome, done. The key is now
buttons, the type is at version 2, and migrate_config/2 renames the
key in a version 1 block as it resolves. The moduledoc says why the
type declares no outcomes/1: a step finishing with a button's outcome
would be unconsumed by the sequence that holds it.

Journey start now refuses a Path whose step disagrees with the screen
it names, as steps_disagree: a configured button or response the
screen does not carry, or a button or question on the screen the step
does not configure. One test per refusal, each with a sabotage note.

The patron registration steps, the branch onboarding and its three
setups move to buttons at version 2. No card or signup fixture
carries the type.

Refs: se-9p2o
The step's moduledoc said that declaring one outcome per button would
leave a step unconsumed by the core.sequence holding it. That is not
so: a sequence advances on a child's done event whichever final the
child enters, and never reads an outcome name. The paragraph now rests
the rename on the vocabulary alone, says that declaring outcomes/1 was
the other open answer, and why the rename was taken instead.

The test helper the refusal tests and the version 1 start test share
is named start/1, since it starts as well as refuses.

Refs: se-9p2o
@johnnyt
johnnyt merged commit 8e95ffb into main Nov 27, 2026
4 checks passed
@johnnyt
johnnyt deleted the se-9p2o-step-outcomes branch November 27, 2026 23:22
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