Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
882161a
WIP: Ctrl-Migration Substrate Mgr — Phase 1 process algebra substrate
briansrls May 12, 2026
24fcd6b
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
9a11b7e
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
e94163f
fix process algebra substrate shape
briansrls May 12, 2026
2aba243
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
784007f
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
fd86780
tighten process algebra state sums
briansrls May 12, 2026
a33afd4
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
7a3ea81
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
9d80963
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
06d22d7
tighten process graph identity carrier
briansrls May 12, 2026
b4ead9b
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
4f7b25d
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
f1076c4
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
a75a39d
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
cb4cc9a
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
910fa8d
keep undeclared process mode projection-only
briansrls May 12, 2026
9e868a0
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
fb2405f
derive process operation effects
briansrls May 12, 2026
8415426
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
9320d2b
stage process projections without host boundaries
briansrls May 12, 2026
7dc0518
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
58c0b64
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
b2e051d
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
b5e1deb
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
993ddf3
represent missing process declarations
briansrls May 12, 2026
a70e354
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
a187545
WIP: Ctrl-Migration Substrate Mgr — Phase 1 process algebra substrate
briansrls May 12, 2026
8fb9475
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
e3963e6
collapse process declaration state
briansrls May 12, 2026
825f805
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
1e98df3
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 2026
ce770cd
Merge remote-tracking branch 'origin/main' into session/witty-hawk-471
briansrls May 12, 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
275 changes: 275 additions & 0 deletions dsl/std/process_algebra.dag
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> }

This comment was marked as resolved.


// 🟢 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.

// 🟡 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.

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.

}

// 🟢 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.

//
// Practice 4 receipt:
// - Classification: 🟢 TERMINAL for the decomposition-algebra operation

This comment was marked as resolved.

// 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

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: 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.


// 🟡 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
}
8 changes: 8 additions & 0 deletions src/v3/compiler/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);

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: 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");
Expand Down
Loading