Skip to content

regen_stage0: verify hand-maintained files against a fresh emit (§5 inert-gate hole #1) - #6311

Merged
briansrls merged 13 commits into
mainfrom
session/loyal-dove-903
Jul 6, 2026
Merged

briansrls merged 13 commits into
mainfrom
session/loyal-dove-903

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

regen_stage0: verify hand-maintained files against a fresh emit (don't just trust them)

Closes §5 inert-gate hole #1: RegenVerifyGate copies the HAND_MAINTAINED_STAGE0_FILES verbatim into the fresh crate and only ever verifies them against themselves, never against what the emitter would produce. Those are exactly the files people hand-edit, so a bad hand-sync — or an emitter that has quietly caught up and made the hand entry a dead scaffold — is invisible.

What this adds

verify_hand_maintained_candidates runs in the --emit-fresh path (which the CI RegenVerifyGate and the manual cutover both use). For each hand file it diffs the committed content against the emitter's fresh candidate — both pushed through identical standalone rustfmt so the comparison isolates content drift from formatting — and classifies:

  • MATCH — emitter reproduces it byte-for-byte → the HAND entry is a dead scaffold; flip it to GENERATED_STAGE0_FILES.
  • DRIFT — candidate differs → a known emitter gap (the reason it's hand-maintained) or an unintended hand-edit; inspect.
  • NO CANDIDATE — not in the fresh emit closure (host-physics pin with no .dag source, or a module the closure doesn't reach) → only cargo-green covers it.

It never overwrites the hand files (they stay authoritative for the buildable crate); it only reports. The report is printed, counted, and located — a typed diagnostic, not a silent skip (DESIGN §5: a failure arm must refuse/report, never widen or hide).

Current tree result

0 match / 1 drift / 7 no-candidate:

  • DRIFT: main.rs — the emitter emits a candidate but it differs, i.e. the known dag_collect emitter split: 05_emit_rust standalone emit for dag_collect{,_support}.rs #6053 dag_collect-split gap (dropped Ci-subcommand / extract_module_path emission). Correctly justifies its hand-maintenance, and will flip to MATCH the moment that gap closes.
  • NO CANDIDATE (7): cli_run.rs, coproduct_reflection.rs, recorded_fixture.rs, resolved_graph_cache.rs, v1_interpreter.rs, phase_profile.rs, module_path_index/ — genuinely not in the emit closure (host-physics pins).

No hand file is a dead scaffold today, so all remain justified — but now that's verified each run, not assumed.

Scope / non-goals

  • Report-only (non-fatal) v1. Promoting MATCH→hard-fail (auto-force the GENERATED flip) is an operator gate-policy call.
  • §5 hole Codex/graph viz test helpers #2 (route_a_emit_fresh_cargo_green_test is #[ignore]'d, so fresh-emit cargo-green doesn't run in CI) is left as-is — it's the open ROADMAP "make cargo-green continuous (or cheap)" decision, gated on the same compile-wall.

Verified by execution

regen_stage0 --emit-fresh <dir> prints the report; classification confirmed correct after fixing the emitted-map key (keyed src/<name>.rs, not bare).

@gunbai-bot gunbai-bot Bot changed the title Fork of realization regen_stage0: verify hand-maintained files against a fresh emit (§5 inert-gate hole #1) Jul 6, 2026
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review July 6, 2026 01:32
@gunbai-bot

gunbai-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Agreed that gating-on-MATCH is the right §5 endpoint (construction over validation) — and thanks for flagging it as an observation, not a blocker.

The deferral is deliberate, not just later-polish: a hard-fail on MATCH forces the HAND→GENERATED flip the instant an emitter gap closes, but the flip itself — removing the file from HAND_MAINTAINED_STAGE0_FILES and proving byte-identity via regen --verify over the full 92-file seed — is the regen-cutover work currently blocked on the resolver/compile-speed lane (the same compile-clean wall this whole thread sits under; --verify can't even run today because of the pre-existing #6289 roster drift). Gating now would red the build mid-flight, before the flip can be staged atomically. So MATCH→construction should ride the regen-cutover cadence (each cutover un-ignores its witnesses and drains the HAND roster), where the flip lands as one atomic step — not ahead of it.

Concretely today the tree is 0 MATCH / 1 DRIFT (main.rs, the known #6053 gap) / 7 NO-CANDIDATE, so nothing is being silently deferred — the report would go loud the moment a hand file becomes flippable, which is exactly the trigger to do the gated flip. Captured in the PR body's non-goals.

— sent from loyal-dove-903

briansrls and others added 10 commits July 6, 2026 02:32
… (unblock pure-.rs PRs)

floor_diff_edits_from_line_ranges refused (Err) when a diff changed only
non-.dag files (saw_non_dag && !saw_dag) — reddening the discovery-corpus
batch for every pure-.rs PR (seed hand-syncs, Rust-only changes). That
conflated a structural-∅ .dag frontier with an ignorance state.

Per the operator's arity ruling: a successful git-diff observation whose
.dag subset is empty is NOMINAL (present, empty) — the SAME outcome as an
empty diff (every row takes the not-affected skip). The only ignorance
state is a FAILED observation (UnifiedDiffFail, floor_diff_observe.dag),
refused upstream in floor_git_diff_range. This mirrors the function's own
departed-.dag-path arm, which already distinguishes structural-∅ (continue)
from ignorance (refuse).

Fix: drop the saw_non_dag/saw_dag refusal; a non-.dag-only diff falls
through to the empty frontier. Observation layer (Ok/Fail + exit code) and
the shell docs-only shortcut are unchanged (already correct / downstream-
safe). Red control: non_dag_only_diff_is_structural_empty_frontier_not_refusal
(was Err, now Ok empty).

Also fixes the compile error at 32fac2e (auto-commit captured this edit
mid-flight: declarations removed, refusal block not yet dropped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…d by broken regen); keep source_root_ingest V2Tree fix

The #6289 witness ownership_movable_test.dag emits test_claim_ownership_movable.rs,
which references v1.compiler.ownership symbols (merge_branch_licenses, MoveLicenseAccum,
LiveState, move_site_key, ...) that are NOT in the committed v1_compiler_ownership.rs
seed. Registering it as a GENERATED file therefore breaks the seed crate's compile
(E0432/E0425/E0061) -- 'just register it' cannot land in isolation.

Measured blast radius: the fresh self-compile drifts from the committed seed across
33 files (the known-broken regen, emitter bugs #6298), so pulling in the fresh
v1_compiler_ownership.rs cascades into the whole regen. Not a scoped fix; parked for
the regen project (or exclude the off-auto-path witness from the emit closure).

KEPT: the source_root_ingest_gate_passes main-red fix -- emit_source_root_ingest_manifest
now imports v2.std.cross_tree.import_model { DagTree, V2Tree }. The manifest emitter
hardcodes its import block and missed this when source_root became a grounded
SourceRootRef (#5473/#5486), so every witness importing the manifest failed with
'undefined variable V2Tree'. Verified locally: all 3 real_ingest witnesses + the 2
runnable closure witnesses now return true (were compile errors).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
manifest_imports_grounded_source_root_constructors: asserts the emitted manifest
imports v2.std.cross_tree.import_model whenever it emits a grounded source_root
value -- deleting the import line reddens this test (paired with the CI witness
program_assembly_real_ingest_module_roots_parse_holds as the execution oracle).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The auto-committer flushed the in-progress merge with conflict markers (0b74fe4);
this resolves both:

- floor_diff_edits_from_line_ranges: keep #6269's v1_attribution_index + added_paths
  handling; keep the structural-∅ fix (no saw_non_dag/saw_dag refusal -- a non-.dag-only
  diff is a nominal empty frontier). The two are orthogonal and compose.
- emit_source_root_ingest_manifest: take #6269's emit_source_root_ref_import (derives
  the referenced SourceRootRef constructors from records) over the earlier hardcoded
  both-constructors line -- same source_root_ingest V2Tree fix, more precise form.

Kept both red-control tests; retargeted the structural-∅ test off a src/v1/ path
(which #6269 now eagerly resolves via the real workspace tree, unavailable from the
unit-test cwd) onto a path-agnostic non-.dag path. Both green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…import)

The type_env_for_import specific_names filter was auto-committed to this PR
but is a no-op: lookup_binding_by_name reads ancestry_str_bindings, which
build_type_env fills from union_parent_type_env_caches (04_infer.dag:5507)
and the single-import path (:133) -- both merge each import's full
parent.type_env_cache, bypassing type_env_for_import (which only feeds the
unused 'parents' field). Measured: dag_collect still resolves un-imported
ErrorNode with the filter built in. Reverting so #6311 does not carry a
fail-closed illusion; the real fix belongs in the ancestry-cache seam.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gunbai-bot

gunbai-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

CI rust_tests failure @ 86ccf8d is a 30-min timeout on the 'v1 rust gate (fmt + clippy + nextest)' step, not a test failure (GH annotation: "has timed out after 30 minutes"). This is the known v1-compiler compile-wall (#6239) hitting the tight gate on a cold sccache — transient infra, not a code defect. Evidence: the revert commit restored v1_compiler_infer.rs/04_infer.dag to exactly b22b1ab (where rust_tests passed; the only reds there were source_root_ingest), and cli_run.rs is byte-identical to b22b1ab — so the compile workload is unchanged. Retriggering the job. — sent from loyal-dove-903

@briansrls
briansrls merged commit 3a418e5 into main Jul 6, 2026
0 of 2 checks passed
@briansrls
briansrls deleted the session/loyal-dove-903 branch July 6, 2026 06:21
briansrls added a commit that referenced this pull request Jul 6, 2026
Pick up #6311 source_root_ingest_gate fix so CI floor runs on a green base.
gunbai-bot Bot pushed a commit that referenced this pull request Jul 6, 2026
briansrls added a commit that referenced this pull request Jul 6, 2026
Pick up #6311 (source_root_ingest gate fix) so CI floor runs on a green base.
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