valgebra-planning 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 (74) hide show
  1. valgebra_planning-0.0.1/.gitignore +14 -0
  2. valgebra_planning-0.0.1/CHANGELOG.md +48 -0
  3. valgebra_planning-0.0.1/LICENSE-APACHE +202 -0
  4. valgebra_planning-0.0.1/LICENSE-MIT +21 -0
  5. valgebra_planning-0.0.1/PKG-INFO +92 -0
  6. valgebra_planning-0.0.1/README.md +63 -0
  7. valgebra_planning-0.0.1/docs/00-using.md +122 -0
  8. valgebra_planning-0.0.1/docs/01-method.md +227 -0
  9. valgebra_planning-0.0.1/docs/02-api.md +97 -0
  10. valgebra_planning-0.0.1/docs/03-code-mode.md +114 -0
  11. valgebra_planning-0.0.1/docs/04-results.md +51 -0
  12. valgebra_planning-0.0.1/docs/05-releasing.md +195 -0
  13. valgebra_planning-0.0.1/docs/10-writing.md +281 -0
  14. valgebra_planning-0.0.1/docs/11-references.md +100 -0
  15. valgebra_planning-0.0.1/docs/README.md +12 -0
  16. valgebra_planning-0.0.1/docs/studies/bench.json +185 -0
  17. valgebra_planning-0.0.1/docs/studies/parcels.json +166 -0
  18. valgebra_planning-0.0.1/examples/parcels/flows.json +11 -0
  19. valgebra_planning-0.0.1/examples/parcels/observed.json +91 -0
  20. valgebra_planning-0.0.1/examples/parcels/policies.json +23 -0
  21. valgebra_planning-0.0.1/examples/parcels/tasks.json +152 -0
  22. valgebra_planning-0.0.1/examples/parcels/tools.json +381 -0
  23. valgebra_planning-0.0.1/pyproject.toml +127 -0
  24. valgebra_planning-0.0.1/tests/parcel_server.py +63 -0
  25. valgebra_planning-0.0.1/tests/synthetic.py +47 -0
  26. valgebra_planning-0.0.1/tests/test_annotations.py +112 -0
  27. valgebra_planning-0.0.1/tests/test_api.py +130 -0
  28. valgebra_planning-0.0.1/tests/test_blame.py +94 -0
  29. valgebra_planning-0.0.1/tests/test_boundaries.py +34 -0
  30. valgebra_planning-0.0.1/tests/test_cells.py +129 -0
  31. valgebra_planning-0.0.1/tests/test_cli.py +119 -0
  32. valgebra_planning-0.0.1/tests/test_codemode.py +71 -0
  33. valgebra_planning-0.0.1/tests/test_contracts.py +181 -0
  34. valgebra_planning-0.0.1/tests/test_critic.py +188 -0
  35. valgebra_planning-0.0.1/tests/test_doc_examples.py +36 -0
  36. valgebra_planning-0.0.1/tests/test_docs_lint.py +105 -0
  37. valgebra_planning-0.0.1/tests/test_flows.py +261 -0
  38. valgebra_planning-0.0.1/tests/test_inference.py +96 -0
  39. valgebra_planning-0.0.1/tests/test_loops.py +210 -0
  40. valgebra_planning-0.0.1/tests/test_mining.py +79 -0
  41. valgebra_planning-0.0.1/tests/test_optional.py +103 -0
  42. valgebra_planning-0.0.1/tests/test_outcomes.py +155 -0
  43. valgebra_planning-0.0.1/tests/test_planner.py +105 -0
  44. valgebra_planning-0.0.1/tests/test_policy.py +228 -0
  45. valgebra_planning-0.0.1/tests/test_privilege.py +82 -0
  46. valgebra_planning-0.0.1/tests/test_proxy.py +172 -0
  47. valgebra_planning-0.0.1/tests/test_reachable.py +54 -0
  48. valgebra_planning-0.0.1/tests/test_run.py +204 -0
  49. valgebra_planning-0.0.1/tests/test_servers.py +187 -0
  50. valgebra_planning-0.0.1/tests/test_vacuity.py +134 -0
  51. valgebra_planning-0.0.1/tests/test_verify.py +137 -0
  52. valgebra_planning-0.0.1/tools/bench.py +115 -0
  53. valgebra_planning-0.0.1/tools/case.py +117 -0
  54. valgebra_planning-0.0.1/tools/docs_lint.py +458 -0
  55. valgebra_planning-0.0.1/valgebra_planning/__init__.py +10 -0
  56. valgebra_planning-0.0.1/valgebra_planning/_valgebra.py +65 -0
  57. valgebra_planning-0.0.1/valgebra_planning/cells.py +312 -0
  58. valgebra_planning-0.0.1/valgebra_planning/cli.py +312 -0
  59. valgebra_planning-0.0.1/valgebra_planning/codemode.py +132 -0
  60. valgebra_planning-0.0.1/valgebra_planning/contracts.py +265 -0
  61. valgebra_planning-0.0.1/valgebra_planning/critic.py +377 -0
  62. valgebra_planning-0.0.1/valgebra_planning/flows.py +75 -0
  63. valgebra_planning-0.0.1/valgebra_planning/library.py +103 -0
  64. valgebra_planning-0.0.1/valgebra_planning/mining.py +165 -0
  65. valgebra_planning-0.0.1/valgebra_planning/planner.py +703 -0
  66. valgebra_planning-0.0.1/valgebra_planning/policy.py +193 -0
  67. valgebra_planning-0.0.1/valgebra_planning/privilege.py +180 -0
  68. valgebra_planning-0.0.1/valgebra_planning/program.py +236 -0
  69. valgebra_planning-0.0.1/valgebra_planning/proxy.py +164 -0
  70. valgebra_planning-0.0.1/valgebra_planning/py.typed +0 -0
  71. valgebra_planning-0.0.1/valgebra_planning/run.py +268 -0
  72. valgebra_planning-0.0.1/valgebra_planning/servers.py +94 -0
  73. valgebra_planning-0.0.1/valgebra_planning/vacuity.py +186 -0
  74. valgebra_planning-0.0.1/valgebra_planning/verify.py +484 -0
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ build/
5
+ dist/
6
+ *.egg-info
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .hypothesis/
10
+ .vscode/
11
+ *.swp
12
+
13
+ # Local working notes and the paper shelf: third-party PDFs, never committed.
14
+ __DEV/
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ All notable changes to valgebra-planning are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project follows
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.1] - 2026-11-17
10
+
11
+ ### Added
12
+
13
+ - `read_contract` reads an MCP tool's `inputSchema` and `outputSchema`, through
14
+ valgebra-jsonschema, as argument and result slots, an optional output field held apart behind
15
+ a key test and an output that is not an object as one slot; `read_task` reads a task's inputs
16
+ and goal.
17
+ - `plan` searches a strong program of calls and type tests over the cells of every slot, input
18
+ and goal, or a weak one whose stops name the values they leave; a tool the goal cannot be
19
+ reached through is dropped first. `predicates` returns the list the cells are cut from.
20
+ - `verify` asks valgebra every link of a program alone, reading neither the cells nor the
21
+ search: each is proven, refuted with a value outside it, or undecided.
22
+ - `critique` reads a program written in Python against `stubs`, verifies it and names, for
23
+ each link not proven, the test, the order, the source or the error block it needs; `repair`
24
+ runs that loop with any callable as the model.
25
+ - A program is held to tool errors and to retries of read-only or idempotent tools, to
26
+ policies read as automata over calls (`policy`), to flow rules over where a value came from
27
+ (`flows`), to semantic types mined from observed calls (`mining`), and to privilege policies
28
+ in Progent's format (`privilege`). `vacuities` lists the specifications of a library that
29
+ hold vacuously.
30
+ - `run` runs a program failing closed on every argument record, policy step and result, and
31
+ `blame` names the cause of a break; `run_on_server` runs it against a live MCP server, a call
32
+ that asks for input failing as a tool error.
33
+ - `serve` puts an MCP proxy over stdio in front of a server, holding every call to the
34
+ contracts, policies and flow rules: its contract and policy checks hold whatever wrote the
35
+ call, and its flow rules read provenance by equality of values.
36
+ - The command line `valgebra-planning`: `plan`, `critique`, `stubs`, `check`, `privileges`,
37
+ `run` and `proxy`.
38
+ - Each public module's names are its `__all__`, listed on `docs/02-api.md`.
39
+ - The package requires valgebra 0.0.28 and below 0.0.29 and valgebra-jsonschema 0.0.1 and
40
+ below 0.0.2, since a `0.0.x` minor of either is a breaking release here, and Python 3.11 or
41
+ later; the `mcp` extra takes the MCP SDK 2.3 and below 3.
42
+ - Measured on this release, each figure in [`docs/04-results.md`](docs/04-results.md): on the
43
+ parcel library's eight tasks every link of every program is proven, 3 of 3 to 24 of 24, and
44
+ on synthetic libraries of 8 to 256 tools the cut holds 5 predicates and 12 cells at every
45
+ size.
46
+
47
+ [Unreleased]: https://github.com/ppigazzini/valgebra-planning/compare/v0.0.1...HEAD
48
+ [0.0.1]: https://github.com/ppigazzini/valgebra-planning/releases/tag/v0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pasquale Pigazzini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.5
2
+ Name: valgebra-planning
3
+ Version: 0.0.1
4
+ Summary: Plans of tool calls proven well-typed for every output the tool contracts admit, decided by valgebra's sets.
5
+ Project-URL: Repository, https://github.com/ppigazzini/valgebra-planning
6
+ Project-URL: Documentation, https://github.com/ppigazzini/valgebra-planning/tree/main/docs
7
+ Project-URL: Changelog, https://github.com/ppigazzini/valgebra-planning/blob/main/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/ppigazzini/valgebra-planning/issues
9
+ Author: Pasquale Pigazzini
10
+ License-Expression: MIT OR Apache-2.0
11
+ License-File: LICENSE-APACHE
12
+ License-File: LICENSE-MIT
13
+ Keywords: agents,json-schema,mcp,planning,valgebra,verification
14
+ Classifier: Development Status :: 2 - Pre-Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: valgebra-jsonschema<0.0.2,>=0.0.1
25
+ Requires-Dist: valgebra<0.0.29,>=0.0.28
26
+ Provides-Extra: mcp
27
+ Requires-Dist: mcp<3,>=2.3.0; extra == 'mcp'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # valgebra-planning
31
+
32
+ Plans of tool calls for agents, proven well-typed for every output the tool contracts admit.
33
+ A plan here is a program of calls and type tests on values, in the sense of strong planning
34
+ under nondeterministic outcomes: it is accepted only where each value it passes to a tool is
35
+ proven inside that tool's argument, whatever values inside their output schemas the tools
36
+ return. A program proposed elsewhere, by hand or by a language model, is verified the same
37
+ way, link by link.
38
+
39
+ It is part of the [valgebra](https://github.com/ppigazzini/valgebra) ecosystem.
40
+ [valgebra-jsonschema](https://github.com/ppigazzini/valgebra-jsonschema) reads each tool's
41
+ contract, the MCP `inputSchema` and `outputSchema`, into valgebra's sets, and valgebra decides
42
+ every inclusion a program rests on. Nothing here reads JSON Schema itself.
43
+
44
+ Status: pre-alpha.
45
+
46
+ ```bash
47
+ pip install valgebra-planning # Python 3.11 or later
48
+ pip install "valgebra-planning[mcp]" # with a live MCP server's tools, and the proxy
49
+ ```
50
+
51
+ ## What it does
52
+
53
+ | step | module |
54
+ |---|---|
55
+ | read each tool's contract as argument and result slots | `valgebra_planning/contracts.py` |
56
+ | cut the JSON values into the cells of every slot, input and goal | `valgebra_planning/cells.py` |
57
+ | search a strong program, or a weak one whose stops name what they leave | `valgebra_planning/planner.py` |
58
+ | verify every link of a program with valgebra alone | `valgebra_planning/verify.py` |
59
+ | read a program written in Python, verify it and critique it | `valgebra_planning/critic.py` |
60
+ | hold a program to tool errors, policies, flow rules and mined types | `planner.py`, `policy.py`, `flows.py`, `mining.py` |
61
+ | run a program, failing closed on every contract and policy | `valgebra_planning/run.py` |
62
+ | plan a library's tasks or critique a program from the command line | `valgebra_planning/cli.py` |
63
+ | read a live MCP server's tools and run a program against it (`mcp` extra) | `valgebra_planning/servers.py` |
64
+ | find the specifications of a library that hold vacuously | `valgebra_planning/vacuity.py` |
65
+ | read Progent's privilege policies as sets: narrowing, expansion, a program held to one | `valgebra_planning/privilege.py` |
66
+ | serve an MCP proxy holding every call to the contracts, policies and flow rules | `valgebra_planning/proxy.py` |
67
+ | give a model typed stubs, and repair its program with the critique | `valgebra_planning/codemode.py` |
68
+
69
+ [`docs/00-using.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/00-using.md)
70
+ shows the command line,
71
+ [`docs/02-api.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/02-api.md)
72
+ the Python names each module promises,
73
+ [`docs/03-code-mode.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/03-code-mode.md)
74
+ how a model's program is proven before it runs,
75
+ [`docs/01-method.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/01-method.md)
76
+ states the method and its limits, and
77
+ [`docs/04-results.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/04-results.md)
78
+ the studies: on a parcel-returns library of ten tools, eight tasks get programs whose every
79
+ link valgebra proves, from 3 of 3 to 24 of 24.
80
+
81
+ ## Prior work
82
+
83
+ The method starts from valplan
84
+ ([doi:10.5281/zenodo.23686600](https://doi.org/10.5281/zenodo.23686600)), predicate
85
+ abstraction over a Boolean algebra of JSON Schema sets with strong planning over the cells.
86
+ This package is written anew on the valgebra ecosystem and shares no code with it.
87
+
88
+ ## License
89
+
90
+ MIT OR Apache-2.0, at your option. See
91
+ [`LICENSE-MIT`](https://github.com/ppigazzini/valgebra-planning/blob/main/LICENSE-MIT) and
92
+ [`LICENSE-APACHE`](https://github.com/ppigazzini/valgebra-planning/blob/main/LICENSE-APACHE).
@@ -0,0 +1,63 @@
1
+ # valgebra-planning
2
+
3
+ Plans of tool calls for agents, proven well-typed for every output the tool contracts admit.
4
+ A plan here is a program of calls and type tests on values, in the sense of strong planning
5
+ under nondeterministic outcomes: it is accepted only where each value it passes to a tool is
6
+ proven inside that tool's argument, whatever values inside their output schemas the tools
7
+ return. A program proposed elsewhere, by hand or by a language model, is verified the same
8
+ way, link by link.
9
+
10
+ It is part of the [valgebra](https://github.com/ppigazzini/valgebra) ecosystem.
11
+ [valgebra-jsonschema](https://github.com/ppigazzini/valgebra-jsonschema) reads each tool's
12
+ contract, the MCP `inputSchema` and `outputSchema`, into valgebra's sets, and valgebra decides
13
+ every inclusion a program rests on. Nothing here reads JSON Schema itself.
14
+
15
+ Status: pre-alpha.
16
+
17
+ ```bash
18
+ pip install valgebra-planning # Python 3.11 or later
19
+ pip install "valgebra-planning[mcp]" # with a live MCP server's tools, and the proxy
20
+ ```
21
+
22
+ ## What it does
23
+
24
+ | step | module |
25
+ |---|---|
26
+ | read each tool's contract as argument and result slots | `valgebra_planning/contracts.py` |
27
+ | cut the JSON values into the cells of every slot, input and goal | `valgebra_planning/cells.py` |
28
+ | search a strong program, or a weak one whose stops name what they leave | `valgebra_planning/planner.py` |
29
+ | verify every link of a program with valgebra alone | `valgebra_planning/verify.py` |
30
+ | read a program written in Python, verify it and critique it | `valgebra_planning/critic.py` |
31
+ | hold a program to tool errors, policies, flow rules and mined types | `planner.py`, `policy.py`, `flows.py`, `mining.py` |
32
+ | run a program, failing closed on every contract and policy | `valgebra_planning/run.py` |
33
+ | plan a library's tasks or critique a program from the command line | `valgebra_planning/cli.py` |
34
+ | read a live MCP server's tools and run a program against it (`mcp` extra) | `valgebra_planning/servers.py` |
35
+ | find the specifications of a library that hold vacuously | `valgebra_planning/vacuity.py` |
36
+ | read Progent's privilege policies as sets: narrowing, expansion, a program held to one | `valgebra_planning/privilege.py` |
37
+ | serve an MCP proxy holding every call to the contracts, policies and flow rules | `valgebra_planning/proxy.py` |
38
+ | give a model typed stubs, and repair its program with the critique | `valgebra_planning/codemode.py` |
39
+
40
+ [`docs/00-using.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/00-using.md)
41
+ shows the command line,
42
+ [`docs/02-api.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/02-api.md)
43
+ the Python names each module promises,
44
+ [`docs/03-code-mode.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/03-code-mode.md)
45
+ how a model's program is proven before it runs,
46
+ [`docs/01-method.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/01-method.md)
47
+ states the method and its limits, and
48
+ [`docs/04-results.md`](https://github.com/ppigazzini/valgebra-planning/blob/main/docs/04-results.md)
49
+ the studies: on a parcel-returns library of ten tools, eight tasks get programs whose every
50
+ link valgebra proves, from 3 of 3 to 24 of 24.
51
+
52
+ ## Prior work
53
+
54
+ The method starts from valplan
55
+ ([doi:10.5281/zenodo.23686600](https://doi.org/10.5281/zenodo.23686600)), predicate
56
+ abstraction over a Boolean algebra of JSON Schema sets with strong planning over the cells.
57
+ This package is written anew on the valgebra ecosystem and shares no code with it.
58
+
59
+ ## License
60
+
61
+ MIT OR Apache-2.0, at your option. See
62
+ [`LICENSE-MIT`](https://github.com/ppigazzini/valgebra-planning/blob/main/LICENSE-MIT) and
63
+ [`LICENSE-APACHE`](https://github.com/ppigazzini/valgebra-planning/blob/main/LICENSE-APACHE).
@@ -0,0 +1,122 @@
1
+ # Using valgebra-planning
2
+
3
+ How to plan the tasks of a tool library, or check a program written for one, from the command
4
+ line. What each answer means is [01-method.md](01-method.md)'s.
5
+
6
+ ## A library
7
+
8
+ A library is a directory (`valgebra_planning/library.py` reads it):
9
+
10
+ | file | holds |
11
+ |---|---|
12
+ | `tools.json` | a server's `tools/list` result: `{"tools": [...]}`, each tool its `name`, `inputSchema`, and the `outputSchema` and `annotations` it declares; `"trusted": true` where the server's annotations are trusted |
13
+ | `tasks.json` | `{"tasks": [...]}`, each task a `name`, the JSON Schema of each value the agent starts with in `inputs`, the JSON Schema of the `goal`, and the rules it is held to: `errors` (any tool may fail), `policies` and `flows` by name, `types`, the file of observed calls its semantic types are mined from |
14
+ | `policies.json` | `{"policies": [...]}`, each an automaton over calls (`valgebra_planning/policy.py`): `initial`, the `bad` states no path may reach, the `pending` states no path may end in, and the `transitions` |
15
+ | `flows.json` | `{"flows": [...]}`, each a flow rule (`valgebra_planning/flows.py`) |
16
+ | a file `types` names | `{"calls": [...]}`, each an observed call: `tool`, `arguments`, `result`; a tool listed without an `outputSchema` gets one shaped from its results there, an assumption every binding resting on it names |
17
+
18
+ A tool without an `outputSchema` can be called, and nothing it returns can fill another call's
19
+ argument: its result is a set no argument is proven to hold. `examples/parcels` is a library
20
+ holding every file.
21
+
22
+ ## Plan
23
+
24
+ ```bash
25
+ uv run valgebra-planning plan examples/parcels --task "return a parcel"
26
+ ```
27
+
28
+ prints the program for each task (every task when no `--task` is given; `--task` repeats), whether
29
+ it is strong or weak, how many of its links valgebra proves, each link not proven, each value a
30
+ weak program's stops leave uncovered, and each binding resting on a mined type. With `--json` it
31
+ prints one JSON document, a list holding a row per task. The exit status is 1 when a task gets no
32
+ program.
33
+
34
+ ## Critique a program written elsewhere
35
+
36
+ ```bash
37
+ uv run valgebra-planning critique examples/parcels --task "return a parcel" program.py
38
+ ```
39
+
40
+ reads `program.py`, the Python an agent writes against typed tool APIs (`valgebra_planning/critic.py`
41
+ states what it reads), verifies every link under the rules the task names, and prints each link not
42
+ proven with the value that refutes it and what to change: the test that makes a call safe, the call
43
+ a policy needs first, the source a flow rule trusts, the error block a call needs. A binding crossing
44
+ two types the task's observed calls tell apart is a note, and decides nothing. The exit status is 0 when the program is
45
+ accepted, 1 when it is not, and 2 when the reader refuses its text.
46
+
47
+ ## Stubs for a model
48
+
49
+ ```bash
50
+ uv run valgebra-planning stubs examples/parcels
51
+ ```
52
+
53
+ prints the library's tools as Python stubs, after a preamble stating the language a program
54
+ uses: one function a tool, every argument by name, its docstring holding the tool's input and
55
+ output schemas. Hand them to a model to write a program against, then `critique` it; in Python,
56
+ `valgebra_planning.codemode.repair` runs that loop with any callable as the model.
57
+
58
+ ## Check a library
59
+
60
+ ```bash
61
+ uv run valgebra-planning check examples/parcels
62
+ ```
63
+
64
+ lists every specification in the library that holds vacuously, as
65
+ [01-method.md](01-method.md#specifications-that-hold-vacuously) defines them: a goal no value or
66
+ every value meets, a policy transition that never fires, a policy that can never be violated, a
67
+ flow rule that lets nothing or everything through, a rule no task is held to. A finding valgebra
68
+ leaves undecided is marked so. The exit status is 1 when it finds one.
69
+
70
+ ## Compare two privilege policies
71
+
72
+ ```bash
73
+ uv run valgebra-planning privileges old.json new.json
74
+ ```
75
+
76
+ reads two privilege policies in Progent's format, `{"tool": [[priority, effect, condition,
77
+ fallback], ...]}`, and prints for each tool the new one names whether it narrows the old one,
78
+ expands it, with a call it newly allows, or is left undecided. The exit status is 0 only when
79
+ every tool narrows. In Python, `valgebra_planning.privilege.as_policy` turns a policy into one the
80
+ planner, the verifier and the runner hold a program to.
81
+
82
+ ## A live server
83
+
84
+ With the `mcp` extra (`uv sync --extra mcp`, or `pip install "valgebra-planning[mcp]"`), `--server`
85
+ reads the tools from a live MCP server instead of `tools.json`: a URL connects over Streamable
86
+ HTTP, anything else is a command starting a server over stdio.
87
+
88
+ ```bash
89
+ uv run valgebra-planning plan examples/parcels --task "return a parcel" \
90
+ --server "uv run python tests/parcel_server.py"
91
+ uv run valgebra-planning run examples/parcels --task "settle a parcel" \
92
+ --inputs '{"tracking": "AB123456789IT"}' --server "uv run python tests/parcel_server.py"
93
+ ```
94
+
95
+ `run` plans the task over the server's tools and runs the program against the server
96
+ (`valgebra_planning/servers.py`): each call is a `tools/call`, its `structuredContent` the value
97
+ it returns, an `isError` result, a protocol error or a request for input a tool error, and the run
98
+ fails closed on any argument record, policy step or result outside its contract. It prints how the run ended, and the cause of a break (the
99
+ server, an assumption, or the program), and exits 1 unless it returned a value with no break.
100
+ `tests/parcel_server.py` serves the example's tools over stdio.
101
+
102
+ ## A proxy in front of a server
103
+
104
+ ```bash
105
+ uv run valgebra-planning proxy --server "uv run python tests/parcel_server.py" --library examples/parcels
106
+ ```
107
+
108
+ serves an MCP server over stdio, in front of `--server`, that lists its tools as they are and
109
+ answers a call only after holding it to the tool's contract, to every policy and flow rule the
110
+ library defines, and, the call made, its result to the output schema
111
+ (`valgebra_planning/proxy.py`). A broken check answers the call with a tool error naming it, and
112
+ the call never reaches the server, or its result the agent. A refused call leaves every policy
113
+ where it was. A flow rule reads provenance from values: an argument equal to a value a source
114
+ tool returned is taken as that tool's, an assumption. Under `only` an argument equal to no value
115
+ its sources returned is refused, and so is a value from a task input, since a proxy sees no
116
+ task. A call the server answers by asking for input is answered with a tool error, and the
117
+ request is not forwarded. An agent connects to the proxy as to any stdio server, and no agent
118
+ changes.
119
+
120
+ ## Limits
121
+
122
+ - With `--server`, the tasks, policies, flow rules and observed calls are still the library's files.