Conversation
This was referenced Oct 4, 2026
Contributor
…red value layer `t27c gen-python <spec>` prints the declarations a .t27 spec holds as a plain Python module: consts as assignments, enums as dicts with quoted keys and resuming discriminants, structs as descriptors carrying the declared t27 field types, fn/test/bench/invariant blocks ANNOUNCED in a comment and never stubbed (a `def` line here would be a signature this backend invented rather than read). Supersedes the codegen_python.t27 specification stub -- the data-only contract that gen-js settled on is the requirement; the stub's class/def sketch is not. The deciding-generator hole this closes is the one gen-js closed, one language over: every Python harness around a spec was reading its constants from a hand-maintained copy, and the copy, not the spec, decided what the harness believed. Now the module is printed by t27c and the copy does not exist. Python's spellings live in the value layer the three backends share, parametrized by Target rather than duplicated: True/False/None words, and/or/not, `//` integer division, ==/!=, dict-subscript field access, always-quoted dict keys, `#` comments, a Python keyword list with `$` refused, and bitwise ops masked to the DECLARED width at any width (Python ints are unbounded; the spec's type is not) where the JS path repairs inside 32 bits and refuses beyond. NotEmitted ships as a plain list; bound-claim and enum-duplication messages are target-neutral. Measured, not asserted. Corpus (/tmp/t27-bench, 1099 specs): 998 generate under BOTH backends with identical emitted/announced counts and every Python artifact passes ast.parse; 101 are refused by both on identical parse errors (pre-existing, unmodified); zero py-only refusals, zero invalid artifacts, zero count mismatches. gen-js outputs diffed against the parent commit's binary over the same corpus: 994 of the 998 byte-identical, 4 differ ONLY in two refusal-message wordings (object-literal -> mapping literal; the duplicate-binding message now names both backends' failure modes) -- no emitted value changed. The 55-test codegen suite passes. Refs #5983 -- this lands that issue's backend; the next commit closes it. (cherry picked from commit 774ec4da954560efe46d3e0bb32978a2ff14445e) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at it prints (Closes #5983) - codegen_js.rs: the cherry-picked value layer had reworded two JS/TS refusals. That wording is now per target, so gen-js and gen-ts print byte-identical output to master's t27c on all 1185 specs. - bootstrap/tests/gen_python_behaviour.rs: hello_world parses and imports, and constants keep the values python3 reads back. A spec the parser refuses prints nothing. codegen_python.t27 is held to the lines it claims. The suffixed-literal category is pinned. - bootstrap/src/codegen_python.t27: the stub asserted def/class output and was BLOCKED in test-report. It now states the data-only contract as constants, with ten sample lines the test checks. - specs/trinity/compiler_matrix.t27: ABSENT_BACKEND is now go, and the self-check fixture follows. Both specs are resealed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag
force-pushed
the
feat/gen-python
branch
from
October 4, 2026 11:05
36b0d37 to
7340906
Compare
This was referenced Oct 4, 2026
Contributor
PR DashboardGenerated at: 2026-10-04 11:13:41 UTC
Summary
Seal Status
|
This was referenced Oct 4, 2026
Open
This branch has not been deployed
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 #5983
Why
t27c gen-pythonwas written on 2026-09-29 as 774ec4da9. That commit exists only on two local branches and on no remote, so nothing built from master can run it. Two specs also describe Python wrongly:compiler_matrix.t27names python as the backend that does not exist.codegen_python.t27is a CLARA stub. It assertsdef/classoutput that a data-only backend never prints, andtest-reportreports it BLOCKED.What
codegen_python.rs,main.rs, and the shared value layer incodegen_js.rs).__STRUCT_ORDER__,__DECL_ORDER__and__NOT_EMITTED__.codegen_js.rs. The cherry-pick had reworded two JS/TS refusal messages. The wording is now chosen per target, so gen-js and gen-ts keep master's text.bootstrap/tests/gen_python_behaviour.rs(new, 5 tests). Without python3 on PATH, a test still checks the artifact text and skips only the read-back of values.bootstrap/src/codegen_python.t27is rewritten.*_LINEstrings, each naming the exact line gen-python prints for a sample declaration. The integration test fails if any of them is not a line of the artifact.test-reportresult: 2/2 pass, invariant proved. It was BLOCKED before.specs/trinity/compiler_matrix.t27:ABSENT_BACKENDis nowgo, and the test asserts!= "python". The comment says the matrix does not yet measure gen-python, just as it does not measure gen-js or gen-ts. The--self-checkfixture intools/trinity_compiler_matrix.pyfollows.seal --verifygivesall hashes MATCH.Measured:
t27c gen-pythonover everyspecs/**/*.t27, thenast.parseast.parse) and executesAll 12 refusals are parser refusals that master already has. On master's own t27c, all 12 specs exit 1 on
gen,gen-c,gen-rust,gen-jsandtypecheck, with the same parser message (12/12 checked; only theParse error:/Compile error:prefix differs). They are the suite's existingParse failures: 12.parse error at module level near line N: unexpected token after expression statement: Identunterminated string literalparse error in fn ...: Expected RBrace, got Bangparse error at module level ...: Commaparse error in fn ...: Expected RBrace, got SemicolonWhat the 1173 modules leave out. Across 100 specs,
__NOT_EMITTED__holds 222 declarations. Each one is announced in the module, never silently dropped.gen-js / gen-ts parity: both are byte-identical to master's t27c (6765d63) on all 1185 specs, with 0 differing outputs and 0 differing exit codes.
Tests added
gen_python_hello_world_parses_and_importsast.parseand imports under python3gen_python_constants_keep_their_values7 / 2as//, a1 << 40masked to u64, bytes, and an enum dictgen_python_refuses_a_spec_that_does_not_parse_and_prints_nothinggen_python_its_own_spec_states_what_it_prints*_LINEclaims incodegen_python.t27is a line of its artifact; nodef/class/importline; python3 readsSAMPLE_HALF=3,SAMPLE_WIDE=1099511627776,SampleLevel={'Low': 0, 'High': 7, 'Top': 8},__NOT_EMITTED__=[]gen_python_pinned_a_suffixed_literal_is_announced_not_emitted0xA5A5A5Au32lands in__NOT_EMITTED__(3 entries across 2 corpus specs). The fix for that category flips this test on purpose.The cherry-pick also adds 13 unit tests in
codegen_python.rs.Checks run locally
cargo build --release -p t27ccargo test -p t27c -- pythongen_python_behaviour+ 1tt_debug)cargo test -p t27c -- jscargo test -p t27c -- gen_tscargo test -p t27c -- matrixt27c suite(branch vs master 6765d63, same machine)SOME TESTS FAILED, so these failures are pre-existing on master, not introduced here. The branch run showed one extracatalog gate [emitted-unreadable], caused by the two suites racing on the shared$TMPDIR/t27-catalog-emitteddirectory. Run alone,t27c catalog-gategives the same 3 findings on branch and master.t27c seal --verifyon both touched specst27c test-reporttools/trinity_compiler_matrix.py --self-checktools/trinity_compiler_matrix.py checkcompiler_matrix.t27changed. The script is not wired into CI.main.rsare already on master)Follow-up (after merge)
tools/trinity_compiler_matrix.py runon master, then re-pinNATIVE_REVISIONand the report. This PR cannot do it: a squash merge changes the commit the pin would name.compiler_matrix.t27and may need a re-vendor. Website wiring for Python is out of scope here.🤖 Generated with Claude Code