Skip to content

Ground emit-path variant-owner determinism in .dag authority - #5913

Merged
briansrls merged 3 commits into
mainfrom
session/crisp-stag-428
Jun 28, 2026
Merged

briansrls merged 3 commits into
mainfrom
session/crisp-stag-428

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Grounds the structurally-nondeterministic emit-path variant-owner pick and import-set ordering in the .dag authority (not a hand-synced seed restore of #5879).

  • imported_variants disambiguation (04_infer.dag): per-variant owner lookup uses the source module's locally-defined items, not transitive type_env.bindings. Map stores only unambiguous owners (Map<String, String>) so regen emits valid Rust.
  • Deterministic variant_fold: alpha-sort env.bindings before fold so shared-variant owner selection is stable across runs.
  • Emit import ordering (05_emit_rust.dag): sort map_keys(export_sets) at three call sites for stable pub use ordering.
  • Struct literal disambiguation (find_struct_name_by_fields): field-type hints filter candidates when multiple structs share field names.

Preserves #5891 expected_type_override_enum (per-site expected-type override).

Proof (execution-grounded)

  • regen_stage0 --verify: green (seed is pure regen artifact of .dag)
  • gunbc compile --source-root dsl --target rust x2, diff -rq: 0 (was 36 on main)
  • cargo test -p v1-compiler-tests variant_owner_disambiguation: 3/3 green

Test plan

  • regen_stage0 --verify green
  • double-emit corpus oracle 36→0
  • variant_owner_disambiguation 3/3
  • CI floor on updated HEAD

Brian Searls and others added 3 commits June 28, 2026 19:27
…grounding)

Port #5879's variant-owner disambiguation back into .dag authority and hand-sync
the v1 Rust seed: imported_variants (source-module local items), alpha-sorted
variant_fold bindings, sorted export-set map_keys, and field-type-hint struct
disambiguation. Regen in #5873 overwrote these fixes; this re-lands them on
current main (#5899) without disturbing expected_type_override_enum (#5891).

Co-authored-by: Cursor <cursoragent@cursor.com>
Re-land imported_variants + sorted variant_fold on top of #5899's
func_sigs/all_declared_sigs path (not the reverted imported_sigs fork).
Restores compile-clean hand-sync; variant_owner_disambiguation 3/3 green.

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

Fix imported_variants map type so regen emits valid Rust (Map<String,String>
for unambiguous owners only), then regen stage0 to match .dag fixed point.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot gunbai-bot Bot changed the title Restore emit-path variant-owner determinism (#5879 grounding, post-#5873 regen) Ground emit-path variant-owner determinism in .dag authority Jun 28, 2026
@briansrls
briansrls merged commit 5ffee34 into main Jun 28, 2026
2 checks passed
@briansrls
briansrls deleted the session/crisp-stag-428 branch June 28, 2026 21:57
briansrls added a commit that referenced this pull request Jun 29, 2026
Close FLAGS 1/2/5 as decided; keep 2 genuine operator FLAGS. Adopt
DeterminismAxis one-core-two-refinements (§3 probe). State additive
relationship to #5913 as first roster construction-instance.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jun 29, 2026
…esses.

Land operator-ratified design doc and activate v2.std.determinism with a closed
primitive roster (incl. #5913 construction rows), left-biased determinism_compose,
and green determinism_contract_test claims — FLAG 1 locked to bundle into #3468.

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request Jun 29, 2026
* docs: §5 determinism mechanism design (shape-sign draft)

Model how v2.std.determinism graduates from inert carrier to a
signature-derived classification axis orthogonal to EffectShape, with
authority boundaries, phasing, and operator FLAGS — no std/lens edits yet.

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

* docs: sharpen determinism design per manager review

Close FLAGS 1/2/5 as decided; keep 2 genuine operator FLAGS. Adopt
DeterminismAxis one-core-two-refinements (§3 probe). State additive
relationship to #5913 as first roster construction-instance.

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

* fix(ci): wire determinism design doc into doc-graph + DESIGN authority

Link docs/plans/determinism-mechanism-design.md from DESIGN.md open
threads (doc reachability) and sync design_document.dag (generated-artifact
drift gate).

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

---------

Co-authored-by: Brian Searls <briansrls@gunb.ai>
Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls pushed a commit that referenced this pull request Aug 28, 2026
… run to run, and a two-draw control could not have told the difference (#9496)

* Retract a causal story I put on main: the emitter's pub use ordering varies run to run, my preamble-reorder diagnosis was never established, and a two-draw control could not have told the difference

#9439 landed an annotation on emit_rust's preamble asserting that factoring the preamble moved
emitted bytes, that "the emitter is stable given its source and NOT invariant under this
reordering", and that restoring the original order restored byte-identity. THE FIRST HALF OF THAT
SENTENCE IS FALSE AND THE REST IS UNSUPPORTED. Prose on main asserting a mechanism nobody
established is premise contamination, and the next person to touch that preamble would have found a
confident causal story and planned against it.

WHAT IS ACTUALLY HAPPENING, one binary compiling one unchanged corpus six consecutive times (scoped
emit of src/v2/compiler/00_compile.dag, 175 files): the differing-file count VARIES BY RUN --
2, 0, 1, 0, 2. Exactly two files ever differ (v2_lens_enforcement_vocab.rs,
v2_std_cross_tree_resolution.rs), each with exactly two distinct outputs; sorted lines are IDENTICAL
in every differing pair, so this is REORDERING and not value nondeterminism; every changed line is a
`pub use` line (2 of 2, 4 of 4); and after rustfmt both files are NORMALIZED-IDENTICAL. That is the
known import-set ordering class (#5913; measured again on 03_ingest 2026-08-22), reported
independently by another lane on main at 38a127b naming THESE TWO FILES with no contact between
lanes.

THE CENTRE OF THE REWRITE IS THE LESSON, NOT THE FINDING: a control over a probabilistic subject
needs a stated sample size before it concludes anything, and two agreeing draws are not determinism.
The same-source control was run twice, agreed twice, and was read as proof of determinism -- against
a flip with roughly those odds it agrees about half the time, so it could not have detected the thing
it was controlling for. That generalises past this file; the pub use finding does not.

TWO CORRECTIONS STATED IN THE TERMS THAT MATTER. The reordering was never shown to move a byte, and
was never shown innocent either -- so keeping the original binding order is NOT justified by the
specimen given for it, and the annotation says so rather than quietly keeping the conclusion. And the
claim that this undermines every byte-comparison gate including regen's fixed point is true in
general and FALSE of this mechanism against that gate: the compared population is normalized, and
normalization is exactly what removes pure use-statement reordering.

WHAT THIS DOES NOT DO: it offers no theory for why a site grounded in June (#5913) varies again in
August. That is unexplained, is stated as unexplained, and a correct retraction must not become a
second causal story. The contribution is the localisation -- two named files, pure `pub use` order,
two outputs each.

ALSO IN THIS PR, from review 56672's non-blocking note on #9439: reference_derived_census now counts
through one fold that dispatches on the coproduct instead of four filters over the rendered
disposition NAME. Adding a fifth arm now breaks this function rather than being silently uncounted --
which, in a change whose subject is a population that goes uncounted in silence, was that defect
reintroduced one level up. It also makes `candidates` the sum of the arms by construction, and the
witness pins that.

VERIFIED: required-regen first_generation_equal=true planned=138 executed=138 with NO drift against
the committed mirror; all five witness rows PASS.

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

* Take #9537's repair instead of carrying it here: drop the three mirrors this branch did not originate

The merge regenerated five stage0 mirrors -- the two this branch owns, plus
v1_compiler_emit_core_support.rs, v1_compiler_emit_go.rs and v1_compiler_emit_python.rs,
whose drift a pristine-main control showed to be main's and not this branch's. A dedicated
PR (#9537) now carries exactly those four files at the same base, so carrying them here too
would be two independent repairs of one drift -- the conflict class this branch spent the
evening resolving.

Also restores src/v1/stage0/src/bin/claim_executor.rs and src/v1/stage0/src/cli_run.rs to
main's bytes: the regeneration dispatch tarred the whole stage0 source directory back from a
runner whose checkout predated this merge, so those two hand-maintained files returned as
pre-merge copies and silently dropped main's content.

* Complete the census sum assertion over all six arms (review 57169)

The #9466 merge extended the disposition coproduct to six arms and this file's
fixture to six rows, and did not extend the sum clause. It read

  candidates == survived + own_module + registry_absent + export_proof_failed

against a six-row fixture, so it asserted 6 == 4 and evaluated FALSE -- and it
asserted the opposite of the property it exists to check, that the two variant
arms are not part of the total.

Nothing caught it because nothing ran it. The fold compiled, the per-arm
equalities were all correct, the mirror regenerated, and required-regen reached
first_generation_equal with fixed-point 0 -- six green signals, none of which
evaluates a witness assertion. The regen gate proves the mirror matches the
authority; it says nothing about whether the authority is right.

Verified by execution rather than by inspection this time: all five rows run
green against the emitted mirror (2 passed, 0 failed).

---------

Co-authored-by: gunbc-ci-auto-heal <gunbc-ci-auto-heal@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.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