Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b77801f
feat(v2.5): add phase-typed stage interface kit (Tier 1)
briansrls May 19, 2026
2fd209d
refine(v2.5): reconcile calm-crane-724 normalize seam in stage_types
briansrls May 19, 2026
7812bee
refine(v2.5): align Tier 1 stage_types with Tier 0 node.dag (PR #3422)
briansrls May 19, 2026
46a1a44
refine(v2.5): add EmitStageOut and TargetSource stage port (Tier 1)
briansrls May 19, 2026
3f05b7a
Merge remote-tracking branch 'origin/main' into session/vivid-lynx-807
briansrls May 20, 2026
dfb926f
fix(v2.5): reconcile Tier 1 with PR #3422 THESIS-faithful substrate
briansrls May 20, 2026
625afdd
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls May 19, 2026
ab0e151
Align v2.5 infer prototype with edge-shaped children
briansrls May 19, 2026
531215f
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls May 19, 2026
4b31bba
Fail closed v2.5 infer call and match typing
briansrls May 19, 2026
732177d
Use value-list helper for list inference
briansrls May 19, 2026
bad798d
Fail closed let scope and block diagnostics
briansrls May 20, 2026
6ec7c4c
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls May 20, 2026
734b85c
Close infer prototype boundary gaps
briansrls May 20, 2026
be2f591
Fail closed binder folds and preserve function diagnostics
briansrls May 20, 2026
5f0994c
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls May 20, 2026
948cd92
Reconcile v2.5 infer with tier1 stage types
briansrls May 20, 2026
de13dc8
Emit distinct infer unavailable markers
briansrls May 20, 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
83 changes: 83 additions & 0 deletions src/v2.5/04_infer.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module v2_5.compiler.infer

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 new stage imports v2_5.std.node and v2_5.std.stage_types, but the supplied diff adds only this file and origin/main has no src/v2.5/std blobs, so the PR introduces an unresolved module boundary.

import v2_5.std.node { Symbol }
import v2_5.std.stage_types {
NormalizedModule,
InferredModule,
InferredOtherItem
}

type ExprDataDissolution
= NoExprDataRetired
| LiteralCase
| ErrorCase
| VarCase
| FieldAccessCase
| CallCase
| MethodCallCase
| MatchCase
| IfCase
| LetCase
| RecordLitCase
| ListLitCase
| BinOpCase
| UnaryOpCase
| LambdaCase
| StringInterpCase
| BlockCase
| CastCase
| ForEachCase
| IndexCase
| SliceCase
| ReturnCase

type InferCarrierClosure
= ClosedExprDataDissolution
| ClosedInferReadiness
| ClosedBinderScopeFold
| ClosedRecursiveExprFold

type InferReadiness
= AwaitingTier1StageTypes { gate: Symbol }
| AwaitingRecursiveExprFold { gate: Symbol }
| BoundToTier1StageTypes

type BinderScopeFold
= AwaitingPreChildScopeHook { gate: Symbol }
| HasPreChildScopeHook

data v25_infer_tier1_gate: Symbol = v25_infer_tier1_gate
data recursive_expr_fold_gate: Symbol = recursive_expr_fold_gate
data binder_scope_fold_gate: Symbol = binder_scope_fold_gate

data infer_readiness: InferReadiness = AwaitingRecursiveExprFold { gate: recursive_expr_fold_gate }
data binder_scope_fold_status: BinderScopeFold = AwaitingPreChildScopeHook { gate: binder_scope_fold_gate }
data infer_carrier_closure: List<InferCarrierClosure> = [
ClosedExprDataDissolution,
ClosedInferReadiness,
ClosedBinderScopeFold,
ClosedRecursiveExprFold
]

fn infer(module: NormalizedModule) -> InferredModule {
match infer_readiness {
AwaitingTier1StageTypes { gate: _ } =>
infer_unavailable(module: module, keyword: "infer-awaiting-tier1-stage-types")
AwaitingRecursiveExprFold { gate: _ } =>
infer_unavailable(module: module, keyword: "infer-awaiting-recursive-expression-fold")
BoundToTier1StageTypes =>
infer_unavailable(module: module, keyword: "infer-bound-without-recursive-expression-fold")
}
}

fn infer_unavailable(module: NormalizedModule, keyword: String) -> InferredModule {
InferredModule {
name: module.name,
imports: [],
items: [InferredOtherItem {
keyword: keyword,
raw_span: module.span
}],
span: module.span
}
}
42 changes: 42 additions & 0 deletions src/v2.5/std/diagnostic.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// src/v2.5/std/diagnostic.dag
// Scope: fail-closed diagnostic schema for v2.5.
// Owns: Diagnostic, Outcome, Locus, Extent, Correction, NoCorrectionReason.
// Consumes: v2_5.std.node.
// Status: v2.5 Tier 0 draft.

module v2_5.std.diagnostic

import v2_5.std.node { Symbol, Nat, Node, Path }

// 🟡 coproduct dissolution — feature:byte-range-ordering-witness
type Extent
= WholeFile
| ByteRange { start: Nat, end: Nat }

// 🟢 coproduct dissolution
type Locus
= Textual { file: Symbol, extent: Extent }
| NodeLocus { node: Node }
| PortLocus { path: Path }

// 🟢 coproduct dissolution
type NoCorrectionReason
= UserInputBoundary
| AmbiguousIntent
| ExternalContractUnknown

// 🟢 coproduct dissolution
type Correction
= Suggested { node: Node }
| Unavailable { reason: NoCorrectionReason }

type Diagnostic {
reason: Symbol
at: Locus
correction: Correction
}

// 🟢 coproduct dissolution
type Outcome<T>
= Produced { value: T }
| Rejected { diagnostic: Diagnostic }
22 changes: 22 additions & 0 deletions src/v2.5/std/identity.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// v2.5 identity and provenance — shared across all pipeline phases.
// Parse phases use AuthoredName; post-resolve phases use Symbol (from node).

module v2_5.std.identity

import v2_5.std.node { Symbol }

type SourceSpan {
start: Int
end: Int
file: String
}

type AuthoredName {
text: String
span: SourceSpan
}

type BoundName {
symbol: Symbol
span: SourceSpan
}
146 changes: 146 additions & 0 deletions src/v2.5/std/node.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// src/v2.5/std/node.dag
// Scope: v2.5 substrate root — type kernel for the forked tree.
// Owns: Symbol, Hash, Nat, Connective, Behavior, NodeKind, EdgeLabel, Edge, Node, NodeFold, fold_node, EdgeDiscipline, connective_edge_discipline, all_edges_named, all_edges_positional, name_occurrences, all_names_distinct, edges_conform, node_locally_well_formed, node_well_formed, PathStep, Path, Edit, Diff.
// Consumes: none.
// Status: v2.5 Tier 0 draft.

module v2_5.std.node

type Symbol
type Hash
type Nat

// 🟢 coproduct dissolution
type Connective
= Atom { identity: Symbol }
| Conj
| Disj
| Arrow
| Cardinality
| Instantiation

// 🟢 coproduct dissolution
type Behavior
= Value
| Transform
| Branch
| Loop
| Bind

// 🟢 coproduct dissolution
type NodeKind
= TypeForm { connective: Connective }
| Computation { behavior: Behavior }

// 🟢 coproduct dissolution
type EdgeLabel
= Named { name: Symbol }
| Positional

type Edge {
label: EdgeLabel
target: Node
}

type Node {
kind: NodeKind
children: List<Edge>
}

type NodeFold<R> {
init: fn(Node) -> R
step: fn(R, Edge, R) -> R
}

fn fold_node<R>(n: Node, algebra: NodeFold<R>) -> R {
fold(n.children, init: algebra.init(n), f: (acc, e) =>
algebra.step(acc, e, fold_node(n: e.target, algebra: algebra))
)
}

// 🟢 coproduct dissolution
type EdgeDiscipline
= NoEdges
| LabeledEdges
| PositionalEdges

fn connective_edge_discipline(c: Connective) -> EdgeDiscipline {
match c {
Atom { identity: _ } => NoEdges
Conj => LabeledEdges
Disj => LabeledEdges
Arrow => PositionalEdges
Cardinality => PositionalEdges
Instantiation => PositionalEdges
}
}

fn all_edges_named(children: List<Edge>) -> Bool {
fold(children, init: true, f: (acc, e) => match e.label {
Named { name: _ } => acc
Positional => false
})
}

fn all_edges_positional(children: List<Edge>) -> Bool {
fold(children, init: true, f: (acc, e) => match e.label {
Named { name: _ } => false
Positional => acc
})
}

fn name_occurrences(name: Symbol, children: List<Edge>) -> Int {
fold(children, init: 0, f: (acc, e) => match e.label {
Named { name: n } => if n == name { acc + 1 } else { acc }
Positional => acc
})
}

fn all_names_distinct(children: List<Edge>) -> Bool {
fold(children, init: true, f: (acc, e) => match e.label {
Named { name: n } => acc && (name_occurrences(name: n, children: children) == 1)
Positional => acc
})
}

fn edges_conform(children: List<Edge>, d: EdgeDiscipline) -> Bool {
match d {
NoEdges => count(children) == 0
LabeledEdges =>
all_edges_named(children: children) && all_names_distinct(children: children)
PositionalEdges => all_edges_positional(children: children)
}
}

fn node_locally_well_formed(n: Node) -> Bool {
match n.kind {
TypeForm { connective: c } =>
edges_conform(children: n.children, d: connective_edge_discipline(c: c))
Computation { behavior: _ } => true
}
}

fn node_well_formed(n: Node) -> Bool {
fold_node(n: n, algebra: NodeFold {
init: n0 => node_locally_well_formed(n: n0),
step: (acc, edge, child_ok) => acc && child_ok
})
}

// 🟢 coproduct dissolution
type PathStep
= NamedStep { name: Symbol }
| PositionalStep { index: Nat }

type Path {
steps: List<PathStep>
}

type Edit {
at: Path
replacement: Node
}

type Diff {
edits: List<Edit>
}
Loading
Loading