Repository navigation
Add v2.5 infer stage prototype #3425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
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 2fd209d
refine(v2.5): reconcile calm-crane-724 normalize seam in stage_types
briansrls 7812bee
refine(v2.5): align Tier 1 stage_types with Tier 0 node.dag (PR #3422)
briansrls 46a1a44
refine(v2.5): add EmitStageOut and TargetSource stage port (Tier 1)
briansrls 3f05b7a
Merge remote-tracking branch 'origin/main' into session/vivid-lynx-807
briansrls dfb926f
fix(v2.5): reconcile Tier 1 with PR #3422 THESIS-faithful substrate
briansrls 625afdd
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls ab0e151
Align v2.5 infer prototype with edge-shaped children
briansrls 531215f
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls 4b31bba
Fail closed v2.5 infer call and match typing
briansrls 732177d
Use value-list helper for list inference
briansrls bad798d
Fail closed let scope and block diagnostics
briansrls 6ec7c4c
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls 734b85c
Close infer prototype boundary gaps
briansrls be2f591
Fail closed binder folds and preserve function diagnostics
briansrls 5f0994c
WIP: v2 stage rework — 04_INFER_CONSOLIDATED.dag — 13 files into one …
briansrls 948cd92
Reconcile v2.5 infer with tier1 stage types
briansrls de13dc8
Emit distinct infer unavailable markers
briansrls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| module v2_5.compiler.infer | ||
|
|
||
| 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 | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.