Skip to content

t27o: second golden port -- csr_map.rs to specs/host/csr_map.t27 - #11255

Merged
gHashTag merged 5 commits into
masterfrom
t27o/csr-map-p2
Oct 20, 2026
Merged

gHashTag merged 5 commits into
masterfrom
t27o/csr-map-p2

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #11235

The second golden port of step 4 of #9000, by the recipe of the first (#11157, bitmask). bootstrap/src/host/csr_map.rs (214 lines: the BitNet AXI-Lite CSR address map and its 10 tests) is deleted; its spec, converted by tri t27o and read by eye, is specs/host/csr_map.t27, and t27c gen-rust writes bootstrap/gen/rust/host/csr_map.rs, which bootstrap/src/host/mod.rs mounts by #[path] as module csr_map. driver.rs and dma.rs (use super::csr_map) and main.rs are not touched.

What is in the diff

file change
bootstrap/src/host/csr_map.rs deleted (-214)
bootstrap/src/host/mod.rs the pub mod csr_map; line becomes the #[path] mount (+1 -1)
specs/host/csr_map.t27 new: 30 pub consts, 13 test blocks
bootstrap/gen/rust/host/csr_map.rs new, generated by t27c gen-rust (never hand-edited)
.trinity/seals/host_HostCsrMap.json new seal: 13 of 13 tests, vacuous 0, closure rust_std.t27

Hand lines (the counted foreign files): +1 / -215, net -214. The own-language budget, compiled from the merge base's (e10a1bb7c) gen/c/policy/own_language.c and fed git diff --numstat --no-renames BASE...HEAD, ends rc=0 (a control line of +5 / -0 hand Rust makes the same gate exit 1).

How it was done, step by step

  1. The three tests tri t27o refused were rewritten with index loops and a bit test (csr_offsets_strictly_increasing and csr_offsets_step_is_four used windows(2); status_masks_are_powers_of_two used is_power_of_two; the bit test is x != 0 && (x & (x - 1)) == 0). cargo test host::csr_map on that commit: 10 passed, 0 failed.
  2. tri t27o bootstrap/src/host/csr_map.rs: 10 fn seen, 10 converted (10 of 10 tests), 0 refused.
  3. The spec was read by eye and kept the 10 hand tests under their own names. No spec in specs/ defines a const of these names or mirrors this map (git grep on the names and the values); python3 -I tools/dupe_scan.py --like says no function body long enough to compare, and the full scan on this head and on its merge base gives the same 4 findings (none head-only).
  4. t27c gen-rust, hand file deleted, mounted like bitmask.

Evidence

  • Side-by-side, every pub const. The old file (git show origin/master:bootstrap/src/host/csr_map.rs) and the generated one were compiled into one rustc harness (throwaway, not committed) that compares each of the 30 old pub consts by value, with both sides forced to one type: 30 compared, 0 disagree. The same harness with two planted differences reports them (5 disagreements, the table included), so it can fail. Every name of the old file is present in the new one.
  • Crate. cargo check --all-targets -p t27c exit 0; cargo test -p t27c --bin t27c host:: 567 passed, 0 failed.
  • Spec tests. t27b test: 13 passed, 0 failed. t27c test-report: 13 pass, vacuous passes 0 of 13.
  • Seal. t27c seal --save, seal --verify all hashes MATCH, tri seals sync-twins writes 0 files, python3 tools/check_seal_currency.py exit 0 (0 stale generated-code hashes of 2943 seals), python3 tools/check_seal_coverage.py exit 0 (2943 seals, 2830 hold, 113 known-broken as in seal_baseline.txt). Both ran with a release t27c built from this head (merged with master e10a1bb7c); a debug build made t27c seal fail for 245 other specs (the one I opened panicked on an integer overflow that a release build wraps), so it is not a valid instrument for those two checks.

Read this when reviewing

  • Vacuous tests, and what was done. tri t27o kept the hand tests as they were, and t27c test-report counted 10 of the 14 spec tests as vacuous passes: assert(CSR_COUNT == 12) has two constants as operands, Zig folds it, and the test executes 0 runtime asserts (T730); tri pr preflight refuses that. The tests now read the constants out of const arrays at a loop index, so each assert runs. Every hand test keeps its name and the property it pinned; the header of the spec says so.
  • Added to the spec: one negative control (a table with two offsets swapped and masks that overlap must be refused by the same rules) and two oracle_* tests that pin every offset, bit position and mask (the hand tests only pinned order, step, first and last, not which name sits at which offset).
  • The generated file has 7 items more than the hand file: count_ones_u32, count_ones_u64, B_UNDERSCORE, alpha, digit, same, word. gen-rust splices them from tools::t27o::rust_std because one test calls rust_std::count_ones_u32; bitmask.rs has the same. Nothing outside the spec uses them, and rust_std.t27 is in this seal's closure.
  • The ten Rust #[test]s no longer exist as cargo test tests: they are test blocks run by t27b and t27c test-report (the host test count of the crate falls by 10, the checks do not).
  • CSR_OFFSETS is written [u32; CSR_COUNT as usize] by gen-rust; the type is [u32; 12] as before (the harness above would not compile otherwise).

Known and not mine

tri pr preflight --quick on this branch: changes, check, tests, seal, types, dupes, census, budget, devhome, kept PASS. ledgers FAILs for the one reason a new spec always has: docs/reports/t27b_expectations.json has no row for it. The row is {"path": "specs/host/csr_map.t27", "t27b": "pass"} (as specs/host/bitmask.t27 has); the steward applies it, this PR does not edit the ledger. suite is NOT RUN under --quick.

Not run

The full tri pr preflight (corpus ratchet, about 11 minutes); the whole cargo test of the crate (only host::); t27c test-report on the corpus; a silicon or Verilog check of the spec (the map is host-side).

🤖 Generated with Claude Code

claude and others added 5 commits October 20, 2026 13:32
… t27o converts all 10 fns (Closes #11235)

Step (a) of the second golden port. csr_offsets_strictly_increasing and
csr_offsets_step_is_four loop over CSR_OFFSETS by index; status_masks_are_powers_of_two
uses x != 0 && (x & (x - 1)) == 0. The meaning of each test is unchanged:
cargo test host::csr_map ends with 10 passed, 0 failed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd reviewed (Closes #11235)

Step (c) of the second golden port. The spec is the 30 pub consts of the hand file and its
10 tests as test blocks (10 of 10 fns converted), plus one negative control and three oracle
tests that pin every offset, bit position and mask. t27b test: 14 passed, 0 failed.
No spec in specs/ defines a const of these names or mirrors this map.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…trap/src/host/csr_map.rs, mounted from host/mod.rs (Closes #11235)

Steps (d) and (e) of the second golden port. t27c gen-rust writes the 30 pub consts
of specs/host/csr_map.t27; host/mod.rs mounts the file by #[path] as module csr_map the
way it mounts bitmask, so driver.rs and dma.rs (use super::csr_map) are unchanged.
The 214-line hand file is deleted. cargo check --all-targets -p t27c ends with exit 0.
The spec header now names the rust_std items gen-rust splices into the generated file.

Hand lines: +1 / -215 (mod.rs +1 -1, csr_map.rs -214).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… HostCsrMap (Closes #11235)

Steps (c) and (g) of the second golden port. tri t27o kept the hand tests as they were, and
`t27c test-report` counted 10 of the 14 as vacuous passes (an assert on two constants folds at
compile time, T730): tri pr preflight refuses that. The tests now read the constants out of
const arrays at a loop index, keeping every hand test's name and property; the two
oracle tests are merged into one table walk and one for bits and masks. test-report: 13
tests, 13 pass, vacuous passes 0 of 13. t27c seal --save writes
.trinity/seals/host_HostCsrMap.json (closure: rust_std.t27); seal --verify: all hashes MATCH.
The generated Rust differs from the previous commit only in its test count (14 to 13).

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

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-20 07:00:56 UTC

Summary

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

These columns do not partition: 2 + 47 + 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)=5aec047d42ec != 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).

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.

t27o: second golden port -- bootstrap/src/host/csr_map.rs to specs/host/csr_map.t27

2 participants