Skip to content

feat(history): check each dispatch against the core's commands - #72

Merged
FeathBow merged 2 commits into
mainfrom
feat/historychecks
Oct 22, 2026
Merged

FeathBow merged 2 commits into
mainfrom
feat/historychecks

Conversation

@FeathBow

Copy link
Copy Markdown
Owner

Why

History replay steps every journaled event through the event core, but it kept only the core's state and dropped the commands the core emitted. A journal could therefore record a dispatch before the event that let the core order it, for example a rollout of update 1 dispatched before update 0 committed at staleness zero, and the history was still admitted. The learner side has no such gap: an attempt, a record and a commit are accepted only in the phase the core enters when it emits the matching command.

Most runtime history tests also ran at staleness zero, crossed at most one recovery window, and applied mutations to journals the tests assembled by hand. Refs #30.

What

  • Replay keeps the requests the core has asked to dispatch: those from the start of the run, those from each event, and those from each restart, which replace the earlier set. A dispatched entry must name one of them and uses it up, so each command allows one dispatch. A dispatch of any other request is refused with a named problem.
  • A test fixture with two updates whose workers answer by the request they receive, so one run directory can be resumed more than once. At staleness one the learner of update 0 and the rollout of update 1 reserve their bindings concurrently, and the workers answer either order.
  • Tests on histories emitted by the runtime:
    • A run at staleness one is admitted. Both updates learn from version zero, and each update request carries the declared schedule.
    • A run is resumed after the publication of update 0 lost its acknowledgement, then again after the learner of update 1 ran without its receipt arriving. It is admitted with three attempts: update 0 committed once, update 1's failed attempt concluded, and its retry committed. Each committed attempt consumed only its own update's requests, and the history records two restarts.
    • A learner that exits with an error and the resume after it are admitted with the failed attempt and the committed retry. The history is still admitted when the restart, rather than the learner's exit record, ends that learner. Without the restart it is refused.
    • Targeted mutations are refused, each for the reason it targets: a changed learner file in a committed generation, a record after the learner's result, a dispatch moved before the commit that allows it, a commit before its record, an epoch taken back after a restart, and a retry under another attempt number.
  • The existing removed-restart mutation is now refused at the next segment's dispatch, which no restart has reordered, instead of at a result reported under the new epoch.

Validation

The core suite, formatting, lint and the type fixtures pass. With the dispatch check removed, the moved-dispatch mutation is admitted and the removed-restart case is refused at a result again, so two tests fail. Over six runs of the staleness-one test, both binding orders occurred and every run was admitted.

@FeathBow
FeathBow merged commit bc9daee into main Oct 22, 2026
4 checks passed
@FeathBow
FeathBow deleted the feat/historychecks branch October 22, 2026 10:04
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