Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
90d7a29
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
50d5ea4
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
0c3ddf4
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
c687292
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
11ce3dc
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
88c4a67
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
77635d7
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
4bdcfe5
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
6d41df0
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
0c3791d
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
df0d27b
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
f5e80f5
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
634d734
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
f4675e2
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
588edf9
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
91b9ff2
merge: sync origin/main (free_monoid rename + Wave-3-E corpus)
briansrls May 21, 2026
3599a51
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
c2edad8
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
1e41026
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
cf40696
docs: clarify scaffold fixpt digest equality and CompilesClaim semantics
briansrls May 21, 2026
5eefe4a
fix: model fixpt digest equality via independent carriers (A2+A3)
briansrls May 21, 2026
0eb902e
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
8f193ae
fix: close codex #15875 ratchets for independent digests and RoundTri…
briansrls May 21, 2026
16e5112
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
10816f5
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
0e2add6
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
29c30ef
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
f23685e
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
a1c3910
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
e269c7d
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
4d0fae8
fix: polarity-specific InferReceiptCase bridge (codex infer migration)
briansrls May 21, 2026
ffeb163
fix: add Practice 4/9 coproduct tag on InferReceiptCase (codex P5)
briansrls May 21, 2026
bf50e45
fix: wire bootstrap mismatch witness to v4_stage2_hash carrier (A2+A3)
briansrls May 21, 2026
71b5b32
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
456ea47
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
f79c472
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
6dc5229
chore: apply cargo fmt
briansrls May 21, 2026
8243612
WIP: Substrate hardening bundle: node well-formedness arity + bootstr…
briansrls May 21, 2026
771da10
fix: P2 accessors for InferReceiptCase and unified P9 row proof
briansrls May 21, 2026
6122864
fix: type infer_add_mvp receipt over InferredTree and preserve Fail a…
briansrls May 21, 2026
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
81 changes: 58 additions & 23 deletions src/v3/compiler/tests/integration/v4_lens_testgen_dag_smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ use v3_compiler::tokenize_for_test;

const TESTGEN_DAG: &str = include_str!("../../../../v4/lens/testgen.dag");
const VERIFICATION_DAG: &str = include_str!("../../../../v4/std/verification.dag");
const P9_REGISTRY_OWNER_DAG: &str =
include_str!("../../../../v4/test/claim/lens_cost/p9_llvm_instruction_cost_registry_owner.dag");
const P9_REGISTRY_OWNER_PATH: &str =
"src/v4/test/claim/lens_cost/p9_llvm_instruction_cost_registry_owner.dag";
const NAT_LAW_DAG: &str = include_str!("../../../../v4/test/claim/manual/nat_law_anchors.dag");
const NAT_SUBSTRATE_DAG: &str = include_str!("../../../../v4/std/nat.dag");

Expand All @@ -34,6 +38,19 @@ const NAT_MANUAL_CLAIM_DATA: [&str; 6] = [
"claim_nat_mul_associativity",
];

#[test]
fn v4_lens_testgen_p9_registry_owner_claim_parses_and_checks_registry_exclusivity() {
parse_module(P9_REGISTRY_OWNER_DAG, P9_REGISTRY_OWNER_PATH);
assert!(
P9_REGISTRY_OWNER_DAG.contains("lens_owned_fn_registry_v0")
&& P9_REGISTRY_OWNER_DAG.contains("p9_owned_fn_row_eq")
&& P9_REGISTRY_OWNER_DAG.contains("count_equal(")
&& P9_REGISTRY_OWNER_DAG.contains("item: lens_owned_fn_llvm_instruction_cost")
&& P9_REGISTRY_OWNER_DAG.contains("EqualsClaim {"),
"P9 receipt must prove exactly one full registry row matches canonical fn+owner (B1)"
);
}

#[test]
fn v4_lens_testgen_wave0_modules_tokenize_and_parse() {
let testgen = parse_module(TESTGEN_DAG, "src/v4/lens/testgen.dag");
Expand All @@ -53,6 +70,16 @@ fn v4_lens_testgen_wave0_modules_tokenize_and_parse() {
#[test]
fn v4_lens_testgen_wave0_verification_manual_anchor_key_only() {
let verification = parse_module(VERIFICATION_DAG, "src/v4/std/verification.dag");
assert!(
import_names_for_path(&verification, &["v4", "std", "node"])
.is_some_and(|names| names.iter().any(|n| n == "Symbol")),
"verification.dag must import Symbol for diagnostic reason carriers (P2 resolve)"
);
assert!(
VERIFICATION_DAG.contains("expected_value: Node")
&& VERIFICATION_DAG.contains("expected_rejection: NonEmptyDiagnostics"),
"TestClaim variants must use polarity-specific carriers, not Outcome<Node> (P2 illegal-states)"
);
assert!(
module_declares_type_sum_named(&verification, "T19ManualAnchorKey"),
"substrate must declare `type T19ManualAnchorKey` (parsed `TypeSum`)"
Expand Down Expand Up @@ -90,7 +117,7 @@ fn v4_lens_testgen_wave0_function_inventory_matches_wave0() {
assert_eq!(
function_count(&testgen, "bootstrap_assert_kind_for_manual_anchor"),
0,
"AssertKind must not be re-authored in testgen; use manual `TestClaim.kind`"
"AssertKind must not be re-authored in testgen; assertion shape lives on TestClaim coproduct"
);
assert_eq!(
function_count(&verification, "t19_present_manual_anchor_key"),
Expand All @@ -107,6 +134,12 @@ fn v4_lens_testgen_wave0_function_inventory_matches_wave0() {
0,
"lens/testgen must not host a mirrored present-key conversion table (codex duplicate-authority fix)"
);
let expected_outcome_rt = fn_return_type(&verification, "test_claim_expected_outcome")
.expect("test_claim_expected_outcome should have an explicit return type");
assert!(
type_is_outcome_outcome_named(expected_outcome_rt, "Node"),
"RoundTripClaim has no declared expected outcome: projection must fail-close as `Outcome<Outcome<Node>>`, not fabricate `Outcome<Node>`; got {expected_outcome_rt:?}"
);
}

#[test]
Expand Down Expand Up @@ -180,20 +213,20 @@ fn v4_lens_testgen_wave0_generator_t19_anchor_field_is_manual_key() {
fn v4_lens_testgen_wave0_concept_projection_matches_claim_t19_anchor() {
assert!(
TESTGEN_DAG.contains("fn testgen_concept_for_manual_claim")
&& TESTGEN_DAG.contains("match claim.t19_anchor"),
"concept projection must match on `claim.t19_anchor` (single authority path with manual claim)"
&& TESTGEN_DAG.contains("match test_claim_t19_anchor(c: claim)"),
"concept projection must match on `test_claim_t19_anchor(c: claim)` (single authority path with manual claim)"
);
}

#[test]
fn v4_lens_testgen_wave0_generator_carries_claim_kind_and_classification() {
fn v4_lens_testgen_wave0_generator_carries_claim_classification_and_anchor() {
assert!(
TESTGEN_DAG.contains("classification: claim.classification"),
"Generator must take classification from manual TestClaim"
TESTGEN_DAG.contains("classification: test_claim_classification(c: claim)"),
"Generator must take classification from manual TestClaim via substrate helper"
);
assert!(
TESTGEN_DAG.contains("kind: claim.kind"),
"Generator must take AssertKind from manual TestClaim.kind"
TESTGEN_DAG.contains("t19_anchor: test_claim_t19_anchor(c: claim)"),
"Generator must take T19ManualAnchorKey from manual TestClaim via substrate helper"
);
}

Expand All @@ -204,8 +237,8 @@ fn v4_lens_testgen_wave0_bootstrap_threads_claim_anchor_into_generator() {
"bootstrap must not use a mirrored present-key conversion helper"
);
assert!(
TESTGEN_DAG.contains("t19_anchor: claim.t19_anchor"),
"Generator must wire `t19_anchor` from the manual `TestClaim` row (single authority)"
TESTGEN_DAG.contains("t19_anchor: test_claim_t19_anchor(c: claim)"),
"Generator must wire `t19_anchor` from the manual `TestClaim` row via substrate helper (single authority)"
);
assert!(
TESTGEN_DAG.contains("match testgen_concept_for_manual_claim(claim: claim)"),
Expand All @@ -231,20 +264,9 @@ fn v4_lens_testgen_testgen_carries_six_nat_algebra_law_scheduling_arms() {
fn assert_nat_manual_claim_blocks_use_compiles_stub(nat_law_src: &str) {
for claim in NAT_MANUAL_CLAIM_DATA {
let block = nat_law_manual_claim_data_block(nat_law_src, claim);
let kind_lines: Vec<&str> = block
.lines()
.map(str::trim)
.filter(|l| l.starts_with("kind:"))
.collect();
assert_eq!(
kind_lines.len(),
1,
"{claim}: expected exactly one `kind:` field in this `data` block; got {kind_lines:?}"
);
assert!(
kind_lines[0].starts_with("kind: Compiles"),
"{claim}: nat-law manual stubs use placeholder `input`/`expected`; `kind` must stay `Compiles` until T-22 law-shaped `Node` obligations land (codex #14833); got {:?}",
kind_lines[0]
block.contains("CompilesClaim {"),
"{claim}: nat-law manual stubs use placeholder `input`/`expected_value`; variant must stay `CompilesClaim` until T-22 law-shaped `Node` obligations land"
);
}
}
Expand Down Expand Up @@ -407,6 +429,19 @@ fn type_is_generator_testgen_concept(ty: &SurfaceType) -> bool {
)
}

fn type_is_outcome_outcome_named(ty: &SurfaceType, inner_name: &str) -> bool {
let SurfaceType::Parameterized { name, args, .. } = ty else {
return false;
};
if name != "Outcome" || args.len() != 1 {
return false;
}
let TypeAngleArg::TypeExpr { ty: outer_inner } = &args[0] else {
return false;
};
type_is_outcome_named(outer_inner.as_ref(), inner_name)
}

fn type_is_outcome_named(ty: &SurfaceType, inner_name: &str) -> bool {
let SurfaceType::Parameterized { name, args, .. } = ty else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ fn t22_eval_diagnostic_assert_not_deferred_in_substrate() {
"removed deferred scaffold must not return"
);
assert!(
EVAL_DAG.contains("DiagnosticAssert => match actual"),
"DiagnosticAssert must execute, not defer"
EVAL_DAG.contains("DiagnosticClaim { expected_rejection: expected")
&& EVAL_DAG.contains("Rejected { diagnostics: expected }"),
"DiagnosticClaim must execute with polarity-specific rejection carrier (P2)"
);
assert!(
EVAL_DAG.contains("verdict: aggregate_verdicts(") && EVAL_DAG.contains("rs: ["),
"run_test_claim must route through aggregate_verdicts"
);
assert!(
EVAL_DAG.contains("CompilesClaim { expected_value: expected")
&& EVAL_DAG.contains("Accepted { value: expected, diagnostics: None }"),
"CompilesClaim must compare actual against declared accepted Node (P2/P3 fail-closed)"
);
assert!(
EVAL_DAG.contains("RoundTripClaim { input: input")
&& EVAL_DAG.contains("Deferred {")
&& EVAL_DAG.contains("eval_rejected_roundtrip_deferred"),
"RoundTripClaim eval authority must stay Deferred (single authority; verification must not synthesize expected Outcome<Node>)"
);
}

#[test]
Expand All @@ -73,11 +85,10 @@ fn t19_testgen_concept_surface_stays_closed_and_classified() {
record_field_type_map(type_record(&module, "Generator")),
expected_field_type_map(&[
("classification", "TestClassification"),
("kind", "AssertKind"),
("t19_anchor", "T19ManualAnchorKey"),
("slot", "C"),
]),
"Generator<C> must carry the claim kind, anchor, classification, and parameterized slot"
"Generator<C> must carry anchor, classification, and parameterized slot (assertion shape lives on TestClaim coproduct)"
);
}

Expand All @@ -92,16 +103,16 @@ fn t19_manual_manifest_matches_claim_anchor_discriminants() {

assert_eq!(
manifest_keys.len(),
12,
"T-19 manifest is the twelve live anchors"
17,
"T-19 manifest is the seventeen live anchors"
);
assert_eq!(
claim_keys, manifest_keys,
"manual TestClaim.t19_anchor values must join to the manifest by the same T19ManualAnchorKey discriminants"
);
assert!(
!claim_keys.contains("T19ManualAnchorAbsent"),
"the twelve live manual anchors must not route through the absent sentinel"
"the seventeen live manual anchors must not route through the absent sentinel"
);
}

Expand Down Expand Up @@ -190,21 +201,56 @@ fn t20_bootstrap_plan_keeps_self_hosting_chain_as_data() {
record_field_expr(bootstrap_plan_fields, "self1"),
&["v4_dag_source", "v4_stage1_binary"],
"v4_stage2_binary",
("v4_stage2_hash", "v4_stage2_hash_pin"),
("v4_stage1_hash", "v4_stage2_hash_pin"),
"v4_stage1_binary",
);
assert_fixpt(
record_field_expr(bootstrap_plan_fields, "fixpt"),
"v4_stage1_binary",
("v4_stage1_hash", "v4_stage1_hash_pin"),
"v4_stage2_binary",
("v4_stage2_hash", "v4_stage2_hash_pin"),
(
"pinned_v4_fixed_point_hash",
"pinned_v4_fixed_point_hash_pin",
),
("v4_stage1_hash", "v4_stage2_hash_pin"),
("v4_stage1_hash", "pinned_v4_fixed_point_hash_pin"),
"bit_identical_check",
);
assert!(
BOOTSTRAP_DAG.contains("data v4_stage2_hash: Hash = v4_stage2_hash")
&& BOOTSTRAP_DAG.contains(
"data pinned_v4_fixed_point_hash: Hash = pinned_v4_fixed_point_hash"
),
"bootstrap must declare stage-2 and pinned digest carriers as independent Hash facts (A2+A3)"
);
assert!(
BOOTSTRAP_DAG.contains("p.self0.produces_hash.digest == p.self1.produces_hash.digest")
&& BOOTSTRAP_DAG
.contains("p.fixpt.left_hash.digest == p.self0.produces_hash.digest")
&& BOOTSTRAP_DAG
.contains("p.fixpt.right_hash.digest == p.self1.produces_hash.digest")
&& BOOTSTRAP_DAG
.contains("p.fixpt.pinned_hash.digest == p.self0.produces_hash.digest"),
"bootstrap_plan_well_formed must enforce digest convergence via stage outputs, not data aliases (A2+A3)"
);
assert!(
!BOOTSTRAP_DAG.contains("p.fixpt.left_hash.pin == p.fixpt.right_hash.pin")
&& !BOOTSTRAP_DAG.contains("p.fixpt.left_hash.pin == p.fixpt.pinned_hash.pin"),
"fixpt pins identify independent carrier slots; digest equality proves convergence (A2+A3)"
);
const CONNECTIVE_ANCHORS: &str =
include_str!("../../../../v4/test/claim/manual/connective_anchors.dag");
assert!(
CONNECTIVE_ANCHORS.contains("claim_arrow_empty_rejected")
&& CONNECTIVE_ANCHORS.contains("claim_transform_empty_rejected")
&& CONNECTIVE_ANCHORS.contains("claim_branch_empty_rejected")
&& CONNECTIVE_ANCHORS.contains("claim_loop_empty_rejected")
&& CONNECTIVE_ANCHORS.contains("claim_bind_zero_children_rejected"),
"A1 arity gate must pin rejection receipts for Arrow/Transform/Branch/Loop/Bind shapes (TESTING.md regression discipline)"
);
assert!(
BOOTSTRAP_DAG.contains("bootstrap_plan_fixpt_digest_mismatch_rejects")
&& BOOTSTRAP_DAG.contains("produces_hash: BootstrapHashPin { digest: v4_stage2_hash, pin: v4_stage2_hash_pin")
&& BOOTSTRAP_DAG.contains("right_hash: BootstrapHashPin { digest: v4_stage2_hash, pin: v4_stage2_hash_pin"),
"mismatch regression must wire stage-2 and fixpt.right through v4_stage2_hash (not an unrelated seed digest)"
);
}

fn parse_module(source: &str, file: &str) -> SurfaceModule {
Expand Down Expand Up @@ -326,19 +372,39 @@ fn claim_anchor_values<'a>(modules: &[&'a SurfaceModule]) -> BTreeSet<&'a str> {
.filter_map(|item| match item {
SurfaceItem::Data {
ty: SurfaceType::Named { name: ty_name, .. },
body: Some(SurfaceExpr::VariantRecord { fields, .. }),
body: Some(body),
..
} if ty_name == "TestClaim" => match record_field_expr(fields, "t19_anchor") {
SurfaceExpr::Var { name, .. } => Some(name.as_str()),
other => {
panic!("TestClaim.t19_anchor must be a discriminant var, got {other:?}")
}
},
} if ty_name == "TestClaim" => Some(claim_t19_anchor_name(body)),
_ => None,
})
.collect()
}

fn claim_t19_anchor_name(body: &SurfaceExpr) -> &str {
let anchor_expr = match body {
SurfaceExpr::VariantRecord { fields, .. } => record_field_expr(fields, "t19_anchor"),
SurfaceExpr::Call { target, args, .. } if target == "arity_rejection_claim" => {
let SurfaceExpr::Record { fields, .. } = args
.first()
.unwrap_or_else(|| panic!("arity_rejection_claim must take one named-arg record"))
else {
panic!(
"arity_rejection_claim args must desugar to Record, got {:?}",
args.first()
);
};
record_field_expr(fields, "anchor")
}
other => panic!(
"TestClaim data body must be variant record or arity_rejection_claim, got {other:?}"
),
};
match anchor_expr {
SurfaceExpr::Var { name, .. } => name.as_str(),
other => panic!("TestClaim.t19_anchor must be a discriminant var, got {other:?}"),
}
}

fn record_field_expr<'a>(fields: &'a [SurfaceRecordField], name: &str) -> &'a SurfaceExpr {
fields
.iter()
Expand Down
Loading
Loading