Skip to content

A skipped page's answers are left out of what is stored, not out of what is judged (0246) - #363

Merged
sharkysan merged 2 commits into
mainfrom
fix/a-skipped-pages-answers-are-not-stored
Nov 27, 2026
Merged

sharkysan merged 2 commits into
mainfrom
fix/a-skipped-pages-answers-are-not-stored

Conversation

@sharkysan

Copy link
Copy Markdown
Owner

A page a skip rule walks past had its fields hidden from validation and its answers stored all the same. Measured on main: a server replay of { needsVisa: false, passport: "X123" } with the passport page skipped accepted the submission and stored passport: "X123". What was typed on a page before it was walked past was stored too, and so was a default on a page skipped from the start. Read from 0.3.0's code, the first release with a skip rule, it has been so since then (hazards A4 and A10). 0087 promised the answers would stay out of the submission; nothing did that, and nothing tested it.

A skip also shared one switch with visible rules. A field on a skipped page with a visible rule of its own that showed it was shown again by the browser's next pass. A required one then held the form up on a page nobody could reach, where the replay of the same answers accepted it (A2).

The fix (0246).

  • A new engine.submission() returns value() without each field, group and list on a skipped page, whole, unless its own clearOnHide is false.
  • The server stores it, hands it to webhooks, and checks sourced answers and claims files from it.
  • value() is unchanged: it is what a binding sends, what a draft keeps and what the server replays. So every rule judges as it did, and the replay judges what the browser judged.
  • A skip and a visible rule now hide apart, and either one hides the field.
  • The skip machinery leaves engine.ts for skips.ts.

Two other repairs were built, measured and dropped; 0246 records both:

  • Pruning the store, as 0013 does for a hidden field, let a skip that reads its own page undo itself. A payment page skipped when total == 0.0 came back at a total of nothing, and two crossed skips with defaults overflowed the stack.
  • Leaving the answers out of value() made the server's replay judge without answers the browser had judged with. The reviewer found six cases where the two disagreed.

A new test table, the replay of what the browser hands over, guards that property from now on. It reaches each state answer by answer in the browser, replays exactly what value() hands over in server mode, and requires the same verdict, the same pages and the same submission(). All six cases fail under the second dropped design.

What this costs, recorded in 0246, A3, A4 and §11:

  • A withdrawn answer still drives the rules, as on main. A field shown because of it is asked and stored, and a value computed from it is stored, while the answer itself is not. So a stored response can disagree with its own inputs. A test pins this, so changing it is a decision.
  • Walking back into a skipped page finds what was typed there, which a field a rule hides does not.
  • A host that stores a binding's value without a replay still stores the answers. The MCP guidance now says to store submission().
  • @formancy/core measures 17.751 kB brotli, 0.22 kB above main, which leaves 0.25 kB of its 18 kB budget (§9.3).

Other readers follow the same line:

  • The review a person checks before sending reads submission(), and so does an example's absent, so neither shows a skipped page's answer as one that will be sent.
  • Membership of a sourced answer is checked against value(), what was judged. One on a skipped page that its list does not offer is still refused, as on main, because the rules read it.

Also fixed, found on the way (hazard A7): a sourced answer on a page was never checked against its list, in every release since 0.2.0, the first with a membership check. The membership walk took a page for a group, looked for the page's key in the answers, found nothing, and asked the source about none of the fields on it. So on any paged form, a value the list does not offer was stored. The walk now opens pages with the same flattenPages the file walk already used, which moves to server-core/src/pages.ts. From the upgrade, a paged form version published before refuses, with option, a sourced answer it used to accept.

From the upgrade, a form version published before stores none of what a client sends for a page its answers walk past, except what a field there keeps with clearOnHide: false. Responses stored before keep what they were stored with, and never migrate.

Not fixed, recorded in A4's residual: in the browser, a computed field that a visible rule hides is written again by the next pass that re-runs its rule. In the case measured the replay stripped it.

Tests:

  • packages/core/src/skip.test.ts has sixteen new cases, all of which pass. Removing the strip, letting it ignore clearOnHide, sharing the rules' switch, or stripping value() instead each fails at least one of them.
  • One new case each in review.test.ts and scenarios.test.ts, which fail when their file reads value().
  • packages/server-core/src/use-cases.test.ts has two new cases:
    • one asserts the answer, the stored row and the webhook body, and fails when either of the last two is built from value();
    • one fails when membership is checked against submission(), or when the walk does not open pages.
  • options-membership.test.ts has one new case, which fails on main's walk.

Run locally: build, typecheck, lint, format check, and the core, spec, docs, server-core, server, builder-core, conformance, mcp, React and Angular suites. The e2e and browser gates are left to CI.

…hat is judged (0246)

A page a skip rule walks past had its fields hidden from validation and its answers stored
all the same, in every release since 0.3.0: what a client sent for a skipped page, what was
typed there before the page was walked past, and a default on a page skipped from the start
(hazards A4, A10). And a skip shared one switch with the visible rules, so a field's own rule
showed it again on a skipped page and a required one held the form up where the replay
accepted it (A2).

The server now stores, and hands to webhooks, the engine's new submission(): value() without
each field, group and list on a skipped page, whole, by its own clearOnHide. value() is
unchanged, so the replay judges what the browser judged. Pruning the store let a skip reading
its own page undo itself, and leaving the answers out of value() made the replay judge without
answers the browser judged with; 0246 records both and what this costs. A skip and a visible
rule now hide apart. The skip machinery leaves the engine for skips.ts.
… needs, and a page is opened in the membership walk
@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

❌ Patch coverage is 89.36170% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/core/src/skips.ts 85.7% 0 Missing and 4 partials ⚠️
packages/server-core/src/pages.ts 80.0% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@sharkysan
sharkysan merged commit d9b4a29 into main Nov 27, 2026
15 checks passed
@sharkysan
sharkysan deleted the fix/a-skipped-pages-answers-are-not-stored branch November 27, 2026 10:31
sharkysan added a commit that referenced this pull request Nov 27, 2026
…ser did, by random roads (#364)

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.
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