Skip to content

test(fold): close the corpus, so an entry in neither list fails (#2225) - #2451

Merged
lex00 merged 2 commits into
mainfrom
fix/2225-fold-ratchet
Sep 13, 2026
Merged

lex00 merged 2 commits into
mainfrom
fix/2225-fold-ratchet

Conversation

@lex00

@lex00 lex00 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Closes #2225. Option (a) from the issue, as recommended there.

The hole

EXPECTED_FOLD is a name-by-name ratchet, and the gate only walks names already in it:

const regressed = EXPECTED_FOLD.filter((name) => byName.get(name)?.mode !== "fold");

An entry absent from the list can never appear in regressed, whether it folds or not. A new corpus entry that never folds passes by construction — and twice did. forgejo/ci-workflow joined in #1119 and sat run-fallback for a month; fountain-steward joined in #2129 with every *.op.ts default-exporting its Op and all four files falling back, moving the published count from 96 of 110 to 96 of 111, denominator only. Neither dropped the numerator, so nothing tripped.

That is also why option (b) — refusing when the live fold count falls — would not have caught either.

What this adds

EXPECTED_RUN_FALLBACK names all thirteen entries that do not fold today, each with the reason chant actually gives. I instrumented the report to print the live fold-decision reasons rather than inferring them, so e.g. cpln/secret-access is "an ambient process read, which wants a build-time parameter instead" and not a guess.

Three gates close the corpus:

  1. an entry in neither list fails by name
  2. no entry is in both
  3. a listed fallback that starts folding, or leaves the corpus, fails — so the list can only shrink

fold-adversarial carries an explicit note that it is the one entry that should never move: it exists to exercise refusals.

Writing the gate first found the same hole in the other direction

Seven entries fold and were never ratcheted, so a regression in any of them would have gone unnoticed:

examples/argo-cd-gke
examples/cc-gcp-canonical
examples/cockroachdb-multi-region-gke
examples/fan-out-estate
examples/github-pr-preview
examples/testing-harness-aws
lexicons/k8s/examples/operator-stack

All seven are added, taking EXPECTED_FOLD from 89 to 96 — which is the live fold count, so the ratchet now covers every folding entry. None is removed. (fan-out-estate landed today in #2420, and would have been the eighth instance of exactly the bug this issue is about.)

Acceptance

  • EXPECTED_RUN_FALLBACK lists every entry currently run-fallback, each with a one-line reason
  • an entry in neither list fails the gate — verified by removing one from both lists and watching it fail by name, then restoring
  • no existing EXPECTED_FOLD entry removed or commented out
  • npx tsc --noEmit clean (repo-wide: 31 known failures, no regressions); eslint clean
  • the suite is green: 116 passed

…2280)

Three source files carried literal NUL bytes inside template literals, used
as separators in composite keys. The values were right and the code worked.
What broke was every tool that reads the files as text: ripgrep classifies a
file containing NUL as binary, so it answers "binary file matches" instead
of the matching lines, and a repo-wide search omits the file entirely.

The issue named one file. The gate added here found three:

  graph-ir.ts       3 NUL   911 lines
  audit/core.ts     2 NUL   449 lines
  graph-layout.ts   1 NUL   185 lines

1545 lines invisible to every grep-driven search of this repository for as
long as the bytes were there. That is worse than a silent bug, because it is
a silent bug in the tool you would reach for to find bugs: any audit, any
"I searched the codebase", any refactor that greps for a symbol defined in
one of those files quietly skipped it and reported success.

NUL stays the separator — it is the right one, being the character that
cannot occur in an identifier or an attribute name. It is now written as an
escape: four ASCII characters in the file, the same single code unit at
runtime, so the keys are byte-identical.

The gate walks every shipped .ts for a NUL byte, since one file was never
the interesting number and finding the other two by eye was luck.
`EXPECTED_FOLD` is a ratchet over names known to fold, and the gate only
walks names already in it:

    const regressed = EXPECTED_FOLD.filter((n) => byName.get(n)?.mode !== "fold");

So an entry absent from the list could never appear in `regressed`, whether
it folded or not. A new corpus entry that never folds passed by
construction, and twice did: forgejo's ci-workflow joined in #1119 and sat
run-fallback for a month, and fountain-steward joined in #2129 with every
*.op.ts default-exporting its Op, moving the published count's denominator
only. Neither dropped the numerator, so neither tripped anything.

`EXPECTED_RUN_FALLBACK` names all thirteen entries that do not fold today,
each with the reason chant actually gives — read off the fold decisions
rather than guessed. Three gates close the corpus: an entry in neither list
fails by name, no entry is in both, and a listed fallback that starts
folding or leaves the corpus fails so the list can only shrink.

Option (a) from the issue. (b), refusing when the live count drops, would
have caught neither case above: both left the numerator flat while the
denominator grew.

Writing the gate first turned up the same hole in the other direction —
seven entries FOLD and were never ratcheted, so a regression in any of them
would have gone unnoticed:

  argo-cd-gke, cc-gcp-canonical, cockroachdb-multi-region-gke,
  fan-out-estate, github-pr-preview, testing-harness-aws,
  k8s/operator-stack

All seven are added to EXPECTED_FOLD, taking it from 89 to 96, which is the
live fold count. None is removed.

Verified the gate fails as intended by dropping one entry from both lists
and watching it name that entry.
@lex00
lex00 merged commit a7ca7d8 into main Sep 13, 2026
5 checks passed
@lex00
lex00 deleted the fix/2225-fold-ratchet branch September 13, 2026 02:54
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.

fold coverage gate passes a corpus entry that never folds, by construction

1 participant