Propagating Effect & Process
Relevant source files
The following files were used as context for generating this wiki page:
Propagating Effect and Propagating Process are specialized type aliases built upon the CausalEffectPropagationProcess container in the deep_causality_core crate. They represent the foundational monadic architecture for causal effect propagation, enabling developers to model both stateless causal transformations and stateful causal processes within a unified functional framework.
These types utilize a Higher-Kinded Type (HKT) design to manage stateful, context-aware causal computations. By providing robust error handling and integrated logging (audit trails), they ensure that causal reasoning remains deterministic and observable across complex multi-stage models.
Sources: deep_causality_core/Notes.md
Core Architecture and Container Type
The fundamental unit of the system is the CausalEffectPropagationProcess, an arity-5 generic structure that encapsulates all components of a causal computation.
The CausalEffectPropagationProcess Structure
The container is defined by five independent type parameters:
- Value: The primary result of the computation (wrapped in
EffectValue). - State: Data that persists across a chain of computations.
- Context: Environmental or global information accessible to the computation.
- Error: Failure information for short-circuiting and propagation.
- Log: An accumulated history (audit trail) of the computation steps.
Sources: deep_causality_core/Notes.md
Structural Relationships
The following diagram illustrates how the specialized types PropagatingEffect and PropagatingProcess relate to the core container:
Sources: deep_causality_core/Notes.md
Specialization Types
PropagatingEffect
PropagatingEffect<T> is a type alias specializing the core container for stateless causal effects. It is primarily used for pure functional transformations where environmental context or persistent state is not required.
| Aspect | Specification |
|---|---|
| State | () (Unit/Stateless) |
| Context | () (No Context) |
| Error Type | CausalityError |
| Log Type | EffectLog |
Sources: deep_causality_core/src/types/propagating_effect/mod.rs, deep_causality_core/Notes.md
PropagatingProcess
PropagatingProcess<T, S, C> specializes the container for stateful and context-aware causal processes. This is the primary tool for modeling systems with history dependency or those requiring interaction with a complex hypergraph environment.
| Aspect | Specification |
|---|---|
| State | Generic S (Persistent State) |
| Context | Generic C (Context Hypergraph) |
| Error Type | CausalityError |
| Log Type | EffectLog |
Sources: deep_causality_core/src/types/propagating_process/mod.rs, deep_causality_core/Notes.md
Monadic Operations
The CausalMonad provides the implementation of monadic operations (pure and bind) that drive the propagation of effects and processes.
Computation Flow and Bind logic
The bind operation is responsible for chaining computations. It implements an error short-circuiting mechanism: if a previous step results in an error, the subsequent function is not executed, and the error state is propagated alongside the accumulated logs.
Markovian Property
The architecture is specifically designed to support Markovian processes. In this context, a process is Markovian if its future state depends only on its current state. The bind method facilitates this by passing the current Value, State, and Option<Context> to the function f, allowing for deterministic state transitions without requiring explicit access to the full history.
Sources: deep_causality_core/Notes.md
Causal Interventions
The system supports causal interventions via the Intervenable trait. This allows a developer to manually replace a value mid-computation. When an intervention occurs, the system logs the event to ensure the audit trail remains accurate, reflecting that the value was injected rather than computed.
Sources: deep_causality_core/src/types/causal_monad/mod.rs, deep_causality_core/Notes.md
Implementation Risks and Mitigations
| Risk | Description | Mitigation |
|---|---|---|
| State Mishandling | Explicit state management in PropagatingProcess may lead to incorrect updates or clones. | Use immutable-first approaches; document clear state transition rules. |
| Performance | Passing State and Context by value in monadic chains may cause overhead for large objects. | Use Arc for large read-only Contexts; benchmark critical paths. |
| unwrap() Panics | Using unwrap() on EffectValue can cause crashes in error states. | Enforce clippy rules against unwrap(); use pattern matching. |
Sources: openspec/changes/archive/migration_risk_analysis.md
Summary
Propagating Effect and Process provide a robust, type-safe framework for causal reasoning. By distinguishing between stateless effects (PropagatingEffect) and stateful processes (PropagatingProcess), the system allows for flexible modeling of complex causal graphs while maintaining strict audit trails through integrated logging and error propagation. This monadic design ensures that causal interventions and state transitions are handled deterministically within the Deep Causality ecosystem.