SZL kernel publisher commited on
Commit
6acda98
·
1 Parent(s): 2618533

Publish szl-lambda-gate v1 from szl-holdings/szl-lambda-gate@219ee89500f2d2a137f547c1c6ed8d97c6c66e9d

Browse files

Source: https://github.com/szl-holdings/szl-lambda-gate/tree/219ee89500f2d2a137f547c1c6ed8d97c6c66e9d
Publisher: scripts/szl_kernel_publish.py (https://github.com/szl-holdings/szl-lambda-gate/actions/runs/38478441021)

LICENSE CHANGED
@@ -1,7 +1,192 @@
 
1
  Apache License
2
  Version 2.0, January 2004
3
  http://www.apache.org/licenses/
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  Copyright 2026 SZL Holdings
6
 
7
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,5 +200,3 @@
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
-
19
- The full Apache License 2.0 text is available at the URL above.
 
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 2026 SZL Holdings
191
 
192
  Licensed under the Apache License, Version 2.0 (the "License");
 
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.
 
 
README.md CHANGED
@@ -1,172 +1,105 @@
1
- ---
2
- tags:
3
- - kernel
4
- - governance
5
- - lambda
6
- - gate
7
- - provenance
8
- - doi:10.5281/zenodo.19944926
9
- library_name: kernels
10
- license: apache-2.0
11
- ---
12
-
13
- <p align="center">
14
- <a href="https://huggingface.co/SZLHOLDINGS/szl-lambda-gate/tree/main/build/torch-universal/szl_lambda_gate"><img src="https://img.shields.io/badge/kernel%20hub-torch--universal-5b8dee?style=flat-square" alt="kernel hub"></a>
15
- <a href="https://huggingface.co/SZLHOLDINGS/szl-lambda-gate/blob/main/MODEL_PROVENANCE.json"><img src="https://img.shields.io/badge/provenance-MODEL_PROVENANCE.json-3af4c8?style=flat-square" alt="provenance"></a>
16
- <a href="https://huggingface.co/SZLHOLDINGS/szl-lambda-gate/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-7e8aa3?style=flat-square" alt="license"></a>
17
- </p>
18
-
19
- # szl-lambda-gate
20
-
21
- **Λ — a governance aggregator as a Hugging Face kernel.** A differentiable, torch.compile-friendly weighted-geometric-mean aggregator with an ADVISORY non-compensatory gate and runtime axiom self-checks, from [SZL Holdings](https://huggingface.co/SZLHOLDINGS).
22
-
23
- > Companion to [`szl-governed-norm`](https://huggingface.co/SZLHOLDINGS/szl-governed-norm). Where that kernel makes a normalization *auditable*, this one makes a *governance decision* computable and checkable at the tensor layer.
24
-
25
- ## Interactive demo
26
-
27
- > **Live demos (in-browser, nothing to install)** — [`lambda-gate-holo`](https://szlholdings-lambda-gate-holo.static.hf.space) (this kernel's holographic gate demo) · [`szl-kernels-live`](https://szlholdings-szl-kernels-live.static.hf.space) (unified suite demo).
28
- >
29
- > The quickstart above runs fully locally. For a full governed-kernel suite demo, see [szl-kernels](https://huggingface.co/SZLHOLDINGS/szl-kernels). For the live a11oy substrate, see [a11oy Space](https://huggingface.co/spaces/SZLHOLDINGS/a11oy).
30
-
31
- ## What Λ is — and is NOT (read this first)
32
-
33
- Λ is the **weighted geometric mean** over axis scores in [0,1]:
34
-
35
- \[ \Lambda(x) = \prod_i x_i^{w_i}, \quad \sum_i w_i = 1, \; w_i > 0, \; x_i \in [0,1] \]
36
-
37
- It is a **non-compensatory, ADVISORY** roll-up: any single zeroed (or non-finite) axis drives the whole aggregate to 0 — a conservative "one bad axis fails the gate" signal. **Λ is NOT "proven trust" and NOT a closed theorem.** Its *uniqueness* (that the weighted geometric mean is the only aggregator satisfying the carried axioms) remains **Conjecture 1 — OPEN**. A gate "pass" is an advisory signal, never a guarantee. We label this honestly everywhere.
38
-
39
- ## Quickstart
40
-
41
- ```bash
42
- pip install kernels torch
43
- ```
44
-
45
- ```python
46
- import torch
47
- from kernels import get_kernel
48
-
49
- # Current `kernels` (>=0.15) requires an explicit revision/version + trust flag for org kernels:
50
- lg = get_kernel("SZLHOLDINGS/szl-lambda-gate", revision="main", trust_remote_code=True)
51
- # (once a tag is published you can pin it, e.g. revision="v0.2.0")
52
-
53
- axes = torch.tensor([0.9, 0.8, 0.95]) # axis scores in [0,1]
54
- score = lg.lambda_aggregate(axes) # Λ(x) ∈ [0,1]
55
- res = lg.lambda_gate(axes, threshold=0.5)
56
- print(res.score, res.passed, res.advisory) # advisory is always True
57
-
58
- print(lg.selfcheck()) # empirical A1–A4 checks + version
59
- ```
60
-
61
- ## API
62
-
63
- | Function | Notes |
64
- |---|---|
65
- | `lambda_aggregate(axes, weights=None)` | Λ over the last dim. Differentiable, batched, torch.compile-friendly. |
66
- | `lambda_gate(axes, weights=None, threshold=0.5)` | Advisory gate → `LambdaGateResult(score, passed, threshold, advisory)`. |
67
- | `lambda_gate_batch(candidates, weights=None, threshold=0.5)` | Score many candidate vectors `(..., N, k)` in one call; returns the advisory pass mask. |
68
- | `selfcheck()` | Empirical A1–A4 axiom checks + adversarial falsification search + version. NOT a uniqueness proof. |
69
- | `is_monotone / is_homogeneous / is_egyptian_exact / is_bounded_by_max` | The four carried axioms as real runtime checks. |
70
- | `yuyay_weights()`, `YUYAY_AXES`, `YUYAY_FLOORS` | Canonical 13-axis Yuyay preset (advisory). |
71
- | layers: `LambdaGate`, `LambdaAggregate` | Pure `nn.Module` for the Kernel Hub layer-mapping mechanism. |
72
-
73
- ## Carried axioms (verifiable, not a proof)
74
-
75
- - **A1 IsMonotone** — Λ is non-decreasing in each axis.
76
- - **A2 IsHomogeneous (deg 1)** — Λ(t·x) = t·Λ(x).
77
- - **A3 IsEgyptianExact** — Λ(c,…,c) = c.
78
- - **A4 IsBounded** — Λ(x) ≤ maxᵢ xᵢ.
79
-
80
- `selfcheck()` verifies these empirically on sampled inputs and runs a random falsification search. A clean run is **evidence, not proof** — Λ-uniqueness is Conjecture 1 (open).
81
-
82
- ## Provenance
83
-
84
- Backed by the Lean 4 formalization [szl-holdings/lutar-lean](https://github.com/szl-holdings/lutar-lean) (749 declarations / 14 axioms / 163 tracked sorries), DOI [10.5281/zenodo.20434308](https://doi.org/10.5281/zenodo.20434308). Λ uniqueness = Conjecture 1 (open).
85
-
86
- ## Honesty
87
-
88
- - Pure-Python universal kernel — a correctness reference, not a CUDA speed record. No fabricated benchmarks (50 passing tests).
89
- - Λ is advisory; never "proven trust."
90
- - Prior art honestly attributed: the weighted geometric mean as a less-compensatory composite indicator is established practice (UN HDI 2010, OECD Composite Indicators Handbook 2008); the veto/cut-off idea is ELECTRE. The 13-axis conjunctive form is SZL's own yuyay_v3 gate.
91
-
92
- ## Compatibility
93
-
94
- Python 3.9+, `torch>=2.5`, standard library + torch only.
95
-
96
- ## License
97
-
98
- Apache-2.0. Copyright 2026 SZL Holdings.
99
-
100
- ---
101
-
102
- ## SZL Kernels Suite
103
-
104
- Part of the [`szl-kernels`](https://huggingface.co/SZLHOLDINGS/szl-kernels) governed-kernel suite — the hub links every member, and each member links back to the hub so no leaf is orphaned:
105
-
106
- | Kernel | Lane |
107
- |---|---|
108
- | [`szl-kernels`](https://huggingface.co/SZLHOLDINGS/szl-kernels) | **hub** — unified suite, cross-kernel `UnifiedReceiptChain` |
109
- | [`szl-governed-norm`](https://huggingface.co/SZLHOLDINGS/szl-governed-norm) | RMSNorm/LayerNorm + SHA3-256 receipts |
110
- | **`szl-lambda-gate`** (this repo) | **advisory Λ gate (Conjecture 1, OPEN)** |
111
- | [`governed-inference-meter`](https://huggingface.co/SZLHOLDINGS/governed-inference-meter) | MEASURED-joule energy accounting (NVML) |
112
- | [`szl-govsign`](https://huggingface.co/SZLHOLDINGS/szl-govsign) | signed governance attestation (DSSE / in-toto) |
113
- | [`szl-blocked`](https://huggingface.co/SZLHOLDINGS/szl-blocked) | honest-BLOCKED state + EU AI Act Annex IV DRAFT |
114
- | [`szl-provctl`](https://huggingface.co/SZLHOLDINGS/szl-provctl) | provenance-DAG verify + in-toto/SLSA interop |
115
-
116
- **Live Spaces:** [a11oy](https://huggingface.co/spaces/SZLHOLDINGS/a11oy) · [hatun-mcp](https://huggingface.co/spaces/SZLHOLDINGS/hatun-mcp).
117
-
118
- **Related — Governed Kernels collection:** [Governed Kernels — verifiable AI building blocks](https://huggingface.co/collections/SZLHOLDINGS/governed-kernels-verifiable-ai-building-blocks-6a41d3936cfce4fba83ce378) groups the whole family in one page. **Live console:** [a11oy](https://szlholdings-a11oy.hf.space) · [a-11-oy.com](https://a-11-oy.com) · [llm-router](https://szlholdings-llm-router-live.hf.space) · [receipt verifier](https://szlholdings-governed-receipt-verifier.static.hf.space) · [receipt spec (hub)](https://github.com/szl-holdings/governed-receipt-spec).
119
-
120
-
121
- ---
122
-
123
- <sub><b>SZL Holdings</b> · Λ governance aggregator · advisory, not proven trust · <a href="https://a-11-oy.com">a-11-oy.com</a> · <a href="https://github.com/szl-holdings">github.com/szl-holdings</a> · <a href="https://huggingface.co/SZLHOLDINGS">huggingface.co/SZLHOLDINGS</a></sub>
124
-
125
- ---
126
-
127
- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.19944926.svg)](https://doi.org/10.5281/zenodo.19944926)
128
-
129
- ## Citation
130
-
131
-
132
- **Cite this.** Part of the SZL Holdings *Ouroboros Thesis* (Governed Post-Determinism).
133
- Concept DOI (always-latest): [10.5281/zenodo.19944926](https://doi.org/10.5281/zenodo.19944926).
134
- Author: Stephen P. Lutar Jr. · [ORCID 0009-0001-0110-4173](https://orcid.org/0009-0001-0110-4173) · License CC-BY-4.0.
135
- Full DOI-pinned lineage (v1→v26) + the 8 papers: [szl-papers PAPERS_INDEX](https://github.com/szl-holdings/szl-papers/blob/main/PAPERS_INDEX.md).
136
- No artifact-specific DOI is minted for this model; the concept DOI above covers the program.
137
-
138
- Honesty (Doctrine v11): Λ unconditional uniqueness is **Conjecture 1** (machine-checked FALSE as stated) — never a theorem; conditional uniqueness is **Theorem U** (axiom-free). Locked-proven formulas = **exactly 8** {F1,F4,F7,F11,F12,F18,F19,F22}; ~185 experimental theorems are a separate CI-green tier; Khipu BFT safety = Conjecture 2. Trust never 100%.
139
-
140
- ```bibtex
141
- @misc{lutar_szl_ouroboros,
142
- author = {Lutar, Stephen P., Jr.},
143
- title = {SZL Holdings --- The Ouroboros Thesis (Governed Post-Determinism)},
144
- year = {2026},
145
- publisher = {Zenodo},
146
- doi = {10.5281/zenodo.19944926},
147
- url = {https://doi.org/10.5281/zenodo.19944926},
148
- note = {Concept DOI --- always resolves to the latest version. ORCID 0009-0001-0110-4173. CC-BY-4.0.}
149
- }
150
- ```
151
-
152
- *Signed-off-by: Stephen Lutar <stephenlutar2@gmail.com>*
153
-
154
- ## Files in this repo
155
-
156
- | Path | What it is |
157
- |---|---|
158
- | `build/torch-universal/szl_lambda_gate/__init__.py` | public API — `lambda_aggregate`, `lambda_gate`, `selfcheck()` |
159
- | `build/torch-universal/szl_lambda_gate/_lambda.py` | the weighted-geometric-mean aggregator + A1–A4 empirical checks |
160
- | `build/torch-universal/szl_lambda_gate/layers.py` | `nn.Module` wrapper |
161
- | `build.toml` · `metadata.json` | Kernel Hub build/metadata manifests |
162
- | `LICENSE` · `SECURITY.md` | Apache-2.0 · security policy |
163
-
164
- ---
165
-
166
- <p align="center">
167
- <a href="https://huggingface.co/SZLHOLDINGS">SZL Holdings</a> ·
168
- <a href="https://a-11-oy.com">a-11-oy.com</a> ·
169
- <a href="https://huggingface.co/SZLHOLDINGS/szl-kernels">szl-kernels</a>
170
- </p>
171
-
172
- <p align="center"><sub>SLSA: L1 honest · L2 attested · L3 roadmap. Λ = Conjecture 1. Trust ceiling 0.97.</sub></p>
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: kernels
4
+ tags:
5
+ - kernel
6
+ - governance
7
+ - lambda
8
+ - gate
9
+ - provenance
10
+ - szl-holdings
11
+ - doi:10.5281/zenodo.19944926
12
+ ---
13
+
14
+ # szl-lambda-gate
15
+
16
+ **Λ, a governance aggregator, as a pure-PyTorch (noarch) kernel.** A differentiable,
17
+ `torch.compile`-friendly weighted-geometric-mean aggregator with an ADVISORY
18
+ non-compensatory gate, the strict `szl.lambda/v1` entry point and runtime axiom
19
+ self-checks, from [SZL Holdings](https://huggingface.co/SZLHOLDINGS).
20
+
21
+ This repository is published from GitHub
22
+ [szl-holdings/szl-lambda-gate](https://github.com/szl-holdings/szl-lambda-gate) by its
23
+ `hf-kernel-publish` workflow, which is its only writer. GitHub is the source of truth:
24
+ every file under `build/` is a byte copy of `torch-ext/szl_lambda_gate` at the commit
25
+ named in `SZL_KERNEL_SOURCE.json`.
26
+
27
+ ## Load it
28
+
29
+ ```python
30
+ # pip install "kernels>=0.17.2" torch
31
+ import torch
32
+ from kernels import get_kernel
33
+
34
+ lg = get_kernel("SZLHOLDINGS/szl-lambda-gate", version=1, trust_remote_code=True)
35
+
36
+ axes = torch.tensor([0.9, 0.8, 0.95], dtype=torch.float64) # axis scores in [0,1]
37
+ weights = torch.tensor([0.5, 0.25, 0.25], dtype=torch.float64)
38
+ gate = lg.lambda_v1_gate(axes, weights, tau=0.8) # GO / NO_GO / ABSTAIN / BLOCK
39
+ print(gate.verdict, gate.code)
40
+
41
+ print(lg.lambda_aggregate(axes)) # legacy Λ(x) in [0,1]
42
+ print(lg.selfcheck()) # empirical A1-A4 checks, not a proof
43
+ ```
44
+
45
+ - `version=1` resolves the `v1` branch, the stable API channel. It
46
+ is republished on every release. The `kernels` library refuses a call that names neither
47
+ a version nor a revision.
48
+ - `trust_remote_code` is required: SZLHOLDINGS is not a trusted kernel publisher on the Hub.
49
+ The narrowest form is `trust_remote_code=["SZLHOLDINGS/szl-lambda-gate"]`.
50
+ - CPU hosts load `build/torch-cpu`; CUDA and other hosts load `build/torch-universal`.
51
+ Both variants carry identical code, built from the same GitHub commit.
52
+
53
+ ### Pin an exact build (production)
54
+
55
+ ```python
56
+ from huggingface_hub import HfApi
57
+ from kernels import get_kernel
58
+
59
+ refs = HfApi().list_repo_refs("SZLHOLDINGS/szl-lambda-gate", repo_type="kernel")
60
+ pin = next(b.target_commit for b in refs.branches if b.name == "v1")
61
+ lg = get_kernel("SZLHOLDINGS/szl-lambda-gate", revision=pin, trust_remote_code=["SZLHOLDINGS/szl-lambda-gate"])
62
+ ```
63
+
64
+ Record `pin` (a commit of this kernel repository) in your lockfile. Commits of the
65
+ model repository [https://huggingface.co/SZLHOLDINGS/szl-lambda-gate](https://huggingface.co/SZLHOLDINGS/szl-lambda-gate) are not kernel revisions and
66
+ do not resolve here.
67
+
68
+ ## What Λ is, and is not
69
+
70
+ Λ is the weighted geometric mean over axis scores in [0,1]:
71
+ Λ(x) = ∏ xᵢ^wᵢ with Σ wᵢ = 1, wᵢ > 0. It is a non-compensatory, ADVISORY roll-up: any
72
+ zero (or, in the legacy entry, non-finite) axis drives the aggregate to 0. A gate pass is
73
+ an advisory signal that the host must enforce; it is not proven trust. Λ uniqueness
74
+ remains **Conjecture 1 (open)**. The A1-A4 self-checks are empirical evidence on sampled
75
+ inputs, not a proof.
76
+
77
+ ## API
78
+
79
+ | Entry | Notes |
80
+ |---|---|
81
+ | `lambda_v1(axes, weights)` / `lambda_v1_gate(axes, weights, tau)` | Strict `szl.lambda/v1` contract (`spec/szl.lambda.v1.json`): validated, never repaired; bad input returns `BLOCK` with a `LAMBDA_*` code; τ is required. |
82
+ | `lambda_aggregate(axes, weights=None)` | Legacy Λ over the last dim. Differentiable, batched. Clamps and renormalises (see the spec for the differences). |
83
+ | `lambda_gate(axes, weights=None, threshold=...)` / `lambda_gate_batch(...)` | Legacy advisory gate → `LambdaGateResult(score, passed, threshold, advisory)`. |
84
+ | `selfcheck()`, `is_monotone`, `is_homogeneous`, `is_egyptian_exact`, `is_bounded_by_max`, `find_axiom_violation` | Empirical A1-A4 checks and a falsification search. |
85
+ | `governed_norm` (`rms_norm`, `layer_norm`, `fused_add_rms_norm`) | Governed normalization with SHA3-256 hash-chained receipts. Also published standalone as [SZLHOLDINGS/szl-governed-norm](https://huggingface.co/kernels/SZLHOLDINGS/szl-governed-norm). |
86
+ | `layers.LambdaGate`, `layers.LambdaAggregate` | Pure `nn.Module` layers for kernel layer mapping. |
87
+
88
+ ## Files
89
+
90
+ | Path | What it is |
91
+ |---|---|
92
+ | `build/torch-cpu/`, `build/torch-universal/` | The kernel package and its generated `metadata.json` (with a sha256 digest of every file). |
93
+ | `spec/szl.lambda.v1.json`, `spec/lambda_v1_vectors.json` | The `szl.lambda/v1` contract and its golden vectors. |
94
+ | `reference/szl_lambda_v1.py` | Stdlib-only reference implementation of the contract. |
95
+ | `SZL_KERNEL_SOURCE.json` | The GitHub commit and per-file sha256 this tree was built from. |
96
+ | `build.toml`, `LICENSE` | Kernel build manifest and Apache-2.0 license, copied from GitHub. |
97
+
98
+ No speedup, throughput or energy figure is claimed for this kernel. Test results live
99
+ in GitHub Actions for the source commit.
100
+
101
+ ## License and citation
102
+
103
+ Apache-2.0. Copyright 2026 SZL Holdings. Concept DOI
104
+ [10.5281/zenodo.19944926](https://doi.org/10.5281/zenodo.19944926); see `CITATION.cff` in
105
+ the GitHub repository.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SZL_KERNEL_SOURCE.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "content_sha256": "7bb76d1613da5e0487cc182afb64115e5b9998e06b57027694e9bb381ba94435",
3
+ "files": {
4
+ "LICENSE": "bc8cef3450d423b046a3ba2b1a03089c8c795302f502cabbdbef055a68f0b1e7",
5
+ "README.md": "e5141ba71f4ea828c30537ad9c4e88760f1712d1bf1a90cc5939ee902c9620c3",
6
+ "build.toml": "5c5ebbfe83770a898b8b8893e342c2c5547c65cd2b5a96146b14e3abb9411f3b",
7
+ "build/torch-cpu/metadata.json": "94fd9128b27adcb36237f2ee9618b09f7a61e1f88ba520623dda3b504154ac10",
8
+ "build/torch-cpu/szl_lambda_gate/__init__.py": "2d95cb2a572a9ee8f00678e1a8aff347a12ccb0d529d2945a6a3bd67fa565854",
9
+ "build/torch-cpu/szl_lambda_gate/_lambda.py": "f953a38019c91a6fa8a9c411f55baa4f5f2b9e76d7153bba54bb8a5d9469af38",
10
+ "build/torch-cpu/szl_lambda_gate/_ops.py": "6adf1dc42e7a9e6da914e304da9720438e59c234104e11f3e5ccaa45ecee23b6",
11
+ "build/torch-cpu/szl_lambda_gate/_v1.py": "9ac2d8fe0a47ff191eba76e62b1e9dd9b2b54f64ba0c3d86306e0cdd58bc468c",
12
+ "build/torch-cpu/szl_lambda_gate/governed_norm/__init__.py": "50fe4fb09a165d0ae9a781f0ef3515388c752a14cde95f73687854f59a7dfadc",
13
+ "build/torch-cpu/szl_lambda_gate/governed_norm/_norm.py": "cf72ace281ec86c504426f75e23eebdb661a1e3a12e4dfcc6c8b9fa634b03942",
14
+ "build/torch-cpu/szl_lambda_gate/governed_norm/_receipt.py": "0fa2cf7e8c5f4f9b5908868ba6d6ec05e9dfbec26a7656b89ab2bfbdf3d6d870",
15
+ "build/torch-cpu/szl_lambda_gate/governed_norm/layers.py": "d79c83355cb2332b9d0e9d98584b86434e486532e27d30652df10158b30fc37b",
16
+ "build/torch-cpu/szl_lambda_gate/layers.py": "51da478e185ee4d16daa9971bdcbdcfcbb0c0c5b7837a002b97cd05cb968ea75",
17
+ "build/torch-universal/metadata.json": "a69500fb8634cb39482b1c73efba0b9feda6cfacc0be3cb073d505e25aa5a6f4",
18
+ "build/torch-universal/szl_lambda_gate/__init__.py": "2d95cb2a572a9ee8f00678e1a8aff347a12ccb0d529d2945a6a3bd67fa565854",
19
+ "build/torch-universal/szl_lambda_gate/_lambda.py": "f953a38019c91a6fa8a9c411f55baa4f5f2b9e76d7153bba54bb8a5d9469af38",
20
+ "build/torch-universal/szl_lambda_gate/_ops.py": "6adf1dc42e7a9e6da914e304da9720438e59c234104e11f3e5ccaa45ecee23b6",
21
+ "build/torch-universal/szl_lambda_gate/_v1.py": "9ac2d8fe0a47ff191eba76e62b1e9dd9b2b54f64ba0c3d86306e0cdd58bc468c",
22
+ "build/torch-universal/szl_lambda_gate/governed_norm/__init__.py": "50fe4fb09a165d0ae9a781f0ef3515388c752a14cde95f73687854f59a7dfadc",
23
+ "build/torch-universal/szl_lambda_gate/governed_norm/_norm.py": "cf72ace281ec86c504426f75e23eebdb661a1e3a12e4dfcc6c8b9fa634b03942",
24
+ "build/torch-universal/szl_lambda_gate/governed_norm/_receipt.py": "0fa2cf7e8c5f4f9b5908868ba6d6ec05e9dfbec26a7656b89ab2bfbdf3d6d870",
25
+ "build/torch-universal/szl_lambda_gate/governed_norm/layers.py": "d79c83355cb2332b9d0e9d98584b86434e486532e27d30652df10158b30fc37b",
26
+ "build/torch-universal/szl_lambda_gate/layers.py": "51da478e185ee4d16daa9971bdcbdcfcbb0c0c5b7837a002b97cd05cb968ea75",
27
+ "reference/szl_lambda_v1.py": "57b264fa96056d1f2d77b797ba80eab087a729283f16416196fdd1423c9c532f",
28
+ "spec/lambda_v1_vectors.json": "460bb966ff2bec4fd99e03d267b721f22c5fad731e0667723407a6909bd4dcec",
29
+ "spec/szl.lambda.v1.json": "04a8368568d59509c8603cdc45cf80f6b1395e751c77eabb1957bbe12906f2d9"
30
+ },
31
+ "kernel_name": "szl-lambda-gate",
32
+ "kernel_version": 1,
33
+ "load": {
34
+ "call": "get_kernel(\"SZLHOLDINGS/szl-lambda-gate\", version=1, trust_remote_code=True)",
35
+ "requires": "kernels>=0.17.2"
36
+ },
37
+ "packages": [
38
+ {
39
+ "name": "szl_lambda_gate",
40
+ "src": "torch-ext/szl_lambda_gate"
41
+ }
42
+ ],
43
+ "publisher": "scripts/szl_kernel_publish.py",
44
+ "repo_id": "SZLHOLDINGS/szl-lambda-gate",
45
+ "repo_type": "kernel",
46
+ "schema": "szl.kernel-source-binding/v1",
47
+ "source_commit": "219ee89500f2d2a137f547c1c6ed8d97c6c66e9d",
48
+ "source_repository": "szl-holdings/szl-lambda-gate"
49
+ }
build/torch-cpu/__init__.py DELETED
@@ -1,2 +0,0 @@
1
- from .szl_lambda_gate import * # noqa: F401,F403
2
- from .szl_lambda_gate import __all__
 
 
 
build/torch-cpu/metadata.json CHANGED
@@ -1 +1,26 @@
1
- {"backend":{"type":"cpu"},"digest":{"algorithm":"sha256","files":{"__init__.py":"NuinjlWRNlWgg0y2D61HEaKtW/VOktRHP8w2Nj3opjQ=","szl_lambda_gate/__init__.py":"QpfkkacuKUGxXitqBYLq0nM4NnCsX7uNFOLHbeye0V0=","szl_lambda_gate/_lambda.py":"+VOjgBnJGm+oqcQR9VuqT18rnnbXFTu6VLuKXZRprzg=","szl_lambda_gate/_ops.py":"at8dxC56nm2pFOME2pcgQ45ZwjQQThHz5cyqRezuI7Y=","szl_lambda_gate/_v1.py":"msLY/gpH/xkeunbmKx6d2bK1T2S6DD2GMG4M3Vi8Row=","szl_lambda_gate/governed_norm/__init__.py":"UP5PsJoWXQrpp4Hw7zUVOIx1KhTN6V9zaHhU9Zp9+tw=","szl_lambda_gate/governed_norm/_norm.py":"z3Ks4oHshsUEQm914j7r22YaHjoS5N/MbIufpjSwOUI=","szl_lambda_gate/governed_norm/_receipt.py":"2xJEvRhK/9ypKb04rHKLJpb4KtVlqvgtFMo4RdTXSKk=","szl_lambda_gate/governed_norm/layers.py":"15yDNVyyMyudDp2YWEuGQ05IZTLifTBlLfEBWLMPw3s=","szl_lambda_gate/layers.py":"UdpHjhhe5NFtqplxvcvc/LsMDFt4N6ACuXzQXLlo6nU="}},"id":"_szl_lambda_gate_cpu_7cb79cba7ecb5dbb9da59b2d6b516a98d2a114d6","license":"Apache-2.0","name":"szl-lambda-gate","python-depends":[],"source":"https://github.com/szl-holdings/szl-lambda-gate","universal":false,"version":1}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": {
3
+ "type": "cpu"
4
+ },
5
+ "digest": {
6
+ "algorithm": "sha256",
7
+ "files": {
8
+ "szl_lambda_gate/__init__.py": "LZXLKlcqnujwBnjhqK/zR6Esyw1SnSlFpqO9Z/pWWFQ=",
9
+ "szl_lambda_gate/_lambda.py": "+VOjgBnJGm+oqcQR9VuqT18rnnbXFTu6VLuKXZRprzg=",
10
+ "szl_lambda_gate/_ops.py": "at8dxC56nm2pFOME2pcgQ45ZwjQQThHz5cyqRezuI7Y=",
11
+ "szl_lambda_gate/_v1.py": "msLY/gpH/xkeunbmKx6d2bK1T2S6DD2GMG4M3Vi8Row=",
12
+ "szl_lambda_gate/governed_norm/__init__.py": "UP5PsJoWXQrpp4Hw7zUVOIx1KhTN6V9zaHhU9Zp9+tw=",
13
+ "szl_lambda_gate/governed_norm/_norm.py": "z3Ks4oHshsUEQm914j7r22YaHjoS5N/MbIufpjSwOUI=",
14
+ "szl_lambda_gate/governed_norm/_receipt.py": "D6LPfoxfT5tZCIaLptbsBenfvsJqdla4mrK/vfPW2HA=",
15
+ "szl_lambda_gate/governed_norm/layers.py": "15yDNVyyMyudDp2YWEuGQ05IZTLifTBlLfEBWLMPw3s=",
16
+ "szl_lambda_gate/layers.py": "UdpHjhhe5NFtqplxvcvc/LsMDFt4N6ACuXzQXLlo6nU="
17
+ }
18
+ },
19
+ "id": "_szl_lambda_gate_cpu_219ee89500f2",
20
+ "kernel-depends": [],
21
+ "license": "Apache-2.0",
22
+ "name": "szl-lambda-gate",
23
+ "python-depends": [],
24
+ "source": "https://github.com/szl-holdings/szl-lambda-gate",
25
+ "version": 1
26
+ }
build/torch-cpu/szl_lambda_gate/__init__.py CHANGED
@@ -16,7 +16,7 @@ Load from the Hub:
16
  import torch
17
  from kernels import get_kernel
18
 
19
- lg = get_kernel("SZLHOLDINGS/szl-lambda-gate")
20
  axes = torch.tensor([0.9, 0.8, 0.95]) # axis scores in [0,1]
21
  score = lg.lambda_aggregate(axes) # Λ(x) ∈ [0,1]
22
  res = lg.lambda_gate(axes, threshold=0.5) # ADVISORY pass/fail
 
16
  import torch
17
  from kernels import get_kernel
18
 
19
+ lg = get_kernel("SZLHOLDINGS/szl-lambda-gate", version=1, trust_remote_code=True)
20
  axes = torch.tensor([0.9, 0.8, 0.95]) # axis scores in [0,1]
21
  score = lg.lambda_aggregate(axes) # Λ(x) ∈ [0,1]
22
  res = lg.lambda_gate(axes, threshold=0.5) # ADVISORY pass/fail
build/torch-cpu/szl_lambda_gate/governed_norm/_receipt.py CHANGED
@@ -16,8 +16,7 @@ HONESTY:
16
  it proves authorship. DSSE signing is a separate, out-of-band concern.
17
  - Receipts are kept in an in-process, append-only chain. Nothing is written
18
  to disk or the network from inside the kernel.
19
- - Stdlib + torch (+ numpy for the output digest) only — Kernel Hub
20
- universal-kernel requirement.
21
  - The canonical szl-receipt v0.2.0 evidence binding (``emit_receipt``) is
22
  ADDITIVE and IMPORT-GUARDED: with szl-receipt absent it returns ``None`` and
23
  the kernel runs unchanged. It binds subject / input-digest / output-digest /
@@ -27,6 +26,7 @@ HONESTY:
27
  """
28
  import hashlib
29
  import json
 
30
  import threading
31
  import time
32
  from typing import Any, Dict, List, Optional, Union
@@ -71,19 +71,90 @@ def _maybe_sign(
71
  return env
72
 
73
 
74
- def _tensor_digest(t: torch.Tensor, decimals: int = 6) -> str:
75
- """Deterministic SHA3-256 over a tensor's rounded float32 contents.
 
 
 
 
 
 
 
76
 
77
- Rounding to a fixed number of decimals makes the digest stable across
78
- devices/dtypes for the same logical values (tiny FP noise won't change
79
- it). This is an integrity fingerprint, not a signature.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  """
81
  flat = t.detach().to(torch.float32).reshape(-1)
82
- # Round to `decimals` places, integerize, hash the raw bytes. CPU move is
83
- # required to read bytes; kept O(n) and allocation-light.
84
- scaled = torch.round(flat * (10 ** decimals)).to(torch.int64).cpu().numpy().tobytes()
85
  h = hashlib.sha3_256()
86
- h.update(scaled)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  return h.hexdigest()
88
 
89
 
@@ -112,17 +183,19 @@ def emit_receipt(
112
  policy_id: str = _POLICY_ID,
113
  sign_key: Optional[Union[str, bytes]] = None,
114
  organ: str = _ORGAN,
 
115
  ) -> Optional[Dict[str, Any]]:
116
  """Canonical szl-receipt v0.2.0 evidence binding for a governed-norm call.
117
 
118
  ADDITIVE and IMPORT-GUARDED: returns ``None`` when szl-receipt is not
119
  installed, so this universal Kernel-Hub kernel still imports and runs on
120
- stdlib + torch + numpy alone. When szl-receipt is present it binds an
121
  EVIDENCE trail and wraps it in a DSSE envelope via ``sign_receipt``:
122
 
123
  subject organ / norm-call id (who/what emitted this)
124
  input_digest SHA3-256 over canonical {input shape, dtype, eps}
125
- output_digest the EXISTING SHA3-256 rounded-tensor digest of ``out``
 
126
  policy_id the governing policy id
127
  energy the literal string "UNAVAILABLE"
128
 
@@ -145,7 +218,7 @@ def emit_receipt(
145
  body = {
146
  "subject": subject if subject is not None else f"{organ}/{op}",
147
  "input_digest": _input_digest(x, eps),
148
- "output_digest": _tensor_digest(out),
149
  "policy_id": policy_id,
150
  "energy": _ENERGY_UNAVAILABLE,
151
  }
@@ -179,27 +252,37 @@ class ReceiptChain:
179
  sign_key: Optional[Union[str, bytes]] = None,
180
  organ: str = _ORGAN,
181
  policy_id: str = _POLICY_ID,
 
182
  ) -> Dict[str, Any]:
183
  with self._lock:
184
  prev = self._records[-1]["digest"] if self._records else _GENESIS
185
  seq = len(self._records)
 
 
 
 
186
  body = {
187
  "seq": seq,
188
  "op": op,
189
  "in_shape": list(x.shape),
190
  "in_dtype": str(x.dtype).replace("torch.", ""),
191
  "eps": float(eps),
192
- "out_digest": _tensor_digest(out),
193
  "prev": prev,
194
  }
195
  digest = self._digest_body(body)
196
- rec = dict(body, digest=digest, ts=time.time())
 
 
 
 
 
197
  sig = _maybe_sign(body, sign_key, organ)
198
  if sig is not None:
199
  rec["signature"] = sig
200
  # ADDITIVE canonical szl-receipt v0.2.0 evidence binding. Import-
201
  # guarded: None when szl-receipt is absent, so the universal kernel
202
- # keeps working on stdlib + torch + numpy only. Binds subject /
203
  # input-digest / output-digest / policy-id / energy; energy is
204
  # "UNAVAILABLE" (no joules measured here). It does NOT enter the
205
  # SHA3-256 chain body, so verify() is unaffected.
@@ -209,6 +292,7 @@ class ReceiptChain:
209
  policy_id=policy_id,
210
  sign_key=sign_key,
211
  organ=organ,
 
212
  )
213
  if binding is not None:
214
  rec["receipt"] = binding
 
16
  it proves authorship. DSSE signing is a separate, out-of-band concern.
17
  - Receipts are kept in an in-process, append-only chain. Nothing is written
18
  to disk or the network from inside the kernel.
19
+ - Stdlib + torch only — Kernel Hub universal-kernel requirement.
 
20
  - The canonical szl-receipt v0.2.0 evidence binding (``emit_receipt``) is
21
  ADDITIVE and IMPORT-GUARDED: with szl-receipt absent it returns ``None`` and
22
  the kernel runs unchanged. It binds subject / input-digest / output-digest /
 
26
  """
27
  import hashlib
28
  import json
29
+ import struct
30
  import threading
31
  import time
32
  from typing import Any, Dict, List, Optional, Union
 
71
  return env
72
 
73
 
74
+ # Historical receipts used the rounded-int64 encoding. The class-byte encoding
75
+ # prefixes one class byte per element, so finite-value digests change too.
76
+ # A stored hash is never rewritten from one encoding into the other.
77
+ # Donor: szl-governed-norm src _receipt.py at
78
+ # 3ef27eb7ebf491b0a6ce69be170ecef4c37885a2, file pin
79
+ # c68d06d35058542ea77dc6bad4c8bde2361cc16a.
80
+ TENSOR_DIGEST_LEGACY = "rounded-int64-v1"
81
+ TENSOR_DIGEST_CLASS_BYTE = "class-byte-v1"
82
+ TENSOR_DIGEST_DEFAULT = TENSOR_DIGEST_CLASS_BYTE
83
 
84
+
85
+ def _update_tensor_bytes(h, tensor: torch.Tensor) -> None:
86
+ """Hash native-endian uint8 or int64 tensor bytes without NumPy.
87
+
88
+ Bounded chunks preserve the historical byte stream without building a
89
+ Python list for the entire output tensor.
90
+ """
91
+ flat = tensor.cpu().contiguous().reshape(-1)
92
+ for chunk in flat.split(4096):
93
+ values = chunk.tolist()
94
+ if flat.dtype == torch.uint8:
95
+ h.update(bytes(values))
96
+ elif flat.dtype == torch.int64:
97
+ h.update(struct.pack(f"={len(values)}q", *values))
98
+ else:
99
+ raise TypeError(f"unsupported tensor digest dtype: {flat.dtype}")
100
+
101
+
102
+ def _tensor_digest(
103
+ t: torch.Tensor,
104
+ decimals: int = 6,
105
+ *,
106
+ encoding: str = TENSOR_DIGEST_DEFAULT,
107
+ ) -> str:
108
+ """SHA3-256 of a tensor under an explicit encoding.
109
+
110
+ ``rounded-int64-v1`` is the historical interpretation. ``class-byte-v1``
111
+ is the current default. Passing the other encoding interprets the same
112
+ tensor; it does not replace a hash that was already stored.
113
+ """
114
+ if encoding == TENSOR_DIGEST_LEGACY:
115
+ return _tensor_digest_legacy(t, decimals)
116
+ if encoding == TENSOR_DIGEST_CLASS_BYTE:
117
+ return _tensor_digest_class_byte(t, decimals)
118
+ raise ValueError(
119
+ f"unknown tensor digest encoding {encoding!r}; "
120
+ f"expected {TENSOR_DIGEST_LEGACY!r} or {TENSOR_DIGEST_CLASS_BYTE!r}"
121
+ )
122
+
123
+
124
+ def _tensor_digest_legacy(t: torch.Tensor, decimals: int = 6) -> str:
125
+ """Historical digest: rounded int64 payload only.
126
+
127
+ Non-finite values can collide under int64 saturation. This function
128
+ remains so those historical hashes can still be reproduced.
129
  """
130
  flat = t.detach().to(torch.float32).reshape(-1)
131
+ scaled = torch.round(flat * (10 ** decimals)).to(torch.int64)
 
 
132
  h = hashlib.sha3_256()
133
+ _update_tensor_bytes(h, scaled)
134
+ return h.hexdigest()
135
+
136
+
137
+ def _tensor_digest_class_byte(t: torch.Tensor, decimals: int = 6) -> str:
138
+ """Class-byte digest. Finite digests change because the class bytes are hashed first.
139
+
140
+ Each element contributes a class byte (0 = finite, 1 = +Inf, 2 = -Inf,
141
+ 3 = NaN) and then its rounded int64 payload. Non-finite payloads are 0,
142
+ so the class byte carries their identity. Finite payloads stay the
143
+ rounded int64 values, but the prefix means the SHA3-256 digest is not
144
+ the legacy digest. -0.0 and +0.0 still share a digest.
145
+ """
146
+ flat = t.detach().to(torch.float32).reshape(-1)
147
+ cls = torch.zeros_like(flat, dtype=torch.uint8)
148
+ cls[flat == float("inf")] = 1
149
+ cls[flat == float("-inf")] = 2
150
+ cls[torch.isnan(flat)] = 3
151
+ finite = cls == 0
152
+ scaled = torch.where(
153
+ finite, torch.round(flat * (10 ** decimals)), torch.zeros_like(flat)
154
+ ).to(torch.int64)
155
+ h = hashlib.sha3_256()
156
+ _update_tensor_bytes(h, cls)
157
+ _update_tensor_bytes(h, scaled)
158
  return h.hexdigest()
159
 
160
 
 
183
  policy_id: str = _POLICY_ID,
184
  sign_key: Optional[Union[str, bytes]] = None,
185
  organ: str = _ORGAN,
186
+ digest_encoding: str = TENSOR_DIGEST_DEFAULT,
187
  ) -> Optional[Dict[str, Any]]:
188
  """Canonical szl-receipt v0.2.0 evidence binding for a governed-norm call.
189
 
190
  ADDITIVE and IMPORT-GUARDED: returns ``None`` when szl-receipt is not
191
  installed, so this universal Kernel-Hub kernel still imports and runs on
192
+ stdlib + torch alone. When szl-receipt is present it binds an
193
  EVIDENCE trail and wraps it in a DSSE envelope via ``sign_receipt``:
194
 
195
  subject organ / norm-call id (who/what emitted this)
196
  input_digest SHA3-256 over canonical {input shape, dtype, eps}
197
+ output_digest SHA3-256 of ``out`` under ``digest_encoding``
198
+ (default class-byte-v1; legacy remains callable)
199
  policy_id the governing policy id
200
  energy the literal string "UNAVAILABLE"
201
 
 
218
  body = {
219
  "subject": subject if subject is not None else f"{organ}/{op}",
220
  "input_digest": _input_digest(x, eps),
221
+ "output_digest": _tensor_digest(out, encoding=digest_encoding),
222
  "policy_id": policy_id,
223
  "energy": _ENERGY_UNAVAILABLE,
224
  }
 
252
  sign_key: Optional[Union[str, bytes]] = None,
253
  organ: str = _ORGAN,
254
  policy_id: str = _POLICY_ID,
255
+ digest_encoding: str = TENSOR_DIGEST_DEFAULT,
256
  ) -> Dict[str, Any]:
257
  with self._lock:
258
  prev = self._records[-1]["digest"] if self._records else _GENESIS
259
  seq = len(self._records)
260
+ # The encoding label stays outside the hashed body. verify()
261
+ # still rebuilds that body from the original keys, so a legacy
262
+ # receipt is not rewritten when this field is absent or present.
263
+ out_digest = _tensor_digest(out, encoding=digest_encoding)
264
  body = {
265
  "seq": seq,
266
  "op": op,
267
  "in_shape": list(x.shape),
268
  "in_dtype": str(x.dtype).replace("torch.", ""),
269
  "eps": float(eps),
270
+ "out_digest": out_digest,
271
  "prev": prev,
272
  }
273
  digest = self._digest_body(body)
274
+ rec = dict(
275
+ body,
276
+ digest=digest,
277
+ ts=time.time(),
278
+ tensor_digest_encoding=digest_encoding,
279
+ )
280
  sig = _maybe_sign(body, sign_key, organ)
281
  if sig is not None:
282
  rec["signature"] = sig
283
  # ADDITIVE canonical szl-receipt v0.2.0 evidence binding. Import-
284
  # guarded: None when szl-receipt is absent, so the universal kernel
285
+ # keeps working on stdlib + torch only. Binds subject /
286
  # input-digest / output-digest / policy-id / energy; energy is
287
  # "UNAVAILABLE" (no joules measured here). It does NOT enter the
288
  # SHA3-256 chain body, so verify() is unaffected.
 
292
  policy_id=policy_id,
293
  sign_key=sign_key,
294
  organ=organ,
295
+ digest_encoding=digest_encoding,
296
  )
297
  if binding is not None:
298
  rec["receipt"] = binding
build/torch-universal/__init__.py DELETED
@@ -1,2 +0,0 @@
1
- from .szl_lambda_gate import * # noqa: F401,F403
2
- from .szl_lambda_gate import __all__
 
 
 
build/torch-universal/metadata.json CHANGED
@@ -1 +1,26 @@
1
- {"backend":{"type":"cpu"},"digest":{"algorithm":"sha256","files":{"__init__.py":"NuinjlWRNlWgg0y2D61HEaKtW/VOktRHP8w2Nj3opjQ=","szl_lambda_gate/__init__.py":"QpfkkacuKUGxXitqBYLq0nM4NnCsX7uNFOLHbeye0V0=","szl_lambda_gate/_lambda.py":"+VOjgBnJGm+oqcQR9VuqT18rnnbXFTu6VLuKXZRprzg=","szl_lambda_gate/_ops.py":"at8dxC56nm2pFOME2pcgQ45ZwjQQThHz5cyqRezuI7Y=","szl_lambda_gate/_v1.py":"msLY/gpH/xkeunbmKx6d2bK1T2S6DD2GMG4M3Vi8Row=","szl_lambda_gate/governed_norm/__init__.py":"UP5PsJoWXQrpp4Hw7zUVOIx1KhTN6V9zaHhU9Zp9+tw=","szl_lambda_gate/governed_norm/_norm.py":"z3Ks4oHshsUEQm914j7r22YaHjoS5N/MbIufpjSwOUI=","szl_lambda_gate/governed_norm/_receipt.py":"2xJEvRhK/9ypKb04rHKLJpb4KtVlqvgtFMo4RdTXSKk=","szl_lambda_gate/governed_norm/layers.py":"15yDNVyyMyudDp2YWEuGQ05IZTLifTBlLfEBWLMPw3s=","szl_lambda_gate/layers.py":"UdpHjhhe5NFtqplxvcvc/LsMDFt4N6ACuXzQXLlo6nU="}},"id":"_szl_lambda_gate_universal_7cb79cba7ecb5dbb9da59b2d6b516a98d2a114d6","license":"Apache-2.0","name":"szl-lambda-gate","python-depends":[],"source":"https://github.com/szl-holdings/szl-lambda-gate","universal":true,"version":1}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": {
3
+ "type": "cpu"
4
+ },
5
+ "digest": {
6
+ "algorithm": "sha256",
7
+ "files": {
8
+ "szl_lambda_gate/__init__.py": "LZXLKlcqnujwBnjhqK/zR6Esyw1SnSlFpqO9Z/pWWFQ=",
9
+ "szl_lambda_gate/_lambda.py": "+VOjgBnJGm+oqcQR9VuqT18rnnbXFTu6VLuKXZRprzg=",
10
+ "szl_lambda_gate/_ops.py": "at8dxC56nm2pFOME2pcgQ45ZwjQQThHz5cyqRezuI7Y=",
11
+ "szl_lambda_gate/_v1.py": "msLY/gpH/xkeunbmKx6d2bK1T2S6DD2GMG4M3Vi8Row=",
12
+ "szl_lambda_gate/governed_norm/__init__.py": "UP5PsJoWXQrpp4Hw7zUVOIx1KhTN6V9zaHhU9Zp9+tw=",
13
+ "szl_lambda_gate/governed_norm/_norm.py": "z3Ks4oHshsUEQm914j7r22YaHjoS5N/MbIufpjSwOUI=",
14
+ "szl_lambda_gate/governed_norm/_receipt.py": "D6LPfoxfT5tZCIaLptbsBenfvsJqdla4mrK/vfPW2HA=",
15
+ "szl_lambda_gate/governed_norm/layers.py": "15yDNVyyMyudDp2YWEuGQ05IZTLifTBlLfEBWLMPw3s=",
16
+ "szl_lambda_gate/layers.py": "UdpHjhhe5NFtqplxvcvc/LsMDFt4N6ACuXzQXLlo6nU="
17
+ }
18
+ },
19
+ "id": "_szl_lambda_gate_universal_219ee89500f2",
20
+ "kernel-depends": [],
21
+ "license": "Apache-2.0",
22
+ "name": "szl-lambda-gate",
23
+ "python-depends": [],
24
+ "source": "https://github.com/szl-holdings/szl-lambda-gate",
25
+ "version": 1
26
+ }
build/torch-universal/szl_lambda_gate/__init__.py CHANGED
@@ -16,7 +16,7 @@ Load from the Hub:
16
  import torch
17
  from kernels import get_kernel
18
 
19
- lg = get_kernel("SZLHOLDINGS/szl-lambda-gate")
20
  axes = torch.tensor([0.9, 0.8, 0.95]) # axis scores in [0,1]
21
  score = lg.lambda_aggregate(axes) # Λ(x) ∈ [0,1]
22
  res = lg.lambda_gate(axes, threshold=0.5) # ADVISORY pass/fail
 
16
  import torch
17
  from kernels import get_kernel
18
 
19
+ lg = get_kernel("SZLHOLDINGS/szl-lambda-gate", version=1, trust_remote_code=True)
20
  axes = torch.tensor([0.9, 0.8, 0.95]) # axis scores in [0,1]
21
  score = lg.lambda_aggregate(axes) # Λ(x) ∈ [0,1]
22
  res = lg.lambda_gate(axes, threshold=0.5) # ADVISORY pass/fail
build/torch-universal/szl_lambda_gate/governed_norm/_receipt.py CHANGED
@@ -16,8 +16,7 @@ HONESTY:
16
  it proves authorship. DSSE signing is a separate, out-of-band concern.
17
  - Receipts are kept in an in-process, append-only chain. Nothing is written
18
  to disk or the network from inside the kernel.
19
- - Stdlib + torch (+ numpy for the output digest) only — Kernel Hub
20
- universal-kernel requirement.
21
  - The canonical szl-receipt v0.2.0 evidence binding (``emit_receipt``) is
22
  ADDITIVE and IMPORT-GUARDED: with szl-receipt absent it returns ``None`` and
23
  the kernel runs unchanged. It binds subject / input-digest / output-digest /
@@ -27,6 +26,7 @@ HONESTY:
27
  """
28
  import hashlib
29
  import json
 
30
  import threading
31
  import time
32
  from typing import Any, Dict, List, Optional, Union
@@ -71,19 +71,90 @@ def _maybe_sign(
71
  return env
72
 
73
 
74
- def _tensor_digest(t: torch.Tensor, decimals: int = 6) -> str:
75
- """Deterministic SHA3-256 over a tensor's rounded float32 contents.
 
 
 
 
 
 
 
76
 
77
- Rounding to a fixed number of decimals makes the digest stable across
78
- devices/dtypes for the same logical values (tiny FP noise won't change
79
- it). This is an integrity fingerprint, not a signature.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  """
81
  flat = t.detach().to(torch.float32).reshape(-1)
82
- # Round to `decimals` places, integerize, hash the raw bytes. CPU move is
83
- # required to read bytes; kept O(n) and allocation-light.
84
- scaled = torch.round(flat * (10 ** decimals)).to(torch.int64).cpu().numpy().tobytes()
85
  h = hashlib.sha3_256()
86
- h.update(scaled)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  return h.hexdigest()
88
 
89
 
@@ -112,17 +183,19 @@ def emit_receipt(
112
  policy_id: str = _POLICY_ID,
113
  sign_key: Optional[Union[str, bytes]] = None,
114
  organ: str = _ORGAN,
 
115
  ) -> Optional[Dict[str, Any]]:
116
  """Canonical szl-receipt v0.2.0 evidence binding for a governed-norm call.
117
 
118
  ADDITIVE and IMPORT-GUARDED: returns ``None`` when szl-receipt is not
119
  installed, so this universal Kernel-Hub kernel still imports and runs on
120
- stdlib + torch + numpy alone. When szl-receipt is present it binds an
121
  EVIDENCE trail and wraps it in a DSSE envelope via ``sign_receipt``:
122
 
123
  subject organ / norm-call id (who/what emitted this)
124
  input_digest SHA3-256 over canonical {input shape, dtype, eps}
125
- output_digest the EXISTING SHA3-256 rounded-tensor digest of ``out``
 
126
  policy_id the governing policy id
127
  energy the literal string "UNAVAILABLE"
128
 
@@ -145,7 +218,7 @@ def emit_receipt(
145
  body = {
146
  "subject": subject if subject is not None else f"{organ}/{op}",
147
  "input_digest": _input_digest(x, eps),
148
- "output_digest": _tensor_digest(out),
149
  "policy_id": policy_id,
150
  "energy": _ENERGY_UNAVAILABLE,
151
  }
@@ -179,27 +252,37 @@ class ReceiptChain:
179
  sign_key: Optional[Union[str, bytes]] = None,
180
  organ: str = _ORGAN,
181
  policy_id: str = _POLICY_ID,
 
182
  ) -> Dict[str, Any]:
183
  with self._lock:
184
  prev = self._records[-1]["digest"] if self._records else _GENESIS
185
  seq = len(self._records)
 
 
 
 
186
  body = {
187
  "seq": seq,
188
  "op": op,
189
  "in_shape": list(x.shape),
190
  "in_dtype": str(x.dtype).replace("torch.", ""),
191
  "eps": float(eps),
192
- "out_digest": _tensor_digest(out),
193
  "prev": prev,
194
  }
195
  digest = self._digest_body(body)
196
- rec = dict(body, digest=digest, ts=time.time())
 
 
 
 
 
197
  sig = _maybe_sign(body, sign_key, organ)
198
  if sig is not None:
199
  rec["signature"] = sig
200
  # ADDITIVE canonical szl-receipt v0.2.0 evidence binding. Import-
201
  # guarded: None when szl-receipt is absent, so the universal kernel
202
- # keeps working on stdlib + torch + numpy only. Binds subject /
203
  # input-digest / output-digest / policy-id / energy; energy is
204
  # "UNAVAILABLE" (no joules measured here). It does NOT enter the
205
  # SHA3-256 chain body, so verify() is unaffected.
@@ -209,6 +292,7 @@ class ReceiptChain:
209
  policy_id=policy_id,
210
  sign_key=sign_key,
211
  organ=organ,
 
212
  )
213
  if binding is not None:
214
  rec["receipt"] = binding
 
16
  it proves authorship. DSSE signing is a separate, out-of-band concern.
17
  - Receipts are kept in an in-process, append-only chain. Nothing is written
18
  to disk or the network from inside the kernel.
19
+ - Stdlib + torch only — Kernel Hub universal-kernel requirement.
 
20
  - The canonical szl-receipt v0.2.0 evidence binding (``emit_receipt``) is
21
  ADDITIVE and IMPORT-GUARDED: with szl-receipt absent it returns ``None`` and
22
  the kernel runs unchanged. It binds subject / input-digest / output-digest /
 
26
  """
27
  import hashlib
28
  import json
29
+ import struct
30
  import threading
31
  import time
32
  from typing import Any, Dict, List, Optional, Union
 
71
  return env
72
 
73
 
74
+ # Historical receipts used the rounded-int64 encoding. The class-byte encoding
75
+ # prefixes one class byte per element, so finite-value digests change too.
76
+ # A stored hash is never rewritten from one encoding into the other.
77
+ # Donor: szl-governed-norm src _receipt.py at
78
+ # 3ef27eb7ebf491b0a6ce69be170ecef4c37885a2, file pin
79
+ # c68d06d35058542ea77dc6bad4c8bde2361cc16a.
80
+ TENSOR_DIGEST_LEGACY = "rounded-int64-v1"
81
+ TENSOR_DIGEST_CLASS_BYTE = "class-byte-v1"
82
+ TENSOR_DIGEST_DEFAULT = TENSOR_DIGEST_CLASS_BYTE
83
 
84
+
85
+ def _update_tensor_bytes(h, tensor: torch.Tensor) -> None:
86
+ """Hash native-endian uint8 or int64 tensor bytes without NumPy.
87
+
88
+ Bounded chunks preserve the historical byte stream without building a
89
+ Python list for the entire output tensor.
90
+ """
91
+ flat = tensor.cpu().contiguous().reshape(-1)
92
+ for chunk in flat.split(4096):
93
+ values = chunk.tolist()
94
+ if flat.dtype == torch.uint8:
95
+ h.update(bytes(values))
96
+ elif flat.dtype == torch.int64:
97
+ h.update(struct.pack(f"={len(values)}q", *values))
98
+ else:
99
+ raise TypeError(f"unsupported tensor digest dtype: {flat.dtype}")
100
+
101
+
102
+ def _tensor_digest(
103
+ t: torch.Tensor,
104
+ decimals: int = 6,
105
+ *,
106
+ encoding: str = TENSOR_DIGEST_DEFAULT,
107
+ ) -> str:
108
+ """SHA3-256 of a tensor under an explicit encoding.
109
+
110
+ ``rounded-int64-v1`` is the historical interpretation. ``class-byte-v1``
111
+ is the current default. Passing the other encoding interprets the same
112
+ tensor; it does not replace a hash that was already stored.
113
+ """
114
+ if encoding == TENSOR_DIGEST_LEGACY:
115
+ return _tensor_digest_legacy(t, decimals)
116
+ if encoding == TENSOR_DIGEST_CLASS_BYTE:
117
+ return _tensor_digest_class_byte(t, decimals)
118
+ raise ValueError(
119
+ f"unknown tensor digest encoding {encoding!r}; "
120
+ f"expected {TENSOR_DIGEST_LEGACY!r} or {TENSOR_DIGEST_CLASS_BYTE!r}"
121
+ )
122
+
123
+
124
+ def _tensor_digest_legacy(t: torch.Tensor, decimals: int = 6) -> str:
125
+ """Historical digest: rounded int64 payload only.
126
+
127
+ Non-finite values can collide under int64 saturation. This function
128
+ remains so those historical hashes can still be reproduced.
129
  """
130
  flat = t.detach().to(torch.float32).reshape(-1)
131
+ scaled = torch.round(flat * (10 ** decimals)).to(torch.int64)
 
 
132
  h = hashlib.sha3_256()
133
+ _update_tensor_bytes(h, scaled)
134
+ return h.hexdigest()
135
+
136
+
137
+ def _tensor_digest_class_byte(t: torch.Tensor, decimals: int = 6) -> str:
138
+ """Class-byte digest. Finite digests change because the class bytes are hashed first.
139
+
140
+ Each element contributes a class byte (0 = finite, 1 = +Inf, 2 = -Inf,
141
+ 3 = NaN) and then its rounded int64 payload. Non-finite payloads are 0,
142
+ so the class byte carries their identity. Finite payloads stay the
143
+ rounded int64 values, but the prefix means the SHA3-256 digest is not
144
+ the legacy digest. -0.0 and +0.0 still share a digest.
145
+ """
146
+ flat = t.detach().to(torch.float32).reshape(-1)
147
+ cls = torch.zeros_like(flat, dtype=torch.uint8)
148
+ cls[flat == float("inf")] = 1
149
+ cls[flat == float("-inf")] = 2
150
+ cls[torch.isnan(flat)] = 3
151
+ finite = cls == 0
152
+ scaled = torch.where(
153
+ finite, torch.round(flat * (10 ** decimals)), torch.zeros_like(flat)
154
+ ).to(torch.int64)
155
+ h = hashlib.sha3_256()
156
+ _update_tensor_bytes(h, cls)
157
+ _update_tensor_bytes(h, scaled)
158
  return h.hexdigest()
159
 
160
 
 
183
  policy_id: str = _POLICY_ID,
184
  sign_key: Optional[Union[str, bytes]] = None,
185
  organ: str = _ORGAN,
186
+ digest_encoding: str = TENSOR_DIGEST_DEFAULT,
187
  ) -> Optional[Dict[str, Any]]:
188
  """Canonical szl-receipt v0.2.0 evidence binding for a governed-norm call.
189
 
190
  ADDITIVE and IMPORT-GUARDED: returns ``None`` when szl-receipt is not
191
  installed, so this universal Kernel-Hub kernel still imports and runs on
192
+ stdlib + torch alone. When szl-receipt is present it binds an
193
  EVIDENCE trail and wraps it in a DSSE envelope via ``sign_receipt``:
194
 
195
  subject organ / norm-call id (who/what emitted this)
196
  input_digest SHA3-256 over canonical {input shape, dtype, eps}
197
+ output_digest SHA3-256 of ``out`` under ``digest_encoding``
198
+ (default class-byte-v1; legacy remains callable)
199
  policy_id the governing policy id
200
  energy the literal string "UNAVAILABLE"
201
 
 
218
  body = {
219
  "subject": subject if subject is not None else f"{organ}/{op}",
220
  "input_digest": _input_digest(x, eps),
221
+ "output_digest": _tensor_digest(out, encoding=digest_encoding),
222
  "policy_id": policy_id,
223
  "energy": _ENERGY_UNAVAILABLE,
224
  }
 
252
  sign_key: Optional[Union[str, bytes]] = None,
253
  organ: str = _ORGAN,
254
  policy_id: str = _POLICY_ID,
255
+ digest_encoding: str = TENSOR_DIGEST_DEFAULT,
256
  ) -> Dict[str, Any]:
257
  with self._lock:
258
  prev = self._records[-1]["digest"] if self._records else _GENESIS
259
  seq = len(self._records)
260
+ # The encoding label stays outside the hashed body. verify()
261
+ # still rebuilds that body from the original keys, so a legacy
262
+ # receipt is not rewritten when this field is absent or present.
263
+ out_digest = _tensor_digest(out, encoding=digest_encoding)
264
  body = {
265
  "seq": seq,
266
  "op": op,
267
  "in_shape": list(x.shape),
268
  "in_dtype": str(x.dtype).replace("torch.", ""),
269
  "eps": float(eps),
270
+ "out_digest": out_digest,
271
  "prev": prev,
272
  }
273
  digest = self._digest_body(body)
274
+ rec = dict(
275
+ body,
276
+ digest=digest,
277
+ ts=time.time(),
278
+ tensor_digest_encoding=digest_encoding,
279
+ )
280
  sig = _maybe_sign(body, sign_key, organ)
281
  if sig is not None:
282
  rec["signature"] = sig
283
  # ADDITIVE canonical szl-receipt v0.2.0 evidence binding. Import-
284
  # guarded: None when szl-receipt is absent, so the universal kernel
285
+ # keeps working on stdlib + torch only. Binds subject /
286
  # input-digest / output-digest / policy-id / energy; energy is
287
  # "UNAVAILABLE" (no joules measured here). It does NOT enter the
288
  # SHA3-256 chain body, so verify() is unaffected.
 
292
  policy_id=policy_id,
293
  sign_key=sign_key,
294
  organ=organ,
295
+ digest_encoding=digest_encoding,
296
  )
297
  if binding is not None:
298
  rec["receipt"] = binding
distribution.json DELETED
@@ -1 +0,0 @@
1
- {"files":{"build.toml":"5c5ebbfe83770a898b8b8893e342c2c5547c65cd2b5a96146b14e3abb9411f3b","build/torch-cpu/__init__.py":"36e8a78e55913655a0834cb60fad4711a2ad5bf54e92d4473fcc36363de8a634","build/torch-cpu/metadata.json":"d15c8285af060f9c1e43ff269650508fe0f31a0297cfbd309aff552e9de8d3d4","build/torch-cpu/szl_lambda_gate/__init__.py":"4297e491a72e2941b15e2b6a0582ead273383670ac5fbb8d14e2c76dec9ed15d","build/torch-cpu/szl_lambda_gate/_lambda.py":"f953a38019c91a6fa8a9c411f55baa4f5f2b9e76d7153bba54bb8a5d9469af38","build/torch-cpu/szl_lambda_gate/_ops.py":"6adf1dc42e7a9e6da914e304da9720438e59c234104e11f3e5ccaa45ecee23b6","build/torch-cpu/szl_lambda_gate/_v1.py":"9ac2d8fe0a47ff191eba76e62b1e9dd9b2b54f64ba0c3d86306e0cdd58bc468c","build/torch-cpu/szl_lambda_gate/governed_norm/__init__.py":"50fe4fb09a165d0ae9a781f0ef3515388c752a14cde95f73687854f59a7dfadc","build/torch-cpu/szl_lambda_gate/governed_norm/_norm.py":"cf72ace281ec86c504426f75e23eebdb661a1e3a12e4dfcc6c8b9fa634b03942","build/torch-cpu/szl_lambda_gate/governed_norm/_receipt.py":"db1244bd184affdca929bd38ac728b2696f82ad565aaf82d14ca3845d4d748a9","build/torch-cpu/szl_lambda_gate/governed_norm/layers.py":"d79c83355cb2332b9d0e9d98584b86434e486532e27d30652df10158b30fc37b","build/torch-cpu/szl_lambda_gate/layers.py":"51da478e185ee4d16daa9971bdcbdcfcbb0c0c5b7837a002b97cd05cb968ea75","build/torch-universal/__init__.py":"36e8a78e55913655a0834cb60fad4711a2ad5bf54e92d4473fcc36363de8a634","build/torch-universal/metadata.json":"448ed5fb0c866455d045cdc7a75e1bbcaccc8d9f323039daf62cda1f5a35e0b4","build/torch-universal/szl_lambda_gate/__init__.py":"4297e491a72e2941b15e2b6a0582ead273383670ac5fbb8d14e2c76dec9ed15d","build/torch-universal/szl_lambda_gate/_lambda.py":"f953a38019c91a6fa8a9c411f55baa4f5f2b9e76d7153bba54bb8a5d9469af38","build/torch-universal/szl_lambda_gate/_ops.py":"6adf1dc42e7a9e6da914e304da9720438e59c234104e11f3e5ccaa45ecee23b6","build/torch-universal/szl_lambda_gate/_v1.py":"9ac2d8fe0a47ff191eba76e62b1e9dd9b2b54f64ba0c3d86306e0cdd58bc468c","build/torch-universal/szl_lambda_gate/governed_norm/__init__.py":"50fe4fb09a165d0ae9a781f0ef3515388c752a14cde95f73687854f59a7dfadc","build/torch-universal/szl_lambda_gate/governed_norm/_norm.py":"cf72ace281ec86c504426f75e23eebdb661a1e3a12e4dfcc6c8b9fa634b03942","build/torch-universal/szl_lambda_gate/governed_norm/_receipt.py":"db1244bd184affdca929bd38ac728b2696f82ad565aaf82d14ca3845d4d748a9","build/torch-universal/szl_lambda_gate/governed_norm/layers.py":"d79c83355cb2332b9d0e9d98584b86434e486532e27d30652df10158b30fc37b","build/torch-universal/szl_lambda_gate/layers.py":"51da478e185ee4d16daa9971bdcbdcfcbb0c0c5b7837a002b97cd05cb968ea75","reference/szl_lambda_v1.py":"57b264fa96056d1f2d77b797ba80eab087a729283f16416196fdd1423c9c532f","source/LICENSE":"bc8cef3450d423b046a3ba2b1a03089c8c795302f502cabbdbef055a68f0b1e7","spec/lambda_v1_vectors.json":"460bb966ff2bec4fd99e03d267b721f22c5fad731e0667723407a6909bd4dcec","spec/szl.lambda.v1.json":"04a8368568d59509c8603cdc45cf80f6b1395e751c77eabb1957bbe12906f2d9"},"packager":"scripts/build_lambda_distribution.py","schema":"szl.lambda/distribution.v1","source_commit":"7cb79cba7ecb5dbb9da59b2d6b516a98d2a114d6","source_files":{"LICENSE":"bc8cef3450d423b046a3ba2b1a03089c8c795302f502cabbdbef055a68f0b1e7","build.toml":"5c5ebbfe83770a898b8b8893e342c2c5547c65cd2b5a96146b14e3abb9411f3b","reference/szl_lambda_v1.py":"57b264fa96056d1f2d77b797ba80eab087a729283f16416196fdd1423c9c532f","spec/lambda_v1_vectors.json":"460bb966ff2bec4fd99e03d267b721f22c5fad731e0667723407a6909bd4dcec","spec/szl.lambda.v1.json":"04a8368568d59509c8603cdc45cf80f6b1395e751c77eabb1957bbe12906f2d9","torch-ext/szl_lambda_gate/__init__.py":"4297e491a72e2941b15e2b6a0582ead273383670ac5fbb8d14e2c76dec9ed15d","torch-ext/szl_lambda_gate/_lambda.py":"f953a38019c91a6fa8a9c411f55baa4f5f2b9e76d7153bba54bb8a5d9469af38","torch-ext/szl_lambda_gate/_ops.py":"6adf1dc42e7a9e6da914e304da9720438e59c234104e11f3e5ccaa45ecee23b6","torch-ext/szl_lambda_gate/_v1.py":"9ac2d8fe0a47ff191eba76e62b1e9dd9b2b54f64ba0c3d86306e0cdd58bc468c","torch-ext/szl_lambda_gate/governed_norm/__init__.py":"50fe4fb09a165d0ae9a781f0ef3515388c752a14cde95f73687854f59a7dfadc","torch-ext/szl_lambda_gate/governed_norm/_norm.py":"cf72ace281ec86c504426f75e23eebdb661a1e3a12e4dfcc6c8b9fa634b03942","torch-ext/szl_lambda_gate/governed_norm/_receipt.py":"db1244bd184affdca929bd38ac728b2696f82ad565aaf82d14ca3845d4d748a9","torch-ext/szl_lambda_gate/governed_norm/layers.py":"d79c83355cb2332b9d0e9d98584b86434e486532e27d30652df10158b30fc37b","torch-ext/szl_lambda_gate/layers.py":"51da478e185ee4d16daa9971bdcbdcfcbb0c0c5b7837a002b97cd05cb968ea75"},"source_repository":"https://github.com/szl-holdings/szl-lambda-gate","vectors_count":60,"vectors_sha256":"61bfb0410b9f0eaab0eb9f22f29cb7cb13cfde8c083fe308d895565d6ba9ebd4"}
 
 
source/LICENSE DELETED
@@ -1,202 +0,0 @@
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 2026 SZL Holdings
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.