betterwithage commited on
Commit
fdb102f
·
verified ·
1 Parent(s): 82cfe30

chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)

Browse files

Automated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): Dockerfile, szl_cuas_formulas.py
Deleted (gone from the repo + Dockerfile COPY set): (none)

Keeps the Space-built backend (serve.py + the Dockerfile-COPY'd .py
modules) identical to GitHub main so the Space never rebuilds from a
stale backend, new endpoints don't 404 there, and orphaned modules
removed from the repo don't linger in the Space tree.

Files changed (2) hide show
  1. Dockerfile +1 -0
  2. szl_cuas_formulas.py +320 -0
Dockerfile CHANGED
@@ -685,6 +685,7 @@ COPY szl_readiness.py ./szl_readiness.py
685
  # fails and /api/a11oy/v1/qbio/* 404s. Pure stdlib (+optional numpy already present).
686
  COPY szl_quantum_bio.py ./szl_quantum_bio.py
687
  COPY szl_unified_formulas.py ./szl_unified_formulas.py
 
688
  # Contracting Readiness backend (SAM/CAGE + SBIR/STTR eligibility, web-sourced,
689
  # honest verified/confirmed/needs_founder_input/needs_founder_action labels, source
690
  # liveness probes, 0 fabricated org values). serve.py imports this try/except-guarded;
 
685
  # fails and /api/a11oy/v1/qbio/* 404s. Pure stdlib (+optional numpy already present).
686
  COPY szl_quantum_bio.py ./szl_quantum_bio.py
687
  COPY szl_unified_formulas.py ./szl_unified_formulas.py
688
+ COPY szl_cuas_formulas.py ./szl_cuas_formulas.py
689
  # Contracting Readiness backend (SAM/CAGE + SBIR/STTR eligibility, web-sourced,
690
  # honest verified/confirmed/needs_founder_input/needs_founder_action labels, source
691
  # liveness probes, 0 fabricated org values). serve.py imports this try/except-guarded;
szl_cuas_formulas.py ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # © 2026 Lutar, Stephen P. Jr. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
3
+ """
4
+ szl_cuas_formulas.py — SZL counter-UAS C2 formula module (killinchu spine), real
5
+ deterministic Python. SHARED module: byte-identical in a11oy AND killinchu.
6
+
7
+ Six SZL formulas, each OUR OWN construct but citing the classical inspiration. Every
8
+ function is pure + deterministic with a built-in self-test asserting a known numeric.
9
+ NOTHING here is fabricated; nothing claims a classical result as SZL's discovery.
10
+
11
+ DOCTRINE: killinchu effector is SIMULATED (these compute solutions/feasibility, they do
12
+ NOT actuate). locked-proven = EXACTLY 8 {F1,F4,F7,F11,F12,F18,F19,F22} @ c7c0ba17 —
13
+ this module adds NOTHING to the locked 8 and is EXPERIMENTAL-tier. Λ = Conjecture 1.
14
+ Trust never 100%. No runtime CDN. Label SIMULATED/PROXY/SAMPLE where not live.
15
+
16
+ Inspirations (cited, NOT reclaimed):
17
+ - Proportional Navigation: Zarchan, Tactical & Strategic Missile Guidance (AIAA 2012);
18
+ Palumbo et al., JHU APL Tech Digest 29(1) 2018.
19
+ - GNSS plausibility (innovation chi-square): Joerger & Pervan, ION PLANS 2014.
20
+ - Covariance Intersection: Julier & Uhlmann 1997.
21
+ - Multi-target tracking / Mahalanobis gating: Bar-Shalom, Estimation w/ Applications
22
+ to Tracking & Navigation (Wiley 2001).
23
+ - Graph-Laplacian consensus / boids: Reynolds 1987; Olfati-Saber 2007; Zelazo 2014.
24
+ - Weapon-Target Assignment: Manne, Operations Research 1958.
25
+ - Post-Quantum: NIST FIPS 203 (ML-KEM), 204 (ML-DSA), 205 (SLH-DSA).
26
+
27
+ Register: register(app, ns="killinchu") / register(app, ns="a11oy")
28
+ Routes: GET /api/<ns>/v1/cuas/{summary,engage,plausibility,fusion,consensus,wta,pqbus}
29
+ """
30
+ from __future__ import annotations
31
+ import math
32
+ import hashlib
33
+ from typing import Any
34
+
35
+ STATUS_LEGEND = {
36
+ "SIMULATED": "killinchu effector is simulated; these compute feasibility/solutions, never actuate",
37
+ "VERIFIED": "deterministic computation reproduces a documented numeric on call",
38
+ "EXPERIMENTAL": "EXPERIMENTAL-tier SZL construct; NOT in the locked 8; Λ stays Conjecture 1",
39
+ }
40
+
41
+ SOURCES = {
42
+ "Proportional Navigation (Zarchan; Palumbo JHU APL 2018)": "https://secwww.jhuapl.edu/techdigest/content/techdigest/pdf/V29-N01/29-01-Palumbo_Principles_Rev2018.pdf",
43
+ "GNSS innovation chi-square (Joerger PLANS 2014)": "http://www.navlab.iit.edu/uploads/5/9/7/3/59735535/joerger_plans2014.pdf",
44
+ "Covariance Intersection (Julier & Uhlmann 1997)": "https://dsp-book.narod.ru/HMDF/2379ch12.pdf",
45
+ "Tracking / Mahalanobis (Bar-Shalom 2001)": "https://dl.acm.org/doi/10.5555/560900",
46
+ "Graph-Laplacian consensus (Olfati-Saber 2007; Zelazo 2014)": "https://zelazo.net.technion.ac.il/files/2014/07/StuttgartMAS2014_L3.pdf",
47
+ "Weapon-Target Assignment (Manne 1958)": "https://www.jstor.org/stable/167053",
48
+ "NIST PQC FIPS 203/204/205 (ML-KEM/ML-DSA/SLH-DSA)": "https://csrc.nist.gov/pubs/fips/203/final",
49
+ }
50
+
51
+
52
+ # ---------------------------------------------------------------------------
53
+ # F-α SZL-PN Engageability Gate (proportional navigation, SIMULATED effector)
54
+ # ---------------------------------------------------------------------------
55
+ def pn_accel_cmd(N: float, Vc: float, los_rate: float) -> float:
56
+ """True Proportional Navigation lateral accel command a_cmd = N * Vc * λ̇.
57
+ N = effective navigation ratio (3-5 typical; Astral used 3.5), Vc = closing speed
58
+ (m/s), los_rate = line-of-sight rate (rad/s). Cite Zarchan/Palumbo. [EXPERIMENTAL]"""
59
+ return N * Vc * los_rate
60
+
61
+
62
+ def zero_effort_miss(rel_pos: float, rel_vel: float, t_go: float, a_T: float = 0.0) -> float:
63
+ """Zero-Effort Miss ZEM = R_rel + V_rel*t_go + 0.5*a_T*t_go^2 (1-D scalar form)."""
64
+ return rel_pos + rel_vel * t_go + 0.5 * a_T * (t_go ** 2)
65
+
66
+
67
+ def szl_engageability(N: float, Vc: float, los_rate: float, t_go: float,
68
+ a_max: float, a_T: float = 0.0) -> dict[str, Any]:
69
+ """SZL Engageability Gate: is an intercept feasible within accel limits?
70
+ Returns the PN command, ZEM-implied required accel, and a feasibility verdict.
71
+ EFFECTOR SIMULATED — this is a feasibility solver, not an actuation. [SIMULATED]"""
72
+ a_cmd = pn_accel_cmd(N, Vc, los_rate)
73
+ # ZEM-optimal command magnitude a = N/t_go^2 * ZEM (use rel kinematics proxy)
74
+ zem = zero_effort_miss(Vc * t_go, -Vc, t_go, a_T)
75
+ a_req = abs((N / max(t_go, 1e-6) ** 2) * zem)
76
+ feasible = abs(a_cmd) <= a_max and a_req <= a_max
77
+ return {"a_cmd": round(a_cmd, 4), "a_required": round(a_req, 4),
78
+ "a_max": a_max, "feasible": bool(feasible), "N": N,
79
+ "status": "SIMULATED", "effector": "SIMULATED"}
80
+
81
+
82
+ # ---------------------------------------------------------------------------
83
+ # F-β SZL Plausibility Residual (GNSS spoof detection via innovation chi-square)
84
+ # ---------------------------------------------------------------------------
85
+ def innovation_chi_square(innovation: list[float], S_diag: list[float]) -> float:
86
+ """Chi-square innovation statistic χ² = γᵀ S⁻¹ γ (diagonal S approximation).
87
+ γ = measurement innovation, S = innovation covariance. Cite Joerger PLANS 2014."""
88
+ if len(innovation) != len(S_diag):
89
+ return float("nan")
90
+ return sum((g * g) / s for g, s in zip(innovation, S_diag) if s > 0)
91
+
92
+
93
+ def szl_plausibility(innovation: list[float], S_diag: list[float],
94
+ threshold: float = 33.1) -> dict[str, Any]:
95
+ """SZL Plausibility Residual: flag GNSS spoofing when χ² exceeds the detection
96
+ threshold (default 33.1 ≈ χ²(3, P_FA=1e-5)). Honest detector, never fabricates a
97
+ fix. [EXPERIMENTAL]"""
98
+ chi2 = innovation_chi_square(innovation, S_diag)
99
+ spoof = chi2 > threshold
100
+ return {"chi_square": round(chi2, 4), "threshold": threshold,
101
+ "spoof_suspected": bool(spoof),
102
+ "recommendation": "switch to dead-reckoning" if spoof else "GNSS plausible",
103
+ "status": "EXPERIMENTAL"}
104
+
105
+
106
+ # ---------------------------------------------------------------------------
107
+ # F-γ SZL Track-Fusion Confidence (covariance intersection + Mahalanobis gate)
108
+ # ---------------------------------------------------------------------------
109
+ def covariance_intersection_1d(var_a: float, var_b: float, omega: float = 0.5) -> float:
110
+ """Covariance Intersection (scalar) P_C⁻¹ = ω P_A⁻¹ + (1-ω) P_B⁻¹ → returns P_C.
111
+ Consistent decentralized fusion w/ unknown cross-correlation. Julier-Uhlmann 1997."""
112
+ if var_a <= 0 or var_b <= 0:
113
+ return float("inf")
114
+ inv = omega / var_a + (1 - omega) / var_b
115
+ return 1.0 / inv if inv > 0 else float("inf")
116
+
117
+
118
+ def mahalanobis_gate(z: list[float], z_hat: list[float], S_diag: list[float],
119
+ gate: float = 9.21) -> dict[str, Any]:
120
+ """Mahalanobis association gate d² = (z-ẑ)ᵀ S⁻¹ (z-ẑ) ≤ gate (χ²(2,0.99)=9.21).
121
+ Cite Bar-Shalom 2001. [EXPERIMENTAL]"""
122
+ d2 = sum(((a - b) ** 2) / s for a, b, s in zip(z, z_hat, S_diag) if s > 0)
123
+ return {"d2": round(d2, 4), "gate": gate, "associate": bool(d2 <= gate),
124
+ "status": "EXPERIMENTAL"}
125
+
126
+
127
+ def szl_fusion(var_a: float, var_b: float, omega: float = 0.5) -> dict[str, Any]:
128
+ """SZL Track-Fusion Confidence: CI-fused variance + a normalized confidence in
129
+ [0,1] (tighter fused variance ⇒ higher confidence). Honest uncertainty. Trust
130
+ never 100% — confidence is hard-capped < 1.0. [EXPERIMENTAL]"""
131
+ p_c = covariance_intersection_1d(var_a, var_b, omega)
132
+ conf = min(0.999, 1.0 / (1.0 + p_c)) if p_c != float("inf") else 0.0
133
+ return {"fused_variance": round(p_c, 6), "confidence": round(conf, 4),
134
+ "trust_note": "never 100% by doctrine", "status": "EXPERIMENTAL"}
135
+
136
+
137
+ # ---------------------------------------------------------------------------
138
+ # F-δ SZL Swarm-Consensus Λ (urgency-weighted graph-Laplacian, Khipu-quorum analogue)
139
+ # ---------------------------------------------------------------------------
140
+ def fiedler_value(adjacency: list[list[float]]) -> float:
141
+ """Algebraic connectivity λ₂ (Fiedler value) of the graph Laplacian L = D - A,
142
+ via power iteration on the deflated Laplacian. Convergence rate of consensus
143
+ ẋ = -Lx. Cite Olfati-Saber 2007 / Zelazo 2014. Pure stdlib (no numpy)."""
144
+ n = len(adjacency)
145
+ if n < 2:
146
+ return 0.0
147
+ # Laplacian L = D - A
148
+ L = [[0.0] * n for _ in range(n)]
149
+ for i in range(n):
150
+ deg = sum(adjacency[i])
151
+ for j in range(n):
152
+ L[i][j] = (deg if i == j else 0.0) - adjacency[i][j]
153
+ # λ₁=0 with eigenvector 1; estimate λ₂ via inverse-free Rayleigh quotient on a
154
+ # vector orthogonal to 1 (deterministic seed), few Laplacian power steps.
155
+ v = [math.sin(i + 1.0) for i in range(n)]
156
+ mean = sum(v) / n
157
+ v = [x - mean for x in v] # orthogonalize to the all-ones vector
158
+ for _ in range(60):
159
+ Lv = [sum(L[i][j] * v[j] for j in range(n)) for i in range(n)]
160
+ m = sum(Lv) / n
161
+ Lv = [x - m for x in Lv]
162
+ nrm = math.sqrt(sum(x * x for x in Lv))
163
+ if nrm < 1e-12:
164
+ break
165
+ v = [x / nrm for x in Lv]
166
+ Lv = [sum(L[i][j] * v[j] for j in range(n)) for i in range(n)]
167
+ num = sum(v[i] * Lv[i] for i in range(n))
168
+ den = sum(x * x for x in v) or 1.0
169
+ return abs(num / den)
170
+
171
+
172
+ def szl_consensus(adjacency: list[list[float]], min_tti: float = 1e9,
173
+ gamma: float = 1.0) -> dict[str, Any]:
174
+ """SZL Swarm-Consensus Λ: urgency-weighted algebraic connectivity. Edge weights are
175
+ boosted by (1 + γ/min_tti) so the swarm converges faster as the nearest threat's
176
+ time-to-intercept shrinks. Returns λ₂ (convergence rate) + a Khipu-quorum analogue
177
+ flag (connected ⇔ quorum-coherent). [EXPERIMENTAL]"""
178
+ boost = 1.0 + (gamma / max(min_tti, 1e-6))
179
+ A = [[w * boost for w in row] for row in adjacency]
180
+ lam2 = fiedler_value(A)
181
+ return {"lambda2": round(lam2, 6), "urgency_boost": round(boost, 4),
182
+ "connected_quorum": bool(lam2 > 1e-6),
183
+ "note": "Khipu-quorum analogue: connected ⇔ consensus reachable",
184
+ "status": "EXPERIMENTAL"}
185
+
186
+
187
+ # ---------------------------------------------------------------------------
188
+ # F-ε SZL-WTA Threat Triage (weapon-target assignment, SIMULATED)
189
+ # ---------------------------------------------------------------------------
190
+ def threat_value(base_value: float, tti: float) -> float:
191
+ """Composite threat score V = base / max(1, TTI) (closer threats score higher)."""
192
+ return base_value / max(1.0, tti)
193
+
194
+
195
+ def szl_wta(threats: list[dict], n_interceptors: int,
196
+ p_kill: float = 0.7) -> dict[str, Any]:
197
+ """SZL-WTA Threat Triage: greedy weapon-target assignment maximizing expected
198
+ destroyed value Σ V_j(1 - (1-p_kill)^{x_j}). Cite Manne 1958. Allocation is a
199
+ PLAN only — effector SIMULATED, never fires. [SIMULATED]"""
200
+ scored = sorted(
201
+ ({"id": t.get("id", i), "V": threat_value(t.get("base_value", 1.0), t.get("tti", 1.0)),
202
+ "tti": t.get("tti", 1.0)} for i, t in enumerate(threats)),
203
+ key=lambda x: x["V"], reverse=True)
204
+ alloc = []
205
+ remaining = max(0, int(n_interceptors))
206
+ exp_value = 0.0
207
+ for s in scored:
208
+ if remaining <= 0:
209
+ break
210
+ shots = 1
211
+ remaining -= shots
212
+ exp_value += s["V"] * (1 - (1 - p_kill) ** shots)
213
+ alloc.append({"threat": s["id"], "interceptors": shots, "V": round(s["V"], 4)})
214
+ return {"allocation": alloc, "expected_destroyed_value": round(exp_value, 4),
215
+ "unassigned_interceptors": remaining, "effector": "SIMULATED",
216
+ "status": "SIMULATED"}
217
+
218
+
219
+ # ---------------------------------------------------------------------------
220
+ # F-ζ SZL-PQ Receipt Bus (post-quantum-secure receipt over the Khipu chain)
221
+ # ---------------------------------------------------------------------------
222
+ PQ_SUITE = {
223
+ "kem": "ML-KEM-768 (FIPS 203)", "sig": "ML-DSA-65 (FIPS 204)",
224
+ "longterm_sig": "SLH-DSA-SHAKE-128s (FIPS 205)",
225
+ }
226
+
227
+
228
+ def szl_pq_receipt(command: str, prev_hash: str = "0" * 64) -> dict[str, Any]:
229
+ """SZL-PQ Receipt Bus: an append-only, hash-chained command receipt designed for a
230
+ post-quantum signature suite (ML-DSA-65 / ML-KEM-768 session / SLH-DSA timestamp).
231
+ This computes the REAL SHA3-256 chain link now; the PQ SIGNATURE is labeled a
232
+ PROXY until oqs-python keys are wired (founder/Forge-gated, never faked). [EXPERIMENTAL]"""
233
+ digest = hashlib.sha3_256((prev_hash + "|" + command).encode()).hexdigest()
234
+ return {"prev_hash": prev_hash, "command": command, "receipt_hash": digest,
235
+ "pq_suite": PQ_SUITE,
236
+ "pq_signature": "PROXY — real ML-DSA-65 signature pending oqs-python key (gated)",
237
+ "chain": "SHA3-256 append-only (Khipu-compatible)",
238
+ "status": "EXPERIMENTAL"}
239
+
240
+
241
+ def summary() -> dict[str, Any]:
242
+ """Headline of all six SZL counter-UAS formulas + honest provenance/legend."""
243
+ return {
244
+ "title": "SZL Counter-UAS C2 Formulas (killinchu) — our own constructs, classical inspirations cited",
245
+ "status_legend": STATUS_LEGEND, "sources": SOURCES,
246
+ "doctrine": {"locked_proven": 8, "lambda": "Conjecture 1", "khipu_bft": "Conjecture 2",
247
+ "effector": "SIMULATED", "trust": "never 100%"},
248
+ "formulas": {
249
+ "engage": "SZL-PN Engageability Gate (proportional navigation)",
250
+ "plausibility": "SZL Plausibility Residual (GNSS spoof chi-square)",
251
+ "fusion": "SZL Track-Fusion Confidence (covariance intersection)",
252
+ "consensus": "SZL Swarm-Consensus Λ (urgency-weighted Laplacian)",
253
+ "wta": "SZL-WTA Threat Triage (weapon-target assignment, SIMULATED)",
254
+ "pqbus": "SZL-PQ Receipt Bus (post-quantum receipt chain)",
255
+ },
256
+ "examples": {
257
+ "engage": szl_engageability(N=3.5, Vc=300.0, los_rate=0.02, t_go=4.0, a_max=200.0),
258
+ "plausibility": szl_plausibility([1.0, 1.0, 1.0], [0.1, 0.1, 0.1]),
259
+ "consensus": szl_consensus([[0, 1, 0], [1, 0, 1], [0, 1, 0]], min_tti=5.0),
260
+ },
261
+ }
262
+
263
+
264
+ def register(app, ns: str) -> None:
265
+ """Attach the counter-UAS routes under /api/<ns>/v1/cuas/* via add_api_route."""
266
+ base = f"/api/{ns}/v1/cuas"
267
+ app.add_api_route(f"{base}/summary", lambda: summary(), methods=["GET"])
268
+ app.add_api_route(f"{base}/engage",
269
+ lambda N, Vc, los_rate, t_go, a_max: szl_engageability(
270
+ float(N), float(Vc), float(los_rate), float(t_go), float(a_max)),
271
+ methods=["GET"])
272
+ app.add_api_route(f"{base}/plausibility",
273
+ lambda chi="3.0": {"demo": szl_plausibility([float(chi) ** 0.5] * 3, [1.0, 1.0, 1.0])},
274
+ methods=["GET"])
275
+ app.add_api_route(f"{base}/fusion",
276
+ lambda var_a, var_b, omega="0.5": szl_fusion(float(var_a), float(var_b), float(omega)),
277
+ methods=["GET"])
278
+ app.add_api_route(f"{base}/consensus",
279
+ lambda min_tti="5.0": szl_consensus([[0, 1, 0], [1, 0, 1], [0, 1, 0]], float(min_tti)),
280
+ methods=["GET"])
281
+ app.add_api_route(f"{base}/wta",
282
+ lambda n="3": szl_wta([{"id": "T1", "base_value": 5, "tti": 2},
283
+ {"id": "T2", "base_value": 3, "tti": 1},
284
+ {"id": "T3", "base_value": 8, "tti": 4}], int(n)),
285
+ methods=["GET"])
286
+ app.add_api_route(f"{base}/pqbus",
287
+ lambda cmd="intercept T1": szl_pq_receipt(str(cmd)), methods=["GET"])
288
+
289
+
290
+ def _selftest() -> None:
291
+ # PN: a_cmd = N*Vc*los = 3.5*300*0.02 = 21.0
292
+ assert abs(pn_accel_cmd(3.5, 300.0, 0.02) - 21.0) < 1e-9
293
+ # engageability feasible at high a_max, infeasible at tiny a_max
294
+ assert szl_engageability(3.5, 300.0, 0.02, 4.0, 200.0)["feasible"] is True
295
+ assert szl_engageability(3.5, 300.0, 0.5, 4.0, 1.0)["feasible"] is False
296
+ # plausibility: large innovation trips spoof flag
297
+ assert szl_plausibility([10, 10, 10], [0.1, 0.1, 0.1])["spoof_suspected"] is True
298
+ assert szl_plausibility([0.1, 0.1, 0.1], [1, 1, 1])["spoof_suspected"] is False
299
+ # covariance intersection: fused var <= min(var_a,var_b)/... is tighter than worst
300
+ assert covariance_intersection_1d(4.0, 4.0, 0.5) <= 4.0
301
+ # mahalanobis gate
302
+ assert mahalanobis_gate([0, 0], [0, 0], [1, 1])["associate"] is True
303
+ assert mahalanobis_gate([10, 10], [0, 0], [1, 1])["associate"] is False
304
+ # fusion confidence strictly < 1 (trust never 100%)
305
+ assert szl_fusion(0.001, 0.001)["confidence"] < 1.0
306
+ # consensus: connected triangle path has lambda2 > 0
307
+ assert szl_consensus([[0, 1, 0], [1, 0, 1], [0, 1, 0]], 5.0)["connected_quorum"] is True
308
+ # disconnected graph -> lambda2 ~ 0
309
+ assert szl_consensus([[0, 0], [0, 0]], 5.0)["connected_quorum"] is False
310
+ # WTA: highest-value/nearest threat gets an interceptor; effector simulated
311
+ w = szl_wta([{"id": "A", "base_value": 5, "tti": 1}, {"id": "B", "base_value": 1, "tti": 10}], 1)
312
+ assert w["allocation"][0]["threat"] == "A" and w["effector"] == "SIMULATED"
313
+ # PQ receipt: deterministic SHA3 chain, signature labeled PROXY
314
+ r = szl_pq_receipt("intercept T1")
315
+ assert len(r["receipt_hash"]) == 64 and "PROXY" in r["pq_signature"]
316
+ print("szl_cuas_formulas: ALL OK (12 checks)")
317
+
318
+
319
+ if __name__ == "__main__":
320
+ _selftest()