as-agreed 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. as_agreed-0.0.1/CITATION.cff +13 -0
  2. as_agreed-0.0.1/LICENSE +202 -0
  3. as_agreed-0.0.1/MANIFEST.in +5 -0
  4. as_agreed-0.0.1/NOTICE +2 -0
  5. as_agreed-0.0.1/PKG-INFO +114 -0
  6. as_agreed-0.0.1/README.md +90 -0
  7. as_agreed-0.0.1/SEND-A-MAP.md +21 -0
  8. as_agreed-0.0.1/draw_flow.py +14 -0
  9. as_agreed-0.0.1/examples/hello/01-research.md +8 -0
  10. as_agreed-0.0.1/examples/hello/02-email.md +8 -0
  11. as_agreed-0.0.1/examples/hello/flow.svg +25 -0
  12. as_agreed-0.0.1/examples/planted-failure/01-order.md +4 -0
  13. as_agreed-0.0.1/examples/planted-failure/02-research.md +6 -0
  14. as_agreed-0.0.1/examples/planted-failure/03-commit-retry.json +7 -0
  15. as_agreed-0.0.1/examples/planted-failure/03-commit.json +6 -0
  16. as_agreed-0.0.1/examples/planted-failure/03-commit.md +5 -0
  17. as_agreed-0.0.1/examples/planted-failure/commitments.json +22 -0
  18. as_agreed-0.0.1/examples/planted-failure/flow.svg +34 -0
  19. as_agreed-0.0.1/examples/planted-widened/01-order.md +3 -0
  20. as_agreed-0.0.1/examples/planted-widened/02-research.md +5 -0
  21. as_agreed-0.0.1/examples/planted-widened/03-commit-retry.json +6 -0
  22. as_agreed-0.0.1/examples/planted-widened/03-commit.json +6 -0
  23. as_agreed-0.0.1/examples/planted-widened/03-commit.md +4 -0
  24. as_agreed-0.0.1/examples/planted-widened/commitments.json +11 -0
  25. as_agreed-0.0.1/examples/planted-widened/flow.svg +20 -0
  26. as_agreed-0.0.1/ledger.py +15 -0
  27. as_agreed-0.0.1/pyproject.toml +39 -0
  28. as_agreed-0.0.1/readings/README.md +26 -0
  29. as_agreed-0.0.1/setup.cfg +4 -0
  30. as_agreed-0.0.1/src/as_agreed/__init__.py +17 -0
  31. as_agreed-0.0.1/src/as_agreed/__main__.py +101 -0
  32. as_agreed-0.0.1/src/as_agreed/adapters/__init__.py +4 -0
  33. as_agreed-0.0.1/src/as_agreed/adapters/base.py +217 -0
  34. as_agreed-0.0.1/src/as_agreed/adapters/langgraph.py +378 -0
  35. as_agreed-0.0.1/src/as_agreed/adapters/plain.py +75 -0
  36. as_agreed-0.0.1/src/as_agreed/adapters/temporal.py +339 -0
  37. as_agreed-0.0.1/src/as_agreed/check.py +401 -0
  38. as_agreed-0.0.1/src/as_agreed/commitment.py +479 -0
  39. as_agreed-0.0.1/src/as_agreed/conformance/__init__.py +1979 -0
  40. as_agreed-0.0.1/src/as_agreed/demo.py +173 -0
  41. as_agreed-0.0.1/src/as_agreed/destination.py +70 -0
  42. as_agreed-0.0.1/src/as_agreed/draw_flow.py +169 -0
  43. as_agreed-0.0.1/src/as_agreed/drift.py +778 -0
  44. as_agreed-0.0.1/src/as_agreed/errors.py +49 -0
  45. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/01-order.md +4 -0
  46. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/02-research.md +6 -0
  47. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/03-commit-retry.json +7 -0
  48. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/03-commit.json +6 -0
  49. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/03-commit.md +5 -0
  50. as_agreed-0.0.1/src/as_agreed/examples/planted-failure/commitments.json +22 -0
  51. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/01-order.md +3 -0
  52. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/02-research.md +5 -0
  53. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/03-commit-retry.json +6 -0
  54. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/03-commit.json +6 -0
  55. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/03-commit.md +4 -0
  56. as_agreed-0.0.1/src/as_agreed/examples/planted-widened/commitments.json +11 -0
  57. as_agreed-0.0.1/src/as_agreed/flowsvg.py +337 -0
  58. as_agreed-0.0.1/src/as_agreed/hold.py +160 -0
  59. as_agreed-0.0.1/src/as_agreed/importers/__init__.py +2 -0
  60. as_agreed-0.0.1/src/as_agreed/importers/stages.py +225 -0
  61. as_agreed-0.0.1/src/as_agreed/ledger.py +563 -0
  62. as_agreed-0.0.1/src/as_agreed/match.py +49 -0
  63. as_agreed-0.0.1/src/as_agreed/reason.py +73 -0
  64. as_agreed-0.0.1/src/as_agreed/report.py +626 -0
  65. as_agreed-0.0.1/src/as_agreed/retry.py +21 -0
  66. as_agreed-0.0.1/src/as_agreed/sdk.py +444 -0
  67. as_agreed-0.0.1/src/as_agreed/serialise.py +147 -0
  68. as_agreed-0.0.1/src/as_agreed.egg-info/PKG-INFO +114 -0
  69. as_agreed-0.0.1/src/as_agreed.egg-info/SOURCES.txt +87 -0
  70. as_agreed-0.0.1/src/as_agreed.egg-info/dependency_links.txt +1 -0
  71. as_agreed-0.0.1/src/as_agreed.egg-info/entry_points.txt +2 -0
  72. as_agreed-0.0.1/src/as_agreed.egg-info/requires.txt +6 -0
  73. as_agreed-0.0.1/src/as_agreed.egg-info/top_level.txt +1 -0
  74. as_agreed-0.0.1/tests/test_adapter_langgraph.py +63 -0
  75. as_agreed-0.0.1/tests/test_adapter_temporal.py +211 -0
  76. as_agreed-0.0.1/tests/test_conformance.py +97 -0
  77. as_agreed-0.0.1/tests/test_destination.py +120 -0
  78. as_agreed-0.0.1/tests/test_examples.py +38 -0
  79. as_agreed-0.0.1/tests/test_gate.py +280 -0
  80. as_agreed-0.0.1/tests/test_integrity.py +413 -0
  81. as_agreed-0.0.1/tests/test_lexicon.py +38 -0
  82. as_agreed-0.0.1/tests/test_map.py +181 -0
  83. as_agreed-0.0.1/tests/test_no_network.py +85 -0
  84. as_agreed-0.0.1/tests/test_packaged_fixtures.py +33 -0
  85. as_agreed-0.0.1/tests/test_site.py +114 -0
  86. as_agreed-0.0.1/tests/test_stages.py +314 -0
  87. as_agreed-0.0.1/tests/test_surface.py +53 -0
  88. as_agreed-0.0.1/tests/test_trace_items.py +501 -0
  89. as_agreed-0.0.1/tests/test_vocabulary.py +85 -0
@@ -0,0 +1,13 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software or its readings, please cite it as below."
3
+ type: software
4
+ title: "As-Agreed"
5
+ abstract: "As-Agreed checks each step of a pipeline against what was agreed. Before the last step writes its result, As-Agreed compares each declared field with the agreed record. If a field of a MUST or MUST_NOT commitment changed, As-Agreed stops that step. It tells you which field changed, and at which step. The record is a file on your disk. A test gives an error if the code imports a known network module."
6
+ authors:
7
+ - family-names: "Motin"
8
+ given-names: "Yuriy"
9
+ orcid: "https://orcid.org/0009-0003-4152-0328"
10
+ affiliation: "BizBuilder, Inc."
11
+ repository-code: "https://github.com/as-agreed/as-agreed"
12
+ license: "Apache-2.0"
13
+ version: "0.0.1"
@@ -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,5 @@
1
+ include NOTICE CITATION.cff SEND-A-MAP.md ledger.py draw_flow.py
2
+ graft examples
3
+ graft readings
4
+ graft tests
5
+ global-exclude __pycache__ *.py[cod] ledger.jsonl .DS_Store
as_agreed-0.0.1/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ As-Agreed
2
+ Copyright 2026 BizBuilder, Inc.
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: as-agreed
3
+ Version: 0.0.1
4
+ Summary: Checks each step of a pipeline against what was agreed, and stops the last step if a declared field changed.
5
+ Author: BizBuilder, Inc.
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/as-agreed/as-agreed
8
+ Project-URL: Issues, https://github.com/as-agreed/as-agreed/issues
9
+ Keywords: ai-agents,multi-agent-systems,agent-reliability,provenance,handoff,llm,local-first
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: NOTICE
19
+ Provides-Extra: langgraph
20
+ Requires-Dist: langgraph>=1.2; extra == "langgraph"
21
+ Provides-Extra: temporal
22
+ Requires-Dist: temporalio>=1.35; extra == "temporal"
23
+ Dynamic: license-file
24
+
25
+ # As-Agreed
26
+
27
+ **What you agreed is what arrives.**
28
+
29
+ As-Agreed checks each step of a pipeline against what was agreed. It stops the last step if a must term changed.
30
+
31
+ In a multi-agent system, agents give work to agents, and at each hand-off a term you agreed can change. As-Agreed keeps the record of what was agreed, and names the hand-off where a declared term changed.
32
+
33
+ Before the last step writes its result, As-Agreed compares each declared field with the agreed record. If a field of a `MUST` or `MUST_NOT` commitment changed, As-Agreed stops that step. It tells you which field changed, and at which step.
34
+
35
+ The record is a file on your disk. The test [`tests/test_no_network.py`](https://github.com/as-agreed/as-agreed/blob/main/tests/test_no_network.py) gives an error if the code imports a known network module.
36
+
37
+ ## Run the demo
38
+
39
+ ```
40
+ git clone https://github.com/as-agreed/as-agreed
41
+ cd as-agreed
42
+ PYTHONPATH=src python3 -m as_agreed demo --no-retry
43
+ ```
44
+
45
+ You must have Python 3.9 or higher. You do not install a package, and you do not use an account. The last line of the demo shows how much time it used.
46
+
47
+ ## What you see
48
+
49
+ The order sets a limit: "up to 18,400 dollars". The output for the payment system has 19,800. All the types are correct, thus the schema check passes. As-Agreed stops the step, and the code does not call the payment system. The demo above shows these lines:
50
+
51
+ ```
52
+ commit#1@1 schema amount: float ok | po: str ok | approved: bool ok -> schema: PASS
53
+ commitment pay-invoice limit.amount WIDENED 19800 where at most 18400 USD was agreed
54
+ claim [flat] words only, no status PRESERVED "Pay the October invoice from Northwind Freight, up to 18,400 dollars, only if it mat"
55
+ gate: HOLD (1 reason(s)) outputs discarded; the payment system was never called code 1
56
+ ```
57
+
58
+ A commitment line compares one declared field. Here, the field `limit.amount` is `WIDENED`. A claim line compares the status of a claim: a hedge, a source, a date, or "not found". It does not compare numbers. Thus the claim of the order arrives (`PRESERVED`), but its limit does not arrive (`WIDENED`).
59
+
60
+ Without `--no-retry`, the demo sends the reason back to the step one time. The next output comes from a file, not from a model, and it passes. With `--fixture dropped`, the agreed commitment `phone-check` does not arrive (`DROPPED`).
61
+
62
+ ## Use it in your code
63
+
64
+ ```python
65
+ import as_agreed.sdk as aa
66
+
67
+ agreed = aa.register("Pay the invoice, up to 18,400 dollars.", [{
68
+ "commitment_id": "pay", "act": "pay the invoice", "obligor": "finance", "obligee": "vendor",
69
+ "modality": "MUST", "limit": {"amount": {"max": 18400, "unit": "USD"}},
70
+ "carried_by": {"limit.amount": "amount"}}])
71
+
72
+ def pay(note, *, idempotency_key):
73
+ print("paid", note["amount"])
74
+
75
+ @aa.step("commit", agreed, commit=pay)
76
+ def prepare(text, reason=None):
77
+ return {"amount": 19800.0}
78
+
79
+ prepare("Pay 19,800 dollars.") # raises DriftHold: limit.amount WIDENED; pay() is not called
80
+ ```
81
+
82
+ Run this code from the clone with `PYTHONPATH=src`. A commitment must have 4 fields: `act`, `obligor`, `obligee` and `modality`. The fields `condition`, `limit`, `deadline` and `acceptance_criteria` are optional. The key `carried_by` tells As-Agreed which output key holds a field. The step gets the reason in `reason`, and it runs one more time. If the next output also breaks the limit, As-Agreed stops the step. The record goes to `ledger.jsonl` in the folder where you start Python.
83
+
84
+ ## The text gate
85
+
86
+ For text files, `ledger.py` checks that each claim keeps its status from one stage to the next. Put one file for each stage in a folder, in sequence. Mark each line that must arrive with `[!]` before its full stop. In the example below, a line that must arrive does not arrive (`DROPPED!`). The claim "probably allows early payment" arrives as "allows early payment" (`DANGER`). Thus the run exits with a code that is not 0, and it can stop the next step. It also writes `ledger.jsonl` and `flow.svg`, which shows each claim at each stage.
87
+
88
+ ```
89
+ python3 ledger.py run examples/planted-failure --against-all --only hedged,not_found,sourced,dated,must --fail-on danger,dropped_must
90
+ ```
91
+
92
+ ![The flow picture of the planted-failure example](https://raw.githubusercontent.com/as-agreed/as-agreed/main/examples/planted-failure/flow.svg)
93
+
94
+ ## Its limits
95
+
96
+ It compares only the fields that you declare, and it does not read a field from text.
97
+
98
+ ## Where this goes
99
+
100
+ Version 0.2 will read traces from the tools that you use, thus you will not write stage files. After that, an As-Agreed service will keep one record for all your pipelines. To use that service, you will change one value in your code: `destination=`. All other code stays the same.
101
+
102
+ ## Tests
103
+
104
+ ```
105
+ python3 -m unittest discover -s tests
106
+ ```
107
+
108
+ ## Licence
109
+
110
+ The code is under the Apache-2.0 licence ([LICENSE](https://github.com/as-agreed/as-agreed/blob/main/LICENSE), [NOTICE](https://github.com/as-agreed/as-agreed/blob/main/NOTICE)), copyright BizBuilder, Inc. The files in `readings/` are under CC BY 4.0. A change that you send must have a DCO sign-off (`git commit -s`).
111
+
112
+ ## Help
113
+
114
+ Write to hello@bizbuilderai.com. To send the map of your pipeline without its data, read [SEND-A-MAP.md](https://github.com/as-agreed/as-agreed/blob/main/SEND-A-MAP.md).
@@ -0,0 +1,90 @@
1
+ # As-Agreed
2
+
3
+ **What you agreed is what arrives.**
4
+
5
+ As-Agreed checks each step of a pipeline against what was agreed. It stops the last step if a must term changed.
6
+
7
+ In a multi-agent system, agents give work to agents, and at each hand-off a term you agreed can change. As-Agreed keeps the record of what was agreed, and names the hand-off where a declared term changed.
8
+
9
+ Before the last step writes its result, As-Agreed compares each declared field with the agreed record. If a field of a `MUST` or `MUST_NOT` commitment changed, As-Agreed stops that step. It tells you which field changed, and at which step.
10
+
11
+ The record is a file on your disk. The test [`tests/test_no_network.py`](https://github.com/as-agreed/as-agreed/blob/main/tests/test_no_network.py) gives an error if the code imports a known network module.
12
+
13
+ ## Run the demo
14
+
15
+ ```
16
+ git clone https://github.com/as-agreed/as-agreed
17
+ cd as-agreed
18
+ PYTHONPATH=src python3 -m as_agreed demo --no-retry
19
+ ```
20
+
21
+ You must have Python 3.9 or higher. You do not install a package, and you do not use an account. The last line of the demo shows how much time it used.
22
+
23
+ ## What you see
24
+
25
+ The order sets a limit: "up to 18,400 dollars". The output for the payment system has 19,800. All the types are correct, thus the schema check passes. As-Agreed stops the step, and the code does not call the payment system. The demo above shows these lines:
26
+
27
+ ```
28
+ commit#1@1 schema amount: float ok | po: str ok | approved: bool ok -> schema: PASS
29
+ commitment pay-invoice limit.amount WIDENED 19800 where at most 18400 USD was agreed
30
+ claim [flat] words only, no status PRESERVED "Pay the October invoice from Northwind Freight, up to 18,400 dollars, only if it mat"
31
+ gate: HOLD (1 reason(s)) outputs discarded; the payment system was never called code 1
32
+ ```
33
+
34
+ A commitment line compares one declared field. Here, the field `limit.amount` is `WIDENED`. A claim line compares the status of a claim: a hedge, a source, a date, or "not found". It does not compare numbers. Thus the claim of the order arrives (`PRESERVED`), but its limit does not arrive (`WIDENED`).
35
+
36
+ Without `--no-retry`, the demo sends the reason back to the step one time. The next output comes from a file, not from a model, and it passes. With `--fixture dropped`, the agreed commitment `phone-check` does not arrive (`DROPPED`).
37
+
38
+ ## Use it in your code
39
+
40
+ ```python
41
+ import as_agreed.sdk as aa
42
+
43
+ agreed = aa.register("Pay the invoice, up to 18,400 dollars.", [{
44
+ "commitment_id": "pay", "act": "pay the invoice", "obligor": "finance", "obligee": "vendor",
45
+ "modality": "MUST", "limit": {"amount": {"max": 18400, "unit": "USD"}},
46
+ "carried_by": {"limit.amount": "amount"}}])
47
+
48
+ def pay(note, *, idempotency_key):
49
+ print("paid", note["amount"])
50
+
51
+ @aa.step("commit", agreed, commit=pay)
52
+ def prepare(text, reason=None):
53
+ return {"amount": 19800.0}
54
+
55
+ prepare("Pay 19,800 dollars.") # raises DriftHold: limit.amount WIDENED; pay() is not called
56
+ ```
57
+
58
+ Run this code from the clone with `PYTHONPATH=src`. A commitment must have 4 fields: `act`, `obligor`, `obligee` and `modality`. The fields `condition`, `limit`, `deadline` and `acceptance_criteria` are optional. The key `carried_by` tells As-Agreed which output key holds a field. The step gets the reason in `reason`, and it runs one more time. If the next output also breaks the limit, As-Agreed stops the step. The record goes to `ledger.jsonl` in the folder where you start Python.
59
+
60
+ ## The text gate
61
+
62
+ For text files, `ledger.py` checks that each claim keeps its status from one stage to the next. Put one file for each stage in a folder, in sequence. Mark each line that must arrive with `[!]` before its full stop. In the example below, a line that must arrive does not arrive (`DROPPED!`). The claim "probably allows early payment" arrives as "allows early payment" (`DANGER`). Thus the run exits with a code that is not 0, and it can stop the next step. It also writes `ledger.jsonl` and `flow.svg`, which shows each claim at each stage.
63
+
64
+ ```
65
+ python3 ledger.py run examples/planted-failure --against-all --only hedged,not_found,sourced,dated,must --fail-on danger,dropped_must
66
+ ```
67
+
68
+ ![The flow picture of the planted-failure example](https://raw.githubusercontent.com/as-agreed/as-agreed/main/examples/planted-failure/flow.svg)
69
+
70
+ ## Its limits
71
+
72
+ It compares only the fields that you declare, and it does not read a field from text.
73
+
74
+ ## Where this goes
75
+
76
+ Version 0.2 will read traces from the tools that you use, thus you will not write stage files. After that, an As-Agreed service will keep one record for all your pipelines. To use that service, you will change one value in your code: `destination=`. All other code stays the same.
77
+
78
+ ## Tests
79
+
80
+ ```
81
+ python3 -m unittest discover -s tests
82
+ ```
83
+
84
+ ## Licence
85
+
86
+ The code is under the Apache-2.0 licence ([LICENSE](https://github.com/as-agreed/as-agreed/blob/main/LICENSE), [NOTICE](https://github.com/as-agreed/as-agreed/blob/main/NOTICE)), copyright BizBuilder, Inc. The files in `readings/` are under CC BY 4.0. A change that you send must have a DCO sign-off (`git commit -s`).
87
+
88
+ ## Help
89
+
90
+ Write to hello@bizbuilderai.com. To send the map of your pipeline without its data, read [SEND-A-MAP.md](https://github.com/as-agreed/as-agreed/blob/main/SEND-A-MAP.md).
@@ -0,0 +1,21 @@
1
+ # Send the map, not the data
2
+
3
+ If you run a pipeline of agents, you can see where its claims lose their status without showing anyone your text. Draw the map on your own machine and send only the picture. We would be glad to see it.
4
+
5
+ ## How
6
+ 1. Put one file per step of your pipeline in a folder, named in order: `01-order.md`, `02-research.md`, `03-summary.md`, and so on.
7
+ 2. In the first file, mark with `[!]` each sentence that must reach the end, just before its full stop.
8
+ 3. From this repository, run:
9
+
10
+ ```
11
+ python3 ledger.py run path/to/your-folder --against-all --only hedged,not_found,sourced,dated,must --fail-on danger,dropped_must
12
+ ```
13
+
14
+ 4. Open `flow.svg` in that folder. It holds no claim text, but it does hold your folder's name as its title, your file names as stage names, and the time it was drawn. Rename the files (the stage names and the picture's tooltips come from them), rename the folder or add `--title "my pipeline"` to the command, and look at the picture before you send it.
15
+ 5. Open an issue here with the "Send a map" template and attach the SVG. Tell us the shape of the pipeline (a hub with helpers, a line of stages, a mesh) and the engine, if there is one. An issue is public, so post only a map you are happy to show; to send one privately, write to hello@bizbuilderai.com.
16
+
17
+ ## What happens to it
18
+ Each map is read for one thing: where, in pipelines shaped like yours, claims kept or lost their status, and whether the must-travel sentences arrived. Maps are compared only as counts, by pipeline shape. Ask, and a map you sent is taken out.
19
+
20
+ ## Why the picture is enough
21
+ The question is where the status of a claim falls off, not what your pipeline says. The map answers it with counts per step, so your data stays where it is.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python3
2
+ """Draw a status-flow SVG from any per-claim CSV, from a clone: `python3 draw_flow.py claims.csv --stages ...`.
3
+
4
+ The code and its options are in `src/as_agreed/draw_flow.py` (`python3 draw_flow.py --help`).
5
+ """
6
+ import os
7
+ import sys
8
+
9
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "src"))
10
+
11
+ from as_agreed.draw_flow import main # noqa: E402
12
+
13
+ if __name__ == "__main__":
14
+ main()
@@ -0,0 +1,8 @@
1
+ # Research notes before the call (illustrative text, not data from any system)
2
+
3
+ The company moved its billing to a usage-based model in March 2026, according to the pricing page.
4
+ Their head of operations is likely the decision maker, but this is not confirmed by any public source.
5
+ We could not find a published SLA for the enterprise tier.
6
+ The onboarding team has twelve people as of 2026-09-30 per the careers page.
7
+ Support is handled in-house; there is no evidence of an outsourced provider.
8
+ The last funding round closed in 2025 at approximately 40 million.
@@ -0,0 +1,8 @@
1
+ Hello,
2
+
3
+ Since you moved billing to a usage-based model in March, the operations side is where our work applies.
4
+ Your head of operations is the decision maker on this, so I am writing to you directly.
5
+ There is no SLA for the enterprise tier, which is where the risk sits.
6
+ Your onboarding team has twelve people, and support is in-house.
7
+
8
+ Would a twenty-minute call next week suit?
@@ -0,0 +1,25 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1500" height="720" viewBox="0 0 1500 720" font-family="Helvetica, Arial, sans-serif">
2
+ <rect width="1500" height="720" fill="#ffffff"/>
3
+ <style>.lbl{font-size:13px;fill:#222}.sub{font-size:11px;fill:#666}.hdr{font-size:14px;font-weight:600;fill:#222}.ttl{font-size:20px;font-weight:600;fill:#111}.stt{font-size:13px;fill:#444}.fn{font-size:11px;fill:#555}path.rib:hover{opacity:0.95}</style>
4
+ <text class="ttl" x="230" y="34">Where did the claims go? hello</text>
5
+ <text class="stt" x="230" y="56">Binary per claim per hop. Ribbon colour = what the claim carried at origin; red = hardened, or a must-travel claim dropped. Counts only.</text>
6
+ <text class="hdr" x="239.0" y="88" text-anchor="middle">claims at 'research'</text>
7
+ <text class="hdr" x="1231.0" y="88" text-anchor="middle">at 'email'</text>
8
+ <path class="rib" d="M248.0,439.0 C735.0,439.0 735.0,110.0 1222.0,110.0 L1222.0,264.0 C735.0,264.0 735.0,593.0 248.0,593.0 Z" fill="#6f9f6f" fill-opacity="0.55" stroke="none"><title>o::flat -&gt; email::changed (flat): 2</title></path>
9
+ <path class="rib" d="M248.0,117.0 C735.0,117.0 735.0,278.0 1222.0,278.0 L1222.0,432.0 C735.0,432.0 735.0,271.0 248.0,271.0 Z" fill="#c0392b" fill-opacity="0.55" stroke="none"><title>o::hedged -&gt; email::danger (hedged): 2</title></path>
10
+ <path class="rib" d="M248.0,271.0 C735.0,271.0 735.0,446.0 1222.0,446.0 L1222.0,600.0 C735.0,600.0 735.0,425.0 248.0,425.0 Z" fill="#e5862e" fill-opacity="0.55" stroke="none"><title>o::hedged -&gt; email::dropped (hedged): 2</title></path>
11
+ <rect x="230.0" y="117.0" width="18" height="308.0" fill="#e5862e" stroke="#333" stroke-width="0.8"><title>hedged: 4</title></rect>
12
+ <rect x="230.0" y="439.0" width="18" height="154.0" fill="#6f9f6f" stroke="#333" stroke-width="0.8"><title>stated flat: 2</title></rect>
13
+ <text class="lbl" x="220.0" y="275.0" text-anchor="end">hedged <tspan font-weight="600">4</tspan></text>
14
+ <text class="lbl" x="220.0" y="520.0" text-anchor="end">stated flat <tspan font-weight="600">2</tspan></text>
15
+ <rect x="1222.0" y="110.0" width="18" height="154.0" fill="#d98c5f" stroke="#333" stroke-width="0.8"><title>present, status changed: 2</title></rect>
16
+ <rect x="1222.0" y="278.0" width="18" height="154.0" fill="#c0392b" stroke="#c0392b" stroke-width="2.5"><title>hardened or inverted: 2</title></rect>
17
+ <rect x="1222.0" y="446.0" width="18" height="154.0" fill="#9a9a9a" stroke="#333" stroke-width="0.8"><title>dropped: 2</title></rect>
18
+ <text class="lbl" x="1250.0" y="191.0" text-anchor="start"><tspan font-weight="600">2</tspan> present, status changed</text>
19
+ <text class="lbl" x="1250.0" y="359.0" text-anchor="start" style="fill:#c0392b;font-weight:700"><tspan font-weight="600">2</tspan> hardened or inverted</text>
20
+ <text class="lbl" x="1250.0" y="519.0" text-anchor="start"><tspan font-weight="600">2</tspan> dropped</text>
21
+ <text class="sub" x="1250.0" y="535.0" text-anchor="start">flow stops here</text>
22
+ <text class="fn" x="230" y="628">6 claims, 1 hop(s). Matching: explicit [c:id] tags, else a third of content words (at least two; two thirds for a must-travel claim) on one line, else a 60-character substring.</text>
23
+ <text class="fn" x="230" y="646">Paraphrase and translation are missed, and a line sharing enough words can pass for a claim, so 'dropped' and 'present' are approximate.</text>
24
+ <text class="fn" x="230" y="664">Generated 2026-11-04T21:25:14Z by ledger.py; no claim text in this file.</text>
25
+ </svg>
@@ -0,0 +1,4 @@
1
+ # 01, the order (illustrative text, not data from any system)
2
+
3
+ Pay the October invoice from Northwind Freight only if it matches purchase order 4471.
4
+ Finance must confirm the vendor's new bank details by phone before any payment [!].
@@ -0,0 +1,6 @@
1
+ # 02, what the research agent found (illustrative text, not data from any system)
2
+
3
+ The invoice total is 18,400 dollars, per the invoice PDF.
4
+ Purchase order 4471 lists 18,400 dollars, per the procurement export of 2026-10-27.
5
+ The vendor changed its bank details on 2026-10-20, so finance must confirm the vendor's new bank details by phone before any payment.
6
+ The contract probably allows early payment, but clause 7.2 was not found in the copy we have.
@@ -0,0 +1,7 @@
1
+ {
2
+ "amount": 18400.0,
3
+ "po": "4471",
4
+ "approved": true,
5
+ "phone_confirmed": true,
6
+ "note": "Invoice matches purchase order 4471 at 18,400 dollars, per the procurement export of 2026-10-27. Finance must confirm the vendor's new bank details by phone before any payment. The contract probably allows early payment, but clause 7.2 was not found in the copy we have. Approved for early payment today."
7
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "amount": 18400.0,
3
+ "po": "4471",
4
+ "approved": true,
5
+ "note": "Invoice matches purchase order 4471 at 18,400 dollars. The contract allows early payment under clause 7.2. Approved for early payment today."
6
+ }
@@ -0,0 +1,5 @@
1
+ # 03, the note that goes to the payment system (illustrative text, not data from any system)
2
+
3
+ Invoice matches purchase order 4471 at 18,400 dollars.
4
+ The contract allows early payment under clause 7.2.
5
+ Approved for early payment today.
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "commitment_id": "pay-invoice",
4
+ "act": "pay the October invoice from Northwind Freight",
5
+ "obligor": "finance-ops",
6
+ "obligee": "northwind-freight",
7
+ "modality": "MUST",
8
+ "condition": {"po": "4471"},
9
+ "carried_by": {"condition.po": "po"}
10
+ },
11
+ {
12
+ "commitment_id": "phone-check",
13
+ "act": "confirm the vendor's new bank details by phone before any payment",
14
+ "obligor": "finance-ops",
15
+ "obligee": "controller",
16
+ "modality": "MUST",
17
+ "acceptance_criteria": [
18
+ {"criterion_id": "phone", "text": "the vendor's new bank details are confirmed by phone",
19
+ "verification": "machine_checkable", "field": "phone_confirmed", "equals": true}
20
+ ]
21
+ }
22
+ ]
@@ -0,0 +1,34 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1500" height="720" viewBox="0 0 1500 720" font-family="Helvetica, Arial, sans-serif">
2
+ <rect width="1500" height="720" fill="#ffffff"/>
3
+ <style>.lbl{font-size:13px;fill:#222}.sub{font-size:11px;fill:#666}.hdr{font-size:14px;font-weight:600;fill:#222}.ttl{font-size:20px;font-weight:600;fill:#111}.stt{font-size:13px;fill:#444}.fn{font-size:11px;fill:#555}path.rib:hover{opacity:0.95}</style>
4
+ <text class="ttl" x="230" y="34">Where did the claims go? planted-failure</text>
5
+ <text class="stt" x="230" y="56">Binary per claim per hop. Ribbon colour = what the claim carried at origin; red = hardened, or a must-travel claim dropped. Counts only.</text>
6
+ <text class="hdr" x="239.0" y="72" text-anchor="middle">claims where first</text>
7
+ <text class="hdr" x="239.0" y="88" text-anchor="middle">registered</text>
8
+ <text class="hdr" x="735.0" y="88" text-anchor="middle">at 'research'</text>
9
+ <text class="hdr" x="1231.0" y="88" text-anchor="middle">at 'commit'</text>
10
+ <path class="rib" d="M248.0,227.6 C487.0,227.6 487.0,310.2 726.0,310.2 L726.0,399.8 C487.0,399.8 487.0,317.2 248.0,317.2 Z" fill="#6f9f6f" fill-opacity="0.55" stroke="none"><title>o::flat -&gt; research::preserved (flat): 1</title></path>
11
+ <path class="rib" d="M744.0,310.2 C983.0,310.2 983.0,406.8 1222.0,406.8 L1222.0,496.4 C983.0,496.4 983.0,399.8 744.0,399.8 Z" fill="#c0392b" fill-opacity="0.55" stroke="none"><title>research::preserved -&gt; commit::lost (flat): 1</title></path>
12
+ <path class="rib" d="M248.0,317.2 C735.0,317.2 735.0,110.0 1222.0,110.0 L1222.0,289.2 C735.0,289.2 735.0,496.4 248.0,496.4 Z" fill="#6f9f6f" fill-opacity="0.55" stroke="none"><title>o::flat -&gt; commit::changed (flat): 2</title></path>
13
+ <path class="rib" d="M248.0,496.4 C735.0,496.4 735.0,510.4 1222.0,510.4 L1222.0,600.0 C735.0,600.0 735.0,586.0 248.0,586.0 Z" fill="#6f9f6f" fill-opacity="0.55" stroke="none"><title>o::flat -&gt; commit::dropped (flat): 1</title></path>
14
+ <path class="rib" d="M248.0,124.0 C735.0,124.0 735.0,303.2 1222.0,303.2 L1222.0,392.8 C735.0,392.8 735.0,213.6 248.0,213.6 Z" fill="#c0392b" fill-opacity="0.55" stroke="none"><title>o::hedged -&gt; commit::danger (hedged): 1</title></path>
15
+ <rect x="230.0" y="124.0" width="18" height="89.6" fill="#e5862e" stroke="#333" stroke-width="0.8"><title>hedged: 1</title></rect>
16
+ <rect x="230.0" y="227.6" width="18" height="358.4" fill="#6f9f6f" stroke="#333" stroke-width="0.8"><title>stated flat: 4</title></rect>
17
+ <text class="lbl" x="220.0" y="172.8" text-anchor="end">hedged <tspan font-weight="600">1</tspan></text>
18
+ <text class="lbl" x="220.0" y="410.8" text-anchor="end">stated flat <tspan font-weight="600">4</tspan></text>
19
+ <rect x="726.0" y="310.2" width="18" height="89.6" fill="#5b8c5a" stroke="#333" stroke-width="0.8"><title>present, status preserved: 1</title></rect>
20
+ <text class="lbl" x="754.0" y="359.0" text-anchor="start"><tspan font-weight="600">1</tspan> present, status preserved</text>
21
+ <rect x="1222.0" y="110.0" width="18" height="179.2" fill="#d98c5f" stroke="#333" stroke-width="0.8"><title>present, status changed: 2</title></rect>
22
+ <rect x="1222.0" y="303.2" width="18" height="89.6" fill="#c0392b" stroke="#c0392b" stroke-width="2.5"><title>hardened or inverted: 1</title></rect>
23
+ <rect x="1222.0" y="406.8" width="18" height="89.6" fill="#c0392b" stroke="#c0392b" stroke-width="2.5"><title>dropped, must-travel: 1</title></rect>
24
+ <rect x="1222.0" y="510.4" width="18" height="89.6" fill="#9a9a9a" stroke="#333" stroke-width="0.8"><title>dropped: 1</title></rect>
25
+ <text class="lbl" x="1250.0" y="203.6" text-anchor="start"><tspan font-weight="600">2</tspan> present, status changed</text>
26
+ <text class="lbl" x="1250.0" y="352.0" text-anchor="start" style="fill:#c0392b;font-weight:700"><tspan font-weight="600">1</tspan> hardened or inverted</text>
27
+ <text class="lbl" x="1250.0" y="447.6" text-anchor="start" style="fill:#c0392b;font-weight:700"><tspan font-weight="600">1</tspan> dropped, must-travel</text>
28
+ <text class="sub" x="1250.0" y="463.6" text-anchor="start">flow stops here</text>
29
+ <text class="lbl" x="1250.0" y="551.2" text-anchor="start"><tspan font-weight="600">1</tspan> dropped</text>
30
+ <text class="sub" x="1250.0" y="567.2" text-anchor="start">flow stops here</text>
31
+ <text class="fn" x="230" y="628">5 claims, 2 hop(s). Matching: explicit [c:id] tags, else a third of content words (at least two; two thirds for a must-travel claim) on one line, else a 60-character substring.</text>
32
+ <text class="fn" x="230" y="646">Paraphrase and translation are missed, and a line sharing enough words can pass for a claim, so 'dropped' and 'present' are approximate.</text>
33
+ <text class="fn" x="230" y="664">Generated 2026-11-04T21:25:15Z by ledger.py; no claim text in this file.</text>
34
+ </svg>
@@ -0,0 +1,3 @@
1
+ # 01, the order (illustrative text, not data from any system)
2
+
3
+ Pay the October invoice from Northwind Freight, up to 18,400 dollars, only if it matches purchase order 4471.
@@ -0,0 +1,5 @@
1
+ # 02, what the research agent found (illustrative text, not data from any system)
2
+
3
+ The invoice total is 18,400 dollars, per the invoice PDF.
4
+ Purchase order 4471 lists 18,400 dollars, per the procurement export of 2026-10-27.
5
+ The vendor's statement adds a fuel surcharge of 1,400 dollars that purchase order 4471 does not list.