Repository navigation
t27b: ts -- consts, scalar fns and tests as TypeScript, decided in .t27 plans (Closes #9994) - #10047
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gen/rust/tri/t27b/ts_emit.rs is generated from specs/tri/t27b/ts_emit.t27 on the lab; the two seals were saved there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This was referenced Oct 17, 2026
gHashTag
added a commit
that referenced
this pull request
Oct 17, 2026
The duplicate-bodies gate refused #10047: ts_emit.t27 repeated 18 helper bodies of verilog_emit.t27 word for word (byte writers, to_front, line_near, the scope and name resolver, the symbol encoding, the test-tree builders). They now live once, in specs/tri/t27b/emit_kit.t27, with tests of their own, and both writers `use` it. A whole-module `use` of verilog_emit from ts_emit was tried first and does not work: the splice counts words inside string literals as references, so ts_emit's "export function" pulled verilog_emit's fn `function`, and the generated-Rust typecheck refused it against ts_emit's own param_type and stmts. Measured on the Railway lab: test-report emit_kit 4/4, ts_emit 4/4, verilog_emit 5/5, 0 vacuous; dupe_scan: no new duplicate body; t27b ts and t27b verilog print byte-identical output and exit codes before and after on all 2051 specs (4102 of 4102). Generated writers and the three affected records regenerated there; ledger row added for emit_kit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
added a commit
that referenced
this pull request
Oct 17, 2026
#10047 merged at its head before this fix reached the branch, and master's duplicate-bodies gate went red: ts_emit.t27 repeats 18 helper bodies of verilog_emit.t27 word for word (byte writers, to_front, line_near, the scope and name resolver, the symbol encoding, the test-tree builders). They now live once, in specs/tri/t27b/emit_kit.t27, with tests of their own, and both writers `use` it by name. A whole-module `use` of verilog_emit from ts_emit does not work: the splice counts words inside string literals as references, so ts_emit's "export function" pulls verilog_emit's fn `function`, and the generated Rust typecheck refuses it against ts_emit's own param_type and stmts. The ledger also loses its ternary_matmul row: that group is gone on master and the gate refuses a ceiling left above the real count. Measured on the Railway lab, on top of master 896d87b: test-report emit_kit 4/4, ts_emit 4/4, verilog_emit 7/7, 0 vacuous; dupe_scan ok after the bless; t27b ts and t27b verilog print byte-identical output and exit codes before and after on all 2095 specs (4190 of 4190). Generated writers and the three records regenerated there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
added a commit
that referenced
this pull request
Oct 17, 2026
#10047 merged at its head before this fix reached the branch, and master's duplicate-bodies gate went red: ts_emit.t27 repeats 18 helper bodies of verilog_emit.t27 word for word (byte writers, to_front, line_near, the scope and name resolver, the symbol encoding, the test-tree builders). They now live once, in specs/tri/t27b/emit_kit.t27, with tests of their own, and both writers `use` it by name. A whole-module `use` of verilog_emit from ts_emit does not work: the splice counts words inside string literals as references, so ts_emit's "export function" pulls verilog_emit's fn `function`, and the generated Rust typecheck refuses it against ts_emit's own param_type and stmts. The ledger also loses its ternary_matmul row: that group is gone on master and the gate refuses a ceiling left above the real count. Measured on the Railway lab, on top of master 896d87b: test-report emit_kit 4/4, ts_emit 4/4, verilog_emit 7/7, 0 vacuous; dupe_scan ok after the bless; t27b ts and t27b verilog print byte-identical output and exit codes before and after on all 2095 specs (4190 of 4190). Generated writers and the three records regenerated there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
added a commit
that referenced
this pull request
Oct 17, 2026
… (#10065) #10047 merged at its head before this fix reached the branch, and master's duplicate-bodies gate went red: ts_emit.t27 repeats 18 helper bodies of verilog_emit.t27 word for word (byte writers, to_front, line_near, the scope and name resolver, the symbol encoding, the test-tree builders). They now live once, in specs/tri/t27b/emit_kit.t27, with tests of their own, and both writers `use` it by name. A whole-module `use` of verilog_emit from ts_emit does not work: the splice counts words inside string literals as references, so ts_emit's "export function" pulls verilog_emit's fn `function`, and the generated Rust typecheck refuses it against ts_emit's own param_type and stmts. The ledger also loses its ternary_matmul row: that group is gone on master and the gate refuses a ceiling left above the real count. Measured on the Railway lab, on top of master 896d87b: test-report emit_kit 4/4, ts_emit 4/4, verilog_emit 7/7, 0 vacuous; dupe_scan ok after the bless; t27b ts and t27b verilog print byte-identical output and exit codes before and after on all 2095 specs (4190 of 4190). Generated writers and the three records regenerated there. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9994 (phase 1)
What
t27b ts <file.t27>writes a spec's consts, its pure scalar fns and its tests as one TypeScript module, with real bodies. It coversu8..u32,i8..i32andbool.testbecomesexport function t27_test_<name>(): number, a self-check that returns how many asserts it ran.invariantbecomes a self-check too.t27_report()prints the assert table oft27c test-report, line for line.t27_failures()names each check that throws.Anything outside the subset is refused with exit 2 and
t27b: ts: unsupported construct <what>at line <n>.The decisions and the writer are both in t27, modelled on
t27b verilog:specs/tri/t27b/ts_plan.t27holds the decisions:+ - *are checked+% -% *%wrap (*%with Math.imul)/ %are unsignedspecs/tri/t27b/ts_emit.t27is the writer. It reaches cli/t27b throughgen/rust/tri/t27b/ts_emit.rs(generated) and one#[path]mod.The Rust
The only hand-written Rust is the mod line and the subcommand arm, plus its USAGE line. That comes to +10/-10 lines across
cli/t27b/src/lower.rsandmain.rs, and the foreign-budget and own-language gates pass. No TypeScript codegen is written by hand.Evidence (Railway lab, node 24.22.0)
The two targets in the issue:
t27b ts specs/queen/dispatch_exit.t27andt27b ts specs/queen/key_failover.t27both emit.t27_report()is byte-identical to the assert table fromt27c test-report: 10 tests (dispatch_exit) and 9 tests (key_failover), 0 vacuous.Whole-repo sweep, 2050 specs:
t27c test-report, with no node failures.Counting asserts. test-report does not count an assert whose operands are all compile-time constants (#6509). The TS matches this: such an assert goes through
t27_check, which checks it without counting it. Before this change, 23 of the 96 tables differed.The specs' own checks.
t27c test-report:Both are sealed in
.trinity/seals/t27b_T27bTs{Plan,Emit}.json.Limitations
at line 0, because the t27c parser records no line for it. Fixing that means changing the parser in compiler.rs, which is out of scope here.docs/reports/t27b_expectations.jsonrows for the two new specs are written aspass, the same as the verilog plan and emit rows. The JIT runs only on arm64 and the lab is x86_64, sot27b-nativeCI gives the measured verdict.🤖 Generated with Claude Code