Repository navigation
Ctrl-Migration Substrate Mgr — Phase 1 process algebra substrate #2779
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
Changes from 2 commits
882161a
24fcd6b
9a11b7e
e94163f
2aba243
784007f
fd86780
a33afd4
7a3ea81
9d80963
06d22d7
b4ead9b
4f7b25d
f1076c4
a75a39d
cb4cc9a
910fa8d
9e868a0
fb2405f
8415426
9320d2b
7dc0518
58c0b64
b2e051d
b5e1deb
993ddf3
a70e354
a187545
8fb9475
e3963e6
825f805
1e98df3
ce770cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<C>` remains the | ||
| // analysis proof carrier. This file's human intent record is `Attestation`. | ||
| // - Does not define a bidirectional Lens; `v3.std.lens.Lens<C>` 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<C>`. | ||
| // | ||
| // 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<C>` / `Witness<C>` 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<C>`. | ||
| // | ||
| // 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<AttestationEvidence> | ||
| } | ||
|
|
||
| // 🟢 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<ProcessNodeId> } | ||
|
|
||
| // 🟢 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 | ||
|
|
||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| // 🟡 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 { | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| closure_effect: ClosureEligibilityEffect | ||
| workflow_effect: WorkflowEffect | ||
| } | ||
|
|
||
| type ReopenAttestation { | ||
| reason: NonEmptyStr | ||
| attestation: Attestation | ||
| } | ||
|
|
||
| type RegressionAttestation { | ||
| reason: NonEmptyStr | ||
| retracted_subtree_signature: NonEmptyStr | ||
| attestation: Attestation | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| } | ||
|
|
||
| // 🟢 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. | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| // | ||
| // Practice 4 receipt: | ||
| // - Classification: 🟢 TERMINAL for the decomposition-algebra operation | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
| // 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<ProcessNodeId> | ||
| 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<ProcessNodeId> | ||
| 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<T>` specialization for process operations. | ||
| type ProcessEvent { | ||
| position: ProcessEventPosition | ||
| timestamp: Timestamp | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BLOCKING: ProcessEvent.timestamp creates a second timestamp authority beside Attestation.timestamp for the same audit-backed operation, so replay can disagree about when the event happened (INVARIANTS.md P2 single authority). |
||
| operation: ProcessOperation | ||
| } | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
|
|
||
| // 🟡 STAGED alias — append-only operation history. This uses `FreeMonoid` | ||
| // rather than a process-local log algebra. | ||
| // | ||
| // Dissolution trigger: when a generic `EventLog<T>` primitive lands, this | ||
| // becomes `type ProcessEventLog = EventLog<ProcessOperation>`; until then the | ||
| // concrete process log names the same FreeMonoid structure directly. | ||
| type ProcessEventLog = FreeMonoid<ProcessEvent> | ||
|
|
||
| // 🟡 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<ProcessNodeId> | ||
| } | ||
|
|
||
| type ProcessGraph { | ||
| nodes: List<ProcessNodeState> | ||
| } | ||
|
|
||
| // 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 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1084,6 +1084,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", | ||
| ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BLOCKING: INVARIANTS.md P5 applies to expanded Rust tests under src/v3, so this added handwritten parser test needs the required receipt: deleted scaffold, SG-0 census shrink, or concrete ROADMAP deferral. |
||
| } | ||
|
|
||
| #[test] | ||
| fn handwritten_parser_accepts_v3_list_dag() { | ||
| parse_file(include_str!("../../std/list.dag"), "src/v3/std/list.dag"); | ||
|
|
||
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.