From 882161aa22294451a8b73c200b73759f5b3d7b14 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 15:44:08 -0400 Subject: [PATCH 01/10] =?UTF-8?q?WIP:=20Ctrl-Migration=20Substrate=20Mgr?= =?UTF-8?q?=20=E2=80=94=20Phase=201=20process=20algebra=20substrate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dsl/std/process_algebra.dag | 275 +++++++++++++++++++++++++++ src/v3/compiler/tests/integration.rs | 8 + 2 files changed, 283 insertions(+) create mode 100644 dsl/std/process_algebra.dag diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag new file mode 100644 index 00000000000..91736f94fbf --- /dev/null +++ b/dsl/std/process_algebra.dag @@ -0,0 +1,275 @@ +// std/process_algebra.dag -- staged process decomposition algebra. +// +// Status: 🟡 STAGED. This file models the ctrl/ decomposition algebra as +// substrate, but it is not runtime authority until the cut-over trio lands: +// emission target consumes it, parity tests match ctrl PRs #1192/#1193/#1195/ +// #1197 behavior, and the ctrl TypeScript implementation is deleted or made +// generated-only. +// +// M9 DFS receipt: +// - Reuses `std.types.Timestamp` / `NonEmptyStr` for time and actor identity. +// - Reuses `std.algebra.FreeMonoid` for append-only event-log shape. +// - Reuses `std.effects.WorkflowEffect` for typed operation effects instead +// of claiming blanket monotonicity. +// - Does not define `Witness`; `v3.std.dimensions.Witness` remains the +// analysis proof carrier. This file's human intent record is `Attestation`. +// - Does not define a bidirectional Lens; `v3.std.lens.Lens` remains the +// analysis carrier for future structural receipts. +// - Keeps workflow phase / run-key facts in `gunbc.workflow.types` orthogonal +// to process decomposition mode. +// +// Current ctrl runtime authority until cut-over: +// - ctrl/lib/dag_schema.mjs +// - ctrl/lib/dag_writes.mjs +// - ctrl/scripts/session-dashboard/dag_api.mjs +// - ctrl PRs #1192/#1193/#1195/#1197. + +module std.process_algebra + +import std.algebra { FreeMonoid } +import std.effects { WorkflowEffect } +import std.types { NonEmptyStr, Timestamp } + +type ProcessNodeId = NonEmptyStr where brand("ProcessNodeId") +type ProcessSessionId = NonEmptyStr where brand("ProcessSessionId") +type ProcessRuleName = NonEmptyStr where brand("ProcessRuleName") +type ProcessEventPosition = Int where range(min: 0), brand("ProcessEventPosition") + +// 🟡 STAGED coproduct — process decomposition shape, mirroring ctrl PR #1192. +// +// Practice 4 receipt: +// - Classification: 🟡 STAGED / mixed. `Leaf`, `Composite`, and `Bucket` +// are durable graph-shape coordinates, while `ModeUndeclared` is a cutoff +// transition state. +// - Dissolution pattern: dimensional + fact-placement. Mode is a projection +// over declared operations and child/drain facts, not a workflow lifecycle +// phase and not a run-keyed pipeline fact. +// - Trigger: when `current_process_mode` is emitted from the event-log fold +// and all pre-cutoff ctrl nodes are closed, `ModeUndeclared` dissolves and +// stored mode becomes projection provenance. +type ProcessNodeMode + = Leaf + | Composite + | Bucket + | ModeUndeclared + +// 🟡 STAGED coproduct — evidence channels attached to a human-authored +// attestation. Kept distinct from `v3.std.dimensions.Witness`. +// +// Practice 4 receipt: +// - Classification: 🟡 STAGED. The three arms are real current evidence +// classes, but the target set can tighten only after emission/parity work +// proves which receipts ctrl actually consumes. +// - Dissolution pattern: fact-placement. Structural lens results should move +// to typed `Lens` / `Witness` references once cross-namespace typed +// declaration refs are available; integration-test and prose receipts remain +// separate human/process facts. +// - Trigger: ctrl cut-over parity names the exact structural lens and test +// receipt carriers; string-name receipt fields are replaced by typed refs. +type AttestationEvidence + = StructuralLensReceipt { lens_name: NonEmptyStr } + | IntegrationTestReceipt { test_name: NonEmptyStr, passed: Bool } + | ProseReceipt { text: NonEmptyStr } + +// 🟡 STAGED record — human/process intent attached to an operation. This is +// not a proof carrier and does not compete with `Witness`. +// +// Dissolution trigger: when ctrl audit-event emission lands, `author`, +// `timestamp`, and `evidence` are populated by emitted audit events rather +// than handwritten API payloads. +type Attestation { + author: ProcessSessionId + text: NonEmptyStr + timestamp: Timestamp + evidence: List +} + +// 🟢 TERMINAL coproduct at Phase-1 scope — explicit closure guard results +// matching ctrl PR #1195. This is fail-closed: every known refusal has a +// distinct inhabitant, including the undeclared post-cutoff and bucket-drain +// cases. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL for this guard surface. Each variant maps to +// a distinct ctrl close guard branch and HTTP/audit behavior. +// - Dissolution pattern rejected: these are not data fields on one refusal; +// callers branch differently on not-found, idempotent close, undeclared +// mode, undrained bucket, and open children. +// - Trigger: none for the Phase-1 guard vocabulary. New ctrl guard reasons +// must extend this sum here first. +type ProcessClosureDecision + = CanClose + | CloseRefused(ProcessClosureRefusal) + +// 🟢 TERMINAL coproduct at Phase-1 scope — refusal reasons are kept separate +// from success so no optional-reason product can represent contradictory +// states. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL. The five refusal variants preserve the +// ctrl `canCloseNode` reason codes without stringly matching. +// - Dissolution pattern rejected: dimensional collapse would hide separate +// repair actions (declare mode, drain bucket, close children, ignore +// already-closed, fix missing node). +// - Trigger: none for PR #1195 parity; future reason codes extend here. +type ProcessClosureRefusal + = ProcessNodeNotFound + | ProcessAlreadyClosed + | ProcessModeNotDeclared + | ProcessBucketNotDrained + | ProcessCompositeHasOpenChildren { open_children: List } + +// 🟢 TERMINAL coproduct — closure eligibility effect per operation. This +// replaces the rejected blanket monotonicity claim with typed per-operation +// behavior. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL. Improve/retract/neutral/override are the +// irreducible closure-eligibility deltas needed by downstream consumers. +// - Dissolution pattern rejected: a Bool or monotonicity tag would collapse +// operator override and ordinary improvement/retraction into one axis. +// - Trigger: none; operation-specific payloads below carry the detailed cause. +type ClosureEligibilityEffect + = ClosureImproves + | ClosureRetracts + | ClosureNeutral + | ClosureOverride + +// 🟡 STAGED record — a typed effect summary is required per operation. The +// `workflow_effect` field reuses the existing effect substrate rather than +// defining a process-local effect hierarchy. +// +// Dissolution trigger: when ctrl HTTP/SQL/audit emission consumes this file, +// operation effect rows are generated from each `ProcessOperation` arm and +// validated against emitted behavior. +type ProcessOperationEffect { + closure_effect: ClosureEligibilityEffect + workflow_effect: WorkflowEffect +} + +type ReopenAttestation { + reason: NonEmptyStr + attestation: Attestation +} + +type RegressionAttestation { + reason: NonEmptyStr + retracted_subtree_signature: NonEmptyStr + attestation: Attestation +} + +// 🟢 TERMINAL coproduct at Phase-1 scope — friendly ctrl operations are closed +// and structurally distinct. Reopen/regress are explicit so closure decisions +// are not assumed monotonic. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL for the decomposition-algebra operation +// vocabulary. Each arm has distinct payload and closure effect. +// - Dissolution pattern rejected: variants are not values of a single generic +// mutation; declare, decompose, drain, replan, escalate, pause, reopen, +// regress, and override have different repair paths and audit payloads. +// - Trigger: none for Phase 1. Adding a ctrl operation must extend this one +// file before REST/SQL/CLI projections can expose it. +type ProcessOperation + = DeclareProcessNode { + node: ProcessNodeId + mode: ProcessNodeMode + attestation: Attestation + effect: ProcessOperationEffect + } + | DecomposeProcessNode { + parent: ProcessNodeId + children: List + attestation: Attestation + effect: ProcessOperationEffect + } + | DrainProcessBucket { + bucket: ProcessNodeId + attestation: Attestation + effect: ProcessOperationEffect + } + | ReplanProcessNode { + node: ProcessNodeId + reason: Attestation + effect: ProcessOperationEffect + } + | EscalateProcessDebt { + from: ProcessNodeId + to_parent: ProcessNodeId + debt: Attestation + effect: ProcessOperationEffect + } + | PauseProcessNode { + node: ProcessNodeId + reason: Attestation + effect: ProcessOperationEffect + } + | ReopenProcessNode { + node: ProcessNodeId + reopen: ReopenAttestation + effect: ProcessOperationEffect + } + | RegressProcessSubtree { + node: ProcessNodeId + retracted_child_ids: List + regression: RegressionAttestation + effect: ProcessOperationEffect + } + | AttestedClosureOverride { + rule: ProcessRuleName + attestation: Attestation + effect: ProcessOperationEffect + } + +// 🟡 STAGED record — append-only event row for replay-as-truth. `position` +// is a monotone sequence witness by convention until a shared MonotonicSeq +// carrier lands. +// +// Dissolution trigger: replace `ProcessEventPosition` with a shared monotonic +// sequence substrate once one exists; then reuse this row as the concrete +// `TimestampedEvent` specialization for process operations. +type ProcessEvent { + position: ProcessEventPosition + timestamp: Timestamp + operation: ProcessOperation +} + +// 🟡 STAGED alias — append-only operation history. This uses `FreeMonoid` +// rather than a process-local log algebra. +// +// Dissolution trigger: when a generic `EventLog` primitive lands, this +// becomes `type ProcessEventLog = EventLog`; until then the +// concrete process log names the same FreeMonoid structure directly. +type ProcessEventLog = FreeMonoid + +// 🟡 STAGED graph snapshot for closure projection. This is the minimum state +// needed by the Phase-1 guard; workflow phase and run-keyed facts remain in +// `gunbc.workflow.types`. +// +// Dissolution trigger: when `state(log: ProcessEventLog)` is emitted, this +// snapshot is generated from the event log and no longer hand-authored. +type ProcessNodeState { + id: ProcessNodeId + mode: ProcessNodeMode + closed_at: Timestamp? + bucket_drained_at: Timestamp? + children: List +} + +type ProcessGraph { + nodes: List +} + +// Projection signatures. Bodies wait for emission/parity work; declaring the +// signature here fixes the substrate boundary that ctrl projections consume. +fn current_process_mode(_graph: ProcessGraph, _node: ProcessNodeId) -> ProcessNodeMode { + host process_algebra_current_mode +} + +fn can_close_process_node( + _graph: ProcessGraph, + _node: ProcessNodeId, + _cutoff: Timestamp +) -> ProcessClosureDecision { + host process_algebra_can_close_node +} diff --git a/src/v3/compiler/tests/integration.rs b/src/v3/compiler/tests/integration.rs index e43f82cf6cd..fa1c545f9bc 100644 --- a/src/v3/compiler/tests/integration.rs +++ b/src/v3/compiler/tests/integration.rs @@ -1082,6 +1082,14 @@ mod parse_stage4_prep { ); } + #[test] + fn handwritten_parser_accepts_process_algebra_dag() { + parse_file( + include_str!("../../../../dsl/std/process_algebra.dag"), + "dsl/std/process_algebra.dag", + ); + } + #[test] fn handwritten_parser_accepts_v3_list_dag() { parse_file(include_str!("../../std/list.dag"), "src/v3/std/list.dag"); From e94163fd1691d25c40d431733a561304c1fd90b8 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 20:08:51 +0000 Subject: [PATCH 02/10] fix process algebra substrate shape --- dsl/std/process_algebra.dag | 77 ++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 91736f94fbf..832b57b69db 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -9,8 +9,9 @@ // M9 DFS receipt: // - Reuses `std.types.Timestamp` / `NonEmptyStr` for time and actor identity. // - Reuses `std.algebra.FreeMonoid` for append-only event-log shape. -// - Reuses `std.effects.WorkflowEffect` for typed operation effects instead -// of claiming blanket monotonicity. +// - Reuses `std.effects.OperationEffect` for layer-local per-operation +// external effect facts instead of importing v3 workflow carriers or +// claiming blanket monotonicity. // - Does not define `Witness`; `v3.std.dimensions.Witness` remains the // analysis proof carrier. This file's human intent record is `Attestation`. // - Does not define a bidirectional Lens; `v3.std.lens.Lens` remains the @@ -27,7 +28,7 @@ module std.process_algebra import std.algebra { FreeMonoid } -import std.effects { WorkflowEffect } +import std.effects { OperationEffect } import std.types { NonEmptyStr, Timestamp } type ProcessNodeId = NonEmptyStr where brand("ProcessNodeId") @@ -35,23 +36,37 @@ type ProcessSessionId = NonEmptyStr where brand("ProcessSessionId") type ProcessRuleName = NonEmptyStr where brand("ProcessRuleName") type ProcessEventPosition = Int where range(min: 0), brand("ProcessEventPosition") -// 🟡 STAGED coproduct — process decomposition shape, mirroring ctrl PR #1192. +// 🟢 TERMINAL coproduct at Phase-1 scope — declared process decomposition +// modes, mirroring ctrl PR #1192's non-null mode values. // // Practice 4 receipt: -// - Classification: 🟡 STAGED / mixed. `Leaf`, `Composite`, and `Bucket` -// are durable graph-shape coordinates, while `ModeUndeclared` is a cutoff -// transition state. -// - Dissolution pattern: dimensional + fact-placement. Mode is a projection -// over declared operations and child/drain facts, not a workflow lifecycle -// phase and not a run-keyed pipeline fact. -// - Trigger: when `current_process_mode` is emitted from the event-log fold -// and all pre-cutoff ctrl nodes are closed, `ModeUndeclared` dissolves and -// stored mode becomes projection provenance. -type ProcessNodeMode +// - Classification: 🟢 TERMINAL for declared modes. Leaf, Composite, and +// Bucket are durable graph-shape coordinates. +// - Dissolution pattern rejected: undeclared/cutoff state is not a mode; it +// lives in `ProcessModeProjection` so declared-mode consumers cannot accept +// a transitional missing declaration as a real declaration. +// - Trigger: none for declared modes. New ctrl declaration modes must extend +// this sum here first. +type DeclaredProcessNodeMode = Leaf | Composite | Bucket - | ModeUndeclared + +// 🟡 STAGED coproduct — current mode projection result. This separates the +// transitional cutoff/null case from durable declarations. +// +// Practice 4 receipt: +// - Classification: 🟡 STAGED. `DeclaredProcessMode` carries durable +// declarations; `ProcessModeUndeclared` preserves post-cutoff failure and +// pre-cutoff grandfathering without polluting declared mode. +// - Dissolution pattern: fact-placement. Undeclared state is a projection +// result over event-log/cutoff facts, not a stored node mode. +// - Trigger: when `current_process_mode` is emitted from the event-log fold +// and all pre-cutoff ctrl nodes are closed, the transitional arm narrows to +// an explicit refusal-only result and stored mode becomes provenance. +type ProcessModeProjection + = DeclaredProcessMode(DeclaredProcessNodeMode) + | ProcessModeUndeclared // 🟡 STAGED coproduct — evidence channels attached to a human-authored // attestation. Kept distinct from `v3.std.dimensions.Witness`. @@ -136,15 +151,15 @@ type ClosureEligibilityEffect | ClosureOverride // 🟡 STAGED record — a typed effect summary is required per operation. The -// `workflow_effect` field reuses the existing effect substrate rather than -// defining a process-local effect hierarchy. +// `external_effect` field reuses the layer-local `std.effects.OperationEffect` +// authority instead of importing v3 workflow carriers into `dsl/std`. // // Dissolution trigger: when ctrl HTTP/SQL/audit emission consumes this file, // operation effect rows are generated from each `ProcessOperation` arm and // validated against emitted behavior. type ProcessOperationEffect { closure_effect: ClosureEligibilityEffect - workflow_effect: WorkflowEffect + external_effect: OperationEffect } type ReopenAttestation { @@ -173,7 +188,7 @@ type RegressionAttestation { type ProcessOperation = DeclareProcessNode { node: ProcessNodeId - mode: ProcessNodeMode + mode: DeclaredProcessNodeMode attestation: Attestation effect: ProcessOperationEffect } @@ -242,6 +257,24 @@ type ProcessEvent { // concrete process log names the same FreeMonoid structure directly. type ProcessEventLog = FreeMonoid +// 🟢 TERMINAL coproduct at Phase-1 scope — mode-specific closure facts. This +// avoids sibling nullable fields that admit impossible states, such as a leaf +// with a bucket-drain timestamp or a bucket with child facts. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL for the closure guard state consumed by +// `can_close_process_node`. +// - Dissolution pattern rejected: nullable sibling fields collapse distinct +// repair paths and admit contradictory states. Each mode owns only the +// facts needed for its closure rule. +// - Trigger: none for PR #1195 parity; new mode-specific closure facts must +// extend the corresponding carrier here. +type ProcessNodeModeState + = LeafState + | CompositeState { open_children: List } + | BucketState { drained_at: Timestamp? } + | UndeclaredState + // 🟡 STAGED graph snapshot for closure projection. This is the minimum state // needed by the Phase-1 guard; workflow phase and run-keyed facts remain in // `gunbc.workflow.types`. @@ -250,10 +283,8 @@ type ProcessEventLog = FreeMonoid // snapshot is generated from the event log and no longer hand-authored. type ProcessNodeState { id: ProcessNodeId - mode: ProcessNodeMode + mode: ProcessNodeModeState closed_at: Timestamp? - bucket_drained_at: Timestamp? - children: List } type ProcessGraph { @@ -262,7 +293,7 @@ type ProcessGraph { // Projection signatures. Bodies wait for emission/parity work; declaring the // signature here fixes the substrate boundary that ctrl projections consume. -fn current_process_mode(_graph: ProcessGraph, _node: ProcessNodeId) -> ProcessNodeMode { +fn current_process_mode(_graph: ProcessGraph, _node: ProcessNodeId) -> ProcessModeProjection { host process_algebra_current_mode } From fd867802434ea1e55240aa4698ae0f407642a685 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 21:06:40 +0000 Subject: [PATCH 03/10] tighten process algebra state sums --- dsl/std/process_algebra.dag | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 832b57b69db..5bcd69a2061 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -257,6 +257,35 @@ type ProcessEvent { // concrete process log names the same FreeMonoid structure directly. type ProcessEventLog = FreeMonoid +// 🟢 TERMINAL coproduct at Phase-1 scope — bucket drain state. Avoids using +// `Timestamp?` for a state that callers branch on structurally. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL. Drained and not-drained are the two states +// the ctrl closure guard distinguishes for buckets. +// - Dissolution pattern rejected: nullable timestamp would reintroduce the +// optional-product shape this file avoids for guard decisions. +// - Trigger: none for PR #1195 parity; richer drain receipts extend the +// drained arm payload. +type BucketDrainState + = BucketNotDrained + | BucketDrained { drained_at: Timestamp } + +// 🟢 TERMINAL coproduct at Phase-1 scope — process closure state. Avoids +// `closed_at: Timestamp?` beside every mode state. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL. Open and closed are disjoint lifecycle +// states for the close guard. +// - Dissolution pattern rejected: nullable timestamp permits code to treat +// "missing close timestamp" as data absence instead of an explicit open +// state. +// - Trigger: none for PR #1195 parity; richer close receipts extend the +// closed arm payload. +type ProcessCloseState + = ProcessOpen + | ProcessClosed { closed_at: Timestamp } + // 🟢 TERMINAL coproduct at Phase-1 scope — mode-specific closure facts. This // avoids sibling nullable fields that admit impossible states, such as a leaf // with a bucket-drain timestamp or a bucket with child facts. @@ -272,7 +301,7 @@ type ProcessEventLog = FreeMonoid type ProcessNodeModeState = LeafState | CompositeState { open_children: List } - | BucketState { drained_at: Timestamp? } + | BucketState { drain: BucketDrainState } | UndeclaredState // 🟡 STAGED graph snapshot for closure projection. This is the minimum state @@ -284,7 +313,7 @@ type ProcessNodeModeState type ProcessNodeState { id: ProcessNodeId mode: ProcessNodeModeState - closed_at: Timestamp? + close: ProcessCloseState } type ProcessGraph { From 06d22d7e1299c075180e7db5335cde035aeb2569 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 21:22:53 +0000 Subject: [PATCH 04/10] tighten process graph identity carrier --- dsl/std/process_algebra.dag | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 5bcd69a2061..5ff558089d0 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -304,20 +304,30 @@ type ProcessNodeModeState | BucketState { drain: BucketDrainState } | UndeclaredState -// 🟡 STAGED graph snapshot for closure projection. This is the minimum state -// needed by the Phase-1 guard; workflow phase and run-keyed facts remain in -// `gunbc.workflow.types`. +// 🟡 STAGED node facts for closure projection. Identity is carried by the +// graph entry below, not by this closure-fact row, so mode/close facts cannot +// treat ProcessNodeId as another mutable sibling field. // // Dissolution trigger: when `state(log: ProcessEventLog)` is emitted, this // snapshot is generated from the event log and no longer hand-authored. -type ProcessNodeState { - id: ProcessNodeId +type ProcessNodeFacts { mode: ProcessNodeModeState close: ProcessCloseState } +// 🟡 STAGED keyed-carrier scaffold — `id` is the graph row key for these node +// facts until a generic keyed map / graph-storage substrate exists in std. +// +// Dissolution trigger: replace `List` with the shared keyed +// graph carrier once it lands; consumers continue to address nodes by +// `ProcessNodeId`. +type ProcessNodeEntry { + id: ProcessNodeId + facts: ProcessNodeFacts +} + type ProcessGraph { - nodes: List + nodes: List } // Projection signatures. Bodies wait for emission/parity work; declaring the From 910fa8d749f29a804a4428507c67e9226f84591e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 22:07:16 +0000 Subject: [PATCH 05/10] keep undeclared process mode projection-only --- dsl/std/process_algebra.dag | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 5ff558089d0..9f0e6c6ee33 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -286,27 +286,31 @@ type ProcessCloseState = ProcessOpen | ProcessClosed { closed_at: Timestamp } -// 🟢 TERMINAL coproduct at Phase-1 scope — mode-specific closure facts. This -// avoids sibling nullable fields that admit impossible states, such as a leaf -// with a bucket-drain timestamp or a bucket with child facts. +// 🟢 TERMINAL coproduct at Phase-1 scope — mode-specific closure facts for +// declared process nodes. This avoids sibling nullable fields that admit +// impossible states, such as a leaf with a bucket-drain timestamp or a bucket +// with child facts. // // Practice 4 receipt: // - Classification: 🟢 TERMINAL for the closure guard state consumed by // `can_close_process_node`. // - Dissolution pattern rejected: nullable sibling fields collapse distinct -// repair paths and admit contradictory states. Each mode owns only the -// facts needed for its closure rule. +// repair paths and admit contradictory states. Each declared mode owns only +// the facts needed for its closure rule. +// - Dissolution pattern applied: undeclared/cutoff remains a projection result +// in `ProcessModeProjection`, not stored node state. // - Trigger: none for PR #1195 parity; new mode-specific closure facts must // extend the corresponding carrier here. type ProcessNodeModeState = LeafState | CompositeState { open_children: List } | BucketState { drain: BucketDrainState } - | UndeclaredState // 🟡 STAGED node facts for closure projection. Identity is carried by the // graph entry below, not by this closure-fact row, so mode/close facts cannot -// treat ProcessNodeId as another mutable sibling field. +// treat ProcessNodeId as another mutable sibling field. Undeclared/cutoff +// nodes are represented by `ProcessModeProjection` and refusal facts, not by +// storing a fourth mode here. // // Dissolution trigger: when `state(log: ProcessEventLog)` is emitted, this // snapshot is generated from the event log and no longer hand-authored. From fb2405f78db598f397967b533382820af15b891e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 22:17:42 +0000 Subject: [PATCH 06/10] derive process operation effects --- dsl/std/process_algebra.dag | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 9f0e6c6ee33..6f8e629da11 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -99,6 +99,17 @@ type Attestation { evidence: List } +// 🟢 TERMINAL record — a non-empty list of process nodes. Used where the +// substrate fact says at least one node exists, so an empty `List` cannot +// contradict the enclosing state. +// +// Dissolution trigger: replace with a shared `NonEmptyList` when +// that carrier is available in `dsl/std`. +type NonEmptyProcessNodeIds { + first: ProcessNodeId + rest: List +} + // 🟢 TERMINAL coproduct at Phase-1 scope — explicit closure guard results // matching ctrl PR #1195. This is fail-closed: every known refusal has a // distinct inhabitant, including the undeclared post-cutoff and bucket-drain @@ -132,7 +143,7 @@ type ProcessClosureRefusal | ProcessAlreadyClosed | ProcessModeNotDeclared | ProcessBucketNotDrained - | ProcessCompositeHasOpenChildren { open_children: List } + | ProcessCompositeHasOpenChildren { open_children: NonEmptyProcessNodeIds } // 🟢 TERMINAL coproduct — closure eligibility effect per operation. This // replaces the rejected blanket monotonicity claim with typed per-operation @@ -150,9 +161,11 @@ type ClosureEligibilityEffect | ClosureNeutral | ClosureOverride -// 🟡 STAGED record — a typed effect summary is required per operation. The +// 🟡 STAGED record — a typed effect summary is projected per operation. The // `external_effect` field reuses the layer-local `std.effects.OperationEffect` -// authority instead of importing v3 workflow carriers into `dsl/std`. +// authority instead of importing v3 workflow carriers into `dsl/std`. This row +// is derived by `process_operation_effect`; it is not an authored sibling field +// on `ProcessOperation` arms. // // Dissolution trigger: when ctrl HTTP/SQL/audit emission consumes this file, // operation effect rows are generated from each `ProcessOperation` arm and @@ -190,50 +203,41 @@ type ProcessOperation node: ProcessNodeId mode: DeclaredProcessNodeMode attestation: Attestation - effect: ProcessOperationEffect } | DecomposeProcessNode { parent: ProcessNodeId children: List attestation: Attestation - effect: ProcessOperationEffect } | DrainProcessBucket { bucket: ProcessNodeId attestation: Attestation - effect: ProcessOperationEffect } | ReplanProcessNode { node: ProcessNodeId reason: Attestation - effect: ProcessOperationEffect } | EscalateProcessDebt { from: ProcessNodeId to_parent: ProcessNodeId debt: Attestation - effect: ProcessOperationEffect } | PauseProcessNode { node: ProcessNodeId reason: Attestation - effect: ProcessOperationEffect } | ReopenProcessNode { node: ProcessNodeId reopen: ReopenAttestation - effect: ProcessOperationEffect } | RegressProcessSubtree { node: ProcessNodeId retracted_child_ids: List regression: RegressionAttestation - effect: ProcessOperationEffect } | AttestedClosureOverride { rule: ProcessRuleName attestation: Attestation - effect: ProcessOperationEffect } // 🟡 STAGED record — append-only event row for replay-as-truth. `position` @@ -340,6 +344,10 @@ fn current_process_mode(_graph: ProcessGraph, _node: ProcessNodeId) -> ProcessMo host process_algebra_current_mode } +fn process_operation_effect(_operation: ProcessOperation) -> ProcessOperationEffect { + host process_algebra_operation_effect +} + fn can_close_process_node( _graph: ProcessGraph, _node: ProcessNodeId, From 9320d2bea24686a81e11b407751d5aeb013bcdb5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 22:24:40 +0000 Subject: [PATCH 07/10] stage process projections without host boundaries --- dsl/std/process_algebra.dag | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 6f8e629da11..016ae59562f 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -164,8 +164,8 @@ type ClosureEligibilityEffect // 🟡 STAGED record — a typed effect summary is projected per operation. The // `external_effect` field reuses the layer-local `std.effects.OperationEffect` // authority instead of importing v3 workflow carriers into `dsl/std`. This row -// is derived by `process_operation_effect`; it is not an authored sibling field -// on `ProcessOperation` arms. +// is reserved for the future generated effect projection; it is not an authored +// sibling field on `ProcessOperation` arms. // // Dissolution trigger: when ctrl HTTP/SQL/audit emission consumes this file, // operation effect rows are generated from each `ProcessOperation` arm and @@ -338,20 +338,10 @@ type ProcessGraph { nodes: List } -// Projection signatures. Bodies wait for emission/parity work; declaring the -// signature here fixes the substrate boundary that ctrl projections consume. -fn current_process_mode(_graph: ProcessGraph, _node: ProcessNodeId) -> ProcessModeProjection { - host process_algebra_current_mode -} - -fn process_operation_effect(_operation: ProcessOperation) -> ProcessOperationEffect { - host process_algebra_operation_effect -} - -fn can_close_process_node( - _graph: ProcessGraph, - _node: ProcessNodeId, - _cutoff: Timestamp -) -> ProcessClosureDecision { - host process_algebra_can_close_node -} +// Projection surfaces intentionally remain comments in this Phase-1 substrate: +// current_process_mode(ProcessGraph, ProcessNodeId) -> ProcessModeProjection, +// process_operation_effect(ProcessOperation) -> ProcessOperationEffect, and +// can_close_process_node(ProcessGraph, ProcessNodeId, Timestamp) -> +// ProcessClosureDecision. They become declared functions in the PR that also +// lands an emission/parity consumer, so this file does not introduce unused host +// boundaries. From 993ddf3ee3e6c19dc4374533d10633d8a05ca196 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 23:17:28 +0000 Subject: [PATCH 08/10] represent missing process declarations --- dsl/std/process_algebra.dag | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 016ae59562f..17152fab400 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -310,16 +310,32 @@ type ProcessNodeModeState | CompositeState { open_children: List } | BucketState { drain: BucketDrainState } +// 🟢 TERMINAL coproduct at Phase-1 scope — whether an existing process node has +// a declared mode yet. This preserves the ctrl distinction between "node not +// found" and "node exists but has no declaration" without making undeclared a +// stored mode. +// +// Practice 4 receipt: +// - Classification: 🟢 TERMINAL for the closure guard snapshot. Missing +// declaration and declared-mode facts have different repair paths. +// - Dissolution pattern applied: fact placement. The missing-declaration state +// is stored as declaration absence; `ProcessNodeModeState` remains only the +// declared mode facts. +// - Trigger: none for PR #1195 parity; richer declaration provenance extends +// the declared arm payload. +type ProcessNodeDeclarationState + = ProcessModeMissing + | ProcessModeDeclared(ProcessNodeModeState) + // 🟡 STAGED node facts for closure projection. Identity is carried by the // graph entry below, not by this closure-fact row, so mode/close facts cannot -// treat ProcessNodeId as another mutable sibling field. Undeclared/cutoff -// nodes are represented by `ProcessModeProjection` and refusal facts, not by -// storing a fourth mode here. +// treat ProcessNodeId as another mutable sibling field. Missing mode declaration +// is represented as declaration absence, not by storing a fourth mode here. // // Dissolution trigger: when `state(log: ProcessEventLog)` is emitted, this // snapshot is generated from the event log and no longer hand-authored. type ProcessNodeFacts { - mode: ProcessNodeModeState + declaration: ProcessNodeDeclarationState close: ProcessCloseState } From a18754587831d64924e09bb66e7012adb7fd2ec5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 19:27:01 -0400 Subject: [PATCH 09/10] =?UTF-8?q?WIP:=20Ctrl-Migration=20Substrate=20Mgr?= =?UTF-8?q?=20=E2=80=94=20Phase=201=20process=20algebra=20substrate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dsl/std/process_algebra.dag | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 17152fab400..99d483fdf60 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -194,8 +194,9 @@ type RegressionAttestation { // - Classification: 🟢 TERMINAL for the decomposition-algebra operation // vocabulary. Each arm has distinct payload and closure effect. // - Dissolution pattern rejected: variants are not values of a single generic -// mutation; declare, decompose, drain, replan, escalate, pause, reopen, -// regress, and override have different repair paths and audit payloads. +// mutation; declare, decompose, drain, close, refused-close, replan, +// escalate, pause, reopen, regress, and override have different repair paths +// and audit payloads. // - Trigger: none for Phase 1. Adding a ctrl operation must extend this one // file before REST/SQL/CLI projections can expose it. type ProcessOperation @@ -206,13 +207,22 @@ type ProcessOperation } | DecomposeProcessNode { parent: ProcessNodeId - children: List + children: NonEmptyProcessNodeIds attestation: Attestation } | DrainProcessBucket { bucket: ProcessNodeId attestation: Attestation } + | CloseProcessNode { + node: ProcessNodeId + attestation: Attestation + } + | RefuseCloseProcessNode { + node: ProcessNodeId + refusal: ProcessClosureRefusal + attestation: Attestation + } | ReplanProcessNode { node: ProcessNodeId reason: Attestation @@ -232,7 +242,7 @@ type ProcessOperation } | RegressProcessSubtree { node: ProcessNodeId - retracted_child_ids: List + retracted_child_ids: NonEmptyProcessNodeIds regression: RegressionAttestation } | AttestedClosureOverride { From e3963e6c038bce2dbe38491fba7a097f0e795dea Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Tue, 12 May 2026 23:46:50 +0000 Subject: [PATCH 10/10] collapse process declaration state --- dsl/std/process_algebra.dag | 69 ++++++++++--------------------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/dsl/std/process_algebra.dag b/dsl/std/process_algebra.dag index 99d483fdf60..faef16fe322 100644 --- a/dsl/std/process_algebra.dag +++ b/dsl/std/process_algebra.dag @@ -42,9 +42,9 @@ type ProcessEventPosition = Int where range(min: 0), brand("ProcessEventPosition // Practice 4 receipt: // - Classification: 🟢 TERMINAL for declared modes. Leaf, Composite, and // Bucket are durable graph-shape coordinates. -// - Dissolution pattern rejected: undeclared/cutoff state is not a mode; it -// lives in `ProcessModeProjection` so declared-mode consumers cannot accept -// a transitional missing declaration as a real declaration. +// - Dissolution pattern rejected: undeclared/cutoff state is not a declared +// mode; closure snapshots carry it as `ProcessModeMissing` so declared-mode +// consumers cannot accept a transitional missing declaration as real data. // - Trigger: none for declared modes. New ctrl declaration modes must extend // this sum here first. type DeclaredProcessNodeMode @@ -52,22 +52,6 @@ type DeclaredProcessNodeMode | Composite | Bucket -// 🟡 STAGED coproduct — current mode projection result. This separates the -// transitional cutoff/null case from durable declarations. -// -// Practice 4 receipt: -// - Classification: 🟡 STAGED. `DeclaredProcessMode` carries durable -// declarations; `ProcessModeUndeclared` preserves post-cutoff failure and -// pre-cutoff grandfathering without polluting declared mode. -// - Dissolution pattern: fact-placement. Undeclared state is a projection -// result over event-log/cutoff facts, not a stored node mode. -// - Trigger: when `current_process_mode` is emitted from the event-log fold -// and all pre-cutoff ctrl nodes are closed, the transitional arm narrows to -// an explicit refusal-only result and stored mode becomes provenance. -type ProcessModeProjection - = DeclaredProcessMode(DeclaredProcessNodeMode) - | ProcessModeUndeclared - // 🟡 STAGED coproduct — evidence channels attached to a human-authored // attestation. Kept distinct from `v3.std.dimensions.Witness`. // @@ -300,42 +284,27 @@ type ProcessCloseState = ProcessOpen | ProcessClosed { closed_at: Timestamp } -// 🟢 TERMINAL coproduct at Phase-1 scope — mode-specific closure facts for -// declared process nodes. This avoids sibling nullable fields that admit -// impossible states, such as a leaf with a bucket-drain timestamp or a bucket -// with child facts. -// -// Practice 4 receipt: -// - Classification: 🟢 TERMINAL for the closure guard state consumed by -// `can_close_process_node`. -// - Dissolution pattern rejected: nullable sibling fields collapse distinct -// repair paths and admit contradictory states. Each declared mode owns only -// the facts needed for its closure rule. -// - Dissolution pattern applied: undeclared/cutoff remains a projection result -// in `ProcessModeProjection`, not stored node state. -// - Trigger: none for PR #1195 parity; new mode-specific closure facts must -// extend the corresponding carrier here. -type ProcessNodeModeState - = LeafState - | CompositeState { open_children: List } - | BucketState { drain: BucketDrainState } - -// 🟢 TERMINAL coproduct at Phase-1 scope — whether an existing process node has -// a declared mode yet. This preserves the ctrl distinction between "node not -// found" and "node exists but has no declaration" without making undeclared a -// stored mode. +// 🟢 TERMINAL coproduct at Phase-1 scope — declaration and mode-specific closure +// facts for existing process nodes. The declared mode and its closure facts live +// in the same arm, so the snapshot cannot say "declared leaf" while storing +// bucket facts. // // Practice 4 receipt: // - Classification: 🟢 TERMINAL for the closure guard snapshot. Missing -// declaration and declared-mode facts have different repair paths. +// declaration and declared-mode facts have different repair paths, and each +// declared mode owns only the facts needed for its closure rule. +// - Dissolution pattern rejected: nullable sibling fields collapse distinct +// repair paths and admit contradictory states. Separate `mode` plus fact +// fields can represent impossible combinations; this carrier cannot. // - Dissolution pattern applied: fact placement. The missing-declaration state -// is stored as declaration absence; `ProcessNodeModeState` remains only the -// declared mode facts. -// - Trigger: none for PR #1195 parity; richer declaration provenance extends -// the declared arm payload. +// is stored as declaration absence, not as a fourth declared mode. +// - Trigger: none for PR #1195 parity; richer declaration provenance or new +// mode-specific closure facts extend the corresponding arm here. type ProcessNodeDeclarationState = ProcessModeMissing - | ProcessModeDeclared(ProcessNodeModeState) + | ProcessLeafDeclared + | ProcessCompositeDeclared { open_children: List } + | ProcessBucketDeclared { drain: BucketDrainState } // 🟡 STAGED node facts for closure projection. Identity is carried by the // graph entry below, not by this closure-fact row, so mode/close facts cannot @@ -365,7 +334,7 @@ type ProcessGraph { } // Projection surfaces intentionally remain comments in this Phase-1 substrate: -// current_process_mode(ProcessGraph, ProcessNodeId) -> ProcessModeProjection, +// current_process_mode(ProcessGraph, ProcessNodeId) -> ProcessNodeDeclarationState, // process_operation_effect(ProcessOperation) -> ProcessOperationEffect, and // can_close_process_node(ProcessGraph, ProcessNodeId, Timestamp) -> // ProcessClosureDecision. They become declared functions in the PR that also