algovoi-execution-ref 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,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: algovoi-execution-ref
3
+ Version: 0.1.0
4
+ Summary: AlgoVoi execution_ref -- decision-bound execution evidence bound to the keystone. Proves an executed action is consistent with the decision that authorized it. Runs on any algovoi-substrate version (v0/v1); uses only JCS RFC 8785 canonicalisation.
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/execution-ref
9
+ Project-URL: Repository, https://github.com/chopmob-cloud/algovoi-execution-ref
10
+ Project-URL: Issues, https://github.com/chopmob-cloud/algovoi-execution-ref/issues
11
+ Keywords: x402,ap2,a2a,mpp,jcs,rfc8785,canonicalisation,agentic-payments,execution_ref,keystone,decision-bound,execution-evidence
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: algovoi-substrate>=0.3.0
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-execution-ref
34
+
35
+ Decision-bound execution evidence, bound to the keystone. A standalone, pinned,
36
+ Apache-2.0 app.
37
+
38
+ `execution_ref` proves an executed action is consistent with the decision that
39
+ authorized it, not merely correlated with an identity:
40
+
41
+ ```
42
+ execution_ref = "sha256:" + SHA-256(JCS({decision_ref, action_type, scope, outcome, executed_at_ms}))
43
+ ```
44
+
45
+ It binds the full keystone chain:
46
+
47
+ ```
48
+ passport_ref -> mandate_ref -> policy_bound_ref -> decision_ref -> execution_ref -> trust_query_ref
49
+ (identity) (authority) (policy) (decision) (execution) (one verdict)
50
+ ```
51
+
52
+ ## Runs on any substrate version (v0 and v1)
53
+
54
+ This app uses only the substrate's JCS canonicalisation, which is byte-stable and
55
+ present in every release. It pins `algovoi-substrate>=0.3.0` and runs unchanged on
56
+ substrate v0 (0.x) and v1 (1.x). You get `execution_ref` and the keystone **without
57
+ upgrading your substrate**:
58
+
59
+ ```
60
+ pip install algovoi-execution-ref # installs next to whatever substrate you already have
61
+ ```
62
+
63
+ ## Use
64
+
65
+ ```python
66
+ from algovoi_execution_ref import bind_keystone, verify_record, execution_ref
67
+
68
+ record = bind_keystone(
69
+ passport_ref="sha256:...", mandate_ref="sha256:...", policy_bound_ref="sha256:...",
70
+ verdict="ALLOW", action_type="payment", scope="bilateral",
71
+ outcome="COMMITTED", executed_at_ms=1716460800000, trust_outcome="TRUSTED",
72
+ )
73
+ record["execution_ref"] # decision-bound execution evidence
74
+ record["trust_query_ref"] # content address: one verdict over the whole chain
75
+ verify_record(record) # recomputes every ref from raw fields -> True
76
+ ```
77
+
78
+ ## CLI
79
+
80
+ ```
81
+ echo '{"passport_ref":"sha256:...", ...}' | algovoi-execution-ref
82
+ algovoi-execution-ref --verify < record.json # exit 0 if consistent, 1 if not
83
+ ```
84
+
85
+ ## Conformance and tiers
86
+
87
+ The composed chain reproduces the public corpus byte for byte
88
+ (`execution_ref_v1` and the `keystone_v1` composition). This is the open tier: it
89
+ binds and proves. Post-quantum signing and CCC-ingestable evidence chains are the
90
+ commercial Substrate 2 tier. `outcome` is the closed enum
91
+ `{COMMITTED, SKIPPED, FAILED, REVERSED}`; `executed_at_ms` is an integer
92
+ epoch-millisecond; no raw agent id appears in the preimage, so it carries no PII.
@@ -0,0 +1,60 @@
1
+ # algovoi-execution-ref
2
+
3
+ Decision-bound execution evidence, bound to the keystone. A standalone, pinned,
4
+ Apache-2.0 app.
5
+
6
+ `execution_ref` proves an executed action is consistent with the decision that
7
+ authorized it, not merely correlated with an identity:
8
+
9
+ ```
10
+ execution_ref = "sha256:" + SHA-256(JCS({decision_ref, action_type, scope, outcome, executed_at_ms}))
11
+ ```
12
+
13
+ It binds the full keystone chain:
14
+
15
+ ```
16
+ passport_ref -> mandate_ref -> policy_bound_ref -> decision_ref -> execution_ref -> trust_query_ref
17
+ (identity) (authority) (policy) (decision) (execution) (one verdict)
18
+ ```
19
+
20
+ ## Runs on any substrate version (v0 and v1)
21
+
22
+ This app uses only the substrate's JCS canonicalisation, which is byte-stable and
23
+ present in every release. It pins `algovoi-substrate>=0.3.0` and runs unchanged on
24
+ substrate v0 (0.x) and v1 (1.x). You get `execution_ref` and the keystone **without
25
+ upgrading your substrate**:
26
+
27
+ ```
28
+ pip install algovoi-execution-ref # installs next to whatever substrate you already have
29
+ ```
30
+
31
+ ## Use
32
+
33
+ ```python
34
+ from algovoi_execution_ref import bind_keystone, verify_record, execution_ref
35
+
36
+ record = bind_keystone(
37
+ passport_ref="sha256:...", mandate_ref="sha256:...", policy_bound_ref="sha256:...",
38
+ verdict="ALLOW", action_type="payment", scope="bilateral",
39
+ outcome="COMMITTED", executed_at_ms=1716460800000, trust_outcome="TRUSTED",
40
+ )
41
+ record["execution_ref"] # decision-bound execution evidence
42
+ record["trust_query_ref"] # content address: one verdict over the whole chain
43
+ verify_record(record) # recomputes every ref from raw fields -> True
44
+ ```
45
+
46
+ ## CLI
47
+
48
+ ```
49
+ echo '{"passport_ref":"sha256:...", ...}' | algovoi-execution-ref
50
+ algovoi-execution-ref --verify < record.json # exit 0 if consistent, 1 if not
51
+ ```
52
+
53
+ ## Conformance and tiers
54
+
55
+ The composed chain reproduces the public corpus byte for byte
56
+ (`execution_ref_v1` and the `keystone_v1` composition). This is the open tier: it
57
+ binds and proves. Post-quantum signing and CCC-ingestable evidence chains are the
58
+ commercial Substrate 2 tier. `outcome` is the closed enum
59
+ `{COMMITTED, SKIPPED, FAILED, REVERSED}`; `executed_at_ms` is an integer
60
+ epoch-millisecond; no raw agent id appears in the preimage, so it carries no PII.
@@ -0,0 +1,29 @@
1
+ """algovoi-execution-ref: decision-bound execution evidence, bound to the keystone.
2
+
3
+ Runs on any substrate version (v0 / v1): it uses only the stable JCS
4
+ canonicalisation. Install alongside your existing substrate and use execution_ref
5
+ and the keystone with no substrate upgrade required.
6
+ """
7
+
8
+ from algovoi_execution_ref.refs import (
9
+ ExecutionRefError,
10
+ EXECUTION_OUTCOMES,
11
+ DECISION_VERDICTS,
12
+ TRUST_OUTCOMES,
13
+ execution_ref,
14
+ decision_ref,
15
+ trust_query_ref,
16
+ execution_binding,
17
+ bind_keystone,
18
+ verify_record,
19
+ )
20
+
21
+ __version__ = "0.1.0"
22
+
23
+ __all__ = [
24
+ "ExecutionRefError",
25
+ "EXECUTION_OUTCOMES", "DECISION_VERDICTS", "TRUST_OUTCOMES",
26
+ "execution_ref", "decision_ref", "trust_query_ref",
27
+ "execution_binding", "bind_keystone", "verify_record",
28
+ "__version__",
29
+ ]
@@ -0,0 +1,45 @@
1
+ """CLI: bind an execution to the keystone, or verify a record.
2
+
3
+ echo '{...}' | algovoi-execution-ref # build a keystone record
4
+ algovoi-execution-ref --verify < record.json # verify (exit 0/1)
5
+
6
+ Build input requires: passport_ref, mandate_ref, policy_bound_ref, verdict,
7
+ action_type, scope, outcome, executed_at_ms, trust_outcome.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import sys
14
+
15
+ from algovoi_execution_ref.refs import (
16
+ ExecutionRefError,
17
+ bind_keystone,
18
+ verify_record,
19
+ )
20
+
21
+
22
+ def main() -> None:
23
+ ap = argparse.ArgumentParser(prog="algovoi-execution-ref",
24
+ description="Bind an execution to the AlgoVoi keystone")
25
+ ap.add_argument("--verify", action="store_true",
26
+ help="verify a record from stdin (exit 0 if consistent, 1 if not)")
27
+ ap.add_argument("file", nargs="?", help="input JSON file (default: stdin)")
28
+ args = ap.parse_args()
29
+ raw = open(args.file, encoding="utf-8").read() if args.file else sys.stdin.read()
30
+ try:
31
+ obj = json.loads(raw)
32
+ except json.JSONDecodeError as e:
33
+ print(f"invalid JSON: {e}", file=sys.stderr); sys.exit(2)
34
+ try:
35
+ if args.verify:
36
+ ok = verify_record(obj)
37
+ print("VERIFIED" if ok else "MISMATCH")
38
+ sys.exit(0 if ok else 1)
39
+ print(json.dumps(bind_keystone(**obj), separators=(",", ":"), sort_keys=True))
40
+ except (ExecutionRefError, TypeError) as e:
41
+ print(f"error: {e}", file=sys.stderr); sys.exit(2)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
@@ -0,0 +1,178 @@
1
+ """
2
+ algovoi-execution-ref: decision-bound execution evidence + keystone binding.
3
+
4
+ A standalone app that implements execution_ref and binds the full keystone
5
+ chain. It depends ONLY on the substrate's JCS canonicalisation (sha256_jcs),
6
+ which is byte-stable and present in every substrate release, so this app runs
7
+ unchanged on substrate v0 (0.x) and v1 (1.x). An existing adopter gets
8
+ execution_ref and the keystone without upgrading their substrate.
9
+
10
+ execution_ref = "sha256:" + SHA-256(JCS({decision_ref, action_type, scope,
11
+ outcome, executed_at_ms}))
12
+
13
+ The keystone it binds:
14
+
15
+ passport_ref -> mandate_ref -> policy_bound_ref
16
+ -> decision_ref = "sha256:" + SHA-256(JCS({agent_ref, mandate_ref, policy_bound_ref, verdict}))
17
+ -> execution_ref (above; decision-bound)
18
+ -> trust_query_ref = "sha256:" + SHA-256(JCS({subject_refs, trust_outcome}))
19
+
20
+ Every reference is JCS (RFC 8785) + SHA-256, so the chain reproduces byte for
21
+ byte from raw fields with no issuer contact, identical on any substrate version.
22
+ """
23
+ from __future__ import annotations
24
+
25
+ import re
26
+
27
+ # sha256_jcs is the one substrate primitive this app uses. It is present and
28
+ # byte-identical across substrate v0 (0.x) and v1 (1.x).
29
+ from algovoi_substrate import sha256_jcs
30
+
31
+ _SHA256_REF_RE = re.compile(r"^sha256:[0-9a-f]{64}$")
32
+
33
+ EXECUTION_OUTCOMES = ("COMMITTED", "SKIPPED", "FAILED", "REVERSED")
34
+ DECISION_VERDICTS = ("ALLOW", "DENY", "REFER")
35
+ TRUST_OUTCOMES = ("TRUSTED", "PROVISIONAL", "INSUFFICIENT_EVIDENCE", "UNTRUSTED")
36
+
37
+
38
+ class ExecutionRefError(ValueError):
39
+ """Raised when inputs violate the substrate discipline."""
40
+
41
+
42
+ def _ref(field: str, value: object) -> str:
43
+ if not isinstance(value, str) or not _SHA256_REF_RE.match(value):
44
+ raise ExecutionRefError(f"{field} must be 'sha256:<lowercase 64-char hex>'")
45
+ return value
46
+
47
+
48
+ def _nonempty(field: str, value: object) -> str:
49
+ if not isinstance(value, str) or value == "":
50
+ raise ExecutionRefError(f"{field} must be a non-empty string")
51
+ return value
52
+
53
+
54
+ def _member(field: str, value: object, members: tuple[str, ...]) -> str:
55
+ if value not in members:
56
+ raise ExecutionRefError(f"{field} must be one of {members}, got {value!r}")
57
+ return value
58
+
59
+
60
+ def _int_ms(value: object) -> int:
61
+ if isinstance(value, bool) or not isinstance(value, int):
62
+ raise ExecutionRefError("executed_at_ms must be an epoch-millisecond integer")
63
+ if value < 0:
64
+ raise ExecutionRefError("executed_at_ms must be non-negative")
65
+ return value
66
+
67
+
68
+ def execution_ref(decision_ref: str, action_type: str, scope: str,
69
+ outcome: str, executed_at_ms: int) -> str:
70
+ """execution_ref = "sha256:" + SHA-256(JCS(preimage)). Decision-bound."""
71
+ return "sha256:" + sha256_jcs({
72
+ "decision_ref": _ref("decision_ref", decision_ref),
73
+ "action_type": _nonempty("action_type", action_type),
74
+ "scope": _nonempty("scope", scope),
75
+ "outcome": _member("outcome", outcome, EXECUTION_OUTCOMES),
76
+ "executed_at_ms": _int_ms(executed_at_ms),
77
+ })
78
+
79
+
80
+ def decision_ref(agent_ref: str, mandate_ref: str, policy_bound_ref: str, verdict: str) -> str:
81
+ """The pre-payment decision reference (the keystone this execution binds to)."""
82
+ return "sha256:" + sha256_jcs({
83
+ "agent_ref": _ref("agent_ref", agent_ref),
84
+ "mandate_ref": _ref("mandate_ref", mandate_ref),
85
+ "policy_bound_ref": _ref("policy_bound_ref", policy_bound_ref),
86
+ "verdict": _member("verdict", verdict, DECISION_VERDICTS),
87
+ })
88
+
89
+
90
+ def trust_query_ref(subject_refs: list[str], trust_outcome: str) -> str:
91
+ """A composite trust verdict over an ordered reference list."""
92
+ if not isinstance(subject_refs, list) or not subject_refs:
93
+ raise ExecutionRefError("subject_refs must be a non-empty list")
94
+ refs = [_ref(f"subject_refs[{i}]", r) for i, r in enumerate(subject_refs)]
95
+ return "sha256:" + sha256_jcs({
96
+ "subject_refs": refs,
97
+ "trust_outcome": _member("trust_outcome", trust_outcome, TRUST_OUTCOMES),
98
+ })
99
+
100
+
101
+ def execution_binding(execution_ref: str, settlement_ref: str, retention_chain_ref: str) -> str:
102
+ """Post-settlement accountability binding over an execution_ref.
103
+
104
+ The execution-tier replacement for the action_ref settlement binding. Because
105
+ execution_ref already encodes the committed outcome bound to its authorizing
106
+ decision, it subsumes the old (action_ref + transition_hash) pair: one
107
+ decision-bound reference instead of two.
108
+
109
+ binding_ref = "sha256:" + SHA-256(JCS({execution_ref, settlement_ref, retention_chain_ref}))
110
+ """
111
+ return "sha256:" + sha256_jcs({
112
+ "execution_ref": _ref("execution_ref", execution_ref),
113
+ "settlement_ref": _ref("settlement_ref", settlement_ref),
114
+ "retention_chain_ref": _ref("retention_chain_ref", retention_chain_ref),
115
+ })
116
+
117
+
118
+ def bind_keystone(
119
+ *,
120
+ passport_ref: str,
121
+ mandate_ref: str,
122
+ policy_bound_ref: str,
123
+ verdict: str,
124
+ action_type: str,
125
+ scope: str,
126
+ outcome: str,
127
+ executed_at_ms: int,
128
+ trust_outcome: str,
129
+ ) -> dict:
130
+ """Bind an execution to the full keystone and return a self-describing record.
131
+
132
+ The execution is bound to the exact decision the chain produced. Content
133
+ address of the record is trust_query_ref. Identical bytes on any substrate
134
+ version.
135
+ """
136
+ d_ref = decision_ref(passport_ref, mandate_ref, policy_bound_ref, verdict)
137
+ e_ref = execution_ref(d_ref, action_type, scope, outcome, executed_at_ms)
138
+ chain = [_ref("passport_ref", passport_ref), _ref("mandate_ref", mandate_ref),
139
+ _ref("policy_bound_ref", policy_bound_ref), d_ref, e_ref]
140
+ tq_ref = trust_query_ref(chain, trust_outcome)
141
+ return {
142
+ "canon_version": "jcs-rfc8785-v1",
143
+ "type": "execution_keystone",
144
+ "passport_ref": passport_ref,
145
+ "mandate_ref": mandate_ref,
146
+ "policy_bound_ref": policy_bound_ref,
147
+ "verdict": verdict,
148
+ "decision_ref": d_ref,
149
+ "action_type": action_type,
150
+ "scope": scope,
151
+ "outcome": outcome,
152
+ "executed_at_ms": executed_at_ms,
153
+ "execution_ref": e_ref,
154
+ "trust_outcome": trust_outcome,
155
+ "trust_query_ref": tq_ref,
156
+ "chain": chain,
157
+ }
158
+
159
+
160
+ def verify_record(record: dict) -> bool:
161
+ """Recompute decision_ref, execution_ref, trust_query_ref, and the chain from
162
+ the record's raw fields; return True iff all match the carried values."""
163
+ required = ("passport_ref", "mandate_ref", "policy_bound_ref", "verdict",
164
+ "action_type", "scope", "outcome", "executed_at_ms", "trust_outcome")
165
+ missing = [f for f in required if f not in record]
166
+ if missing:
167
+ raise ExecutionRefError(f"record missing required fields: {missing}")
168
+ rebuilt = bind_keystone(**{f: record[f] for f in required})
169
+ return all(record.get(k) == rebuilt[k]
170
+ for k in ("decision_ref", "execution_ref", "trust_query_ref", "chain"))
171
+
172
+
173
+ __all__ = [
174
+ "ExecutionRefError",
175
+ "EXECUTION_OUTCOMES", "DECISION_VERDICTS", "TRUST_OUTCOMES",
176
+ "execution_ref", "decision_ref", "trust_query_ref",
177
+ "execution_binding", "bind_keystone", "verify_record",
178
+ ]
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: algovoi-execution-ref
3
+ Version: 0.1.0
4
+ Summary: AlgoVoi execution_ref -- decision-bound execution evidence bound to the keystone. Proves an executed action is consistent with the decision that authorized it. Runs on any algovoi-substrate version (v0/v1); uses only JCS RFC 8785 canonicalisation.
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/execution-ref
9
+ Project-URL: Repository, https://github.com/chopmob-cloud/algovoi-execution-ref
10
+ Project-URL: Issues, https://github.com/chopmob-cloud/algovoi-execution-ref/issues
11
+ Keywords: x402,ap2,a2a,mpp,jcs,rfc8785,canonicalisation,agentic-payments,execution_ref,keystone,decision-bound,execution-evidence
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: algovoi-substrate>=0.3.0
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-execution-ref
34
+
35
+ Decision-bound execution evidence, bound to the keystone. A standalone, pinned,
36
+ Apache-2.0 app.
37
+
38
+ `execution_ref` proves an executed action is consistent with the decision that
39
+ authorized it, not merely correlated with an identity:
40
+
41
+ ```
42
+ execution_ref = "sha256:" + SHA-256(JCS({decision_ref, action_type, scope, outcome, executed_at_ms}))
43
+ ```
44
+
45
+ It binds the full keystone chain:
46
+
47
+ ```
48
+ passport_ref -> mandate_ref -> policy_bound_ref -> decision_ref -> execution_ref -> trust_query_ref
49
+ (identity) (authority) (policy) (decision) (execution) (one verdict)
50
+ ```
51
+
52
+ ## Runs on any substrate version (v0 and v1)
53
+
54
+ This app uses only the substrate's JCS canonicalisation, which is byte-stable and
55
+ present in every release. It pins `algovoi-substrate>=0.3.0` and runs unchanged on
56
+ substrate v0 (0.x) and v1 (1.x). You get `execution_ref` and the keystone **without
57
+ upgrading your substrate**:
58
+
59
+ ```
60
+ pip install algovoi-execution-ref # installs next to whatever substrate you already have
61
+ ```
62
+
63
+ ## Use
64
+
65
+ ```python
66
+ from algovoi_execution_ref import bind_keystone, verify_record, execution_ref
67
+
68
+ record = bind_keystone(
69
+ passport_ref="sha256:...", mandate_ref="sha256:...", policy_bound_ref="sha256:...",
70
+ verdict="ALLOW", action_type="payment", scope="bilateral",
71
+ outcome="COMMITTED", executed_at_ms=1716460800000, trust_outcome="TRUSTED",
72
+ )
73
+ record["execution_ref"] # decision-bound execution evidence
74
+ record["trust_query_ref"] # content address: one verdict over the whole chain
75
+ verify_record(record) # recomputes every ref from raw fields -> True
76
+ ```
77
+
78
+ ## CLI
79
+
80
+ ```
81
+ echo '{"passport_ref":"sha256:...", ...}' | algovoi-execution-ref
82
+ algovoi-execution-ref --verify < record.json # exit 0 if consistent, 1 if not
83
+ ```
84
+
85
+ ## Conformance and tiers
86
+
87
+ The composed chain reproduces the public corpus byte for byte
88
+ (`execution_ref_v1` and the `keystone_v1` composition). This is the open tier: it
89
+ binds and proves. Post-quantum signing and CCC-ingestable evidence chains are the
90
+ commercial Substrate 2 tier. `outcome` is the closed enum
91
+ `{COMMITTED, SKIPPED, FAILED, REVERSED}`; `executed_at_ms` is an integer
92
+ epoch-millisecond; no raw agent id appears in the preimage, so it carries no PII.
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ algovoi_execution_ref/__init__.py
5
+ algovoi_execution_ref/__main__.py
6
+ algovoi_execution_ref/py.typed
7
+ algovoi_execution_ref/refs.py
8
+ algovoi_execution_ref.egg-info/PKG-INFO
9
+ algovoi_execution_ref.egg-info/SOURCES.txt
10
+ algovoi_execution_ref.egg-info/dependency_links.txt
11
+ algovoi_execution_ref.egg-info/entry_points.txt
12
+ algovoi_execution_ref.egg-info/requires.txt
13
+ algovoi_execution_ref.egg-info/top_level.txt
14
+ tests/test_execution_ref_app.py
15
+ tests/test_replacement_parity.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ algovoi-execution-ref = algovoi_execution_ref.__main__:main
@@ -0,0 +1,5 @@
1
+ algovoi-substrate>=0.3.0
2
+
3
+ [test]
4
+ pytest>=7
5
+ pytest-cov>=4
@@ -0,0 +1 @@
1
+ algovoi_execution_ref
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "algovoi-execution-ref"
7
+ version = "0.1.0"
8
+ description = "AlgoVoi execution_ref -- decision-bound execution evidence bound to the keystone. Proves an executed action is consistent with the decision that authorized it. Runs on any algovoi-substrate version (v0/v1); uses only JCS RFC 8785 canonicalisation."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [
13
+ { name = "AlgoVoi", email = "chopmob@gmail.com" },
14
+ ]
15
+ keywords = [
16
+ "x402", "ap2", "a2a", "mpp",
17
+ "jcs", "rfc8785", "canonicalisation",
18
+ "agentic-payments", "execution_ref", "keystone",
19
+ "decision-bound", "execution-evidence",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 4 - Beta",
23
+ "Intended Audience :: Developers",
24
+ "Intended Audience :: Financial and Insurance Industry",
25
+ "License :: OSI Approved :: Apache Software License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Security :: Cryptography",
32
+ "Topic :: Software Development :: Libraries",
33
+ "Typing :: Typed",
34
+ ]
35
+ # Depends only on the stable JCS canonicalisation, present in every substrate
36
+ # release, so this app runs unchanged on substrate v0 (0.x) and v1 (1.x).
37
+ dependencies = [
38
+ "algovoi-substrate>=0.3.0",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ test = ["pytest>=7", "pytest-cov>=4"]
43
+
44
+ [project.scripts]
45
+ algovoi-execution-ref = "algovoi_execution_ref.__main__:main"
46
+
47
+ [project.urls]
48
+ Homepage = "https://api.algovoi.co.uk"
49
+ Documentation = "https://docs.algovoi.co.uk/execution-ref"
50
+ Repository = "https://github.com/chopmob-cloud/algovoi-execution-ref"
51
+ Issues = "https://github.com/chopmob-cloud/algovoi-execution-ref/issues"
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["."]
55
+ include = ["algovoi_execution_ref*"]
56
+
57
+ [tool.setuptools.package-data]
58
+ algovoi_execution_ref = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,98 @@
1
+ """Tests for the algovoi-execution-ref standalone app.
2
+
3
+ Pins to the published corpus values (keystone_v1 / execution_ref_v1 /
4
+ spend_decision_v1). These hold identically on substrate v0 and v1 because the
5
+ app uses only JCS canonicalisation.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ import subprocess
11
+ import sys
12
+
13
+ import pytest
14
+
15
+ import algovoi_substrate as _sub
16
+ from algovoi_execution_ref import (
17
+ execution_ref, decision_ref, trust_query_ref,
18
+ bind_keystone, verify_record, ExecutionRefError, __version__,
19
+ )
20
+
21
+ PASSPORT = "sha256:b3594e33998af01bd1ad208172c5c1ac586daa8c75781379f034d97e50b1a9be"
22
+ MANDATE = "sha256:a4f8cb5ee09b29478ac1cc2f468d66e16d3d25f7a229a31d22ad521e11d04d35"
23
+ POLICY = "sha256:aaee2091799f376ee8cac802ea4920feaa4eca52950488a3e047ff82e6959a21"
24
+ DECISION_ALLOW = "sha256:2a444c629892f44fde1bd004aba9be01dd6cc7fe251eecdd545b82dca9f0bf97"
25
+ EXECUTION = "sha256:f6e2bfc15b085ed51c4c972de81d1c6b00f4e55b272e2aa12e56bb7c521fc65a"
26
+ TRUST_KEYSTONE = "sha256:18fb601a08c71eb6bed11e1c117f33bdc0ada6d635ea9bb9cca15e8410ce7ebd"
27
+
28
+ KW = dict(passport_ref=PASSPORT, mandate_ref=MANDATE, policy_bound_ref=POLICY,
29
+ verdict="ALLOW", action_type="payment", scope="bilateral",
30
+ outcome="COMMITTED", executed_at_ms=1716460800000, trust_outcome="TRUSTED")
31
+
32
+
33
+ def test_version():
34
+ assert __version__ == "0.1.0"
35
+
36
+
37
+ def test_runs_on_any_substrate_version():
38
+ # informational: the app must work on whatever substrate is installed
39
+ assert _sub.__version__ # present
40
+
41
+
42
+ def test_decision_ref_matches_corpus():
43
+ assert decision_ref(PASSPORT, MANDATE, POLICY, "ALLOW") == DECISION_ALLOW
44
+
45
+
46
+ def test_execution_ref_matches_corpus():
47
+ assert execution_ref(DECISION_ALLOW, "payment", "bilateral", "COMMITTED", 1716460800000) == EXECUTION
48
+
49
+
50
+ def test_trust_query_ref_matches_corpus():
51
+ assert trust_query_ref([PASSPORT, MANDATE, POLICY, DECISION_ALLOW, EXECUTION], "TRUSTED") == TRUST_KEYSTONE
52
+
53
+
54
+ def test_bind_keystone_matches_corpus():
55
+ r = bind_keystone(**KW)
56
+ assert r["decision_ref"] == DECISION_ALLOW
57
+ assert r["execution_ref"] == EXECUTION
58
+ assert r["trust_query_ref"] == TRUST_KEYSTONE
59
+ assert r["chain"] == [PASSPORT, MANDATE, POLICY, DECISION_ALLOW, EXECUTION]
60
+
61
+
62
+ def test_record_self_verifies():
63
+ assert verify_record(bind_keystone(**KW)) is True
64
+
65
+
66
+ def test_tamper_detected():
67
+ r = bind_keystone(**KW)
68
+ r["execution_ref"] = "sha256:" + "f" * 64
69
+ assert verify_record(r) is False
70
+
71
+
72
+ def test_decision_binding_load_bearing():
73
+ allow = bind_keystone(**KW)
74
+ deny = bind_keystone(**{**KW, "verdict": "DENY"})
75
+ assert deny["execution_ref"] != allow["execution_ref"]
76
+ assert deny["trust_query_ref"] != allow["trust_query_ref"]
77
+
78
+
79
+ def test_rejects_rfc3339_timestamp():
80
+ with pytest.raises(ExecutionRefError):
81
+ execution_ref(DECISION_ALLOW, "payment", "bilateral", "COMMITTED", "2026-05-23T00:00:00.000Z")
82
+
83
+
84
+ def test_rejects_bad_inputs():
85
+ with pytest.raises(ExecutionRefError):
86
+ bind_keystone(**{**KW, "passport_ref": "nope"})
87
+ with pytest.raises(ExecutionRefError):
88
+ bind_keystone(**{**KW, "outcome": "DONE"})
89
+
90
+
91
+ def test_cli_roundtrip():
92
+ b = subprocess.run([sys.executable, "-m", "algovoi_execution_ref"],
93
+ input=json.dumps(KW), capture_output=True, text=True)
94
+ assert b.returncode == 0, b.stderr
95
+ assert json.loads(b.stdout)["trust_query_ref"] == TRUST_KEYSTONE
96
+ v = subprocess.run([sys.executable, "-m", "algovoi_execution_ref", "--verify"],
97
+ input=b.stdout, capture_output=True, text=True)
98
+ assert v.returncode == 0 and "VERIFIED" in v.stdout
@@ -0,0 +1,125 @@
1
+ """Replacement parity: execution_ref does everything action_ref does, as the
2
+ natural keystone replacement, and the lifecycle/binding roles more cleanly.
3
+
4
+ Each test maps a documented action_ref capability (from the action_ref_namespace_v0,
5
+ action_ref_transactional_v0, action_ref_exactly_once_v1, and settlement_action_binding_v1
6
+ corpus sets) to its execution_ref equivalent and proves it. Runs on substrate v0 and v1.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import pytest
11
+
12
+ from algovoi_execution_ref import (
13
+ execution_ref, decision_ref, execution_binding, bind_keystone,
14
+ ExecutionRefError, EXECUTION_OUTCOMES,
15
+ )
16
+
17
+ DEC = "sha256:2a444c629892f44fde1bd004aba9be01dd6cc7fe251eecdd545b82dca9f0bf97" # ALLOW
18
+ DEC2 = "sha256:792a5b43e9df0fc460d6bf99d6357afafbdcf910ef1e81a340e3581bc27109cf" # DENY
19
+ REF_A = "sha256:" + "a" * 64
20
+ REF_B = "sha256:" + "b" * 64
21
+ REF_C = "sha256:" + "c" * 64
22
+
23
+
24
+ def E(**kw):
25
+ base = dict(decision_ref=DEC, action_type="payment", scope="bilateral",
26
+ outcome="COMMITTED", executed_at_ms=1716460800000)
27
+ base.update(kw)
28
+ return execution_ref(**base)
29
+
30
+
31
+ # --- action_ref capability 1: content-addressed identity + deterministic correlation ---
32
+ def test_deterministic_content_address():
33
+ # action_ref: same logical action -> same handle. execution_ref: same here.
34
+ assert E() == E()
35
+
36
+
37
+ def test_two_parties_correlate_same_execution():
38
+ # two independent emitters describing the same execution derive the same ref
39
+ party_a = execution_ref(DEC, "payment", "bilateral", "COMMITTED", 1716460800000)
40
+ party_b = execution_ref(DEC, "payment", "bilateral", "COMMITTED", 1716460800000)
41
+ assert party_a == party_b
42
+
43
+
44
+ # --- capability 2: every field byte-load-bearing (namespace / scope discipline) ---
45
+ @pytest.mark.parametrize("field,alt", [
46
+ ("decision_ref", DEC2),
47
+ ("action_type", "refund"),
48
+ ("scope", "unilateral"),
49
+ ("outcome", "REVERSED"),
50
+ ("executed_at_ms", 1716460800001),
51
+ ])
52
+ def test_every_field_is_load_bearing(field, alt):
53
+ assert E() != E(**{field: alt})
54
+
55
+
56
+ # --- capability 3: integer-ms discipline (Substrate Rule) ---
57
+ def test_integer_ms_discipline():
58
+ with pytest.raises(ExecutionRefError):
59
+ E(executed_at_ms="2026-05-23T00:00:00.000Z") # RFC 3339 string rejected
60
+ with pytest.raises(ExecutionRefError):
61
+ E(executed_at_ms=1716460800000.5) # float rejected
62
+ with pytest.raises(ExecutionRefError):
63
+ E(executed_at_ms=-1) # negative rejected
64
+ assert E(executed_at_ms=0) # epoch zero valid
65
+
66
+
67
+ # --- capability 4: transactional lifecycle (PENDING/COMMITTED/REVERSED -> outcome enum) ---
68
+ def test_lifecycle_states_distinct():
69
+ refs = {oc: E(outcome=oc) for oc in EXECUTION_OUTCOMES}
70
+ # each lifecycle state yields a distinct execution_ref; none collide
71
+ assert len(set(refs.values())) == len(EXECUTION_OUTCOMES)
72
+
73
+
74
+ # --- capability 5: exactly-once / SKIP-on-retry idempotency ---
75
+ def test_exactly_once_idempotent_commit():
76
+ # the committed execution is idempotent: re-deriving it gives the same ref
77
+ first = E(outcome="COMMITTED")
78
+ again = E(outcome="COMMITTED")
79
+ assert first == again
80
+
81
+
82
+ def test_skip_on_retry_is_distinguishable():
83
+ # a suppressed duplicate (SKIPPED) is a distinct, recordable outcome, not a silent dup
84
+ committed = E(outcome="COMMITTED")
85
+ skipped = E(outcome="SKIPPED")
86
+ assert committed != skipped
87
+
88
+
89
+ # --- capability 6: replay-binding (an execution cannot be re-attributed) ---
90
+ def test_replay_binding_via_decision():
91
+ # the same action replayed under a different authorizing decision is a different ref
92
+ assert E(decision_ref=DEC) != E(decision_ref=DEC2)
93
+
94
+
95
+ # --- capability 7: settlement binding (action_ref + transition_hash -> binding_ref) ---
96
+ def test_settlement_binding_over_execution_ref():
97
+ e = E(outcome="COMMITTED")
98
+ b1 = execution_binding(e, REF_B, REF_C)
99
+ assert b1.startswith("sha256:") and len(b1) == len("sha256:") + 64
100
+ # settlement-binding: changing settlement_ref changes the binding
101
+ assert execution_binding(e, REF_A, REF_C) != b1
102
+ # action-binding: changing the execution changes the binding
103
+ assert execution_binding(E(outcome="REVERSED"), REF_B, REF_C) != b1
104
+ # chain-binding: changing retention_chain_ref changes the binding
105
+ assert execution_binding(e, REF_B, REF_A) != b1
106
+
107
+
108
+ def test_settlement_binding_subsumes_transition_hash():
109
+ # execution_ref already encodes the committed outcome, so the binding needs
110
+ # one decision-bound reference where action_ref needed action_ref + transition_hash
111
+ committed = execution_binding(E(outcome="COMMITTED"), REF_B, REF_C)
112
+ reversed_ = execution_binding(E(outcome="REVERSED"), REF_B, REF_C)
113
+ assert committed != reversed_ # the lifecycle state is still load-bearing in the binding
114
+
115
+
116
+ # --- capability 8: anchors the keystone record (receipts / audit) ---
117
+ def test_execution_ref_anchors_keystone():
118
+ rec = bind_keystone(
119
+ passport_ref=REF_A, mandate_ref=REF_B, policy_bound_ref=REF_C,
120
+ verdict="ALLOW", action_type="payment", scope="bilateral",
121
+ outcome="COMMITTED", executed_at_ms=1716460800000, trust_outcome="TRUSTED",
122
+ )
123
+ # the execution_ref is the load-bearing anchor inside the record + the chain
124
+ assert rec["execution_ref"] in rec["chain"]
125
+ assert rec["execution_ref"] == execution_ref(rec["decision_ref"], "payment", "bilateral", "COMMITTED", 1716460800000)