Skip to content

t27b: fold compile-time float arithmetic in binary128, as Zig does (Closes #7021) - #7042

Closed
gHashTag wants to merge 22 commits into
masterfrom
claude/t27b-comptime-f128
Closed

gHashTag wants to merge 22 commits into
masterfrom
claude/t27b-comptime-f128

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

What

Zig's comptime_float is an IEEE binary128 value. A literal rounds to binary128 (nearest, ties to even). + - * / between two of them fold in binary128, and two of them compare exactly. The value is rounded to f64 or f32 only when it meets one.

t27b kept only the f64 value. It refused a fold (ExprBinary(*) and the other operators) whenever an operand was not exactly an f64. This PR adds a small exact soft-float (cli/t27b/src/lower/f128.rs) and folds in binary128 the way the reference's Zig does.

  • Still refused, each by name:
    • a literal or folded value that overflows f64;
    • a constant division by zero;
    • @intFromFloat of a compile-time float that is not exactly an f64.
  • Two f32 midpoint literals that share one f64 (1 + 2^-24 written two ways) now round to the two f32s Zig gives instead of being refused.

Conformance spec first

specs/tri/t27b/conformance/comptime_float_f128.t27 gives 10 pass and 0 vacuous under t27c test-report, and the same 10 under t27b. As a negative control, flipping three of its asserts makes those three fail under the reference. Tests live in cli/t27b/tests/comptimef128.rs, with differential.rs updated: the refusal rows that are now folds became positive cases.

Measured on the t27b Railway lab

Same reference before and after; the reference is unchanged between the two masters.

tree reference-passing specs t27b passes pass vacuous per-test mismatch
master 33e61b3 767 / 829 523 244 0
+ this PR 770 / 829 526 244 0

The three specs that moved from blocked to pass:

  • specs/port/scripts/verify_smoking_guns.t27
  • specs/port/scripts/pysr_trinity_blind_test_v2.t27
  • the new conformance spec

Disagreements are 0, and fail is 10 before and after. Builds produce 0 warnings and cargo test passes.

Re-measured on the merged tree

The PR was merged twice from master's side: once for lane 1's StmtAssign change, and once for #6998's StmtLocal change. The last merged tree was compared against master f4d3333, with the same reference:

tree reference-passing specs t27b passes pass vacuous per-test mismatch
master f4d3333 774 / 835 531 248 0
+ this PR 776 / 835 533 248 0

The same three specs move from blocked to pass. The fourth change is specs/benchmarks/kernel_ternary.t27, which went from pass to timeout in this run. That is timing noise under qemu, not this PR: in the previous run (against master c5779e6) it went the other way, from timeout to pass, and the ledger has it as pass. Builds produce 0 warnings and cargo test passes.

Ledger

docs/reports/t27b_expectations.json is master's ledger plus this PR's own three moves:

  • verify_smoking_guns.t27 moves from blocked (ExprBinary(*)) to pass.
  • pysr_trinity_blind_test_v2.t27 and comptime_float_f128.t27 enter as pass.

0 entries move down. The cap goes from 52 (master at the merge) to 51, with no --accept-new. scripts/ci/test_a_t27b_spec_cannot_move_silently.py passes. Master was merged in from master's side.

Foreign code (owner approval)

This PR edits Rust in cli/t27b. That is approved by the owner: the owner-approved-foreign label is on epic #6063, and the owner's instruction, translated, was "add the label yourself and do the work". The edit is kept minimal: one new soft-float module, the uses in lower.rs and lower_float.rs, and tests. All five files are listed in tools/policy/foreign-exceptions.txt.

Closes #7021
Refs #6063

🤖 Generated with Claude Code

Trinity Bee and others added 10 commits October 5, 2026 22:27
- Add red_check_passes function: true only when not required, concluded and discounted
- Add required_check_passes function: true when posted and green
- Add gate_open function: false when ruleset unreadable (fails closed)
- Include 13 tests covering all negative controls and positive cases
- Meets all acceptance criteria for functions, tests, and test results

Closes #5776
… evidence

Narrow 'no competitor has' and 'unique position' claims to reference the four projects surveyed here, removing absolute claims that aren't supported by systematic survey evidence as required by POSITIONING_CONFORMANCE_LAYER.md.

Closes #5399
…check_vector_data.t27

- Port counts(), census(), baseline(), _write_vectors(), _run_gate(), _control_case(), _baselined_empty_file_case(), _record_refusal_case()
- Add 8 test blocks for each function
- All acceptance criteria met:
  1. File exists and is present
  2. All 8 functions are present with correct names
  3. Generated code has 0 'not yet implemented' and >24 lines
  4. File parses successfully (status: IMPLEMENTED)
  5. File has 8 test blocks

Closes #6405
Erratum (#5406): Add erratum lines to both WAVE_LOOP_51_REPORT.md and WAVE_LOOP_45_REPORT.md documenting deliverables that were claimed as complete but never implemented in source code.

- W51: ExprAddressOf and t27c lint --ascii identifiers absent from source
- W45: has_cycle_dfs identifier absent from source

Closes #5406
A pull request must add exactly one docs/now entry and a bee has no way
to know that: its brief names a boundary file and acceptance criteria,
and docs/now/ is neither. The publisher adds it rather than failing the
gate.

Closes #5406

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A pull request must add exactly one docs/now entry and a bee has no way
to know that: its brief names a boundary file and acceptance criteria,
and docs/now/ is neither. The publisher adds it rather than failing the
gate.

Closes #6405

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A pull request must add exactly one docs/now entry and a bee has no way
to know that: its brief names a boundary file and acceptance criteria,
and docs/now/ is neither. The publisher adds it rather than failing the
gate.

Closes #5399

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A pull request must add exactly one docs/now entry and a bee has no way
to know that: its brief names a boundary file and acceptance criteria,
and docs/now/ is neither. The publisher adds it rather than failing the
gate.

Closes #5776

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Zig's comptime_float is an IEEE binary128 value. t27b kept the f64 value
and refused folds on literals that are not exactly an f64. It now rounds
literals to binary128, folds + - * / and compares exactly in binary128,
and rounds to f64 or f32 only when the value meets one.

Lab, master 33e61b3 before and after: 767 -> 770 of 829
reference-passing specs, per-test mismatch 0 -> 0. Ledger: master's plus
three moves (verify_smoking_guns blocked -> pass; pysr_trinity_blind_test_v2
and the new conformance spec enter as pass), cap 55 -> 54.

Rust under the owner's owner-approved-foreign approval on #6063.

Closes #7021
Refs #6063

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…foreign-exceptions blocks; ledger = master's plus this PR's three moves)

Refs #6063

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
…ers (Closes #6972 #6974 #6975 #6976 #6990 #6991 #6992) (#7001)

* spec(queen): actors control lane, call, backoff, hung turn, dead letters (Refs #6971)

A self-review of specs/queen/actors.t27 against Erlang/OTP, Akka,
Temporal, Orleans and Dapr found five places weaker than the systems it
borrows from. This closes them in the spec:

- #6972 control lane: cancel and heartbeat survive a full mailbox,
  coalesce per kind, and are taken before data;
- #6974 call: reply, DOWN or timeout; a reply wins over a DOWN; the alias
  dies with the call, so a late reply reaches nobody;
- #6975 backoff: a slow crash loop extends an unstable streak, waits
  10 s doubling to 300 s, and gives up to the parent past 6;
- #6990 hung turn: past TURN_MAX_SECONDS the supervisor kills the turn
  and the DOWN reclaims its task at once;
- #6991 dead letters: every lost message is counted, a coalesced one is not;
- #6992 two Erlang corners stated (no trappable kill on a link; no
  exit(self, normal) quirk);
- #6976 coverage: all 49 pub functions called by a test, section 7 pinned
  by an invariant with a negative control.

22 tests and 9 invariants pass, 0 vacuous; gen-rust, gen-c, gen-verilog
exit 0; 40 of 41 new-line mutants killed, the survivor is equivalent.

Closes #6972, Closes #6974, Closes #6975, Closes #6976, Closes #6990,
Closes #6991, Closes #6992

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

* test(queen): actors boundary asserts from the first tri mutate spec run (Refs #6976, #6993)

`tri mutate spec` (#6993) ran the whole file on the lab: 149 of 157
mutants killed, 8 survivors. Two were test gaps and are closed here:

- pid_of: `slot > GEN_MASK` -> `>=` survived; slot GEN_MASK is a real
  slot, now asserted.
- mbox_push: `tag > TAG_MASK` -> `>=` survived; tag 255 is a message,
  now asserted.

Both mutants were applied by hand and now fail `zig test`.

Six are equivalent and stay:
- mbox_len and mbox_find loop bounds `< MBOX_SLOTS` -> `<=`: mbox_tag
  returns 0 past the last slot, so both loops end the same way.
- ctl_next `t < CTL_TAGS` -> `<=`: ctl_pending is false for tag 64.
- backoff_seconds `wait >= CAP` -> `>`: 10 * 2^k never equals 300.
- backoff_seconds `wait > CAP` -> `>=`: at equality both return CAP.
- the reclaim wait at `since_renewal == ttl`: every branch returns 0.

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

* docs(now): actors lanes -- the whole-file tri mutate spec count beside the hand list (Refs #6976)

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Review jam: reviewer bee as a service, merger that reads the bee's discounted checks, publisher heading that passes chec
…gen_w633.t27 (Closes #6711) (#6997)

* feat(port): scripts/gen_w633.py to specs/port/scripts/gen_w633.t27 (Closes #6711)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* chore(dupes): record build_tree shared by the gen_w631 and gen_w633 ports

scripts/gen_w633.py is a copy of scripts/gen_w631.py with a different grid
size, so the two ports carry the same subtree walk. Reusing gen_w631's
function is not possible today: a use of another port module does not
compile under t27c test-report (undeclared identifier), which issue #6711
requires to pass. The copy is deliberate, so it is recorded in the ledger
(tools/dupe_scan.py --bless; one line, no other group moved).

Refs #6711

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

---------

Co-authored-by: Claude Sonnet 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 19:16:53 UTC

Summary

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

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

Seal Status

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

A 'no competitor has' claim, a four-row table, and a survey that stopped in June
Port part 1 of 2 of tools/check_vector_data.py to specs/port/tools/check_vector_data.t27 (8 functions)
….t27 (Closes #6664) (#6695)

t27b test --check gave the reference interpreter 50e6 steps per test; under
qemu one fuel-bound test costs ~31 s, so kernel_fib, kernel_matmul,
kernel_ternary and d_g22_test exceed the 60 s corpus timeout while proving
nothing (Stop::Fuel counts as agreement).

The policy is specs/tri/t27b/check_budget.t27: one budget of 20e6 steps per
file (about 12.3 s under qemu), deterministic rather than wall-clock, with the
four measured cases of #6664 as test vectors and invariants. cli/t27b loads
its t27c gen-rust output gen/rust/tri/t27b/check_budget.rs; the hand-written
Rust is the call-site glue in cmd_test (6 lines), owner-approved 2026-10-06.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…foreign-exceptions blocks)

Refs #6063

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

gHashTag commented Oct 6, 2026

Copy link
Copy Markdown
Owner Author

Duplicate of #7045 (Closes #7007, lane 1), which landed on master at 2026-10-06T20:14Z while this PR was being re-measured. Both PRs fold comptime_float in binary128, and both make the same three ledger moves: verify_smoking_guns and pysr_trinity_blind_test_v2 go to pass, plus a new conformance spec.

Auto-merge is now off. This PR conflicts with master and should not land as it is.

I checked the result on the t27b lab. Master 96cf7c8, which includes #7045, passes this PR's conformance spec comptime_float_f128.t27 (10 tests, including the two f32 midpoint literals and exact comparisons) and the extra cases file. The flipped-assert negative control fails under both t27b and the reference. So the Rust here adds nothing to master.

The one thing left worth landing is the spec itself, as extra conformance coverage. That would be a spec-only follow-up: one .t27 file and one new ledger entry as pass. Whether to close this PR or cut it down to that is the coordinator's call.

Refs #6063 #7021

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-06 20:30:12 UTC

Summary

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

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

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b23641f01baa != 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 commented Oct 6, 2026

Copy link
Copy Markdown
Owner Author

Closing as a duplicate of #7045 (ExprBinary(*)), which landed first; master passes this PR's spec and tests. The conformance spec comptime_float_f128.t27 will be kept in a spec-only follow-up if it adds coverage over #7045's.

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.

t27b: fold compile-time float arithmetic in binary128, as Zig's comptime_float does (ExprBinary(*))

3 participants