Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a7baf50
WIP: keen-swift-519
briansrls May 2, 2026
cd79042
WIP: keen-swift-519
briansrls May 2, 2026
8b3afba
WIP: keen-swift-519
briansrls May 2, 2026
917f305
WIP: keen-swift-519
briansrls May 2, 2026
ceca2ab
chore: apply cargo fmt
briansrls May 2, 2026
6eeee7d
WIP: keen-swift-519
briansrls May 2, 2026
6c19aa1
WIP: keen-swift-519
briansrls May 2, 2026
6e05ca8
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 2, 2026
9f8db0b
chore(v3-compiler): refresh SG-2 manifest hash for approximate_field.dag
briansrls May 2, 2026
f0ca6df
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 2, 2026
97e9cf9
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
0b7cd5c
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
2d4eaf8
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
73188df
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
7edbcc3
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
5231a19
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
8ede55e
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
4308c48
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
0474988
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
c641c77
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
54f7f4a
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
49072a8
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
c62c2a0
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
12dbf29
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
f29a0c3
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
a776c4c
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
db63d7c
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
1c1d434
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
0c4f604
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
30dab0f
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
0b269c7
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
65ad18e
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
337494b
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
9d12fb2
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
6d8ca1a
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
6ed1c08
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
4544ea4
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
8b09cc1
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
74bc4b9
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
05f52fd
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
f9d51c0
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 3, 2026
7c0680d
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
b2780e7
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
03c873d
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
b46bced
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
5741f3a
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
53c036f
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
931c12a
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
47ab3a8
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
1556c1f
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
7483888
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
577e235
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
9225b20
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
fb04211
WIP: keen-swift-519
briansrls May 4, 2026
9582177
chore: apply cargo fmt
briansrls May 4, 2026
8a7a6f0
WIP: keen-swift-519
briansrls May 4, 2026
cf94fad
WIP: keen-swift-519
briansrls May 4, 2026
d05f3ce
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
0f27c28
WIP: keen-swift-519
briansrls May 4, 2026
4bf2561
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
c2a48f5
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
b400015
WIP: keen-swift-519
briansrls May 4, 2026
9c1ea8a
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
fedc3aa
WIP: keen-swift-519
briansrls May 4, 2026
eb3b930
WIP: keen-swift-519
briansrls May 4, 2026
0d66ecc
WIP: keen-swift-519
briansrls May 4, 2026
536aa9c
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
9fa0d4f
WIP: keen-swift-519
briansrls May 4, 2026
12875fb
WIP: keen-swift-519
briansrls May 4, 2026
0a53705
WIP: keen-swift-519
briansrls May 4, 2026
5e423c1
Merge remote-tracking branch 'origin/main' into topic/t-numeric-appro…
briansrls May 4, 2026
8747367
WIP: keen-swift-519
briansrls May 4, 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
2,754 changes: 1,431 additions & 1,323 deletions src/v3/compiler/src/bootstrap_generated.rs

Large diffs are not rendered by default.

2,334 changes: 1,221 additions & 1,113 deletions src/v3/compiler/src/bootstrap_generated_without_parse_surface.rs

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/v3/compiler/src/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ impl PortId {
}
}

#[cfg(test)]
impl PortId {
pub(crate) const fn test_raw(raw: u32) -> Self {
Self(raw)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DeclarationId(u32);

Expand All @@ -159,6 +166,13 @@ impl DeclarationId {
}
}

#[cfg(test)]
impl DeclarationId {
pub(crate) const fn test_raw(raw: u32) -> Self {
Self(raw)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ClusterId(u32);

Expand Down
145 changes: 145 additions & 0 deletions src/v3/compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,60 @@ pub enum Diagnostic {
},
}

/// Layer-1 compiler diagnostic kind labels in **declaration order** of [`Diagnostic`].
///
/// This is the **only** source of label strings for [`Diagnostic::layer1_kind_label`], which
/// indexes this slice using an exhaustive per-variant index match (no wildcard). Crate tests assert
/// the declaration-order fixture matches those indices; integration tests ratchet
/// `CompilerDiagnosticKind` / `std.verification.DiagnosticKind` in the bootstrap DAG against this
/// slice. When adding a [`Diagnostic`] variant, extend this list, add an index arm next to
/// `layer1_kind_label`, and update the `.dag` closed sums — lens-instance kinds stay on the
/// Layer-2 path (Q6.5), not here.
pub const LAYER1_DIAGNOSTIC_KIND_LABELS: &[&str] = &[
"TokenizerError",
"ParseError",
"TypeMismatch",
"ArityMismatch",
"ResolveError",
"UnitMismatch",
"BranchConditionNotBool",
"MagnitudeOutOfRange",
"MalformedIntegerRangeFact",
"NominalOpacityViolation",
];

impl Diagnostic {
/// Zero-based declaration index for Layer-1 kind strings (same order as [`Diagnostic`] and
/// [`LAYER1_DIAGNOSTIC_KIND_LABELS`]).
///
/// This match is **exhaustive with no wildcard**: adding a [`Diagnostic`] variant is a compile
/// error until a new arm is authored here **and** [`LAYER1_DIAGNOSTIC_KIND_LABELS`] is extended
/// by one entry. [`Diagnostic::layer1_kind_label`] reads only from that slice, so the label
/// strings have a single authority.
fn layer1_declaration_index(&self) -> usize {
match self {
Diagnostic::TokenizerError { .. } => 0,
Diagnostic::ParseError { .. } => 1,
Diagnostic::TypeMismatch { .. } => 2,
Diagnostic::ArityMismatch { .. } => 3,
Diagnostic::ResolveError { .. } => 4,
Diagnostic::UnitMismatch { .. } => 5,
Diagnostic::BranchConditionNotBool { .. } => 6,
Diagnostic::MagnitudeOutOfRange { .. } => 7,
Diagnostic::MalformedIntegerRangeFact { .. } => 8,
Diagnostic::NominalOpacityViolation { .. } => 9,
}
}

/// Stable Layer-1 kind name for substrate mirrors and test predicates (Q6.5).
///
/// Labels come only from [`LAYER1_DIAGNOSTIC_KIND_LABELS`]; an exhaustive per-variant index
/// match selects the row so new enum variants cannot compile without extending the const slice
/// and substrate closed sums.
pub fn layer1_kind_label(&self) -> &'static str {
LAYER1_DIAGNOSTIC_KIND_LABELS[self.layer1_declaration_index()]
}

pub fn span(&self) -> &SourceSpan {
match self {
Diagnostic::TokenizerError { span, .. }
Expand Down Expand Up @@ -816,6 +869,98 @@ impl DiagnosticTable {
#[cfg(test)]
mod tests {
use super::*;
use crate::types::TypeShape;

fn layer1_diagnostic_examples_in_declaration_order() -> Vec<Diagnostic> {
let span = SourceSpan::new("layer1_kind_label_ratchets.v3", 0, 0);
let fixes = Vec::new();
let ty = TypeShape::new(DeclarationId::test_raw(0));
vec![
Diagnostic::TokenizerError {
message: String::new(),
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::ParseError {
message: String::new(),
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::TypeMismatch {
expected: ty,
actual: ty,
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::ArityMismatch {
function: String::new(),
expected: 0,
actual: 0,
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::ResolveError {
name: String::new(),
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::UnitMismatch {
operator: String::new(),
parameter: String::new(),
expected: ty,
actual: ty,
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::BranchConditionNotBool {
port: PortId::test_raw(0),
actual_type: None,
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::MagnitudeOutOfRange {
literal: String::new(),
target: String::new(),
range_min_inclusive: String::new(),
range_max_inclusive: String::new(),
expected: ty,
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::MalformedIntegerRangeFact {
message: String::new(),
span: span.clone(),
fixes: fixes.clone(),
},
Diagnostic::NominalOpacityViolation {
declaration: DeclarationId::test_raw(0),
accessor: None,
span,
fixes,
},
]
}

#[test]
fn layer1_ordered_labels_match_layer1_kind_label() {
let examples = layer1_diagnostic_examples_in_declaration_order();
assert_eq!(
examples.len(),
LAYER1_DIAGNOSTIC_KIND_LABELS.len(),
"declaration-order fixture must list every Diagnostic variant exactly once"
);
let mut seen = std::collections::HashSet::new();
for (i, diag) in examples.iter().enumerate() {
let idx = diag.layer1_declaration_index();
assert_eq!(
idx, i,
"fixture must stay in declaration order and match layer1_declaration_index()"
);
let label = diag.layer1_kind_label();
assert_eq!(label, LAYER1_DIAGNOSTIC_KIND_LABELS[i]);
assert!(seen.insert(label), "duplicate layer1 label: {label}");
}
}

#[test]
fn apply_correction_replaces_the_requested_span() {
Expand Down
2 changes: 1 addition & 1 deletion src/v3/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3365,7 +3365,7 @@ pub(crate) mod workflow_idempotency;
pub(crate) mod workflow_parallelism;

pub use dag::{Dag, NodeId};
pub use diagnostics::{Diagnostic, SourceSpan};
pub use diagnostics::{Diagnostic, SourceSpan, LAYER1_DIAGNOSTIC_KIND_LABELS};
pub use emit::{EmitDispatchError, EmitMode, EmitTarget, EmittedSource};
pub use emit_rust::EmitError;
/// Lane 2 Stage 2b — supported public surface: [`analyze_workflow`] is the
Expand Down
17 changes: 1 addition & 16 deletions src/v3/compiler/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3905,26 +3905,11 @@ fn find_bind<'a>(
})
}

fn diagnostic_kind(diagnostic: &Diagnostic) -> &'static str {
match diagnostic {
Diagnostic::TokenizerError { .. } => "TokenizerError",
Diagnostic::ParseError { .. } => "ParseError",
Diagnostic::TypeMismatch { .. } => "TypeMismatch",
Diagnostic::UnitMismatch { .. } => "UnitMismatch",
Diagnostic::ArityMismatch { .. } => "ArityMismatch",
Diagnostic::ResolveError { .. } => "ResolveError",
Diagnostic::BranchConditionNotBool { .. } => "BranchConditionNotBool",
Diagnostic::MagnitudeOutOfRange { .. } => "MagnitudeOutOfRange",
Diagnostic::MalformedIntegerRangeFact { .. } => "MalformedIntegerRangeFact",
Diagnostic::NominalOpacityViolation { .. } => "NominalOpacityViolation",
}
}

fn diagnostic_matches_reference(
diagnostic: &Diagnostic,
reference: &(String, DiagnosticDetailFilter),
) -> bool {
diagnostic_kind(diagnostic) == reference.0
diagnostic.layer1_kind_label() == reference.0
&& match &reference.1 {
DiagnosticDetailFilter::Any => true,
DiagnosticDetailFilter::Contains(text) => diagnostic.message().contains(text),
Expand Down
43 changes: 22 additions & 21 deletions src/v3/compiler/tests/integration/lens_substrate_carrier_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
//! shape (`name`, `read`, `sequential: Monoid<C>`, `branch`, `iterate`,
//! `validate`).
//! - `Diagnostic.kind` widens from `CompilerDiagnosticKind` to
//! `AnyDiagnosticKind`; the Layer-1 closed sum stays unchanged.
//! `AnyDiagnosticKind`; the Layer-1 closed sum tracks the compiler's
//! native `Diagnostic` taxonomy, ratcheted via `LAYER1_DIAGNOSTIC_KIND_LABELS`.
//! - `LensInstanceKindWitness` is decl-only (no payload value field)
//! until refinement/dependent typing lands; this is the explicit
//! substrate gap receipt.
Expand All @@ -17,7 +18,7 @@ use std::collections::HashSet;

use crate::common::cached_compile_to_dag;
use v3_compiler::dag::{ArrowBody, Dag, DeclarationId, TypeConnective};
use v3_compiler::generated_full_bootstrap_dag;
use v3_compiler::{generated_full_bootstrap_dag, LAYER1_DIAGNOSTIC_KIND_LABELS};

fn conj_field_labels(dag: &Dag, name: &str) -> Vec<String> {
let decl = dag
Expand Down Expand Up @@ -123,28 +124,28 @@ fn diagnostic_kind_widened_to_any_diagnostic_kind() {
}

#[test]
fn compiler_diagnostic_kind_closed_sum_unchanged() {
fn compiler_diagnostic_kind_matches_rust_layer1_authority() {
let dag = generated_full_bootstrap_dag();
let variants: HashSet<String> = disj_variant_labels(&dag, "CompilerDiagnosticKind")
.into_iter()
.collect();
let expected: HashSet<&str> = [
"TokenizerError",
"ParseError",
"TypeMismatch",
"UnitMismatch",
"ArityMismatch",
"ResolveError",
"NominalOpacityViolation",
]
.into_iter()
.collect();
let actual: HashSet<&str> = variants.iter().map(String::as_str).collect();
let substrate = disj_variant_labels(&dag, "CompilerDiagnosticKind");
let expected: Vec<&str> = LAYER1_DIAGNOSTIC_KIND_LABELS.to_vec();
let actual: Vec<&str> = substrate.iter().map(String::as_str).collect();
assert_eq!(
actual, expected,
"CompilerDiagnosticKind closed sum changed — Layer-1 must stay locked; \
lens-instance kinds enter via Layer-2 LensInstanceKindWitness, NOT \
by extending this sum (anti-bridge invariant per Q6.5)"
"CompilerDiagnosticKind must match `LAYER1_DIAGNOSTIC_KIND_LABELS` in **declaration order** \
(same order as `Diagnostic` in diagnostics.rs); a HashSet-only check would miss order \
drift; lens-instance kinds use Layer-2 LensInstanceKindWitness (Q6.5 anti-bridge)"
);
}

#[test]
fn verification_diagnostic_kind_mirrors_compiler_diagnostic_kind() {
let dag = generated_full_bootstrap_dag();
let compiler = disj_variant_labels(&dag, "CompilerDiagnosticKind");
let verification = disj_variant_labels(&dag, "DiagnosticKind");
assert_eq!(
compiler, verification,
"std.verification.DiagnosticKind must mirror std.diagnostics.CompilerDiagnosticKind \
(variant labels and order)"
);
}

Expand Down
17 changes: 1 addition & 16 deletions src/v3/compiler/tests/integration/m1_5_testgen_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ fn diagnostic_detail_filter(dag: &Dag, value: &FieldValue) -> Option<String> {
}

fn match_detail(kind_label: &str, detail_contains: &Option<String>, diag: &Diagnostic) -> bool {
if diagnostic_kind(diag) != kind_label {
if diag.layer1_kind_label() != kind_label {
return false;
}
match detail_contains {
Expand All @@ -469,21 +469,6 @@ fn match_detail(kind_label: &str, detail_contains: &Option<String>, diag: &Diagn
}
}

fn diagnostic_kind(diag: &Diagnostic) -> &'static str {
match diag {
Diagnostic::TokenizerError { .. } => "TokenizerError",
Diagnostic::ParseError { .. } => "ParseError",
Diagnostic::TypeMismatch { .. } => "TypeMismatch",
Diagnostic::UnitMismatch { .. } => "UnitMismatch",
Diagnostic::ArityMismatch { .. } => "ArityMismatch",
Diagnostic::ResolveError { .. } => "ResolveError",
Diagnostic::BranchConditionNotBool { .. } => "BranchConditionNotBool",
Diagnostic::MagnitudeOutOfRange { .. } => "MagnitudeOutOfRange",
Diagnostic::MalformedIntegerRangeFact { .. } => "MalformedIntegerRangeFact",
Diagnostic::NominalOpacityViolation { .. } => "NominalOpacityViolation",
}
}

fn diagnostic_detail(diag: &Diagnostic) -> String {
match diag {
Diagnostic::TokenizerError { message, .. } | Diagnostic::ParseError { message, .. } => {
Expand Down
5 changes: 4 additions & 1 deletion src/v3/compiler/tests/integration/m1_5_verification_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ fn bootstrap_loads_verification_authority_types() {
(String::from("TokenizerError"), Vec::new()),
(String::from("ParseError"), Vec::new()),
(String::from("TypeMismatch"), Vec::new()),
(String::from("UnitMismatch"), Vec::new()),
(String::from("ArityMismatch"), Vec::new()),
(String::from("ResolveError"), Vec::new()),
(String::from("UnitMismatch"), Vec::new()),
(String::from("BranchConditionNotBool"), Vec::new()),
(String::from("MagnitudeOutOfRange"), Vec::new()),
(String::from("MalformedIntegerRangeFact"), Vec::new()),
(String::from("NominalOpacityViolation"), Vec::new()),
]
);
Expand Down
5 changes: 4 additions & 1 deletion src/v3/std/diagnostics.dag
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ type CompilerDiagnosticKind
= TokenizerError
| ParseError
| TypeMismatch
| UnitMismatch
| ArityMismatch
| ResolveError
| UnitMismatch
| BranchConditionNotBool
| MagnitudeOutOfRange
| MalformedIntegerRangeFact
| NominalOpacityViolation

// 🟢 TERMINAL for DB-1's source-level correction carrier. Corrections
Expand Down
5 changes: 4 additions & 1 deletion src/v3/std/verification.dag
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ type DiagnosticKind
= TokenizerError
| ParseError
| TypeMismatch
| UnitMismatch
| ArityMismatch
| ResolveError
| UnitMismatch
| BranchConditionNotBool
| MagnitudeOutOfRange
| MalformedIntegerRangeFact
| NominalOpacityViolation

// **🟡 Scaffold — DiagnosticDetailExpectation.** Bootstrap-local bridge
Expand Down
Loading