tatara_core/domain/classification.rs
1//! The six classification dimensions.
2//!
3//! Every convergence point is classified along six orthogonal axes.
4//! Together, these determine scheduling, coordination, verification,
5//! lifetime, and intelligence participation.
6
7use serde::{Deserialize, Serialize};
8
9// ── Dimension 1: Structure — How Data Flows ───────────────────
10
11/// Structural type of a convergence point — how data flows through it.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
13#[serde(rename_all = "snake_case")]
14pub enum ConvergencePointType {
15 /// 1 input → 1 output (linear conversion).
16 Transform,
17 /// 1 input → N outputs (fan-out, spawns downstream DAGs).
18 Fork,
19 /// N inputs → 1 output (fan-in, merges upstream results).
20 Join,
21 /// N inputs → 1 output (barrier, waits for all inputs).
22 Gate,
23 /// N inputs → 1 output (choice, picks best by policy).
24 Select,
25 /// 1 input → N outputs same type (replicate signal).
26 Broadcast,
27 /// N inputs → 1 output (fold/aggregate).
28 Reduce,
29 /// 1 input → 1 output + side-channel (tap for observation).
30 Observe,
31}
32
33// ── Dimension 2: Substrate — What Dimension ───────────────────
34
35/// Which operational substrate a convergence point belongs to.
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
37#[serde(rename_all = "snake_case")]
38pub enum SubstrateType {
39 /// Cost optimization, billing, budgets, spot markets.
40 Financial,
41 /// CPU, GPU, memory, WASI runtimes.
42 Compute,
43 /// Connectivity, DNS, TLS, routing, mesh.
44 Network,
45 /// Volumes, caches, replication, backups.
46 Storage,
47 /// Secrets, certificates, policies.
48 Security,
49 /// Authentication, authorization, RBAC.
50 Identity,
51 /// Metrics, logs, traces, alerting.
52 Observability,
53 /// Compliance frameworks, data residency, audit.
54 Regulatory,
55}
56
57// ── Dimension 3: Horizon — How Long ───────────────────────────
58
59/// How long a convergence point runs.
60#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
61#[serde(rename_all = "snake_case")]
62pub enum ConvergenceHorizon {
63 /// Has a fixed point — distance CAN reach 0. Terminates.
64 Bounded,
65 /// Runs in perpetuity. Rate is the health signal, not distance.
66 Asymptotic {
67 /// What metric is being optimized.
68 metric: String,
69 /// Minimize or maximize.
70 direction: OptimizationDirection,
71 /// Rate threshold considered healthy.
72 healthy_rate_threshold: f64,
73 },
74}
75
76/// Direction of asymptotic optimization.
77#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
78#[serde(rename_all = "snake_case")]
79pub enum OptimizationDirection {
80 /// Cost, latency, error rate — lower is better.
81 Minimize,
82 /// Revenue, throughput, coverage — higher is better.
83 Maximize,
84}
85
86// ── Dimension 4: Coordination — How Nodes Agree ───────────────
87
88/// CALM theorem classification for an operation.
89/// Determines whether the operation can be distributed without coordination.
90#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
91#[serde(rename_all = "snake_case")]
92pub enum CalmClassification {
93 /// Monotone: can be distributed without coordination.
94 /// Examples: health checks, metrics, flow logs, set unions.
95 Monotone,
96 /// Non-monotone: requires coordination (Raft).
97 /// Examples: allocation placement, job deletion, policy changes.
98 NonMonotone,
99}
100
101// ── Dimension 5: Trust — When Compliance Is Verified ──────────
102// (VerificationPhase lives in compliance_binding.rs)
103
104// ── Dimension 6: Intelligence — Who Drives Convergence ────────
105
106/// Whether intelligence (AI/LLM) participates in convergence.
107#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
108#[serde(rename_all = "snake_case")]
109pub enum ComputationMode {
110 /// Deterministic, no AI. Fully automated, fully reproducible.
111 Mechanical,
112 /// An LLM participates through an interface.
113 AiAssisted {
114 /// What role the AI plays.
115 role: AiRole,
116 /// Through which interface.
117 interface: AiInterface,
118 },
119 /// Mechanical execution with AI at specific boundary phases.
120 Hybrid {
121 /// Phases driven mechanically.
122 mechanical_phases: Vec<String>,
123 /// Phases driven by AI.
124 ai_phases: Vec<String>,
125 },
126}
127
128/// The role an AI plays at a convergence point.
129#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
130#[serde(rename_all = "snake_case")]
131pub enum AiRole {
132 /// Reads convergence state, produces analysis.
133 Observer,
134 /// Recommends actions, system/human decides.
135 Advisor,
136 /// Takes bounded actions within emission catalogs.
137 Actor,
138 /// Reviews convergence correctness, attests.
139 Verifier,
140 /// Generates compliance/performance reports.
141 Reporter,
142}
143
144/// The interface through which AI accesses convergence.
145#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
146#[serde(rename_all = "snake_case")]
147pub enum AiInterface {
148 /// Model Context Protocol — structured tool access.
149 Mcp,
150 /// REST API.
151 Rest,
152 /// GraphQL.
153 GraphQl,
154 /// gRPC.
155 Grpc,
156}
157
158/// The outcome of a convergence point execution.
159#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
160#[serde(rename_all = "snake_case")]
161pub enum ConvergenceOutcome {
162 /// Converged successfully — distance = 0.
163 Converged,
164 /// Cannot converge — permanent failure.
165 Failed { reason: String },
166 /// Partially converged — degraded operation.
167 Degraded {
168 /// What was achieved.
169 achieved: super::convergence_state::ConvergenceDistance,
170 /// What's missing.
171 missing: Vec<String>,
172 },
173}
174
175/// The mechanism that drives convergence at a given point.
176#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
177#[serde(rename_all = "snake_case")]
178pub enum ConvergenceMechanism {
179 /// Raft consensus (leader coordinates).
180 Raft,
181 /// Gossip protocol (eventually consistent, no coordination).
182 Gossip,
183 /// Local computation (no network, single-node).
184 Local,
185 /// NATS event bus (fire-and-forget, append-only).
186 Nats,
187 /// Fixed-point iteration (recursive evaluation until stable).
188 FixedPoint,
189 /// Control feedback loop (PID-like).
190 Feedback,
191}