Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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: 2 additions & 2 deletions src/v3/compiler/src/bin/regen_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
let full_dag = compile_full_bootstrap_dag_from_std_seed(std_dag.clone());
let full_formatted = render_bootstrap_generated_rs(
&full_dag,
"dsl/std/*.dag + src/v3/std/*.dag + src/v3/spec/*.dag + src/v3/compiler/*.dag minus tokenize.dag",
"dsl/std/*.dag + src/v3/std/*.dag + src/v3/spec/*.dag + src/v3/compiler/*.dag minus tokenize.dag + dsl/extdeps/languages/rust/primitives.dag",
"bootstrapped_fixture_dag",
)
.unwrap_or_else(|e| panic!("regen_bootstrap full: {e}"));
Expand All @@ -45,7 +45,7 @@ fn main() {
compile_full_bootstrap_without_parse_surface_dag_from_std_seed(std_dag);
let full_no_parse_surface_formatted = render_bootstrap_generated_rs(
&full_no_parse_surface_dag,
"dsl/std/*.dag + src/v3/std/*.dag + src/v3/spec/*.dag + src/v3/compiler/*.dag minus tokenize.dag and src/v3/std/parse_surface.dag",
"dsl/std/*.dag + src/v3/std/*.dag + src/v3/spec/*.dag + src/v3/compiler/*.dag minus tokenize.dag and src/v3/std/parse_surface.dag + dsl/extdeps/languages/rust/primitives.dag",
"bootstrapped_fixture_without_parse_surface_dag",
)
.unwrap_or_else(|e| panic!("regen_bootstrap no-parse-surface: {e}"));
Expand Down
68 changes: 55 additions & 13 deletions src/v3/compiler/src/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
// Dag::new() bootstrap.
//
// PB-1 closure: `Dag::new()` no longer tokenizes/parses/lowers any
// bootstrap authority at runtime. All four bootstrap authority sets
// bootstrap authority at runtime. Five bootstrap authority sets
// are loaded from committed generated snapshots:
//
// - `std_fixtures` (`dsl/std/*.dag`)
// - `STAGED_FILES` (`src/v3/std/*.dag`)
// - `V3_SPECS` (`src/v3/spec/*.dag`)
// - `COMPILER_FILES` (`src/v3/compiler/*.dag`, minus `tokenize.dag`)
// - `std_fixtures` (`dsl/std/*.dag`)
// - `STAGED_FILES` (`src/v3/std/*.dag`)
// - `V3_SPECS` (`src/v3/spec/*.dag`)
// - `COMPILER_FILES` (`src/v3/compiler/*.dag`, minus `tokenize.dag`)
// - `EXTDEPS_BOOTSTRAP_FIXTURES` (scoped subset of `dsl/extdeps/languages/*/*.dag`)
//
// `compile_parse_surface_std_authority_dag` uses the companion snapshot
// that omits `src/v3/std/parse_surface.dag`, so a fresh parse+lower of
// that authority still stays first-of-name.
//
// **Production bootstrap does not inject target-language
// realizations.** Realization facts for emitted languages live in
// `dsl/extdeps/languages/*` per the thesis; compiler code does not
// manufacture those. L1.5 adds one narrow exception: the staged
// `src/v3/compiler/pipeline.dag` declarations are upgraded in-place to
// `ArrowBody::ExternalRealization` so the compiler's own pipeline
// authority lives in the bootstrap Dag with the intended stage-body
// shape.
// **Target-language realization facts stay out of bootstrap.** Realization
// facts for emitted languages live in `dsl/extdeps/languages/*` per the
// thesis and are consumed by the per-target emitters at emission time via
// `SubstrateAccessorBinding` records — compiler code does not manufacture
// those. The L1.5 exception remains: `src/v3/compiler/pipeline.dag` stage
// declarations are upgraded in-place to `ArrowBody::ExternalRealization`
// so the compiler's own pipeline authority lives in the bootstrap Dag with
// the intended stage-body shape.
//
// `EXTDEPS_BOOTSTRAP_FIXTURES` is a narrow, bounded extension of that
// boundary: only extdeps authorities whose content is pure structural
// **data** (target-primitive declarations consumed symbolically by the
// target-grounding engine as `Declaration`-shaped values; see
// `dsl/extdeps/languages/rust/primitives.dag`) are loaded. Arrow/realization
// files (`rust/emit.dag`, `rust/types.dag`, etc.) are deliberately excluded
// — their bodies stay per-target emitter-side, not in the bootstrap Dag.
// Coverage is currently `rust/primitives.dag` only (T-Ground-Engine pilot
// unblock, Director-dispatched); expansion to python/go primitives is a
// file-system extension once those targets reach the same pilot stage.
//
// **Type-structure-only load (Path 2 scoping).** The top-level
// `rust_pilot_primitives: List<RustPrimitive> = [...]` data declaration
// lowers with `value_body = ValueBody::Unparsed(span)` because v3's
// `ValueBody` enum does not yet carry a top-level list/aggregate variant
// (`dag.rs:258-287`). Type-structure walking of `RustPrimitive =
// IntegerPrimitive | NonIntegerPrimitive {...}` is fully available via the
// loaded declarations; the 10-element pilot enumeration becomes walkable
// only when R2 T-Substrate's 4th sub-lane lands the top-level
// `ValueBody::List`/aggregate extension. Same substrate gap as
// `kernel_algebra_profile`'s hand-Rust mirror (`dag.rs:1530`) and
// tokenizer `sub_charclass_in_std_unicode` phase-2.
//
// Transitional shape: PB-Bootstrap-Process lane (Zero-Floor program;
// tracked in `docs/design-pure-bootstrap-zero.md` §"New lanes") absorbs
// `bootstrap.rs` entirely when it lands `bootstrap.dag` declaring the
// workflow as data — at that point this loader logic becomes part of the
// to-be-generated content with no hand-Rust edit.
//
// Bootstrap failures (tokenize/parse/lower errors on std/ files,
// unresolved cross-file references) attach to the Dag's diagnostic
Expand All @@ -46,6 +76,17 @@ const FLOAT_DAG: &str = include_str!("../../../../dsl/std/float.dag");
const STRING_TYPE_DAG: &str = include_str!("../../../../dsl/std/string_type.dag");
const TYPES_DAG: &str = include_str!("../../../../dsl/std/types.dag");

// Scoped extdeps bootstrap authorities. See the `EXTDEPS_BOOTSTRAP_FIXTURES`
// commentary in the file header: only pure structural-data extdeps authorities
// are in scope, and expansion is a file-system edit to this array.
const EXTDEPS_RUST_PRIMITIVES_DAG: &str =
include_str!("../../../../dsl/extdeps/languages/rust/primitives.dag");

const EXTDEPS_BOOTSTRAP_FIXTURES: &[(&str, &str)] = &[(
"dsl/extdeps/languages/rust/primitives.dag",
EXTDEPS_RUST_PRIMITIVES_DAG,
)];

// M1(3) PR-B-unwind R1 — the v3-only staged files are enumerated
// by `build.rs` at compile time and exposed via generated statics:
//
Expand Down Expand Up @@ -144,6 +185,7 @@ fn load_runtime_bootstrap_authorities(
let fixtures: Vec<(&str, &str)> = staged_iter
.chain(V3_SPECS.iter().copied())
.chain(compiler_iter)
.chain(EXTDEPS_BOOTSTRAP_FIXTURES.iter().copied())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Regenerate full bootstrap snapshots with extdeps fixtures

Adding EXTDEPS_BOOTSTRAP_FIXTURES here changes only the runtime assembly path, but Dag::new() still clones the committed generated snapshots (bootstrap_generated*.rs). Because those generated files were not updated in this commit, generated and runtime bootstraps now diverge (the PB-1 snapshot equivalence tests report declaration-count mismatches), so production bootstrap still omits the new extdeps declarations until regen output is committed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale on current tip. Verified: snapshots were regenerated after my initial WIP.

$ git log --oneline --all -- src/v3/compiler/src/bootstrap_generated.rs | head -1
342146cb6 WIP: extdeps loader close

$ grep -c "rust_pilot_primitives" src/v3/compiler/src/bootstrap_generated.rs src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs
src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs:1
src/v3/compiler/src/bootstrap_generated.rs:1

The WIP commit that landed EXTDEPS_BOOTSTRAP_FIXTURES also regenerated bootstrap_generated.rs / bootstrap_generated_without_parse_surface.rs / bootstrap_std_generated.rs (via cargo run -p v3-compiler --bin regen_bootstrap); the same commit also regenerated eight lens modules that walk Disj declarations (cost, cost_symbolic, provenance, structural_resolution, unused_parameters, variant_payload, infer_helpers, lower_helpers) so the TargetCarrier / RustPrimitive enums land in every generated consumer.

PB-1 drift tests — pb1_bootstrap_full_snapshot_test::generated_full_bootstrap_snapshot_matches_runtime_full_bootstrap, ..._without_parse_surface_matches_runtime_variant, and dag_new_bootstrap_is_clean_and_byte_stable — are green in the latest cargo test --workspace --exclude v2-compiler-tests run cited in the PR body. You were likely looking at the pre-regen WIP (f58fa555f); head is now 6acadd450.

.collect();
load_fixtures(dag, &fixtures);
materialize_pipeline_realizations(dag);
Expand Down
2,274 changes: 1,148 additions & 1,126 deletions src/v3/compiler/src/bootstrap_generated.rs

Large diffs are not rendered by default.

2,126 changes: 1,074 additions & 1,052 deletions src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/v3/compiler/src/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,34 @@ impl Dag {
})
}

/// Typed accessor for the `rust_pilot_primitives` data declaration
/// from `dsl/extdeps/languages/rust/primitives.dag` (loaded via
/// `EXTDEPS_BOOTSTRAP_FIXTURES` in `bootstrap.rs`). Returns the
/// top-level `List<RustPrimitive>` declaration whose *type* the
/// target-grounding engine walks structurally (`RustPrimitive =
/// IntegerPrimitive | NonIntegerPrimitive {target_name, algebra,
/// carrier, is_copy[, overflow]}`).
///
/// **Path 2 partial Req-1 satisfaction.** The returned declaration's
/// `value_body` is `ValueBody::Unparsed(SourceSpan)` — v3's
/// `ValueBody` enum does not yet carry a top-level list/aggregate
/// variant, so the 10-element pilot enumeration is not yet walkable
/// as structured records. Consumers that only need the type shape
/// (sum variants, variant fields, tag enums) can walk through
/// `connective` immediately; consumers that need to enumerate the
/// concrete pilot primitives must wait for R2 T-Substrate's 4th
/// sub-lane to land the top-level `ValueBody::List`/aggregate
/// extension (same substrate gap as `kernel_algebra_profile` at
/// `dag.rs:1530` and tokenizer `sub_charclass_in_std_unicode`
/// phase-2).
///
/// Returns `None` only when bootstrap failed to load
/// `rust/primitives.dag`, in which case a diagnostic is already on
/// `Dag.diagnostics`.
pub fn rust_pilot_primitives(&self) -> Option<&Declaration> {
self.declaration_by_name("rust_pilot_primitives")
}

/// DB-10 (3a.2): read the compile-time value body attached to a
/// declaration. Returns `None` for declarations without a
/// value body (type aliases, bare type declarations, function
Expand Down
2 changes: 2 additions & 0 deletions src/v3/compiler/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ mod common;
mod cementing_lens_registry_dispatch_test;
#[path = "integration/e_i_lane_induction_preflight_test.rs"]
mod e_i_lane_induction_preflight_test;
#[path = "integration/extdeps_rust_primitives_loader_test.rs"]
mod extdeps_rust_primitives_loader_test;
#[path = "integration/four_fixture_regression_test.rs"]
mod four_fixture_regression_test;
#[path = "integration/l1_5_fixed_point_test.rs"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//! **Layer:** integration
//!
//! T-Ground-Engine Phase-1 unblock (Path 2): `dsl/extdeps/languages/rust/
//! primitives.dag` is loaded into the bootstrap Dag; `Dag::rust_pilot_primitives`
//! returns a walkable type-structure declaration. The 10-element pilot
//! enumeration is NOT walkable as structured records until R2 T-Substrate's
//! 4th sub-lane lands the top-level `ValueBody::List`/aggregate extension;
//! this test pins the currently-available type-structure access and
//! explicitly records the `ValueBody::Unparsed` boundary.

use v3_compiler::dag::{Dag, TypeConnective, ValueBody};

#[test]
fn dag_new_exposes_rust_pilot_primitives_type_structure() {
let dag = Dag::new();
assert!(
dag.diagnostics().is_empty(),
"bootstrap must be clean for extdeps loader-close, got {:?}",
dag.diagnostics()
);

let decl = dag
.rust_pilot_primitives()
.expect("rust_pilot_primitives must be loaded from EXTDEPS_BOOTSTRAP_FIXTURES");

// Req 2: stable shape, walkable structurally.
assert_eq!(
decl.span.file, "dsl/extdeps/languages/rust/primitives.dag",
"rust_pilot_primitives span must point at the authority file"
);

// Top-level declaration is `List<RustPrimitive>` — an Instantiation
// connective parameterized over the RustPrimitive sum.
let rust_primitive_decl_id = match &decl.connective {
TypeConnective::Instantiation { arguments, .. } => {
assert_eq!(
arguments.len(),
1,
"rust_pilot_primitives: List<RustPrimitive> has exactly one template argument"
);
arguments[0].value
}
other => panic!(
"rust_pilot_primitives must lower to an Instantiation (List<RustPrimitive>), got {:?}",
other
),
};

// Walk through to the RustPrimitive sum and pin the two variants +
// their field labels. This is the type-structure-only walk that
// Engine sharpened-(b) Phase 1 consumes.
let rust_primitive = dag.declaration(rust_primitive_decl_id);
assert_eq!(rust_primitive.name.as_deref(), Some("RustPrimitive"));
let variants = match &rust_primitive.connective {
TypeConnective::Disj { variants } => variants,
other => panic!("RustPrimitive must be a Disj, got {:?}", other),
};
let variant_labels: Vec<&str> = variants.iter().map(|f| f.label.as_str()).collect();
assert_eq!(
variant_labels,
vec!["IntegerPrimitive", "NonIntegerPrimitive"],
"pilot scope is integer/non-integer split per primitives.dag authority"
);

let integer_variant = dag.declaration(variants[0].ty);
let integer_field_labels: Vec<&str> = match &integer_variant.connective {
TypeConnective::Conj { children } => children.iter().map(|f| f.label.as_str()).collect(),
other => panic!(
"IntegerPrimitive payload must be a Conj record, got {:?}",
other
),
};
assert_eq!(
integer_field_labels,
vec!["target_name", "algebra", "carrier", "is_copy", "overflow"],
"IntegerPrimitive field order is load-bearing for T-Ground L4-(C) witness consumption"
);

let non_integer_variant = dag.declaration(variants[1].ty);
let non_integer_field_labels: Vec<&str> = match &non_integer_variant.connective {
TypeConnective::Conj { children } => children.iter().map(|f| f.label.as_str()).collect(),
other => panic!(
"NonIntegerPrimitive payload must be a Conj record, got {:?}",
other
),
};
assert_eq!(
non_integer_field_labels,
vec!["target_name", "algebra", "carrier", "is_copy"],
"NonIntegerPrimitive is structurally missing `overflow` (state-space discipline)"
);
}

#[test]
fn rust_pilot_primitives_value_body_is_unparsed_until_r2_substrate_4th_sublane() {
// Boundary pin: the 10-element pilot list stays unparsed at the
// top-level `data ... = [...]` body because v3's `ValueBody` enum
// lacks a top-level list/aggregate variant. When R2 T-Substrate's
// 4th sub-lane (top-level `ValueBody::List`/aggregate extension)
// lands, this assertion flips and Engine sharpened-(b) Phase 2 can
// re-dispatch against structured records. See
// `docs/r2-structure.md` 4th sub-lane scoping.
let dag = Dag::new();
let decl = dag.rust_pilot_primitives().expect("loaded");
let body = decl
.value_body
.as_ref()
.expect("data declarations carry a value_body");
assert!(
matches!(body, ValueBody::Unparsed(_)),
"rust_pilot_primitives.value_body must stay Unparsed until ValueBody grows a \
top-level list/aggregate variant; got {body:?}. If this test flips to failing \
because the body is now structured, update Engine sharpened-(b) Phase 2 \
consumers to walk the structured value and delete this assertion."
);
}
6 changes: 3 additions & 3 deletions src/v3/compiler/tests/integration/parse_corpus_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ src/v3/compiler/tests/four_fixture_pressure/id.v3 2 2452 ec8b40edc3d3c017
src/v3/compiler/tests/four_fixture_pressure/is_empty.v3 3 6755 00117f14eb43dd20
src/v3/compiler/tests/four_fixture_pressure/wrap.v3 4 5189 ac633b042c944480
src/v3/compiler/tokenize.dag 27 56809 9a7718edd277aa93
src/v3/spec/go.dag 119 1056460 98fdca9b71a6c43b
src/v3/spec/python.dag 87 554058 11d7013f71682497
src/v3/spec/rust.dag 135 1123188 229ccb9a6a76e024
src/v3/spec/go.dag 119 1057003 e21bbda50cdc82a9
src/v3/spec/python.dag 87 554606 d8aa76b9e7a30d49
src/v3/spec/rust.dag 135 1123734 4e900c6b6e7d9189
src/v3/spec/v3_l1.dag 8 2238 1f55d782265c3bfe
src/v3/std/algebra.dag 36 284938 29978b1b9f257877
src/v3/std/clean_emission.dag 15 23867 e7bc1e6145f4781e
Expand Down
8 changes: 8 additions & 0 deletions src/v3/compiler/tests/integration/sg0_census_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ const EXPECTED_HAND_AUTHORED_TEST: &[&str] = &[
"src/v3/compiler/tests/integration/common/mod.rs",
"src/v3/compiler/tests/integration/common/substrate_receipts.rs",
"src/v3/compiler/tests/integration/e_i_lane_induction_preflight_test.rs",
// T-Ground-Engine Phase-1 loader-close (PR #776, Director-approved
// Path 2): hand-Rust integration test pinning
// `Dag::rust_pilot_primitives()` type-structure walk + the
// `ValueBody::Unparsed` boundary that flips when R2 T-Substrate's
// 4th sub-lane lands top-level `ValueBody::List`/aggregate.
// Dissolves into testgen authority when the testgen path covers
// the dsl/extdeps loader surface.
"src/v3/compiler/tests/integration/extdeps_rust_primitives_loader_test.rs",
"src/v3/compiler/tests/integration/four_fixture_regression_test.rs",
"src/v3/compiler/tests/integration/l1_5_fixed_point_test.rs",
"src/v3/compiler/tests/integration/lane2_stage_2a_effects_smoke.rs",
Expand Down
1 change: 1 addition & 0 deletions src/v3/spec/go.dag
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ data go_execution_model: TargetExecutionModel = {
data go_source_filtering: SourceFiltering = {
excluded_prefixes: [
"dsl/std/",
"dsl/extdeps/",
"src/v3/std/",
"src/v3/spec/",
"src/v3/compiler/",
Expand Down
1 change: 1 addition & 0 deletions src/v3/spec/python.dag
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ data python_target: TargetExecutionModel = {
data python_source_filtering: SourceFiltering = {
excluded_prefixes: [
"dsl/std/",
"dsl/extdeps/",
"src/v3/std/",
"src/v3/spec/",
]
Expand Down
1 change: 1 addition & 0 deletions src/v3/spec/rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ data rust_execution_model: TargetExecutionModel = {
data rust_source_filtering: SourceFiltering = {
excluded_prefixes: [
"dsl/std/",
"dsl/extdeps/",
"src/v3/std/",
"src/v3/spec/",
"src/v3/compiler/",
Expand Down
Loading