Skip to content

fix(scripts): the harness refuses a flag given no value instead of inventing "true" (TASK-081) - #1779

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/harness-bare-flag
Sep 19, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/harness-bare-flag

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

TASK-081, the fifth and last silent-input path in the evidence harness, and the only one that invented a value rather than dropping one. Vera named it in 70182 while clearing #1776 and classified it "the same class of bug, not a hold", so #1776 landed untouched and this is its own row.

Measured on main before changing anything

$ node -e "... parseArgs(['--route','--out','/tmp/a.png']) ..."
MAIN behaviour:  route="true"   refusalFor(...)===null

--route $UNSET --out a.png (the shape an unset shell variable takes — Vera's exact example) parsed as route='true' and the harness refused nothing, so a run would navigate to a route literally named true under a file name that named the intended page. Every other path in this class loses information; this one manufactured it, which is why it is worth its own refusal even though #1776 had just landed four.

The repair

A flag followed by nothing is refused and named, alongside the four refusals already there:

flag(s) with no value: --route — every flag here takes a value, so a flag
followed by nothing (or by the next flag) is an unset variable or a forgotten
argument, not a switch. There is no boolean flag to pass bare.

Every flag this harness implements takes a value, so there is no legitimate bare invocation — the refusal cannot reject a valid run. A bare unknown flag is reported as unknown and bare, mirroring the pairing #1776 established for an empty value, so a caller learns both mistakes at once.

The boundary, pinned

The lookahead treats only ---prefixed tokens as flags, so --wait -1 is a value, not a bare flag. I asserted the opposite in the first draft, the test disagreed, and the correct behaviour is now pinned (--wait -1 → not bare; --wait --out x → bare) so the edge of the new refusal is deliberate rather than discovered.

Evidence

  • End-to-end through the real script, which is where this class actually bit: node scripts/ui-evidence-shot.mjs --route $UNSET --out /tmp/a.png → exit 2, flag named, before the Playwright import. Same for the trailing form … --out x --route.
  • 3 new tests; whole backend/__tests__/unit/scripts = 16 suites / 117 tests green.
  • 2 mutations, each reddening a distinct witness, no survivors: stop recording the bare flag; report a bare flag only when the flag is known (which is exactly the "unknown as well as bare" pairing). Source restored byte-identical after each.
  • docs/runbooks/local-ui-render-harness.md — the refusal table now names this fifth case and says what made it different: the one path that invented a value.

No version slot: scripts/, docs/ and a backend test only.

…venting "true" (TASK-081)

The last silent-input path in scripts/lib/ui-evidence-args.js, and the only one
that manufactured a value rather than dropping one. Measured on main:
parseArgs(['--route', '--out', '/tmp/a.png']) yields route='true' and refusalFor
returns null, so `--route $UNSET --out a.png` navigated to a route literally
named `true` under a file name that named the intended page.

Every flag this harness implements takes a value, so a bare flag is an unset
variable or a forgotten argument, never a switch: it is now refused and named.
A bare unknown flag is reported as unknown AND bare, mirroring the pairing the
empty-value refusal already uses.

The lookahead treats only `--`-prefixed tokens as flags, so `--wait -1` is a
value rather than a bare flag; that boundary is pinned by a test.
@lilyshen0722
lilyshen0722 merged commit 8bfca7b into main Sep 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant