Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return - #14479

Merged
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake
Sep 2, 2026
Merged

Verdict handshake for 134 scripts/** self-tests that exit 0 on an early return#14479
baozhoutao merged 9 commits into
mainfrom
claude/issue-13798-self-test-handshake

Conversation

@claude

@claudeclaudeBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Part of #13798 (batch 1)

Transplants the verdict handshake PR #13797 landed on check-self-test-wired.mjs and
check-self-test-workflow-commands.mjs to every other scripts/** gate the census
instrument reads as DEFEATED, minus the files held by other lanes' open PRs. Nothing
inside any self-test body changes — no battery, no floor, no case is touched. The
strictly-sequenced sibling #13799 (hole 1, the roster floor) is deliberately NOT in this
diff and stays in pm:queue; per triage 5478876397 the handshake must land before or with
the floor on any given file, so this PR is first and #13799 rebases onto it.

The reading, measured — not re-derived from the card

The card's 144/154 was taken on 597020aa5. The population has moved since. Both numbers
below come from node scripts/measure-self-test-floor.mjs --probe on this branch's own
merge base, 96b627d13
, which is also the commit the dispatch was cut against.

populationDEFEATEDHELDNOT MEASURED
before (96b627d13)16415095
after (this branch, pre-merge)164161435

142 of the 150 defeated printed nothing at all and still exited 0.

The 16 that remain are exactly the excluded set — set equality asserted, not eyeballed:
{DEFEATED after} == {DEFEATED before} \ {worklist}. Every one is held by another lane's
open PR or in-flight card, so a hunk here would collide:

filewhy excluded
scripts/check-skill-identifier-liveness.mjs, scripts/check-skills-token-ratchet.mjsPRs #14427 / #14351
scripts/check-type-check-coverage.mjs, scripts/check-type-source-resolution.mjsPR #14420 (landing)
scripts/pm/bare-root-worklist.mjs, check-clause2-carriers.mjs, check-governed-merges.mjs, check-governed-prose.mjs, check-governed-queue-guard.mjs, check-half-states.mjs, check-label-desc-cap.mjs, check-skill-id-lint.mjs, check-skill-line-ratchet.mjs, ci-failure.mjs, git-history.mjs, release-rehearsal-clone.mjsthe whole scripts/pm/ directory is carved out of batch 1

They are batch 2, once their holding PRs land. scripts/pm/dispatch-gates.mjs is NOT
MEASURED, not clean, and is carved out separately in #13800 — it is not in the 16.

Four more exclusion-list entries never appear because they are not in the population at
all (no --self-test dispatch in code): regen-artifacts.mjs,
measure-durability-swallow-family.mjs, cross-package-test-inputs.mjs,
check-adr-symbol-anchors.mjs, symbol-anchors.mjs; build-console.sh is a shell script
and the census only walks .mjs/.mts/.js/.ts.

Two shapes, one per dispatch spelling

⛔ Candidates were taken with the AST, decided with the probe. The worklist is
DEFEATED − exclusions, never a grep for return selfTest().

Shape 1 — the returned sentinel (68 files). PR #13797's shape verbatim: a per-file
SELF_TEST_VERDICT naming the gate, returned as the last statement of the self-test after
its verdict line, compared at the dispatch. Applied where the dispatch discards the
result (selfTest();, await selfTest();, including as an unbraced else if body) and
the self-test does not already end in a return/process.exit that would make an appended
return unreachable.

Shape 2 — the verdict flag (66 files). A module-level selfTestReachedVerdict, set
only after the verdict prints and read at the dispatch. Applied wherever the self-test's
own exit code is load-bearing, because a returned sentinel would either destroy that
code or be unreachable:

dispatch spellingfileswhat the rewrite does
process.exit(selfTest())20captures the code, reads the flag, re-exits the same code — process.exit(undefined) is exit 0, which is why this spelling reads like a handshake and is not one
return selfTest() (inside main())22reads the flag between the call and the return; the returned value is unchanged
process.exit(cond ? selfTest() : …) and const code = cond ? selfTest() : …14splits the ternary so the self-test arm can be handshaked; the production arm keeps its exact expression
dispatch discards, but the self-test ends in return EXITCODE / process.exit(…)9flag set immediately before that terminal statement — an appended sentinel return would be dead code
check-durability-degradation-log-level.mjs1see below

check-durability-degradation-log-level.mjs is the one Tier C file in the worklist: its
dispatch calls two self-test entries and combines them with
process.exit(a || b ? 1 : 0). An early return in either yields undefined, which that
|| reads as a pass. PR #13797 recorded the choice as "one handshake per callee, or one
wrapper". One handshake per callee is what landed — both entries are structurally
identical (verdict print, then return 0), so it stays a transplant rather than a
redesign. Only the first entry is what the probe measures; the second is repaired because
leaving half a dispatch handshaked is the same silence one call deeper.

Two mechanical traps the transplant had to survive

  • An unbraced branch body.} else if (argv.includes('--self-test')) selfTest();
    becomes several statements, and without braces the following else re-binds to the
    handshake's own if. 51 of the 134 files needed the brace; they are braced.
  • The temporal dead zone. 6 files dispatch above the self-test's definition, where
    the function is hoisted and a const/let is not. In those the declaration is placed
    before the dispatch's top-level statement instead of before the function, or the run
    would throw a ReferenceError where it used to handshake.

Reverse verification — four ablations, one per dispatch spelling

Each injects return; as the first statement of the entry function in a scratch copy
written beside the original
(so relative imports and repo-root resolution answer
identically — the same placement the census instrument uses), runs it, then deletes the
copy. The tracked file is never mutated: the marker count is read back from disk on
both files before the reading is accepted (x1 in the copy, x0 in the original — an
editor step that matched nothing exits 0 exactly like one that landed), and
git status --porcelain was empty afterwards.

gatedispatch spellingbaselinewith early return
check-nul-bytes.mjssentinel · discardsexit 0, ✓ … 75 assertions over a temp git repoexit 1, ✗ check-nul-bytes self-test: selfTest() returned without reaching its verdict
check-cli-command-ids.mjsflag · process.exit(selfTest())exit 0, ✓ … 39 cases passexit 1, same refusal
check-error-code-casing.mjsflag · return selfTest()exit 0, ✓ … 46 recognizer + 5 registry case(s) passexit 1, same refusal
check-comment-mask-adoption.mjsflag · ternaryexit 0, PASS … (0 failure(s))exit 1, same refusal

There is no build or dist/ on this path — every gate runs from source — so there is no
rebuild leg to get wrong. The pre-fix direction needs no separate ablation: the before
column of the census is that measurement, and it recorded all four as DEFEATED,
printing nothing.

What did not change, asserted rather than assumed

  • Every one of the 134 files still runs its own --self-test to the same exit code and
    byte-identical output.
    Captured before the codemod and again after, and diffed. Two
    files differ and neither is a behaviour change: objectui-changeset-digest.mjs prints
    fresh mktemp paths and fresh commit shas on every run, and
    check-plugin-teardown-shape.mjs was red before and after on a shallow checkout —
    its positive control is pinned to a commit a --depth=1 clone cannot reach. After
    git fetch --depth=6000 it is green (✓ … 47 cases pass). ⚠️ On a checkout too shallow
    to reach that commit the gate now prints its own "Deepen the clone" refusal and the
    handshake refusal, because it really does return 1 without reaching its verdict. Exit
    code is 1 either way; the extra line is noise on an already-red path, not a new failure.
  • Hole 1 is untouched, measured both ways. The census's floor classification
    (ROSTER/COUNT/NONE) is byte-identical for all 164 files before and after. That is
    the mechanical proof this remedy is boundary-only, and it is why 155 of 158 scripts/** self-tests have no assertion floor: a battery that never ran is indistinguishable from one that passed #13799 still has its
    whole job to do.

Verification

Every exit code captured before any pipe, from a variable assigned directly after the
command.

Union re-derived and re-run after the final commit, on 83916a44b (this branch's head,
which is the merge of origin/main at a98b61b3e).

  • node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstackDG_EXIT=0,
    134 path(s) vs the merge base, 149 families (148 by path + 3 by change kind, 2 reached
    both ways). Every one was run from --commands, so the harvest cannot end at one section.

  • 146 of the 149 exit 0. The other three are NOT MEASURED — never read as passes:

    familyexitwhy it is not a verdict
    node scripts/check-partof-closing-keyword.mjs2NOT WIRED — neither PR_BODY nor PR_NUMBER is set; its own text says this is a usage failure, not a verdict. Re-run against this PR's body below.
    node scripts/check-single-claim-paths.mjs2NOT WIRED — PR_NUMBER is not set, same shape; needs the PR to exist
    node scripts/check-test-completeness.mjs3PREREQUISITE NOT MET — it grades a saved turbo run test log and no log exists locally. The same reading PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797 recorded.

    ⚠️ Thirteen families first came back non-zero on an unbuilt tree — PREREQUISITE NOT MET
    / "Run pnpm build first", not findings. pnpm build (exit 0, 71/71 tasks) turned
    twelve of them green; the thirteenth was a real red and is fixed in this branch, below.

  • Named because the dispatch names them, all exit 0: pnpm check:ratchet-remedy-authority,
    pnpm check:declared-population-live, pnpm check:nul-bytes,
    node scripts/pm/bare-root-worklist.mjs --self-test, and
    pnpm check:pm-dispatch-gates — the ~13-minute one, run to completion (781s).

  • The two precedent gates in both modes, no pnpm alias, the way lint.yml runs them:
    node scripts/check-self-test-wired.mjs --self-testexit 0
    (6 declared batteries, 43 cases registered) then node scripts/check-self-test-wired.mjs
    exit 0; node scripts/check-self-test-workflow-commands.mjs --self-testexit 0
    (6 declared batteries, 23 cases registered) then the production run exit 0.

  • pnpm linteslint . --no-inline-config over the whole repo, not narrowed:
    exit 0, 5703 files, 0 errors, 0 warnings (count read from --format json).

  • pnpm check:nul-bytesexit 0; the touched files were additionally swept directly for
    raw control bytes (grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]') — no match.

The one real red this produced, and why it was fixed rather than ledgered

pnpm check:type-check-debt reddened at exit 1:
@objectstack/spec-monorepo: DEBT records 26 raw tsc error(s), tsc --noEmit now reports 28 (+2).

scripts/check-test-typecheck.mts is the one TypeScript file in this diff and it lives in
the root tsc program — the convention block of the derivation names it for exactly this
reason. Its selfTest() is annotated : void, so returning the sentinel produced
TS2322: Type 'string' is not assignable to type 'void' and the comparison at the dispatch
produced TS2367.

⛔ Raising the ledger entry is MAINTAINER-ONLY and was not taken. The gate's own author
remedy — fix the errors — is what landed: the annotation now says : string, which is what
the function returns. Root tsc --noEmit -p tsconfig.json is back to 26 errors, equal
to the frozen entry, and the single remaining one (TS2550 Object.hasOwn at line 368) is
pre-existing and untouched. pnpm check:type-check-debtexit 0 on the final head.

No changeset, and the label

scripts/** publishes nothing from any package, so this releases nothing — the closed
skip-changeset list in lint.yml names exactly this case ("this PR edits a CI-internal
script"), and PR #13797 took the same route for the same reason. No changeset is written;
the skip-changeset label is applied on the PR.

Not in this batch — named so it is not mistaken for done

  • The 16 excluded gates above. Batch 2, after their holding PRs land.
  • The five gates that hold today only by luck, named in 144 of 154 scripts/** self-tests exit 0 when an early return leaves them before their verdict — 137 printing nothing at all #13798's own notes and tabled
    in PR Survey: which scripts/** self-tests cannot prove they ran — and the two that now can #13797: check-osv-exemptions.mjs, typecheck-configs.mjs,
    check-exported-any-returns.mts (a downstream TypeError), checklist-select.mjs,
    run-with-stall-guard.mjs (a usage/argument error), plus
    check-page-declaration-shape.mjs whose process.exit(selfTest() ? 0 : 1) stops a bare
    return and prints nothing while doing it. The probe reads all six HELD, so they fall
    outside batch 1's stated surface — "every file that reads DEFEATED, minus the exclusion
    list"
    — and are not repaired here. Their green is still an accident one refactor
    deep; they need the same five-line transplant.
  • The five NOT MEASURED files: check-platform-checklist.mjs (four callees combined),
    check-regen-pending.mjs, git-merge-regen.mjs, setup-git-hooks.mjs (inline top-level
    blocks with no callee to leave early) and scripts/pm/dispatch-gates.mjs (Four scripts/** gates hit by the #13489 survey were excluded by occupancy — carry them forward #13800). Each
    needs reshaping before the probe measures anything, which is a decision, not a
    transplant.
  • Three gates (check-filter-alias-parity.mjs, check-meta-type-normalized.mjs,
    check-test-completeness.mjs) also call their self-test on the production path. That
    call still discards its result. It is the same silence, one seam over, and outside the
    measured surface; recorded here rather than fixed.

#13799 is not addressed here. #13014 (the empty-scan class) is not addressed here and does
not overlap: check-adr-links.mjs and check-doc-anchors.mjs both carry a full empty-scan
refusal and were both defeated by this hole.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA


Generated by Claude Code

…h discards the result
`scripts/**` gates spelled `if (--self-test) selfTest();` had no handshake: a
`return` anywhere above the verdict printed nothing, evaluated no floor and
still exited 0 — a self-test that never finished, reported as one that passed.
Transplants the boundary-only shape landed on `check-self-test-wired.mjs`: a
per-file `SELF_TEST_VERDICT` sentinel returned as the last statement of the
self-test, after its verdict line, and compared at the dispatch. Nothing inside
any self-test body changes.
An unbraced branch body (`else if (c) selfTest();`) is braced first, so the
multi-statement replacement cannot re-bind a following `else`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…turn selfTest()`
Here the self-test's own return value reaches a caller, so the sentinel shape
cannot be used without changing what the dispatch propagates. A module-level
`selfTestReachedVerdict` is set only after the verdict prints and read between
the call and the return, leaving the returned value exactly as it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…ocess.exit(selfTest())`
The shape that reads like a handshake and is not: an early bare `return` yields
`undefined`, and `process.exit(undefined)` is exit 0. The self-test's numeric
exit code is load-bearing, so it is captured and re-exited unchanged; the flag
is read in between.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
… a ternary
`process.exit(argv.includes('--self-test') ? selfTest() : main())` and the
`const code = ... ? selfTest() : main(argv)` variant carry the same hole. The
ternary is split so the self-test arm can be handshaked; the production arm
keeps its exact expression and exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…atches
Nine gates whose dispatch discards the result but whose self-test ends in
`return <code>` or `process.exit(...)`, so an appended sentinel return would be
unreachable; the flag is set immediately before that terminal statement.
Plus `check-durability-degradation-log-level.mjs`, whose dispatch calls TWO
self-test entries and combines their statuses with `||`. An early return in
either yields `undefined`, which that `||` reads as a pass, so each entry gets
its own handshake rather than a wrapper.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
Braces were added around 51 unbraced branch bodies so the multi-statement
handshake could not re-bind a following `else`. In the 16 whose dispatch was
already nested, the block that moved inside them kept its old indentation and
came out one level deep. Whitespace only — no statement moves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
…-test
`selfTest()` there is annotated `: void`, so returning the verdict sentinel
added two raw tsc errors to the ROOT program and drifted the
@objectstack/spec-monorepo DEBT entry 26 -> 28. The ledger is shrink-only and
raising it is maintainer-only, so the errors are fixed instead: the annotation
now says what the function returns. Root `tsc --noEmit` is back to 26.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Euac24FtaPN3AXf9uiUWA
@claudeclaudeBot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Sep 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9e286e248866c40d2db662f69aa0ba6e71b4b096packageMentionDocs.

@baozhoutao
baozhoutao marked this pull request as ready for review September 2, 2026 10:15
@baozhoutao
baozhoutao added this pull request to the merge queueSep 2, 2026
Merged via the queue into main with commit 9acdddeSep 2, 2026
42 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-13798-self-test-handshake branch September 2, 2026 10:49
baozhoutao pushed a commit that referenced this pull request Sep 4, 2026
…erdict
`check-type-check-coverage.mjs` and `bare-root-worklist.mjs` were the last two
gates in `scripts/**` that the census reads as DEFEATED: an early `return`
anywhere above the verdict line printed NOTHING and still exited 0, so a
self-test that never finished reported as one that passed.
Both dispatches DISCARD the self-test's return value
(`selfTest(); process.exit(0);` and `if (--self-test) selfTest(); else report()`),
so the sentinel spelling landed in PRs #14479 / #14853 is the fitting form for
each: `SELF_TEST_VERDICT` returned only after the success line, compared at the
dispatch, which refuses anything else with exit 1. Nothing inside either
self-test body changes.
Part of #13798
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xlskip-changesetPR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@baozhoutao@claude