Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ jobs:
fi
scripts/check-test-timeout.sh /tmp/v3-test-timings.log

# PB-1-e — DB-8 fresh-compile gate at regen time. Replaces the in-tree
# `compile_full_bootstrap_dag()` vs committed-snapshot drift tests with a
# CI-side check: regen the bootstrap snapshot from authority, then assert
# the committed `bootstrap_*_generated.rs` files are byte-identical to a
# fresh compile. Any drift (hand-edit, stale regen, substrate change) fails
# CI here. See `docs/briefs/pb-1-e-residual-scaffold-retirement-worker.md`.
- name: v3 bootstrap snapshot fresh-compile gate
run: |
cargo run -p v3-compiler --bin regen_bootstrap
if ! git diff --exit-code -- \
src/v3/compiler/src/bootstrap_std_generated.rs \
src/v3/compiler/src/bootstrap_generated.rs \
src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs; then
echo "::error::Committed bootstrap snapshot drifted from a fresh compile. Run \`cargo run -p v3-compiler --bin regen_bootstrap\` and commit the result."
exit 1
fi

- name: v3 Compiler Clippy
run: cargo clippy -p v3-compiler --all-targets -- -D warnings

Expand Down
41 changes: 16 additions & 25 deletions src/v3/compiler/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,29 @@ fn declaration_name_preference_rank(file: &str) -> usize {
}
}

// PB-1 scaffold boundary: this legacy std-only runtime bootstrap path exists
// solely for `regen_bootstrap` and the PB-1 equivalence tests. Production
// bootstrap MUST seed from `Dag::std_fixture_bootstrap_snapshot()`, not from a
// fresh `load_fixtures(std_fixtures())` pass.
// PB-1-e scaffold boundary: the runtime-parse helpers below exist solely so
// `regen_bootstrap` can produce the committed snapshot files
// (`bootstrap_*_generated.rs`) from the canonical `.dag` authorities.
// Production bootstrap MUST seed from `Dag::std_fixture_bootstrap_snapshot()`
// or `Dag::new()` directly; neither calls these helpers.
//
// Named dissolution trigger: delete this helper once the PB-1 drift harness no
// longer needs to re-run the pre-snapshot std bootstrap path (for example if
// regen/tests compare against a direct `.dag`-to-snapshot receipt without
// reconstructing the runtime std Dag in-process).
// In-tree DB-8 cross-check is "the committed snapshot is internally
// consistent" (see `tests/integration/pb1_bootstrap_full_snapshot_test.rs`).
// The fresh-parse-vs-snapshot acid test runs at regen time: CI invokes
// `cargo run --bin regen_bootstrap` and asserts `git diff --exit-code` on
// `src/v3/compiler/src/bootstrap_*_generated.rs` — drift between the
// committed bytes and a fresh compile fails CI.
//
// Named dissolution trigger: delete these helpers once `regen_bootstrap`
// itself is generated from a `.dag` regen-authority spec (so the fresh-parse
// step is no longer hand-Rust). At that point the std snapshot can be
// derived from the same authority that drives the rest of the regen registry.
pub(crate) fn bootstrap_std_fixtures_only(dag: &mut Dag) {
*dag = Dag::empty();
load_fixtures(dag, std_fixtures());
dag.populate_primitive_cache();
}

pub(crate) fn bootstrap_all_runtime(
dag: &mut Dag,
excluded_staged_paths: &[&str],
excluded_compiler_paths: &[&str],
) {
*dag = Dag::std_fixture_bootstrap_snapshot();
// The std snapshot already represents `load_fixtures(std_fixtures())`
// after one `resolve_pending_identifiers` + `populate_primitive_cache`
// pass. Loading staged/spec/compiler fixtures on top re-runs both
// operations for the *combined* bootstrap Dag. That double-pass shape is
// intentional and must stay idempotent: the first pass closes the frozen
// std snapshot, the second closes cross-authority references introduced by
// `src/v3/std/*.dag`, `src/v3/spec/*.dag`, and `src/v3/compiler/*.dag`
// (while still tolerating dangling bootstrap-range stubs such as `Tuple`).
load_runtime_bootstrap_authorities(dag, excluded_staged_paths, excluded_compiler_paths);
}

pub(crate) fn bootstrap_runtime_authorities_on(
dag: &mut Dag,
excluded_staged_paths: &[&str],
Expand Down
30 changes: 9 additions & 21 deletions src/v3/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,11 @@ pub fn patch_lower_helpers_generated_type_alias_refinement(src: &str) -> String
out
}

/// PB-1 scaffold helper: re-run the pre-snapshot std bootstrap path for
/// `regen_bootstrap` and the PB-1 drift tests only. This is NOT a second
/// production bootstrap authority; `Dag::new()` seeds from the committed
/// generated snapshot. Dissolution trigger: same as
/// `bootstrap::bootstrap_std_fixtures_only`.
/// PB-1-e scaffold helper: fresh-parse the std fixtures so `regen_bootstrap`
/// can produce `bootstrap_std_generated.rs` from authority. Not a production
/// bootstrap path — `Dag::new()` seeds from the committed snapshot. Sole
/// in-tree consumer is `regen_bootstrap`; CI's `regen_bootstrap` + `git diff`
/// step is the cross-check that the snapshot matches a fresh compile.
pub fn compile_std_bootstrap_dag() -> Dag {
let mut dag = Dag::empty();
bootstrap::bootstrap_std_fixtures_only(&mut dag);
Expand All @@ -1179,10 +1179,10 @@ pub fn generated_std_bootstrap_dag() -> Dag {
Dag::std_fixture_bootstrap_snapshot()
}

/// PB-1 closure scaffold helper for `regen_bootstrap`: layer the staged/spec/
/// compiler bootstrap authorities onto an explicitly supplied std seed so all
/// generated outputs in one regen pass derive from the same `dsl/std/*.dag`
/// authority. This is not a production bootstrap entry point.
/// PB-1-e regen-only scaffold helper: layer the staged/spec/compiler bootstrap
/// authorities onto an explicitly supplied std seed so all generated outputs in
/// one regen pass derive from the same `dsl/std/*.dag` authority. Sole consumer
/// is `regen_bootstrap`; not a production bootstrap entry point.
pub fn compile_full_bootstrap_dag_from_std_seed(std_seed: Dag) -> Dag {
let mut dag = std_seed;
bootstrap::bootstrap_runtime_authorities_on(&mut dag, &[], &[]);
Expand All @@ -1198,18 +1198,6 @@ pub fn compile_full_bootstrap_without_parse_surface_dag_from_std_seed(std_seed:
dag
}

pub fn compile_full_bootstrap_dag() -> Dag {
let mut dag = Dag::empty();
bootstrap::bootstrap_all_runtime(&mut dag, &[], &[]);
dag
}

pub fn compile_full_bootstrap_without_parse_surface_dag() -> Dag {
let mut dag = Dag::empty();
bootstrap::bootstrap_all_runtime(&mut dag, &["src/v3/std/parse_surface.dag"], &[]);
dag
}

pub fn generated_full_bootstrap_dag() -> Dag {
Dag::new()
}
Expand Down
2 changes: 0 additions & 2 deletions src/v3/compiler/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ mod m2_substrate_inhabitance_test;
mod p0_std_render_repeat_string_test;
#[path = "integration/pb1_bootstrap_full_snapshot_test.rs"]
mod pb1_bootstrap_full_snapshot_test;
#[path = "integration/pb1_bootstrap_std_snapshot_test.rs"]
mod pb1_bootstrap_std_snapshot_test;
#[path = "integration/pipe_desugar.rs"]
mod pipe_desugar;
#[path = "integration/r1_manual_claim_gate_test.rs"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
//! **Layer:** integration
//!
//! PB-1-e — in-tree DB-8 cross-check is now "the committed bootstrap snapshot is
//! internally consistent": `Dag::new()` is diagnostic-clean and byte-stable across
//! clones, and the std-only snapshot is a strict prefix-shape of the full snapshot.
//! The fresh-parse-vs-snapshot acid test runs at regen time (`regen_bootstrap` +
//! CI's `git diff --exit-code` on the committed `bootstrap_*_generated.rs`),
//! not on every `cargo test`. See `docs/briefs/pb-1-e-residual-scaffold-retirement-worker.md`.

use v3_compiler::{
compile_full_bootstrap_dag, compile_full_bootstrap_without_parse_surface_dag,
generated_full_bootstrap_dag, generated_full_bootstrap_without_parse_surface_dag,
generated_std_bootstrap_dag,
generated_full_bootstrap_dag, generated_std_bootstrap_dag,
serialize::{first_difference, serialize_dag},
Dag,
};

fn assert_no_bootstrap_drift(label: &str, runtime: &Dag, generated: &Dag) {
if let Some(diff) = first_difference(runtime, generated) {
panic!("{label} drifted from runtime bootstrap: {}", diff.detail);
}
}

#[test]
fn generated_full_bootstrap_snapshot_matches_runtime_full_bootstrap() {
let runtime = compile_full_bootstrap_dag();
let generated = generated_full_bootstrap_dag();
assert_no_bootstrap_drift("generated full bootstrap", &runtime, &generated);
}

#[test]
fn generated_full_bootstrap_without_parse_surface_matches_runtime_variant() {
let runtime = compile_full_bootstrap_without_parse_surface_dag();
let generated = generated_full_bootstrap_without_parse_surface_dag();
assert_no_bootstrap_drift(
"generated no-runtime-mirrors bootstrap",
&runtime,
&generated,
);
}

#[test]
fn full_bootstrap_extends_std_snapshot() {
let std_only = generated_std_bootstrap_dag();
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/v3/compiler/tests/integration/sg0_census_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ const EXPECTED_HAND_AUTHORED_TEST: &[&str] = &[
"src/v3/compiler/tests/integration/m2_substrate_inhabitance_test.rs",
"src/v3/compiler/tests/integration/p0_std_render_repeat_string_test.rs",
"src/v3/compiler/tests/integration/pb1_bootstrap_full_snapshot_test.rs",
"src/v3/compiler/tests/integration/pb1_bootstrap_std_snapshot_test.rs",
"src/v3/compiler/tests/integration/pipe_desugar.rs",
"src/v3/compiler/tests/integration/r1_manual_claim_gate_test.rs",
"src/v3/compiler/tests/integration/sg0_census_test.rs",
Expand Down
Loading