Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions dag/gunbc/namespace/namespace_cut_subject_roster.dag
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ fn subject_probes(s: NamespaceCutSubjectIdentity) -> NamespaceCutSubjectProbes {
}
ImportDerivedUseLineInputs => NamespaceCutSubjectProbes {
first: DagDeclarationProbe { module_path: "v1.compiler.emit_rust", decl_name: "emit_imports" },
rest: [
DagDeclarationProbe { module_path: "v1.compiler.emit_rust", decl_name: "emit_extract_import_paths_fn" },
],
rest: [],
}
LegacyImportRepairApparatus => NamespaceCutSubjectProbes {
first: HostRustItemProbe { crate_relative_file: "src/v1/stage0/src/cli_run.rs", item_name: "classify_unlisted_import_binding_source" },
Expand Down
2 changes: 1 addition & 1 deletion docs/plans/namespace-cut-replacement-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Standing census on the branch (2026-08-15, dated record): **5,531 hard diagnosti
## Step 2 — host and emit machinery

- `src/v1/stage0/src/cli_run.rs` (**frozen file — surgical trims, never deletion**): `extract_import_paths` (the starts-with-import text scanner every host import fact builds on), `resolve_virtual_source_with_imports`, `source_declares_import_lines`, `import_module_paths_for_typed_module`, `emit_import_admission_list`; the closure-walk family (`build_import_adjacency`, `import_closure_from_adjacency`/`_from_facts`/`_live_paths`/`_live_paths_with_facts`, `reference_only_direct_import_paths`, `entry_file_touched_via_import_closure`, `import_closure_module_reaches_carrier_home`, `collect_import_closure_module_names_from_facts`, `roster_import_closure_nodes_pre_resolve`, `import_closure_files_from_graph`, `touched_file_in_import_closure`, `import_closure_repo_paths_for_entry`, `augment_closure_modules_from_import_facts`, `import_closure_dag_files`); the `declared_import_closure_*` compile family incl. `compile_entry_on_declared_import_closure_only` and `observe_declared_import_closure_symbol_binding`; the unlisted-import census family (`classify_unlisted_import_binding_source`, `compile_clean_unlisted_import_census`, `compile_clean_unlisted_import_use_blocks_from_policy`/`_cached`); the class-b import-closure gates
- `src/v1/05_emit_rust.dag` (+ twin `v1_compiler_emit_rust.rs`): `emit_imports`, `emit_extract_import_paths_fn` — **this one prints the import scanner into generated stage0; cut it in the same pass or the seed regrows it on regen** — `augment_scoped_data_item_index_with_imports`, `module_imports_std_serialization_coproduct_wire_contract`, `record_lit_resolved_ctor_import_names`, `emit_specific_import_block`, `explicit_import_source_module_for_name`, `import_variant_parent_for_name`, `wildcard_import_pool_surface_names`, `import_module_enum_scope`
- `src/v1/05_emit_rust.dag` (+ twin `v1_compiler_emit_rust.rs`): `emit_imports` — `emit_extract_import_paths_fn` was deleted (generated main already routes compile through `cli_run::compile_emission`; the stamp had no caller) — `augment_scoped_data_item_index_with_imports`, `module_imports_std_serialization_coproduct_wire_contract`, `record_lit_resolved_ctor_import_names`, `emit_specific_import_block`, `explicit_import_source_module_for_name`, `import_variant_parent_for_name`, `wildcard_import_pool_surface_names`, `import_module_enum_scope`
- Whole-file deletions: `dag/gunbc/instruments/namespace_import_closure_behavioral_transport.dag` (its own dissolution trigger names this cut) · `dag/gunbc/class_b_import_closure_overlay.dag` · `dag/gunbc/declared_import_closure_binding.dag` · `dag/gunbc/instruments/dag_compile_clean_cli_floor_agreement.dag` · `dag/std/import.dag` (empty stub) · `src/v2/test/claim/long/dag_import_block_lexeme_stamp_test.dag` · `dag/test/claim/module_graph_edge_source_witness_test.dag`
- Partial deletions: `dag/gunbc/compile_clean_diagnostic_policy.dag` (only the `UnlistedImportUse` enforcement declarations + dissolve rows) · `dag/gunbc/instruments/diagnostics_witness_transport.dag` (`diagnostics_import_resolution_suite`, `run_diagnostics_import_resolution_witness`)

Expand Down
61 changes: 0 additions & 61 deletions src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -20253,9 +20253,7 @@ fn emit_main_pipeline_fns(crate_name: String, pipeline_module: String) -> String
concat(
emit_collect_dag_files_fn(),
emit_extract_module_path_fn(),
emit_extract_import_paths_fn(),
emit_dep_pool_type_and_fns(),
emit_resolve_transitively_fn(crate_name: crate_name, pipeline_mod: pipeline_mod),
emit_compile_target_helpers(crate_name: crate_name, pipeline_mod: pipeline_mod, artifact_mod: artifact_mod))
}

Expand Down Expand Up @@ -20377,25 +20375,6 @@ fn emit_extract_module_path_fn() -> String {
"}\n\n")
}

fn emit_extract_import_paths_fn() -> String {
concat(
"/// Extract import module paths from a .dag file's import declarations.\n",
"fn extract_import_paths(content: &str) -> Vec<String> {\n",
" let mut imports = Vec::new();\n",
" for line in content.lines() {\n",
" let trimmed = line.trim();\n",
" if trimmed.starts_with(\"import \") {\n",
" let rest = trimmed[\"import \".len()..].trim();\n",
" let module_path = rest.split('{').next().unwrap_or(rest).trim();\n",
" if !module_path.is_empty() {\n",
" imports.push(module_path.to_string());\n",
" }\n",
" }\n",
" }\n",
" imports\n",
"}\n\n")
}

fn emit_dep_pool_type_and_fns() -> String {
concat(
"#[derive(Clone, Copy, PartialEq, Eq)]\nenum DependencyPoolIndex {\n Strict,\n PrimaryPrecedence,\n}\n\n",
Expand Down Expand Up @@ -20468,46 +20447,6 @@ fn emit_dep_pool_type_and_fns() -> String {
"}\n\n")
}

fn emit_resolve_transitively_fn(crate_name: String, pipeline_mod: String) -> String {
concat(
"/// Resolve imports transitively from entry modules.\n",
"/// Fail-closed: panics on unreadable imported files.\n",
"/// Returns sources sorted by path for deterministic fixed-point convergence.\n",
"fn resolve_transitively_with_seen(\n",
" entry_sources: Vec<(String, String)>,\n",
" index: &HashMap<String, std::path::PathBuf>,\n",
" mut seen: HashMap<String, Rc<", crate_name, "::", pipeline_mod, "::SourceFile>>,\n",
") -> Vec<Rc<", crate_name, "::", pipeline_mod, "::SourceFile>> {\n",
" let mut queue: Vec<(String, String)> = entry_sources;\n",
"\n",
" while let Some((_path, content)) = queue.pop() {\n",
" let imports = extract_import_paths(&content);\n",
" for module_path in imports {\n",
" if seen.contains_key(&module_path) {\n",
" continue;\n",
" }\n",
" if let Some(file_path) = index.get(&module_path) {\n",
" let file_content = std::fs::read_to_string(file_path)\n",
" .unwrap_or_else(|e| panic!(\"failed to read imported module '{}' at {:?}: {}\",\n",
" module_path, file_path, e));\n",
" let rel_path = file_path.to_string_lossy().to_string();\n",
" let source = Rc::new(", crate_name, "::", pipeline_mod, "::SourceFile {\n",
" path: rel_path.clone(),\n",
" content: file_content.clone(),\n",
" });\n",
" seen.insert(module_path, source);\n",
" queue.push((rel_path, file_content));\n",
" }\n",
" // If not found in index, the compiler's resolve stage will report the error.\n",
" }\n",
" }\n",
"\n",
" let mut result: Vec<_> = seen.into_iter().map(|(_, v)| v).collect();\n",
" result.sort_by(|a, b| a.path.cmp(&b.path));\n",
" result\n",
"}\n\n")
}

fn emit_main_diagnostic_fns(crate_name: String) -> String {
let core_mod = module_to_filename(name: "v1.std.core")
concat(
Expand Down
18 changes: 2 additions & 16 deletions src/v1/stage0/src/v1_compiler_emit_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42203,14 +42203,8 @@ pub fn emit_main_pipeline_fns(crate_name: String, pipeline_module: String) -> St
crate::gunbc_rust_emitted_edge::module_to_filename("v1.compiler.artifact".to_string());
v1_rt::concat(
v1_rt::concat(
v1_rt::concat(
v1_rt::concat(
v1_rt::concat(emit_collect_dag_files_fn(), emit_extract_module_path_fn()),
emit_extract_import_paths_fn(),
),
emit_dep_pool_type_and_fns(),
),
emit_resolve_transitively_fn(crate_name.clone(), pipeline_mod.clone()),
v1_rt::concat(emit_collect_dag_files_fn(), emit_extract_module_path_fn()),
emit_dep_pool_type_and_fns(),
),
emit_compile_target_helpers(
crate_name.clone(),
Expand All @@ -42237,18 +42231,10 @@ pub fn emit_extract_module_path_fn() -> 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("/// Extract the `module x.y.z` declaration from a .dag file's first lines.\n".to_string(), "fn extract_module_path(content: &str) -> Option<String> {\n".to_string()), " for line in content.lines() {\n".to_string()), " let trimmed = line.trim();\n".to_string()), " if trimmed.starts_with(\"module \") {\n".to_string()), " return Some(trimmed[\"module \".len()..].trim().to_string());\n".to_string()), " }\n".to_string()), " if !trimmed.is_empty() && !trimmed.starts_with(\"//\") {\n".to_string()), " break;\n".to_string()), " }\n".to_string()), " }\n".to_string()), " None\n".to_string()), "}\n\n".to_string())
}

pub fn emit_extract_import_paths_fn() -> 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("/// Extract import module paths from a .dag file's import declarations.\n".to_string(), "fn extract_import_paths(content: &str) -> Vec<String> {\n".to_string()), " let mut imports = Vec::new();\n".to_string()), " for line in content.lines() {\n".to_string()), " let trimmed = line.trim();\n".to_string()), " if trimmed.starts_with(\"import \") {\n".to_string()), " let rest = trimmed[\"import \".len()..].trim();\n".to_string()), " let module_path = rest.split('{').next().unwrap_or(rest).trim();\n".to_string()), " if !module_path.is_empty() {\n".to_string()), " imports.push(module_path.to_string());\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " imports\n".to_string()), "}\n\n".to_string())
}

pub fn emit_dep_pool_type_and_fns() -> 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(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(v1_rt::concat(v1_rt::concat(v1_rt::concat("#[derive(Clone, Copy, PartialEq, Eq)]\nenum DependencyPoolIndex {\n Strict,\n PrimaryPrecedence,\n}\n\n".to_string(), "fn parse_dependency_pool_index(value: &str) -> DependencyPoolIndex {\n".to_string()), " match value {\n".to_string()), " \"strict\" => DependencyPoolIndex::Strict,\n".to_string()), " \"primary-precedence\" => DependencyPoolIndex::PrimaryPrecedence,\n".to_string()), " other => {\n".to_string()), " eprintln!(\"unknown --dependency-pool-index: {} (expected strict | primary-precedence)\", other);\n".to_string()), " std::process::exit(1);\n".to_string()), " }\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "fn insert_module_path(\n".to_string()), " index: &mut HashMap<String, std::path::PathBuf>,\n".to_string()), " module_path: String,\n".to_string()), " path: std::path::PathBuf,\n".to_string()), " within_root: &mut HashMap<String, std::path::PathBuf>,\n".to_string()), ") {\n".to_string()), " if let Some(existing) = within_root.get(&module_path) {\n".to_string()), " panic!(\"duplicate module path '{}' within source root: declared in both {:?} and {:?}\", module_path, existing, path);\n".to_string()), " }\n".to_string()), " within_root.insert(module_path.clone(), path.clone());\n".to_string()), " index.insert(module_path, path);\n".to_string()), "}\n\n".to_string()), "fn index_source_root(root: &str, index: &mut HashMap<String, std::path::PathBuf>, pool_fill_only: bool) {\n".to_string()), " let root_path = std::path::Path::new(root);\n".to_string()), " if !root_path.exists() {\n".to_string()), " panic!(\"source root does not exist: {}\", root);\n".to_string()), " }\n".to_string()), " let mut dag_files = Vec::new();\n".to_string()), " collect_dag_files(root_path, &mut dag_files);\n".to_string()), " let mut within_root = HashMap::new();\n".to_string()), " for path in dag_files {\n".to_string()), " let content = std::fs::read_to_string(&path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read {:?}: {}\", path, e));\n".to_string()), " if let Some(module_path) = extract_module_path(&content) {\n".to_string()), " if pool_fill_only {\n".to_string()), " if index.contains_key(&module_path) {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " insert_module_path(index, module_path, path, &mut within_root);\n".to_string()), " } else if let Some(existing) = index.get(&module_path) {\n".to_string()), " panic!(\"duplicate module path '{}': declared in both {:?} and {:?}\", module_path, existing, path);\n".to_string()), " } else {\n".to_string()), " insert_module_path(index, module_path, path, &mut within_root);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), "}\n\n".to_string()), "fn build_module_index(source_roots: &[String], pool_index: DependencyPoolIndex) -> HashMap<String, std::path::PathBuf> {\n".to_string()), " let mut index = HashMap::new();\n".to_string()), " if source_roots.is_empty() {\n".to_string()), " return index;\n".to_string()), " }\n".to_string()), " match pool_index {\n".to_string()), " DependencyPoolIndex::Strict => {\n".to_string()), " for root in source_roots {\n".to_string()), " index_source_root(root, &mut index, false);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " DependencyPoolIndex::PrimaryPrecedence => {\n".to_string()), " index_source_root(&source_roots[0], &mut index, false);\n".to_string()), " for root in &source_roots[1..] {\n".to_string()), " index_source_root(root, &mut index, true);\n".to_string()), " }\n".to_string()), " }\n".to_string()), " }\n".to_string()), " index\n".to_string()), "}\n\n".to_string())
}

pub fn emit_resolve_transitively_fn(crate_name: String, pipeline_mod: 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(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("/// Resolve imports transitively from entry modules.\n".to_string(), "/// Fail-closed: panics on unreadable imported files.\n".to_string()), "/// Returns sources sorted by path for deterministic fixed-point convergence.\n".to_string()), "fn resolve_transitively_with_seen(\n".to_string()), " entry_sources: Vec<(String, String)>,\n".to_string()), " index: &HashMap<String, std::path::PathBuf>,\n".to_string()), " mut seen: HashMap<String, Rc<".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::SourceFile>>,\n".to_string()), ") -> Vec<Rc<".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::SourceFile>> {\n".to_string()), " let mut queue: Vec<(String, String)> = entry_sources;\n".to_string()), "\n".to_string()), " while let Some((_path, content)) = queue.pop() {\n".to_string()), " let imports = extract_import_paths(&content);\n".to_string()), " for module_path in imports {\n".to_string()), " if seen.contains_key(&module_path) {\n".to_string()), " continue;\n".to_string()), " }\n".to_string()), " if let Some(file_path) = index.get(&module_path) {\n".to_string()), " let file_content = std::fs::read_to_string(file_path)\n".to_string()), " .unwrap_or_else(|e| panic!(\"failed to read imported module '{}' at {:?}: {}\",\n".to_string()), " module_path, file_path, e));\n".to_string()), " let rel_path = file_path.to_string_lossy().to_string();\n".to_string()), " let source = Rc::new(".to_string()), crate_name.clone()), "::".to_string()), pipeline_mod.clone()), "::SourceFile {\n".to_string()), " path: rel_path.clone(),\n".to_string()), " content: file_content.clone(),\n".to_string()), " });\n".to_string()), " seen.insert(module_path, source);\n".to_string()), " queue.push((rel_path, file_content));\n".to_string()), " }\n".to_string()), " // If not found in index, the compiler's resolve stage will report the error.\n".to_string()), " }\n".to_string()), " }\n".to_string()), "\n".to_string()), " let mut result: Vec<_> = seen.into_iter().map(|(_, v)| v).collect();\n".to_string()), " result.sort_by(|a, b| a.path.cmp(&b.path));\n".to_string()), " result\n".to_string()), "}\n\n".to_string())
}

pub fn emit_main_diagnostic_fns(crate_name: String) -> String {
{
let core_mod =
Expand Down
Loading