Skip to content

tri t27o-sweep: t27o over a whole tree, rows reused while the file and the two seals hold (Closes #10543) - #10587

Merged
gHashTag merged 3 commits into
masterfrom
t27o/sweep-10543
Oct 18, 2026
Merged

gHashTag merged 3 commits into
masterfrom
t27o/sweep-10543

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #10543. Part of #10522.

Stacked on #10538 (branch t27o/check-t27b-first-10525) and must merge after it. Until then this PR's diff also shows that PR's two commits; mine are the last two (ledger.t27: the rules of tri t27o-sweep ... and tri t27o-sweep: the command ...).

What it does

tri t27o-sweep [PATHS...] [--max-bytes N (300000)] [--cache FILE (target/t27o-sweep.tsv)] [--top K (15)] runs t27o over every tracked .rs file in-process and prints one line per file (path seen converted tests stubs reused|fresh|skipped), the totals with the coverage share, the top-K root refusal kinds, the cascade total, and cold N / reused M / skipped S with the wall time.

A file's row is reused only when its key holds: the SHA-256 of the file, and the spec_hash of the seals of rust_convert.t27 and rust_std.t27. Re-sealing either spec makes every row stale by itself; there is no version constant to bump. A file over --max-bytes is listed as skipped instead of hanging the converter.

Rules are in specs/tools/t27o/ledger.t27 (not in main.rs)

  • key_check(recorded, same_source, same_converter, same_std) is the one rule of staleness. The existing key_state (version constants) now calls it, so there is still one rule; all 12 earlier tests pass unchanged.
  • reuse_row, sweep_path (a .rs file with no gen/ or target/ directory above it), over_cap, coverage_permille (seen == 0 is unknown, 1001, never 1000), is_refusal / kind_from / kind_to (the words before the first backtick of a refusal reason), is_cascade, text_order / rank_cmp (more refusals first, equal counts in text order). The defaults (SWEEP_MAX_BYTES, SWEEP_TOP, SWEEP_CACHE) are constants there too and clap reads them.
  • use tri::lab::receipt::span_is; instead of a second copy of the byte comparison (the ledger seal's closure now lists receipt.t27).
  • 11 new tests (23 total), three of them negative controls: a stale or missing key is never reused; no fn seen is never 100 percent; a line that is not a refusal is not misread. I mutated five rules (reuse, the seen == 0 guard, the cap boundary, the gen component, the cascade prefix) and each mutation fails exactly one test.

t27b test: 23 passed, 0 failed. t27c test-report: vacuous passes 0 of 23. t27c seal --verify: all hashes MATCH. gen/rust/tools/t27o/ledger.rs and .trinity/seals/t27o_T27oLedger.json are regenerated.

Glue (cli/tri/src/main.rs): 34 added lines

One T27oSweep variant (2 lines), its dispatch line, and cmd_t27o_sweep: git ls-files, SHA-256 (sha2 was already imported), the two seal files, t27o::convert with the counters read from the state vector (NFN seen, NOK converted, NTEST tests converted, NTS tests seen, NSTUB stubs), the TSV cache (path, three keys, five counts, kind=count;...), printing. Every if that decides something is a call into t27o_ledger::. Nothing in cmd_t27o or the T27o variant is touched, nor rust_convert.t27.

Gen-rust's text parameters are &'static str, so the glue leaks each converted file's output text once (a cold run leaks about the output size, the process exits right after); the same pattern is in cmd_lanes.

Own-language budget

Added 34, deleted 42 in counted foreign files, so the sweep's own part nets to minus 8. Over the whole stacked diff against git merge-base origin/master HEAD: 40 49 (added, deleted) with the one-liner from the review. The deleted lines are code nothing calls and no test reaches, each checked with grep over cli/ and the rustc dead-code warning:

I did not use the items other PRs take (nownote.rs check_added/check_staged, fpga.rs cclk_variant_and_xadc_envelope_check), nor the dead-in-the-non-test-build items that have test callers.

Measured (this Mac, the repo at this branch)

  • Cold: 377 files converted, 5 skipped over the 300000-byte cap (bootstrap/src/compiler.rs, bootstrap/src/main.rs, cli/t27b/src/lower.rs, cli/tri/src/fpga.rs, cli/tri/src/gates.rs): 47.8 s wall at load average about 60 (222 s at load average about 150).
  • Warm, nothing changed: 0 cold / 377 reused, 0.3 s wall, under 1 percent of the cold run (1.2 s against 222 s in the loaded pair). Cold and warm print the same per-file counts and totals.
  • Totals: 7052 fn seen, 633 converted (8.9 %), tests 252 of 3477, 572 stubs, 1294 cascade refusals. Top root kinds: type 1412, method 1126, tuple 625, macro 388, for over an iterator 376.
  • Per-file check: for all 377 converted files the line equals tri t27o <file> | tail -1 (fn seen, converted, tests converted of seen, stubs); 0 differ.
  • Invalidation, with --cache on edited copies of the cache: one row's source hash changed - only that file converted (1 cold / 376 reused); one row's std key changed - only that file; every row's converter key changed (what re-sealing rust_convert.t27 does) - 377 cold. A real edit did the same by accident: I deleted dead code in two files while the cold run was going, and the next warm run converted exactly those two.
  • The shell sweep at 7496ed2 read 382 files, 7108 fns, 627 converted. The sources and specs/tools/t27o are identical between that commit and this branch's base, so the 54 fewer fns and 6 more converted are not a change of the code or the converter; I could not reproduce that sweep's per-file numbers (its scratch files are gone), and every file here matches tri t27o. The 5 files over the cap are not in this total.

Not in this PR

The converter has no time cap: a file just under the cap can still take long; --max-bytes stands in until the superlinear pass is fixed.

🤖 Generated with Claude Code

@gHashTag

Copy link
Copy Markdown
Owner Author

Review (orchestrator, Opus), before auto-merge:

claude and others added 3 commits October 19, 2026 01:39
…ur booleans, sweep paths, cap, coverage, refusal kind and cascade, ranking (Closes #10543)

key_check takes the four booleans (recorded, same source, same converter, same std table) and is the
one rule of staleness; key_state calls it with the two version constants compared. Added for the
sweep: reuse_row, sweep_path (a .rs file with no gen/ or target/ directory above it), over_cap,
coverage_permille (seen == 0 is unknown, never 1000), is_refusal / kind_from / kind_to (the words
before the first backtick of a refusal reason), is_cascade, rank_cmp. 11 new tests, 3 of them
negative controls (a stale or missing key is never reused; no fn seen is never 100 percent; a line
that is not a refusal is not misread).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…42 dead lines deleted (Closes #10543)

`tri t27o-sweep [PATHS...] [--max-bytes N] [--cache FILE] [--top K]`: git ls-files, a SHA-256 per
file, an in-process t27o::convert, a TSV cache keyed by the file digest and the spec_hash of the
seals of rust_convert.t27 and rust_std.t27. Every decision is a fn of ledger.t27 (which paths, which
rows are reusable, the cap, coverage, the kind of a refusal, cascade or root, the ranking); main.rs
holds 34 added lines of I/O and printing.

The own-language budget (added <= deleted over the counted foreign files) is paid with code nothing
calls and no test reaches: gates::rev (allow(dead_code), its only caller removed in #5935),
MiningEpoch::next and the never-read start_ts field of depin/types.rs, and dlc10's migen_latency with
its constant (rustc: never used).

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

t27c dupes --name starts_at found it in builtin_parity_table.t27,
text_escape.t27 and seal.t27 already; seal.t27's has the same signature
(string, usize, string), so ledger.t27 uses it. dupes back to 3 places;
t27b 23/23; gen-rust regenerated (the use splices seal.t27's fns in);
cargo check -p tri clean; seal re-saved, --verify MATCH.

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

gHashTag commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner Author

Rebased onto master after #10538 merged (31f8323): three commits, the #10538 glue appears once, the own-language budget passes locally (+34 / -42 hand lines), t27b test specs/tools/t27o/ledger.t27 23/23, cargo check -p tri clean. Auto-merge on.

@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-18 19:56:40 UTC

Summary

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

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

Seal Status

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

tri t27o-sweep: t27o coverage over a tree, rows reused by the seal hashes of the converter (warm run in seconds)

2 participants