Skip to content

The server's replay of what the browser hands over judges as the browser did, by random roads - #364

Merged
sharkysan merged 1 commit into
mainfrom
test/the-replay-judges-as-the-browser-did
Nov 27, 2026
Merged

sharkysan merged 1 commit into
mainfrom
test/the-replay-judges-as-the-browser-did

Conversation

@sharkysan

Copy link
Copy Markdown
Owner

Hazard A2 says the browser and the server must not disagree about a submission. The one engine build (0006) answers that only for the same road. The browser reaches its answers one at a time and keeps state between passes: what is hidden, which pages are walked past, which rows exist. The server builds an engine once, from what the browser hands over. Three defects in the last week were that disagreement by another road: #358, and two in #363.

packages/core/src/replay.test.ts is a fast-check property, test-only. It works like this:

  • It walks seven forms, each holding a road the engine has got wrong or one beside it: skip chains, a visible rule on a skipped page, a required by rule, computed fields in groups and rows, minItems, defaults, clearOnHide: false and a disabled rule.
  • A walk is up to thirty steps that a person could take: answers to fields that are shown, enabled and theirs to give, and rows added or removed where the buttons allow.
  • After each walk, a server-mode replay of a JSON copy of value() must give the same verdict, errors, skipped pages and submission(), and the same value, visibility, requiredness and disabledness of every field.
  • The seed is random. A failure prints the seed and a shrunk walk, with field paths and values.

Shown to fail against the engines before #358 and #363 (with submission() aliased so they compile), against one that leaves a skipped page's answers out of value(), and against one whose server ignores disabled rules. On main, three searches of 4,000 runs per form found nothing. A normal run takes about 4 s.

What it found on main, pinned as debt rather than fixed here. A rule that reads an answer which a hiding clears in the same pass decides as though the answer were still there. The pass reads the answers as it began, and a visible rule's clear only reaches the store. Both ways round:

  • The browser can refuse what the server accepts, and show a computed value the server does not store.
  • The browser can accept and send what the server refuses. The error is then on a field it shows as optional, or, where the cleared answer hid the field, on one it does not show at all. That last case leaves the person nothing to answer.

Four cases in the test assert the disagreement as it is, and each flips against an engine with the debt fixed. The seven forms leave that road out until its fix, which comes in its own PR. SAFETY-ANALYSIS A2 and arc42 §11 record it.

What the walks do not cover, stated in A2:

  • No emptied number, which would reach A3's accepted residual.
  • No row moves and no page navigation.
  • Not the second pass that a filled default runs.
  • Not a disagreement that both sides share.

An earlier version tolerated A3's stale computed value, and that let #358's defect through; it was removed.

Documents: SAFETY-ANALYSIS A2, arc42 §10 and §11, LIFECYCLE.md, and 0006's Verified by. Run locally: lint, format check, the core typecheck, and the core and docs suites.

…ser did, by random roads

A property walks seven forms by random roads of up to thirty steps, each answer one a person
could give and each row one the buttons allow, and asks the replay of a JSON copy of value()
for the same verdict, errors, pages walked past, stored value and every field's reading. It
fails against the engines before #358 and #363, against one that strips a skipped page's
answers from value(), and against one whose server ignores disabled rules.

It found one disagreement on main: a rule reading an answer that a hiding clears in the same
pass decides as though it were still there, because the pass reads the answers as it began.
Both ways round: the browser can refuse what the server accepts, and accept and send what the
server refuses, on a field it shows as optional or on one it does not show at all. That road is
pinned as debt in four cases (A2, arc42 §11) and left out of the forms until its fix.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sharkysan
sharkysan merged commit b83c022 into main Nov 27, 2026
15 checks passed
@sharkysan
sharkysan deleted the test/the-replay-judges-as-the-browser-did branch November 27, 2026 15:25
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.

2 participants