khipu-sda-core 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. khipu_sda_core-0.1.1/LICENSE +202 -0
  2. khipu_sda_core-0.1.1/MANIFEST.in +2 -0
  3. khipu_sda_core-0.1.1/NOTICE +10 -0
  4. khipu_sda_core-0.1.1/PKG-INFO +393 -0
  5. khipu_sda_core-0.1.1/README.md +367 -0
  6. khipu_sda_core-0.1.1/THIRD_PARTY_NOTICES +84 -0
  7. khipu_sda_core-0.1.1/khipu_sda_core.egg-info/PKG-INFO +393 -0
  8. khipu_sda_core-0.1.1/khipu_sda_core.egg-info/SOURCES.txt +31 -0
  9. khipu_sda_core-0.1.1/khipu_sda_core.egg-info/dependency_links.txt +1 -0
  10. khipu_sda_core-0.1.1/khipu_sda_core.egg-info/requires.txt +14 -0
  11. khipu_sda_core-0.1.1/khipu_sda_core.egg-info/top_level.txt +8 -0
  12. khipu_sda_core-0.1.1/pyproject.toml +47 -0
  13. khipu_sda_core-0.1.1/setup.cfg +4 -0
  14. khipu_sda_core-0.1.1/szl_confidence.py +79 -0
  15. khipu_sda_core-0.1.1/szl_mosaic_core.py +467 -0
  16. khipu_sda_core-0.1.1/szl_mosaic_validate.py +485 -0
  17. khipu_sda_core-0.1.1/szl_sda_envelope.py +225 -0
  18. khipu_sda_core-0.1.1/szl_sda_orbit.py +382 -0
  19. khipu_sda_core-0.1.1/szl_sda_spine.py +440 -0
  20. khipu_sda_core-0.1.1/szl_track_fusion.py +235 -0
  21. khipu_sda_core-0.1.1/szl_witness.py +336 -0
  22. khipu_sda_core-0.1.1/tests/test_dependency_policy.py +56 -0
  23. khipu_sda_core-0.1.1/tests/test_no_mock.py +60 -0
  24. khipu_sda_core-0.1.1/tests/test_orbit_screen.py +113 -0
  25. khipu_sda_core-0.1.1/tests/test_receipt_delegation.py +49 -0
  26. khipu_sda_core-0.1.1/tests/test_receipt_roundtrip.py +86 -0
  27. khipu_sda_core-0.1.1/tests/test_sda_spine.py +204 -0
  28. khipu_sda_core-0.1.1/tests/test_source_dependency_gate.py +73 -0
  29. khipu_sda_core-0.1.1/tests/test_witness_dedup.py +97 -0
  30. khipu_sda_core-0.1.1/tests/test_witness_input_validation.py +103 -0
  31. khipu_sda_core-0.1.1/tests/test_witness_quorum.py +113 -0
  32. khipu_sda_core-0.1.1/tools/check_dependency_policy.py +50 -0
  33. khipu_sda_core-0.1.1/tools/check_installed_wheel.py +63 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ include tools/check_installed_wheel.py
2
+ include tools/check_dependency_policy.py
@@ -0,0 +1,10 @@
1
+ khipu-sda-core / szl_mosaic
2
+ Copyright (c) SZL Holdings.
3
+ Licensed under the Apache License, Version 2.0.
4
+
5
+ This product includes clean-room implementations inspired by the publicly
6
+ described capability of True Anomaly Inc.'s "Mosaic" platform (inspiration only;
7
+ no proprietary code). It adopts algorithm methods from PyOD (BSD-2), PyGOD
8
+ (BSD-2), Merlion (BSD-3), TODS (Apache-2.0), tsod (MIT), GDN (MIT), GraGOD (MIT),
9
+ and python-sgp4 (MIT). See ATTRIBUTION.md and THIRD_PARTY_NOTICES.
10
+ alibi-detect (BSL-1.1) is excluded.
@@ -0,0 +1,393 @@
1
+ Metadata-Version: 2.4
2
+ Name: khipu-sda-core
3
+ Version: 0.1.1
4
+ Summary: Clean-room anomaly/SDA core engine (szl_mosaic).
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Source, https://github.com/szl-holdings/khipu-sda-core
7
+ Project-URL: Repository, https://github.com/szl-holdings/khipu-sda-core
8
+ Project-URL: Homepage, https://a-11-oy.com
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ License-File: THIRD_PARTY_NOTICES
14
+ Requires-Dist: numpy>=2.5.4
15
+ Requires-Dist: scipy>=1.18.1
16
+ Requires-Dist: scikit-learn>=1.9.1
17
+ Requires-Dist: matplotlib>=3.11.2
18
+ Requires-Dist: sgp4>=2.27
19
+ Provides-Extra: torch
20
+ Requires-Dist: torch>=2.14.1; extra == "torch"
21
+ Provides-Extra: receipt
22
+ Requires-Dist: szl-receipt-dsse==0.3.4; extra == "receipt"
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=9.1.1; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ > **SZL Holdings** · Doctrine v11 · Λ = Conjecture 1 (advisory, never "green"/theorem) · canonical [a-11-oy.com](https://a-11-oy.com)
28
+
29
+ # szl_mosaic / khipu-sda-core — SZL-native clean-room anomaly-detection + SDA CORE
30
+
31
+ **SZL Holdings · Dev 1 · Doctrine v11 · clean-room · sovereign · honest**
32
+
33
+ SZL's sovereign answer to True Anomaly's **Mosaic** ("the operating system for
34
+ space superiority"). This is the **clean-room anomaly/SDA CORE organ**: a
35
+ multivariate + graph anomaly-detection ensemble, multi-sensor track fusion into a
36
+ Common Operating Picture (COP), a **real orbital conjunction screen** (sgp4
37
+ time-of-closest-approach + miss distance over a small TLE catalog, honestly
38
+ labeled SCREENING-GRADE / roadmap-toward-operational), and **multi-witness
39
+ verified detection** (a Khipu 3-of-4 quorum, Conjecture 2) — each verdict emitting
40
+ a structured, **honestly UNSIGNED** provenance receipt with an **Λ-gated,
41
+ bounded-confidence** advisory.
42
+
43
+ > **One honest sentence:** today killinchu does **counter-UAS / drone / vessel**
44
+ > track→classify→evaluate→signed-receipt at the air/maritime edge; the **orbital-
45
+ > SDA / Threat-Warning** extension is **roadmap-toward-operational** — the orbital
46
+ > screen now computes **real** sgp4 closest-approach geometry but is honestly
47
+ > labeled **SCREENING-GRADE, NOT \(P_c\)/covariance-grade** and never claims SZL flies.
48
+
49
+ <!-- szl:header v1 -->
50
+ <!-- Native identity: szl-brand@4309f6fce89179331b0b3ed8c99494e76c5be256; Orbit v2 icon. -->
51
+ <p>
52
+ <a href="https://github.com/szl-holdings">
53
+ <img src="https://raw.githubusercontent.com/szl-holdings/szl-brand/4309f6fce89179331b0b3ed8c99494e76c5be256/kit/logos/orbit-v2/suite/szl-icon-32.svg" alt="SZL Holdings — Orbit v2" width="32" height="32" />
54
+ </a>
55
+ </p>
56
+
57
+ **Control before action. Evidence after.**
58
+
59
+ [Product](https://a-11-oy.com) · [Proof](https://a11oy.net) · [GitHub organization](https://github.com/szl-holdings)
60
+ <!-- /szl:header -->
61
+
62
+ ---
63
+
64
+ ## CLEAN-ROOM STATEMENT (read first)
65
+
66
+ This engine is **inspired by the publicly described CAPABILITY** of True Anomaly
67
+ Inc.'s proprietary **Mosaic** platform (SDA / C2 / Threat-Warning) — the public
68
+ four-function decomposition **Detect/Track/ID → Characterize → ML Threat-Warning
69
+ & Assessment → fuse/forecast into a COP** ([Mosaic page](https://www.trueanomaly.space/mosaic);
70
+ [Hilmer/True Anomaly, LinkedIn](https://www.linkedin.com/posts/erichilmer_true-anomaly-lands-174m-contract-from-us-activity-7110684034724233216-371t)).
71
+ **No proprietary Mosaic code, assets, or internals were seen, copied, or
72
+ referenced.** We clean-room the *capability* only, from public descriptions plus
73
+ **verified-permissive** open-source methods. See `ATTRIBUTION.md` +
74
+ `THIRD_PARTY_NOTICES`. **alibi-detect (BSL-1.1) is deliberately excluded.**
75
+
76
+ Lineage adopted (methods only, implemented from scratch): **PyOD** (BSD-2),
77
+ **PyGOD** (BSD-2), **Merlion** (BSD-3), **TODS** (Apache-2.0), **tsod** (MIT),
78
+ **GDN** (MIT), **GraGOD** (MIT), **python-sgp4** (MIT). Runtime deps: numpy, scipy,
79
+ scikit-learn (BSD-3), matplotlib, optional torch (BSD-3-style).
80
+
81
+ ---
82
+
83
+ ## Modules
84
+
85
+ | File | Role | Lineage |
86
+ |---|---|---|
87
+ | `szl_mosaic_core.py` | Multivariate anomaly ENSEMBLE (Isolation-Forest + autoencoder + robust z-score) + **GraphDeviationDetector** (track-relational) + provenance receipt + Λ-gate + conformal CI | PyOD, Merlion/TODS, tsod, GDN/PyGOD |
88
+ | `szl_track_fusion.py` | Multi-sensor track fusion: global-nearest-neighbour association + tiny constant-velocity **Kalman** update → fused **COP** track list | textbook MTT (numpy) |
89
+ | `szl_sda_orbit.py` | **SDA orbital screen (roadmap-toward-operational)**: `python-sgp4` TLE propagation + **REAL pairwise conjunction screen** (time-of-closest-approach + miss distance over a small catalog) + conformal band + advisory orbital-anomaly flag | python-sgp4 (MIT) |
90
+ | `szl_witness.py` | **Multi-witness verified detection**: N independent witness re-scorers + **Khipu 3-of-4 quorum** + quorum receipt (Conjecture 2, proposed) | textbook BFT quorum (numpy) |
91
+ | `szl_confidence.py` | Honest **bounded confidence**: split-conformal band + **PAC-Bayes (Catoni/McAllester)** bound — labeled `ESTIMATE` | conformal; PAC-Bayes (cited) |
92
+ | `szl_sda_envelope.py` | The FROZEN **§3.0 interface contract**: `evaluate(track) -> envelope` with in-toto **Statement v1** receipt | spec §3.0 |
93
+ | `szl_mosaic_validate.py` | Synthetic multi-track generator + injected anomalies + **honest precision/recall** + **orbital conjunction screen** + **witness quorum** + 6-panel matplotlib figure | — |
94
+ | `tests/` | `test_no_mock.py` (no placeholder logic; alibi-detect absent) + `test_receipt_roundtrip.py` + `test_orbit_screen.py` (real sgp4 conjunction) + `test_witness_quorum.py` (real 3-of-4 quorum) | — |
95
+
96
+ ---
97
+
98
+ ## The math (clean-room formulas)
99
+
100
+ ### 1. Robust z-score detector (tsod / PyOD lineage)
101
+ Per channel \(j\), using median and Median-Absolute-Deviation (MAD) for robustness:
102
+ \[
103
+ z_{ij} = \frac{|x_{ij} - \mathrm{median}_j|}{1.4826\,\mathrm{MAD}_j + \epsilon},
104
+ \qquad s_i^{\text{z}} = \max_j z_{ij}.
105
+ \]
106
+ (The constant \(1.4826\) makes MAD a consistent estimator of \(\sigma\) for Gaussians.)
107
+
108
+ ### 2. Autoencoder reconstruction detector (Merlion / TODS lineage)
109
+ A small autoencoder \(g\circ f\) (torch MLP, or numpy PCA fallback) trained on
110
+ standardized normal data; anomaly score is the RMS reconstruction error:
111
+ \[
112
+ s_i^{\text{ae}} = \sqrt{\tfrac{1}{F}\sum_{j=1}^{F}\bigl(x_{ij} - (g\!\circ\! f)(x_i)_j\bigr)^2}.
113
+ \]
114
+
115
+ ### 3. Isolation Forest detector (PyOD lineage, via scikit-learn)
116
+ \(s_i^{\text{if}} = -\,\text{decisionfn}(x_i)\) (negated so larger ⇒ more outlying).
117
+
118
+ ### 4. Ensemble combination
119
+ Each detector's score is min–max normalized to \([0,1]\) using a training-data
120
+ range \((\ell,h)\): \(\tilde s = \mathrm{clip}\!\big((s-\ell)/(h-\ell),0,1\big)\).
121
+ The combined per-cell score is the mean:
122
+ \[
123
+ S_i = \tfrac{1}{3}\bigl(\tilde s_i^{\text{if}} + \tilde s_i^{\text{ae}} + \tilde s_i^{\text{z}}\bigr)\in[0,1].
124
+ \]
125
+
126
+ ### 5. Graph-deviation detector (GDN / PyGOD lineage, clean-room)
127
+ Nodes = tracks; edges = \(k\)-nearest neighbours in **kinematic (velocity) space**
128
+ at a reference snapshot. Each node's features are PREDICTED as the mean of its
129
+ neighbours (a 1-hop graph smoother / message-passing predictor); the deviation
130
+ score is
131
+ \[
132
+ d_i = \frac{\bigl\|x_i - \frac{1}{k}\sum_{j\in N(i)} x_j\bigr\|}{\text{ref-scale}}.
133
+ \]
134
+ A track that maneuvers unlike its kinematic neighbourhood gets a large \(d_i\).
135
+ This is the explainable "which track/sensor deviated" idea of GDN, done minimally.
136
+
137
+ ### 6. Track fusion (textbook MTT)
138
+ Constant-velocity state \(\mathbf{x}=[x,y,v_x,v_y]\); predict
139
+ \(\mathbf{x}\leftarrow F\mathbf{x},\ P\leftarrow FPF^\top+Q\); associate
140
+ measurements to tracks by minimizing total Euclidean cost (Hungarian if scipy,
141
+ else greedy) within a gate; Kalman-correct with gain \(K=PH^\top(HPH^\top+R)^{-1}\).
142
+
143
+ ### 7. Honest bounded confidence
144
+ - **Split-conformal band:** lower/upper = \(\alpha/2,\ 1-\alpha/2\) calibration
145
+ quantiles, widened to contain the observed score.
146
+ - **PAC-Bayes (McAllester):**
147
+ \(\text{risk} \le \hat r + \sqrt{\tfrac{\mathrm{KL} + \ln(2\sqrt{n}/\delta)}{2n}}\).
148
+ Both are reported as `ESTIMATE`. They are bounds/intervals — **never a certainty**.
149
+
150
+ ### 8. Λ-gate (HONEST, ADVISORY — Λ = Conjecture 1)
151
+ \[
152
+ \text{verdict}(S)=\begin{cases}\text{allow}& S<0.35\\ \text{advisory}& 0.35\le S<0.65\\ \text{deny}& S\ge 0.65\end{cases}
153
+ \]
154
+ Verdicts are **advisories** under human-on-the-loop — **never "proven trust"**,
155
+ never folded into locked-proven = 8.
156
+
157
+ ### 9. Orbital conjunction screen (REAL closest-approach geometry)
158
+ Propagate each catalog object with SGP4 over a screening window
159
+ \(\{t_0+k\,\Delta t\}_{k=0}^{N-1}\) to TEME positions \(\mathbf r_a(t),\mathbf r_b(t)\).
160
+ For each pair, the discrete relative range is \(d_k=\lVert\mathbf r_a(t_k)-\mathbf r_b(t_k)\rVert\);
161
+ the time-of-closest-approach (TCA) is refined to sub-step resolution by a local
162
+ 3-point parabolic vertex around the discrete minimum \(k^\star\):
163
+ \[
164
+ \delta=\tfrac12\,\frac{d_{k^\star-1}-d_{k^\star+1}}{d_{k^\star-1}-2d_{k^\star}+d_{k^\star+1}},\qquad
165
+ d_{\min}=d_{k^\star}-\tfrac14\,(d_{k^\star-1}-d_{k^\star+1})\,\delta.
166
+ \]
167
+ A pair is flagged when \(d_{\min}\le\) `threshold_km`. The encounter (relative)
168
+ speed at TCA is \(\lVert\mathbf v_a-\mathbf v_b\rVert\). This is **standard,
169
+ public-domain astrodynamics** (relative-range minimisation + parabolic
170
+ refinement) — no proprietary CA internals.
171
+
172
+ > **HONEST LIMIT — SCREENING-GRADE, NOT \(P_c\)/COVARIANCE-GRADE.** SGP4 propagates
173
+ > **mean elements with no per-object covariance**, so the screen emits a
174
+ > *deterministic miss distance*, **never a probability of collision** \(P_c\). TLE
175
+ > epoch staleness and drag/SRP mismodelling widen the true uncertainty well beyond
176
+ > the reported point miss (km-level along-track error budget). A real CA product
177
+ > (e.g. CARA/CSpOC) fuses covariance, a high-fidelity numerical propagator, and
178
+ > integrates \(P_c\) over the encounter — **this module does triage only**, and is
179
+ > ADVISORY (Λ = Conjecture 1). The miss is wrapped in the §7 conformal band as an
180
+ > `ESTIMATE`, **not** a calibrated risk. The demo catalog uses **real public sample
181
+ > TLEs plus one explicitly-DERIVED co-orbiting companion** (a transparent
182
+ > mean-anomaly offset of a real TLE, labeled SAMPLE/DERIVED) so the screen finds a
183
+ > real, sub-threshold close approach to exercise — we **never fabricate orbital
184
+ > ground truth**.
185
+
186
+ ### 10. Multi-witness verified detection (Khipu 3-of-4 quorum)
187
+ Given a detection with base score \(S\) and evidence vector \(\mathbf e\), each of
188
+ \(M\) **independent witness nodes** \(w\) re-scores it under its own seed: it
189
+ bootstrap-resamples the evidence (\(\tilde{\mathbf e}_w=\mathbf e[\mathrm{idx}_w]+\eta_w\),
190
+ \(\eta_w\sim\mathcal N(0,\sigma^2)\)) and reports
191
+ \(s_w=\tfrac12 S+\tfrac12\tanh(\overline{|\tilde{\mathbf e}_w|})\in[0,1]\), then maps
192
+ \(s_w\) to a Λ band. Let \(c\) be the count of witnesses in the modal band; the
193
+ detection is **witnessed** iff \(c\ge Q\) with the Khipu quorum \(Q\text{-of-}M=3\text{-of-}4\)
194
+ (super-majority, tolerates one dissenting/faulty witness). The quorum receipt
195
+ records which witnesses agreed and the agreed score band \([\min_w s_w,\max_w s_w]\).
196
+
197
+ Base and retained witness scores must be finite real numbers in `[0, 1]`.
198
+ Thresholds must satisfy `0 <= allow_thr < deny_thr <= 1`; an external opinion's
199
+ band must match its score under those thresholds. Invalid input raises
200
+ `ValueError` before a receipt is emitted. Duplicate witness IDs still use the
201
+ first opinion, and valid receipts remain advisory and unsigned.
202
+
203
+ > **HONEST LIMIT — Khipu BFT = Conjecture 2 (PROPOSED, NOT PROVEN).** This is the
204
+ > **engineering mechanism** (an \(N\)-of-\(M\) agreement gate), **not a proven-safe
205
+ > consensus**: no Byzantine safety/liveness proof, no partial-synchrony bound, no
206
+ > equivocation/sybil model exercised. The witnesses are **simulated independent
207
+ > re-scorers in one process** — no network, no real replication, no adversary. A
208
+ > *witnessed* verdict is a **stronger ADVISORY** (more independent scorers
209
+ > concurred), **never proven trust** and **never folded into locked-proven = 8**.
210
+ > The receipt digest is a SHA-256 provenance handle, **not** a signature — no
211
+ > signature is ever fabricated. Λ stays Conjecture 1 (advisory).
212
+
213
+ ---
214
+
215
+ ## §3.0 SDA verdict envelope (the frozen interface contract)
216
+
217
+ `evaluate(track, core, calib_scores, stage=...) -> envelope`:
218
+
219
+ ```jsonc
220
+ {
221
+ "track_id": "TRK-0001",
222
+ "stage": "DTID|CHARACTERIZE|TWA|FUSE",
223
+ "anomaly_score": 0.0, // [0,1]
224
+ "lambda_axis": {"name":"anomaly_twa","value":0.0,"advisory":true,"verdict":"allow|advisory|deny"},
225
+ "confidence": {"lo":0.0,"hi":0.0,"method":"PAC-Bayes|conformal","label":"ESTIMATE"},
226
+ "sgp4": {"tle_hash":"sha256:…","propagated":true}, // null for air/maritime
227
+ "receipt": { // in-toto Statement v1
228
+ "_type": "https://in-toto.io/Statement/v1",
229
+ "predicateType": "https://szlholdings.com/attestations/sda-anomaly/v1",
230
+ "subject": [{"name":"TRK-0001","digest":{"sha256":"…"}}],
231
+ "predicate": {"engine":"khipu-sda-core","model_hash":"…","seed":0,
232
+ "lib_lineage":["pyod-BSD2","gdn-MIT","sgp4-MIT","merlion-BSD3"],
233
+ "verified": false, "sovereign": true}
234
+ },
235
+ "_signing": {"status":"UNSIGNED","signed_by":"szl_lake/khipu DSSE (Ed25519/P-256)"}
236
+ }
237
+ ```
238
+
239
+ ### Receipt schema — honesty invariants
240
+ - `predicate.verified = false` and `_signing.status = "UNSIGNED"` until a **real**
241
+ DSSE signature attaches downstream (a11oy / khipu-consensus, BFT 3-of-4, on a
242
+ SHA-256 Khipu Merkle DAG). **UNSIGNED is structural-only — never a false green.**
243
+ - **No signature is ever fabricated.** `real-DSSE-or-honestly-UNSIGNED`.
244
+ - `predicate.sovereign = true` (own-metal, 0 CDN). `confidence.label = "ESTIMATE"`.
245
+ - `lambda_axis.advisory = true` always (Λ = Conjecture 1).
246
+
247
+ ---
248
+
249
+ ## Validation (REAL numbers on synthetic data)
250
+
251
+ Run: `python3 szl_mosaic_validate.py` → writes `mosaic_validation.png`, prints
252
+ precision/recall and a Λ-gated example receipt/envelope.
253
+
254
+ Synthetic: **6 tracks × 120 steps × 7 raw features**, reduced to **6 behavioural
255
+ features** [speed, rcs, |Δvx|, |Δvy|, |accel|, |heading-rate|]; **23 injected-
256
+ anomaly cells** across 3 anomaly types (sustained maneuver, RCS spike, heading
257
+ oscillation). Detectors trained on the normal early window; thresholds set from
258
+ the calibration (normal) distribution (not tuned to the test anomalies):
259
+
260
+ | Channel | Precision | Recall | F1 |
261
+ |---|---|---|---|
262
+ | Point ensemble (iForest + AE + robust-z) | **0.44** | **0.74** | **0.55** |
263
+ | Graph-relational (GDN-style velocity-deviation) | **1.00** | **0.35** | **0.52** |
264
+ | Fused consensus (0.5·point + 0.5·graph) | **0.40** | **0.70** | **0.51** |
265
+ | Track fusion | 6 fused COP tracks from 6 true (2 noisy sensors) | | |
266
+
267
+ **Honest reading:** the point ensemble carries recall; the graph channel is
268
+ high-precision / low-recall (it only fires on velocity-space maneuvers and
269
+ correctly MISSES the RCS spike, which has no kinematic signature). False positives
270
+ come from genuine normal heading-drift noise — not hidden. These are small-model,
271
+ honest numbers, not inflated.
272
+
273
+ ### Orbital conjunction screen (REAL sgp4 numbers)
274
+ The same harness now runs the real pairwise conjunction screen over a 4-object
275
+ demo catalog (real public sample TLEs + one explicitly-DERIVED co-orbiting
276
+ companion) on a 90-minute window (180 steps × 0.5 min):
277
+
278
+ - **catalog objects = 4; pairwise conjunctions < 5 km = 1**
279
+ - **ISS (ZARYA) 25544 × ISS-COMPANION (DERIVED):** miss **2.368 km** @ TCA
280
+ **+2302 s**, encounter rel-speed **0.0027 km/s**, verdict **advisory**, conformal
281
+ `ESTIMATE` band **[2.37, 9040] km** (the wide upper bound honestly reflects the
282
+ no-covariance screening posture — it is not a \(P_c\)). The three unrelated
283
+ public pairs stay at ~10³–10⁴ km and are NOT flagged. **SCREENING-GRADE, NOT
284
+ \(P_c\)-grade** (see math §9).
285
+
286
+ ### Multi-witness verified detection (REAL 3-of-4 quorum)
287
+ The harness witnesses the engine's strongest behavioural detection and a
288
+ clearly-normal cell through 4 independent re-scorers:
289
+
290
+ - **STRONG TRK-1@t40:** base 1.000 (deny) → **witnessed**, agreed band **deny 4/4**,
291
+ agreed score-band **[0.942, 0.991]**.
292
+ - **NORMAL TRK-0@t5:** base 0.188 (allow) → **witnessed**, agreed band **allow 3/4**.
293
+ - On bimodal/boundary evidence the quorum genuinely **FAILS** (a real 2–2 split is
294
+ exercised in `tests/test_witness_quorum.py`) — the gate is real, not always-True.
295
+ **Khipu BFT = Conjecture 2 (proposed, not proven)** — a witnessed verdict is a
296
+ stronger ADVISORY only (see math §10).
297
+
298
+ See `mosaic_validation.png` for the 6-panel figure (tracks + flagged anomalies +
299
+ fused COP + score curves + **orbital conjunction screen** + **witness quorum**).
300
+
301
+ ---
302
+
303
+ ## Run
304
+
305
+ A base installation (`python -m pip install .`, or the built wheel) resolves the
306
+ NumPy, SciPy, scikit-learn, matplotlib and sgp4 dependencies. It includes every
307
+ listed module and uses the NumPy PCA autoencoder and local unsigned receipt
308
+ fallback. Torch and the shared receipt builder are opt-in extras: `.[torch]`
309
+ and `.[receipt]`; `.[test]` adds pytest. `requirements.txt` selects all three
310
+ extras for the full repository test environment. No package release is asserted.
311
+
312
+ CI first builds a wheel and installs only that wheel in a new virtual environment.
313
+ It checks dependencies, module origins and the base execution paths without the
314
+ checkout on `sys.path`, then runs the existing full source suite separately.
315
+ The license gate parses both base and optional project dependencies and normalizes
316
+ package names; it retains the existing source-import scan.
317
+ The same base check can be run as:
318
+
319
+ ```bash
320
+ python -m pip wheel --no-deps --wheel-dir dist .
321
+ python -m venv /tmp/sda-base
322
+ /tmp/sda-base/bin/python -m pip install dist/*.whl
323
+ /tmp/sda-base/bin/python -m pip check
324
+ /tmp/sda-base/bin/python -I tools/check_installed_wheel.py
325
+ ```
326
+
327
+ For the full optional-feature source environment:
328
+
329
+ ```bash
330
+ pip install -r requirements.txt
331
+ python3 szl_mosaic_core.py # smoke test the ensemble + receipt
332
+ python3 szl_track_fusion.py # smoke test fusion -> COP
333
+ python3 szl_sda_orbit.py # REAL pairwise conjunction screen (sgp4 TCA + miss)
334
+ python3 szl_witness.py # multi-witness 3-of-4 quorum (Conjecture 2)
335
+ python3 szl_sda_envelope.py # emit a §3.0 envelope (air + orbital)
336
+ python3 szl_mosaic_validate.py # full validation -> mosaic_validation.png
337
+ python3 -m pytest tests/ -q # honesty + receipt round-trip tests
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Operations (ownership · health · rollback)
343
+
344
+ **Ownership.** SZL Holdings · Dev 1 (anomaly/SDA CORE organ). This is an importable
345
+ library + CLI smoke/validation harness — it is *not* a long-running network service
346
+ (sovereign, own-metal, 0 CDN, no listening port), so there is no `/healthz` endpoint
347
+ to expose. Its "health check" is the test suite + per-module smoke run.
348
+
349
+ **Health / readiness check.** Treat a green run of the following as readiness:
350
+
351
+ ```bash
352
+ python3 -m pytest tests/ -q # 20 tests: honesty gate + receipt/orbit/quorum
353
+ python3 szl_sda_orbit.py # must print: catalog objects: 4; ... advisories (<5 km): 1
354
+ ```
355
+
356
+ CI (`.github/workflows/ci.yml`) gates every push/PR on: the full test suite, a
357
+ license-hygiene check (BSL `alibi-detect` forbidden as a dependency/import), and a
358
+ no-fabricated-signature check. Main is never merged red.
359
+
360
+ **Rollback (one-step, tested).** Releases are plain git refs — there is no stateful
361
+ migration to unwind, so rollback is a single revert/checkout:
362
+
363
+ ```bash
364
+ # revert the most recent merge to main (keeps history; preferred)
365
+ git revert -m 1 <merge_commit_sha>
366
+
367
+ # or pin a known-good tagged release for a redeploy
368
+ git checkout <last_good_tag> # e.g. the commit before the regression
369
+ ```
370
+
371
+ Verify the rollback the same way as readiness above (pytest + the orbit smoke line).
372
+ Because the engine holds no persistent state and writes only `mosaic_validation.png`
373
+ (gitignored), reverting code is a complete rollback.
374
+
375
+ ---
376
+
377
+ ## Doctrine v11 (binding)
378
+
379
+ Λ = **Conjecture 1** (advisory, never proven trust) · locked-proven = **8**
380
+ `{F1,F4,F7,F11,F12,F18,F19,F22}` (this engine is engineering capability, NOT in
381
+ the locked count) · Khipu BFT = **Conjecture 2** (proposed, NOT proven — the
382
+ `szl_witness.py` 3-of-4 quorum is the engineering mechanism, not a proven-safe
383
+ consensus; a 'witnessed' verdict is a stronger ADVISORY only) · orbital screen =
384
+ **SCREENING-GRADE roadmap**, honestly NOT operational \(P_c\)/covariance-grade ·
385
+ SLSA **L1 honest /
386
+ L2 roadmap (not yet earned — no signed build provenance in CI today) / L3 roadmap** · **sovereign own-metal, 0 CDN** · **NO
387
+ free-energy** · joules MEASURED only · every $/credit = **ESTIMATE** ·
388
+ **cite-never-plagiarize** · NEVER fabricate numbers (validation is real on
389
+ synthetic data) · honest sensor caveat: broadcast Remote-ID/ADS-B/MAVLink are
390
+ **unauthenticated and spoofable** — every decoded field is a *claim*, and the same
391
+ skepticism applies to fused anomaly inputs.
392
+
393
+ Estate on Hugging Face: models, datasets and Spaces are published under the [SZLHOLDINGS](https://huggingface.co/SZLHOLDINGS) org.