Skip to content

Fix the direct-import-vs-transitive-leak binding defect (#6663 x #6686 main-red root fix) + fmt-immune crate-layout emitter - #6701

Merged
briansrls merged 9 commits into
mainfrom
session/vivid-owl-803
Jul 16, 2026
Merged

briansrls merged 9 commits into
mainfrom
session/vivid-owl-803

Conversation

@gunbai-bot

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

Copy link
Copy Markdown
Contributor

What this PR is now

The root fix for the #6663 × #6686 main-red (this PR began as a revert of #6686; main then moved — #6696 landed a colliding literal-flattening unbreak — so the revert/re-land pairs cancel and the net diff is the root fix alone, 6 files):

  1. overlay_direct_import_exports (src/v1/04_infer.dag + regenerated v1_compiler_infer.rs): after the ancestry cache union in build_type_env, re-apply each direct import's own export surface (interface.env.str_bindings — locals only, never its ancestry), restricted to the names the import statement makes visible. Effective precedence, nearest first: locals > kernel > direct-selected > transitive union.
  2. 5-arm receipt test (direct_import_precedence_over_transitive_leak_test): direct-selected beats a later transitive leak (selective + is_all); the field-presence wall still refuses the true shape's missing field; kernel names are never overridden; the binding-fork ledger still records conflicts.
  3. Drift-gate deadlock fix: stage0_crate_layout_emit.dag stamps #[rustfmt::skip] on the generated consts so the wet emitter's bytes are the fixed point of cargo fmt (Wave 2 derived crate layout (GATES the wide fan-out) — make frontier.dag the single crate-organization authority: derive the emitted-module registration (pub mod list in 05_emit_rust hand_maintained_mods + regen_stage0 HAND_MAINTAINED_STAGE0_FILES) from the SelfEmitted frontier set, killing the §3 h #6677's artifact had two writers that could never agree: committed = fmt-clean/drift-red, regenerated = drift-clean/fmt-red; batch 4 first ran on this PR because main broke before ever reaching it).

The defect

union_parent_type_env_caches folds each direct import's whole flattened cache (own exports and inherited ancestry) with import-order overlay-wins, so a later import's transitively-leaked homonym silently beats an earlier import's explicitly selected export.

Ruled semantics preserved (2026-07-11 lane ruling): peer-direct forks keep import-order overlay-wins and stay ledgered on binding_forks; the kernel scope layer stays positionally above imports (kernel_type_set, containers List/Set/Map/Witness, Optional/Present/Absent/Unit) — builtin and algebra-profile typing (first, ends_with) grounds on kernel identities, and the v2 substrate models of those names are the known dual-representation interim. Fork observability is untouched; only which binding serves lookups changes. Dissolves with namespace Rule-1 (the union leak itself disappears).

Receipts (by execution)

  • RED control: pre-fix seed binary on the re-land tree → the identical 28 missing required field errors from main run 29461044828; post-fix binary, same tree → clean. Only the binary varies.
  • Whole-tree compile-clean on this merged tree (main + §3: consolidate md_helpers + flatten v2 algebra literals onto std.algebra #6696 + Ground fnv1a64 hash fork: unify v2.std.node.Hash with std ContentHash #6686 edge + fix): gunbc compile --source-root dag --source-root src/v2 --target dag → 0 diagnostics. (First fix cut had 11 errors from kernel/container shadowing — that iteration is why the kernel guard and its receipt arm exist.)
  • Fork-ledger arms: existing transitive_interface_binding_test untouched and green.
  • Self-host fixed point: regen_stage0 --verify → regen_divergence_count=0.
  • Drift gate: wet regen (main_wet) leaves the tree byte-clean; cargo fmt --check green on the emitter's own output.

🤖 Generated with Claude Code

Brian Searls and others added 5 commits July 16, 2026 01:05
…port x #6663 field wall)

Partial revert of 4a60303: src/v2/std/node.dag, materialize.dag,
materialize_witness_test.dag, inert_carrier.dag, and the DESIGN Sec-3-thread
note pair (carrier + generated doc together). Keeps #6686's orthogonal
cli_run.rs nfr-roster backfill (reverting it would re-red the falsifier lane).

Root cause (proven by execution): #6663's new MissingField presence check
resolves a literal's expected type by unqualified name through the flat module
type env; #6686's 'import std.types { ContentHash }' in v2.std.node pulls
dag-root std.algebra into the typecheck closure of every v2 module importing
v2.std.node (704 files), so dag-root Monoid/Semigroup/BooleanAlgebra/
OrderedRing/CommutativeMonoid/CommutativeSemiring/AbelianGroup shadow the
v2.std.algebra declarations at 28 literal sites in
src/v2/std/{diagnostic,logic,nat,integer}.dag -> ci_floor_plan resolve fails
-> every main push red. Neither PR alone was red: zero file overlap, merged
31 minutes apart, and the squash union tree was never CI'd (the PR's only CI
run began 8 minutes before #6686 landed).

Receipt: on the 60286e0 tree with the same seed binary, reverting exactly
this .dag surface takes the plan resolve from 28 missing-required-field errors
to green with the floor executing witnesses (control: #6678/#6685 left in
tree).

Re-land trigger (dissolution): the wall's presence leg consults the resolver's
binding (or fails closed on ambiguous names) instead of the flat-env name
lookup; the follow-up re-lands these files with that fix, using this exact
28-error tree as the RED control.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…poisoning surface)

The floor's inert_carrier_no_unrostered_or_stale witness reds without it:
the LocalAlias fixture it rosters landed in #6641, not #6686 — the roster
line was a bundled orthogonal fix (same class as the kept cli_run.rs
backfill), not part of the hash-grounding surface. Receipt: local floor on
the revert tree, 300 PASS / 1 FAIL (this witness), FAIL clears with the
line restored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
briansrls added a commit that referenced this pull request Jul 16, 2026
Branch now stacks on session/vivid-owl-803 (#6701) for main-red resolve fix;
PR diff vs base remains 3-file construction wall only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Brian Searls and others added 3 commits July 16, 2026 02:16
…immune (rustfmt::skip)

Batch-4 generated_artifact_drift_gate_passes red on this PR is the first run
of that gate since main broke at 60286e0 -- #6677 landed its derived
crate-layout artifact during the red window, so no tree ever executed batch 4
against it. Two writers disagreed on one artifact: the wet leg
(stage0_crate_layout_emit.dag) emits plain multi-line arrays, while the
committed bytes were rustfmt'd (trailing comma, collapsed one-liner). Committed
bytes: fmt-clean, drift-red; emitter bytes: drift-clean, fmt-red -- no tree
could satisfy both gates.

Fix: the emitter stamps #[rustfmt::skip] on both consts, so its output is the
fixed point of cargo fmt; artifact regenerated via main_wet. Receipts: wet
regen leaves the tree clean, cargo fmt --check -p v1-compiler green,
regen_stage0 --verify divergence 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gunbai-bot gunbai-bot Bot changed the title Unbreak main: revert #6686's v2 hash-grounding surface (cross-root import x #6663 field wall) Fix the direct-import-vs-transitive-leak binding defect (#6663 x #6686 main-red root fix) + fmt-immune crate-layout emitter Jul 16, 2026
@gunbai-bot

gunbai-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

CI green on head ada3d2a: run 29466927103 (build ✓, ci floor ✓ — whole-tree compile-clean + batch-4 drift gate both pass). Merge bar met: 2 distinct dashboard approvals on this head (review 38626, review 38630), no request-changes, MERGEABLE. Ready for operator merge — landing this un-reds main (it carries both the binding-precedence root fix and the #6677 drift-gate deadlock fix).

Suite-triage note for context: the 6 local cargo-test failures on this tree are all pre-existing (bisected by execution: the 3 pipeline wire-contract tests red since #6663's field wall — they assert the pre-wall fail-at-emit contract; eval_measurement_purity + std_types_freebie red at #6685 already; claim_batch one is a local-binary environmental). None gate CI — nextest was removed from CI by the 2026-07-11 ruling (ci_spec ci_fmt_gate_note); fix-up belongs to a wall-lane follow-up, not this PR.

— sent from vivid-owl-803

@briansrls
briansrls merged commit b018f54 into main Jul 16, 2026
3 checks passed
@briansrls
briansrls deleted the session/vivid-owl-803 branch July 16, 2026 03:16
briansrls added a commit that referenced this pull request Jul 16, 2026
briansrls added a commit that referenced this pull request Jul 16, 2026
Reverts src/v1/04_infer.dag and v1_compiler_infer.rs to origin/main
(#6701/#6696). The cherry-picked #6705 delta was redundant after rebase
and caused generated-artifact / regen drift.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jul 16, 2026
Reverts src/v1/04_infer.dag and v1_compiler_infer.rs to origin/main
(#6701/#6696). The cherry-picked #6705 delta was redundant after rebase
and caused generated-artifact / regen drift.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jul 16, 2026
Reverts src/v1/04_infer.dag and v1_compiler_infer.rs to origin/main
(#6701/#6696). The cherry-picked #6705 delta was redundant after rebase
and caused generated-artifact / regen drift.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jul 16, 2026
Reverts src/v1/04_infer.dag and v1_compiler_infer.rs to origin/main
(#6701/#6696). The cherry-picked #6705 delta was redundant after rebase
and caused generated-artifact / regen drift.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jul 16, 2026
…ia the existing value-expression path, prove behavioral equivalence to v1 seed (hermetic per-PR + wet oracle), flip frontier row SeedRetained->SelfEmitted. Copy the use_site_verdict pilot template (#6675). v2-only leaf, shim-free. (#6704)

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

* Fix record-lit field authority for v2.std.algebra annotated literals.

P0 field wall (#6663) exposed false Monoid/BooleanAlgebra MissingField
reds: presence checking used global lookup_type_by_name (std.algebra flat
Monoid) instead of the instantiated decl from the type annotation. Use
type_node_label for applied-type matching, decl.children for template
fields, and record_lit_fields_from_expected before bare-name fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

* Fix compile-clean parse error in stage0 crate layout witness.

Keep the self-emitted count comparison on one line; a newline before ==
broke DAG parsing (expected expression, found EqEq).

Co-authored-by: Cursor <cursoragent@cursor.com>

* Drop redundant infer cherry-pick; main already has record-lit fix.

Reverts src/v1/04_infer.dag and v1_compiler_infer.rs to origin/main
(#6701/#6696). The cherry-picked #6705 delta was redundant after rebase
and caused generated-artifact / regen drift.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Align infer with main after rebase (drop surviving cherry-pick hunk).

Keeps src/v1/04_infer.dag and v1_compiler_infer.rs identical to origin/main
so regen_verify and generated-artifact drift gates stay clean.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Regen bootstrap_stage0_crate_layout_generated.rs (trailing-comma drift).

main_wet byte-compare caught a hand-merge comma in the last filename
entry; aligns bootstrap with stage0_crate_layout_emit output.

Co-authored-by: Cursor <cursoragent@cursor.com>

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

* WIP: Wave 2 Band A self-emit: discovery_enumeration — self-emit its Rust via

---------

Co-authored-by: Brian Searls <briansrls@gunb.ai>
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