uor-foundation 0.2.0

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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
// @generated by uor-crate from uor-ontology — do not edit manually

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

use crate::enums::VerificationDomain;
use crate::enums::WittLevel;
use crate::Primitives;

/// The composite endofunctor ψ = ψ_9 ∘ … ∘ ψ_1, parameterized by Ω = e^{iπ/6}.
pub trait EulerReduction<P: Primitives> {
    /// The base phase parameter Ω for this reduction (e.g., e^{iπ/6}).
    fn phase_parameter(&self) -> P::Decimal;
    /// The number of stages in this reduction.
    fn stage_count(&self) -> P::NonNegativeInteger;
    /// The cumulative phase angle at which the reduction converges.
    fn convergence_angle(&self) -> P::Decimal;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The ordered list of ψ-maps that compose this reduction.
    fn composed_of_maps(&self) -> &[Self::TermExpression];
}

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

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

/// Validation at each stage boundary checking that the accumulated phase angle matches the expected Ω^k.
pub trait PhaseGateAttestation<P: Primitives> {
    /// Associated type for `ReductionStep`.
    type ReductionStep: ReductionStep<P>;
    /// The reduction stage at which this gate is applied.
    fn gate_stage(&self) -> &Self::ReductionStep;
    /// The expected phase angle Ω^k at this gate.
    fn gate_expected_phase(&self) -> P::Decimal;
    /// 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 `ReductionStep`.
    type ReductionStep: ReductionStep<P>;
    /// The reduction stage to which execution rolls back on gate failure.
    fn rollback_target(&self) -> &Self::ReductionStep;
}

/// A named stage of the reduction. The standard reduction has six stages (Initialization through Convergence).
pub trait ReductionStep<P: Primitives> {
    /// Zero-based index of this stage in the reduction.
    fn stage_index(&self) -> P::NonNegativeInteger;
    /// Human-readable name of this reduction stage.
    fn stage_name(&self) -> &P::String;
    /// The expected phase angle Ω^k at this stage.
    fn expected_phase(&self) -> P::Decimal;
    /// Associated type for `StatePredicate`.
    type StatePredicate: crate::kernel::predicate::StatePredicate<P>;
    /// A typed predicate evaluated on the current ReductionState. Must be satisfied to enter this stage.
    fn entry_guard(&self) -> &Self::StatePredicate;
    /// A typed predicate that must be satisfied before the reduction 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 reduction execution at a specific point, including the current stage, phase angle, and pinned mask.
pub trait ReductionState<P: Primitives> {
    /// Associated type for `ReductionStep`.
    type ReductionStep: ReductionStep<P>;
    /// The reduction stage at which execution is currently positioned.
    fn current_stage(&self) -> &Self::ReductionStep;
    /// The accumulated phase angle at the current point.
    fn phase_angle(&self) -> P::Decimal;
    /// Bit mask of sites that are pinned (resolved) at this point.
    fn pinned_mask(&self) -> P::NonNegativeInteger;
    /// The number of free (unresolved) sites at this point.
    fn free_rank(&self) -> P::NonNegativeInteger;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The site state descriptor within a reduction state.
    fn site_state(&self) -> &Self::TermExpression;
}

/// Guard-effect pair governing stage transitions in the reduction. The guard must be satisfied before the effect is applied.
pub trait ReductionRule<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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The effect applied when this transition fires.
    fn transition_effect(&self) -> &Self::TermExpression;
    /// Whether this transition advances to the next stage.
    fn transition_advance(&self) -> P::Boolean;
}

/// Temporal segment of reduction execution. Each epoch represents one complete pass through the reduction stages.
pub trait Epoch<P: Primitives> {
    /// Zero-based index of this epoch in the reduction execution.
    fn epoch_index(&self) -> P::NonNegativeInteger;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// Metadata or summary datum for this epoch.
    fn epoch_datum(&self) -> &Self::TermExpression;
}

/// Transition between epochs. Carries metadata about the epoch boundary crossing.
pub trait EpochBoundary<P: Primitives> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The type of epoch boundary crossing (e.g., normal, forced, timeout).
    fn epoch_boundary_type(&self) -> &Self::TermExpression;
    /// Whether grounding was preserved across the epoch boundary.
    fn preserved_grounding(&self) -> P::Boolean;
}

/// A Boolean expression over the reduction 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 site pinning: target site + value.
pub trait PropertyBind<P: Primitives> {
    /// The target site identifier for this binding.
    fn bind_target(&self) -> &P::String;
    /// The value to pin the target site to.
    fn bind_value(&self) -> &P::String;
}

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

/// 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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// Reference to the base context provided by this service window.
    fn base_context_ref(&self) -> &Self::TermExpression;
}

/// An atomic group of state changes within the reduction.
pub trait ReductionTransaction<P: Primitives> {
    /// The execution policy for this transaction (e.g., AllOrNothing, BestEffort).
    fn transaction_policy(&self) -> &P::String;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The outcome of this transaction (e.g., committed, rolled back).
    fn transaction_outcome(&self) -> &Self::TermExpression;
    /// The scope of sites affected by this transaction.
    fn transaction_scope(&self) -> &Self::TermExpression;
    /// Current status of this transaction (e.g., pending, committed).
    fn transaction_status(&self) -> &Self::TermExpression;
}

/// Successful termination (FullGrounding).
pub trait PipelineSuccess<P: Primitives> {
    /// Whether full grounding was achieved.
    fn grounding_reached(&self) -> P::Boolean;
    /// The final grounding level achieved on pipeline success.
    fn final_grounding(&self) -> P::Decimal;
}

/// 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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The reduction stage at which the pipeline failure occurred.
    fn failure_stage(&self) -> &Self::TermExpression;
}

/// 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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The result of the preflight check (e.g., pass, fail).
    fn preflight_result(&self) -> &Self::TermExpression;
    /// 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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The kind of infeasibility detected.
    fn infeasibility_kind(&self) -> &Self::TermExpression;
}

/// 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> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// Unique identifier for this managed lease.
    fn managed_lease_id(&self) -> &Self::TermExpression;
    /// 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 site 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 `ReductionState`.
    type ReductionState: ReductionState<P>;
    /// The reduction state captured at this checkpoint.
    fn checkpoint_state(&self) -> &Self::ReductionState;
    /// The remaining site budget at this checkpoint.
    fn lease_remaining_budget(&self) -> P::NonNegativeInteger;
}

/// Flow control when reduction 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::Decimal;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The source stage emitting back-pressure.
    fn source_stage(&self) -> &Self::TermExpression;
    /// The target stage receiving back-pressure.
    fn target_stage(&self) -> &Self::TermExpression;
}

/// 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;
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The reason for deferring these queries.
    fn deferral_reason(&self) -> &Self::TermExpression;
}

/// Transfer of a lease from one computation to another.
pub trait SubleaseTransfer<P: Primitives> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The lease being transferred from.
    fn source_lease_ref(&self) -> &Self::TermExpression;
    /// The lease being transferred to.
    fn target_lease_ref(&self) -> &Self::TermExpression;
    /// The site 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> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The state field tested by this comparison predicate.
    fn comparison_field(&self) -> &Self::TermExpression;
    /// The comparison operator (e.g., '=', '<', '>=').
    fn comparison_operator(&self) -> &Self::TermExpression;
    /// The value against which the comparison is made.
    fn comparison_value(&self) -> &Self::TermExpression;
}

/// Conjunction (AND) of multiple predicates.
pub trait ConjunctionPredicate<P: Primitives>: PredicateExpression<P> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// A conjunct predicate in a conjunction.
    fn conjuncts(&self) -> &[Self::TermExpression];
}

/// Disjunction (OR) of multiple predicates.
pub trait DisjunctionPredicate<P: Primitives>: PredicateExpression<P> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// A disjunct predicate in a disjunction.
    fn disjuncts(&self) -> &[Self::TermExpression];
}

/// Negation (NOT) of a single predicate.
pub trait NegationPredicate<P: Primitives>: PredicateExpression<P> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The predicate being negated.
    fn negated_predicate(&self) -> &Self::TermExpression;
}

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

/// Predicate testing whether grounding exceeds a threshold.
pub trait GroundingPredicate<P: Primitives>: PredicateExpression<P> {
    /// The grounding threshold above which the predicate holds.
    fn grounding_threshold(&self) -> P::NonNegativeInteger;
}

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

/// Predicate testing equality of two expressions.
pub trait EqualsPredicate<P: Primitives>: PredicateExpression<P> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The left-hand side of an equality test.
    fn equality_left(&self) -> &Self::TermExpression;
    /// The right-hand side of an equality test.
    fn equality_right(&self) -> &Self::TermExpression;
}

/// 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::NonNegativeInteger;
}

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

/// The typed input graph submitted to the reduction pipeline. Packages a root Term, target quantum level, verification domains, and thermodynamic budget. Stage 0 accepts exactly one CompileUnit and initializes the reduction state vector from it.
pub trait CompileUnit<P: Primitives> {
    /// Associated type for `TermExpression`.
    type TermExpression: crate::kernel::schema::TermExpression<P>;
    /// The root term expression of a CompileUnit — the top-level syntactic node from which all sub-expressions descend.
    fn root_term(&self) -> &Self::TermExpression;
    /// The quantum level at which this CompileUnit operates.
    fn unit_witt_level(&self) -> WittLevel;
    /// The Landauer-bounded energy budget for this CompileUnit's resolution, measured in k_B T ln 2 units.
    fn thermodynamic_budget(&self) -> P::Decimal;
    /// The verification domain(s) targeted by this CompileUnit.
    fn target_domains(&self) -> &[VerificationDomain];
    /// Associated type for `Element`.
    type Element: crate::kernel::address::Element<P>;
    /// Content-addressable identifier computed as the u:Element 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::Element;
}

/// 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: reduction 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/reduction/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/reduction/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/reduction/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/reduction/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/reduction/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/reduction/stage_extract";
}

/// The canonical Euler reduction instance with Ω = e^{iπ/6} and 6 stages.
pub mod euler_reduction_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 reduction.
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/reduction/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: reduction 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 sites saturated.
pub mod full_grounding_success {
    /// `groundingReached`
    pub const GROUNDING_REACHED: bool = true;
}

/// Preflight: checks that the reduction 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/reduction/stage_initialization";
    /// `advanceTo` -> `stage_declare`
    pub const ADVANCE_TO: &str = "https://uor.foundation/reduction/stage_declare";
}

/// An all-or-nothing atomic reduction 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: reduction is feasible.
pub mod feasibility_witness {
    /// `feasibilityKind`
    pub const FEASIBILITY_KIND: &str = "Feasible";
}

/// Preflight result: reduction 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(unitWittLevel) × 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";
}