uor-foundation 0.1.3

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
// @generated by uor-crate from uor-ontology — do not edit manually

//! `cascade/` namespace — Sequential composition of ψ-maps into a parameterized cascade ψ = ψ_9 ∘ … ∘ ψ_1. Defines stages, phase gates, rollback, and epochs..
//!
//! Space: Kernel

use crate::enums::FiberState;
use crate::enums::QuantumLevel;
use crate::enums::VerificationDomain;
use crate::Primitives;

/// The composite endofunctor ψ = ψ_9 ∘ … ∘ ψ_1, parameterized by Ω = e^{iπ/6}.
pub trait EulerCascade<P: Primitives> {
    /// The base phase parameter Ω for this cascade (e.g., e^{iπ/6}).
    fn phase_parameter(&self) -> &P::String;
    /// The number of stages in this cascade.
    fn stage_count(&self) -> P::NonNegativeInteger;
    /// The cumulative phase angle at which the cascade converges.
    fn convergence_angle(&self) -> &P::String;
}

/// Schedule Ω⁰, Ω¹, …, Ω⁵ assigning a phase angle to each stage of the cascade.
pub trait PhaseRotationScheduler<P: Primitives> {
    /// String representation of the rotation schedule Ω⁰, Ω¹, …, Ω⁵.
    fn rotation_schedule(&self) -> &P::String;
    /// The base angle π/6 from which the schedule is derived.
    fn base_angle(&self) -> &P::String;
}

/// The angle at which the cascade terminates (default: π).
pub trait TargetConvergenceAngle<P: Primitives> {
    /// The target convergence angle (default: π).
    fn target_angle(&self) -> &P::String;
}

/// Validation at each stage boundary checking that the accumulated phase angle matches the expected Ω^k.
pub trait PhaseGateAttestation<P: Primitives> {
    /// Associated type for `CascadeStage`.
    type CascadeStage: CascadeStage<P>;
    /// The cascade stage at which this gate is applied.
    fn gate_stage(&self) -> &Self::CascadeStage;
    /// The expected phase angle Ω^k at this gate.
    fn gate_expected_phase(&self) -> &P::String;
    /// Whether the phase gate check passed or failed.
    fn gate_result(&self) -> P::Boolean;
}

/// Recovery operation when a phase gate fails: z → z̄. Involutory: applying twice yields the original value.
pub trait ComplexConjugateRollback<P: Primitives> {
    /// Associated type for `CascadeStage`.
    type CascadeStage: CascadeStage<P>;
    /// The cascade stage to which execution rolls back on gate failure.
    fn rollback_target(&self) -> &Self::CascadeStage;
}

/// A named stage of the cascade. The standard cascade has six stages (Initialization through Convergence).
pub trait CascadeStage<P: Primitives> {
    /// Zero-based index of this stage in the cascade.
    fn stage_index(&self) -> P::NonNegativeInteger;
    /// Human-readable name of this cascade stage.
    fn stage_name(&self) -> &P::String;
    /// The expected phase angle Ω^k at this stage.
    fn expected_phase(&self) -> &P::String;
    /// Associated type for `StatePredicate`.
    type StatePredicate: crate::kernel::predicate::StatePredicate<P>;
    /// A typed predicate evaluated on the current CascadeState. Must be satisfied to enter this stage.
    fn entry_guard(&self) -> &Self::StatePredicate;
    /// A typed predicate that must be satisfied before the cascade advances past this stage.
    fn exit_guard(&self) -> &Self::StatePredicate;
    /// Associated type for `Effect`.
    type Effect: crate::kernel::effect::Effect<P>;
    /// The effect applied by this stage upon successful exit.
    fn stage_effect(&self) -> &Self::Effect;
}

/// State of cascade execution at a specific point, including the current stage, phase angle, and pinned mask.
pub trait CascadeState<P: Primitives> {
    /// Associated type for `CascadeStage`.
    type CascadeStage: CascadeStage<P>;
    /// The cascade stage at which execution is currently positioned.
    fn current_stage(&self) -> &Self::CascadeStage;
    /// The accumulated phase angle at the current point.
    fn phase_angle(&self) -> &P::String;
    /// Bit mask of fibers that are pinned (resolved) at this point.
    fn pinned_mask(&self) -> &P::String;
    /// The number of free (unresolved) fibers at this point.
    fn free_count(&self) -> P::NonNegativeInteger;
    /// The fiber state descriptor within a cascade state.
    fn fiber_state(&self) -> FiberState;
}

/// Guard-effect pair governing stage transitions in the cascade. The guard must be satisfied before the effect is applied.
pub trait CascadeTransitionRule<P: Primitives> {
    /// Associated type for `GuardedTransition`.
    type GuardedTransition: crate::kernel::predicate::GuardedTransition<P>;
    /// A typed GuardedTransition from predicate/ governing the stage transition.
    fn transition_guard(&self) -> &Self::GuardedTransition;
    /// The effect applied when this transition fires.
    fn transition_effect(&self) -> &P::String;
    /// Whether this transition advances to the next stage.
    fn transition_advance(&self) -> P::Boolean;
}

/// Temporal segment of cascade execution. Each epoch represents one complete pass through the cascade stages.
pub trait Epoch<P: Primitives> {
    /// Zero-based index of this epoch in the cascade execution.
    fn epoch_index(&self) -> P::NonNegativeInteger;
}

/// Transition between epochs. Carries metadata about the epoch boundary crossing.
pub trait EpochBoundary<P: Primitives> {
    /// The type of epoch boundary crossing (e.g., normal, forced, timeout).
    fn epoch_boundary_type(&self) -> &P::String;
    /// Whether saturation was preserved across the epoch boundary.
    fn preserved_saturation(&self) -> P::Boolean;
}

/// A Boolean expression over the cascade state. The atomic guard unit.
pub trait PredicateExpression<P: Primitives> {
    /// The state field this predicate tests.
    fn predicate_field(&self) -> &P::String;
    /// The comparison operator (e.g., '=', '<', '>=').
    fn predicate_operator(&self) -> &P::String;
    /// The value against which the field is compared.
    fn predicate_value(&self) -> &P::String;
}

/// A conjunction of PredicateExpressions that must hold for a transition to fire.
pub trait GuardExpression<P: Primitives> {
    /// Associated type for `PredicateExpression`.
    type PredicateExpression: PredicateExpression<P>;
    /// The predicate expressions that compose this guard.
    fn guard_predicates(&self) -> &[Self::PredicateExpression];
}

/// State changes applied when a transition fires. Contains PropertyBind steps.
pub trait TransitionEffect<P: Primitives> {
    /// Associated type for `PropertyBind`.
    type PropertyBind: PropertyBind<P>;
    /// The property bind steps applied by this effect.
    fn effect_bindings(&self) -> &[Self::PropertyBind];
}

/// A single fiber pinning: target fiber + value.
pub trait PropertyBind<P: Primitives> {
    /// The target fiber identifier for this binding.
    fn bind_target(&self) -> &P::String;
    /// The value to pin the target fiber to.
    fn bind_value(&self) -> &P::String;
}

/// Advancement from one CascadeStage to the next.
pub trait StageAdvance<P: Primitives> {
    /// Associated type for `CascadeStage`.
    type CascadeStage: CascadeStage<P>;
    /// The source stage of the advancement.
    fn advance_from(&self) -> &Self::CascadeStage;
    /// The target stage of the advancement.
    fn advance_to(&self) -> &Self::CascadeStage;
}

/// A sliding window over recent epochs providing BaseContext.
pub trait ServiceWindow<P: Primitives> {
    /// The number of recent epochs in this service window.
    fn window_size(&self) -> P::NonNegativeInteger;
    /// The starting epoch offset of this service window.
    fn window_offset(&self) -> P::NonNegativeInteger;
    /// Reference to the base context provided by this service window.
    fn base_context_ref(&self) -> &P::String;
}

/// An atomic group of state changes within the cascade.
pub trait CascadeTransaction<P: Primitives> {
    /// The execution policy for this transaction (e.g., AllOrNothing, BestEffort).
    fn transaction_policy(&self) -> &P::String;
    /// The outcome of this transaction (e.g., committed, rolled back).
    fn transaction_outcome(&self) -> &P::String;
    /// The scope of fibers affected by this transaction.
    fn transaction_scope(&self) -> &P::String;
    /// Current status of this transaction (e.g., pending, committed).
    fn transaction_status(&self) -> &P::String;
}

/// Successful termination (FullSaturation).
pub trait PipelineSuccess<P: Primitives> {
    /// Whether full saturation was achieved.
    fn saturation_reached(&self) -> P::Boolean;
    /// The final saturation level achieved on pipeline success.
    fn final_saturation(&self) -> &P::String;
}

/// Typed failure: DispatchMiss, GroundingFailure, ConvergenceStall, etc.
pub trait PipelineFailureReason<P: Primitives> {
    /// The kind of pipeline failure (e.g., DispatchMiss, ConvergenceStall).
    fn failure_kind(&self) -> &P::String;
    /// The cascade stage at which the pipeline failure occurred.
    fn failure_stage(&self) -> &P::String;
}

/// A pre-execution validation: feasibility, dispatch coverage, coherence.
pub trait PreflightCheck<P: Primitives> {
    /// The kind of preflight check (e.g., feasibility, dispatch coverage).
    fn preflight_kind(&self) -> &P::String;
    /// The result of the preflight check (e.g., pass, fail).
    fn preflight_result(&self) -> &P::String;
    /// Zero-based execution order for preflight checks. Lower indices execute first. BudgetSolvencyCheck (order 0) must precede all others.
    fn preflight_order(&self) -> P::NonNegativeInteger;
}

/// Result of a preflight check: feasibility witness or infeasibility witness.
pub trait FeasibilityResult<P: Primitives> {
    /// The kind of feasibility result (e.g., Feasible, Infeasible).
    fn feasibility_kind(&self) -> &P::String;
    /// The witness justifying the feasibility or infeasibility result.
    fn feasibility_witness(&self) -> &P::String;
    /// The kind of infeasibility detected.
    fn infeasibility_kind(&self) -> &P::String;
}

/// Lifecycle of a partitioned context lease: Pending → Active → Released/Expired/Suspended.
pub trait LeaseState<P: Primitives> {
    /// The lifecycle phase of a lease (e.g., Pending, Active, Released).
    fn lease_phase(&self) -> &P::String;
}

/// A context lease with lifecycle tracking.
pub trait ManagedLease<P: Primitives> {
    /// Unique identifier for this managed lease.
    fn managed_lease_id(&self) -> &P::String;
    /// Associated type for `LeaseState`.
    type LeaseState: LeaseState<P>;
    /// The current lifecycle state of this managed lease.
    fn lease_lifecycle(&self) -> &Self::LeaseState;
    /// The epoch at which this managed lease expires.
    fn expiry_epoch(&self) -> P::NonNegativeInteger;
    /// The total fiber budget allocated to this managed lease.
    fn lease_budget(&self) -> P::NonNegativeInteger;
}

/// Snapshot of lease state at a point in time.
pub trait LeaseCheckpoint<P: Primitives> {
    /// The epoch index at which this checkpoint was taken.
    fn checkpoint_epoch(&self) -> P::NonNegativeInteger;
    /// Associated type for `CascadeState`.
    type CascadeState: CascadeState<P>;
    /// The cascade state captured at this checkpoint.
    fn checkpoint_state(&self) -> &Self::CascadeState;
    /// The remaining fiber budget at this checkpoint.
    fn lease_remaining_budget(&self) -> P::NonNegativeInteger;
}

/// Flow control when cascade produces faster than downstream can consume.
pub trait BackPressureSignal<P: Primitives> {
    /// The current back-pressure level (e.g., Low, Medium, High).
    fn pressure_level(&self) -> &P::String;
    /// The threshold at which back-pressure activates.
    fn pressure_threshold(&self) -> &P::String;
    /// The source stage emitting back-pressure.
    fn source_stage(&self) -> &P::String;
    /// The target stage receiving back-pressure.
    fn target_stage(&self) -> &P::String;
}

/// Queries postponed to a future epoch.
pub trait DeferredQuerySet<P: Primitives> {
    /// The number of queries in this deferred set.
    fn deferred_count(&self) -> P::NonNegativeInteger;
    /// The epoch in which these queries were deferred.
    fn deferral_epoch(&self) -> P::NonNegativeInteger;
    /// The reason for deferring these queries.
    fn deferral_reason(&self) -> &P::String;
}

/// Transfer of a lease from one computation to another.
pub trait SubleaseTransfer<P: Primitives> {
    /// The lease being transferred from.
    fn source_lease_ref(&self) -> &P::String;
    /// The lease being transferred to.
    fn target_lease_ref(&self) -> &P::String;
    /// The fiber budget transferred between leases.
    fn transferred_budget(&self) -> P::NonNegativeInteger;
    /// Whether the sublease transfer has been completed.
    fn transfer_completed(&self) -> P::Boolean;
}

/// Predicate comparing a state field against a value.
pub trait ComparisonPredicate<P: Primitives>: PredicateExpression<P> {
    /// The state field tested by this comparison predicate.
    fn comparison_field(&self) -> &P::String;
    /// The comparison operator (e.g., '=', '<', '>=').
    fn comparison_operator(&self) -> &P::String;
    /// The value against which the comparison is made.
    fn comparison_value(&self) -> &P::String;
}

/// Conjunction (AND) of multiple predicates.
pub trait ConjunctionPredicate<P: Primitives>: PredicateExpression<P> {
    /// A conjunct predicate in a conjunction.
    fn conjuncts_count(&self) -> usize;
    /// Returns the item at `index`. Must satisfy `index < self.conjuncts_count()`.
    fn conjuncts_at(&self, index: usize) -> &P::String;
}

/// Disjunction (OR) of multiple predicates.
pub trait DisjunctionPredicate<P: Primitives>: PredicateExpression<P> {
    /// A disjunct predicate in a disjunction.
    fn disjuncts_count(&self) -> usize;
    /// Returns the item at `index`. Must satisfy `index < self.disjuncts_count()`.
    fn disjuncts_at(&self, index: usize) -> &P::String;
}

/// Negation (NOT) of a single predicate.
pub trait NegationPredicate<P: Primitives>: PredicateExpression<P> {
    /// The predicate being negated.
    fn negated_predicate(&self) -> &P::String;
}

/// Predicate testing membership of an element in a set.
pub trait MembershipPredicate<P: Primitives>: PredicateExpression<P> {
    /// The set against which membership is tested.
    fn membership_set(&self) -> &P::String;
    /// The element being tested for set membership.
    fn membership_element(&self) -> &P::String;
}

/// Predicate testing whether saturation exceeds a threshold.
pub trait SaturationPredicate<P: Primitives>: PredicateExpression<P> {
    /// The saturation threshold above which the predicate holds.
    fn saturation_threshold(&self) -> &P::String;
}

/// Predicate testing whether a fiber coverage target is met.
pub trait FiberCoveragePredicate<P: Primitives>: PredicateExpression<P> {
    /// The fiber coverage target expression.
    fn coverage_target(&self) -> &P::String;
}

/// Predicate testing equality of two expressions.
pub trait EqualsPredicate<P: Primitives>: PredicateExpression<P> {
    /// The left-hand side of an equality test.
    fn equality_left(&self) -> &P::String;
    /// The right-hand side of an equality test.
    fn equality_right(&self) -> &P::String;
}

/// Predicate testing that a field is non-null.
pub trait NonNullPredicate<P: Primitives>: PredicateExpression<P> {
    /// The field that must be non-null.
    fn non_null_field(&self) -> &P::String;
}

/// Predicate testing whether a query is a subtype of a given type.
pub trait QuerySubtypePredicate<P: Primitives>: PredicateExpression<P> {
    /// The query type reference for subtype testing.
    fn query_type_ref(&self) -> &P::String;
}

/// The typed input graph submitted to the cascade pipeline. Packages a root Term, target quantum level, verification domains, and thermodynamic budget. Stage 0 accepts exactly one CompileUnit and initializes the cascade state vector from it.
pub trait CompileUnit<P: Primitives> {
    /// Associated type for `Term`.
    type Term: crate::kernel::schema::Term<P>;
    /// The top-level term to be evaluated by the cascade pipeline. The transitive closure of this term defines the complete computation graph.
    fn root_term(&self) -> &Self::Term;
    /// The quantum level Q_k at which this compile unit operates. Determines the ring modulus 2^(8*(k+1)), bit width, and fiber budget.
    fn unit_quantum_level(&self) -> QuantumLevel;
    /// The verification domains the submitter requires the cascade to check. Non-functional: a compile unit may target multiple domains. Identities with universallyValid=true are enforced regardless.
    fn target_domains(&self) -> &[VerificationDomain];
    /// Maximum Landauer cost authorized for this computation, in units of k_B T. Minimum viable budget = bitsWidth(Q_k) × ln 2.
    fn thermodynamic_budget(&self) -> P::Decimal;
    /// Associated type for `Address`.
    type Address: crate::kernel::address::Address<P>;
    /// Content-addressable identifier computed as the u:Address of the root term’s transitive closure. Computed by stage_initialization, not declared by the submitter. Excludes budget, domains, and quantum level to enable memoization.
    fn unit_address(&self) -> &Self::Address;
}

/// Stage 0: initialize state vector to identity.
pub mod stage_initialization {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω⁰";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 0;
    /// `stageName`
    pub const STAGE_NAME: &str = "Initialization";
}

/// Stage 1: dispatch resolver (δ selects).
pub mod stage_declare {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω¹";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 1;
    /// `stageName`
    pub const STAGE_NAME: &str = "Declare";
}

/// Stage 2: produce valid ring address (G grounds).
pub mod stage_factorize {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω²";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 2;
    /// `stageName`
    pub const STAGE_NAME: &str = "Factorize";
}

/// Stage 3: resolve constraints (Π terminates).
pub mod stage_resolve {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω³";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 3;
    /// `stageName`
    pub const STAGE_NAME: &str = "Resolve";
}

/// Stage 4: accumulate without contradiction (α consistent).
pub mod stage_attest {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω⁴";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 4;
    /// `stageName`
    pub const STAGE_NAME: &str = "Attest";
}

/// Stage 5: extract coherent output (P projects).
pub mod stage_extract {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "Ω⁵";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 5;
    /// `stageName`
    pub const STAGE_NAME: &str = "Extract";
}

/// Terminal stage: cascade has reached the convergence angle π.
pub mod stage_convergence {
    /// `expectedPhase`
    pub const EXPECTED_PHASE: &str = "π";
    /// `stageIndex`
    pub const STAGE_INDEX: i64 = 6;
    /// `stageName`
    pub const STAGE_NAME: &str = "Convergence";
}

/// Phase gate at stage 0 boundary: checks Ω⁰ = 1.
pub mod gate_initialization {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω⁰";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_initialization`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_initialization";
}

/// Phase gate at stage 1 boundary: checks Ω¹.
pub mod gate_declare {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω¹";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_declare`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_declare";
}

/// Phase gate at stage 2 boundary: checks Ω².
pub mod gate_factorize {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω²";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_factorize`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_factorize";
}

/// Phase gate at stage 3 boundary: checks Ω³.
pub mod gate_resolve {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω³";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_resolve`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_resolve";
}

/// Phase gate at stage 4 boundary: checks Ω⁴.
pub mod gate_attest {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω⁴";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_attest`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_attest";
}

/// Phase gate at stage 5 boundary: checks Ω⁵.
pub mod gate_extract {
    /// `gateExpectedPhase`
    pub const GATE_EXPECTED_PHASE: &str = "Ω⁵";
    /// `gateResult`
    pub const GATE_RESULT: bool = true;
    /// `gateStage` -> `stage_extract`
    pub const GATE_STAGE: &str = "https://uor.foundation/cascade/stage_extract";
}

/// The canonical Euler cascade instance with Ω = e^{iπ/6} and 6 stages.
pub mod euler_cascade_instance {
    /// `convergenceAngle`
    pub const CONVERGENCE_ANGLE: &str = "π";
    /// `phaseParameter`
    pub const PHASE_PARAMETER: &str = "e^{iπ/6}";
    /// `stageCount`
    pub const STAGE_COUNT: i64 = 6;
}

/// The canonical phase rotation schedule for the 6-stage cascade.
pub mod phase_schedule {
    /// `baseAngle`
    pub const BASE_ANGLE: &str = "π/6";
    /// `rotationSchedule`
    pub const ROTATION_SCHEDULE: &str = "Ω⁰, Ω¹, Ω², Ω³, Ω⁴, Ω⁵";
}

/// The default convergence target angle π.
pub mod convergence_target {
    /// `targetAngle`
    pub const TARGET_ANGLE: &str = "π";
}

/// The canonical complex conjugate rollback operation: z → z̄.
pub mod conjugate_rollback {
    /// `rollbackTarget` -> `stage_initialization`
    pub const ROLLBACK_TARGET: &str = "https://uor.foundation/cascade/stage_initialization";
}

/// Failure: no resolver matched the dispatch query.
pub mod dispatch_miss {
    /// `failureKind`
    pub const FAILURE_KIND: &str = "DispatchMiss";
}

/// Failure: grounding to a valid ring address failed.
pub mod grounding_failure {
    /// `failureKind`
    pub const FAILURE_KIND: &str = "GroundingFailure";
}

/// Failure: cascade stalled before reaching convergence angle.
pub mod convergence_stall {
    /// `failureKind`
    pub const FAILURE_KIND: &str = "ConvergenceStall";
}

/// Failure: accumulation detected a logical contradiction.
pub mod contradiction_detected {
    /// `failureKind`
    pub const FAILURE_KIND: &str = "ContradictionDetected";
}

/// Failure: coherence constraint violated during extraction.
pub mod coherence_violation {
    /// `failureKind`
    pub const FAILURE_KIND: &str = "CoherenceViolation";
}

/// Successful termination: all fibers saturated.
pub mod full_saturation_success {
    /// `saturationReached`
    pub const SATURATION_REACHED: bool = true;
}

/// Preflight: checks that the cascade can reach convergence.
pub mod feasibility_check {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "Feasibility";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 1;
}

/// Preflight: checks that every dispatch query has a resolver.
pub mod dispatch_coverage_check {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "DispatchCoverage";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 2;
}

/// Preflight: checks package-level coherence constraints.
pub mod package_coherence_check {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "PackageCoherence";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 3;
}

/// The default service window: 3 epochs, zero offset.
pub mod default_service_window {
    /// `windowOffset`
    pub const WINDOW_OFFSET: i64 = 0;
    /// `windowSize`
    pub const WINDOW_SIZE: i64 = 3;
}

/// Advancement from Initialization to Declare.
pub mod advance_init_to_declare {
    /// `advanceFrom` -> `stage_initialization`
    pub const ADVANCE_FROM: &str = "https://uor.foundation/cascade/stage_initialization";
    /// `advanceTo` -> `stage_declare`
    pub const ADVANCE_TO: &str = "https://uor.foundation/cascade/stage_declare";
}

/// An all-or-nothing atomic cascade transaction.
pub mod atomic_transaction {
    /// `transactionPolicy`
    pub const TRANSACTION_POLICY: &str = "AllOrNothing";
}

/// A trivially satisfied guard with no predicates.
pub mod empty_guard {}

/// The identity effect: no state changes.
pub mod identity_effect {}

/// A predicate that always evaluates to true.
pub mod true_predicate {
    /// `predicateField`
    pub const PREDICATE_FIELD: &str = "*";
    /// `predicateOperator`
    pub const PREDICATE_OPERATOR: &str = "true";
    /// `predicateValue`
    pub const PREDICATE_VALUE: &str = "*";
}

/// A no-op property binding that changes nothing.
pub mod noop_bind {
    /// `bindTarget`
    pub const BIND_TARGET: &str = "none";
    /// `bindValue`
    pub const BIND_VALUE: &str = "unchanged";
}

/// Lease is pending activation.
pub mod pending {
    /// `leasePhase`
    pub const LEASE_PHASE: &str = "Pending";
}

/// Lease is active and resources are allocated.
pub mod active {
    /// `leasePhase`
    pub const LEASE_PHASE: &str = "Active";
}

/// Lease has been explicitly released.
pub mod released {
    /// `leasePhase`
    pub const LEASE_PHASE: &str = "Released";
}

/// Lease has expired due to timeout.
pub mod expired {
    /// `leasePhase`
    pub const LEASE_PHASE: &str = "Expired";
}

/// Lease is temporarily suspended.
pub mod suspended {
    /// `leasePhase`
    pub const LEASE_PHASE: &str = "Suspended";
}

/// Preflight result: cascade is feasible.
pub mod feasibility_witness {
    /// `feasibilityKind`
    pub const FEASIBILITY_KIND: &str = "Feasible";
}

/// Preflight result: cascade is infeasible.
pub mod infeasibility_witness {
    /// `feasibilityKind`
    pub const FEASIBILITY_KIND: &str = "Infeasible";
    /// `feasibilityWitness`
    pub const FEASIBILITY_WITNESS: &str = "obstruction detected";
}

/// Preflight: timing feasibility check.
pub mod preflight_timing {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "Timing";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 4;
}

/// Preflight: runtime timing bounds check.
pub mod runtime_timing {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "RuntimeTiming";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 5;
}

/// Preflight: verifies thermodynamicBudget ≥ bitsWidth(unitQuantumLevel) × ln 2. Rejects the CompileUnit if the budget is absent or insufficient. Must execute before all other preflights (preflightOrder 0). Cost is O(1) per CS_4.
pub mod budget_solvency_check {
    /// `preflightKind`
    pub const PREFLIGHT_KIND: &str = "BudgetSolvency";
    /// `preflightOrder`
    pub const PREFLIGHT_ORDER: i64 = 0;
}

/// Default back-pressure signal with medium threshold.
pub mod back_pressure_default {
    /// `pressureLevel`
    pub const PRESSURE_LEVEL: &str = "Medium";
    /// `pressureThreshold`
    pub const PRESSURE_THRESHOLD: &str = "0.75";
}