Skip to content

feat(sieve): DDC of t27core through t27c and t27b (Closes #6508) - #6825

Merged
gHashTag merged 2 commits into
masterfrom
sieve/ddc-t27core
Oct 6, 2026
Merged

gHashTag merged 2 commits into
masterfrom
sieve/ddc-t27core

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Closes #6508
Refs #6488 #5980

Diverse Double-Compiling of the self-hosted core (theorem T732).

What lands

  • specs/compiler/core/t27core_ddc.t27 (new). It imports t27core through use and carries S (t27core.t27) and E (t27c gen-c S) as tool-packed data, with sha256 sums pinned next to the lengths. Its one test runs S's compile on S and checks that the output is E byte for byte. It then flips one byte and requires the comparison to find exactly that byte. Each backend that builds this module builds a stage-1 core, and running the test is that core's stage 2.
  • specs/compiler/core/t27core.t27: changes so all three compilers can build it.
    • Buffers hold 65536 elements, t27b's repeat cap. They held 512K and 4M before.
    • Indexes are as usize and put_int divides unsigned, both for Zig.
    • Tests use fresh locals instead of reassigning one. Both Zig and t27b read a reassignment as a redeclaration.
    • { } [ ] character literals became K_* constants, because use_resolve counts brackets inside character literals and cut functions short.
    • Three parse functions step with advance() instead of a repeated p = p + 1. The repeated form triggers the gen-zig CSE miscompile in gen-zig CSE hoists count + 1 above var count and across its reassignment #6292.
  • bootstrap/tests/core_selfhost.rs: one line. run_core no longer panics on the closed pipe when the core refuses a spec longer than SRC_MAX. With the smaller buffers, 24 corpus specs are longer than that.
  • tools/policy/foreign-exceptions.txt: entry for that test file.

Stage 2 on each route (lab evidence, commit 0fbd183)

Route Stage-1 build Stage 2 == E Where
A gen-c + cc fixpoint core(S) == gen-c(S), own tests 8/8, corpus differential cargo test --release -p t27c --test core_selfhost on the t27c lab: ok
B t27b, AArch64 under qemu PASS, 7 runtime asserts, JIT == interpreter t27b lab
C t27c Zig reference PASS t27b lab

The comparison is one command. It runs routes B and C and compares their verdicts test by test:

t27b corpus specs/compiler/core --blockers --reference target/release/t27c
  supported, all tests pass : 2 (9 tests)
  JIT/interpreter mismatch  : 0
  reference: compiles, every test passes : 2
  reference disagree (per test, t27b against t27c + zig): 0 files, 0 tests, of 2 files compared

Lab records:

The t27b lab runs the same t27b and reference comparison over all of specs/ on every master commit, so after merge both files are covered there too. The t27b and t27c binaries are the lab's master build; this PR changes no t27b or t27c source.

t27core.t27 under the Zig reference: 8/8 PASS. Under t27b test --check: 8/8, 19 runtime asserts.

The core_selfhost corpus differential still accepts 59 specs, the same set as master, with 0 mismatches against gen-c. That was measured with the cc-built core, outside cargo.

Found by the harness

Limitation (T729), stated next to the result

t27b mounts bootstrap/src/compiler.rs's parser and type checker through #[path], and gen-c and gen-zig run behind the same parser. A front-end defect is therefore common mode: all three routes can agree on it. The diversity here is in the back ends only (C via cc, AArch64 via t27b, Zig via zig). Wheeler's independence also requires a second front end, which is not removed here.

The harness header states two more limits:

  • The comparison runs inside each built program. The flipped-byte control rules out a no-op comparison, but it does not rule out a targeted trojan.
  • The data is pinned to the sums in the file and must be regenerated when t27core changes.

Foreign code

The owner added the label owner-approved-foreign to #6508 on 2026-10-06. Under that approval this PR edits one line of an existing Rust test, bootstrap/tests/core_selfhost.rs, and lists the file in tools/policy/foreign-exceptions.txt. No new foreign file is added. bootstrap/src/compiler.rs is not touched.

Not done here

specs/compiler/theory/toolchain.t27 T732 still says "Today it cannot run". Updating that text would make its seal stale, so it needs a reseal on the lab and is left for a follow-up.

🤖 Generated with Claude Code

Diverse Double-Compiling of the self-hosted core (theorem T732, epics
#6488 and #5980). specs/compiler/core/t27core_ddc.t27 imports t27core
through `use`, carries S (t27core.t27) and E (`t27c gen-c S`) as data,
and has one test: S's compile on S must write E byte for byte, and one
flipped byte must be found. Each backend that builds the module runs its
own stage 2:

  gen-c + cc     core_selfhost.rs fixpoint (core(S) == gen-c(S))
  t27b AArch64   t27b test --check: PASS, 7 runtime asserts
  Zig reference  t27c test-report: PASS

`t27b corpus specs/compiler/core --blockers --reference <t27c>` runs the
t27b and Zig routes and compares them test by test: 2 files, 0 disagree.

t27core changes so three compilers can build it: buffers of 65536
elements (t27b's repeat cap), usize indexes and unsigned division (Zig),
fresh test locals instead of reassignment, brace and bracket character
literals as K_* constants (use_resolve counts them), and advance()
instead of a repeated `p = p + 1` (gen-zig CSE miscompile #6292, found
by this harness). Fixpoint and the 59-spec corpus differential still
hold. Hex data words lost digits in the front end (#6802), so the data
is decimal.

Limitation (T729), stated in the harness: t27b mounts compiler.rs's
parser and type checker, so all three routes share one front end; the
diversity is in the back ends only.

core_selfhost.rs ignores the closed pipe when the core refuses a spec
longer than SRC_MAX (owner-approved-foreign on #6508).

Refs #6488 #5980

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gHashTag gHashTag added the owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR label Oct 6, 2026
@gHashTag
gHashTag enabled auto-merge (squash) October 6, 2026 13:00
Conflict in tools/policy/foreign-exceptions.txt: both entries kept
(core_selfhost.rs for #6508, test_report.rs and main.rs for #6509).
compiler.rs, use_resolve.rs and specs/compiler/core are unchanged on
master, so S, E and their sha256 sums in t27core_ddc.t27 still hold.

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-06 13:38:58 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 48
PRs with All Checks Green 2
READY 1
FAILING 48
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 48 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c78f3c7ffb7 != 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 bdf66f4 into master Oct 6, 2026
31 of 37 checks passed
gHashTag added a commit that referenced this pull request Oct 6, 2026
T732 said the Diverse Double-Compiling check of t27core "cannot run"
because t27b was BLOCKED on t27core.t27. PR #6825 makes it run: the
harness specs/compiler/core/t27core_ddc.t27 builds a stage-1 core on
three back ends (gen-c + cc, t27b AArch64, Zig reference) and each
stage 2 equals t27c gen-c of S byte for byte (lab records cited in the
spec). The text now states that result, the two defects the run found
(#6292, #6802), and keeps the T729 limit: the front end is shared, so
the agreement is of back ends only.

The model gains the verdict rule over routes (cannot run / miscompile /
back-end agreement / independent agreement), with the shared-front-end
flag taken from T729's shared() rather than restated. Tests check the
three recorded runs (before #6825, the first Zig run of #6292, commit
0fbd183), an exhaustive enumeration over every route mask, and a
negative control: the self-host fixpoint alone passes the run DDC flags.
Mutation check on the lab: dropping the miscompile branch fails all
three new tests.

Seal: t27c seal --save on the Railway t27c lab (t27c built from this
tree), tests 20/20.

Refs #6488 #6508

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Oct 6, 2026
T732 said the Diverse Double-Compiling check of t27core "cannot run"
because t27b was BLOCKED on t27core.t27. PR #6825 makes it run: the
harness specs/compiler/core/t27core_ddc.t27 builds a stage-1 core on
three back ends (gen-c + cc, t27b AArch64, Zig reference) and each
stage 2 equals t27c gen-c of S byte for byte (lab records cited in the
spec). The text now states that result, the two defects the run found
(#6292, #6802), and keeps the T729 limit: the front end is shared, so
the agreement is of back ends only.

The model gains the verdict rule over routes (cannot run / miscompile /
back-end agreement / independent agreement), with the shared-front-end
flag taken from T729's shared() rather than restated. Tests check the
three recorded runs (before #6825, the first Zig run of #6292, commit
0fbd183), an exhaustive enumeration over every route mask, and a
negative control: the self-host fixpoint alone passes the run DDC flags.
Mutation check on the lab: dropping the miscompile branch fails all
three new tests.

Seal: t27c seal --save on the Railway t27c lab (t27c built from this
tree), tests 20/20.

Refs #6488 #6508

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DDC: diverse double-compile t27core through t27c and t27b (T732)

1 participant