algovoi-substrate 0.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.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: algovoi-substrate
3
+ Version: 0.1.0
4
+ Summary: AlgoVoi agentic-payments substrate -- JCS canonicalisation, action_ref, composite trust-query, compliance receipts, audit chain
5
+ Author-email: AlgoVoi <chopmob@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://api.algovoi.co.uk
8
+ Project-URL: Documentation, https://docs.algovoi.co.uk/canonicalisation-substrate
9
+ Project-URL: Repository, https://github.com/chopmob-cloud/algovoi-substrate
10
+ Project-URL: Issues, https://github.com/chopmob-cloud/algovoi-substrate/issues
11
+ Keywords: x402,ap2,a2a,mpp,jcs,rfc8785,canonicalisation,agentic-payments,compliance,audit-chain,trust-query
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Security :: Cryptography
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: rfc8785>=0.1.4
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=7; extra == "test"
30
+ Requires-Dist: pytest-cov>=4; extra == "test"
31
+ Dynamic: license-file
32
+
33
+ # algovoi-substrate (Python)
34
+
35
+ AlgoVoi agentic-payments substrate reference implementation.
36
+
37
+ JCS RFC 8785 canonicalisation, `action_ref` atomic primitive, composite
38
+ trust-query algorithm, compliance receipt shape, and audit chain primitives
39
+ that compose the substrate underneath x402, AP2, A2A, and MPP receipts.
40
+
41
+ The substrate runs in production at `https://api.algovoi.co.uk/compliance`.
42
+ This package is the AlgoVoi-authored reference implementation; cross-validated
43
+ byte-for-byte against four other JCS implementations (JavaScript `canonicalize`,
44
+ Go `gowebpki/jcs`, Java `cyberphone`, Rust `serde_jcs`) on 53 conformance
45
+ vectors and 3 composite-trust-query vectors.
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install algovoi-substrate
51
+ ```
52
+
53
+ ## Quickstart
54
+
55
+ ```python
56
+ from algovoi_substrate import (
57
+ canonicalize,
58
+ sha256_jcs,
59
+ action_ref,
60
+ composite_trust_query_hash,
61
+ build_compliance_receipt,
62
+ append_to_chain,
63
+ verify_audit_chain,
64
+ )
65
+
66
+ # Canonicalise an object to RFC 8785 JCS bytes.
67
+ canonicalize({"b": 1, "a": 2}) # -> '{"a":2,"b":1}'
68
+
69
+ # The action_ref atomic primitive:
70
+ # SHA-256(JCS({agent_id, action_type, scope, timestamp_ms}))
71
+ ref = action_ref(
72
+ agent_id="agent-x",
73
+ action_type="payment",
74
+ scope="bilateral",
75
+ timestamp_ms=1716460800000,
76
+ )
77
+
78
+ # Composite trust-query (PR #2440 in x402-foundation/x402).
79
+ # Aggregates multi-source attestations into a single canonical hash.
80
+ rows = [
81
+ {"source_id": "trust-a", "score": 80, "sig": "sig-bytes"},
82
+ {"source_id": "trust-b", "score": 75, "sig": "sig-bytes"},
83
+ ]
84
+ composite_hash = composite_trust_query_hash(rows)
85
+
86
+ # Compliance receipt (AlgoVoi production schema).
87
+ receipt = build_compliance_receipt(
88
+ payer_ref="sha256:abc123",
89
+ screen_result="ALLOW",
90
+ screen_timestamp_ms=1716460800000,
91
+ screen_provider_did="did:web:api.algovoi.co.uk",
92
+ jurisdiction_flags=["UK", "EU"],
93
+ )
94
+
95
+ # Audit chain: monotonic per-row hash chain with content_hash + prev_hash.
96
+ row0 = append_to_chain(payload=dict(receipt), prev_row=None)
97
+ row1 = append_to_chain(payload={"event": "next"}, prev_row=row0)
98
+ verify_audit_chain([row0, row1])
99
+ ```
100
+
101
+ ## Substrate discipline
102
+
103
+ This package enforces the AlgoVoi-discipline rules formalised in PR #2436
104
+ (x402-foundation/x402, three-voice coalition co-signed):
105
+
106
+ - **Rule 1.** `timestamp_ms` is an epoch-millisecond integer. Floats, ISO 8601
107
+ strings, and negative values are rejected at the source-side.
108
+ - **Rule 4.** Type validation happens before canonicalisation. A field
109
+ declared integer that receives a float is a hard validation failure, not
110
+ a silent type-cast.
111
+ - **canon_version pin.** Receipts carry `canon_version: "jcs-rfc8785-v1"`
112
+ as an in-band format-version pin, so a year-five re-canonicalisation
113
+ knows which rule was active at emission without depending on an
114
+ out-of-band rule registry.
115
+ - **Array element order preserved.** `["UK","EU"]` and `["EU","UK"]` are
116
+ distinct canonical preimages per RFC 8785 §3.2.3 -- producer-side
117
+ ordering is load-bearing.
118
+
119
+ The categorical screen result (`ALLOW` / `REFER` / `DENY`) is enforced as a
120
+ closed set. Under UK POCA 2002 s.330 a `REFER` carries a mandatory SAR
121
+ obligation that `DENY` does not; collapsing this to a score / tier
122
+ projection would lose the property and break year-five auditability.
123
+
124
+ ## Cross-impl validation
125
+
126
+ The substrate has been byte-for-byte cross-validated across five
127
+ implementations on the AlgoVoi-authored vector sets:
128
+
129
+ - Python `rfc8785@0.1.4` (this package wraps it)
130
+ - JavaScript `canonicalize@3.0.0`
131
+ - Go `gowebpki/jcs v1.0.1`
132
+ - Java `cyberphone/json-canonicalization`
133
+ - Rust `serde_jcs@0.2.0`
134
+
135
+ Vector sets (Apache 2.0, AlgoVoi-authored):
136
+
137
+ - [AP2 OMH v0](https://gist.github.com/chopmob-cloud/1dca25fd6107db4b7a30bed5dbf2ded8) -- 10 vectors
138
+ - [CTEF + APS v1](https://gist.github.com/chopmob-cloud/5f35eaa527d292bf3ddc52f8725a85c9) -- 14 vectors
139
+ - [privacy_class v0.1](https://gist.github.com/chopmob-cloud/30bcbc717c86493f737feb92c415ba07) -- 10 vectors
140
+ - [per-chain envelope v0](https://gist.github.com/chopmob-cloud/e1bf4c9efde6f0e94b77c238cb33d78d) -- 19 vectors
141
+
142
+ Substrate matrix: <https://gist.github.com/chopmob-cloud/b327814c4e17ed9fc7b4f29c8bda523c>
143
+
144
+ Composite trust-query matrix:
145
+ <https://gist.github.com/chopmob-cloud/f2e9f0877b7d9fff70c8eca46e4ce636>
146
+
147
+ ## Tests
148
+
149
+ ```bash
150
+ pip install -e ".[test]"
151
+ pytest
152
+ ```
153
+
154
+ ## Production reference
155
+
156
+ The reference exhibit for this substrate is AlgoVoi's `/compliance/attestation`
157
+ audit chain, live at `https://api.algovoi.co.uk/compliance/attestation`.
158
+ Receipts retained under seven-year Object Lock COMPLIANCE retention (current
159
+ horizon 2033-05-04). The migration boundary (receipts before / after
160
+ 2026-05-21) is observable directly from the chain.
161
+
162
+ ## Spec references
163
+
164
+ - [PR #2436](https://github.com/x402-foundation/x402/pull/2436) -- canonicalisation discipline
165
+ - [PR #2440](https://github.com/x402-foundation/x402/pull/2440) -- composite trust-query
166
+ - [PR #2434](https://github.com/x402-foundation/x402/pull/2434) -- compliance-receipt-fixture
167
+ - [draft-vauban-x402-stark-receipts](https://datatracker.ietf.org/doc/draft-vauban-x402-stark-receipts/) -- IETF I-D normatively referencing the substrate
168
+
169
+ ## Licence
170
+
171
+ Apache 2.0. See `LICENSE`.
172
+
173
+ ## Author
174
+
175
+ AlgoVoi (Christopher Hopley, GitHub `chopmob-cloud`).
@@ -0,0 +1,143 @@
1
+ # algovoi-substrate (Python)
2
+
3
+ AlgoVoi agentic-payments substrate reference implementation.
4
+
5
+ JCS RFC 8785 canonicalisation, `action_ref` atomic primitive, composite
6
+ trust-query algorithm, compliance receipt shape, and audit chain primitives
7
+ that compose the substrate underneath x402, AP2, A2A, and MPP receipts.
8
+
9
+ The substrate runs in production at `https://api.algovoi.co.uk/compliance`.
10
+ This package is the AlgoVoi-authored reference implementation; cross-validated
11
+ byte-for-byte against four other JCS implementations (JavaScript `canonicalize`,
12
+ Go `gowebpki/jcs`, Java `cyberphone`, Rust `serde_jcs`) on 53 conformance
13
+ vectors and 3 composite-trust-query vectors.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install algovoi-substrate
19
+ ```
20
+
21
+ ## Quickstart
22
+
23
+ ```python
24
+ from algovoi_substrate import (
25
+ canonicalize,
26
+ sha256_jcs,
27
+ action_ref,
28
+ composite_trust_query_hash,
29
+ build_compliance_receipt,
30
+ append_to_chain,
31
+ verify_audit_chain,
32
+ )
33
+
34
+ # Canonicalise an object to RFC 8785 JCS bytes.
35
+ canonicalize({"b": 1, "a": 2}) # -> '{"a":2,"b":1}'
36
+
37
+ # The action_ref atomic primitive:
38
+ # SHA-256(JCS({agent_id, action_type, scope, timestamp_ms}))
39
+ ref = action_ref(
40
+ agent_id="agent-x",
41
+ action_type="payment",
42
+ scope="bilateral",
43
+ timestamp_ms=1716460800000,
44
+ )
45
+
46
+ # Composite trust-query (PR #2440 in x402-foundation/x402).
47
+ # Aggregates multi-source attestations into a single canonical hash.
48
+ rows = [
49
+ {"source_id": "trust-a", "score": 80, "sig": "sig-bytes"},
50
+ {"source_id": "trust-b", "score": 75, "sig": "sig-bytes"},
51
+ ]
52
+ composite_hash = composite_trust_query_hash(rows)
53
+
54
+ # Compliance receipt (AlgoVoi production schema).
55
+ receipt = build_compliance_receipt(
56
+ payer_ref="sha256:abc123",
57
+ screen_result="ALLOW",
58
+ screen_timestamp_ms=1716460800000,
59
+ screen_provider_did="did:web:api.algovoi.co.uk",
60
+ jurisdiction_flags=["UK", "EU"],
61
+ )
62
+
63
+ # Audit chain: monotonic per-row hash chain with content_hash + prev_hash.
64
+ row0 = append_to_chain(payload=dict(receipt), prev_row=None)
65
+ row1 = append_to_chain(payload={"event": "next"}, prev_row=row0)
66
+ verify_audit_chain([row0, row1])
67
+ ```
68
+
69
+ ## Substrate discipline
70
+
71
+ This package enforces the AlgoVoi-discipline rules formalised in PR #2436
72
+ (x402-foundation/x402, three-voice coalition co-signed):
73
+
74
+ - **Rule 1.** `timestamp_ms` is an epoch-millisecond integer. Floats, ISO 8601
75
+ strings, and negative values are rejected at the source-side.
76
+ - **Rule 4.** Type validation happens before canonicalisation. A field
77
+ declared integer that receives a float is a hard validation failure, not
78
+ a silent type-cast.
79
+ - **canon_version pin.** Receipts carry `canon_version: "jcs-rfc8785-v1"`
80
+ as an in-band format-version pin, so a year-five re-canonicalisation
81
+ knows which rule was active at emission without depending on an
82
+ out-of-band rule registry.
83
+ - **Array element order preserved.** `["UK","EU"]` and `["EU","UK"]` are
84
+ distinct canonical preimages per RFC 8785 §3.2.3 -- producer-side
85
+ ordering is load-bearing.
86
+
87
+ The categorical screen result (`ALLOW` / `REFER` / `DENY`) is enforced as a
88
+ closed set. Under UK POCA 2002 s.330 a `REFER` carries a mandatory SAR
89
+ obligation that `DENY` does not; collapsing this to a score / tier
90
+ projection would lose the property and break year-five auditability.
91
+
92
+ ## Cross-impl validation
93
+
94
+ The substrate has been byte-for-byte cross-validated across five
95
+ implementations on the AlgoVoi-authored vector sets:
96
+
97
+ - Python `rfc8785@0.1.4` (this package wraps it)
98
+ - JavaScript `canonicalize@3.0.0`
99
+ - Go `gowebpki/jcs v1.0.1`
100
+ - Java `cyberphone/json-canonicalization`
101
+ - Rust `serde_jcs@0.2.0`
102
+
103
+ Vector sets (Apache 2.0, AlgoVoi-authored):
104
+
105
+ - [AP2 OMH v0](https://gist.github.com/chopmob-cloud/1dca25fd6107db4b7a30bed5dbf2ded8) -- 10 vectors
106
+ - [CTEF + APS v1](https://gist.github.com/chopmob-cloud/5f35eaa527d292bf3ddc52f8725a85c9) -- 14 vectors
107
+ - [privacy_class v0.1](https://gist.github.com/chopmob-cloud/30bcbc717c86493f737feb92c415ba07) -- 10 vectors
108
+ - [per-chain envelope v0](https://gist.github.com/chopmob-cloud/e1bf4c9efde6f0e94b77c238cb33d78d) -- 19 vectors
109
+
110
+ Substrate matrix: <https://gist.github.com/chopmob-cloud/b327814c4e17ed9fc7b4f29c8bda523c>
111
+
112
+ Composite trust-query matrix:
113
+ <https://gist.github.com/chopmob-cloud/f2e9f0877b7d9fff70c8eca46e4ce636>
114
+
115
+ ## Tests
116
+
117
+ ```bash
118
+ pip install -e ".[test]"
119
+ pytest
120
+ ```
121
+
122
+ ## Production reference
123
+
124
+ The reference exhibit for this substrate is AlgoVoi's `/compliance/attestation`
125
+ audit chain, live at `https://api.algovoi.co.uk/compliance/attestation`.
126
+ Receipts retained under seven-year Object Lock COMPLIANCE retention (current
127
+ horizon 2033-05-04). The migration boundary (receipts before / after
128
+ 2026-05-21) is observable directly from the chain.
129
+
130
+ ## Spec references
131
+
132
+ - [PR #2436](https://github.com/x402-foundation/x402/pull/2436) -- canonicalisation discipline
133
+ - [PR #2440](https://github.com/x402-foundation/x402/pull/2440) -- composite trust-query
134
+ - [PR #2434](https://github.com/x402-foundation/x402/pull/2434) -- compliance-receipt-fixture
135
+ - [draft-vauban-x402-stark-receipts](https://datatracker.ietf.org/doc/draft-vauban-x402-stark-receipts/) -- IETF I-D normatively referencing the substrate
136
+
137
+ ## Licence
138
+
139
+ Apache 2.0. See `LICENSE`.
140
+
141
+ ## Author
142
+
143
+ AlgoVoi (Christopher Hopley, GitHub `chopmob-cloud`).
@@ -0,0 +1,82 @@
1
+ """
2
+ algovoi-substrate -- AlgoVoi agentic-payments substrate reference implementation.
3
+
4
+ This package provides the AlgoVoi-authored primitives that compose the substrate
5
+ underneath x402, AP2, A2A, and MPP agentic-payment flows:
6
+
7
+ - JCS RFC 8785 canonicalisation with the AlgoVoi-discipline rules
8
+ (type-validation pre-canonicalisation, in-band canon_version pin).
9
+ - action_ref atomic primitive:
10
+ SHA-256(JCS({agent_id, action_type, scope, timestamp_ms})).
11
+ - Composite trust-query algorithm (PR #2440 in x402-foundation/x402).
12
+ - Compliance receipt shape matching AlgoVoi's production /compliance/screen
13
+ emission.
14
+ - Audit chain primitive: monotonic per-row hash chain with content_hash +
15
+ prev_hash linking, year-five auditability under canon_version pin.
16
+
17
+ Substrate is cross-validated byte-for-byte across five JCS implementations
18
+ (Python rfc8785, JavaScript canonicalize, Go gowebpki/jcs, Java cyberphone,
19
+ Rust serde_jcs) against 53 conformance vectors and 3 composite-trust-query
20
+ vectors. See https://gist.github.com/chopmob-cloud/b327814c4e17ed9fc7b4f29c8bda523c
21
+
22
+ The substrate runs in production at https://api.algovoi.co.uk/compliance.
23
+
24
+ Licensed under Apache 2.0.
25
+ """
26
+
27
+ from algovoi_substrate.canonicalize import (
28
+ CANON_VERSION,
29
+ CanonicalizationError,
30
+ canonicalize,
31
+ canonicalize_bytes,
32
+ sha256_jcs,
33
+ )
34
+ from algovoi_substrate.action_ref import (
35
+ ActionRefError,
36
+ action_ref,
37
+ action_ref_object,
38
+ )
39
+ from algovoi_substrate.composite_trust_query import (
40
+ CompositeTrustQueryError,
41
+ composite_trust_query_hash,
42
+ )
43
+ from algovoi_substrate.compliance_receipt import (
44
+ SCREEN_RESULTS,
45
+ ComplianceReceipt,
46
+ ComplianceReceiptError,
47
+ build_compliance_receipt,
48
+ )
49
+ from algovoi_substrate.audit_chain import (
50
+ AuditChainError,
51
+ AuditChainRow,
52
+ append_to_chain,
53
+ verify_audit_chain,
54
+ )
55
+
56
+ __all__ = [
57
+ # canonicalize
58
+ "CANON_VERSION",
59
+ "CanonicalizationError",
60
+ "canonicalize",
61
+ "canonicalize_bytes",
62
+ "sha256_jcs",
63
+ # action_ref
64
+ "ActionRefError",
65
+ "action_ref",
66
+ "action_ref_object",
67
+ # composite_trust_query
68
+ "CompositeTrustQueryError",
69
+ "composite_trust_query_hash",
70
+ # compliance_receipt
71
+ "SCREEN_RESULTS",
72
+ "ComplianceReceipt",
73
+ "ComplianceReceiptError",
74
+ "build_compliance_receipt",
75
+ # audit_chain
76
+ "AuditChainError",
77
+ "AuditChainRow",
78
+ "append_to_chain",
79
+ "verify_audit_chain",
80
+ ]
81
+
82
+ __version__ = "0.1.0"