Skip to content

fix(regen): normalize emitted artifact at production — fix batch-2 self-host gate (follow-up to #6957) - #6958

Merged
briansrls merged 1 commit into
mainfrom
fix/regen-selfhost-normalize-production
Jul 21, 2026
Merged

briansrls merged 1 commit into
mainfrom
fix/regen-selfhost-normalize-production

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Why

main is red on the required gate self_host_realized_comparison_staleness_gate_holds (batch 2 of the self-host fixed-point job) since the #6957 merge — proven on that run: ✗ FAIL [batch 2] self_host_realized_comparison_staleness_gate_holds (returned Bool(false)).

#6957 greened the batch-1 Rust regen_verify gate by re-normalizing both sides inside verify_stage0_matches. But batch-2 is a separate .dag comparer (self_host_realized_comparison) that byte-compares the same emit-fresh tree (target/v2-emit-fresh-realize/src/*) and cannot re-normalize on its side. A comparison-side patch structurally cannot reach it — two forked comparers over one artifact (§3).

Root cause (one gap → one authority)

rustfmt_generated_crate runs cargo fmt --all on the faithful-full-regen crate, which has non-building modules, so cargo fmt silently skips the emitted files (they surface as cargo errors by design), leaving them as raw emit. The committed seed is rustfmt-normalized. #6848 shifted the global_bare_callable region into a rustfmt-reversible shape (match-arm block wrapping), so raw-fresh differs from the normalized seed by formatting alone → false red.

Fix

Normalize at production, not per-comparer. rustfmt_generated_crate now pushes every GENERATED_STAGE0_FILES file through standalone rustfmt via stdin (no path-header, no module recursion, fail-closed on rustfmt's non-zero exit — an unparseable emit is a hard located error, never a silent skip). Both comparers (verify_stage0_matches, changed_registered_outputs) revert to plain byte compare over the already-normalized artifact.

One normalization authority → every consumer (Rust verify and .dag self-host) sees canonical form.

Proven by execution (this branch)

  • regen_stage0 --verify → regen_divergence_count=0, exit 0 (batch 1).
  • regen_stage0 --emit-fresh reproduces all 98 generated files byte-identical to the committed seed — the exact inputs the .dag gate byte-compares (batch 2).
  • New test normalize_generated_source_erases_rustfmt_reversible_formatting_but_preserves_content: green (formatting-only difference vanishes) + RED control (an x+2 content drift survives normalization).

The committed seed is the rustfmt fixed point and is correct — a reseed to the raw shape would trade regen-red for fmt-red (§7: a byte-identical fixed point is explicitly not the goal).

🤖 Generated with Claude Code

… self-host gate

Follow-up to #6957. That PR fixed the batch-1 regen_verify gate by
normalizing both sides inside verify_stage0_matches (the Rust comparer),
but left the required batch-2 gate self_host_realized_comparison_staleness_gate_holds
red on main: it byte-compares the same emit-fresh tree
(target/v2-emit-fresh-realize/src/*) and cannot re-normalize on its side,
so a comparison-side patch cannot reach it. Proven on the #6957 merge run:
batch 2 returned Bool(false).

Root cause is one normalization gap, so the fix belongs at one place — the
produced artifact, not each comparer. rustfmt_generated_crate now pushes
every GENERATED_STAGE0_FILES file through standalone rustfmt via stdin
(no path-header, no module recursion, fail-closed on rustfmt's non-zero
exit) after cargo fmt --all silently skips the non-building faithful-full-
regen crate. Both comparers revert to plain byte compare over the already-
normalized artifact — one authority, every consumer (Rust verify AND .dag
self-host) sees canonical form.

Proven by execution on this branch: regen_stage0 --verify reports
regen_divergence_count=0, and emit-fresh reproduces all 98 generated files
byte-identical to the committed seed (the exact inputs the .dag gate
compares). New test
normalize_generated_source_erases_rustfmt_reversible_formatting_but_preserves_content
carries a green (formatting-only difference vanishes) plus a RED control
(x+2 content drift survives normalization).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@briansrls
briansrls merged commit eb4c713 into main Jul 21, 2026
3 checks passed
@briansrls
briansrls deleted the fix/regen-selfhost-normalize-production branch July 21, 2026 00:43
gunbai-bot Bot pushed a commit that referenced this pull request Jul 21, 2026
Resolve regen_stage0.rs conflict by keeping main's production-side
normalize_generated_source path (#6957/#6958), which supersedes this
branch's interim per-file rustfmt workaround.

Co-authored-by: Cursor <cursoragent@cursor.com>
gunbai-bot Bot pushed a commit that referenced this pull request Jul 21, 2026
briansrls added a commit that referenced this pull request Jul 21, 2026
Branch merge left regen behind main; restore so self-host gate
matches #6958. No strip-scope change.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jul 21, 2026
Re-assembles session/quick-ram-838-assembled from stale 2ace12c
onto current slice-1 convergence (.dag emitter authority + partial
stage0 mirror, v1_rt Rc revert per review 40447) before rebasing onto
green main (eb4c713 / #6958).

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant