Skip to content

fix(scripts): the UI evidence harness refuses a value that belongs to no flag, and prefers UI_TOKEN over --token - #1775

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/harness-arg-guards
Sep 19, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/harness-arg-guards

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

What

Two follow-ups Vera read out of the harness while clearing #1770, neither a hold (70101, her own correction in 70102).

1. A value that belongs to no flag was skipped without a word. --width 390 400 ran with 390 and never mentioned the 400, because the parser did continue on anything not starting with --. That is the same silent-input class as rule 27's unimplemented flag, one step over: the tool accepted input it did not act on. It is now refused with exit 2, naming the value and listing the known flags — the shape the unknown-flag refusal already had.

Argument parsing moved to scripts/lib/ui-evidence-args.js (a module that imports nothing), so the argument contract has a witness that needs no browser, and Playwright is imported after validation — --widht 390 now says so whether or not a browser is installed.

2. --token <jwt> leaks the JWT through two channels it does not need to. The process table (ps) and shell history. UI_TOKEN carries the same value through neither, so the runbook and the script's usage block lead with the environment form (UI_TOKEN="$TOK" node scripts/ui-evidence-shot.mjs …) and keep --token as the explicit fallback. The flag still works; the doc no longer recommends it.

Doc note: Vera's correction was right and worth recording — the runbook's sentence says an unknown flag is refused, so it was accurate, and the gap was in the tool. The row now covers both inputs.

Evidence

  • backend/__tests__/unit/scripts/uiEvidenceShotArgs.test.js — 8 tests, all passing: the stray value refused and named, a route passed positionally refused rather than ignored, --flag value and --flag=value both parsed as the same flag, --click alone a boolean, the unknown flag refused with the known list printed, both mistakes reported in one message, and a fully known invocation not refused.
  • End-to-end against the real script: --width 390 400 → unexpected value(s): 400 … exit 2; --widht 390 → unknown flag(s): --widht … exit 2; --width=390px → the 200–4000 range message, exit 2. All three exit before the browser is needed.
  • Four mutations, each reddening its own witness: drop the stray again → the three stray tests; stop collecting unknown flags → the unknown-flag and both-mistakes tests; drop the --flag=value branch → the joined-form test; drop the boolean branch → the bare-flag test.

Scope

scripts/ui-evidence-shot.mjs, scripts/lib/ui-evidence-args.js (new), docs/runbooks/local-ui-render-harness.md, one backend test. No version slot — scripts/, docs/ and backend/__tests__ are outside what the release ladder guards. Cut on 2ae3e00e (#1770, merged).

… no flag, and prefers UI_TOKEN over --token

Two follow-ups Vera read out of the harness after #1770 (70101, corrected in
70102):

- `--width 390 400` passed: the `400` belonged to no flag and the parser skipped
  it with `continue`, so the capture ran with 390 and never said so. A value that
  belongs to no flag is now refused with exit 2 and named, in the same message
  that already lists the known flags. Argument parsing moved to
  `scripts/lib/ui-evidence-args.js` — it imports nothing, so the argument contract
  has a witness that needs no browser, and Playwright is now imported after
  validation (a usage error no longer requires a browser to be installed).

- `--token <jwt>` puts the seat's JWT in the process table and in shell history.
  `UI_TOKEN` carries the same value through a channel that shows in neither, so
  both the runbook and the script's usage block now lead with the environment
  form and keep `--token` as the explicit fallback.

Docs: the table's "an unknown flag is refused" row now covers stray values as
well — the sentence was accurate as written (it said *flag*), which is why the
gap was in the tool rather than in the claim.
@samxu01
samxu01 force-pushed the kai/harness-arg-guards branch from 1f256eb to cd5f7e0 Compare September 19, 2026 18:23
@lilyshen0722
lilyshen0722 merged commit 08ddfd2 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