Skip to content
Merged
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
63 changes: 58 additions & 5 deletions INVARIANTS.md

Large diffs are not rendered by default.

38 changes: 33 additions & 5 deletions dsl/gunbc/compiler.dag
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,58 @@ type GeneratedCrate {
data stage0: GeneratedCrate = {
package_name: "v3-compiler",
source_dir: "src/v3/compiler/src",
// SG-0 / stage0: every root-level `source_dir` `*.rs` hand file must appear here so
// `clean_stage0_generated_command` / copy / freshness diffs cannot treat census-listed
// hand paths as generated (INVARIANTS P2; keep in lockstep with
// `EXPECTED_HAND_AUTHORED_NON_TEST` root `src/v3/compiler/src/*.rs` rows).
hand_maintained_src: [
"bootstrap.rs",
"bootstrap_regen_fresh.rs",
"cementing_dispatch.rs",
"complexity_lattice.rs",
"cost_basis_declaration.rs",
"dag.rs",
"diagnostics.rs",
"dimension.rs",
"emit.rs",
"emit_go.rs",
"emit_python.rs",
"emit_rust.rs",
"python_target.rs",
"rust_target.rs",
// PB-1 Item 5: hand-authored `main.rs` shell formatter (not emitted into src/).
"emit_rust_bin_shim.rs",
"emit_rust_roundtrip_fixtures.rs",
"enforced_lens_application.rs",
"gunbc_ci.rs",
"infer.rs",
"int_literal_ranges.rs",
"integration_rs_wiring_scan.rs",
"lens_declaration_apply.rs",
"lens_t_las_carrier.rs",
// R3 gate #6: `lens_testgen.rs` retired — body is this hand-authored include fragment
// (`lens_declaration_apply_body.txt` at crate root, `include!`d from `lib.rs`). Must stay in
// `hand_maintained_src` so stage0 recursive
// (`lens_declaration_apply.rs` `include!`). Must stay in `hand_maintained_src` so stage0 recursive
// freshness diff does not treat it as generated drift (P2 boundary discipline).
"lens_testgen_body.txt",
"lib.rs",
"lower.rs",
"memory_peak_cost.rs",
"omni_shape_b_openapi.rs",
"pb_method_template_projection.rs",
"pipeline_authority.rs",
"post_emit_verifier.rs",
// PB-1 Item 5: host mirror of `dsl/std/process.dag` `ProcessExit` for emitted shells.
"process_exit.rs",
"regen_parse_emit.rs"
"python_target.rs",
"r1c_e_gates.rs",
"r3_fc_lane2_loop_witness.rs",
"r3_gate_87_cementing_regen_runner_suites.rs",
"regen_bootstrap_emit.rs",
"regen_parse_emit.rs",
"regen_parse_tables_emit.rs",
"regen_tokenize.rs",
"rust_target.rs",
"self_host_receipt_p0.rs",
"test_runner.rs",
"wall_clock_ratchet_manifest.rs",
]
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/ci-merge/sg0-pr-body-append.3059.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SG-0 hand-path delta: +17
SG-0 pairing: (b) P5 checkable receipt (INVARIANTS §P5 Dispatch-Discipline (b)): +17 restores honest `EXPECTED_HAND_AUTHORED_*` rows after operator corrective revert; paired deletions vs `origin/main` remove rescinded PB-0 codegen/template scaffolds — rep. `tools/pb0_cycle4_emit_templates/cementing_dispatch.rs.in`, `tools/pb0_cycle4_emit_templates/pipeline_authority.rs.in`, `src/v3/compiler/src/complexity_lattice_generated.rs`, `src/v3/compiler/src/emit_rust_bin_shim_generated.rs` (full `D\t` set in this PR diff). ROADMAP.md **SG-0 PR-window net-shrink discipline** (Director course-correction 2026-05-05) frames the PR-body pairing requirement this line satisfies. Director/operator corrective budget URL:
https://github.com/gunb-ai/gunbc/pull/3059
130 changes: 2 additions & 128 deletions src/v3/compiler/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,112 +436,6 @@ fn emit_r1_gates_fixture(manifest_path: &Path, v3_dir: &Path) {
/// **Hygiene:** `repeat_string` exists in the bootstrap bundle only via this excerpt — no
/// hand-maintained duplicate of `render.dag` (INVARIANTS P2). Edit the marked region in
/// `render.dag` only; this output is overwritten on `cargo build -p v3-compiler`.
/// Emit PB-0 host authority modules (former `EXPECTED_HAND_AUTHORED_NON_TEST` paths) from
/// checked-in templates so `REGEN_OUTPUTS` / `GENERATED_FILES` stay the sole SG-0 partition
/// authority (`sg0_v3_hand_authored_census`).
///
/// **Templates** live under `tools/pb0_cycle4_emit_templates/*.rs.in` (workspace root — not under
/// `src/v3/compiler/`, so they are outside the SG-0 `.rs` walk and not misread as hand-authored
/// compiler sources). **Full substrate dissolution** (`.dag` / lens-producer authority replacing
/// this body) is the separate T-LP-Retirement program; this path is the bounded PB-0 census
/// partition receipt per `docs/briefs/r3-pb0-non-test-retirement-worker.md`.
///
/// **Checked-in outputs:** the emitted `*_generated.rs` paths are tracked in git like other
/// `REGEN_OUTPUTS` modules (not gitignored). `cargo build` / `cargo check` runs this `build.rs`
/// hook before `rustc` sees `lib.rs`, and `cargo:rerun-if-changed` on the template directory
/// forces a rebuild when `.rs.in` edits land — refresh committed `*_generated.rs` in the same PR
/// as template edits (CI exercises the full path).
///
/// Do not hand-edit `*_generated.rs`; edit the `.rs.in` templates and rebuild.
fn emit_pb0_cycle4_host_authority_modules(repo_root: &Path) {
const HEADER: &str = concat!(
"// AUTO-GENERATED by src/v3/compiler/build.rs (`emit_pb0_cycle4_host_authority_modules`).\n",
"//\n",
"// Template: `tools/pb0_cycle4_emit_templates/<stem>.rs.in` (workspace root).\n",
"// Dissolution receipt: PB-0 NON_TEST partition — `REGEN_OUTPUTS` producer; full `.dag` emit T-LP track.\n",
"//\n",
"\n",
);
let tmpl_dir = repo_root.join("tools/pb0_cycle4_emit_templates");
let specs: &[(&str, &str)] = &[
(
"cementing_dispatch.rs.in",
"src/v3/compiler/src/cementing_dispatch.rs",
),
(
"complexity_lattice.rs.in",
"src/v3/compiler/src/complexity_lattice_generated.rs",
),
(
"cost_basis_declaration.rs.in",
"src/v3/compiler/src/cost_basis_declaration_generated.rs",
),
("diagnostics.rs.in", "src/v3/compiler/src/diagnostics.rs"),
("dimension.rs.in", "src/v3/compiler/src/dimension.rs"),
(
"emit_collection_ops_method_contract.rs.in",
"src/v3/compiler/src/emit/collection_ops_method_contract_generated.rs",
),
(
"emit_rust_bin_shim.rs.in",
"src/v3/compiler/src/emit_rust_bin_shim_generated.rs",
),
(
"enforced_lens_application.rs.in",
"src/v3/compiler/src/enforced_lens_application_generated.rs",
),
(
"int_literal_ranges.rs.in",
"src/v3/compiler/src/int_literal_ranges_generated.rs",
),
("infer.rs.in", "src/v3/compiler/src/infer.rs"),
(
"pb_method_template_projection.rs.in",
"src/v3/compiler/src/pb_method_template_projection_generated.rs",
),
(
"pipeline_authority.rs.in",
"src/v3/compiler/src/pipeline_authority.rs",
),
(
"post_emit_verifier.rs.in",
"src/v3/compiler/src/post_emit_verifier.rs",
),
];
for (tmpl_name, rel_out) in specs {
let src_path = tmpl_dir.join(tmpl_name);
println!("cargo:rerun-if-changed={}", src_path.display());
let body = fs::read_to_string(&src_path).unwrap_or_else(|e| {
panic!(
"emit_pb0_cycle4_host_authority_modules: read template {}: {e}",
src_path.display()
)
});
let out_path = repo_root.join(rel_out);
if let Some(parent) = out_path.parent() {
fs::create_dir_all(parent).unwrap_or_else(|e| {
panic!(
"emit_pb0_cycle4_host_authority_modules: mkdir {}: {e}",
parent.display()
)
});
}
let generated = format!("{HEADER}{body}");
let needs_write = match fs::read_to_string(&out_path) {
Ok(existing) => existing != generated,
Err(_) => true,
};
if needs_write {
fs::write(&out_path, generated).unwrap_or_else(|e| {
panic!(
"emit_pb0_cycle4_host_authority_modules: write {}: {e}",
out_path.display()
)
});
}
}
}

fn emit_render_repeat_string_bootstrap(repo_root: &Path) {
const BEGIN: &str = "// GUNBC_BOOTSTRAP_EMIT_BEGIN\n";
const END: &str = "// GUNBC_BOOTSTRAP_EMIT_END";
Expand Down Expand Up @@ -635,7 +529,6 @@ fn main() {
let src_dir = v3_dir.parent().expect("v3 dir has parent");
let repo_root = src_dir.parent().expect("src dir has parent");
emit_render_repeat_string_bootstrap(repo_root);
emit_pb0_cycle4_host_authority_modules(repo_root);
let std_dir = v3_dir.join("std");
let spec_dir = v3_dir.join("spec");
let compiler_dir = manifest_path.clone();
Expand All @@ -652,10 +545,6 @@ fn main() {
println!("cargo:rerun-if-changed={}", extdeps_dir.display());
println!("cargo:rerun-if-changed={}", gunbc_dir.display());
println!("cargo:rerun-if-changed={}", dsl_std_dir.display());
println!(
"cargo:rerun-if-changed={}",
repo_root.join("tools/pb0_cycle4_emit_templates").display()
);

// Structural-recursion termination analysis walks a recursing
// argument back to its declared Disj connective (see
Expand Down Expand Up @@ -769,10 +658,6 @@ fn main() {
"src/v3/compiler/src/bootstrap_generated.rs",
"src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs",
"src/v3/compiler/src/bootstrap_std_generated.rs",
// PB-0: former hand `EXPECTED_HAND_AUTHORED_NON_TEST` modules — templates under
// `tools/pb0_cycle4_emit_templates/*.rs.in`, emitted by `emit_pb0_cycle4_host_authority_modules`.
"src/v3/compiler/src/cementing_dispatch.rs",
"src/v3/compiler/src/complexity_lattice_generated.rs",
// SG-5 substrate / runtime-mirror projections, generated from
// `src/v3/std/substrate.dag` + `src/v3/std/parse_surface.dag`
// and consumed by hand-authored Rust via `include!(...)`.
Expand All @@ -781,23 +666,15 @@ fn main() {
// outputs, so the content header alone never masquerades as
// generated (SG-0's `sg0_generated_partition_is_producer_owned`
// invariant).
"src/v3/compiler/src/complexity_lens_generated.rs",
"src/v3/compiler/src/cost_basis_declaration_generated.rs",
"src/v3/compiler/src/dag_branch_generated.rs",
"src/v3/compiler/src/dag_cluster_generated.rs",
"src/v3/compiler/src/dag_cost_generated.rs",
"src/v3/compiler/src/dag_lookup_generated.rs",
"src/v3/compiler/src/dag_cost_generated.rs",
"src/v3/compiler/src/dag_scalar_generated.rs",
"src/v3/compiler/src/dag_value_body_generated.rs",
"src/v3/compiler/src/diagnostics.rs",
"src/v3/compiler/src/diagnostics_generated.rs",
"src/v3/compiler/src/dimension.rs",
"src/v3/compiler/src/emit/collection_ops_method_contract_generated.rs",
"src/v3/compiler/src/emit_rust_bin_shim_generated.rs",
"src/v3/compiler/src/enforced_lens_application_generated.rs",
"src/v3/compiler/src/infer.rs",
"src/v3/compiler/src/infer_helpers_generated.rs",
"src/v3/compiler/src/int_literal_ranges_generated.rs",
"src/v3/compiler/src/complexity_lens_generated.rs",
"src/v3/compiler/src/lens_cost_symbolic_generated.rs",
"src/v3/compiler/src/lens_cost_target_realization_generated.rs",
"src/v3/compiler/src/lens_effect_enumeration_generated.rs",
Expand All @@ -807,9 +684,6 @@ fn main() {
"src/v3/compiler/src/lens_unused_parameters_generated.rs",
"src/v3/compiler/src/lower_helpers_generated.rs",
"src/v3/compiler/src/operators_generated.rs",
"src/v3/compiler/src/pipeline_authority.rs",
"src/v3/compiler/src/post_emit_verifier.rs",
"src/v3/compiler/src/pb_method_template_projection_generated.rs",
"src/v3/compiler/src/parse_generated.rs",
"src/v3/compiler/src/parse_surface_generated.rs",
"src/v3/compiler/src/parse_tables_generated.rs",
Expand Down
Loading
Loading