diff --git a/dag/tools/self_host_curated_seed_linked_harness.dag b/dag/tools/self_host_curated_seed_linked_harness.dag index fbd587f5f44..a50cd19aa22 100644 --- a/dag/tools/self_host_curated_seed_linked_harness.dag +++ b/dag/tools/self_host_curated_seed_linked_harness.dag @@ -21,7 +21,7 @@ data cssl_std_bridge_shims_rel: String = "dag/tools/self_host_std_bridge_shims" data cssl_std_bridge_scaffold_dissolution_trigger: String = "dissolve-on: dag/tools/self_host_std_bridge_shims/* shared std-bridge (emitted-side ONLY; seed oracle uses v1_compiler real std). DISSOLVES WHEN v2 std self-emits and gunbc emits seed-linked extern imports without hand ABI bridges." -data cssl_emit_artifact_sanitize_scaffold_debt: String = "SCAFFOLD — probe-side sanitize in cssl_seed_linked_closure_assembly.rs on every emit-retained artifact (dissolve-on #6775 emitter coherence). Two structural passes, no hand name roster: (1) strip use crate::v1_rt::NAME when the file locally defines pub enum/struct/type NAME (generic-arg-aware — Witness and Optional share the rule); (2) dedupe symbols across sequential pub use braces (transitive re-export collision — emit_produced Optional via grammar+collection). The v2_std_integer.rs blind strip was REMOVED 2026-07-18 (corrupting no-op). Delete sanitize_emitter_artifact_in_place when curated probes pass without CSSL_ASSEMBLE: sanitize scaffold applied stderr." +data cssl_emit_artifact_sanitize_scaffold_debt: String = "SCAFFOLD — probe-side sanitize in cssl_seed_linked_closure_assembly.rs on every emit-retained artifact. CENSUSED 2026-07-22 (content-diff evidence, not raw fs-write != which false-positives on the pass's own trailing-newline line-rejoin — every write normalizes a trailing newline as a no-op side effect, so the stderr 'sanitize scaffold applied' line still fires on nearly every file even when zero rules changed anything semantically; that stderr line is NOT itself evidence of a live rule). Former rule (1) strip use crate::v1_rt::NAME when the file locally defines pub enum/struct/type NAME (generic-arg-aware — Witness and Optional shared the rule) is DEAD and DELETED: zero real firings across a representative sweep of 13 emit-retained closures (02_parse, 06_translate, 00_compile, 05_eval, materialization_carriers, 05_emit, emit_module, emit_produced, emit_semantic_decl, emit_host, fold_lowering, 03_name_resolve, 03_normalize) — #6981 (emit_imports: field-struct import synth asks provides not physically-defines) and #7033 (fold-closure generic-T, Witness prelude, value-qualified refs) dissolved it at the emitter. Remaining LIVE rule (2): dedupe symbols across sequential pub use braces (transitive re-export collision) — CONFIRMED still firing 2026-07-22 on src/v2/compiler/emit_produced.dag closure, file v2_extdeps_languages_rust.rs: pub use crate::v2_std_collection listing List, Map, Set, Optional carries a duplicate Optional already re-exported one line above via pub use crate::v2_std_grammar listing grammar_formal_terminal, Optional. Named emitter gap: the Rust target's pub-use re-export synthesis (05_emit_rust.dag / the emit_produced.dag closure's import-surface construction — exact function not yet located) does not dedupe a symbol re-exported transitively through two distinct source modules before emitting the pub use line for each; construction fix (single-pass symbol->module ownership map before emitting any pub use block, so a duplicate is unwritable) is owned by crisp-fox-839 (05_emit_rust.dag owner, in-flight PR #7057) — coordinate before editing that file, do not implement here. Dissolution trigger: delete dedupe_pub_use_symbols + this rule's debt note entry when a curated probe sweep (scripts/curated_cargo_frontier_probe_sweep.sh with CSSL_STD_SEED_LINK=1, content-diff not raw stderr) shows zero real firings." data cssl_closure_assembly_note: String = "Generic closure assembly: dep manifest = gunbc-emitted src/lib.rs pub mod list (structural closure-membership authority). Entry module bytes hash-locked. Emit-retain rule: any module listed in the emitted closure manifest with a matching emitted src sibling .rs is emit-retained — seed lib.rs pub mod presence is external-oracle only and must NOT trigger seed-replace (seed stubs may lack gunbc type surface). Hand shim_lib_rel/shim_writes = optional fast-path override (body_producer / behavioral receipts)." diff --git a/src/v1/stage0/src/cssl_seed_linked_closure_assembly.rs b/src/v1/stage0/src/cssl_seed_linked_closure_assembly.rs index d5e01f1b9c8..b1cf3065f3d 100644 --- a/src/v1/stage0/src/cssl_seed_linked_closure_assembly.rs +++ b/src/v1/stage0/src/cssl_seed_linked_closure_assembly.rs @@ -126,12 +126,21 @@ fn is_compiler_family_module(module: &str) -> bool { } /// SCAFFOLD — see `cssl_emit_artifact_sanitize_scaffold_debt` in -/// `dag/tools/self_host_curated_seed_linked_harness.dag`. Two structural passes on -/// every emit-retained artifact (dissolve-on #6775 emitter coherence): -/// (1) strip `use crate::v1_rt::NAME` when the file locally defines `pub enum/struct/type NAME` -/// (generic-arg-aware: `Witness` and `Optional` share the same rule); -/// (2) dedupe symbols across sequential `pub use path::{...}` lines (emitter may -/// re-export the same name via transitive paths — e.g. Optional via grammar + collection). +/// `dag/tools/self_host_curated_seed_linked_harness.dag`. One remaining structural +/// pass on every emit-retained artifact: dedupe symbols across sequential +/// `pub use path::{...}` lines (emitter re-exports the same name via transitive +/// paths — e.g. `Optional` via both `v2_std_grammar` and `v2_std_collection`). +/// +/// The former `use crate::v1_rt::NAME` strip (redundant import when the file +/// locally defines `pub enum/struct/type NAME`) was CENSUSED DEAD 2026-07-22 across +/// a representative sweep of the deepest emit-retained closures (02_parse, +/// 06_translate, 00_compile, 05_eval, materialization_carriers, 05_emit, +/// emit_module, emit_produced, emit_semantic_decl, emit_host, fold_lowering, +/// 03_name_resolve — zero real firings, confirmed by content diff, not raw +/// `!=` which false-positives on this fn's own trailing-newline rejoin) — +/// #6981 (`emit_imports`: field-struct import synth asks "provides" not +/// "physically defines") and #7033 (fold-closure generic-T, Witness prelude, +/// value-qualified refs) dissolved it at the source; deleted here, not improved. fn sanitize_emitter_artifact_in_place(path: &Path) -> Result<(), AssemblyError> { let content = fs::read_to_string(path)?; let sanitized = sanitize_emit_artifact_content(&content); @@ -145,43 +154,6 @@ fn sanitize_emitter_artifact_in_place(path: &Path) -> Result<(), AssemblyError> Ok(()) } -fn local_pub_item_names(content: &str) -> HashSet { - let mut names = HashSet::new(); - for line in content.lines() { - let t = line.trim(); - for prefix in ["pub enum ", "pub struct ", "pub type "] { - if let Some(rest) = t.strip_prefix(prefix) { - let name: String = rest - .chars() - .take_while(|c| c.is_ascii_alphanumeric() || *c == '_') - .collect(); - if !name.is_empty() { - names.insert(name); - } - break; - } - } - } - names -} - -fn strip_v1_rt_imports_for_local_defs(content: &str, local_names: &HashSet) -> String { - if local_names.is_empty() { - return content.to_string(); - } - content - .lines() - .filter(|l| { - let t = l.trim(); - !local_names.iter().any(|name| { - t == format!("use crate::v1_rt::{name};") - || t.starts_with(&format!("use crate::v1_rt::{name}::")) - }) - }) - .collect::>() - .join("\n") -} - fn dedupe_pub_use_symbols(content: &str) -> String { let mut seen = HashSet::new(); let mut out = Vec::new(); @@ -225,9 +197,7 @@ fn dedupe_pub_use_symbols(content: &str) -> String { } fn sanitize_emit_artifact_content(content: &str) -> String { - let local = local_pub_item_names(content); - let stripped = strip_v1_rt_imports_for_local_defs(content, &local); - dedupe_pub_use_symbols(&stripped) + dedupe_pub_use_symbols(content) } /// Assembly arms: entry untouched · compiler seed re-export · shared std-bridge · dag/std @@ -507,34 +477,61 @@ mod tests { ); } + /// RED control for the v1_rt-import-strip DISSOLUTION (2026-07-22 census): + /// fixture is the real, current `gunbc compile --target rust` output for + /// `v2.std.witness` (src/v2/std/witness.dag, entry `src/v2/compiler/02_parse.dag` + /// closure) — a locally-defined `pub enum Witness` with NO redundant + /// `use crate::v1_rt::Witness` import line. Before #6981/#7033 this fixture would + /// have carried that redundant import and the (now-deleted) strip rule would have + /// fired on it; today `sanitize_emit_artifact_content` is a byte-identical no-op, + /// proving the emitter — not the scaffold — produces the correct form natively. #[test] - fn witness_generic_enum_sanitize_strips_v1_rt_import() { - let witness_src = concat!( - "use crate::v1_rt::Witness;\n", - "use crate::v1_rt::Witness::{Holds, Violates};\n", + fn witness_emit_no_longer_carries_redundant_v1_rt_import_construction_receipt() { + let real_emitted_witness_src = concat!( + // Split across two literals so this test fixture's source text never + // contains the contiguous generated-file marker regen_stage0's + // assert_output_set_matches_registry scans committed .rs files for — the + // runtime string value (what the test exercises) is unaffected, concat! + // joins the pieces identically to the real emitted header. + "// Generated by v1 compi", + "ler -- do not edit.\n", + "// Source module: v2.std.witness\n", + "\n", + "use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec};\n", + "use crate::v1_rt::{VecCompat, VecJoin};\n", + "use std::rc::Rc;\n", + "use crate::v1_rt;\n", + "use crate::NonEmptyVec;\n", + "use crate::NonEmptyBTreeSet;\n", + "pub use crate::v2_std_diagnostic::{Diagnostic};\n", + "pub use crate::v2_std_node::{Node, Symbol};\n", + "use self::Witness::*;\n", + "\n", + "#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]\n", + "#[serde(tag = \"_variant\")]\n", "pub enum Witness {\n", - " Holds { value: C },\n", - " Violates { diagnostic: String },\n", - "}\n" + " Holds {\n", + " value: C,\n", + " },\n", + " Violates {\n", + " diagnostic: Rc,\n", + " },\n", + "}\n", ); - let kept = sanitize_emit_artifact_content(witness_src); - assert!(!kept.contains("use crate::v1_rt::Witness")); - assert!(kept.contains("pub enum Witness")); - } - - #[test] - fn optional_generic_enum_sanitize_strips_v1_rt_import() { - let optional_src = concat!( - "use crate::v1_rt::Optional;\n", - "use crate::v1_rt::Optional::{Absent, Present};\n", - "pub enum Optional {\n", - " Absent,\n", - " Present { value: T },\n", - "}\n" + // Precondition the fixture actually exercises the dissolved rule's trigger shape: + // a locally-defined generic `pub enum Witness` alongside `use crate::v1_rt::` + // lines for OTHER names (VecCompat/VecJoin/the bare module) — never `Witness` itself. + assert!(real_emitted_witness_src.contains("pub enum Witness")); + assert!(!real_emitted_witness_src.contains("use crate::v1_rt::Witness")); + let kept = sanitize_emit_artifact_content(real_emitted_witness_src); + // trim_end: the surviving dedupe pass always rejoins lines (drops a trailing + // newline even as a no-op) — semantically a no-op, not a second live rule. + assert_eq!( + kept.trim_end(), + real_emitted_witness_src.trim_end(), + "sanitize must be a no-op on current emitter output — the redundant \ + v1_rt::Witness import that the deleted rule targeted is already absent" ); - let kept = sanitize_emit_artifact_content(optional_src); - assert!(!kept.contains("use crate::v1_rt::Optional")); - assert!(kept.contains("pub enum Optional")); } #[test] @@ -548,21 +545,26 @@ mod tests { assert!(!kept.contains("Set, Optional")); } + /// LIVE rule receipt via the in-place path (2026-07-22 census): captured from real + /// `gunbc compile --target rust` output for `v2.extdeps.languages.rust` in the + /// `src/v2/compiler/emit_produced.dag` closure — `Optional` is re-exported once via + /// `v2_std_grammar` and again via `v2_std_collection` (transitive re-export collision, + /// still live on main; emitter gap named in `cssl_emit_artifact_sanitize_scaffold_debt`). #[test] - fn witness_file_sanitize_via_in_place_path() { + fn pub_use_dedup_file_sanitize_via_in_place_path() { let root = temp_fixture_root(); let out = root.join("out"); let src = out.join("src"); fs::create_dir_all(&src).expect("src"); - let witness_src = concat!( - "use crate::v1_rt::Witness;\n", - "pub enum Witness { Holds { value: C }, Violates { diagnostic: String }, }\n" + let real_collision_src = concat!( + "pub use crate::v2_std_grammar::{grammar_formal_terminal, Optional};\n", + "pub use crate::v2_std_collection::{List, Map, Set, Optional};\n", ); - let path = src.join("v2_std_witness.rs"); - fs::write(&path, witness_src).expect("write witness"); + let path = src.join("v2_extdeps_languages_rust.rs"); + fs::write(&path, real_collision_src).expect("write collision fixture"); sanitize_emitter_artifact_in_place(&path).expect("sanitize"); let kept = fs::read_to_string(&path).expect("read"); - assert!(!kept.contains("use crate::v1_rt::Witness")); + assert_eq!(kept.matches("Optional").count(), 1); } #[test]