Skip to content

gates: a real scanner, so a continued string is not read as code - #3262

Merged
gHashTag merged 8 commits into
masterfrom
w108-a-real-scanner
Sep 5, 2026
Merged

gHashTag merged 8 commits into
masterfrom
w108-a-real-scanner

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Finishes the case #3255 reported and deliberately left unfixed.

test_module_lines used per-line rules, and no line rule can express an
ordinary string continued with a trailing backslash
. types_dup.rs holds

const THREE_SPELLINGS: &str = "\
struct Alpha { a: u32 }
...
enum E {
    struct = 21,
}
";

whose fixture has a column-0 } at line 1115. That closed the file's test
module, and everything after it was reported as production: 29 test-only
literals handed to the mutator as constants
.

What replaces them

code_mask — one character pass over line and nested block comments, ordinary
strings honouring escapes (which is exactly what lets them span lines), raw
strings with hash-counted closes, and char literals kept distinct from
lifetimes. test_module_lines now asks it whether a line's first byte is code
before treating a } as a close.

file offered skipped as test sites inside its own test module
types_dup.rs 71 → 40 11 → 42 29 → 0
competitors.rs 114 → 45 14 → 77 36 → 0
nine others unchanged unchanged —

gates.rs reads 251 rather than 221 because this change edits gates.rs —
it adds ~120 lines of scanner with 42 literals of its own. Master's own copy of
gates.rs, run under this binary, is unchanged at 221/218.

Mutation

Five killed: the ordinary-string rule never firing · escapes ignored · block
comments not nested · the raw close ignoring its hash count · the caller
ignoring the mask.

Two controls had to be sharpened before they could kill anything.
/* /* 888 */ */ has 888 inside whether or not nesting is honoured, and the
continuation fixture contained no escaped quote. Both passed under their
mutants until the digit was moved after the inner close and an escaped quote
added. A control that cannot fail is not a control.

The guard, one last time

#3256 recorded that a !prev_is_word check was a decoration in masked() and
load-bearing in raw_string_opens. This change deletes raw_string_opens
— code_mask supersedes it — so the guard is a decoration again and is gone.
Measured across eleven files plus the probe: zero differ.

Necessity was never a property of the check; it was a property of the scanner's
shape. tri gates warnings flagged the orphaned raw_string_opens immediately
after the merge, which is what that command exists for.

cargo test -p tri --bin tri: 779 passed, 0 failed.

Refs #3255

gHashTag and others added 6 commits September 5, 2026 15:22
Two defects, same family, both measured with the tool against master's binary.

`masked()` is deliberately language-agnostic -- it runs on a Python oracle, a
Verilog header and a YAML workflow. But `#` opens a comment two rules down, so
`r#"` was read as `r` followed by a comment to end of line, and the raw string's
CONTENTS came back marked as code. A probe holding
`pub const FIXTURE: &str = r#"\n threshold = 12345\n other = 6789\n"#;` was
reported as "4 literal(s)", offering both fixture numbers as constants.

`test_module_lines` ended a `#[cfg(test)]` module at a line that is exactly `}`,
and competitors.rs has one inside the raw string `const TWO` (opens 681, the
brace at 692). Everything after it was reported as production: 36 offered sites
sat below that file's own `#[cfg(test)]` at 567.

Perturbing fixture text and reading the red as "the checker noticed" is the
tautology `drop_test_module_sites` exists to prevent, through another door.

Measured, master's binary vs this one, same eleven files:

  competitors.rs  offered 114 -> 45   skipped 14 -> 77   in-module 36 -> 0
  fpga.rs         offered 376 -> 376  skipped 637 -> 617
  nine others     unchanged

Four mutants, all previously green, now red: the rule never firing, the hash
count ignored, the close searched from the wrong offset, and an unterminated
raw string stopping at the quote instead of end of file.

Two branches were REMOVED after mutation showed them unexercisable and a probe
showed why: a `!prev_is_word` guard and a `br#"` prefix branch, both in
`masked()`, where the ordinary-string rule reaches those bytes first and masks
the same span. The same guard IS load-bearing in `raw_string_opens`, which has
no such rule -- without it `"cannot occur"` reads as an unclosed raw-string
opener. Only measurement tells the two apart.

Not fixed, reported in the issue: types_dup.rs uses an ORDINARY string
continued with a backslash whose fixture has a column-0 brace at 1115, leaving
29 test-only sites offered. A quote-parity rule was written and reverted after
measurement -- it took fpga.rs from 376 offered / 637 skipped to 993 / 0.

Refs #3255

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ring in the next

Records the raw-string pass. The bug is small; three things around it are not.

A `!prev_is_word` guard was written into two functions. In `masked()` mutation
removed it and everything stayed green -- the ordinary-string rule reaches those
bytes first -- so it was deleted. In `raw_string_opens`, a per-line scanner with
no such rule ahead of it, the identical check carries the whole case. The same
code one function apart is dead in one place and structural in the other, and
only measurement separates them.

A plausible fix for the ordinary multi-line string -- an odd number of unescaped
quotes opens one -- was written and reverted after measurement took fpga.rs from
376 offered / 637 skipped to 993 / 0.

And the baseline has to come from the other binary: I recorded gates.rs at 213
from a partially-modified build, then read 221 and chased a regression that did
not exist. Master reads 221 too.

Refs #3255

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts:
#	.claude/skills/ci-gates/SKILL.md
`test_module_lines` used per-line rules, and no line rule can express an
ordinary string continued with a trailing backslash. `types_dup.rs` holds
`const THREE_SPELLINGS: &str = "\` whose fixture has a column-0 `}` at line
1115: that closed the file's test module and handed 29 test-only literals to
the mutator as production constants.

Replaces the line rules with `code_mask`, one character pass over line and
nested block comments, ordinary strings honouring escapes -- which is what lets
them span lines -- raw strings with hash-counted closes, and char literals as
distinct from lifetimes.

Measured against master's binary, same eleven files:

  types_dup.rs    offered 71 -> 40  skipped 11 -> 42  in-module 29 -> 0
  competitors.rs  offered 114 -> 45 skipped 14 -> 77  in-module 36 -> 0
  nine others     unchanged

Five mutants killed: the ordinary-string rule never firing, escapes ignored,
block comments not nested, the raw close ignoring its hash count, and the
caller ignoring the mask. Two controls had to be SHARPENED first -- the
originals passed under their mutants because `/* /* 888 */ */` has 888 inside
either way and the continuation fixture held no escaped quote. A control that
cannot fail is not one.

The `!prev_is_word` guard is removed. It was load-bearing one revision ago, in
the per-line scanner that had no string rule ahead of it; here the
ordinary-string rule consumes `"cannot occur"` whole and the scan never lands
on the `r`. Measured across eleven files plus the probe: zero differ. Necessity
is a property of the scanner's shape, not of the check.

Refs #3255

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) September 5, 2026 09:09
Replacing a line scanner with a character pass, mutation killed only some
branches -- and two of the controls were the reason, not the code.

`/* /* 888 */ */` cannot prove nesting: 888 is inside either way. It had to
become `/* /* x */ 999 */`, digit after the inner close. The escape control
named `\` handling but its fixture held no escaped quote, so the string closed
at the same byte with or without escapes.

Both passed. Both looked like they exercised the branch they named.

Also records that the `!prev_is_word` guard, load-bearing one revision ago, is a
decoration again now that the per-line scanner it protected is gone -- and that
a baseline regenerated from a moving `origin/master` is not a baseline, which
cost a diagnosis of a regression that did not exist.

Refs #3255

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 09:14:19 UTC

Summary

Status Count
Total Open PRs 13
PRs with Failing Checks 13
PRs with All Checks Green 0
READY 0
FAILING 13
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b52fccebfa30 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 09:15:00 UTC

Summary

Status Count
Total Open PRs 13
PRs with Failing Checks 12
PRs with All Checks Green 1
READY 0
FAILING 12
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=0db5123491c1 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-05 09:35:34 UTC

Summary

Status Count
Total Open PRs 12
PRs with Failing Checks 12
PRs with All Checks Green 0
READY 0
FAILING 12
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=ab7505edd6ab != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit 36288fd into master Sep 5, 2026
28 of 30 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