sengol-verify 2.1.0__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 (41) hide show
  1. sengol_verify-2.1.0/.github/workflows/ci.yml +53 -0
  2. sengol_verify-2.1.0/.github/workflows/publish.yml +43 -0
  3. sengol_verify-2.1.0/.gitignore +8 -0
  4. sengol_verify-2.1.0/AGENTS.md +11 -0
  5. sengol_verify-2.1.0/CLAUDE.md +12 -0
  6. sengol_verify-2.1.0/LICENSE +201 -0
  7. sengol_verify-2.1.0/PKG-INFO +218 -0
  8. sengol_verify-2.1.0/README.md +199 -0
  9. sengol_verify-2.1.0/pyproject.toml +44 -0
  10. sengol_verify-2.1.0/scripts/_bundles.py +153 -0
  11. sengol_verify-2.1.0/scripts/_families.py +209 -0
  12. sengol_verify-2.1.0/scripts/_tables.py +127 -0
  13. sengol_verify-2.1.0/scripts/crosscheck.py +166 -0
  14. sengol_verify-2.1.0/scripts/generate_fixtures.py +228 -0
  15. sengol_verify-2.1.0/src/sengol_verify/__init__.py +7 -0
  16. sengol_verify-2.1.0/src/sengol_verify/bundle.py +144 -0
  17. sengol_verify-2.1.0/src/sengol_verify/canonical.py +390 -0
  18. sengol_verify-2.1.0/src/sengol_verify/cli.py +223 -0
  19. sengol_verify-2.1.0/src/sengol_verify/merkle.py +31 -0
  20. sengol_verify-2.1.0/src/sengol_verify/verify.py +695 -0
  21. sengol_verify-2.1.0/tests/fixtures/bundle.json +297 -0
  22. sengol_verify-2.1.0/tests/fixtures/bundle_chain_break.json +297 -0
  23. sengol_verify-2.1.0/tests/fixtures/bundle_full_pass.json +300 -0
  24. sengol_verify-2.1.0/tests/fixtures/bundle_tampered.json +297 -0
  25. sengol_verify-2.1.0/tests/fixtures/canonical_fixtures.json +4163 -0
  26. sengol_verify-2.1.0/tests/fixtures/judge_evidence_pack.json +364 -0
  27. sengol_verify-2.1.0/tests/fixtures/partition_bundle.json +2341 -0
  28. sengol_verify-2.1.0/tests/fixtures/regression_chain_fixture.json +204 -0
  29. sengol_verify-2.1.0/tests/fixtures/sengol_tables.json +444 -0
  30. sengol_verify-2.1.0/tests/fixtures/trusted_ed25519.pem +3 -0
  31. sengol_verify-2.1.0/tests/helpers.py +12 -0
  32. sengol_verify-2.1.0/tests/test_canonical.py +477 -0
  33. sengol_verify-2.1.0/tests/test_field_coverage.py +172 -0
  34. sengol_verify-2.1.0/tests/test_no_sengol_dependency.py +68 -0
  35. sengol_verify-2.1.0/tests/test_regression_bundle.py +304 -0
  36. sengol_verify-2.1.0/tests/test_regression_chain.py +73 -0
  37. sengol_verify-2.1.0/tests/test_sengol_fixtures.py +139 -0
  38. sengol_verify-2.1.0/tests/test_sengol_tables.py +58 -0
  39. sengol_verify-2.1.0/tests/test_trust.py +413 -0
  40. sengol_verify-2.1.0/tests/test_verify_bundle.py +208 -0
  41. sengol_verify-2.1.0/uv.lock +302 -0
@@ -0,0 +1,53 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Install uv
14
+ uses: astral-sh/setup-uv@v3
15
+ with:
16
+ python-version: "3.11"
17
+ - run: uv sync
18
+ - name: ruff
19
+ run: |
20
+ uv run ruff check .
21
+ uv run ruff format --check .
22
+ - name: pytest
23
+ run: uv run pytest -q
24
+
25
+ import-guard:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v3
31
+ with:
32
+ python-version: "3.11"
33
+ - run: uv sync
34
+ - name: sengol must never be importable as a dependency of sengol_verify
35
+ run: uv run pytest -q tests/test_no_sengol_dependency.py
36
+ - name: built wheel metadata declares no sengol dependency
37
+ run: |
38
+ uv build --wheel -o /tmp/dist
39
+ python3 - <<'EOF'
40
+ import glob, zipfile
41
+
42
+ wheel = sorted(glob.glob("/tmp/dist/*.whl"))[0]
43
+ with zipfile.ZipFile(wheel) as zf:
44
+ metadata_name = next(n for n in zf.namelist() if n.endswith("METADATA"))
45
+ metadata = zf.read(metadata_name).decode()
46
+
47
+ for line in metadata.splitlines():
48
+ if line.startswith("Requires-Dist:") and "sengol-verify" not in line:
49
+ assert "sengol" not in line.lower().split(":", 1)[1].split(";")[0], (
50
+ f"wheel depends on sengol: {line!r}"
51
+ )
52
+ print("OK: wheel declares no sengol dependency")
53
+ EOF
@@ -0,0 +1,43 @@
1
+ # Publishes sengol-verify to PyPI through a trusted publisher (OIDC): no API
2
+ # token is stored anywhere. PyPI must list this repository, this workflow file
3
+ # name and no environment as the trusted publisher for the project.
4
+ name: publish
5
+
6
+ on:
7
+ release:
8
+ types: [published]
9
+ workflow_dispatch:
10
+ inputs:
11
+ testpypi:
12
+ description: Publish to TestPyPI instead of PyPI (proves the OIDC exchange only)
13
+ type: boolean
14
+ default: false
15
+
16
+ permissions:
17
+ contents: read
18
+ id-token: write
19
+
20
+ jobs:
21
+ publish:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: astral-sh/setup-uv@v5
26
+ - name: Build sdist and wheel
27
+ run: uv build
28
+ - name: Guard the wheel against a sengol dependency
29
+ run: |
30
+ uv run --no-project --with ./dist/*.whl python - <<'PY'
31
+ import importlib.metadata as m
32
+ reqs = m.requires("sengol-verify") or []
33
+ assert not any(r.split()[0].lower().startswith("sengol") for r in reqs), reqs
34
+ print("requires:", reqs)
35
+ PY
36
+ # TestPyPI needs its own pending publisher at test.pypi.org (same repo,
37
+ # workflow file name and no environment).
38
+ - name: Publish to TestPyPI
39
+ if: inputs.testpypi
40
+ run: uv publish --publish-url https://test.pypi.org/legacy/
41
+ - name: Publish
42
+ if: ${{ !inputs.testpypi }}
43
+ run: uv publish
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ *.egg-info/
7
+ dist/
8
+ build/
@@ -0,0 +1,11 @@
1
+ # AGENTS.md — sengol-verify
2
+
3
+ ## Code Review Rules
4
+
5
+ - Review only defects introduced or exposed by this PR.
6
+ - Report only actionable correctness, security, reliability, or breaking-change issues.
7
+ - Do not report formatting, naming preferences, speculative improvements, or unrelated existing problems.
8
+ - Do not repeat an issue already reported unless the latest commit failed to fix it.
9
+ - Before reporting a finding, verify it against the current PR head.
10
+ - Prefer one consolidated review with at most 5 findings, ordered by severity.
11
+ - If no material issues remain, approve without suggesting additional improvements.
@@ -0,0 +1,12 @@
1
+ @AGENTS.md
2
+
3
+ # CLAUDE.md — sengol-verify
4
+
5
+ ## Pull Request Review Workflow
6
+
7
+ - Collect all review comments before making changes.
8
+ - Validate each comment; do not implement incorrect or purely stylistic suggestions.
9
+ - Fix accepted comments as one batch, run tests, and push once.
10
+ - Do not push separately after every individual fix.
11
+ - Perform at most two review/fix rounds.
12
+ - After two rounds, summarize remaining disagreements and wait for human direction.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.5
2
+ Name: sengol-verify
3
+ Version: 2.1.0
4
+ Summary: Standalone, offline verifier for sengol signed evidence bundles
5
+ Project-URL: Homepage, https://github.com/sengol/sengol-verify
6
+ Author: Sengol
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: audit,evidence,offline,sengol,verification
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Security
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: cryptography>=41
17
+ Requires-Dist: rfc8785
18
+ Description-Content-Type: text/markdown
19
+
20
+ # sengol-verify
21
+
22
+ A standalone, offline verifier for [Sengol](https://github.com/sengol) signed
23
+ evidence bundles — the file `sengol audit export` produces.
24
+
25
+ ## What it verifies
26
+
27
+ Given a bundle (records, Ed25519 countersignatures, Merkle anchor receipts,
28
+ and public key material), it recomputes these checks entirely from the bytes
29
+ in the file. Step 0 and step 7 are named for the checks of the same name in
30
+ sengol's own verifier; the rest are numbered as before:
31
+
32
+ 0. **Canonical payload** — every record has a canonical payload at all. A
33
+ value with no RFC 8785 form (NaN, infinity, an integer beyond 2^53), a
34
+ payload version the family does not register, or a `record_type` this
35
+ tool does not register FAILs here, naming the record.
36
+ 1. **Payload hash integrity** — each record's canonical payload still
37
+ hashes to the value its countersignature committed to.
38
+ 2. **HMAC verification** — if the bundle embeds HMAC key material (rare;
39
+ normally withheld for security), the symmetric signature is checked too.
40
+ 3. **Hash-chain continuity** — `sequence_number` is monotone per
41
+ `(tenant_id, agent_id)` partition and every `prev_hash` links to the
42
+ previous record's canonical-payload hash.
43
+ 4. **Ed25519 countersignature verification** — each countersignature is
44
+ checked against its record's payload hash. The key it is checked against
45
+ decides what a pass means; see "Trusting the countersignature key" below.
46
+ 5. **Merkle anchor coverage** — each anchor receipt's Merkle root is
47
+ recomputed from its leaf hashes and compared.
48
+ 6. **Field coverage** — a report, not a check: it never FAILs. Every set
49
+ field is signed except the signature fields, the family's unsigned fields
50
+ and a few nested ones (an evaluator score's `reason` and `reason_status`,
51
+ a regression case binding's `config` and `reference`; all listed under
52
+ "How"), so steps 1-5 already cover everything else. This step names
53
+ which of those by-design unsigned fields the bundle's records actually
54
+ carry (for example `hmac_signature`, `eval_result.scores.reason`), so you
55
+ know which values no check vouches for. Its row always reads PASS; it does
56
+ not detect an edit to an unsigned field, and a record with an unregistered
57
+ `record_type` is not assessed (the detail says how many).
58
+ 7. **Signed-field presence** — the keys this tool would otherwise read with a
59
+ default (`record_id`, `tenant_id`, `agent_id`, `sequence_number`,
60
+ `prev_hash`, `key_id`, `payload_version`) are present on every record.
61
+ Nothing is refilled from a default here, so deleting any other signed key
62
+ changes the recomputed bytes and fails step 1 or 2; a record with no
63
+ `record_id` matches no countersignature and would otherwise read as merely
64
+ "not countersigned yet".
65
+
66
+ If the bundle has an optional top-level `regression_evidence` section
67
+ (`{"format": "sengol-regression-evidence/v1", "agent_id": ..., "records":
68
+ [{"family": ..., "record": {...}}]}`), a seventh step, **`regression_lineage`**,
69
+ is added. Any other `format` FAILs, and every record's signed `agent_id` must
70
+ equal the section's `agent_id`. Every family is one of the six regression
71
+ families (failure, case, run, certification, and the unsigned retirement and
72
+ waiver; unknown = FAIL), each record's canonical payload / HMAC (UNVERIFIABLE without
73
+ `public_keys["hmac_material"]`) checks out, and every link
74
+ resolves (case -> failure, retirement -> case, waiver -> failure, run
75
+ `case_results` -> case, certification `run_id` -> a run in the section, and
76
+ its `run_payload_sha256` -> that run's canonical-payload hash, with the same
77
+ `agent_version` as the run). A certification with no `run_payload_sha256`
78
+ FAILs, because it binds no run (sengol's deploy gate refuses it the same way).
79
+ Dangling ids and hash mismatches FAIL and are named. The signed records are not chained, so a deleted
80
+ record is not detectable. Retirements and waivers are exported unsigned (sengol
81
+ ADR-0024, families `RegressionCaseRetirement` and `ProductionFailureWaiver`),
82
+ so they have no HMAC to check; only their `agent_id` and links are verified.
83
+ The old signed families `RegressionCaseRetirementRecord` and
84
+ `ProductionFailureWaiverRecord` are not registered and FAIL as unknown.
85
+ Bundles without the section, or with it set to `null`, verify exactly as
86
+ before.
87
+
88
+ The verdict is **PASS**, **FAIL** (tampering or a broken chain), or
89
+ **UNVERIFIABLE** (the bundle honestly doesn't carry enough — e.g. no
90
+ countersignatures, no anchor receipts, or no trusted key). The exit code does
91
+ not follow the verdict; see "Exit codes".
92
+
93
+ ## How
94
+
95
+ Nothing here is normalized, coerced, or "cleaned up" before verification:
96
+ this tool recomputes over the bytes exactly as stored, which is what makes
97
+ offline verification meaningful months after the evidence was written. The
98
+ canonical payload is built by the same rule sengol signs with (RFC 8785 over
99
+ `{"record": <set fields>, "type": <family>}`, minus each family's unsigned
100
+ fields, with unordered lists sorted), using signing tables vendored from
101
+ sengol's `payload_registry.py` and `types.py`. They are not imported from
102
+ sengol, so they can drift. Two things keep them honest: `scripts/crosscheck.py`
103
+ compares them with a sengol checkout's own classes and bytes (every registered
104
+ family at every payload version, a hash-chained partition of every audit
105
+ family, a judge evidence pack), and the committed fixtures, which sengol itself
106
+ signed, are replayed by the tests; `tests/test_sengol_tables.py` fails when a
107
+ vendored table differs from the snapshot of sengol's. A sengol release newer
108
+ than the snapshot is not covered until the fixtures are regenerated
109
+ (`scripts/generate_fixtures.py`).
110
+
111
+ Some fields of an exported record are outside the signature by design
112
+ (sengol's `UNSIGNED_FIELDS`), so no check here covers them; the
113
+ `field_coverage` row lists the ones a bundle's records carry:
114
+
115
+ - an evaluator score's `reason` text and `reason_status` (sengol ADR-0078).
116
+ The signed `reason_digest` is a keyed HMAC under an install key this tool
117
+ never holds, so the text can be edited or erased without failing a check,
118
+ and this tool does not verify it. The digest itself is signed;
119
+ - `CertificationRecord.evidence_pack_id` and `.anchor_record_id`,
120
+ `SaturationEvent.remediated_at`, the raw `config` and `reference` of a
121
+ regression case binding (their hashes are signed), and the `eval_result`,
122
+ `mcp_server_version`, `model`, token and cost fields of an
123
+ `AuthorizationDecisionRecord`;
124
+ - `call_signature_manifests`, a transport-only field sengol removes before
125
+ storing a record.
126
+
127
+ ```bash
128
+ pip install sengol-verify
129
+ sengol-verify bundle.json --trusted-key appliance-key-1=appliance.pub.pem
130
+ sengol-verify path/to/bundle-dir/ --trusted-keys-file trusted.json
131
+ sengol-verify bundle.zip --trusted-key appliance-key-1=appliance.pub.pem
132
+ sengol-verify bundle.json --trusted-key ... --json # machine-readable
133
+ ```
134
+
135
+ ### Trusting the countersignature key
136
+
137
+ A bundle's own `public_keys` is part of the file being checked: someone who
138
+ rewrites every record can mint a new Ed25519 key, countersign with it, and embed
139
+ its public half, and every check above still passes against that key. A
140
+ countersignature that verifies against a key from the bundle proves the file is
141
+ internally consistent, not which appliance produced it. Give the verifier the
142
+ appliance's public key from outside the bundle (the operator, or the key you
143
+ recorded at commissioning):
144
+
145
+ - `--trusted-key KEY_ID=PEM_PATH`, repeatable: the Ed25519 public key (PEM
146
+ file) for countersignatures whose `key_id` is `KEY_ID`.
147
+ - `--trusted-keys-file PATH`: a JSON object `{"key_id": "<pem>"}`. Applied
148
+ first, so a `--trusted-key` overrides one of its entries.
149
+
150
+ With no trusted key, the `ed25519_countersig` step still checks each signature
151
+ against the embedded key as a tamper signal but reports at most UNVERIFIABLE,
152
+ and the command exits 3 with a message saying no trusted key was supplied. With
153
+ any trusted key supplied (even an empty file, meaning "trust nothing"), only
154
+ those keys are used: a countersignature whose `key_id` is not among them, or
155
+ that does not verify against it, FAILs. The embedded key is then ignored.
156
+
157
+ **A bundle with no countersignatures is not accepted, key or not.** If the
158
+ countersignatures were stripped, or countersigning was never enabled, the step
159
+ is UNVERIFIABLE even with a trusted key (nothing remains to check against it)
160
+ and the command exits 3 with a message saying so. Re-export the bundle from the
161
+ appliance with countersigning enabled, after its countersign outbox has drained
162
+ (`sengol audit export --wait-for-countersign`), and verify that file. A bundle
163
+ with no records and no countersignatures reads PASS on this step, in sengol and
164
+ here, and exits 0.
165
+
166
+ ### Exit codes
167
+
168
+ The codes are those of `sengol audit verify --offline` and follow the
169
+ `ed25519_countersig` step result, not the overall verdict:
170
+
171
+ | Code | Meaning |
172
+ | ---- | ------- |
173
+ | `0` | No step FAILed and the `ed25519_countersig` step is PASS (countersignatures verified against a trusted key). An overall UNVERIFIABLE from `hmac_verify` (always UNVERIFIABLE offline: bundles carry no HMAC key) or `anchor_coverage` does not change this. |
174
+ | `1` | At least one step FAILed. Wins over every other outcome. |
175
+ | `2` | Usage error, unreadable bundle or keys file, or a malformed `--trusted-key`. |
176
+ | `3` | Nothing FAILed, but countersignature trust is not established: no trusted key was supplied, or a key was supplied and the bundle has no countersignatures. The message names which. Treat the bundle as not verified. |
177
+
178
+ `--json` reports `trusted_key_supplied` and `countersignature_trust_established`
179
+ (true exactly when the countersignature step is PASS).
180
+
181
+ ## What it never does
182
+
183
+ `sengol-verify` never contacts Sengol, any Sengol-operated service, or any
184
+ network endpoint at all. It reads one local file and prints a verdict. It
185
+ requires no license, no API key, and no account — verification is a
186
+ property of the bytes, not a service call.
187
+
188
+ It also has **zero runtime dependency on the `sengol` package**. Its only
189
+ third-party dependencies are [`cryptography`](https://cryptography.io) (for
190
+ Ed25519) and [`rfc8785`](https://pypi.org/project/rfc8785/) (for the canonical
191
+ JSON the signatures are computed over). This is enforced by a test that imports `sengol_verify` with
192
+ `sengol` absent from `sys.modules` and asserts nothing named `sengol` or
193
+ `sengol.*` gets imported as a side effect.
194
+
195
+ ## Scope
196
+
197
+ This tool implements the offline bundle format as of `payload_registry.py`
198
+ in sengol at the time it was vendored, including the call-start,
199
+ accepted-set-lease, guard-decision (`sengol.guard.decision`) and dataset-rows-reveal
200
+ (`sengol.audit.dataset_rows_reveal`) families. It verifies the signed commitment values of a
201
+ guard decision as part of the record; it does not recompute a text or context commitment, because
202
+ a bundle carries neither the text nor its nonce. It registers only families sengol signs: the
203
+ families sengol has stopped signing (agent registration and secret records,
204
+ retention and legal-hold records, signed regression retirements and waivers,
205
+ and the like) are not registered. A bundle record whose `record_type` is not
206
+ registered, whether one of those or a type this tool has never heard of, has
207
+ no canonical payload here: `payload_hash_integrity` FAILs and names the
208
+ record and its `record_type`, and the other steps that need its payload fail
209
+ with it. It is never verified as a generic record. A `regression_evidence`
210
+ entry naming a family that is not one of the six regression families FAILs as
211
+ an unknown family. An export of such a record from an older sengol therefore cannot be
212
+ verified with this version. It does not verify anything Sengol didn't sign —
213
+ trace IDs, span IDs, and other fields documented as outside every canonical
214
+ payload are not assessed by design.
215
+
216
+ ## License
217
+
218
+ Apache-2.0. See `LICENSE`.