Repository navigation
Commit 6d98342
fix(scripts): evaluate the census self-test's battery floor before its verdict, and set the handshake last (#19053)
Fixes #19029
Clause-②: no
One file: `scripts/check-system-context-census.mjs`. A root `scripts/`
gate, nothing published.
## Premise, re-read on the source first
The card was filed bare and triage (comment 5730522407) asked the taker
to read the order itself and refute the card if it was in fact
compliant. Read on `origin/main` `b22db516d`: `selfTest()` printed its
verdict line, set `selfTestReachedVerdict = true`, and only THEN
evaluated its 46-line battery floor, whose own comment claimed it was
"Evaluated ... BEFORE the verdict". Premise **confirmed**, and
`AGENTS.md`'s `Writing a --self-test` band is explicit: "Set the flag as
the self-test's last statement, after its success line prints".
## What moved
- The floor block moves **above** the verdict write. Its 40 lines of
code are **byte-identical** after the move (sha256 of the block
`f6312a3aa320cbf0` before and after); the roster, the floor's rules and
`SELF_TEST_BATTERY_FLOOR` are untouched, and so is `run()` and the entry
block.
- `selfTestReachedVerdict = true` becomes the **last statement** before
the return, after the verdict line prints — the ordering
`scripts/check-agent-model-declared.mjs` already carries (copied, ⛔ not
imported).
- The floor's comment now describes the order it relies on, and names
why the order is load-bearing.
- One new self-test case, `⭐ VERDICT ORDER`, filed under the battery
already open — the roster is **not** widened.
## Why the new case is a STATIC read, and what it pins
The floor prints only when it FAILS, so a passing run's bytes are
identical whichever side of the verdict it sits on: no mutation of a
green tree exposes the order, which is why the fleet probe on PR
#19026's branch correctly reports that it observed nothing. So the case
reads the order off this file's own text (the idiom the neighbouring
`POPULATION DECLARATION` pins already use) and holds five facts, each
anchor required to resolve **exactly once**:
```
{"floorBeforeVerdict":true,"floorAddsToTheCounterTheVerdictReads":true,"flagAfterVerdictLine":true,
"nothingExitsBetweenVerdictAndFlag":true,"flagIsTheLastStatement":true,
"anchorsResolvedExactlyOnce":{"floor":true,"verdict":true,"flag":true,"returnStatement":true}}
```
Chained, those are the behavioural claim: the floor adds to the same
`failures` the verdict reads, the verdict prints after it, and the flag
is the last statement with no `return` or `process.exit(` between — so a
breached floor can only print the FAILED line and can only return
non-zero. Comments are stripped before the two adjacency reads, in both
directions: prose between the two statements must not red the case, and
prose must not be able to hide a statement from it either (a
line-anchored `^return` misses `if (x) return 0;` — measured, see leg
2).
## Measurements
All four ablation legs ran through `scripts/ablation-replace.mjs` on the
**committed** file: anchor hit count declared, the write verified
against the disk and the blob hash, and the restore proven by `blob ==
HEAD` plus an empty `git diff HEAD`. Every leg printed `ok restored:
blob == HEAD (dcaf90e) and git diff HEAD is empty`.
**1. A passing run is unchanged except for the new case** (`--self-test`
before vs after, full transcripts diffed):
```
93a94
> ok ⭐ VERDICT ORDER: the battery floor is evaluated ABOVE the verdict line and ...
```
That is the whole diff: 95 lines / 18,636 bytes before, 96 lines /
19,201 bytes after, 80 cases to 81, success line still last, exit 0
both. Nothing else moved, because the floor prints nothing on a passing
run.
**2. A breached floor prints the FAILED line and no success line.**
Mutation: one pin raised above its count (`'absence is loud': 1,` to `:
99,`).
```
ablation-replace: ok mutation landed: anchor 1 -> 0, blob dcaf90e -> 85fc130dabf9
FAIL self-test battery "absence is loud" registered 1 case(s), below its pinned floor of 99 — cases that used to run no longer do.
FAIL A battery at or below its floor means cases STOPPED RUNNING — the battery is the bug, not the number. ...
check-system-context-census --self-test: 2 case(s) FAILED
ablation-replace: command exited 1
```
No `all cases passed` anywhere in that run (grep count 0). Before this
change the same breach printed `all cases passed` and then those FAIL
lines.
**3. An early exit between the verdict and the flag is caught twice.**
Mutation: `return 0;` injected after the verdict write, before the flag.
```
FAIL ⭐ VERDICT ORDER: ... -- {"floorBeforeVerdict":true,...,"nothingExitsBetweenVerdictAndFlag":false,...}
check-system-context-census --self-test: 1 case(s) FAILED
✗ check-system-context-census self-test: selfTest() returned without reaching its verdict,
so no success line was printed. Exiting 0 here would report a self-test
that never finished as a self-test that passed.
ablation-replace: command exited 1
```
The static case names the ordering; the handshake refuses the 0. Exit 1.
**4. An early exit inside the floor region, new order.** Mutation:
`return 0;` injected at the top of the floor region (before `const
declaredBatteries`).
```
ok ⭐ VERDICT ORDER: ...
(no verdict line at all: grep "all cases passed" = 0, grep "case(s) FAILED" = 0)
✗ check-system-context-census self-test: selfTest() returned without reaching its verdict,
so no success line was printed. ...
ablation-replace: command exited 1
```
**5. ⭐ The identical injection on `origin/main`'s shape — the hole,
empirically.** Same anchor, same replacement, run against `HEAD~1`'s
bytes checked out on disk (blob `2b21f55e7045`, verified before
mutating; restored to HEAD's `dcaf90ed4d1a` after, `git diff HEAD`
empty):
```
ok: the origin/main shape is on disk (floor BELOW the verdict and BELOW the handshake)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 2b21f55 -> ac63c9bade5a
check-system-context-census --self-test: all cases passed
ablation-replace: command exited 0
```
A run that printed the success line, exited 0, and never evaluated its
floor. 1 parent 5380daa commit 6d98342
1 file changed
Lines changed: 75 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2838 | 2838 | | |
2839 | 2839 | | |
2840 | 2840 | | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
2841 | 2890 | | |
2842 | 2891 | | |
2843 | 2892 | | |
2844 | | - | |
2845 | | - | |
2846 | | - | |
2847 | | - | |
2848 | | - | |
2849 | | - | |
| 2893 | + | |
2850 | 2894 | | |
2851 | 2895 | | |
2852 | | - | |
2853 | | - | |
2854 | | - | |
2855 | | - | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
2856 | 2908 | | |
2857 | 2909 | | |
2858 | 2910 | | |
| |||
2894 | 2946 | | |
2895 | 2947 | | |
2896 | 2948 | | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
2897 | 2962 | | |
2898 | 2963 | | |
2899 | 2964 | | |
| |||
0 commit comments