Skip to content

specs: remove the duplicate test blocks identical to their twin - #3482

Merged
gHashTag merged 1 commit into
masterfrom
c/dedupe-identical-tests
Sep 8, 2026
Merged

specs: remove the duplicate test blocks identical to their twin#3482
gHashTag merged 1 commit into
masterfrom
c/dedupe-identical-tests

Conversation

@gHashTag

@gHashTag gHashTag commented Sep 8, 2026

Copy link
Copy Markdown
Owner

specs: remove the duplicate test blocks identical to their twin

Closes #3481

#3480 made the duplicate-declaration gate see 341 duplicated names in 30
specs and measured that 174 of the blocks had a body byte-identical to
their twin. This removes them: only a block whose body is IDENTICAL to
an earlier block of the same name in the same spec. Nothing renamed,
nothing merged.

blocks removed 188
specs touched 29
lines deleted 838
lines inserted 0

errors 12 071 -> 11 780 (-291)
redefinition of 'X' 365 -> 204 (-161)
baseline 30 / 341 names -> 27 / 172
spec test lines 14 613 -> 14 425 (-188)

188 rather than 174: the estimate came from a cruder extractor that
mis-parsed the two brace-form specs.

THE DECISIVE CONTROL IS A BEFORE/AFTER DIFF OF THE GENERATED C, not of
the specs, because that is the artifact the change is about. Across all
582 headers: 29 changed -- exactly the specs edited -- with 1203 removed
lines inside a void test_*(void) region, 183 blanks beside one, 27 old
printf("All %d tests passed") lines, and ZERO removed from anywhere
else; 29 added, all the same summary line with a smaller count.

READING ONE SPEC'S DIFF BY HAND, BEFORE APPLYING ANYTHING, FOUND THE
REAL BUG. invariant was not among the tokens that end a Gherkin-form
block, so a duplicate test ran on through the invariant that followed
it and deleting the test would have deleted a live declaration. No
aggregate would have shown it: the corpus totals improve either way.

MY OWN ROUND-TRIP CONTROL WAS MEASURING ITS OWN JOIN. It compared the
re-assembled file as a STRING, and joining pieces with newlines inserts
one wherever a piece is empty -- which is wherever two blocks abut. It
refused 49 specs on that. Comparing line lists: 0 refused.

AND THE COUNTING CONTROL'S SAFE SET HAD TO BE MEASURED. In the brace
form a test body legitimately holds const provider = ...,
type = ContentType::Text, (a struct field) and invariant cov == 100;
(an assertion); counting those anywhere refuses two specs for nothing.
Measured: struct, module, impl, use, bench never occur inside
a test body at any indentation, and invariant/fn/const/type/
enum never at column zero.

The tool is kept rather than thrown away, because the job is not
finished: 172 duplicated names remain whose bodies DIFFER, and when one
is resolved by renaming rather than deleting, this must be re-run to
confirm it created no new identical pair. It is idempotent -- a second
run reports 0.

Gates: specs parse, specs generate, duplicate declarations, assertionless
tests, seal currency all pass. Full suite 3533 passed 0 failed. 29 stale
seals refreshed.

🤖 Generated with Claude Code

Closes #3481

#3480 made the duplicate-declaration gate see 341 duplicated names in 30
specs and measured that 174 of the blocks had a body byte-identical to
their twin. This removes them: only a block whose body is IDENTICAL to
an earlier block of the same name in the same spec. Nothing renamed,
nothing merged.

  blocks removed            188
  specs touched              29
  lines deleted             838
  lines inserted              0

  errors            12 071 -> 11 780   (-291)
  redefinition of 'X'  365 ->    204   (-161)
  baseline    30 / 341 names -> 27 / 172
  spec `test` lines 14 613 -> 14 425   (-188)

188 rather than 174: the estimate came from a cruder extractor that
mis-parsed the two brace-form specs.

THE DECISIVE CONTROL IS A BEFORE/AFTER DIFF OF THE GENERATED C, not of
the specs, because that is the artifact the change is about. Across all
582 headers: 29 changed -- exactly the specs edited -- with 1203 removed
lines inside a `void test_*(void)` region, 183 blanks beside one, 27 old
`printf("All %d tests passed")` lines, and ZERO removed from anywhere
else; 29 added, all the same summary line with a smaller count.

READING ONE SPEC'S DIFF BY HAND, BEFORE APPLYING ANYTHING, FOUND THE
REAL BUG. `invariant` was not among the tokens that end a Gherkin-form
block, so a duplicate test ran on through the invariant that followed
it and deleting the test would have deleted a live declaration. No
aggregate would have shown it: the corpus totals improve either way.

MY OWN ROUND-TRIP CONTROL WAS MEASURING ITS OWN JOIN. It compared the
re-assembled file as a STRING, and joining pieces with newlines inserts
one wherever a piece is empty -- which is wherever two blocks abut. It
refused 49 specs on that. Comparing line lists: 0 refused.

AND THE COUNTING CONTROL'S SAFE SET HAD TO BE MEASURED. In the brace
form a test body legitimately holds `const provider = ...`,
`type = ContentType::Text,` (a struct field) and `invariant cov == 100;`
(an assertion); counting those anywhere refuses two specs for nothing.
Measured: `struct`, `module`, `impl`, `use`, `bench` never occur inside
a test body at any indentation, and `invariant`/`fn`/`const`/`type`/
`enum` never at column zero.

The tool is kept rather than thrown away, because the job is not
finished: 172 duplicated names remain whose bodies DIFFER, and when one
is resolved by renaming rather than deleting, this must be re-run to
confirm it created no new identical pair. It is idempotent -- a second
run reports 0.

Gates: specs parse, specs generate, duplicate declarations, assertionless
tests, seal currency all pass. Full suite 3533 passed 0 failed. 29 stale
seals refreshed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) September 8, 2026 11:01
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-09-08 11:01:32 UTC

Summary

Status Count
Total Open PRs 16
PRs with Failing Checks 13
PRs with All Checks Green 3
READY 2
FAILING 13
PENDING 0
NO CHECKS YET 0

These columns do not partition: 2 + 13 + 0 + 0 = 15, and there are 16 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=d0bfdbd5a5fc != 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 8, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

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

@gHashTag
gHashTag merged commit 9816fb5 into master Sep 8, 2026
28 of 30 checks passed
gHashTag added a commit that referenced this pull request Sep 8, 2026
…nit (#3504)

Closes #3503

Last pass found a population column counting comments: `sign` published
as "63 uses in 48 specs" is one use in one spec, and that 63 had already
become a recommendation. The obvious response is to re-count every
figure this campaign has published. ALMOST NONE OF THE MOVEMENT WAS
MISCOUNTING.

  figure                    published   in code   why
  cast_i8 uses                   1079      1079   --
  []T{} empty slice literals      478       478   --
  abs( uses                       389       389   --
  x.len()                        1322      1319   3 in comments
  x.len                           687       680   7 in comments
  three-segment paths             477       473   4 in comments
  len(x)                         "142"      296   142 was a DIAGNOSTIC count
  pub const OP_*                  "20"       11   20 was a SITE count in the C
  [T]                             220   220/228   depends on the primitive set

THE TWO LARGE DISCREPANCIES ARE UNIT CONFLATIONS, not counting errors: a
sentence about the specs quoting a number measured in the generated C.
And `[T]` moves by 8 depending on whether `float` and `int` count as
types -- a number that cannot be reproduced without its matcher is not a
measurement.

So the repair is not another re-count. This pins each figure WITH the
regex that produced it and the UNIT it is in, re-derives them from the
specs in code only, and `--check` exits 1 on drift -- the contract the
census pin already has here: a change that moves a number must say so.

IT CAUGHT ONE ON ITS FIRST RUN: test blocks 12 644 -> 12 456. The corpus
moved and the reason is on the record -- #3482 deleted 188 duplicate
blocks whose bodies were byte-identical to their twin, and
12 644 - 188 = 12 456. The pin followed the corpus rather than being
blessed away.

Wired into Spec Guards beside the duplicate-declaration ratchet, with
the `paths:` filter extended so a change to the file triggers the
workflow that reads it. Positive control recorded: with a deliberately
wrong pin the gate exits 1 and names the drifting row; restored, 0.

CENSUS RE-BLESSED IN THIS COMMIT, and the number is this change's own:
`run: steps` 246 -> 248, the two steps added to Spec Guards -- the
self-check and the `--check` gate. Nothing else moved.

Corrections published: `x.len()` 1319 not 1322; `x.len` 680 not 687;
three-segment paths 473 not 477; the `len(x)` spelling is 296 uses in 29
specs, not 142; `pub const OP_*` declarations are 11 in one spec, not 20.

Full suite 3568 passed 0 failed. No codegen change: 0 stale seals.

Co-authored-by: lab <lab@example.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

specs: remove the 188 duplicate test blocks whose body is identical to their twin

1 participant