Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ const T19_MANIFEST_DAG: &str =
include_str!("../../../../v4/test/claim/manual/t19_manual_anchor_manifest.dag");
const T19_MANIFEST_PATH: &str = "src/v4/test/claim/manual/t19_manual_anchor_manifest.dag";

struct ExpectedHashPin<'a> {
digest: &'a str,
pin: &'a str,
}

struct ExpectedFixpt<'a> {
left: &'a str,
left_hash: ExpectedHashPin<'a>,
right: &'a str,
right_hash: ExpectedHashPin<'a>,
pinned_hash: ExpectedHashPin<'a>,
via: &'a str,
}

#[test]
fn t19_testgen_concept_surface_stays_closed_and_classified() {
let module = parse_module(TESTGEN_DAG, TESTGEN_PATH);
Expand Down Expand Up @@ -82,14 +96,32 @@ fn t19_manual_manifest_matches_claim_anchor_discriminants() {
fn t20_bootstrap_plan_keeps_self_hosting_chain_as_data() {
let module = parse_module(BOOTSTRAP_DAG, BOOTSTRAP_PATH);

assert_eq!(
record_field_type_map(type_record(&module, "BootstrapHashPin")),
expected_field_type_map(&[("digest", "Hash"), ("pin", "Symbol")]),
"BootstrapHashPin must pair digest facts with symbolic pins"
);
assert_eq!(
record_field_type_map(type_record(&module, "CompileStage")),
expected_field_type_map(&[
("consumes", "List<Symbol>"),
("produces", "Symbol"),
("produces_hash", "BootstrapHashPin"),
("compiled_by", "Symbol"),
]),
"CompileStage must keep the compiler-of-record as a structural field"
"CompileStage must keep compiler-of-record and per-stage hash pins as structural fields"
);
assert_eq!(
record_field_type_map(type_record(&module, "FixptStage1Stage2")),
expected_field_type_map(&[
("left", "Symbol"),
("left_hash", "BootstrapHashPin"),
("right", "Symbol"),
("right_hash", "BootstrapHashPin"),
("pinned_hash", "BootstrapHashPin"),
("via", "Symbol"),
]),
"FixptStage1Stage2 must carry paired stage hashes and the pinned fixed-point pin"
);
assert_eq!(
record_field_type_map(type_record(&module, "BootstrapPlan")),
Expand Down Expand Up @@ -131,25 +163,51 @@ fn t20_bootstrap_plan_keeps_self_hosting_chain_as_data() {
record_field_expr(bootstrap_plan_fields, "seed"),
&["v4_dag_source"],
"v4_stage0_binary",
ExpectedHashPin {
digest: "v4_stage0_hash",
pin: "v4_stage0_hash_pin",
},
"v2_pipeline",
);
assert_compile_stage(
record_field_expr(bootstrap_plan_fields, "self0"),
&["v4_dag_source", "v4_stage0_binary"],
"v4_stage1_binary",
ExpectedHashPin {
digest: "v4_stage1_hash",
pin: "v4_stage1_hash_pin",
},
"v4_stage0_binary",
);
assert_compile_stage(
record_field_expr(bootstrap_plan_fields, "self1"),
&["v4_dag_source", "v4_stage1_binary"],
"v4_stage2_binary",
ExpectedHashPin {
digest: "v4_stage2_hash",
pin: "v4_stage2_hash_pin",
},
"v4_stage1_binary",
);
assert_fixpt(
record_field_expr(bootstrap_plan_fields, "fixpt"),
"v4_stage1_binary",
"v4_stage2_binary",
"bit_identical_check",
&ExpectedFixpt {
left: "v4_stage1_binary",
left_hash: ExpectedHashPin {
digest: "v4_stage1_hash",
pin: "v4_stage1_hash_pin",
},
right: "v4_stage2_binary",
right_hash: ExpectedHashPin {
digest: "v4_stage2_hash",
pin: "v4_stage2_hash_pin",
},
pinned_hash: ExpectedHashPin {
digest: "pinned_v4_fixed_point_hash",
pin: "pinned_v4_fixed_point_hash_pin",

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.

BLOCKING: This ratchets the fixed-point fixture to distinct left/right/pinned hash-pin symbols even though bootstrap_plan_well_formed requires those pins to be equal, so the parse-only closeout test blesses a bootstrap_plan that the model rejects (INVARIANTS P2 facts must flow to the consuming invariant).

},
via: "bit_identical_check",
},
);
}

Expand Down Expand Up @@ -296,6 +354,7 @@ fn assert_compile_stage(
expr: &SurfaceExpr,
expected_consumes: &[&str],
expected_produces: &str,
expected_produces_hash: ExpectedHashPin<'_>,
expected_compiled_by: &str,
) {
let fields = match expr {
Expand All @@ -316,14 +375,38 @@ fn assert_compile_stage(
expected_produces,
"CompileStage.produces drifted"
);
assert_hash_pin(
record_field_expr(fields, "produces_hash"),
&expected_produces_hash,
);
assert_eq!(
var_name(record_field_expr(fields, "compiled_by")),
expected_compiled_by,
"CompileStage.compiled_by drifted"
);
}

fn assert_fixpt(expr: &SurfaceExpr, expected_left: &str, expected_right: &str, expected_via: &str) {
fn assert_hash_pin(expr: &SurfaceExpr, expected: &ExpectedHashPin<'_>) {
let fields = match expr {
SurfaceExpr::VariantRecord { target, fields, .. } => {
assert_eq!(target, "BootstrapHashPin");
fields
}
other => panic!("expected BootstrapHashPin record, got {other:?}"),
};
assert_eq!(
var_name(record_field_expr(fields, "digest")),
expected.digest,
"BootstrapHashPin.digest drifted"
);
assert_eq!(
var_name(record_field_expr(fields, "pin")),
expected.pin,
"BootstrapHashPin.pin drifted"
);
}

fn assert_fixpt(expr: &SurfaceExpr, expected: &ExpectedFixpt<'_>) {
let fields = match expr {
SurfaceExpr::VariantRecord { target, fields, .. } => {
assert_eq!(target, "FixptStage1Stage2");
Expand All @@ -332,9 +415,18 @@ fn assert_fixpt(expr: &SurfaceExpr, expected_left: &str, expected_right: &str, e
other => panic!("expected FixptStage1Stage2 record, got {other:?}"),
};

assert_eq!(var_name(record_field_expr(fields, "left")), expected_left);
assert_eq!(var_name(record_field_expr(fields, "right")), expected_right);
assert_eq!(var_name(record_field_expr(fields, "via")), expected_via);
assert_eq!(var_name(record_field_expr(fields, "left")), expected.left);
assert_hash_pin(record_field_expr(fields, "left_hash"), &expected.left_hash);
assert_eq!(var_name(record_field_expr(fields, "right")), expected.right);
assert_hash_pin(
record_field_expr(fields, "right_hash"),
&expected.right_hash,
);
assert_hash_pin(
record_field_expr(fields, "pinned_hash"),
&expected.pinned_hash,
);
assert_eq!(var_name(record_field_expr(fields, "via")), expected.via);
}

fn list_var_names(expr: &SurfaceExpr) -> Vec<&str> {
Expand Down
Loading