ample-receipts-verifier 0.2.0rc3__py3-none-any.whl
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.
- ample_receipts_verifier-0.2.0rc3.dist-info/METADATA +258 -0
- ample_receipts_verifier-0.2.0rc3.dist-info/RECORD +56 -0
- ample_receipts_verifier-0.2.0rc3.dist-info/WHEEL +4 -0
- ample_receipts_verifier-0.2.0rc3.dist-info/licenses/LICENSE +202 -0
- ample_replay/__init__.py +18 -0
- ample_replay/canonical/__init__.py +72 -0
- ample_replay/canonical/decoder.py +284 -0
- ample_replay/canonical/digest.py +36 -0
- ample_replay/canonical/encoder.py +370 -0
- ample_replay/canonical/errors.py +90 -0
- ample_replay/canonical/scale.py +117 -0
- ample_replay/canonical/values.py +318 -0
- ample_replay/receipts/__init__.py +126 -0
- ample_replay/receipts/receipt_call.py +40 -0
- ample_replay/receipts/receipt_v3.py +473 -0
- ample_replay/receipts/receipt_v4.py +378 -0
- ample_replay/receipts/receipt_v5.py +288 -0
- ample_replay/receipts/schema.py +726 -0
- ample_replay/rerun/__init__.py +26 -0
- ample_replay/rerun/policy.py +291 -0
- ample_replay/rerun/record.py +352 -0
- ample_replay/rerun/sglang_backend.py +512 -0
- ample_replay/rerun/strict.py +124 -0
- ample_replay/rerun/token_choice.py +362 -0
- ample_replay/verify/__init__.py +130 -0
- ample_replay/verify/__main__.py +1456 -0
- ample_replay/verify/anchors.py +1110 -0
- ample_replay/verify/audit.py +274 -0
- ample_replay/verify/bucket.py +551 -0
- ample_replay/verify/bundle.py +2168 -0
- ample_replay/verify/call_ids.py +65 -0
- ample_replay/verify/call_ledger.py +917 -0
- ample_replay/verify/call_receipt.py +686 -0
- ample_replay/verify/chain.py +456 -0
- ample_replay/verify/commitments.py +322 -0
- ample_replay/verify/der.py +275 -0
- ample_replay/verify/ecdsa_p256.py +129 -0
- ample_replay/verify/ed25519.py +247 -0
- ample_replay/verify/export.py +719 -0
- ample_replay/verify/genesis.py +536 -0
- ample_replay/verify/held_acks.py +474 -0
- ample_replay/verify/jcs.py +102 -0
- ample_replay/verify/pairs.py +49 -0
- ample_replay/verify/payload.py +217 -0
- ample_replay/verify/prior_envelope.py +169 -0
- ample_replay/verify/proof_inputs.py +749 -0
- ample_replay/verify/receipt.py +321 -0
- ample_replay/verify/registry.py +208 -0
- ample_replay/verify/result.py +80 -0
- ample_replay/verify/reveal_call.py +236 -0
- ample_replay/verify/rsa.py +74 -0
- ample_replay/verify/signatures.py +1097 -0
- ample_replay/verify/timestamp.py +643 -0
- ample_replay/verify/traces.py +243 -0
- ample_replay/verify/weights.py +907 -0
- ample_replay/verify/x509.py +262 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ample-receipts-verifier
|
|
3
|
+
Version: 0.2.0rc3
|
|
4
|
+
Summary: Ample receipts verifier: checks receipt bundles offline with the Python standard library alone.
|
|
5
|
+
Project-URL: Homepage, https://ample.isrm.ai/receipts
|
|
6
|
+
Author: ISRM Labs AB
|
|
7
|
+
Maintainer: ISRM Labs AB
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ample,audit,ed25519,offline,receipts,transparency-log,verifier
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Security :: Cryptography
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Provides-Extra: export
|
|
21
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == 'export'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# ample-receipts-verifier
|
|
25
|
+
|
|
26
|
+
The verifier of Ample receipts as one wheel: the `ample_replay` package without its arbiter
|
|
27
|
+
(`ample_replay/arbiter/`) or its artifacts (`ample_replay/artifacts/`). It checks a bundle offline, on your own
|
|
28
|
+
machine, with the Python standard library alone: Python 3.12 and no dependencies (one optional extra, `export`,
|
|
29
|
+
adds a database driver for exporting a bundle yourself). It is Apache-2.0, by ISRM Labs
|
|
30
|
+
AB, so an auditor can read and run the code that judged a receipt. Ample receipts are described at
|
|
31
|
+
https://ample.isrm.ai/receipts.
|
|
32
|
+
|
|
33
|
+
The import package keeps its name, so the commands are the ones the specifications give:
|
|
34
|
+
`python -m ample_replay.verify`.
|
|
35
|
+
|
|
36
|
+
## What it verifies
|
|
37
|
+
|
|
38
|
+
`python -m ample_replay.verify bundle DIR` checks one bundle directory, the bundle layout of receipts v3
|
|
39
|
+
section 8:
|
|
40
|
+
|
|
41
|
+
- the hash chain and the ledger's signatures, under the public key set you give with `--keys`, taken out of band.
|
|
42
|
+
The bundle's own `keys.json` is not a trust anchor; `--trust-bundle-keys` uses it instead, and the report says so;
|
|
43
|
+
- for a tenant ledger of call receipts (the call-receipt specification, section 12): each call receipt's statement,
|
|
44
|
+
the customer's client signature under the client key file you give with `--client-keys`, the client-key
|
|
45
|
+
introductions and rotations on the ledger, each instance's sequence and its declared losses, and the level each
|
|
46
|
+
call receipt reached, from C1 to C4;
|
|
47
|
+
- with `--check-anchors --tsa-cert FILE`: each `ANCHOR_PUBLISHED` notice, its checkpoint and its time-stamp token,
|
|
48
|
+
under the certificates you pin (needed for C3);
|
|
49
|
+
- with `--bucket-listing DIR`: the version listing of the write-once bucket that you took with your own read access
|
|
50
|
+
(the auditor's guide says how; needed for C4);
|
|
51
|
+
- with `--check-anchors --genesis-pin FILE`: that the bundle holds the first checkpoint a time-stamp authority
|
|
52
|
+
stamped, and its token, as you pinned them from the ledger's first export (the call-receipt specification,
|
|
53
|
+
section 15.1). It catches a ledger started again under the same key; it does not catch a fork after that
|
|
54
|
+
checkpoint;
|
|
55
|
+
- routing receipt bundles (receipts v3, and v4 and v5 with `--host-keys`), as their specifications describe.
|
|
56
|
+
|
|
57
|
+
`python -m ample_replay.verify reveal-call` checks one part of one call that the customer reveals to you (below).
|
|
58
|
+
`genesis-pin` writes that pin from the ledger's first export, only when the export is intact:
|
|
59
|
+
`python -m ample_replay.verify genesis-pin DIR --keys FILE --tsa-cert FILE --out FILE`.
|
|
60
|
+
`python -m ample_replay.verify --help` lists the other
|
|
61
|
+
commands this wheel carries: `reveal`, `weights`, `fingerprint` and `reveal-trace`.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
Install it in a virtual environment of its own:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
python3 -m venv verifier-venv
|
|
69
|
+
verifier-venv/bin/pip install ample-receipts-verifier
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This version is a release candidate, not a stable release; a stable release follows. Pin the exact version you
|
|
73
|
+
install (`ample-receipts-verifier==` and the version this page names).
|
|
74
|
+
|
|
75
|
+
It needs nothing else to verify. To export bundles yourself from the ledger database (below), install it with the
|
|
76
|
+
`export` extra, which adds the PostgreSQL driver psycopg:
|
|
77
|
+
`verifier-venv/bin/pip install 'ample-receipts-verifier[export]'`. An auditor who installs with no network takes the wheel
|
|
78
|
+
(`ample_receipts_verifier-<version>-py3-none-any.whl`) and its SHA-256 from Ample by a channel of their own, checks
|
|
79
|
+
the sum (`shasum -a 256`), and installs that file with `verifier-venv/bin/pip install --no-index` and the wheel's
|
|
80
|
+
path.
|
|
81
|
+
|
|
82
|
+
The project is published as a wheel only, with no source distribution: the wheel is built from files across Ample's
|
|
83
|
+
repository, which a source distribution of this project cannot carry. The wheel is pure Python and holds every
|
|
84
|
+
source file it runs, so an auditor can read exactly what judged a receipt (`unzip -l` lists it). Its import package,
|
|
85
|
+
`ample_replay`, is also part of Ample's full distribution: two packages that ship the same files overwrite each
|
|
86
|
+
other in one environment, which is another reason to keep the verifier in a venv of its own.
|
|
87
|
+
|
|
88
|
+
## Run it on a call bundle
|
|
89
|
+
|
|
90
|
+
Take every input yourself, through channels the receipts service's operator does not control: the bundle of the
|
|
91
|
+
customer's tenant ledger, the operator's ledger public key set, the client public key file from the customer and,
|
|
92
|
+
for C4, the bucket listing. The operator is whoever runs the receipts service and holds its ledger key: a provider
|
|
93
|
+
the customer chose, or the customer itself when it hosts the service.
|
|
94
|
+
The auditor's guide (`auditor.md`, which Ample gives you with each release) says where each one comes from.
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
verifier-venv/bin/python -I -m ample_replay.verify bundle BUNDLE_DIR \
|
|
98
|
+
--keys ledger-keys.json --client-keys client-keys.json --bucket-listing listing/
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`-I` keeps the current directory, `PYTHONPATH` and the user site out of the import path, so the code that runs is
|
|
102
|
+
the installed wheel's.
|
|
103
|
+
|
|
104
|
+
On the vector ledger of the call-receipt specification (`ledger-v1.json`, written out as a bundle), with `--keys`
|
|
105
|
+
and `--client-keys` and no other input, the report ends:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
seq 3 C2 75cd218915288826f7b303b185ba8848e5c7b41e2e65968184b71575fcc7150f
|
|
109
|
+
seq 4 C2 98a83e26816337f3a40c732ba804a9b9bf917a8dd07e280ca6ac78d77306649c
|
|
110
|
+
seq 13 C2 1962ce328b3d1f9629d951ba2fae4f764cc44ae27b5724ba7d5be8c6f48ce822
|
|
111
|
+
declared loss: instance e54387b2-3bcc-473f-841f-e0d79acc48b0 seq 8-8 (NOT_SPOOLED)
|
|
112
|
+
C2 Chained: the receipts service received these exact statement bytes and chained them, and a change to them shows unless the ledger key's holder signs the chain again. The time and the order are the word of the ledger key's holder unless an anchor backs them, or a held ack that someone else kept.
|
|
113
|
+
verdict: INTACT; call receipts by level: C4 0, C3 0, C2 10, C1 0, NONE 0
|
|
114
|
+
Tamper-evident, not tamper-proof.
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
(The lines for seqs 5 to 11 are left out here.) Each call receipt gets one line: its ledger seq, its level token
|
|
118
|
+
and its `statement_sha256`. The report prints the sentence of each level a receipt reached, names each input it was
|
|
119
|
+
not given and the levels it therefore could not reach (here C3 and C4), and never prints a bare pass. The exit code
|
|
120
|
+
is 0 with `INTACT`, 1 with `FINDINGS` and 2 for an unreadable input or a usage error. A one-byte change to the
|
|
121
|
+
bundle, in its chain, its signatures or a receipt, is a finding and exit 1. Without `--client-keys`, every call
|
|
122
|
+
receipt is at `NONE`, since C1 needs the customer's key file. On this bundle that run reports `FINDINGS` and exits
|
|
123
|
+
1: the customer's declared loss at seq 8 counts only once its own statement reaches C1 (section 12, MUST-115), so
|
|
124
|
+
without the key file the hole shows as `CALL_GAP_UNEXPLAINED`.
|
|
125
|
+
|
|
126
|
+
The levels, in short (section 12.4 of the specification has the rules, and 12.5 the sentences the report prints):
|
|
127
|
+
|
|
128
|
+
- **C1 Signed**: the holder of the customer's client key signed the record. It is the customer's own account of
|
|
129
|
+
the call.
|
|
130
|
+
- **C2 Chained**: the receipts service received these exact statement bytes and chained them. A change shows
|
|
131
|
+
unless the ledger key's holder signs the chain again, and the time and the order are the word of the ledger key's
|
|
132
|
+
holder unless an anchor backs them, or a held ack that someone else kept.
|
|
133
|
+
- **C3 Time-stamped**: the record existed by a time-stamp authority's time. That clock is independent of the ledger
|
|
134
|
+
key's holder only if the authority you pinned is, so take its certificate from the authority's own publication.
|
|
135
|
+
The certificate is judged by its pin only: its validity dates and revocation are not checked.
|
|
136
|
+
- **C4 Anchored in write-once storage**: a later rewrite by the ledger key's holder alone shows in the bucket
|
|
137
|
+
listing you took, if someone else owns the bucket (you or a third party: independent storage). It does not hold
|
|
138
|
+
against the ledger key's holder and the bucket's owner together, or against the ledger key's holder alone when it
|
|
139
|
+
owns the bucket: label such a bucket as its own storage, "customer-owned storage" when the customer runs the
|
|
140
|
+
service. The listing does not show who owns the bucket, so the report prints the same C4 sentence for both, and
|
|
141
|
+
the label is yours to give from the bucket's declaration (MUST-B6 of the bucket specification).
|
|
142
|
+
|
|
143
|
+
## Check one part of a call: reveal-call
|
|
144
|
+
|
|
145
|
+
A reveal is four things the customer hands you: the call receipt's canonical payload exactly as stored (its F1
|
|
146
|
+
text, with no final line feed), the part's name, its data and its salt (section 5.8, MUST-62). The customer's client
|
|
147
|
+
library writes them as three files with `python -m ample_receipts_client.reveal`, which derives the salt again
|
|
148
|
+
from the customer's salt key and reads the part from the customer's vault. You need no salt key, no other part and
|
|
149
|
+
no contact with the receipts service or its operator (MUST-63):
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
verifier-venv/bin/python -I -m ample_replay.verify reveal-call --receipt receipt.txt \
|
|
153
|
+
--part response_body --data-file response_body.bin --salt-file response_body.salt
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
On the vectors' first reveal (`reveals` in the specification's `statements-v1.json`, on the receipt of S1 in
|
|
157
|
+
`ledger-v1.json`), it prints:
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
MATCH
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
and exits 0. Any other answer is one line, `MISMATCH: <reason>`, and exit 1 (MUST-126): `UNKNOWN_PART`,
|
|
164
|
+
`PART_NOT_COMMITTED`, `ROOT_DIFFERS`, `COMMITMENT_DIFFERS` (a wrong salt, wrong bytes or the wrong part), or
|
|
165
|
+
`CALL_RECEIPT_MALFORMED` for a receipt that section 12.2 cannot read, decided before the data or the salt is read.
|
|
166
|
+
Exit 2 is a usage error or an input that cannot be read: an option missing, unknown or given twice, a receipt that
|
|
167
|
+
is not F1 text, a salt file that does not hold exactly 64 lower-case hex characters (one final line feed allowed),
|
|
168
|
+
or the data of a JSON part that is not exactly its JCS bytes. The salt is read from `--salt-file` only, never from
|
|
169
|
+
the command line, and neither the salt nor the data is ever printed. A `MATCH` shows that these bytes are what the
|
|
170
|
+
customer committed to, as far as the receipt's level fixes the time; it shows nothing about any other copy of
|
|
171
|
+
them (section 13).
|
|
172
|
+
|
|
173
|
+
## The customer's held acks: --held-acks
|
|
174
|
+
|
|
175
|
+
`--held-acks FILE` gives the bundle command the acks the customer holds: a UTF-8 file, one ack's JCS text per line,
|
|
176
|
+
each line ended by a line feed, as the client library's `python -m ample_receipts_client.held_acks` writes it
|
|
177
|
+
(MUST-125). Each ack is first checked by itself (its JCS text, its cap, its payload hash, its row, its chain hash and
|
|
178
|
+
its signature under the `--keys` set), and an ack that fails is `HELD_ACK_INVALID`: at its seq when it has one, with
|
|
179
|
+
no seq when the line is not JCS text or is empty. Each other ack is compared with the bundle's ledger line at its
|
|
180
|
+
seq, its receipt line and its signature line: `HELD_ACK_MISSING` when the link or the row is gone,
|
|
181
|
+
`HELD_ACK_DIFFERS` when they differ (MUST-109). A call receipt a held ack backs is marked `ACK_HELD` on its line;
|
|
182
|
+
held-ack findings change no level (MUST-121). A held-acks file that cannot be read or is not UTF-8 is exit 2.
|
|
183
|
+
|
|
184
|
+
## Export a bundle yourself: export
|
|
185
|
+
|
|
186
|
+
When the customer hosts the receipts service, it can give you a read-only role on its ledger database, and you
|
|
187
|
+
write the bundle yourself, on your own machine, instead of taking one the customer exported. With the `export`
|
|
188
|
+
extra installed (above), put the connection string in `AMPLE_RECEIPTS_DATABASE_URL`, or use libpq's own
|
|
189
|
+
environment (`PGHOST`, `PGUSER`, `PGDATABASE`, `PGPASSFILE`, `PGSSLMODE` and the rest), never the command line:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
verifier-venv/bin/python -I -m ample_replay.verify export --out bundle --issuer ISSUER --keys ledger-keys.json
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
It reads the three ledger tables (`ledger_events`, `receipts`, `ledger_signatures`) in one read-only
|
|
196
|
+
`REPEATABLE READ` snapshot, so it can write nothing to the database and needs only `SELECT` on those tables, which
|
|
197
|
+
the service's read-only role holds. The bundle is the one the service's own export writes from the same snapshot.
|
|
198
|
+
|
|
199
|
+
- `--out DIR` must not exist: every file is written once, and the manifest last.
|
|
200
|
+
- `--issuer NAME` is the name the bundle's manifest gives: the issuer the customer's service runs as.
|
|
201
|
+
- `--keys FILE` is the ledger public key set you were handed, written as the bundle's `keys.json`. Without it,
|
|
202
|
+
`keys.json` holds the keys the ledger's own notices bring in. Either way you verify with the set you were handed.
|
|
203
|
+
- `--anchor-dir DIR` copies the checkpoints of the write-once directory, when you can read it, into `anchors/`.
|
|
204
|
+
The signer certificates of the time-stamp tokens go into `tsa/` whatever the flags. Both are copies only: you
|
|
205
|
+
still pin the TSA certificate with `--tsa-cert`.
|
|
206
|
+
- `--role ROLE` sets the session's role when it connects, for a login that does not inherit the read-only role.
|
|
207
|
+
|
|
208
|
+
It prints a summary of what it wrote (exit 0); it refuses with exit 1 and leaves no directory, and exit 2 is a
|
|
209
|
+
usage error. A database failure prints its exception type only, never the driver's text, which can quote the
|
|
210
|
+
connection string. A ledger with a receipt whose model weights were observed by Ample or attested by a host is
|
|
211
|
+
refused: its bundle needs a manifest or a signed statement that this command does not take. Then verify the bundle
|
|
212
|
+
with `bundle` or the auditor's script.
|
|
213
|
+
|
|
214
|
+
## The auditor's script
|
|
215
|
+
|
|
216
|
+
`python -m ample_replay.verify.audit` runs the auditor's path in one command: the bundle command with `--keys`,
|
|
217
|
+
`--client-keys` and `--held-acks` (with `--check-anchors --tsa-cert` and `--bucket-listing` when given), then one
|
|
218
|
+
`reveal-call`, then the revealed receipt's level in the bundle. It prints each step with its output, the count of
|
|
219
|
+
call receipts at each level and `ACK_HELD`, and `ALL PASS` or the steps that failed (exit 0, 1, or 2 for an input
|
|
220
|
+
that cannot be read):
|
|
221
|
+
|
|
222
|
+
python -m ample_replay.verify.audit --bundle DIR --keys ledger-keys.json \
|
|
223
|
+
--client-keys client-keys.json --held-acks held-acks.jsonl \
|
|
224
|
+
--reveal-receipt DIR2/receipt.txt --reveal-part request_body \
|
|
225
|
+
--reveal-data-file DIR2/request_body.bin --reveal-salt-file DIR2/request_body.salt
|
|
226
|
+
|
|
227
|
+
## What it cannot do
|
|
228
|
+
|
|
229
|
+
- **`--replay` needs Ample's full distribution.** Replaying a routing receipt re-decides it with the arbiter,
|
|
230
|
+
which this wheel leaves out, with the artifacts and the receipt reader. Here `bundle --replay` refuses, exit 2,
|
|
231
|
+
and says so: the full distribution, which carries all of `ample_replay`, is on no package index, so ask Ample for
|
|
232
|
+
it. Every other bundle check runs here. A call receipt is never replayed, in either distribution.
|
|
233
|
+
- **The re-run needs the full distribution and the model-proof environment.** Re-running a call
|
|
234
|
+
(`python -m ample_replay.rerun`, receipts v5 section 3.2) loads the model with torch, transformers and toploc,
|
|
235
|
+
which this wheel does not carry, so it leaves out `ample_replay/rerun/check.py` and the command. It does carry the
|
|
236
|
+
re-run policy and the reader of the host's signed call record, which `weights --call-record` uses.
|
|
237
|
+
- **It fetches nothing.** It makes no network call, and takes no key from the receipts service, from the bundle or
|
|
238
|
+
from the ledger as a trust anchor for C1: the client keys come only from the file you give.
|
|
239
|
+
- **C3 needs a real time-stamp token** and the authority's certificate, given with `--check-anchors --tsa-cert`.
|
|
240
|
+
C4 needs C3 as well as the listing.
|
|
241
|
+
- **A level is not a proof of the call.** What a call receipt does not show at any level (that the upstream sent
|
|
242
|
+
those bytes, completeness, which weights ran, that the answer is true, and the rest) is listed in section 13 of
|
|
243
|
+
the specification and explained in `proves.md`, which Ample gives you with each release.
|
|
244
|
+
|
|
245
|
+
## How this wheel is tested
|
|
246
|
+
|
|
247
|
+
Ample's test suite builds this wheel offline from the committed tree, installs it with `--no-deps` into a
|
|
248
|
+
throwaway virtual environment that holds nothing else of Ample's, and runs the commands above on the vector bundle:
|
|
249
|
+
`INTACT` with the levels printed, a finding and exit 1 for a one-byte change, and an import probe after a full run
|
|
250
|
+
that finds no module of Ample's routing code, `ample_replay.arbiter` or `ample_replay.artifacts` loaded. It also
|
|
251
|
+
runs `reveal-call` on each of the vectors' seven reveals and on the example above. For `export`, it installs the
|
|
252
|
+
wheel and the extra's driver offline into a throwaway virtual environment, exports a hosted test ledger as a login
|
|
253
|
+
that holds only the read-only role, and requires the bundle to be the service's own export byte for byte and
|
|
254
|
+
`INTACT`, with no module of Ample's service loaded. The release build makes the
|
|
255
|
+
published wheel from a fresh clone of the release commit, with hatchling pinned by hash, and installs it with no
|
|
256
|
+
index and no dependencies before anything is uploaded.
|
|
257
|
+
|
|
258
|
+
Tamper-evident, not tamper-proof.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
ample_replay/__init__.py,sha256=tNGe9qaFUPCtUio9JXyiiDDgIea_3Y0h-NwSTZQZbZs,1010
|
|
2
|
+
ample_replay/canonical/__init__.py,sha256=P4HMnWDJAONye31yp0TodRErikRAkjZ3aFH8zD2E1cc,2150
|
|
3
|
+
ample_replay/canonical/decoder.py,sha256=d3HazZylWSA7psLRj2mfxtaJckLkHVHfGDaaWoDj6RE,10972
|
|
4
|
+
ample_replay/canonical/digest.py,sha256=Sbk33m0_-EQLZIHR3RlPmp9TzGPLHTxXwuQh2n5XAhY,1337
|
|
5
|
+
ample_replay/canonical/encoder.py,sha256=89rzzwDhvjnFdqC2TMIHVtw2fOZVoTj5fu7myt-GWTU,13979
|
|
6
|
+
ample_replay/canonical/errors.py,sha256=bYdylnJ_gDVRojc13XgcptpQ9cL4jBqJDBKFXpt54_Q,3281
|
|
7
|
+
ample_replay/canonical/scale.py,sha256=VKkkpNhWjV2Egxp4HXsRw-0sY1xkIyXAo78h3dIUgY0,4903
|
|
8
|
+
ample_replay/canonical/values.py,sha256=o7X72qV36T32VDdf5CUhE88ho_umZRv2Ik7FFRX6YEo,13907
|
|
9
|
+
ample_replay/verify/__init__.py,sha256=ObDxm70n1ZXDFd8UYv3Via8wgLS2dFprjg8-GDvnWtw,4763
|
|
10
|
+
ample_replay/verify/__main__.py,sha256=G0zey033MFrI2Xm1KEb4jFzvj0gGyDOk3_VM6DW6D74,60948
|
|
11
|
+
ample_replay/verify/anchors.py,sha256=Cb8p5tQgCyYTKFUv11QdO3BWVr4u4DMSGNzikUY-oMA,41674
|
|
12
|
+
ample_replay/verify/audit.py,sha256=nwX4tQZ9VWwyfk4cg96Ub6iOLKR1WkMYEA-lCNUkVMg,9925
|
|
13
|
+
ample_replay/verify/bucket.py,sha256=Ti5StNKjoFUqac7JpID2g_66yFO1o72u2J3aH2ZNkg0,20558
|
|
14
|
+
ample_replay/verify/bundle.py,sha256=NiL6DxrjvtFNoOTW_d6rsUhUHqpM-pp7KFrgsXEjJJU,84606
|
|
15
|
+
ample_replay/verify/call_ids.py,sha256=yG7Njx-3hqo9uHuE0eqlORmy2OqY1YB81-EiRX-Rnx0,2601
|
|
16
|
+
ample_replay/verify/call_ledger.py,sha256=zkBrCxGrXfvOccypH5SoXbJMLcf_3ewqYPvn5e-PsIY,35107
|
|
17
|
+
ample_replay/verify/call_receipt.py,sha256=lJ8-D9WpiLVP1iRjONo3oIhLTfdRTxbQDH42_r86YKI,25602
|
|
18
|
+
ample_replay/verify/chain.py,sha256=A3KcGhc_DoYE6Wew9O0h-i9bkZitrgpRCSIP00doEgQ,16739
|
|
19
|
+
ample_replay/verify/commitments.py,sha256=fwLihHzciCxskh1lraHlYKtdzdptZDwhl3bTRidGSbo,12498
|
|
20
|
+
ample_replay/verify/der.py,sha256=yNWF5QrRlwKQN5nl60W2_oT7WV-2jbxHNRFiKKODhp0,10596
|
|
21
|
+
ample_replay/verify/ecdsa_p256.py,sha256=RQzj06PXoavVixfzULZfVzNJ-kVB4LoD6YhEhOYBp0k,4865
|
|
22
|
+
ample_replay/verify/ed25519.py,sha256=pjaLzUdX6F7orLhCQ7m6QD5-OKn6QVHxD-jaCYgqQec,9974
|
|
23
|
+
ample_replay/verify/export.py,sha256=so5fs99BOKckiamVudesAViALAIpBHSk5jdu1j7N3X0,27509
|
|
24
|
+
ample_replay/verify/genesis.py,sha256=Rii_h_Vg00pr1esjxel0s2d605-T8LdU02g52iSQJ6E,19688
|
|
25
|
+
ample_replay/verify/held_acks.py,sha256=_n02EZsj_JanKJwdkaJ43_xfs_nHqP9_yw3WiAZcHFs,16948
|
|
26
|
+
ample_replay/verify/jcs.py,sha256=7aUyqZT1a14Bd2h3HGGP5TI5EAAHjFwKWNDrxQz9qwA,3847
|
|
27
|
+
ample_replay/verify/pairs.py,sha256=klw9pUF-duvrg3OLM6IboelEij8_NJOnHppviLiZas4,1980
|
|
28
|
+
ample_replay/verify/payload.py,sha256=Kfy1ZQWSpPL7e6H16YY2CQ9KULyv__h08ivOtRjpF6o,9648
|
|
29
|
+
ample_replay/verify/prior_envelope.py,sha256=Hb_UhKT9Yvhj6bkoO6jqukY3v1D_e-ZZ3dwy7dF0gzw,6407
|
|
30
|
+
ample_replay/verify/proof_inputs.py,sha256=-_wuDPqh-YLdkaAkws7kB93EUNJkBTb8HhgBPUdNtx4,31727
|
|
31
|
+
ample_replay/verify/receipt.py,sha256=E8ZLG_pgtEOXc7Rw2g50tydT5ROD5fAB2pQ5QP4CDk4,13181
|
|
32
|
+
ample_replay/verify/registry.py,sha256=sKklYrOooLbSJ5HT3iH9HTeYJWHp2U0GG_U0Xw-EKd0,9075
|
|
33
|
+
ample_replay/verify/result.py,sha256=VnljNl59COJOBN5vJ0ShoN8SAzerl9VrEhVylXdiYSQ,2797
|
|
34
|
+
ample_replay/verify/reveal_call.py,sha256=ExtpMpVunoONi6i3nQrOiVAFHP5xegs-2int_lLmbMc,8895
|
|
35
|
+
ample_replay/verify/rsa.py,sha256=H7gVdPQ0WX6G06yOuD_oPiE5L2L69HSus7-meKzRmhA,3082
|
|
36
|
+
ample_replay/verify/signatures.py,sha256=v5HC3r-9YW9I7d593rLxLnRuBCY5biL1Lb8bf3rCeRQ,42148
|
|
37
|
+
ample_replay/verify/timestamp.py,sha256=OoiHuqDNEhMMBXkRk8jmEXAvlmU51vMgctcNMmMxYlc,28182
|
|
38
|
+
ample_replay/verify/traces.py,sha256=iBbrnfJaFgpumqzNsN7mNZ_OtH0m7J_OeWRo0oAcOWw,9787
|
|
39
|
+
ample_replay/verify/weights.py,sha256=U1jWirFeCOkbcwWGCByvpTb-EInX9YrZPz8Fmb25-SU,34494
|
|
40
|
+
ample_replay/verify/x509.py,sha256=SrWHglo0sbYBvUokjqV3UDUa-Sv24P5377RqSvM-yjU,11086
|
|
41
|
+
ample_replay/receipts/__init__.py,sha256=U1V9Pt-IM-mvjgBMzfmxoAxGcrxgv_g-6v0mtgSzHEg,4416
|
|
42
|
+
ample_replay/receipts/receipt_call.py,sha256=XGrr7nK3PyQM0LDpaMqpO-rCiQnj-11Zedxx_IufHQQ,1608
|
|
43
|
+
ample_replay/receipts/receipt_v3.py,sha256=3VBCtmxkawPCdjMxeuGaIFygrcmIONV0maTXK2Qta_s,18429
|
|
44
|
+
ample_replay/receipts/receipt_v4.py,sha256=kEpL-JuTGLHE7nMy3m31RpEUaVVMOf3v-z0BdAfLzQM,15812
|
|
45
|
+
ample_replay/receipts/receipt_v5.py,sha256=pZIu2t_GDFfrrru9yceT8-AC7vcES_ipWRoDGjyeXXI,10718
|
|
46
|
+
ample_replay/receipts/schema.py,sha256=gnrU0ziLulUxmEOd2WJ6FwacKPB6p3DYGOgYFNssw-E,29393
|
|
47
|
+
ample_replay/rerun/__init__.py,sha256=0hWiuPRjKPNQLt8P4Y91oPT0mcp4g-7fQwQXafHIETE,1512
|
|
48
|
+
ample_replay/rerun/policy.py,sha256=kRtX1eIDPU2csw1-cE0TgBG8gihpnJiPR-6HxaIfers,9749
|
|
49
|
+
ample_replay/rerun/record.py,sha256=44E60YgToJjrehCRw2exhMT9Gj8-GqSF8mf-wLxoENA,13018
|
|
50
|
+
ample_replay/rerun/sglang_backend.py,sha256=651GZviDIjgcA7pR0bGhmy0MRGmZlATOcHCPF00cn3s,20315
|
|
51
|
+
ample_replay/rerun/strict.py,sha256=b3zLfMYGhs-jFqn0c-0bVHrw5melfTrl9altwXewnhc,3954
|
|
52
|
+
ample_replay/rerun/token_choice.py,sha256=s5g9a-NlngujKNMkagwYnCUPE-HTdtEdnk2GNgzgE9c,13752
|
|
53
|
+
ample_receipts_verifier-0.2.0rc3.dist-info/METADATA,sha256=r69t63MObodolnGSTNu1hpa6d4Otk8XNKaD9vQXcBbU,17620
|
|
54
|
+
ample_receipts_verifier-0.2.0rc3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
55
|
+
ample_receipts_verifier-0.2.0rc3.dist-info/licenses/LICENSE,sha256=_ewN0n2bJBu4HRkL2RuqxPRoBBLBSD1I_Wr3IXfYG1s,11343
|
|
56
|
+
ample_receipts_verifier-0.2.0rc3.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 ISRM Labs AB
|
|
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.
|
ample_replay/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Independent replay verifier (F4). A separate package by design.
|
|
2
|
+
|
|
3
|
+
Handoff §5.6: this package MUST NOT import from ``ample`` — not the domain
|
|
4
|
+
models, not the canonicaliser, not the arbiter, not a single helper. Its
|
|
5
|
+
duplicate arbiter logic is intentional. A differential test asserts the two
|
|
6
|
+
implementations agree on 1,000 receipts (§13); sharing code with the emitter
|
|
7
|
+
would make that test prove nothing.
|
|
8
|
+
|
|
9
|
+
§1.3: "An independent verifier — a separate codebase with no shared imports —
|
|
10
|
+
can take that receipt and recompute the routing decision from stored inputs."
|
|
11
|
+
|
|
12
|
+
The isolation is a correctness property of the product claim, not a style
|
|
13
|
+
preference, and it is enforced automatically: ``ops/checks/check_replay_isolation.py``
|
|
14
|
+
parses every module here and fails CI, ``make lint`` and pre-commit on any import
|
|
15
|
+
of ``ample`` — including ``importlib.import_module("ample.x")``. The checker is
|
|
16
|
+
owned by the repository rather than by F4, because a package that audits its own
|
|
17
|
+
isolation is self-policing.
|
|
18
|
+
"""
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""``ample-canon-v1``, reimplemented from the normative document (Handoff §12).
|
|
2
|
+
|
|
3
|
+
This is the *second* implementation the Handoff permits and constrains: "one
|
|
4
|
+
implementation; any second must pass a differential fuzz suite against the
|
|
5
|
+
first" (§12). It is built from ``docs/canonicalization-v1.md`` — its grammar,
|
|
6
|
+
ordering rule, number encoding, absence encoding, normalisation, rejection set,
|
|
7
|
+
version marker and 21 worked examples — and from nothing else. The reference
|
|
8
|
+
source under ``ample/evidence/canonical/`` was deliberately not read, and this
|
|
9
|
+
package may not import it (§5.6).
|
|
10
|
+
|
|
11
|
+
Entry points:
|
|
12
|
+
|
|
13
|
+
* ``canonicalise(payload, scales) -> bytes`` — the document.
|
|
14
|
+
* ``canonical_text(payload, scales) -> str`` — the same, as text.
|
|
15
|
+
* ``payload_hash(payload, scales) -> str`` — lowercase-hex SHA-256 (§6).
|
|
16
|
+
* ``rehash_stored(text) -> str`` — re-hash a stored payload *as stored*.
|
|
17
|
+
* ``decode(document) -> Node`` / ``reencode(node) -> bytes`` — a decoder written
|
|
18
|
+
from the grammar, which is how §3.3's injectivity argument is tested.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from ample_replay.canonical.decoder import (
|
|
24
|
+
DecodedDecimal,
|
|
25
|
+
DecodeError,
|
|
26
|
+
Node,
|
|
27
|
+
decode,
|
|
28
|
+
reencode,
|
|
29
|
+
)
|
|
30
|
+
from ample_replay.canonical.digest import digest_bytes, payload_hash, rehash_stored
|
|
31
|
+
from ample_replay.canonical.encoder import (
|
|
32
|
+
FORM_ID,
|
|
33
|
+
MAX_DEPTH,
|
|
34
|
+
VERSION_MARKER,
|
|
35
|
+
canonical_text,
|
|
36
|
+
canonicalise,
|
|
37
|
+
unicode_version,
|
|
38
|
+
)
|
|
39
|
+
from ample_replay.canonical.errors import (
|
|
40
|
+
TAXONOMY_CODE,
|
|
41
|
+
CanonReason,
|
|
42
|
+
CanonReject,
|
|
43
|
+
render_path,
|
|
44
|
+
)
|
|
45
|
+
from ample_replay.canonical.scale import PARTIAL_SPEC_SCALES, ScaleDeclaration
|
|
46
|
+
from ample_replay.canonical.values import ABSENT, Absent, Scaled
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"ABSENT",
|
|
50
|
+
"FORM_ID",
|
|
51
|
+
"MAX_DEPTH",
|
|
52
|
+
"PARTIAL_SPEC_SCALES",
|
|
53
|
+
"TAXONOMY_CODE",
|
|
54
|
+
"VERSION_MARKER",
|
|
55
|
+
"Absent",
|
|
56
|
+
"CanonReason",
|
|
57
|
+
"CanonReject",
|
|
58
|
+
"DecodeError",
|
|
59
|
+
"DecodedDecimal",
|
|
60
|
+
"Node",
|
|
61
|
+
"ScaleDeclaration",
|
|
62
|
+
"Scaled",
|
|
63
|
+
"canonical_text",
|
|
64
|
+
"canonicalise",
|
|
65
|
+
"decode",
|
|
66
|
+
"digest_bytes",
|
|
67
|
+
"payload_hash",
|
|
68
|
+
"reencode",
|
|
69
|
+
"rehash_stored",
|
|
70
|
+
"render_path",
|
|
71
|
+
"unicode_version",
|
|
72
|
+
]
|