Repository navigation
Expand file tree
/
Copy pathreview_diff.patch
More file actions
313 lines (313 loc) · 13.5 KB
/
Copy pathreview_diff.patch
File metadata and controls
313 lines (313 loc) · 13.5 KB
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
diff --git a/LEXICON.md b/LEXICON.md
index 2d33a65..3f75cd3 100644
--- a/LEXICON.md
+++ b/LEXICON.md
@@ -375,3 +375,36 @@ A strictly typed, verifiable JSON schema used to preserve the causal lineage of
}
}
```
+
+---
+
+## SECTION VIII — TEMPORAL BLENDING ENGINE DEFINITIONS (Temporal Blending)
+
+### PAT-032 · Temporal Blending Engine (TBE)
+**Type**: Orchestration Architecture
+**Definition**: A multi-agent architecture designed to resolve Chronotopological Drift when fusing temporally divergent conceptual spaces under the governance of the Verifiable Cognition Stack (VCS).
+
+### PAT-033 · Causal Path Integrity (CPI)
+**Type**: Metric / Governance Constraint
+**Definition**: A mathematically formal constraint enforced by the System Assurance Agent, quantifying the degree of logical adherence to the laws of cause-and-effect over a discrete trace of states generated by an LLM. Requires threshold CPI >= 0.95.
+
+### PAT-034 · Chronotopological Drift
+**Type**: Phenomenon / Pathological Decay
+**Definition**: Sudden, discontinuous jumps in the latent trajectory of generated semantic flows across disjoint semantic territories, violating temporal causal logic. Prevented via enforcing Epistemic Rheology bounds.
+
+### PAT-035 · System Assurance Agent (SAA)
+**Type**: Agent
+**Definition**: The entity responsible for verifying the Causal Path Integrity (CPI) across generated discrete state transitions and enforcing the >0.95 threshold, intercepting violations and triggering Reflexive Repair.
+
+### PAT-036 · Epistemic Rheology
+**Type**: Mathematical Concept
+**Definition**: The continuous flow and deformation of semantic concepts under temporal and logical constraints. Governed by a semantic viscosity parameter ($\mu$) to limit spatial jumps in generated trajectories.
+
+### PAT-037 · Cost of Coherence Overhead (CCH)
+**Type**: Metric
+**Definition**: The computational resources and tokens expended to maintain semantic rigor and verify constraints via deep symbolic modeling. Scales with Verification Depth x Tokens.
+
+### PAT-038 · Cost of Structural Discovery (CSD)
+**Type**: Metric
+**Definition**: The computational budget allocated to explore low-probability regions of the latent space (Intentional Drift) to generate novelty. Scales with Temperature (T) x Variance.
+
diff --git a/docs/adr/41-temporal-blending-engine.md b/docs/adr/41-temporal-blending-engine.md
new file mode 100644
index 0000000..803d6bc
--- /dev/null
+++ b/docs/adr/41-temporal-blending-engine.md
@@ -0,0 +1,43 @@
+# ADR 41: Temporal Blending Engine and Causal Path Integrity (CPI)
+
+## Context
+The **Temporal Blending Engine (TBE)** is a multi-agent orchestration architecture designed to resolve **Chronotopological Drift** when fusing temporally divergent conceptual spaces under the governance of the Verifiable Cognition Stack (VCS).
+
+## Decision
+We implement a mathematically formal constraint known as **Causal Path Integrity (CPI)** to govern semantic flows in LLM-generated trajectories. The TBE utilizes the **System Assurance Agent (SAA)** to enforce a non-negotiable threshold of `CPI >= 0.95`.
+
+## Mathematical Formalization
+
+### 1. Isomorphic Formalization of the Temporal Blending State-Space
+To model **Epistemic Rheology**—the continuous flow of concepts—we define a continuous trajectory $\mathbf{S}_t \in \mathcal{M}$ (the latent space) using a Double-Scope Blend (DSCB):
+$$\mathbf{S}_t = \mathbf{\Phi}\big(\mathbf{X}_N(t), \mathbf{X}_C(t), \mathbf{W}_t\big)$$
+
+A discrete state $s_k$ is defined by a valuation vector over a finite set of Boolean fluents $F = \{f_1, f_2, \dots, f_m\}$, such that $s_k \in \{0, 1\}^m$.
+
+Causal Actions have:
+1. **Preconditions ($\operatorname{Pre}(a)$):** Required fluent states.
+2. **Effects ($\operatorname{Eff}(a)$):** Changes to fluent states.
+
+We enforce the **Frame Operator** $\operatorname{Frame}(s_k, s_{k+1}, a)$ to ensure fluents not in $\operatorname{Eff}(a)$ remain invariant.
+
+### 2. Causal Path Integrity (CPI)
+For a trace $\tau = (s_1, a_1, s_2, a_2, \dots, a_{N-1}, s_N)$, the CPI is defined as:
+$$\operatorname{CPI}(\tau) = \frac{1}{N-1} \sum_{k=1}^{N-1} \mathbb{I}\Big( s_k \models \operatorname{Pre}(a_k) \;\wedge\; s_{k+1} \models \operatorname{Eff}(a_k) \;\wedge\; \operatorname{Frame}(s_k, s_{k+1}, a_k) \Big)$$
+The SAA enforces the constraint:
+$$\operatorname{CPI}(\tau) \geq 0.95$$
+
+### 3. Cascading Contradiction Boundary
+If an action disabled a fluent (e.g., $f_{cam} = 0$), and a subsequent action requires it ($f_{cam} = 1$), a contradiction occurs. For a sequence length $N < 21$, a single contradiction will drop the CPI below 0.95, mathematically preventing the violation from passing the SAA gate. For longer sequences ($N \geq 21$), execution is halted via an Epistemic Escrow / Reflexive Repair Loop.
+
+### 4. Epistemic Rheological Stability
+The latent trajectory velocity is governed by the Epistemic Rheology Equation:
+$$\mu \nabla^2 \mathbf{u} - \nabla p + \mathbf{f}_{\text{constraint}} = 0$$
+By increasing semantic viscosity $\mu$, we establish a Lipschitz continuity bound to guarantee that the transition does not jump disjoint semantic territories, thereby preventing **Chronotopological Drift**.
+
+### 5. Tension Frontier Parameters
+- **Cost of Coherence Overhead (CCH):** Verification Depth $\times$ Tokens.
+- **Cost of Structural Discovery (CSD):** Temperature ($T$) $\times$ Variance.
+Over-allocating CSD drops viscosity $\mu$, leading to high CFDI (Confidence-Fidelity Divergence Index) and triggering Epistemic Escrow.
+
+## Status
+Accepted.
diff --git a/src/conceptual_synthesis/__init__.py b/src/conceptual_synthesis/__init__.py
index 6de4985..12e5833 100644
--- a/src/conceptual_synthesis/__init__.py
+++ b/src/conceptual_synthesis/__init__.py
@@ -8,3 +8,9 @@ from .jit_swarm_orchestrator import (
)
from .action_alignment_loss import ActionAlignmentLoss
from .ala_agent import AnomalyLearningAgent
+from .temporal_blending_engine import (
+ DiscreteState,
+ CausalAction,
+ Trace,
+ SystemAssuranceAgent
+)
diff --git a/src/conceptual_synthesis/temporal_blending_engine.py b/src/conceptual_synthesis/temporal_blending_engine.py
new file mode 100644
index 0000000..0b0fbfb
--- /dev/null
+++ b/src/conceptual_synthesis/temporal_blending_engine.py
@@ -0,0 +1,77 @@
+from typing import Dict, List, Any
+
+class DiscreteState:
+ def __init__(self, fluents: Dict[str, Any]):
+ self.fluents = fluents
+
+ def __getitem__(self, key: str) -> Any:
+ return self.fluents.get(key, None)
+
+ def contains(self, key: str) -> bool:
+ return key in self.fluents
+
+class CausalAction:
+ def __init__(self, name: str, preconditions: Dict[str, Any], effects: Dict[str, Any]):
+ self.name = name
+ self.preconditions = preconditions
+ self.effects = effects
+
+class Trace:
+ def __init__(self, states: List[DiscreteState], actions: List[CausalAction]):
+ if len(states) != len(actions) + 1:
+ raise ValueError("A trace must have exactly one more state than actions.")
+ self.states = states
+ self.actions = actions
+
+class SystemAssuranceAgent:
+ def __init__(self, cpi_threshold: float = 0.95):
+ self.cpi_threshold = cpi_threshold
+
+ def calculate_cpi(self, trace: Trace) -> float:
+ N = len(trace.states)
+ if N <= 1:
+ return 1.0
+
+ valid_transitions = 0
+
+ for k in range(N - 1):
+ s_k = trace.states[k]
+ s_k1 = trace.states[k + 1]
+ a_k = trace.actions[k]
+
+ # Check preconditions: s_k |= Pre(a_k)
+ preconditions_met = True
+ for f_name, f_val in a_k.preconditions.items():
+ if not s_k.contains(f_name) or s_k[f_name] != f_val:
+ preconditions_met = False
+ break
+
+ # Check effects: s_{k+1} |= Eff(a_k)
+ effects_applied = True
+ for f_name, f_val in a_k.effects.items():
+ if not s_k1.contains(f_name) or s_k1[f_name] != f_val:
+ effects_applied = False
+ break
+
+ # Check frame operator: Frame(s_k, s_{k+1}, a_k)
+ frame_operator_valid = True
+ for f_name in s_k.fluents.keys():
+ if f_name not in a_k.effects:
+ # If not in effects, it must remain invariant
+ if not s_k1.contains(f_name) or s_k1[f_name] != s_k[f_name]:
+ frame_operator_valid = False
+ break
+
+ # Indicator function logic
+ if preconditions_met and effects_applied and frame_operator_valid:
+ valid_transitions += 1
+
+ cpi = valid_transitions / (N - 1)
+ return cpi
+
+ def verify_trace(self, trace: Trace) -> bool:
+ return self.calculate_cpi(trace) >= self.cpi_threshold
+
+ def enforce(self, trace: Trace) -> None:
+ if not self.verify_trace(trace):
+ raise Exception("Epistemic Escrow: Causal Path Integrity (CPI) threshold breached. Triggering Reflexive Repair Loop.")
diff --git a/tests/test_temporal_blending.py b/tests/test_temporal_blending.py
new file mode 100644
index 0000000..605ea69
--- /dev/null
+++ b/tests/test_temporal_blending.py
@@ -0,0 +1,120 @@
+import unittest
+from typing import Dict, List, Set, Optional
+
+from src.conceptual_synthesis.temporal_blending_engine import (
+ DiscreteState,
+ CausalAction,
+ SystemAssuranceAgent,
+ Trace
+)
+
+class TestTemporalBlendingEngine(unittest.TestCase):
+ def setUp(self):
+ self.saa = SystemAssuranceAgent(cpi_threshold=0.95)
+
+ def test_cpi_calculation_perfect_trace(self):
+ s1 = DiscreteState(fluents={"f_cam": 1, "f_door_open": 0})
+ a1 = CausalAction(
+ name="open_door",
+ preconditions={"f_cam": 1},
+ effects={"f_door_open": 1}
+ )
+ s2 = DiscreteState(fluents={"f_cam": 1, "f_door_open": 1})
+
+ trace = Trace(states=[s1, s2], actions=[a1])
+ cpi = self.saa.calculate_cpi(trace)
+ self.assertEqual(cpi, 1.0)
+ self.assertTrue(self.saa.verify_trace(trace))
+
+ def test_cpi_calculation_precondition_failure(self):
+ s1 = DiscreteState(fluents={"f_cam": 0, "f_door_open": 0})
+ a1 = CausalAction(
+ name="open_door",
+ preconditions={"f_cam": 1}, # Contradiction: f_cam is 0
+ effects={"f_door_open": 1}
+ )
+ s2 = DiscreteState(fluents={"f_cam": 0, "f_door_open": 1})
+
+ trace = Trace(states=[s1, s2], actions=[a1])
+ cpi = self.saa.calculate_cpi(trace)
+ self.assertEqual(cpi, 0.0)
+ self.assertFalse(self.saa.verify_trace(trace))
+
+ def test_cpi_calculation_effect_failure(self):
+ s1 = DiscreteState(fluents={"f_cam": 1, "f_door_open": 0})
+ a1 = CausalAction(
+ name="open_door",
+ preconditions={"f_cam": 1},
+ effects={"f_door_open": 1}
+ )
+ # Contradiction: effect f_door_open: 1 was not applied
+ s2 = DiscreteState(fluents={"f_cam": 1, "f_door_open": 0})
+
+ trace = Trace(states=[s1, s2], actions=[a1])
+ cpi = self.saa.calculate_cpi(trace)
+ self.assertEqual(cpi, 0.0)
+ self.assertFalse(self.saa.verify_trace(trace))
+
+ def test_cpi_calculation_frame_operator_failure(self):
+ s1 = DiscreteState(fluents={"f_cam": 1, "f_door_open": 0})
+ a1 = CausalAction(
+ name="open_door",
+ preconditions={"f_cam": 1},
+ effects={"f_door_open": 1}
+ )
+ # Contradiction: f_cam changed even though it was not in effects
+ s2 = DiscreteState(fluents={"f_cam": 0, "f_door_open": 1})
+
+ trace = Trace(states=[s1, s2], actions=[a1])
+ cpi = self.saa.calculate_cpi(trace)
+ self.assertEqual(cpi, 0.0)
+ self.assertFalse(self.saa.verify_trace(trace))
+
+ def test_cascading_contradiction_boundary(self):
+ # Create a trace with length N=20 (19 transitions)
+ states = []
+ actions = []
+
+ # Initial state
+ states.append(DiscreteState(fluents={"f_cam": 1, "f_step": 0}))
+
+ # Step 1: disable camera
+ actions.append(CausalAction(
+ name="disable_cam",
+ preconditions={"f_cam": 1},
+ effects={"f_cam": 0, "f_step": 1}
+ ))
+ states.append(DiscreteState(fluents={"f_cam": 0, "f_step": 1}))
+
+ # Steps 2-18: valid actions
+ for i in range(2, 19):
+ actions.append(CausalAction(
+ name=f"step_{i}",
+ preconditions={"f_step": i-1},
+ effects={"f_step": i}
+ ))
+ states.append(DiscreteState(fluents={"f_cam": 0, "f_step": i}))
+
+ # Step 19: contradiction action requires camera to be 1, but frame operator says it is 0
+ actions.append(CausalAction(
+ name="require_cam",
+ preconditions={"f_cam": 1}, # This will fail
+ effects={"f_step": 19}
+ ))
+ states.append(DiscreteState(fluents={"f_cam": 0, "f_step": 19}))
+
+ trace = Trace(states=states, actions=actions)
+
+ # We have 19 transitions, 1 fails. Score = 18/19 = ~0.947
+ cpi = self.saa.calculate_cpi(trace)
+ self.assertLess(cpi, 0.95)
+ self.assertFalse(self.saa.verify_trace(trace))
+
+ # Epistemic escrow exception should be raised or logged
+ with self.assertRaises(Exception) as context:
+ self.saa.enforce(trace)
+
+ self.assertTrue("Epistemic Escrow" in str(context.exception))
+
+if __name__ == '__main__':
+ unittest.main()