Skip to content

t27b: @divTrunc and a @panic statement as the reference runs them, from builtin_plan.t27 (Closes #7790) - #7808

Merged
gHashTag merged 7 commits into
masterfrom
t27b-divtrunc-panic
Oct 8, 2026
Merged

gHashTag merged 7 commits into
masterfrom
t27b-divtrunc-panic

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #7790. Part of #6063 (t27b coverage), which is item C10 of #6488.

What the reference does

specs/tri/t27b/a64.t27, t27b's own A64 encoder spec, passes the reference (35/35, 0 vacuous) and t27b refused it on two builtins that gen-zig prints as written: ExprCall(@divTrunc) at line 637 (pair) and ExprCall(@panic) at line 790 (size_log2).

Measured on the t27c lab (t27c test-report, zig 0.16.0, x86_64 Debug), one probe per shape:

shape reference this branch's t27b
@divTrunc of two i32, of an i32 and a literal, of two u32 truncated quotient the same
@divTrunc(x, 0) at run time test fails test fails (division by zero)
@divTrunc(minInt(i32), -1) at run time test fails test fails (integer overflow)
@divTrunc(-7, 2) of two literals comptime -3 the same
if (x > 3) { @panic("m"); }, not reached / reached pass / fail pass / fail (assert failed at line 17 (@panic))
@panic("m"); then another statement in its block BLOCKED: unreachable code refused: ExprCall(@panic before more statements)
@panic(msg) with a str parameter compiles refused: ExprCall(@panic with non-literal message)

Decision, with the evidence

  • @divTrunc of two integers (typed or literal) lowers as t27b's /. gen-zig prints a signed a / b as @divTrunc(a, b) (W593), so t27b's / on integers is already the operator the reference runs for @divTrunc: truncation, the division-by-zero trap, then the MIN / -1 trap, and folding of two literals. A float, or any other operand, is refused as ExprCall(@divTrunc of a non-integer) (Zig's @divTrunc of floats truncates a float quotient, which / would not).
  • A @panic("m"); statement that is the last of its block is a trap that always fires, so the test that reaches it fails, as under the reference. Refused by name: a message that is not a string literal, and a @panic with statements after it (the reference does not compile that). A @panic the reference returns as a tail (gen (Zig): a trailing @panic statement is emitted as return @panic(...), which Zig rejects as unreachable code #7533) and a @panic in an expression keep their refusals: the glue never asks the plan for them.

Where the decisions live. specs/tri/t27b/builtin_plan.t27 (#7394) is extended: DIV_TRUNC with the OPERATOR answer of type_from and operator/op_text; panic_stmt, panic_what and panic_why. 4 new tests, 16 in all. t27c gen-rust gives gen/rust/tri/t27b/builtin_plan.rs, already mounted in lower.rs. The glue maps @divTrunc to the plan in builtin_plan, hands an OPERATOR answer to binary, records in stmts whether a statement is the last of its block, and turns the @panic statement into a trap.

Conformance spec first

specs/tri/t27b/conformance/div_trunc_panic.t27, 8 tests: rounding toward zero in all four sign combinations; a literal divisor or dividend taking the other operand's type; unsigned operands; extremes; each operand evaluated once; a64.t27's pair encoding; a64.t27's size_log2 with its @panic not reached; a @panic in a loop body not reached.

result
reference, t27c test-report 8/8, 0 vacuous, 30 runtime asserts; sealed (seal --save, then --verify: all hashes MATCH)
master's t27b refused: ExprCall(@divTrunc)
this branch's t27b (aarch64, qemu) 8/8
specs/tri/t27b/a64.t27 under this branch's t27b 35/35, as the reference

The plan spec: t27c test-report 16/16, 0 vacuous; sealed and verified.

Mutants

mutants of count killed under t27c test-report
the plan spec (tri mutate spec) 158 155; 2 hung (a dropped i = i + 1 in run_plan and digit_count: endless loops), 1 survived: i <= s.len in digits_at, all three in #7394's code, none in this PR's functions
the conformance spec (tri mutate spec) 28 27; 1 hung (a dropped loop step)

Glue, in cargo test --release -p t27b --test tail (div_trunc_and_a_panic_statement): the conformance spec 8/8 through the interpreter, the traps and their lines (division by zero and overflow at line 4, @panic at line 9), and three refusals (a statement after @panic, two messages, @divTrunc of floats).

Corpus, lowered by master's t27b and by this branch's (t27c lab, t27b corpus specs --blockers, master ab544f4's 1600 files)

file reference master's blockers this branch
specs/tri/t27b/a64.t27 pass ExprCall(@divTrunc), ExprCall(@panic) none; 35/35 pass
specs/port/tools/check_graph_law8.t27 blocked ExprCall(@stdout), ..., ExprCall(@panic) first blocker unchanged; the last is ExprCall(@panic with non-literal message)
specs/port/tools/check_withdrawn_live.t27 blocked type (tuple), ..., ExprCall(@panic) first blocker unchanged; the last is ExprCall(@panic with non-literal message)
specs/tri/collections/circular_buffer.t27 blocked type std.mem.Allocator, ... first blocker unchanged

No other file's blockers change.

Lines (git diff --numstat --no-renames origin/master...HEAD)

file kind added deleted
cli/t27b/src/lower.rs hand-written glue 17 2
cli/t27b/src/lower_float.rs hand-written glue 4 3
cli/t27b/tests/tail.rs hand-written test 19 0
gen/rust/tri/t27b/builtin_plan.rs t27c gen-rust, not hand-edited 78 2
specs/tri/t27b/builtin_plan.t27 plan spec, 16 tests 114 4
specs/tri/t27b/conformance/div_trunc_panic.t27 conformance spec, 8 tests 133 0
.trinity/seals/*.json (2) t27c seal --save 29 9
docs/reports/t27b_expectations.json ledger 3 1
AGENTS.md t27b remainder line 5 1

Hand-written foreign code: 40 added lines, 5 deleted (17 in lower.rs, 4 in lower_float.rs, 19 in tests/tail.rs), under the #7371 cap of 40 per file and 80 per PR. All three files are on master's tools/policy/foreign-exceptions.txt; this PR does not change that file and needs no label.

AGENTS.md, re-measured with wc -l after the merge of master 14e1c7b: cli/t27b/src/*.rs 15129 -> 15145 (src/*/*.rs stays 1202, 16347 in all), cli/t27b/tests/*.rs 8075 -> 8094.

Ledger: two new pass rows, specs/tri/t27b/a64.t27 (unlisted until now: the reference passed it and t27b did not) and the conformance spec. pass 915 -> 917 on master 14e1c7b's ledger; not_pass and max_not_pass stay 37.

Gates

Both ran on the t27c lab with master's gen/c/policy/own_language.c and lefthook.yml's one-line C mains:

  • check_budget() over git diff --numstat --no-renames origin/master...HEAD: exit 0. Negative controls exit 1: 41 lines in lower.rs; 38 + 40 + 4 lines (82 in the PR).
  • check_all() with origin/master:tools/policy/foreign-exceptions.txt, -- and git diff --name-status origin/master...HEAD: exit 0.

Other checks:

  • cargo test --release -p t27b on the t27c lab (x86_64, interpreter only): 117 passed, 0 failed before the merges, 124 after them.
  • t27c gen-rust of master's plan reproduces master's builtin_plan.rs byte for byte; the regenerated file is the seal's gen_hash_rust (sha256 14ad2ec0...).

t27b lab: signed receipts (#7686)

Head c956250 (the lane commit plus a merge of master 579bc55) against its merge-base, master 579bc55. Both are signed runs of the deployed t27b lab (lab_py_sha 4e9f106db, rustc 1.99.0, zig 0.16.0, qemu-aarch64 7.2). The head run was requested with a fresh 32-byte challenge.

/work/t27c-master corpus-receipt compare BASE HEAD --challenge-head <mine>, run on the t27b lab from /work/t27:

base "579bc55aab76deabadc6f3e4a359a089f47cc6bb" AUTH_MISSING_NONE AUTHOR leaves-bound true
head "c95625026336066058735a1318181b2841c4f4a2" AUTH_MISSING_NONE FRESH leaves-bound true
  input changed specs/tri/t27b/builtin_plan.t27
  input only-head specs/tri/t27b/conformance/div_trunc_panic.t27
  verdict changed specs/tri/t27b/a64.t27
  verdict only-head specs/tri/t27b/conformance/div_trunc_panic.t27
  output only-head specs/tri/t27b/a64.t27
  output changed specs/tri/t27b/builtin_plan.t27
  output only-head specs/tri/t27b/conformance/div_trunc_panic.t27
  lane improved specs/tri/t27b/a64.t27
  lane neutral specs/tri/t27b/builtin_plan.t27
  lane improved specs/tri/t27b/conformance/div_trunc_panic.t27
totals false inputs false verdicts false outputs false: IMPROVED_ONLY

Exit 3, IMPROVED_ONLY.

base 579bc55 head c956250
files 1600 1601 (+1: the conformance spec)
t27b pass / pass_vacuous 925 / 152 927 / 152
t27b fail 19 19
jit_interp_mismatch / crash 0 / 0 0 / 0
reference pass 1115 1116
reference disagree (files / tests) 0 / 0 0 / 0
cargo test --release -p t27b (aarch64, qemu) 136 passed 137 passed, 0 failed
  • Improved: specs/tri/t27b/a64.t27, blocked (ExprCall(@divTrunc), ExprCall(@panic)) -> pass with 35 tests and 7005 runtime asserts, as under the reference; the conformance spec (8 tests, 30 asserts).
  • Neutral: builtin_plan.t27, pass -> pass (16 tests, 138 asserts).
  • Ratchet: the head has no finding the base lacks; the base's UNLISTED specs/tri/t27b/a64.t27 is gone, because the ledger now names it. Both runs are red on master's own findings (UNEXPECTED PASS 2, UNLISTED 29 or 28, STALE 1, MOVED 3).

Merges of master after the receipt. Master moved five times while the PR waited (to 4d7d2d3 with #7470 and #7530, to 4804cc2 with #7743, to 7f7bf2c with #7786, to f53a734 with #7801, to 14e1c7b with #7447 and #7818; each touches lower.rs, the ledger and AGENTS.md), so master was merged in from master's side (245ccfb, e0c49eb, 92c2ba5, 70831d4, c4d10a6). The conflicts were the AGENTS.md remainder line, the ledger counts, tests/tail.rs (#7801 appended its test beside this PR's) and, the last time, one field of Lower and its initializer in lower.rs (#7818 added lit_consts beside last_stmt); both sides are kept each time. On the final merged tree (t27c lab): cargo test --release -p t27b 124 passed, 0 failed (x86_64); a64.t27 35/35, the conformance spec 8/8 and the plan 16/16 under the aarch64 t27b (qemu); check_budget() and check_all() from master 14e1c7b's gate exit 0. The t27b-native-ratchet check is red on master too, for findings this PR does not add; its only REFDISAGREE file is static_slice_literal.t27 (#7694, #7765).

gen-rust gaps

None. The plan's new functions take u8, usize and bool and return u8 or str constants.

🤖 Generated with Claude Code

claude and others added 2 commits October 8, 2026 19:01
…om builtin_plan.t27 (Closes #7790)

specs/tri/t27b/a64.t27, t27b's own encoder spec, passes the reference and
t27b refused it on ExprCall(@divTrunc) and ExprCall(@Panic). gen-zig prints
both as written.

- @divTrunc of two integers (typed or literal) lowers as t27b's `/`: gen-zig
  prints a signed `a / b` as `@divTrunc(a, b)` (W593), so that operator is
  what the reference runs (truncation, the division-by-zero trap, then the
  MIN / -1 trap). A float or any other operand is refused by name.
- A `@panic("m");` statement last in its block is a trap that always fires:
  the test that reaches it fails, as under the reference. Refused by name: a
  message that is not a string literal, and a @Panic with statements after
  it (Zig: unreachable code). A tail @Panic the reference returns (#7533)
  keeps its refusal.

The decisions extend specs/tri/t27b/builtin_plan.t27 (16 tests), generated
with t27c gen-rust to gen/rust/tri/t27b/builtin_plan.rs. Conformance spec:
specs/tri/t27b/conformance/div_trunc_panic.t27 (t27c test-report 8/8, 0
vacuous). Glue: lower.rs +17 -2, lower_float.rs +4 -3, tests/tail.rs +19.
Ledger: a64.t27 and the conformance spec are new pass rows.

Part of #6063.

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 12:32:19 UTC

Summary

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

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

Seal Status

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

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 14:27:23 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)=39fa3908f9fd != 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 Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 14:48:17 UTC

Summary

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

Seal Status

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

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 15:21:23 UTC

Summary

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

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

Seal Status

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

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 16:18:19 UTC

Summary

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

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

Seal Status

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

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 17:16:13 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)=39fa3908f9fd != 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 81da894 into master Oct 8, 2026
37 of 39 checks passed
gHashTag pushed a commit that referenced this pull request Oct 8, 2026
AGENTS.md takes #7808's step and adds this branch's: 15174 plus 1202 and
8109, on master 81da894's 15145 plus 1202 and 8094. The ledger takes
master's and re-applies this branch's rows: pass 920, not_pass 36.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b: @divTrunc and @panic as the reference runs them (a64.t27, builtin_plan.t27)

2 participants