From f06b7ab82a83a21e0e1a7cc7b757e1f539ab0515 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 15:01:53 +0000 Subject: [PATCH 01/13] Refuse duplicate native-ingest module paths with both files named. A copied closure under one root tagged every v2 file as DagTree because tree identity used a src/ prefix, so resolve reported an unbound name elsewhere instead of the collision. Tag V2Tree on a src/ path component, and locate closure_census_duplicate_module on both declaring files. Co-authored-by: Cursor --- ..._claiming_one_module_path_misdiagnosed.dag | 34 +++++++ .../collision_a.dag | 3 + .../collision_b.dag | 3 + .../dag_side/dag_entry.dag | 3 + .../v2_side/src/v2/v2_other.dag | 3 + .../compiler/self_host/closure_emission.dag | 57 ++++++++++- src/v2/compiler/source_authority.dag | 9 +- src/v2/test/claim/cli/v2_native_cli_test.dag | 95 ++++++++++++++++++- .../claim/self_host/closure_emission_test.dag | 15 ++- .../test/claim/source_root_tagging_test.dag | 37 +++++++- 10 files changed, 247 insertions(+), 12 deletions(-) create mode 100644 dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag create mode 100644 fixtures/native_ingest_duplicate_module/collision_a.dag create mode 100644 fixtures/native_ingest_duplicate_module/collision_b.dag create mode 100644 fixtures/native_ingest_two_roots/dag_side/dag_entry.dag create mode 100644 fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag diff --git a/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag b/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag new file mode 100644 index 00000000000..45453eb3694 --- /dev/null +++ b/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag @@ -0,0 +1,34 @@ +module gunbc.recurring_failure_mode.two_source_files_claiming_one_module_path_misdiagnosed + +import std.types { NonEmptyStr } +import std.decl_ref { DeclarationRef, WholeDeclaration } +import gunbc.recurring_failure_mode { RecurringFailureMode } + +data two_source_files_claiming_one_module_path_misdiagnosed: RecurringFailureMode = RecurringFailureMode { + identity: "two_source_files_claiming_one_module_path_misdiagnosed" as NonEmptyStr, + + receipts: [ + "**two source files claiming one module path are not refused as that collision, and the native door reports a later unbound name instead** (INVALID STATE: either two files declare the same module path, or one walked root's layout maps two files onto one tree identity, and ingest continues. HARM: the operator sequences on `resolve_unbound_name_is_declared_elsewhere` at a real token in an innocent module -- DESIGN section 5 silent wrongness wearing a located diagnostic.", + + "TRIGGER INCIDENT, lively-bear-908: dag/std/algebra.dag (`module std.algebra`) and src/v2/std/algebra.dag (`module v2.std.algebra`) were loaded under ONE copied source root. Those are DISTINCT declared module paths. What collided was PATH-DERIVED SOURCE-ROOT IDENTITY: v2.compiler.source_authority source_root_for_storage_path classified a file as V2Tree only when the walk spelling started with `src/`. A copied tree `/tmp/copy/src/v2/std/algebra.dag` does not, so both files became DagTree. Resolve then named a token in std.change as declared elsewhere rather than naming the layout.", + + "THE SAME DECLARED PATH IS A SECOND ARM OF THE SAME CLASS. The census already refused a second file declaring one QualifiedName (`closure_census_duplicate_module`), but located only that second file's module node. The first file was unnamed. v1's wall at v1_compiler.cli_run module_path_collision_panic_message names BOTH paths. A refusal that names one of two files is still a misdiagnosis of the collision.", + + "DISTINGUISHING FACT: this is not `two_modules_answer_to_one_logical_qualified_name` (a logical-name strip after ingest). It is ingest identity: declared module path, or the tree tag derived from the file's path, answering for two files as one.", + + "RECOGNITION RULE: a native emit or census over a small tree reports `resolve_unbound_name_is_declared_elsewhere` (or any resolve unbound) while two walked files share a declared module path OR a copied `src/` path is tagged DagTree. The reviewer tell: the diagnostic's file is not one of the two that share the identity.", + + "RUNG FOUND AT: OUTSIDE THE LADDER -- silent wrongness. The later diagnostic is typed and located, and it is the wrong subject.", + + "CEILING: 3, structurally guaranteed. Ingest can refuse a second file that declares an already-ingested module path, with loci on both files, and can tag V2Tree by a `src/` directory component rather than a string prefix. It cannot make two files unwritable.", + + "NEXT-RUNG TRIGGER: the native CLI, over a two-file tree whose declared module paths collide, refuses `closure_census_duplicate_module` naming both files; and a path containing `/src/` as a directory component is V2Tree. Sufficient that a copied closure cannot present as an unbound name in a third module. Not satisfied by the census fold refusing on supplied ingest while the filesystem door still prefix-matches.", + + "CONSUMPTION: this per-class record joins the derived gunbc.recurring_failure_mode.roster recurring_failure_mode_roster.", + ], + + evidence: [ + DeclarationRef { module_path: "v2.compiler.source_authority", decl_name: "source_root_for_storage_path", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.compiler.self_host.closure_emission", decl_name: "closure_census_duplicate_module_outcome", field: WholeDeclaration }, + ], +} diff --git a/fixtures/native_ingest_duplicate_module/collision_a.dag b/fixtures/native_ingest_duplicate_module/collision_a.dag new file mode 100644 index 00000000000..1538ef552a1 --- /dev/null +++ b/fixtures/native_ingest_duplicate_module/collision_a.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.collision + +data native_ingest_collision_a_value: Int = 1 diff --git a/fixtures/native_ingest_duplicate_module/collision_b.dag b/fixtures/native_ingest_duplicate_module/collision_b.dag new file mode 100644 index 00000000000..6e4a6710d0f --- /dev/null +++ b/fixtures/native_ingest_duplicate_module/collision_b.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.collision + +data native_ingest_collision_b_value: Int = 2 diff --git a/fixtures/native_ingest_two_roots/dag_side/dag_entry.dag b/fixtures/native_ingest_two_roots/dag_side/dag_entry.dag new file mode 100644 index 00000000000..1e2fd471527 --- /dev/null +++ b/fixtures/native_ingest_two_roots/dag_side/dag_entry.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.dag_entry + +data native_ingest_dag_entry_value: Int = 1 diff --git a/fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag b/fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag new file mode 100644 index 00000000000..69338a89ba1 --- /dev/null +++ b/fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.v2_other + +data native_ingest_v2_other_value: Int = 2 diff --git a/src/v2/compiler/self_host/closure_emission.dag b/src/v2/compiler/self_host/closure_emission.dag index 1f14d07ab0d..9b0922d154d 100644 --- a/src/v2/compiler/self_host/closure_emission.dag +++ b/src/v2/compiler/self_host/closure_emission.dag @@ -62,6 +62,7 @@ import v2.std.diagnostic { bind_outcome, diagnostics_fatal, diagnostics_fatal_reason, + diagnostics_singleton, non_empty_diagnostics_append, node_locus, outcome_accepted, @@ -77,7 +78,7 @@ import v2.std.resolution_policy { default_name_resolution_policy } import v2.std.symbol_index { SymbolIndex, empty_symbol_index } import v2.std.grammar { ParseTree } import v2.std.integer { Int } -import std.optional { Absent, Optional, Present } +import std.optional { Absent, Optional, Present, optional_absent, optional_present } import v2.std.text { String } import v2.compiler.refinement_discharge { infer_and_discharge } @@ -219,10 +220,11 @@ fn closure_ingest_step( o: qualified_name_from_module_node(root: census.root), f: fn(module_qn) { if closure_ingest_declares(files: acc.files, member_module: module_qn) { - outcome_rejected(d: closure_emission_diagnostic( - reason: ^closure_census_duplicate_module, - at: census.root - )) + closure_census_duplicate_module_outcome( + files: acc.files, + member_module: module_qn, + second_root: census.root + ) } else { outcome_accepted(value: ClosureIngest { files: list_snoc_item(xs: acc.files, item: ClosureIngestFile { @@ -313,6 +315,51 @@ fn closure_ingest_declares(files: FreeMonoid, member_module: fold_list(xs: files, empty: false, cons: fn(found, f) { found || f.module == member_module }) } +fn closure_ingest_first_declaring( + files: FreeMonoid, + member_module: QualifiedName +) -> Optional { + fold_list(xs: files, empty: optional_absent(), cons: fn(found, f) { + match found { + Present { value: _ } => found + Absent => + if f.module == member_module { + optional_present(value: f) + } else { + found + } + } + }) +} + +// BOTH FILES, because a collision is a two-place fact. Locating only the second file's module +// node left the first unnamed, and a later resolve diagnostic at an innocent token was then +// read as the cause. +fn closure_census_duplicate_module_diagnostics(first: Node, second: Node) -> NonEmptyDiagnostics { + non_empty_diagnostics_append( + a: diagnostics_singleton(d: closure_emission_diagnostic(reason: ^closure_census_duplicate_module, at: first)), + b: diagnostics_singleton(d: closure_emission_diagnostic(reason: ^closure_census_duplicate_module, at: second)) + ) +} + +fn closure_census_duplicate_module_outcome( + files: FreeMonoid, + member_module: QualifiedName, + second_root: Node +) -> Outcome { + match closure_ingest_first_declaring(files: files, member_module: member_module) { + Present { value: first } => + Rejected { + diagnostics: closure_census_duplicate_module_diagnostics( + first: first.census.root, + second: second_root + ) + } + Absent => + outcome_rejected(d: closure_emission_diagnostic(reason: ^closure_census_duplicate_module, at: second_root)) + } +} + // EXACTLY ONE FILE, OR A TYPED REFUSAL. The census makes more than one unreachable, and it is refused // here anyway rather than read as its first element. fn closure_file_of(files: FreeMonoid, member_module: QualifiedName, at: Node) -> Outcome { diff --git a/src/v2/compiler/source_authority.dag b/src/v2/compiler/source_authority.dag index 4f449781656..1e7bf7e3d3e 100644 --- a/src/v2/compiler/source_authority.dag +++ b/src/v2/compiler/source_authority.dag @@ -483,8 +483,15 @@ fn source_ref_path(ref: SourceRef) -> String { ref.path } +// Tree identity is a PATH COMPONENT, not a prefix of the walk spelling. A source root that +// already is `src/v2` stores `src/v2/std/algebra.dag` and the old prefix test classified it. +// The same file under a copied closure (`/tmp/copy/src/v2/std/algebra.dag`) does not start +// with `src/`, so both dag and v2 files became DagTree and the native door resolved a real +// token as `resolve_unbound_name_is_declared_elsewhere` instead of keeping the two trees +// distinct. `/src/` as a directory boundary recovers that layout; a relative `src/` prefix +// still recovers the in-repo walk. fn source_root_for_storage_path(path: String) -> SourceRootRef { - if starts_with(s: path, prefix: "src/") { + if starts_with(s: path, prefix: "src/") || string_contains(s: path, pattern: "/src/") { V2Tree } else { DagTree diff --git a/src/v2/test/claim/cli/v2_native_cli_test.dag b/src/v2/test/claim/cli/v2_native_cli_test.dag index d0818b9f6a7..5b4f339f3dc 100644 --- a/src/v2/test/claim/cli/v2_native_cli_test.dag +++ b/src/v2/test/claim/cli/v2_native_cli_test.dag @@ -30,7 +30,7 @@ import v2.compiler.source_authority { DagSourceReadWitness, SourceRootIngest } import v2.std.algebra { length, list_head, HeadAbsent, HeadFound } import v2.std.artifact { Artifact, SourceFile } import extdeps.communication.medium { Lossless, Medium } -import v2.std.cross_tree.import_model { DagTree } +import v2.std.cross_tree.import_model { DagTree, SourceRootRef, V2Tree } import v2.std.node { Symbol } import v2.std.qualified_name { qualified_name_from_dotted_string } import v2.std.text { String } @@ -479,3 +479,96 @@ test fn a_trailing_token_refusal_locates_its_fatal_in_the_file_holds() -> Bool { CliDifferentialReported { text: _, observed: _, detail: _ } => false } } + +data cli_dup_a_source: String = "module fixture.native_ingest.collision\n\ndata cli_dup_a_value: Int = 1\n" + +data cli_dup_b_source: String = "module fixture.native_ingest.collision\n\ndata cli_dup_b_value: Int = 2\n" + +data cli_dup_ingest: SourceRootIngest = [ + cli_probe_read(source: cli_dup_a_source, id: ^cli_dup_a_artifact, unit: ^cli_dup_a_cu, path: "dag/collision_a.dag"), + cli_probe_read(source: cli_dup_b_source, id: ^cli_dup_b_artifact, unit: ^cli_dup_b_cu, path: "dag/collision_b.dag") +] + +data argv_emit_collision: FreeMonoid = Cons { + head: "emit", + tail: Cons { + head: "--entry", + tail: Cons { + head: "fixture.native_ingest.collision", + tail: Cons { head: "--source-root", tail: Cons { head: "dag", tail: Empty } } + } + } +} + +fn cli_dup_outcome() -> CliRunOutcome { + v2_cli_run( + plan: v2_cli_parse(argv: argv_of(items: argv_emit_collision)), + ingest: cli_dup_ingest + ) +} + +test fn two_files_declaring_one_module_refuse_as_a_census_collision_holds() -> Bool { + match cli_dup_outcome() { + CliCensusRefused { reason: reason, detail: detail, text: _ } => + reason == ^closure_census_duplicate_module + && string_contains(s: detail, pattern: "cli_dup_a_cu") + && string_contains(s: detail, pattern: "cli_dup_b_cu") + CliRunRefused { reason: reason, detail: detail } => + reason == ^closure_census_duplicate_module + && string_contains(s: detail, pattern: "cli_dup_a_cu") + && string_contains(s: detail, pattern: "cli_dup_b_cu") + CliUsageRefused { reason: _, detail: _ } => false + CliEmitted { text: _, closure_size: _, refused_count: _, refusal_detail: _ } => false + CliDifferentialReported { text: _, observed: _, detail: _ } => false + } +} + +fn cli_distinct_read( + source: String, + id: Symbol, + unit: Symbol, + path: String, + root: SourceRootRef +) -> DagSourceReadWitness { + DagSourceReadWitness { + source: Medium { carried: source, fidelity: Lossless }, + artifact: Artifact { kind: SourceFile, id: id, file_path: path }, + compilation_unit: unit, + source_root: root + } +} + +data cli_distinct_dag_source: String = "module fixture.native_ingest.dag_entry\n\ndata native_ingest_dag_entry_value: Int = 1\n" + +data cli_distinct_v2_source: String = "module fixture.native_ingest.v2_other\n\ndata native_ingest_v2_other_value: Int = 2\n" + +data cli_distinct_ingest: SourceRootIngest = [ + cli_distinct_read(source: cli_distinct_dag_source, id: ^cli_distinct_dag_artifact, unit: ^cli_distinct_dag_cu, path: "dag/native_ingest_dag_entry.dag", root: DagTree), + cli_distinct_read(source: cli_distinct_v2_source, id: ^cli_distinct_v2_artifact, unit: ^cli_distinct_v2_cu, path: "src/v2/native_ingest_v2_other.dag", root: V2Tree) +] + +data argv_emit_distinct: FreeMonoid = Cons { + head: "emit", + tail: Cons { + head: "--entry", + tail: Cons { + head: "fixture.native_ingest.dag_entry", + tail: Cons { head: "--source-root", tail: Cons { head: "dag", tail: Empty } } + } + } +} + +test fn distinct_module_paths_across_two_roots_do_not_refuse_as_a_collision_holds() -> Bool { + match v2_cli_run( + plan: v2_cli_parse(argv: argv_of(items: argv_emit_distinct)), + ingest: cli_distinct_ingest + ) { + CliCensusRefused { reason: reason, detail: _, text: _ } => + reason != ^closure_census_duplicate_module + CliRunRefused { reason: reason, detail: _ } => + reason != ^closure_census_duplicate_module + CliUsageRefused { reason: _, detail: _ } => false + CliEmitted { text: _, closure_size: _, refused_count: _, refusal_detail: _ } => true + CliDifferentialReported { text: _, observed: _, detail: _ } => false + } +} diff --git a/src/v2/test/claim/self_host/closure_emission_test.dag b/src/v2/test/claim/self_host/closure_emission_test.dag index ab2e11ec364..680297c21f1 100644 --- a/src/v2/test/claim/self_host/closure_emission_test.dag +++ b/src/v2/test/claim/self_host/closure_emission_test.dag @@ -30,6 +30,7 @@ import v2.std.algebra { contains, fold_list, length } import v2.std.artifact { Artifact, SourceFile } import v2.std.cross_tree.import_model { DagTree } import v2.std.diagnostic { Accepted, Rejected, diagnostics_fatal_reason } +import v2.std.lens_verdict { lens_verdict_diagnostics_located_chain_text_in_spans } import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } import v2.std.node { Node, Symbol, node_synthetic } import v2.std.qualified_name { QualifiedName, qualified_name_from_dotted_string, qualified_name_to_dotted_string } @@ -322,9 +323,19 @@ test fn the_emission_renders_through_its_codec_and_reads_back_the_same_identitie // A MODULE IDENTITY DECLARED BY TWO FILES REFUSES THE EMISSION AT THE CENSUS, even when the two // files' declarations are independent and neither is a closure member. test fn two_files_declaring_one_module_refuse_the_emission_at_the_census_holds() -> Bool { - match ce_emission_duplicate_module().outcome { + let located = ce_emission_duplicate_module() + match located.outcome { Accepted { value: _, diagnostics: _ } => false - Rejected { diagnostics: d } => diagnostics_fatal_reason(d: d) == ^closure_census_duplicate_module + Rejected { diagnostics: d } => + diagnostics_fatal_reason(d: d) == ^closure_census_duplicate_module + && string_contains( + s: lens_verdict_diagnostics_located_chain_text_in_spans(d: d, index: located.spans), + pattern: "ce_duplicate_a_read" + ) + && string_contains( + s: lens_verdict_diagnostics_located_chain_text_in_spans(d: d, index: located.spans), + pattern: "ce_duplicate_b_read" + ) } } diff --git a/src/v2/test/claim/source_root_tagging_test.dag b/src/v2/test/claim/source_root_tagging_test.dag index 4130e059635..d37bdd0c2d0 100644 --- a/src/v2/test/claim/source_root_tagging_test.dag +++ b/src/v2/test/claim/source_root_tagging_test.dag @@ -1,10 +1,13 @@ module v2.test.claim.source_root_tagging -import v2.std.live_tree { LiveTreeDisposition } -import v2.compiler.source_authority { DagSourceReadWitness } +import v2.compiler.source_authority { + DagSourceReadWitness, + SourceRootIngest, + source_root_for_storage_path, + source_root_set_from_ingest +} import v2.std.artifact { Artifact, SourceFile } import extdeps.communication.medium { Lossless, Medium } -import v2.compiler.source_authority { DagSourceReadWitness, source_root_set_from_ingest } import v2.std.cross_tree.import_model { DagTree, V2Tree, source_root_set_contains } import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } @@ -36,6 +39,34 @@ data sr_tag_dag_read: DagSourceReadWitness = DagSourceReadWitness { data sr_tag_mixed_ingest: SourceRootIngest = [sr_tag_v2_read, sr_tag_dag_read] data sr_tag_v2_only_ingest: SourceRootIngest = [sr_tag_v2_read] +test fn a_repo_relative_src_path_is_v2_tree() -> Bool { + match source_root_for_storage_path(path: "src/v2/std/algebra.dag") { + V2Tree => true + DagTree => false + } +} + +test fn a_repo_relative_dag_path_is_dag_tree() -> Bool { + match source_root_for_storage_path(path: "dag/std/algebra.dag") { + DagTree => true + V2Tree => false + } +} + +test fn a_copied_src_path_under_another_root_is_still_v2_tree() -> Bool { + match source_root_for_storage_path(path: "/tmp/copied-closure/src/v2/std/algebra.dag") { + V2Tree => true + DagTree => false + } +} + +test fn a_copied_dag_path_under_another_root_is_still_dag_tree() -> Bool { + match source_root_for_storage_path(path: "/tmp/copied-closure/dag/std/algebra.dag") { + DagTree => true + V2Tree => false + } +} + test fn source_root_tag_carried_and_folded_to_grounded_set() -> Bool { let mixed = source_root_set_from_ingest(ingest: sr_tag_mixed_ingest) let v2_only = source_root_set_from_ingest(ingest: sr_tag_v2_only_ingest) From 3cff7f5c387f405e051ce6e7cd73bcb999903ab1 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 15:30:00 +0000 Subject: [PATCH 02/13] Stamp native-ingest tree identity from the discovering --source-root. Delete file-path classification: a copied single root refuses as unrecognized, and a dag file whose path contains /src/ stays DagTree. Co-authored-by: Cursor --- ...host_03_normalize_declared_source_refs.dag | 5 +- ..._claiming_one_module_path_misdiagnosed.dag | 13 +-- dag/gunbc/source_root_read.dag | 30 ++++--- .../dag/copied_dag.dag | 3 + .../src/v2/copied_v2.dag | 3 + .../{ => dag}/collision_a.dag | 0 .../{ => dag}/collision_b.dag | 0 .../dag/pkg/src/leaf.dag | 3 + .../{dag_side => dag}/dag_entry.dag | 0 .../{v2_side => }/src/v2/v2_other.dag | 0 src/v1/05_emit_rust.dag | 8 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2 +- src/v2/cli/compile_cli.dag | 23 ++++- src/v2/compiler/program_assembly.dag | 2 +- src/v2/compiler/source_authority.dag | 86 ++++++++++++++----- src/v2/compiler/source_authority_read.dag | 10 +-- src/v2/lens/module_graph.dag | 17 +++- ..._probe_closure_matrix_integration_test.dag | 5 +- .../stage0_production_target_test.dag | 3 +- .../test/claim/source_root_tagging_test.dag | 85 ++++++++++++++---- 20 files changed, 224 insertions(+), 74 deletions(-) create mode 100644 fixtures/native_ingest_copied_single_root/dag/copied_dag.dag create mode 100644 fixtures/native_ingest_copied_single_root/src/v2/copied_v2.dag rename fixtures/native_ingest_duplicate_module/{ => dag}/collision_a.dag (100%) rename fixtures/native_ingest_duplicate_module/{ => dag}/collision_b.dag (100%) create mode 100644 fixtures/native_ingest_src_in_dag/dag/pkg/src/leaf.dag rename fixtures/native_ingest_two_roots/{dag_side => dag}/dag_entry.dag (100%) rename fixtures/native_ingest_two_roots/{v2_side => }/src/v2/v2_other.dag (100%) diff --git a/dag/gunbc/instruments/self_host_03_normalize_declared_source_refs.dag b/dag/gunbc/instruments/self_host_03_normalize_declared_source_refs.dag index 159cbde0661..05199167a2f 100644 --- a/dag/gunbc/instruments/self_host_03_normalize_declared_source_refs.dag +++ b/dag/gunbc/instruments/self_host_03_normalize_declared_source_refs.dag @@ -2,6 +2,7 @@ module tools.self_host_03_normalize_declared_source_refs import std.types { List } import v2.compiler.source_authority { SourceRef, source_ref_for_storage_path } +import v2.std.cross_tree.import_model { V2Tree } // declared_source_refs for the 03_normalize behavioral witness only (review 41433 fix): this list // opts src/v2/compiler/03_normalize.dag's witness entry into the cli_run.rs affected-set selection @@ -13,9 +14,9 @@ import v2.compiler.source_authority { SourceRef, source_ref_for_storage_path } // this selection axis onto all 16 entries; a dedicated per-entry module keeps the axis scoped to // 03_normalize alone, matching the roster row's module_path and contract entry exactly. -data sn_source_ref: SourceRef = source_ref_for_storage_path(path: "src/v2/compiler/03_normalize.dag") +data sn_source_ref: SourceRef = source_ref_for_storage_path(path: "src/v2/compiler/03_normalize.dag", source_root: V2Tree) -data sn_contract_ref: SourceRef = source_ref_for_storage_path(path: "src/v2/test/claim/self_host_contract/normalize_emitted_contract_test.dag") +data sn_contract_ref: SourceRef = source_ref_for_storage_path(path: "src/v2/test/claim/self_host_contract/normalize_emitted_contract_test.dag", source_root: V2Tree) // Hand-verified completeness (docs/plans/declared-source-ref-selection-design.md §5.1 flagship): // every storage path this transport reads from the repository is listed -- the subject .dag and the diff --git a/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag b/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag index 45453eb3694..ed72d939700 100644 --- a/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag +++ b/dag/gunbc/recurring_failure_mode/two_source_files_claiming_one_module_path_misdiagnosed.dag @@ -10,25 +10,26 @@ data two_source_files_claiming_one_module_path_misdiagnosed: RecurringFailureMod receipts: [ "**two source files claiming one module path are not refused as that collision, and the native door reports a later unbound name instead** (INVALID STATE: either two files declare the same module path, or one walked root's layout maps two files onto one tree identity, and ingest continues. HARM: the operator sequences on `resolve_unbound_name_is_declared_elsewhere` at a real token in an innocent module -- DESIGN section 5 silent wrongness wearing a located diagnostic.", - "TRIGGER INCIDENT, lively-bear-908: dag/std/algebra.dag (`module std.algebra`) and src/v2/std/algebra.dag (`module v2.std.algebra`) were loaded under ONE copied source root. Those are DISTINCT declared module paths. What collided was PATH-DERIVED SOURCE-ROOT IDENTITY: v2.compiler.source_authority source_root_for_storage_path classified a file as V2Tree only when the walk spelling started with `src/`. A copied tree `/tmp/copy/src/v2/std/algebra.dag` does not, so both files became DagTree. Resolve then named a token in std.change as declared elsewhere rather than naming the layout.", + "TRIGGER INCIDENT, lively-bear-908: dag/std/algebra.dag (`module std.algebra`) and src/v2/std/algebra.dag (`module v2.std.algebra`) were loaded under ONE copied source root. Those are DISTINCT declared module paths. What collided was PATH-DERIVED SOURCE-ROOT IDENTITY: v2.compiler.source_authority classified a file as V2Tree from the file's storage spelling. A copied tree `/tmp/copy/src/v2/std/algebra.dag` did not start with `src/`, so both files became DagTree. Widening that classifier to 'contains /src/' moved the same silent misclassification onto a dag path such as `dag/pkg/src/leaf.dag`. Resolve then named a token in std.change as declared elsewhere rather than naming the layout.", "THE SAME DECLARED PATH IS A SECOND ARM OF THE SAME CLASS. The census already refused a second file declaring one QualifiedName (`closure_census_duplicate_module`), but located only that second file's module node. The first file was unnamed. v1's wall at v1_compiler.cli_run module_path_collision_panic_message names BOTH paths. A refusal that names one of two files is still a misdiagnosis of the collision.", - "DISTINGUISHING FACT: this is not `two_modules_answer_to_one_logical_qualified_name` (a logical-name strip after ingest). It is ingest identity: declared module path, or the tree tag derived from the file's path, answering for two files as one.", + "DISTINGUISHING FACT: this is not `two_modules_answer_to_one_logical_qualified_name` (a logical-name strip after ingest). It is ingest identity: declared module path, or a tree tag guessed from the file's path, answering for two files as one.", - "RECOGNITION RULE: a native emit or census over a small tree reports `resolve_unbound_name_is_declared_elsewhere` (or any resolve unbound) while two walked files share a declared module path OR a copied `src/` path is tagged DagTree. The reviewer tell: the diagnostic's file is not one of the two that share the identity.", + "RECOGNITION RULE: a native emit or census over a small tree reports `resolve_unbound_name_is_declared_elsewhere` (or any resolve unbound) while two walked files share a declared module path OR a copied layout is tagged by file spelling rather than by the discovering --source-root. The reviewer tell: the diagnostic's file is not one of the two that share the identity.", "RUNG FOUND AT: OUTSIDE THE LADDER -- silent wrongness. The later diagnostic is typed and located, and it is the wrong subject.", - "CEILING: 3, structurally guaranteed. Ingest can refuse a second file that declares an already-ingested module path, with loci on both files, and can tag V2Tree by a `src/` directory component rather than a string prefix. It cannot make two files unwritable.", + "CEILING: 3, structurally guaranteed. Ingest can refuse a second file that declares an already-ingested module path, with loci on both files, and can stamp SourceRootRef from the walk origin that discovered the file, refusing when that origin is not a dag or src/v2 tree. It cannot make two files unwritable.", - "NEXT-RUNG TRIGGER: the native CLI, over a two-file tree whose declared module paths collide, refuses `closure_census_duplicate_module` naming both files; and a path containing `/src/` as a directory component is V2Tree. Sufficient that a copied closure cannot present as an unbound name in a third module. Not satisfied by the census fold refusing on supplied ingest while the filesystem door still prefix-matches.", + "NEXT-RUNG TRIGGER: the native CLI, over a two-file tree whose declared module paths collide, refuses `closure_census_duplicate_module` naming both files; a copied single-root argument refuses as unrecognized rather than guessing DagTree; a file under --source-root dag whose path contains /src/ is still DagTree. Sufficient that a copied closure cannot present as an unbound name in a third module. Not satisfied by classifying the file path.", "CONSUMPTION: this per-class record joins the derived gunbc.recurring_failure_mode.roster recurring_failure_mode_roster.", ], evidence: [ - DeclarationRef { module_path: "v2.compiler.source_authority", decl_name: "source_root_for_storage_path", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.compiler.source_authority", decl_name: "admit_source_root_argument", field: WholeDeclaration }, + DeclarationRef { module_path: "gunbc.source_root_read", decl_name: "source_root_read", field: WholeDeclaration }, DeclarationRef { module_path: "v2.compiler.self_host.closure_emission", decl_name: "closure_census_duplicate_module_outcome", field: WholeDeclaration }, ], } diff --git a/dag/gunbc/source_root_read.dag b/dag/gunbc/source_root_read.dag index dfa7317f24e..49cf2da71a3 100644 --- a/dag/gunbc/source_root_read.dag +++ b/dag/gunbc/source_root_read.dag @@ -15,11 +15,12 @@ import std.optional { Absent, Present } // directory. Only the host's NotADirectory observation admits a candidate as a file; every // other failure stops the walk. In particular a disappearing entry or a broken symlink cannot // silently shrink the compiler's source population. The transport refuses lossy name encodings. -type SourceRootWalkTask { path: String, root: Bool } +type SourceRootWalkTask { path: String, root: Bool, origin: String } +type SourceRootWalkedPath { path: String, origin: String } type SourceRootPaths - = SourceRootPathsRead { paths: List } + = SourceRootPathsRead { paths: List } | SourceRootPathsRefused { path: String, kind: String, cause: String } -type SourceRootFile { path: String, content: String } +type SourceRootFile { path: String, content: String, origin: String } type SourceRootFiles = SourceRootFilesRead { files: List } | SourceRootFilesRefused { path: String, kind: String, cause: String } @@ -39,9 +40,9 @@ fn source_root_candidate_is_file(root: Bool, error_kind: String) -> Bool { } } -fn source_root_walk(pending: List, paths: List) -> SourceRootPaths { +fn source_root_walk(pending: List, paths: List) -> SourceRootPaths { match pending |> first { - Absent => SourceRootPathsRead { paths: paths |> sort_by(path => path) } + Absent => SourceRootPathsRead { paths: paths |> sort_by(walked => walked.path) } Present { value: task } => { let rest = pending.skip(n: 1) let listed = Filesystem.List(path: task.path) @@ -49,13 +50,17 @@ fn source_root_walk(pending: List, paths: List) -> S entries: listed.entries, error: listed.error) { FilesystemDirectoryListed(listing) => { let children = filesystem_listing_entry_names(listing: listing) |> map(name => SourceRootWalkTask { - path: source_root_child_path(directory: task.path, name: name), root: false + path: source_root_child_path(directory: task.path, name: name), + root: false, + origin: task.origin }) source_root_walk(pending: concat(children, rest), paths: paths) } FilesystemDirectoryListingRefused { directory: _, error: cause } => if source_root_candidate_is_file(root: task.root, error_kind: listed.error_kind) { - let next = if task.path.ends_with(suffix: ".dag") { concat(paths, [task.path]) } else { paths } + let next = if task.path.ends_with(suffix: ".dag") { + concat(paths, [SourceRootWalkedPath { path: task.path, origin: task.origin }]) + } else { paths } source_root_walk(pending: rest, paths: next) } else { SourceRootPathsRefused { path: task.path, kind: listed.error_kind, cause: cause } @@ -73,13 +78,13 @@ fn source_root_read_file(path: String) -> FilesystemExactRead { error: read.error, error_kind: read.error_kind) } -fn source_root_read_paths(pending: List, files: List) -> SourceRootFiles { +fn source_root_read_paths(pending: List, files: List) -> SourceRootFiles { match pending |> first { Absent => SourceRootFilesRead { files: files } - Present { value: path } => match source_root_read_file(path: path) { + Present { value: walked } => match source_root_read_file(path: walked.path) { FilesystemExactPathRead { path: observed, content: content } => source_root_read_paths(pending: pending.skip(n: 1), - files: concat(files, [SourceRootFile { path: observed, content: content }])) + files: concat(files, [SourceRootFile { path: observed, content: content, origin: walked.origin }])) FilesystemExactPathAbsent { path: observed } => SourceRootFilesRefused { path: observed, kind: "not_found", cause: "source disappeared before it could be read" } FilesystemExactPathUnreadable { path: observed, kind: kind, error: cause } => @@ -91,7 +96,10 @@ fn source_root_read_paths(pending: List, files: List) -> } fn source_root_read(roots: List) -> SourceRootFiles { - match source_root_walk(pending: roots |> map(path => SourceRootWalkTask { path: path, root: true }), paths: []) { + match source_root_walk( + pending: roots |> map(path => SourceRootWalkTask { path: path, root: true, origin: path }), + paths: [] + ) { SourceRootPathsRefused { path: path, kind: kind, cause: cause } => SourceRootFilesRefused { path: path, kind: kind, cause: cause } SourceRootPathsRead { paths: paths } => source_root_read_paths(pending: paths, files: []) diff --git a/fixtures/native_ingest_copied_single_root/dag/copied_dag.dag b/fixtures/native_ingest_copied_single_root/dag/copied_dag.dag new file mode 100644 index 00000000000..8d779e29278 --- /dev/null +++ b/fixtures/native_ingest_copied_single_root/dag/copied_dag.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.copied_dag + +data native_ingest_copied_dag_value: Int = 1 diff --git a/fixtures/native_ingest_copied_single_root/src/v2/copied_v2.dag b/fixtures/native_ingest_copied_single_root/src/v2/copied_v2.dag new file mode 100644 index 00000000000..4d259ce7c09 --- /dev/null +++ b/fixtures/native_ingest_copied_single_root/src/v2/copied_v2.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.copied_v2 + +data native_ingest_copied_v2_value: Int = 2 diff --git a/fixtures/native_ingest_duplicate_module/collision_a.dag b/fixtures/native_ingest_duplicate_module/dag/collision_a.dag similarity index 100% rename from fixtures/native_ingest_duplicate_module/collision_a.dag rename to fixtures/native_ingest_duplicate_module/dag/collision_a.dag diff --git a/fixtures/native_ingest_duplicate_module/collision_b.dag b/fixtures/native_ingest_duplicate_module/dag/collision_b.dag similarity index 100% rename from fixtures/native_ingest_duplicate_module/collision_b.dag rename to fixtures/native_ingest_duplicate_module/dag/collision_b.dag diff --git a/fixtures/native_ingest_src_in_dag/dag/pkg/src/leaf.dag b/fixtures/native_ingest_src_in_dag/dag/pkg/src/leaf.dag new file mode 100644 index 00000000000..9761f2f9c71 --- /dev/null +++ b/fixtures/native_ingest_src_in_dag/dag/pkg/src/leaf.dag @@ -0,0 +1,3 @@ +module fixture.native_ingest.src_in_dag + +data native_ingest_src_in_dag_value: Int = 1 diff --git a/fixtures/native_ingest_two_roots/dag_side/dag_entry.dag b/fixtures/native_ingest_two_roots/dag/dag_entry.dag similarity index 100% rename from fixtures/native_ingest_two_roots/dag_side/dag_entry.dag rename to fixtures/native_ingest_two_roots/dag/dag_entry.dag diff --git a/fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag b/fixtures/native_ingest_two_roots/src/v2/v2_other.dag similarity index 100% rename from fixtures/native_ingest_two_roots/v2_side/src/v2/v2_other.dag rename to fixtures/native_ingest_two_roots/src/v2/v2_other.dag diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 87ac7976dcf..5af22c8a693 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -18343,8 +18343,12 @@ fn emit_host_source_root_read_rs(crate_name: String) -> String { " let observed = runtime.block_on(", crate_name, "::gunbc_source_root_read::source_root_read(Rc::new(source_roots.iter().cloned().collect()), &filesystem));\n", " match observed {\n", " Ok(files) => match &*files {\n", - " ", crate_name, "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRead { files } =>\n", - " ", crate_name, "::v2_compiler_source_authority::source_root_ingest_from_files(files.clone()).iter().cloned().collect(),\n", + " ", crate_name, "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRead { files } => match &*", crate_name, "::v2_compiler_source_authority::source_root_ingest_from_files(files.clone()) {\n", + " ", crate_name, "::v2_compiler_source_authority::SourceRootIngestFromFiles::SourceRootIngestFromFilesBuilt { ingest } => ingest.iter().cloned().collect(),\n", + " ", crate_name, "::v2_compiler_source_authority::SourceRootIngestFromFiles::SourceRootIngestFromFilesUnrecognizedRoot { argument, path } => {\n", + " eprintln!(\"REFUSED: source root is not a dag or src/v2 tree: {} (file {})\", argument, path); std::process::exit(2);\n", + " }\n", + " },\n", " ", crate_name, "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRefused { path, kind, cause } => {\n", " eprintln!(\"REFUSED: could not read source root at {} [{}]: {}\", path, kind, cause); std::process::exit(2);\n", " }\n", diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 052115df96b..aa129c36ec3 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -41671,7 +41671,7 @@ pub fn emit_direct_ingest_driver_main_rs( } pub fn emit_host_source_root_read_rs(crate_name: String) -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("fn read_ingest(source_roots: &[String]) -> Vec> {\n".to_string(), " let filesystem = ".to_string()), crate_name.clone()), "::extdeps_filesystem_filesystem_io::Filesystem::new(Default::default());\n".to_string()), " let runtime = match tokio::runtime::Builder::new_current_thread().build() { Ok(runtime) => runtime, Err(cause) => { eprintln!(\"REFUSED: native filesystem executor: {}\", cause); std::process::exit(2); } };\n".to_string()), " let observed = runtime.block_on(".to_string()), crate_name.clone()), "::gunbc_source_root_read::source_root_read(Rc::new(source_roots.iter().cloned().collect()), &filesystem));\n".to_string()), " match observed {\n".to_string()), " Ok(files) => match &*files {\n".to_string()), " ".to_string()), crate_name.clone()), "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRead { files } =>\n".to_string()), " ".to_string()), crate_name.clone()), "::v2_compiler_source_authority::source_root_ingest_from_files(files.clone()).iter().cloned().collect(),\n".to_string()), " ".to_string()), crate_name.clone()), "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRefused { path, kind, cause } => {\n".to_string()), " eprintln!(\"REFUSED: could not read source root at {} [{}]: {}\", path, kind, cause); std::process::exit(2);\n".to_string()), " }\n".to_string()), " },\n".to_string()), " Err(cause) => { eprintln!(\"REFUSED: native filesystem transport: {}\", cause); std::process::exit(2); }\n".to_string()), " }\n".to_string()), "}\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("fn read_ingest(source_roots: &[String]) -> Vec> {\n".to_string(), " let filesystem = ".to_string()), crate_name.clone()), "::extdeps_filesystem_filesystem_io::Filesystem::new(Default::default());\n".to_string()), " let runtime = match tokio::runtime::Builder::new_current_thread().build() { Ok(runtime) => runtime, Err(cause) => { eprintln!(\"REFUSED: native filesystem executor: {}\", cause); std::process::exit(2); } };\n".to_string()), " let observed = runtime.block_on(".to_string()), crate_name.clone()), "::gunbc_source_root_read::source_root_read(Rc::new(source_roots.iter().cloned().collect()), &filesystem));\n".to_string()), " match observed {\n".to_string()), " Ok(files) => match &*files {\n".to_string()), " ".to_string()), crate_name.clone()), "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRead { files } => match &*".to_string()), crate_name.clone()), "::v2_compiler_source_authority::source_root_ingest_from_files(files.clone()) {\n".to_string()), " ".to_string()), crate_name.clone()), "::v2_compiler_source_authority::SourceRootIngestFromFiles::SourceRootIngestFromFilesBuilt { ingest } => ingest.iter().cloned().collect(),\n".to_string()), " ".to_string()), crate_name.clone()), "::v2_compiler_source_authority::SourceRootIngestFromFiles::SourceRootIngestFromFilesUnrecognizedRoot { argument, path } => {\n".to_string()), " eprintln!(\"REFUSED: source root is not a dag or src/v2 tree: {} (file {})\", argument, path); std::process::exit(2);\n".to_string()), " }\n".to_string()), " },\n".to_string()), " ".to_string()), crate_name.clone()), "::gunbc_source_root_read::SourceRootFiles::SourceRootFilesRefused { path, kind, cause } => {\n".to_string()), " eprintln!(\"REFUSED: could not read source root at {} [{}]: {}\", path, kind, cause); std::process::exit(2);\n".to_string()), " }\n".to_string()), " },\n".to_string()), " Err(cause) => { eprintln!(\"REFUSED: native filesystem transport: {}\", cause); std::process::exit(2); }\n".to_string()), " }\n".to_string()), "}\n".to_string()) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] diff --git a/src/v2/cli/compile_cli.dag b/src/v2/cli/compile_cli.dag index bc326c90c25..d474b92b23b 100644 --- a/src/v2/cli/compile_cli.dag +++ b/src/v2/cli/compile_cli.dag @@ -11,7 +11,12 @@ import v2.compiler.self_host.closure_emission { closure_emission_refused_count, emit_closure_from_ingest_located } -import v2.compiler.source_authority { SourceRootIngest, source_root_ingest_from_files } +import v2.compiler.source_authority { + SourceRootIngest, + SourceRootIngestFromFilesBuilt, + SourceRootIngestFromFilesUnrecognizedRoot, + source_root_ingest_from_files +} import v2.cli.if_arm_reader_differential { IardCensus, IardCensusTaken, @@ -543,7 +548,21 @@ fn v2_cli_main(argv: FreeMonoid) -> CliRunOutcome { CliPlanRefused { reason: reason, detail: detail } => CliUsageRefused { reason: reason, detail: detail } CliPlanParsed { verb: _ } => match source_root_read(roots: v2_cli_plan_source_roots(plan: plan)) { SourceRootFilesRead { files: files } => - v2_cli_run(plan: plan, ingest: source_root_ingest_from_files(files: files)) + match source_root_ingest_from_files(files: files) { + SourceRootIngestFromFilesBuilt { ingest: ingest } => + v2_cli_run(plan: plan, ingest: ingest) + SourceRootIngestFromFilesUnrecognizedRoot { argument: argument, path: path } => + CliUsageRefused { + reason: ^cli_source_root_unrecognized, + detail: concat( + "source root is not a dag or src/v2 tree: ", + argument, + " (file ", + path, + ")" + ) + } + } SourceRootFilesRefused { path: path, kind: kind, cause: cause } => CliUsageRefused { reason: ^cli_source_root_read_refused, detail: concat("could not read source root at ", path, " [", kind, "]: ", cause) } diff --git a/src/v2/compiler/program_assembly.dag b/src/v2/compiler/program_assembly.dag index f0e276f9805..a20171b2fcd 100644 --- a/src/v2/compiler/program_assembly.dag +++ b/src/v2/compiler/program_assembly.dag @@ -574,7 +574,7 @@ fn program_assembly_ingest_scope(ingest: SourceRootIngest) -> SourceRefListDiges source_ref_list_digest_build(refs: fold_list( xs: ingest, empty: Empty, - cons: fn(acc, read) { list_snoc_item(xs: acc, item: source_ref_for_storage_path(path: read.artifact.file_path)) } + cons: fn(acc, read) { list_snoc_item(xs: acc, item: source_ref_for_storage_path(path: read.artifact.file_path, source_root: read.source_root)) } )) } diff --git a/src/v2/compiler/source_authority.dag b/src/v2/compiler/source_authority.dag index 1e7bf7e3d3e..21210f218e8 100644 --- a/src/v2/compiler/source_authority.dag +++ b/src/v2/compiler/source_authority.dag @@ -25,7 +25,7 @@ import v2.extdeps.languages.dag { import v2.std.compilers.lexing { TokenStream } import v2.std.provenance { span_index_empty } import std.algebra { Empty, FreeMonoid, list_snoc_item } -import v2.std.algebra { fold_list, length } +import v2.std.algebra { HeadAbsent, HeadFound, fold_list, length, list_head, list_reverse, skip } import v2.std.artifact { Artifact, NodeArtifactProvenance, SourceFile } import v2.std.diagnostic { Accepted, @@ -483,25 +483,41 @@ fn source_ref_path(ref: SourceRef) -> String { ref.path } -// Tree identity is a PATH COMPONENT, not a prefix of the walk spelling. A source root that -// already is `src/v2` stores `src/v2/std/algebra.dag` and the old prefix test classified it. -// The same file under a copied closure (`/tmp/copy/src/v2/std/algebra.dag`) does not start -// with `src/`, so both dag and v2 files became DagTree and the native door resolved a real -// token as `resolve_unbound_name_is_declared_elsewhere` instead of keeping the two trees -// distinct. `/src/` as a directory boundary recovers that layout; a relative `src/` prefix -// still recovers the in-repo walk. -fn source_root_for_storage_path(path: String) -> SourceRootRef { - if starts_with(s: path, prefix: "src/") || string_contains(s: path, pattern: "/src/") { - V2Tree +// Tree identity is the --source-root argument that discovered the file, never a substring of +// the file's storage path. SourceRootRef has two inhabitants (the dag tree and the src/v2 +// tree); an argument names one of those directories or is unrecognized. A parent of both, a +// copied single-root dump, or any other spelling refuses rather than defaulting to DagTree. +type SourceRootArgumentAdmission + = SourceRootArgumentAdmitted { tree: SourceRootRef } + | SourceRootArgumentUnrecognized { argument: String } + +fn source_root_argument_trim(argument: String) -> String { + if argument.ends_with(suffix: "/") && (length(xs: argument) > 1) { + source_root_argument_trim( + argument: list_reverse(xs: skip(xs: list_reverse(xs: argument), n: 1)) + ) + } else if starts_with(s: argument, prefix: "./") { + source_root_argument_trim(argument: skip(xs: argument, n: 2)) + } else { + argument + } +} + +fn admit_source_root_argument(argument: String) -> SourceRootArgumentAdmission { + let a = source_root_argument_trim(argument: argument) + if (a == "src/v2") || a.ends_with(suffix: "/src/v2") { + SourceRootArgumentAdmitted { tree: V2Tree } + } else if (a == "dag") || a.ends_with(suffix: "/dag") { + SourceRootArgumentAdmitted { tree: DagTree } } else { - DagTree + SourceRootArgumentUnrecognized { argument: argument } } } -fn source_ref_for_storage_path(path: String) -> SourceRef { +fn source_ref_for_storage_path(path: String, source_root: SourceRootRef) -> SourceRef { SourceRef { path: path, - source_root: source_root_for_storage_path(path: path), + source_root: source_root, content_hash: content_hash_of_value(value: "selection-unpinned" as NonEmptyStr) } } @@ -1562,13 +1578,37 @@ fn source_authority_round_trip( ) } -// The native filesystem fold supplies observed bytes; provenance is constructed at the same -// authority as every other source witness. Neither rendered main owns this conversion. -fn source_root_ingest_from_files(files: List) -> SourceRootIngest { - files |> map(file => DagSourceReadWitness { - source: Medium { carried: file.content, fidelity: Lossless }, - artifact: Artifact { kind: SourceFile, id: file.path, file_path: file.path }, - compilation_unit: file.path, - source_root: source_root_for_storage_path(path: file.path) - }) +// The native filesystem fold supplies observed bytes and the discovering --source-root +// argument on each file. Tree identity is admitted from that argument. An unrecognized +// argument refuses; the file path is never classified. +type SourceRootIngestFromFiles + = SourceRootIngestFromFilesBuilt { ingest: SourceRootIngest } + | SourceRootIngestFromFilesUnrecognizedRoot { argument: String, path: String } + +fn source_root_ingest_from_files_go( + pending: List, + acc: SourceRootIngest +) -> SourceRootIngestFromFiles { + match list_head(xs: pending) { + HeadAbsent => SourceRootIngestFromFilesBuilt { ingest: acc } + HeadFound { value: file } => + match admit_source_root_argument(argument: file.origin) { + SourceRootArgumentAdmitted { tree: tree } => + source_root_ingest_from_files_go( + pending: skip(xs: pending, n: 1), + acc: list_snoc_item(xs: acc, item: DagSourceReadWitness { + source: Medium { carried: file.content, fidelity: Lossless }, + artifact: Artifact { kind: SourceFile, id: file.path, file_path: file.path }, + compilation_unit: file.path, + source_root: tree + }) + ) + SourceRootArgumentUnrecognized { argument: argument } => + SourceRootIngestFromFilesUnrecognizedRoot { argument: argument, path: file.path } + } + } +} + +fn source_root_ingest_from_files(files: List) -> SourceRootIngestFromFiles { + source_root_ingest_from_files_go(pending: files, acc: Empty) } diff --git a/src/v2/compiler/source_authority_read.dag b/src/v2/compiler/source_authority_read.dag index de4d8bc9f96..eb667914b60 100644 --- a/src/v2/compiler/source_authority_read.dag +++ b/src/v2/compiler/source_authority_read.dag @@ -16,9 +16,9 @@ import v2.compiler.source_authority { DagSourceReadWitness, SourceRef, SourceRootIngest, - source_ref_for_storage_path, - source_root_for_storage_path + source_ref_for_storage_path } +import v2.std.cross_tree.import_model { DagTree, SourceRootRef } import extdeps.communication.medium { Lossless, Medium } import v2.std.algebra { fold_list } import v2.std.artifact { Artifact, SourceFile } @@ -58,11 +58,11 @@ import v2.std.text { String } // witness is minted, a missing or unreadable path refuses as a read failure rather than a // misclassified parse error, and both refusals carry the observed digest. Nothing here widens on // failure. -fn source_ref_for_observed_storage_path(path: String) -> SourceRef { +fn source_ref_for_observed_storage_path(path: String, source_root: SourceRootRef) -> SourceRef { let read = Filesystem.Read(path: path) SourceRef { path: path, - source_root: source_root_for_storage_path(path: path), + source_root: source_root, content_hash: if read.success { dag_source_content_hash_for_text(text: read.content) } else { @@ -244,7 +244,7 @@ fn source_root_ingest_from_source_refs(refs: List) -> Outcome Rejected { diagnostics: source_ref_read_failed_diagnostic( - ref: source_ref_for_storage_path(path: "source-root-ingest-build-impossible"), + ref: source_ref_for_storage_path(path: "source-root-ingest-build-impossible", source_root: DagTree), error: "internal: read-through accepted without ingest row" ) } diff --git a/src/v2/lens/module_graph.dag b/src/v2/lens/module_graph.dag index 238f781bd8d..f76d713f2fb 100644 --- a/src/v2/lens/module_graph.dag +++ b/src/v2/lens/module_graph.dag @@ -59,6 +59,7 @@ import v2.compiler.source_authority { SourceRootIngest, source_ref_for_storage_path } +import v2.std.cross_tree.import_model { DagTree, SourceRootRef, V2Tree } import v2.compiler.source_authority_read { source_root_ingest_from_source_refs } import v2.compiler.symbol_index_fill { symbol_index_fill_module_root } import v2.extdeps.languages.dag { @@ -272,12 +273,26 @@ fn reference_derived_path_under_roots(path: String, roots: List) -> Bool any(xs: roots, predicate: fn(root) { starts_with(s: path, prefix: concat(root, "/")) }) } +fn declared_module_source_root(path: String) -> SourceRootRef { + if starts_with(s: path, prefix: "src/v2") { + V2Tree + } else { + DagTree + } +} + fn source_refs_from_declared(declared: List) -> List { fold_list( xs: declared, empty: no_source_refs, cons: fn(acc, fact) { - list_snoc_item(xs: acc, item: source_ref_for_storage_path(path: fact.path)) + list_snoc_item( + xs: acc, + item: source_ref_for_storage_path( + path: fact.path, + source_root: declared_module_source_root(path: fact.path) + ) + ) } ) } diff --git a/src/v2/test/claim/long/frontier_probe_closure_matrix_integration_test.dag b/src/v2/test/claim/long/frontier_probe_closure_matrix_integration_test.dag index 333f7ffad6f..966f76a317f 100644 --- a/src/v2/test/claim/long/frontier_probe_closure_matrix_integration_test.dag +++ b/src/v2/test/claim/long/frontier_probe_closure_matrix_integration_test.dag @@ -17,6 +17,7 @@ import v2.compiler.source_authority { SourceRootCoverageComplete, frontier_probe_discovered_closure_seal } +import v2.std.cross_tree.import_model { DagTree, V2Tree } import v2.compiler.source_authority_read { source_ref_for_observed_storage_path } @@ -34,11 +35,11 @@ data live_tree_disposition: LiveTreeDisposition = ReadsLiveTree // exact-head eval (784772ms / 742109ms). fn fp_matrix_ref_a() -> SourceRef { - source_ref_for_observed_storage_path(path: "dag/std/algebra.dag") + source_ref_for_observed_storage_path(path: "dag/std/algebra.dag", source_root: DagTree) } fn fp_matrix_ref_v2() -> SourceRef { - source_ref_for_observed_storage_path(path: "src/v2/std/text.dag") + source_ref_for_observed_storage_path(path: "src/v2/std/text.dag", source_root: V2Tree) } fn fp_matrix_closure_subject_matching_digest( diff --git a/src/v2/test/claim/self_host/stage0_production_target_test.dag b/src/v2/test/claim/self_host/stage0_production_target_test.dag index cb4fca7dedd..4e711038ca4 100644 --- a/src/v2/test/claim/self_host/stage0_production_target_test.dag +++ b/src/v2/test/claim/self_host/stage0_production_target_test.dag @@ -13,6 +13,7 @@ import v2.compiler.self_host.stage0_production_target { stage0_production_target_model } import v2.compiler.source_authority { DagSourceReadWitness, SourceRef } +import v2.std.cross_tree.import_model { V2Tree } import v2.compiler.source_authority_read { source_ref_for_observed_storage_path, source_root_ingest_from_source_refs @@ -232,7 +233,7 @@ type Stage0BoundaryRead fn stage0_boundary_read_of(path: String) -> Stage0BoundaryRead { match source_root_ingest_from_source_refs( - refs: Cons { head: source_ref_for_observed_storage_path(path: path), tail: Empty } + refs: Cons { head: source_ref_for_observed_storage_path(path: path, source_root: V2Tree), tail: Empty } ) { Rejected { diagnostics: _ } => Stage0BoundaryReadRefused Accepted { value: ingest, diagnostics: _ } => diff --git a/src/v2/test/claim/source_root_tagging_test.dag b/src/v2/test/claim/source_root_tagging_test.dag index d37bdd0c2d0..015d6032123 100644 --- a/src/v2/test/claim/source_root_tagging_test.dag +++ b/src/v2/test/claim/source_root_tagging_test.dag @@ -1,14 +1,21 @@ module v2.test.claim.source_root_tagging +import gunbc.source_root_read { SourceRootFile } import v2.compiler.source_authority { DagSourceReadWitness, + SourceRootArgumentAdmitted, + SourceRootArgumentUnrecognized, SourceRootIngest, - source_root_for_storage_path, + SourceRootIngestFromFilesBuilt, + SourceRootIngestFromFilesUnrecognizedRoot, + admit_source_root_argument, + source_root_ingest_from_files, source_root_set_from_ingest } import v2.std.artifact { Artifact, SourceFile } import extdeps.communication.medium { Lossless, Medium } import v2.std.cross_tree.import_model { DagTree, V2Tree, source_root_set_contains } +import std.algebra { Cons, Empty } import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } @@ -39,31 +46,75 @@ data sr_tag_dag_read: DagSourceReadWitness = DagSourceReadWitness { data sr_tag_mixed_ingest: SourceRootIngest = [sr_tag_v2_read, sr_tag_dag_read] data sr_tag_v2_only_ingest: SourceRootIngest = [sr_tag_v2_read] -test fn a_repo_relative_src_path_is_v2_tree() -> Bool { - match source_root_for_storage_path(path: "src/v2/std/algebra.dag") { - V2Tree => true - DagTree => false +test fn a_dag_source_root_argument_is_dag_tree() -> Bool { + match admit_source_root_argument(argument: "dag") { + SourceRootArgumentAdmitted { tree: DagTree } => true + SourceRootArgumentAdmitted { tree: V2Tree } => false + SourceRootArgumentUnrecognized { argument: _ } => false } } -test fn a_repo_relative_dag_path_is_dag_tree() -> Bool { - match source_root_for_storage_path(path: "dag/std/algebra.dag") { - DagTree => true - V2Tree => false +test fn a_v2_source_root_argument_is_v2_tree() -> Bool { + match admit_source_root_argument(argument: "src/v2") { + SourceRootArgumentAdmitted { tree: V2Tree } => true + SourceRootArgumentAdmitted { tree: DagTree } => false + SourceRootArgumentUnrecognized { argument: _ } => false } } -test fn a_copied_src_path_under_another_root_is_still_v2_tree() -> Bool { - match source_root_for_storage_path(path: "/tmp/copied-closure/src/v2/std/algebra.dag") { - V2Tree => true - DagTree => false +test fn a_copied_single_root_argument_is_unrecognized() -> Bool { + match admit_source_root_argument(argument: "/tmp/copied-closure") { + SourceRootArgumentUnrecognized { argument: argument } => argument == "/tmp/copied-closure" + SourceRootArgumentAdmitted { tree: _ } => false } } -test fn a_copied_dag_path_under_another_root_is_still_dag_tree() -> Bool { - match source_root_for_storage_path(path: "/tmp/copied-closure/dag/std/algebra.dag") { - DagTree => true - V2Tree => false +fn sr_file(path: String, origin: String) -> SourceRootFile { + SourceRootFile { path: path, content: "module fixture.sr_tag\n", origin: origin } +} + +test fn a_dag_file_whose_path_contains_src_is_still_dag_tree() -> Bool { + match source_root_ingest_from_files( + files: [sr_file(path: "dag/pkg/src/leaf.dag", origin: "dag")] + ) { + SourceRootIngestFromFilesUnrecognizedRoot { argument: _, path: _ } => false + SourceRootIngestFromFilesBuilt { ingest: ingest } => + match ingest { + Empty => false + Cons { head: read, tail: rest } => + match rest { + Empty => match read.source_root { + DagTree => true + V2Tree => false + } + Cons { head: _, tail: _ } => false + } + } + } +} + +test fn ingest_from_an_unrecognized_origin_refuses() -> Bool { + match source_root_ingest_from_files( + files: [sr_file(path: "/tmp/copied-closure/src/v2/std/algebra.dag", origin: "/tmp/copied-closure")] + ) { + SourceRootIngestFromFilesUnrecognizedRoot { argument: argument, path: path } => + (argument == "/tmp/copied-closure") + && (path == "/tmp/copied-closure/src/v2/std/algebra.dag") + SourceRootIngestFromFilesBuilt { ingest: _ } => false + } +} + +test fn two_root_origins_tag_each_tree() -> Bool { + match source_root_ingest_from_files( + files: [ + sr_file(path: "dag/std/algebra.dag", origin: "dag"), + sr_file(path: "src/v2/std/algebra.dag", origin: "src/v2") + ] + ) { + SourceRootIngestFromFilesUnrecognizedRoot { argument: _, path: _ } => false + SourceRootIngestFromFilesBuilt { ingest: ingest } => + source_root_set_contains(roots: source_root_set_from_ingest(ingest: ingest), r: DagTree) + && source_root_set_contains(roots: source_root_set_from_ingest(ingest: ingest), r: V2Tree) } } From e0eaa55f68648442c7f90600558f026cc1765c6d Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 15:57:26 +0000 Subject: [PATCH 03/13] Admit source-root arguments by closed tree identity, without string skip. The previous trim used skip/list_reverse on host String and the emitted CLI crate refused at rustc E0308. Co-authored-by: Cursor --- src/v2/compiler/source_authority.dag | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/v2/compiler/source_authority.dag b/src/v2/compiler/source_authority.dag index 21210f218e8..10181adc8c2 100644 --- a/src/v2/compiler/source_authority.dag +++ b/src/v2/compiler/source_authority.dag @@ -25,7 +25,7 @@ import v2.extdeps.languages.dag { import v2.std.compilers.lexing { TokenStream } import v2.std.provenance { span_index_empty } import std.algebra { Empty, FreeMonoid, list_snoc_item } -import v2.std.algebra { HeadAbsent, HeadFound, fold_list, length, list_head, list_reverse, skip } +import v2.std.algebra { HeadAbsent, HeadFound, fold_list, list_head, skip } import v2.std.artifact { Artifact, NodeArtifactProvenance, SourceFile } import v2.std.diagnostic { Accepted, @@ -491,23 +491,18 @@ type SourceRootArgumentAdmission = SourceRootArgumentAdmitted { tree: SourceRootRef } | SourceRootArgumentUnrecognized { argument: String } -fn source_root_argument_trim(argument: String) -> String { - if argument.ends_with(suffix: "/") && (length(xs: argument) > 1) { - source_root_argument_trim( - argument: list_reverse(xs: skip(xs: list_reverse(xs: argument), n: 1)) - ) - } else if starts_with(s: argument, prefix: "./") { - source_root_argument_trim(argument: skip(xs: argument, n: 2)) - } else { - argument - } -} - fn admit_source_root_argument(argument: String) -> SourceRootArgumentAdmission { - let a = source_root_argument_trim(argument: argument) - if (a == "src/v2") || a.ends_with(suffix: "/src/v2") { + if (argument == "src/v2") + || (argument == "./src/v2") + || (argument == "src/v2/") + || argument.ends_with(suffix: "/src/v2") + || argument.ends_with(suffix: "/src/v2/") { SourceRootArgumentAdmitted { tree: V2Tree } - } else if (a == "dag") || a.ends_with(suffix: "/dag") { + } else if (argument == "dag") + || (argument == "./dag") + || (argument == "dag/") + || argument.ends_with(suffix: "/dag") + || argument.ends_with(suffix: "/dag/") { SourceRootArgumentAdmitted { tree: DagTree } } else { SourceRootArgumentUnrecognized { argument: argument } From 7f6dbbef119dffcabbffbe4157f6829174d49755 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 16:18:32 +0000 Subject: [PATCH 04/13] Point the native-CLI door control at a dag-named source root. Tree identity is admitted from the --source-root argument; fixtures/native_cli_door is not that tree. Co-authored-by: Cursor --- fixtures/native_cli_door/{ => dag}/door_probe.dag | 5 +++-- src/v1/stage0/src/cli_run/native_lane_runner.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) rename fixtures/native_cli_door/{ => dag}/door_probe.dag (94%) diff --git a/fixtures/native_cli_door/door_probe.dag b/fixtures/native_cli_door/dag/door_probe.dag similarity index 94% rename from fixtures/native_cli_door/door_probe.dag rename to fixtures/native_cli_door/dag/door_probe.dag index c441246f4f7..7c20b4831c5 100644 --- a/fixtures/native_cli_door/door_probe.dag +++ b/fixtures/native_cli_door/dag/door_probe.dag @@ -7,7 +7,7 @@ module fixture.native_cli_door.door_probe // walked through, which DESIGN section 5 names as specification-without-execution: a green that // establishes the closure typechecks and nothing about whether the program runs. This file is the // argv the built binary is handed so that it does run: `emit --entry -// fixture.native_cli_door.door_probe --source-root fixtures/native_cli_door`. +// fixture.native_cli_door.door_probe --source-root fixtures/native_cli_door/dag`. // // IT HAS NO IMPORTS, for the same reason `fixture.closure.rustc_green_probe` has none: the // admission's subject resolves against the validated roots the ingest produced, so a module whose @@ -17,7 +17,8 @@ module fixture.native_cli_door.door_probe // // IT IS ITS OWN DIRECTORY AND NOT A FILE IN AN EXISTING FIXTURE ROOT, because the CLI's source // root is walked RECURSIVELY for every `.dag` file under it; sharing a directory would make the -// control's ingest a function of what some other fixture's author adds next to it. +// control's ingest a function of what some other fixture's author adds next to it. The walk +// argument is the dag tree (`.../dag`), not a parent of mixed trees. // // THE DECLARATION'S NAME AND VALUE ARE WHAT THE CONTROL READS. v2 lowers this `data` declaration to // a named member whose body is the literal, and the door renders it through the Rust target's diff --git a/src/v1/stage0/src/cli_run/native_lane_runner.rs b/src/v1/stage0/src/cli_run/native_lane_runner.rs index 65fe432ead9..5e1c42f2949 100644 --- a/src/v1/stage0/src/cli_run/native_lane_runner.rs +++ b/src/v1/stage0/src/cli_run/native_lane_runner.rs @@ -101,7 +101,7 @@ const MALFORMED_MATERIALIZED_PATH: &str = "target/v2-native-lane/malformed-contr /// the text not Rust (gunbc.recurring_failure_mode closure_emit_renders_an_arrow_without_its_body). /// So an exit 0 now has to carry the declaration's NAME and its VALUE in text a Rust compiler /// ACCEPTS; anything less is that class returning, not an emission. -const WELL_FORMED_CONTROL_ROOT: &str = "fixtures/native_cli_door"; +const WELL_FORMED_CONTROL_ROOT: &str = "fixtures/native_cli_door/dag"; const CLI_DOOR_ENTRY_MODULE: &str = "fixture.native_cli_door.door_probe"; const CLI_DOOR_EMITTED_WITNESS: &str = "native_cli_door_probe_value"; const CLI_DOOR_EMITTED_VALUE: &str = "606060"; From 8f4bae3e1960add6bac5ec71273ccffcd9c89d9f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 16:40:17 +0000 Subject: [PATCH 05/13] Enroll native-ingest layout fixtures on the built CLI door. The claims still supply ingest at v2_cli_run; deleting a fixture root now fails the instrument walk that actually executes those trees. Co-authored-by: Cursor --- .../stage0/src/cli_run/native_lane_runner.rs | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/src/v1/stage0/src/cli_run/native_lane_runner.rs b/src/v1/stage0/src/cli_run/native_lane_runner.rs index 5e1c42f2949..35b06830981 100644 --- a/src/v1/stage0/src/cli_run/native_lane_runner.rs +++ b/src/v1/stage0/src/cli_run/native_lane_runner.rs @@ -102,6 +102,11 @@ const MALFORMED_MATERIALIZED_PATH: &str = "target/v2-native-lane/malformed-contr /// So an exit 0 now has to carry the declaration's NAME and its VALUE in text a Rust compiler /// ACCEPTS; anything less is that class returning, not an emission. const WELL_FORMED_CONTROL_ROOT: &str = "fixtures/native_cli_door/dag"; +const NATIVE_INGEST_COPIED_SINGLE_ROOT: &str = "fixtures/native_ingest_copied_single_root"; +const NATIVE_INGEST_SRC_IN_DAG_ROOT: &str = "fixtures/native_ingest_src_in_dag/dag"; +const NATIVE_INGEST_TWO_ROOTS_DAG: &str = "fixtures/native_ingest_two_roots/dag"; +const NATIVE_INGEST_TWO_ROOTS_V2: &str = "fixtures/native_ingest_two_roots/src/v2"; +const NATIVE_INGEST_DUPLICATE_MODULE_ROOT: &str = "fixtures/native_ingest_duplicate_module/dag"; const CLI_DOOR_ENTRY_MODULE: &str = "fixture.native_cli_door.door_probe"; const CLI_DOOR_EMITTED_WITNESS: &str = "native_cli_door_probe_value"; const CLI_DOOR_EMITTED_VALUE: &str = "606060"; @@ -2402,11 +2407,124 @@ fn walk_cli_door( } } eprintln!("v2-native-cli: filesystem controls refused absent root and unreadable source with typed, located causes"); + walk_native_ingest_layout_controls(binary, workspace)?; let refusal_status = i64::from(refused.status.unwrap_or_default()); eprintln!("v2-native-cli: door refused as cli_no_entry — exit {refusal_status}"); Ok((door_exit_status, emitted_bytes, refusal_status)) } +/// THE LAYOUT REDS THE PARENT ASKED THE NATIVE DOOR TO EXECUTE. Claims over `v2_cli_run` supply +/// ingest at that fold; these walks are the inhabitance that the discovering --source-root, not +/// the file spelling, tags the tree — deleting any of the four fixture roots makes this control +/// fail. +fn walk_native_ingest_layout_controls(binary: &Path, workspace: &Path) -> Result<(), String> { + let copied = workspace.join(NATIVE_INGEST_COPIED_SINGLE_ROOT); + let src_in_dag = workspace.join(NATIVE_INGEST_SRC_IN_DAG_ROOT); + let two_dag = workspace.join(NATIVE_INGEST_TWO_ROOTS_DAG); + let two_v2 = workspace.join(NATIVE_INGEST_TWO_ROOTS_V2); + let dup = workspace.join(NATIVE_INGEST_DUPLICATE_MODULE_ROOT); + for (label, path) in [ + ("copied-single-root", copied.as_path()), + ("src-in-dag", src_in_dag.as_path()), + ("two-roots-dag", two_dag.as_path()), + ("two-roots-v2", two_v2.as_path()), + ("duplicate-module", dup.as_path()), + ] { + if !path.is_dir() { + return Err(format!( + "V2-NATIVE REFUSAL cause=NativeIngestLayoutRootAbsent — {label} {} is not a directory", + path.display() + )); + } + } + + let copied_obs = run_cli_door( + binary, + &[ + "emit".into(), + "--entry".into(), + "fixture.native_ingest.copied_dag".into(), + "--source-root".into(), + copied.display().to_string(), + ], + )?; + if copied_obs.status != Some(CLI_DOOR_USAGE_REFUSAL_EXIT) + || !copied_obs.stdout.is_empty() + || !copied_obs + .stderr + .contains("source root is not a dag or src/v2 tree") + || !copied_obs.stderr.contains(&copied.display().to_string()) + { + return Err(format!( + "V2-NATIVE REFUSAL cause=NativeIngestCopiedRootNotUnrecognized — status={:?} stderr={}", + copied_obs.status, + copied_obs.stderr.trim() + )); + } + + let src_obs = run_cli_door( + binary, + &[ + "emit".into(), + "--entry".into(), + "fixture.native_ingest.src_in_dag".into(), + "--source-root".into(), + src_in_dag.display().to_string(), + ], + )?; + if src_obs.status != Some(0) || src_obs.stdout.is_empty() { + return Err(format!( + "V2-NATIVE REFUSAL cause=NativeIngestSrcInDagPathMisclassified — status={:?} stderr={}", + src_obs.status, + src_obs.stderr.trim() + )); + } + + let two_obs = run_cli_door( + binary, + &[ + "emit".into(), + "--entry".into(), + "fixture.native_ingest.dag_entry".into(), + "--source-root".into(), + two_dag.display().to_string(), + "--source-root".into(), + two_v2.display().to_string(), + ], + )?; + if two_obs.status != Some(0) || two_obs.stdout.is_empty() { + return Err(format!( + "V2-NATIVE REFUSAL cause=NativeIngestTwoRootsDidNotEmit — status={:?} stderr={}", + two_obs.status, + two_obs.stderr.trim() + )); + } + + let dup_obs = run_cli_door( + binary, + &[ + "emit".into(), + "--entry".into(), + "fixture.native_ingest.collision".into(), + "--source-root".into(), + dup.display().to_string(), + ], + )?; + if dup_obs.status != Some(CLI_DOOR_REFUSAL_EXIT) + || !dup_obs.stderr.contains("closure_census_duplicate_module") + || !dup_obs.stderr.contains("collision_a.dag") + || !dup_obs.stderr.contains("collision_b.dag") + { + return Err(format!( + "V2-NATIVE REFUSAL cause=NativeIngestDuplicateDidNotNameBothFiles — status={:?} stderr={}", + dup_obs.status, + dup_obs.stderr.trim() + )); + } + eprintln!("v2-native-cli: native-ingest layout controls held (unrecognized copied root, /src/ under dag, two roots, both-files duplicate)"); + Ok(()) +} + /// THE GENERATION-ONE EXECUTABLE OUTLIVES THE RUN, because generation two is that executable /// emitting `v2.compiler.compile` and nothing else may stand in for it. The probe root is NOT /// retained: once the executable is copied out and its copy re-hashes to the identity the run From 88a8dbada31a3d1bf42d9b9e4d45fd1219f51a22 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 16:42:08 +0000 Subject: [PATCH 06/13] Finish the walk-origin cutover: repoint the remaining walk consumer and refuse undeclared lens roots. source_reference_repoint now stamps origin on SourceRootWalkTask and reads SourceRootWalkedPath.path. The module-graph lens matches each declared file to a pool root and admits that argument; it no longer defaults unknown paths to DagTree. Co-authored-by: Cursor --- .../instruments/source_reference_repoint.dag | 12 ++- src/v2/lens/module_graph.dag | 91 ++++++++++++++----- 2 files changed, 77 insertions(+), 26 deletions(-) diff --git a/dag/gunbc/instruments/source_reference_repoint.dag b/dag/gunbc/instruments/source_reference_repoint.dag index 14a83e11708..e2226440d77 100644 --- a/dag/gunbc/instruments/source_reference_repoint.dag +++ b/dag/gunbc/instruments/source_reference_repoint.dag @@ -348,7 +348,7 @@ fn repoint_pending_verdict(pending: List) -> ProcessExit { } fn repoint_root_tasks() -> List { - source_reference_repoint_roots |> map(path => SourceRootWalkTask { path: path, root: true }) + source_reference_repoint_roots |> map(path => SourceRootWalkTask { path: path, root: true, origin: path }) } // The wet entry: rewrite every file under the roots that still references a moved module. @@ -357,10 +357,10 @@ fn repoint() -> ProcessExit { SourceRootPathsRefused { path: path, kind: kind, cause: cause } => exit_failure(reason: join(["source reference repoint: cannot walk ", path, " (", kind, "): ", cause], "")) SourceRootPathsRead { paths: paths } => - fold(paths, init: ExitSuccess, f: fn(acc, path) { + fold(paths, init: ExitSuccess, f: fn(acc, walked) { match acc { ExitFailure { code, reason } => ExitFailure { code: code, reason: reason } - ExitSuccess => repoint_one_path(path: path) + ExitSuccess => repoint_one_path(path: walked.path) } }) } @@ -372,6 +372,10 @@ fn repoint_pending() -> ProcessExit { SourceRootPathsRefused { path: path, kind: kind, cause: cause } => exit_failure(reason: join(["source reference repoint: cannot walk ", path, " (", kind, "): ", cause], "")) SourceRootPathsRead { paths: paths } => - repoint_pending_verdict(pending: paths |> filter(path => repoint_path_is_pending(path: path))) + repoint_pending_verdict( + pending: paths + |> filter(walked => repoint_path_is_pending(path: walked.path)) + |> map(walked => walked.path) + ) } } diff --git a/src/v2/lens/module_graph.dag b/src/v2/lens/module_graph.dag index f76d713f2fb..c248d560195 100644 --- a/src/v2/lens/module_graph.dag +++ b/src/v2/lens/module_graph.dag @@ -56,10 +56,12 @@ import v2.compiler.resolution_provenance { } import v2.compiler.source_authority { SourceRef, + SourceRootArgumentAdmitted, + SourceRootArgumentUnrecognized, SourceRootIngest, + admit_source_root_argument, source_ref_for_storage_path } -import v2.std.cross_tree.import_model { DagTree, SourceRootRef, V2Tree } import v2.compiler.source_authority_read { source_root_ingest_from_source_refs } import v2.compiler.symbol_index_fill { symbol_index_fill_module_root } import v2.extdeps.languages.dag { @@ -273,25 +275,64 @@ fn reference_derived_path_under_roots(path: String, roots: List) -> Bool any(xs: roots, predicate: fn(root) { starts_with(s: path, prefix: concat(root, "/")) }) } -fn declared_module_source_root(path: String) -> SourceRootRef { - if starts_with(s: path, prefix: "src/v2") { - V2Tree - } else { - DagTree - } +fn discovering_pool_root(path: String, pool_roots: List) -> Optional { + fold_list( + xs: pool_roots, + empty: Absent, + cons: fn(acc, root) { + match acc { + Present { value: found } => Present { value: found } + Absent => + if (path == root) || starts_with(s: path, prefix: concat(root, "/")) { + Present { value: root } + } else { + Absent + } + } + } + ) } -fn source_refs_from_declared(declared: List) -> List { +fn source_refs_from_declared( + declared: List, + pool_roots: List +) -> Outcome> { fold_list( xs: declared, - empty: no_source_refs, + empty: outcome_accepted(value: no_source_refs), cons: fn(acc, fact) { - list_snoc_item( - xs: acc, - item: source_ref_for_storage_path( - path: fact.path, - source_root: declared_module_source_root(path: fact.path) - ) + bind_outcome( + o: acc, + f: fn(refs) { + match discovering_pool_root(path: fact.path, pool_roots: pool_roots) { + Absent => + outcome_rejected( + d: Diagnostic { + reason: ^declared_module_pool_root_unknown, + at: Textual { file: ^declared_module_pool_root_unknown, extent: WholeFile }, + correction: Unavailable { reason: ExternalContractUnknown } + } + ) + Present { value: origin } => + match admit_source_root_argument(argument: origin) { + SourceRootArgumentAdmitted { tree: tree } => + outcome_accepted( + value: list_snoc_item( + xs: refs, + item: source_ref_for_storage_path(path: fact.path, source_root: tree) + ) + ) + SourceRootArgumentUnrecognized { argument: _ } => + outcome_rejected( + d: Diagnostic { + reason: ^declared_module_source_root_undetermined, + at: Textual { file: ^declared_module_source_root_undetermined, extent: WholeFile }, + correction: Unavailable { reason: ExternalContractUnknown } + } + ) + } + } + } ) } ) @@ -390,15 +431,21 @@ fn edges_from_provenance_owners( } fn load_reference_derived_pool( - declared: List + declared: List, + pool_roots: List ) -> Outcome { bind_outcome( - o: source_root_ingest_from_source_refs(refs: source_refs_from_declared(declared: declared)), - f: fn(ingest) { + o: source_refs_from_declared(declared: declared, pool_roots: pool_roots), + f: fn(refs) { bind_outcome( - o: located_roots_from_source_root_ingest(ingest: ingest), - f: fn(items) { - outcome_accepted(value: reference_derived_pool_from_located_roots(items: items)) + o: source_root_ingest_from_source_refs(refs: refs), + f: fn(ingest) { + bind_outcome( + o: located_roots_from_source_root_ingest(ingest: ingest), + f: fn(items) { + outcome_accepted(value: reference_derived_pool_from_located_roots(items: items)) + } + ) } ) } @@ -614,7 +661,7 @@ fn reference_derived_resolution_facts( let declared = module_declaration_facts_live(pool_roots: pool_roots) |> filter(fact => !reference_derived_path_excluded(path: fact.path, exclude_substrings: exclude_substrings)) bind_outcome( - o: load_reference_derived_pool(declared: declared), + o: load_reference_derived_pool(declared: declared, pool_roots: pool_roots), f: fn(pool) { bind_outcome( o: fold_list( From 27e3a950f6d0e7e9d0f52163d6d717b3bcacab08 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 16:43:03 +0000 Subject: [PATCH 07/13] Locate the ingest-build-impossible diagnostic by path, with no invented tree tag. The sentinel is not a walked source; source_ref_read_failed_diagnostic only needed the path for its locus. Co-authored-by: Cursor --- src/v2/compiler/source_authority_read.dag | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/v2/compiler/source_authority_read.dag b/src/v2/compiler/source_authority_read.dag index eb667914b60..4a4b6adda13 100644 --- a/src/v2/compiler/source_authority_read.dag +++ b/src/v2/compiler/source_authority_read.dag @@ -15,10 +15,9 @@ import std.content_hash { import v2.compiler.source_authority { DagSourceReadWitness, SourceRef, - SourceRootIngest, - source_ref_for_storage_path + SourceRootIngest } -import v2.std.cross_tree.import_model { DagTree, SourceRootRef } +import v2.std.cross_tree.import_model { SourceRootRef } import extdeps.communication.medium { Lossless, Medium } import v2.std.algebra { fold_list } import v2.std.artifact { Artifact, SourceFile } @@ -79,11 +78,11 @@ data source_ref_read_refused: Symbol = ^source_ref_read_refused data source_ref_content_hash_mismatch: Symbol = ^source_ref_content_hash_mismatch -fn source_ref_read_failed_diagnostic(ref: SourceRef, error: String) -> NonEmptyDiagnostics { +fn source_ref_read_failed_diagnostic(path: String, error: String) -> NonEmptyDiagnostics { NonEmptyDiagnostics { head: Diagnostic { reason: source_ref_read_refused, - at: textual_whole_file_locus(file: symbol_intern_lexeme(lexeme: ref.path)), + at: textual_whole_file_locus(file: symbol_intern_lexeme(lexeme: path)), correction: Unavailable { reason: ExternalContractUnknown } }, tail: [ @@ -184,7 +183,7 @@ fn source_ref_read_result_to_outcome(result: SourceRefReadResult) -> Outcome Rejected { - diagnostics: source_ref_read_failed_diagnostic(ref: ref, error: error) + diagnostics: source_ref_read_failed_diagnostic(path: ref.path, error: error) } SourceRefReadHashMismatch { ref: ref, expected: _, observed: observed } => Rejected { @@ -244,7 +243,7 @@ fn source_root_ingest_from_source_refs(refs: List) -> Outcome Rejected { diagnostics: source_ref_read_failed_diagnostic( - ref: source_ref_for_storage_path(path: "source-root-ingest-build-impossible", source_root: DagTree), + path: "source-root-ingest-build-impossible", error: "internal: read-through accepted without ingest row" ) } From ac38757eb991f80f951b93bd026dd7322876a2b4 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 16:44:03 +0000 Subject: [PATCH 08/13] Search the ingest once for a duplicate module path. The Bool scan could only be true when a first declaring file existed, so the one-file fallback was unreachable from the census step. Co-authored-by: Cursor --- .../compiler/self_host/closure_emission.dag | 56 ++++++++----------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/src/v2/compiler/self_host/closure_emission.dag b/src/v2/compiler/self_host/closure_emission.dag index 9b0922d154d..519c7bf46dd 100644 --- a/src/v2/compiler/self_host/closure_emission.dag +++ b/src/v2/compiler/self_host/closure_emission.dag @@ -219,23 +219,23 @@ fn closure_ingest_step( bind_outcome( o: qualified_name_from_module_node(root: census.root), f: fn(module_qn) { - if closure_ingest_declares(files: acc.files, member_module: module_qn) { - closure_census_duplicate_module_outcome( - files: acc.files, - member_module: module_qn, - second_root: census.root - ) - } else { - outcome_accepted(value: ClosureIngest { - files: list_snoc_item(xs: acc.files, item: ClosureIngestFile { - module: module_qn, - parse_tree: artifact.tree, - census: census, - source_root: read.source_root - }), - index: source_root_index_insert(index: acc.index, module: module_qn, root: read.source_root), - alloc: artifact.alloc - }) + match closure_ingest_first_declaring(files: acc.files, member_module: module_qn) { + Present { value: first } => + closure_census_duplicate_module_outcome( + first: first, + second_root: census.root + ) + Absent => + outcome_accepted(value: ClosureIngest { + files: list_snoc_item(xs: acc.files, item: ClosureIngestFile { + module: module_qn, + parse_tree: artifact.tree, + census: census, + source_root: read.source_root + }), + index: source_root_index_insert(index: acc.index, module: module_qn, root: read.source_root), + alloc: artifact.alloc + }) } } ) @@ -311,10 +311,6 @@ fn closure_census_index(files: FreeMonoid) -> SymbolIndex { // would refuse a duplicate too (resolve_duplicate_module_name), but each member is resolved in a // context holding only itself, so that wall cannot fire here; the census is where the whole // population is in view, so the wall lives there (review of gunbc#12218 at 242b7af). -fn closure_ingest_declares(files: FreeMonoid, member_module: QualifiedName) -> Bool { - fold_list(xs: files, empty: false, cons: fn(found, f) { found || f.module == member_module }) -} - fn closure_ingest_first_declaring( files: FreeMonoid, member_module: QualifiedName @@ -343,20 +339,14 @@ fn closure_census_duplicate_module_diagnostics(first: Node, second: Node) -> Non } fn closure_census_duplicate_module_outcome( - files: FreeMonoid, - member_module: QualifiedName, + first: ClosureIngestFile, second_root: Node ) -> Outcome { - match closure_ingest_first_declaring(files: files, member_module: member_module) { - Present { value: first } => - Rejected { - diagnostics: closure_census_duplicate_module_diagnostics( - first: first.census.root, - second: second_root - ) - } - Absent => - outcome_rejected(d: closure_emission_diagnostic(reason: ^closure_census_duplicate_module, at: second_root)) + Rejected { + diagnostics: closure_census_duplicate_module_diagnostics( + first: first.census.root, + second: second_root + ) } } From 98cc185e14cb53d2ea48ba8c562d2a21a95f1511 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 17:27:19 +0000 Subject: [PATCH 09/13] Materialize the poison census control under a dag-named source root. The eval-driver ingest now admits tree identity from the --source-root argument, so a scratch directory that is not dag or src/v2 exited 2 before tokenize could refuse the specimen. Co-authored-by: Cursor --- src/v1/stage0/src/cli_run/native_lane_runner.rs | 5 +++-- src/v2/test/v2_native_route_test.dag | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/v1/stage0/src/cli_run/native_lane_runner.rs b/src/v1/stage0/src/cli_run/native_lane_runner.rs index 35b06830981..13b0a15f811 100644 --- a/src/v1/stage0/src/cli_run/native_lane_runner.rs +++ b/src/v1/stage0/src/cli_run/native_lane_runner.rs @@ -80,8 +80,9 @@ const MALFORMED_SPECIMEN_COMMITTED: &str = "fixtures/native_lane_malformed/poiso /// workspace-relative like every path this harness hands the binary (its working directory is /// the workspace root). The receipt records the observed refusal path; the admission authority /// requires it non-empty, and this harness requires it to name the materialized specimen. -const MALFORMED_CONTROL_ROOT: &str = "target/v2-native-lane/malformed-control-root"; -const MALFORMED_MATERIALIZED_PATH: &str = "target/v2-native-lane/malformed-control-root/poison.dag"; +const MALFORMED_CONTROL_ROOT: &str = "target/v2-native-lane/malformed-control-root/dag"; +const MALFORMED_MATERIALIZED_PATH: &str = + "target/v2-native-lane/malformed-control-root/dag/poison.dag"; /// THE TWO DOORS' CONTROL INPUTS, AS THE THREE FACTS THEIR ARGV IS BUILT FROM. /// diff --git a/src/v2/test/v2_native_route_test.dag b/src/v2/test/v2_native_route_test.dag index 62282253d3f..40548a2613c 100644 --- a/src/v2/test/v2_native_route_test.dag +++ b/src/v2/test/v2_native_route_test.dag @@ -190,7 +190,7 @@ fn receipt_over( false_control: Present { value: NativeTestReturnedFalse }, true_control: Present { value: NativeTestPassed }, malformed_control: MalformedSpecimenRefused { - path: "target/v2-native-lane/malformed-control-root/poison.dag", + path: "target/v2-native-lane/malformed-control-root/dag/poison.dag", reason: ^tokenize_lex_e1_unterminated_string }, old_route_control: OldRouteWithdrawn { withdrawn_executable: "/seed/gunbc" }, From 4351844d76d62b2547b1986f8dad6c642ae674d7 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 18:14:37 +0000 Subject: [PATCH 10/13] Parse discovering_pool_root as nested Optional arms. An if whose condition used || after a parenthesized equality was typed as String vs Optional, so the floor refused module_graph. Co-authored-by: Cursor --- src/v2/lens/module_graph.dag | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/v2/lens/module_graph.dag b/src/v2/lens/module_graph.dag index c248d560195..81cff13087b 100644 --- a/src/v2/lens/module_graph.dag +++ b/src/v2/lens/module_graph.dag @@ -283,10 +283,14 @@ fn discovering_pool_root(path: String, pool_roots: List) -> Optional Present { value: found } Absent => - if (path == root) || starts_with(s: path, prefix: concat(root, "/")) { + if path == root { Present { value: root } } else { - Absent + if starts_with(s: path, prefix: concat(root, "/")) { + Present { value: root } + } else { + Absent + } } } } From 07d5f294ff6526d6e73d437795e2c6e872174e43 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 18:28:23 +0000 Subject: [PATCH 11/13] Account walk_native_ingest_layout_controls on the eval-driver seed-growth row. Ctrl asked for a checkable hand-Rust receipt; the walk extends walk_cli_door and dissolves with that row's existing v1-hand-queue-drain trigger. Co-authored-by: Cursor --- dag/gunbc/source_root_eval_driver_seed_growth.dag | 4 ++-- src/v1/stage0/src/cli_run/native_lane_runner.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dag/gunbc/source_root_eval_driver_seed_growth.dag b/dag/gunbc/source_root_eval_driver_seed_growth.dag index 242e50d7054..adb3873defc 100644 --- a/dag/gunbc/source_root_eval_driver_seed_growth.dag +++ b/dag/gunbc/source_root_eval_driver_seed_growth.dag @@ -21,7 +21,7 @@ data source_root_eval_driver_seed_growth_justification: SeedGrowthJustification } ], - reason: "FILESYSTEM PORTION REMOVED: gunbc.source_root_read owns traversal and typed read refusal through the existing Filesystem service, and v2.compiler.source_authority source_root_ingest_from_files constructs witnesses. emit_host_source_root_read_rs now only binds that handler and transports its outcome. NativeCliDriver calls v2_cli_main once; the eval driver still retains the other obligations below, so this row does not retire. walk_cli_door additionally executes missing-root and unreadable-source controls against the built CLI, requiring exit 2, empty stdout, and a located acquisition cause. The historical enumeration follows; its filesystem traversal and byte-read portion is superseded by this statement. One hand-authored declaration renders the SourceRootEvalDriver's main.rs as target-language text: roughly 500 lines of Rust spelled as string literals inside a .dag concat, not emitter logic over Nodes. It is a single declaration by the citable count and one program by the real one, and the gap between those two numbers is the point of this row. WHAT IS IRREDUCIBLY HOST here: argv, the source-root walk and byte reads, the monotonic and wall clocks, the /proc memory reading, stdout and stderr, and the process exit status. Nothing in .dag can perform those, and the driver exists to own exactly that boundary (std.compiler_entry SourceRootEvalDriver). WHAT IS EXPRESSIBLE IN .dag AND STILL RETAINED, each waiting on a named capability rather than on effort: the host-facts TSV decode (read_host_facts, host_fact, host_fact_int), which needs the ingest direction of the one grammar to produce NativeLaneHostFacts from bytes; the [native-cost-partition] JSON rendering, whose ROW SET and reconcile verdict are already a .dag authority this main calls (std.compiler_entry NativeDriverExclusiveRows, native_driver_cost_account) so that only the rendering is retained; and the THREE-mode orchestration (run_census, run_census_resolve, run_adjudication: phase order, refusal arms, terminal marker), which needs a .dag driver that can receive host effects as values. The third mode was added by the whole-tree census-resolve cut, and it is named here rather than left to be discovered because this row's reason is the standing enumeration of what is retained: a mode that is not in it is hand-authored Rust no row accounts for. What that cut did NOT do is grow the hand-authored DECISION surface -- the roster, the per-module verdict and the occurrence-grain rows are v2.compiler.compile folds (native_census_modules, native_census_module_resolution, native_census_residual_rows), and the mode is the same loop-and-print shape the other two already are, so the retained program grew by an orchestration arm and not by a second place where resolution is decided. WHAT THE INSTRUMENT HARNESS ADDS, ENUMERATED HERE BECAUSE THIS ROW'S OWN STANDARD DEMANDS IT (2026-09-21, review 69637). The sentence above says this reason is the standing enumeration of what is retained and that a mode absent from it is hand-authored Rust no row accounts for. v1_compiler.cli_run.native_lane_runner gained roughly 560 lines that were not enumerated: walk_eval_driver_door and walk_cli_door (the two instruments' entrypoint-execution controls), run_cli_door (a spawn whose stdout contract is the CLI driver's, not the eval driver's, so it cannot share run_native_binary), adjudicate_cli_emit_probe with cli_refusal_determining_reason and CliEmitProbeVerdict (the emit probe's closed partition over a termination plus a rendered refusal), cli_door_member_arm and CliDoorMemberArm (gunbc#12218: the probe reads the fixture member's arm out of the door's ClosureEmission carrier, so the emitted text it judges is that member's and never stdout as a whole; decoding is host-side because the carrier arrives as a spawned process's stdout, and it moves with the adjudication the day a .dag driver receives a process termination as a value), and a #[cfg(test)] module carrying their discriminating controls. gunbc#12207 added one more, emitted_text_compiles_as_rust: the emit probe's exit-0 arm now requires the door's text to name the fixture's declaration, carry its value and be accepted by the build's own rustc, and that last test is a spawn of the compiler over the emitted text -- host effect, the same kind as the door spawns, handed to the pure adjudication as a function so the partition stays a fold over values. ALL OF IT IS HOST EFFECT OR ADJUDICATION OVER ONE: spawning a built binary, reading its termination. It sits under the same reachability limit this row already states -- the required floor's hermetic envelope refuses host effects, so a .dag witness whose subject is a subprocess termination is counted executed while its assertion never runs. WHAT OF IT IS EXPRESSIBLE IN .dag AND STILL RETAINED, named rather than left implicit: the emit probe's ADJUDICATION is a pure fold over a status and two strings and wants no host at all -- it is written in Rust only because its inputs are produced by a spawn on this side of the boundary, and it moves the day a .dag driver can receive a process termination as a value, which is the same capability this row's trigger already names. The SPAWNS are irreducibly host. THE ENUMERATION IS THE POINT: a later reader counting retained Rust against this row will now find these, and a mode added beside them without a row entry is the defect this sentence exists to make visible. WHAT THE NATIVE FRONTIER RATCHET ADDS (2026-09-23), ENUMERATED ON THE SAME STANDARD. In the rendered adjudicate main: one call to gunbc.native_frontier_ratchet native_frontier_verdict beside native_route_admission, its word on the terminal marker, and two stderr loops printing native_frontier_report_lines and native_frontier_proposal_file_lines. It is orchestration and printing only: the verdict, the lines and the proposed roster file are .dag folds. In the host harness (v1_compiler.cli_run.native_lane_runner): the marker's `frontier` field, required on an adjudicate marker, and run_v2_native_frontier, which carries that word out. In v1_compiler.target_invocation_host: the V2NativeFrontier producer arm, a closed match of the word to a termination. THE LIVE PROGRAM RETIRING IT is the one this row already names, v2.cli.compile_cli's NativeCliDriver: the rendered main becomes one call into a .dag fold that receives host effects as values. At that point the frontier print loops and the marker field go with the rest of the orchestration, and nothing here needs a separate trigger. + reason: "FILESYSTEM PORTION REMOVED: gunbc.source_root_read owns traversal and typed read refusal through the existing Filesystem service, and v2.compiler.source_authority source_root_ingest_from_files constructs witnesses. emit_host_source_root_read_rs now only binds that handler and transports its outcome. NativeCliDriver calls v2_cli_main once; the eval driver still retains the other obligations below, so this row does not retire. walk_cli_door additionally executes missing-root and unreadable-source controls against the built CLI, requiring exit 2, empty stdout, and a located acquisition cause. The historical enumeration follows; its filesystem traversal and byte-read portion is superseded by this statement. One hand-authored declaration renders the SourceRootEvalDriver's main.rs as target-language text: roughly 500 lines of Rust spelled as string literals inside a .dag concat, not emitter logic over Nodes. It is a single declaration by the citable count and one program by the real one, and the gap between those two numbers is the point of this row. WHAT IS IRREDUCIBLY HOST here: argv, the source-root walk and byte reads, the monotonic and wall clocks, the /proc memory reading, stdout and stderr, and the process exit status. Nothing in .dag can perform those, and the driver exists to own exactly that boundary (std.compiler_entry SourceRootEvalDriver). WHAT IS EXPRESSIBLE IN .dag AND STILL RETAINED, each waiting on a named capability rather than on effort: the host-facts TSV decode (read_host_facts, host_fact, host_fact_int), which needs the ingest direction of the one grammar to produce NativeLaneHostFacts from bytes; the [native-cost-partition] JSON rendering, whose ROW SET and reconcile verdict are already a .dag authority this main calls (std.compiler_entry NativeDriverExclusiveRows, native_driver_cost_account) so that only the rendering is retained; and the THREE-mode orchestration (run_census, run_census_resolve, run_adjudication: phase order, refusal arms, terminal marker), which needs a .dag driver that can receive host effects as values. The third mode was added by the whole-tree census-resolve cut, and it is named here rather than left to be discovered because this row's reason is the standing enumeration of what is retained: a mode that is not in it is hand-authored Rust no row accounts for. What that cut did NOT do is grow the hand-authored DECISION surface -- the roster, the per-module verdict and the occurrence-grain rows are v2.compiler.compile folds (native_census_modules, native_census_module_resolution, native_census_residual_rows), and the mode is the same loop-and-print shape the other two already are, so the retained program grew by an orchestration arm and not by a second place where resolution is decided. WHAT THE INSTRUMENT HARNESS ADDS, ENUMERATED HERE BECAUSE THIS ROW'S OWN STANDARD DEMANDS IT (2026-09-21, review 69637). The sentence above says this reason is the standing enumeration of what is retained and that a mode absent from it is hand-authored Rust no row accounts for. v1_compiler.cli_run.native_lane_runner gained roughly 560 lines that were not enumerated: walk_eval_driver_door and walk_cli_door (the two instruments' entrypoint-execution controls), run_cli_door (a spawn whose stdout contract is the CLI driver's, not the eval driver's, so it cannot share run_native_binary), adjudicate_cli_emit_probe with cli_refusal_determining_reason and CliEmitProbeVerdict (the emit probe's closed partition over a termination plus a rendered refusal), cli_door_member_arm and CliDoorMemberArm (gunbc#12218: the probe reads the fixture member's arm out of the door's ClosureEmission carrier, so the emitted text it judges is that member's and never stdout as a whole; decoding is host-side because the carrier arrives as a spawned process's stdout, and it moves with the adjudication the day a .dag driver receives a process termination as a value), and a #[cfg(test)] module carrying their discriminating controls. gunbc#13590 added walk_native_ingest_layout_controls on that same walk_cli_door instrument: four inhabitance spawns of the built CLI over discovering --source-root layout fixtures (unrecognized copied root, /src/ under a dag root, two admitted roots, duplicate module naming both files). Same host kind as walk_cli_door — spawn and read termination — so it is enumerated here rather than a second SeedGrowthJustification. gunbc#12207 added one more, emitted_text_compiles_as_rust: the emit probe's exit-0 arm now requires the door's text to name the fixture's declaration, carry its value and be accepted by the build's own rustc, and that last test is a spawn of the compiler over the emitted text -- host effect, the same kind as the door spawns, handed to the pure adjudication as a function so the partition stays a fold over values. ALL OF IT IS HOST EFFECT OR ADJUDICATION OVER ONE: spawning a built binary, reading its termination. It sits under the same reachability limit this row already states -- the required floor's hermetic envelope refuses host effects, so a .dag witness whose subject is a subprocess termination is counted executed while its assertion never runs. WHAT OF IT IS EXPRESSIBLE IN .dag AND STILL RETAINED, named rather than left implicit: the emit probe's ADJUDICATION is a pure fold over a status and two strings and wants no host at all -- it is written in Rust only because its inputs are produced by a spawn on this side of the boundary, and it moves the day a .dag driver can receive a process termination as a value, which is the same capability this row's trigger already names. The SPAWNS are irreducibly host. THE ENUMERATION IS THE POINT: a later reader counting retained Rust against this row will now find these, and a mode added beside them without a row entry is the defect this sentence exists to make visible. WHAT THE NATIVE FRONTIER RATCHET ADDS (2026-09-23), ENUMERATED ON THE SAME STANDARD. In the rendered adjudicate main: one call to gunbc.native_frontier_ratchet native_frontier_verdict beside native_route_admission, its word on the terminal marker, and two stderr loops printing native_frontier_report_lines and native_frontier_proposal_file_lines. It is orchestration and printing only: the verdict, the lines and the proposed roster file are .dag folds. In the host harness (v1_compiler.cli_run.native_lane_runner): the marker's `frontier` field, required on an adjudicate marker, and run_v2_native_frontier, which carries that word out. In v1_compiler.target_invocation_host: the V2NativeFrontier producer arm, a closed match of the word to a termination. THE LIVE PROGRAM RETIRING IT is the one this row already names, v2.cli.compile_cli's NativeCliDriver: the rendered main becomes one call into a .dag fold that receives host effects as values. At that point the frontier print loops and the marker field go with the rest of the orchestration, and nothing here needs a separate trigger. THE NET SEED MOTION OF THE CHANGE THAT ADDS THIS IS FAVOURABLE AND IS NOT AN EXCUSE: src/v1/stage0/src/cli_run/native_lane_runner.rs loses about 859 lines as the universe derivation, the fan-out and the admission move into the emitted compiler, and both v1-interpreter brackets are deleted at the root rather than retained as a fallback. A shrinking neighbour does not discharge this declaration; it only means the lane is moving the right way while this piece has not moved yet.", @@ -29,5 +29,5 @@ THE NET SEED MOTION OF THE CHANGE THAT ADDS THIS IS FAVOURABLE AND IS NOT AN EXC trigger: "Delete this rendered main when a .dag driver function can receive the host operations above AS VALUES — argv, the walked and read source roots, the two clocks, the /proc reading, the two output sinks and the exit status — so that the rendered main becomes one call into that fold and the phase order, the refusal arms and the terminal marker are decided in .dag. That is the capability, and it retires the whole row. WHAT DOES NOT RETIRE IT, named because each is the tempting smaller artifact: migrating the TSV decode alone, which leaves the orchestration hand-authored; rendering the cost row from .dag alone, which is already half-done since the row set and the verdict are a .dag authority and only the JSON rendering is retained; and shrinking the template by moving Rust text into a second emitter helper, which relocates the hand-authored program without reducing it.", - current_boundary: "v1.compiler.emit_rust emit_source_root_eval_driver_main_rs -> the rendered main.rs of the emitted closure crate -> claim_executor --v2-native-route (v1_compiler.cli_run.native_lane_runner run_required_v2_native), which spawns that binary in census and adjudicate modes; and gunbc test //gunbc/instruments:self-host (v1_compiler.cli_run.native_lane_runner walk_eval_driver_door), which spawns it twice in census mode as that instrument's accepting and refusing controls; v1_compiler.cli_run.native_lane_runner walk_cli_door, run_cli_door, adjudicate_cli_emit_probe, cli_refusal_determining_reason, cli_door_member_arm and emitted_text_compiles_as_rust, the instrument-side harness enumerated in this row's reason" + current_boundary: "v1.compiler.emit_rust emit_source_root_eval_driver_main_rs -> the rendered main.rs of the emitted closure crate -> claim_executor --v2-native-route (v1_compiler.cli_run.native_lane_runner run_required_v2_native), which spawns that binary in census and adjudicate modes; and gunbc test //gunbc/instruments:self-host (v1_compiler.cli_run.native_lane_runner walk_eval_driver_door), which spawns it twice in census mode as that instrument's accepting and refusing controls; v1_compiler.cli_run.native_lane_runner walk_cli_door, walk_native_ingest_layout_controls, run_cli_door, adjudicate_cli_emit_probe, cli_refusal_determining_reason, cli_door_member_arm and emitted_text_compiles_as_rust, the instrument-side harness enumerated in this row's reason" } diff --git a/src/v1/stage0/src/cli_run/native_lane_runner.rs b/src/v1/stage0/src/cli_run/native_lane_runner.rs index 13b0a15f811..1d8dd3ef7fb 100644 --- a/src/v1/stage0/src/cli_run/native_lane_runner.rs +++ b/src/v1/stage0/src/cli_run/native_lane_runner.rs @@ -2418,6 +2418,11 @@ fn walk_cli_door( /// ingest at that fold; these walks are the inhabitance that the discovering --source-root, not /// the file spelling, tags the tree — deleting any of the four fixture roots makes this control /// fail. +/// +/// SEED DELTA (ctrl hand-Rust receipt): extend `walk_cli_door`; no new production route and no +/// deleted scaffold. Accounted on `gunbc.source_root_eval_driver_seed_growth` +/// `source_root_eval_driver_seed_growth_justification` (lane `v1-hand-queue-drain`). Net seed is +/// this inhabitance walk over existing `run_cli_door`. fn walk_native_ingest_layout_controls(binary: &Path, workspace: &Path) -> Result<(), String> { let copied = workspace.join(NATIVE_INGEST_COPIED_SINGLE_ROOT); let src_in_dag = workspace.join(NATIVE_INGEST_SRC_IN_DAG_ROOT); From 780a9840229e7df547acfb6866f0b20e72d46838 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 19:47:17 +0000 Subject: [PATCH 12/13] Build discovering_pool_root from a Bool match, not nested if. The inner if still typed Present as String versus Absent as Optional, so the floor kept refusing module_graph. Co-authored-by: Cursor --- src/v2/lens/module_graph.dag | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/v2/lens/module_graph.dag b/src/v2/lens/module_graph.dag index 81cff13087b..3d22044a5a3 100644 --- a/src/v2/lens/module_graph.dag +++ b/src/v2/lens/module_graph.dag @@ -275,6 +275,10 @@ fn reference_derived_path_under_roots(path: String, roots: List) -> Bool any(xs: roots, predicate: fn(root) { starts_with(s: path, prefix: concat(root, "/")) }) } +fn path_is_under_pool_root(path: String, root: String) -> Bool { + path == root || starts_with(s: path, prefix: concat(root, "/")) +} + fn discovering_pool_root(path: String, pool_roots: List) -> Optional { fold_list( xs: pool_roots, @@ -282,16 +286,10 @@ fn discovering_pool_root(path: String, pool_roots: List) -> Optional Present { value: found } - Absent => - if path == root { - Present { value: root } - } else { - if starts_with(s: path, prefix: concat(root, "/")) { - Present { value: root } - } else { - Absent - } - } + Absent => match path_is_under_pool_root(path: path, root: root) { + true => Present { value: root } + false => Absent + } } } ) From 323bf36d98bb71c244ec12e73ac3a3bba515eb02 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Thu, 8 Oct 2026 21:02:13 +0000 Subject: [PATCH 13/13] Drop the CLI emit claims that re-ran census over the new-witness budget. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Duplicate-module both-files already lives at the census fold; two-root and collision inhabitance is walk_native_ingest_layout_controls. Each v2_cli_run enrolment was 150k–634k eval steps against a 72k ceiling. Co-authored-by: Cursor --- src/v2/test/claim/cli/v2_native_cli_test.dag | 95 +------------------- 1 file changed, 1 insertion(+), 94 deletions(-) diff --git a/src/v2/test/claim/cli/v2_native_cli_test.dag b/src/v2/test/claim/cli/v2_native_cli_test.dag index 5b4f339f3dc..d0818b9f6a7 100644 --- a/src/v2/test/claim/cli/v2_native_cli_test.dag +++ b/src/v2/test/claim/cli/v2_native_cli_test.dag @@ -30,7 +30,7 @@ import v2.compiler.source_authority { DagSourceReadWitness, SourceRootIngest } import v2.std.algebra { length, list_head, HeadAbsent, HeadFound } import v2.std.artifact { Artifact, SourceFile } import extdeps.communication.medium { Lossless, Medium } -import v2.std.cross_tree.import_model { DagTree, SourceRootRef, V2Tree } +import v2.std.cross_tree.import_model { DagTree } import v2.std.node { Symbol } import v2.std.qualified_name { qualified_name_from_dotted_string } import v2.std.text { String } @@ -479,96 +479,3 @@ test fn a_trailing_token_refusal_locates_its_fatal_in_the_file_holds() -> Bool { CliDifferentialReported { text: _, observed: _, detail: _ } => false } } - -data cli_dup_a_source: String = "module fixture.native_ingest.collision\n\ndata cli_dup_a_value: Int = 1\n" - -data cli_dup_b_source: String = "module fixture.native_ingest.collision\n\ndata cli_dup_b_value: Int = 2\n" - -data cli_dup_ingest: SourceRootIngest = [ - cli_probe_read(source: cli_dup_a_source, id: ^cli_dup_a_artifact, unit: ^cli_dup_a_cu, path: "dag/collision_a.dag"), - cli_probe_read(source: cli_dup_b_source, id: ^cli_dup_b_artifact, unit: ^cli_dup_b_cu, path: "dag/collision_b.dag") -] - -data argv_emit_collision: FreeMonoid = Cons { - head: "emit", - tail: Cons { - head: "--entry", - tail: Cons { - head: "fixture.native_ingest.collision", - tail: Cons { head: "--source-root", tail: Cons { head: "dag", tail: Empty } } - } - } -} - -fn cli_dup_outcome() -> CliRunOutcome { - v2_cli_run( - plan: v2_cli_parse(argv: argv_of(items: argv_emit_collision)), - ingest: cli_dup_ingest - ) -} - -test fn two_files_declaring_one_module_refuse_as_a_census_collision_holds() -> Bool { - match cli_dup_outcome() { - CliCensusRefused { reason: reason, detail: detail, text: _ } => - reason == ^closure_census_duplicate_module - && string_contains(s: detail, pattern: "cli_dup_a_cu") - && string_contains(s: detail, pattern: "cli_dup_b_cu") - CliRunRefused { reason: reason, detail: detail } => - reason == ^closure_census_duplicate_module - && string_contains(s: detail, pattern: "cli_dup_a_cu") - && string_contains(s: detail, pattern: "cli_dup_b_cu") - CliUsageRefused { reason: _, detail: _ } => false - CliEmitted { text: _, closure_size: _, refused_count: _, refusal_detail: _ } => false - CliDifferentialReported { text: _, observed: _, detail: _ } => false - } -} - -fn cli_distinct_read( - source: String, - id: Symbol, - unit: Symbol, - path: String, - root: SourceRootRef -) -> DagSourceReadWitness { - DagSourceReadWitness { - source: Medium { carried: source, fidelity: Lossless }, - artifact: Artifact { kind: SourceFile, id: id, file_path: path }, - compilation_unit: unit, - source_root: root - } -} - -data cli_distinct_dag_source: String = "module fixture.native_ingest.dag_entry\n\ndata native_ingest_dag_entry_value: Int = 1\n" - -data cli_distinct_v2_source: String = "module fixture.native_ingest.v2_other\n\ndata native_ingest_v2_other_value: Int = 2\n" - -data cli_distinct_ingest: SourceRootIngest = [ - cli_distinct_read(source: cli_distinct_dag_source, id: ^cli_distinct_dag_artifact, unit: ^cli_distinct_dag_cu, path: "dag/native_ingest_dag_entry.dag", root: DagTree), - cli_distinct_read(source: cli_distinct_v2_source, id: ^cli_distinct_v2_artifact, unit: ^cli_distinct_v2_cu, path: "src/v2/native_ingest_v2_other.dag", root: V2Tree) -] - -data argv_emit_distinct: FreeMonoid = Cons { - head: "emit", - tail: Cons { - head: "--entry", - tail: Cons { - head: "fixture.native_ingest.dag_entry", - tail: Cons { head: "--source-root", tail: Cons { head: "dag", tail: Empty } } - } - } -} - -test fn distinct_module_paths_across_two_roots_do_not_refuse_as_a_collision_holds() -> Bool { - match v2_cli_run( - plan: v2_cli_parse(argv: argv_of(items: argv_emit_distinct)), - ingest: cli_distinct_ingest - ) { - CliCensusRefused { reason: reason, detail: _, text: _ } => - reason != ^closure_census_duplicate_module - CliRunRefused { reason: reason, detail: _ } => - reason != ^closure_census_duplicate_module - CliUsageRefused { reason: _, detail: _ } => false - CliEmitted { text: _, closure_size: _, refused_count: _, refusal_detail: _ } => true - CliDifferentialReported { text: _, observed: _, detail: _ } => false - } -}