Repository navigation
Description
Noticed while implementing #10713 (PR #10817), which corrects a ci.yml comment that names
a gate's flag. That edit is safe because check-shard-attestation.mjs drops shell comments
with a real lexer. The sibling guard in scripts/check-required-contexts.mjs does not.
What it is
scripts/check-required-contexts.mjs (in the "the live mode stays OFF the required path"
block, #9642/#9678) strips comments before testing workflow text with:
const uncommentedYaml = (text) => text.split('\n').filter((l) => !/^\s*#/.test(l)).join('\n');That drops a line only when its first non-space character is #. A trailing comment on
an otherwise-live line survives, and so does a shell comment inside a run: block scalar —
which is the ordinary way anyone would write a warning about this very flag:
false <- flag still seen after stripping | whole-line comment (stripped, correct)
true <- flag still seen after stripping | TRAILING comment (survives the filter)
true <- flag still seen after stripping | block-scalar shell comment (survives)
Two assertions read that stripped text, and the surviving mention misfires both:
- the absence assertion —
!/--verify-required-set/.test(uncommentedYaml(text))— fails with
"must not RUN the live required-set read", naming a comment that runs nothing; - the presence assertion sweeping
.github/workflowscollects that file intocallers, so
callers.join(',') === PATROL_WORKFLOWfails and reports a second caller that does not exist.
Both are false positives on prose, and both land on Lint & Repo Gates.
Why it is worth recording
Nothing is red today — no workflow currently spells the flag in a comment. It is latent, and
the trigger is writing a comment warning people about the flag, which is exactly what the
neighbouring ci.yml block does for the shard classifier's flag today.
The contrast is the useful part: the same repo already solved this properly one file over.
check-shard-attestation.mjs's shellCommands() is a small lexer that handles trailing
comments, quoting and continuations, and its docblock records why — documenting the trap
inside a run: re-armed it, "the #4890 shape". Its --self-test pins a trailing-comment
fixture. check-required-contexts.mjs guards a comparable "this flag must not be wired up"
property with a whole-line regex instead.
This is the same family as the open comment-vs-code findings #10570, #10683, #10794 and
#10514 — a recognizer reading prose as code — but a distinct site; none of those name this
function.
Suggested scope
Narrow the recognizer in scripts/check-required-contexts.mjs so a mention inside a comment
(trailing or block-scalar) is not read as wiring, and pin the trailing-comment case in that
script's self-test the way check-shard-attestation.mjs pins its own. Reusing the existing
lexer rather than growing a second regex is the obvious route, but which shared helper is
right is a judgment call for whoever picks this up. Not fixed in PR #10817: different file,
different gate, and #10713 was explicitly comment-only.
Verified against origin/main at f4e5d916d6.
Generated by Claude Code
Generated by Claude Code
Activity
huangyiirene commentedon Aug 21, 2026
Triage first-touch: promoted to queue, type Task. Latent false positive, both assertions land on
Lint & Repo Gates, and the trigger is exactly the kind of comment the neighbouringci.ymlblock already writes for the sibling flag. Scope: make the recognizer inscripts/check-required-contexts.mjsignore mentions inside trailing comments andrun:block-scalar shell comments, and pin the trailing-comment case in that script's self-test the waycheck-shard-attestation.mjspins its own. Whether to reuseshellCommands()/a shared helper or narrow locally is the implementer's call — measured against not growing a second bespoke lexer. Size/model suggestion: S, sonnet.Generated by Claude Code
claude commentedon Aug 21, 2026
Claim:
/pm-dispatchdomain:devx execution seat.Session:
session_01DdCnBGcHeufjrq7drTD3wt· Branch:claude/issue-10818-required-contexts-comment-strip· Worktree:objectstack-issue-10818Container & model:
M,mode:subagent,model: opusFile surface:
scripts/check-required-contexts.mjs(+ its self-test).Scope from triage: make the recognizer ignore mentions inside trailing comments and
run:block-scalar shell comments, and pin the trailing-comment case in that script's self-test the waycheck-shard-attestation.mjspins its own. Whether to reuseshellCommands()/ a shared helper or narrow locally is your call — measure it.⭐ The sibling precedent is the whole point, and it is close at hand:
check-shard-attestation.mjsalready solved this with a real lexer that drops shell comments, and its--self-testpins the comment case explicitly (a--verify-in-a-comment fixture). PR #10817 landed today relying on exactly that property.uncommentedYaml's/^\s*#/filter is the weaker half of the same idea.Lint & Repo Gates, and the trigger is the ordinary way anyone would write a warning about this very flag — the neighbouringci.ymlblock already writes such a comment for the sibling flag. So this fires the first time someone documents the trap.Standing constraints
docs/adr/**,.claude/**,skills/**,AGENTS.md,CLAUDE.md— propose wording in the report.content/docs/releases/**. ⛔ Nevergit stash—refs/stashis shared by every worktree of the repo.cmd > log 2>&1; ec=$?.pnpm --filter <typo>exits 0 with "No projects matched the filters" — a whole verification round can be fictitious and read as green #10853, measured today:pnpm --filter <name>with a name that does not exist printsNo projects matched the filtersand EXITS 0 — a whole verification round can read as green while nothing ran. Verify your filter matched; a negative control (--filter @objectstack/definitely-not-a-package) is the cheap way./home/user/objectstackis STALE. Measure againstorigin/mainor your own worktree — never the shared tree. That mistake bit this seat twice today.dispatch-gatesis blind to bothscripts/**gates — runcheck:entry-guardandcheck:parse-guardby hand.POST /issues/N/labels), never a whole-set PUT, and read back after the size labeler runs.mainhasConsole Pin Gatered for a known unrelated cross-repo reason (p0: main is RED — #10695 retired six spec/ui theme schemas that the PINNED objectui still imports, so Console Pin Gate cannot build the SPA #10856) — non-blocking, ⛔ not yours, ⛔ not a signal about your change.Report back to me; I review against GitHub and land it.
Generated by Claude Code
fix(scripts): check-required-contexts reads comments as prose, not as…
claude commentedon Aug 21, 2026
{ "issue": 10818, "status": "done", "branch": "claude/issue-10818-required-contexts-comment-strip", "pr": "https://github.com/objectstack-ai/objectstack/pull/10878", "premise_still_valid": true, "summary": "The card's premise held exactly as filed: pristine origin/main's --self-test is green at 124 assertions, so the defect was latent. `uncommentedYaml`'s `/^\\s*#/` line filter is replaced by `liveWorkflowText(doc)`, which hands each of the two stacked comment grammars to the thing that knows it -- `yaml.parse` for the YAML layer (every comment gone, leading or trailing; a `#` inside a quoted scalar kept) and check-shard-attestation's exported `shellCommands()` lexer for the shell inside each `run:`. MEASURED REUSE CHOICE: imported the sibling's lexer rather than hand-rolling a second one (the js-comment-mask.mjs history: two private stripComments families drifted apart in opposite directions) and rather than extracting/mirroring a shared module (#10628 had to undo exactly that; `shellCommands` is already exported and already import-safe by its own #10667 note, and nine scripts/check-*.mjs files already import from a sibling check-*). So check-shard-attestation.mjs is UNTOUCHED -- the PR is one file, +301/-10. Deliberately did NOT adopt the sibling's `invokesScript()` adjacency test: --verify and --emit are flags other programs really take (what #6589 misread), while --verify-required-set is spelled nowhere else in the tree, so adjacency would remove a false positive that cannot occur while adding false negatives that can (the flag via a shell variable, or an invocation spelling not enumerated). Width outside `run:` is therefore kept on purpose and pinned. Two orphaned consumers of the deleted stripper were re-homed: the patrol's merge_group check now reads the trigger block through this file's own already-pinned `triggersOf()` (and stops being vacuously true with no readable `on:`), and an unparseable workflow is now a named failure instead of a silent classification (#4690).", "tests": "All gates run in the worktree at final commit b5ef0d6c9d with a clean tree (`git status --porcelain` empty), exit codes captured before any pipe (`cmd > log 2>&1; ec=$?`), each quoted from the gate's OWN verdict line. Gate set derived by `node scripts/pm/dispatch-gates.mjs` with no paths (it took its own change set from merge base 22f662998: 1 path, scripts/check-required-contexts.mjs) -> 5 families, plus the two it is structurally blind to. [1] pnpm check:required-contexts exit=0 -- '✓ check-required-contexts --self-test: 135 assertions ... with the comment-vs-code recognizer pinned in both directions' and '✓ check-required-contexts: 6 required context name(s) pinned across 2 workflow(s); 5 instruction surface(s) scanned'. [2] pnpm check:cross-package-test-inputs exit=0 -- 'OK: 13 package(s) read outside themselves, all declared, and turbo.json hashes every declared glob.' [3] node scripts/check-ci-filter-parity.mjs exit=0 -- 'OK: all 82 declared cross-package glob(s) (71 unique) are covered by `core` or `crosspkg`'. [4] pnpm check:entry-guard (hand-run) exit=0 -- '✓ check:entry-guard: 129 scripts/ file(s) -- every entry guard goes through invoked-as.mjs; 87 export bindings, 77 of them inert on import'. [5] pnpm check:parse-guard (hand-run) exit=0 -- dispatch-gates itself reports this family 'unreachable BY CONSTRUCTION', which is precisely why it is hand-run. [6] pnpm check:nul-bytes exit=0 -- 'check-nul-bytes: OK (scanned 6292 text file(s) ... no raw ASCII control bytes)'. [7] pnpm check:shard-attestation exit=0 -- '✓ ...: 92 assertions' / '✓ ...: 2 aggregate gate(s) count 3 declared leg(s)'; run because this PR now IMPORTS from that file, which is itself unchanged. [8] eslint scripts/check-required-contexts.mjs --no-inline-config exit=0, no output. REVERSE VERIFICATION (single variable, at the recognizer, not at the fixtures -- the pins were refactored so the fixtures are workflow SOURCE and `wired()` is the whole pipeline, letting the recognizer be swapped without touching a fixture). NO BUILD/dist is involved: these are plain .mjs scripts that the gate executes from source, so there is no dist rebuild leg -- the mutation is proven on disk instead, by marker count before/after, never by an editor's exit code: 'const wired = (source) => wiresLiveRead(parse(source));' 1 -> 0 and 'ABLATION' 0 -> 1, with the mutated line printed back by grep -n. Direction PREDICTED BEFORE RUNNING: exactly two pins red -- the trailing YAML comment and the trailing shell comment -- with the whole-line pins and all six live limbs staying green. OBSERVED, verbatim: '✗ check-required-contexts --self-test -- 2 failure(s)' / 'recognizer: a TRAILING YAML comment naming --verify-required-set is prose, not wiring -- the line filter this replaced kept the whole line' / 'recognizer: a TRAILING shell comment inside a run: block scalar is prose'. Prediction matched. RESTORE LEG run and proven: `git checkout <branch> -- scripts/check-required-contexts.mjs`, then 'ABLATION' marker back to 0, seam back to 1, `git status --porcelain` empty; the union above was then run on that restored tree. BASELINE: `git show origin/main:scripts/check-required-contexts.mjs` run standalone -- '124 assertions', green, confirming the defect is latent on main exactly as the card says (branch: 135, i.e. +11 = 10 recognizer pins + 1 unparseable-workflow pin). BOTH LIMBS pinned as triage asked: 4 prose shapes that must NOT read as wiring (trailing YAML comment; whole-line YAML comment; trailing shell comment in a run: block scalar; the #4890 'documenting the invocation' shape) and 6 live shapes that MUST (the same command minus the `#` -- the pair differs by the comment marker alone; the patrol's own backslash-continuation spelling; a quoted `#` as an argument; a `#` inside a quoted YAML scalar; a flag arriving via an env: value; defaults.run as structure). Labels read back AFTER the size labeler ran: ['size/m', 'skip-changeset'] -- the additive POST and the bot's label both present. No changeset: scripts/** only, nothing published changes.", "open_questions": [], "out_of_scope_findings": [ "filed as #10877: check-required-contexts' self-test proves its own WIRING with text a comment can supply -- a second, distinct /^\\s*#/ filter feeding a PRESENCE assertion (a trailing comment satisfies 'the lint job runs the pin'), plus the caller sweep counting the patrol's `echo \"::error::... --verify-required-set ...\"` as a caller. Opposite failure direction (false GREEN), not mechanical to fix, and it wants the NARROW recognizer this PR argues against for the absence half -- filed unassigned and unlabeled for PM triage, not ridden along." ] }Generated by Claude Code
fix(scripts): check-required-contexts reads comments as prose, not as…
fix(scripts): the required-context self-test proves WIRING with invoc…