Skip to content

measure-self-test-floor's probe anchors on the FIRST 'function selfTest() {' in a file, so a fixture string masks the real definition — dispatch-gates.mjs was NOT MEASURED for this reason alone #14963

Description

@claude

Found while working #13800 (verdict handshake, PR #14960), which got a clean reading on scripts/pm/dispatch-gates.mjs by hand-anchoring past this limitation. Filed unassigned. Sibling of #14842, which is the same census reporting NOT MEASURED for a different root cause (a missing ENTRY_BY_HAND row).

The mechanism

injectEarlyReturn(src, name) in scripts/measure-self-test-floor.mjs takes src.match(re) — the FIRST match of

new RegExp(`(?:async\\s+)?function\\s+${name}\\s*\\([^)]*\\)\\s*(?::\\s*...)?\\{`)

The pattern is run against raw source with no literal masking, so it matches inside string and template literals just as happily as at a real definition. In scripts/pm/dispatch-gates.mjs the first match is a FIXTURE — a function selfTest() { embedded in a test string — so return; is injected inside a template literal and the probe copy can only ever produce a SyntaxError. Hence the ledger row:

// Injecting into this file produces a SyntaxError (the anchor lands inside a
// template literal), so no run of it measures anything.
'scripts/pm/dispatch-gates.mjs': null,

That row is accurate about the instrument and was read for months as a property of the file. It is not: anchoring on the real definition (line-start match, or masking literals first) measures it in ONE run. Done by hand in #14960 — before the repair, an early return took that gate from 1288 cases pass to ZERO bytes of output and exit 0; after, exit 1 with the named diagnostic.

Why it matters beyond one file

The census's whole subject is "a green that asserted nothing", and its header says so. An anchor that silently prefers a fixture over a definition produces NOT MEASURED rows that read as "unmeasurable" — a survey shrinking itself for a reason nothing records. The repo already ships the tool this needs: scripts/js-comment-mask.mjs, which measure-self-test-floor.mjs imports for maskComments and could extend to string and template literals; a line-anchored match is the cheaper half.

Worth a control if this is taken: the mask must not blank the file's own controls, which are deliberately fixture strings containing --self-test dispatch spellings.

Second, smaller row in the same ledger

ENTRY_BY_HAND says of scripts/check-platform-checklist.mjs:

// The dispatch calls FOUR self-test functions and combines their statuses

There are FIVE (selfTestSourceLineCitations was added after that note was written), and PR #14960 leaves it five. Stale count in a ledger comment; a one-word fix, listed here so it is not lost rather than because it deserves its own card.


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions