Skip to content

The step became the body, in four backends - #2866

Merged
gHashTag merged 1 commit into
masterfrom
w721
Aug 29, 2026
Merged

The step became the body, in four backends#2866
gHashTag merged 1 commit into
masterfrom
w721

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

while (cond) : (step) { body } parses to three children — condition, continue expression, body. Every while emitter read children[1] as the body and never looked at children[2].

spec      while (i < corpus.len) : (i += 1) {
              scores[i] = compute_similarity(query.embedding, corpus[i].vector);
          }

emitted   while (i < corpus.len) {
              i += 1;
          }

A loop that advances a counter and computes nothing — in code all four target languages accept.

Four backends, not one

The audit that found this (#2860) reported it for Zig. Checking the other three took one command each:

backend before
Zig while (i < k) { i += 1; }
C while ((i < k)) { i += 1; }
Verilog while ((i < k)) begin i = i + 1; end
Rust while (i < k) { i += 1; }

Verilog is the one that reaches silicon.

6 sites, and why "step last" is correct at all of them

4 specs, 6 sites, counted. None of the six bodies contains a continue or a break — which is what makes the repair sound for the three languages with no continue expression, where the step becomes the last statement of the body. A continue would skip it, and that limitation is written beside each emitter rather than left to be found later.

Zig gets the real : (step) form back.

The step arrives wrapped

Emitting children[1] directly printed /* unsupported expr: Module */ in both C and Verilog — the continue expression is inside a block node. A shared unwrap_single descends to the statement.

Nothing moved, and that is the point

before after
zig ast-check 224 / 559 224 / 559
specs cc accepts 171 171
suite 2455 / 0 2455 / 0
iverilog on the affected spec exit 2 exit 2 (pre-existing)

The wrong loop was already valid. No acceptance measure could ever have caught this.

bootstrap/stage0/FROZEN_HASH resealed.

Refs #2860

`while (cond) : (step) { body }` parses to THREE children -- condition,
continue expression, body. Every `while` emitter read `children[1]` as
the body and never looked at `children[2]`.

    spec      while (i < corpus.len) : (i += 1) {
                  scores[i] = compute_similarity(query.embedding,
                                                 corpus[i].vector);
              }

    emitted   while (i < corpus.len) {
                  i += 1;
              }

A loop that advances a counter and computes nothing, in code all four
target languages accept.

The audit that found this (#2860) reported it for Zig. It is Zig, C,
Verilog AND Rust: four emitters, the same off-by-one into the child
list. Verilog is the one that reaches silicon.

6 sites across 4 specs, counted. None of the six bodies contains a
`continue` or a `break` -- which is what makes the repair correct for the
three languages that have no continue expression, where the step becomes
the LAST statement of the body. A `continue` would skip it, and that is
written beside each one rather than left to be discovered.

Zig gets the real `: (step)` form back.

The continue expression arrives wrapped in a block node: emitting
`children[1]` directly printed `/* unsupported expr: Module */` in C and
Verilog alike, so a shared `unwrap_single` descends to the statement.

Nothing moved, and that is the point -- the wrong loop was already valid:

    zig ast-check   224 / 559  ->  224 / 559
    cc accepts            171  ->  171
    suite            2455 / 0  ->  2455 / 0

FROZEN_HASH resealed.

Refs #2860
@gHashTag
gHashTag enabled auto-merge (squash) August 29, 2026 18:46
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-29 18:46:47 UTC

Summary

Status Count
Total Open PRs 9
PRs with Failing Checks 7
PRs with All Checks Green 2
READY 1
FAILING 7
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=459c091c73e1 != 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

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 d7ee76d into master Aug 29, 2026
26 of 27 checks passed
gHashTag added a commit that referenced this pull request Aug 29, 2026
…ived its failure (#2909)

* fix(seals): re-seal 926 gen-drifted specs -- master has been red for 29 runs

`seal-coverage` last passed on master at 588074c, 18:23. The first red is
d7ee76d -- #2866, mine -- which changed four emitters, so generated output moved
while the specs did not.

The `coverage` check was already failing on PR #2866 when I merged it.

Twenty-nine runs later the drift is cumulative:

    926 seals [gen-drift]
      926  gen_hash_rust
       62  gen_hash_verilog
       33  gen_hash_zig
       31  gen_hash_c

The gate calls re-sealing a STATEMENT that the new output is wanted and says to
read the acceptance columns first. Read:

    corpus ratchet, master:  UNEXPECTED PASSES 1
                             DISCARD WORSENED  0
                             GATE FAILURES     0

Red on an improvement -- one more spec passes than the ledger expects, nothing
worsened. Acceptance is better than what is recorded, so this records outputs
whose acceptance rose. That ledger entry (151 -> 150) belongs to the parallel
session's #2906 and is not touched here.

After: 1318 seals, 1224 hold, 94 known-broken already in seal_baseline.txt.
`check_seal_coverage.py` exits 0, and its --self-check still exits 0, so the
green is the gate working rather than the gate skipped.

Closes #2908

* fix(ratchet): drop the emitter_xdc entry -- 151 -> 150, cap lowered with it

The second of master's two red gates, and like the first it is not a regression.

    --- Ratchet (W628) ---
      ledger:              151 / 151 cap
      observed (primary):  150
      UNEXPECTED FAILURES: 0
      UNEXPECTED PASSES  : 1
        - specs/pins/emitter_xdc.t27 [typecheck] (fixed -- remove from the ledger)

#2906 fixed it: an integer literal above i64::MAX fell to the float branch, so a
bit mask read as a float initialising an integer. The spec typechecks; the ledger
entry outlived the failure it recorded, and the ratchet named the repair itself.

`max_entries` drops with the entry rather than staying at 151, so the slack
cannot hide the next one. The reason is written into the file beside the number.

Refs #2908
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