abacist 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.
Files changed (45) hide show
  1. abacist-0.1.0/CHANGELOG.md +60 -0
  2. abacist-0.1.0/LICENSE +202 -0
  3. abacist-0.1.0/MANIFEST.in +3 -0
  4. abacist-0.1.0/PKG-INFO +338 -0
  5. abacist-0.1.0/README.md +320 -0
  6. abacist-0.1.0/examples/decision_unknown.py +44 -0
  7. abacist-0.1.0/examples/mcp_cli_handoff.py +112 -0
  8. abacist-0.1.0/examples/release_migration.py +55 -0
  9. abacist-0.1.0/examples/story_threads.py +58 -0
  10. abacist-0.1.0/pyproject.toml +36 -0
  11. abacist-0.1.0/setup.cfg +4 -0
  12. abacist-0.1.0/src/abacist/__init__.py +50 -0
  13. abacist-0.1.0/src/abacist/_mcp_cli.py +12 -0
  14. abacist-0.1.0/src/abacist/cli.py +185 -0
  15. abacist-0.1.0/src/abacist/concurrent.py +473 -0
  16. abacist-0.1.0/src/abacist/core.py +2185 -0
  17. abacist-0.1.0/src/abacist/knowledge.py +240 -0
  18. abacist-0.1.0/src/abacist/mcp_server.py +281 -0
  19. abacist-0.1.0/src/abacist/mcp_tasks.py +415 -0
  20. abacist-0.1.0/src/abacist/queries.py +792 -0
  21. abacist-0.1.0/src/abacist/schemas.py +145 -0
  22. abacist-0.1.0/src/abacist/service.py +186 -0
  23. abacist-0.1.0/src/abacist/skills/abacist-basics/SKILL.md +152 -0
  24. abacist-0.1.0/src/abacist/skills/abacist-code-changes/SKILL.md +52 -0
  25. abacist-0.1.0/src/abacist/skills/abacist-decisions/SKILL.md +30 -0
  26. abacist-0.1.0/src/abacist/skills/abacist-story-threads/SKILL.md +37 -0
  27. abacist-0.1.0/src/abacist/store.py +197 -0
  28. abacist-0.1.0/src/abacist/world.py +432 -0
  29. abacist-0.1.0/src/abacist.egg-info/PKG-INFO +338 -0
  30. abacist-0.1.0/src/abacist.egg-info/SOURCES.txt +43 -0
  31. abacist-0.1.0/src/abacist.egg-info/dependency_links.txt +1 -0
  32. abacist-0.1.0/src/abacist.egg-info/entry_points.txt +3 -0
  33. abacist-0.1.0/src/abacist.egg-info/requires.txt +3 -0
  34. abacist-0.1.0/src/abacist.egg-info/top_level.txt +1 -0
  35. abacist-0.1.0/tests/reference_semantics.py +544 -0
  36. abacist-0.1.0/tests/test_cli.py +207 -0
  37. abacist-0.1.0/tests/test_concurrent_evidence.py +255 -0
  38. abacist-0.1.0/tests/test_core.py +476 -0
  39. abacist-0.1.0/tests/test_examples.py +52 -0
  40. abacist-0.1.0/tests/test_ledger.py +691 -0
  41. abacist-0.1.0/tests/test_mcp_server.py +226 -0
  42. abacist-0.1.0/tests/test_mcp_tasks.py +411 -0
  43. abacist-0.1.0/tests/test_reference_semantics.py +580 -0
  44. abacist-0.1.0/tests/test_schemas_knowledge_concurrent.py +213 -0
  45. abacist-0.1.0/tests/test_step_zero.py +362 -0
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-12-02)
4
+
5
+ ### Ledger behavior
6
+
7
+ - By default, propagation skips the recorded start (tick 0). Add `"settle": true`
8
+ to run a standing rule at the start. Settling effects must assign values. Rules
9
+ still run after each step. Planning, simulation and constraint checks use the
10
+ same starting state.
11
+ - The engine reports a write conflict when changing the execution order of rule firings
12
+ in the same round changes a field's value. Conflicts include the values actually written.
13
+ `orderVerified: false` marks a group whose order check exhausted its budget.
14
+ Equality follows JSON values. Relation weights are compared without rounding.
15
+
16
+ ### Answers
17
+
18
+ - `startOverwrites` lists recorded values replaced by a settling rule.
19
+ `startWriteConflicts` lists conflicts during settlement. `dependsOnRuleOrder` identifies
20
+ results that can depend on rule ordering. `planWriteConflicts` includes the step, hop,
21
+ writes and verification flag for the shown plan. Simulations count affected branches in
22
+ `branchesWithWriteConflicts`. Search results count affected steps in `writeConflictSteps`.
23
+ Both reachability queries return `undetermined` when the search found no plan and
24
+ encountered rule-order conflicts.
25
+ Python counterfactuals also report the flag in `goalDelta`, and Python plans can report
26
+ `unknown_rule_order` when conflicts leave hard-constraint proof uncertain.
27
+ - Concurrent planning keeps searching past an early conditional witness for a proven
28
+ route. `minTicks` and `minProvenTicks` distinguish the two minima. The Python API adds
29
+ `provenPlans`, `firstInvariantViolationDepth` and `reachable_relaxed_constraints` for
30
+ witnesses that depend on allowing known hard violations. The state and joint-step budgets
31
+ have separate flags, `stateBudgetTruncated` and `jointStepEnumerationTruncated`.
32
+ - The thirteenth MCP tool, `ask_concurrent`, and `abacist ask-concurrent` expose concurrent
33
+ planning with a shared answer. `provenReachable` and `reachabilityStatus` describe proof
34
+ under the recorded model. The `plan` groups actions by tick. `fasterUnprovenPlan` includes
35
+ the gaps and evidence for a faster conditional route when one is found.
36
+
37
+ ### Interfaces
38
+
39
+ - The `abacist` CLI reads and writes the same ledgers as MCP and emits JSON answers.
40
+ `--max-seconds` stops a foreground search cooperatively.
41
+ - MCP and the CLI require a complete `id@revision` for reads and writes. When an
42
+ incomplete handle identifies a world, the error includes its current complete handle.
43
+ For handoffs, pass the original `world` field verbatim.
44
+ - `abacist record --entries-json` takes a literal JSON list as an alternative to
45
+ a file or standard input. The same entries at the same revision produce the same handle.
46
+ - MCP and CLI concurrent queries accept `max_joint_steps` from 1 to 16,384 per state,
47
+ with a default of 4,096.
48
+ - Long MCP searches can return a job id after `wait_seconds`. Use `job_status` to retrieve
49
+ the answer and `job_cancel` to stop the search. Servers also support native MCP tasks
50
+ when the client requests them. Jobs and tasks end with the server process.
51
+
52
+ ### Packaging
53
+
54
+ - Both MCP launchers print the installation command when the MCP extra is missing.
55
+ - The source distribution includes the changelog, examples, and test helpers.
56
+
57
+ ## 0.1.0.dev0
58
+
59
+ Initial public source version with the Python planning and simulation engine, a revisioned
60
+ ledger, MCP tools for recording and querying worlds, and usage guides.
abacist-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,3 @@
1
+ include CHANGELOG.md
2
+ include examples/*.py
3
+ include tests/*.py
abacist-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,338 @@
1
+ Metadata-Version: 2.4
2
+ Name: abacist
3
+ Version: 0.1.0
4
+ Summary: A deterministic reasoning ledger for AI agents: record facts with their evidence, then ask what is reachable, what is missing, and what an answer rests on.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Repository, https://github.com/strmforge/Abacist
7
+ Keywords: mcp,planning,reachability,provenance,agents,hallucination
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Provides-Extra: mcp
16
+ Requires-Dist: mcp<3,>=2.3; extra == "mcp"
17
+ Dynamic: license-file
18
+
19
+ # Abacist
20
+
21
+ A deterministic reasoning ledger for AI agents, usable as a Python library, a command-line
22
+ tool or an MCP server. It calls no language model and works with any agent that can call MCP
23
+ tools or run a command.
24
+
25
+ Language models are good at proposing what might happen and poor at keeping track of what
26
+ is actually known. Abacist does the second part. You record facts together with their
27
+ evidence, describe what can be done and what must stay true, and ask:
28
+
29
+ - Can this goal be reached from what is known? By which steps?
30
+ - What is the earliest tick at which several actors can reach a goal together?
31
+ - What does that answer rest on, and how solid is each fact?
32
+ - Which facts are missing, and which sources contradict each other?
33
+ - Does it still happen if one actor does nothing? What if a fact were different?
34
+
35
+ It never guesses. A field nobody recorded is *unknown*, not false. Two sources that disagree
36
+ are reported, not silently resolved. Every answer names its weakest fact.
37
+
38
+ The name comes from the abacists, who calculated on counting boards step by step, in plain
39
+ sight, so anyone could check the work.
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install abacist # library and the `abacist` command, no dependencies
45
+ pip install "abacist[mcp]" # adds the MCP server `abacist-mcp` (uses the official MCP Python SDK)
46
+ ```
47
+
48
+ Python 3.10 or later. Until the first release, install from a clone with `pip install -e ".[mcp]"`.
49
+ See [CHANGELOG.md](CHANGELOG.md) for changes since the initial public source version.
50
+
51
+ ## A small example
52
+
53
+ ```python
54
+ from abacist import build, reachable
55
+
56
+ entries = [
57
+ {"kind": "entity", "id": "db", "type": "store"},
58
+ {"kind": "entity", "id": "api", "type": "service"},
59
+ {"kind": "claim", "id": "c1", "ref": "entity.db.schema", "value": 1,
60
+ "evidence": "observed", "source": "SELECT max(version) FROM schema_migrations -> 1"},
61
+ {"kind": "claim", "id": "c2", "ref": "entity.api.max_schema", "value": 1,
62
+ "evidence": "reported", "source": "the api owner said so"},
63
+ {"kind": "action", "id": "deploy_api", "effects": [["entity.api.max_schema", "set", 2]]},
64
+ {"kind": "action", "id": "migrate", "effects": [["entity.db.schema", "set", 2]]},
65
+ {"kind": "constraint", "id": "readable", "scope": "path",
66
+ "when": [["entity.api.max_schema", "gte_ref", "entity.db.schema"]]},
67
+ {"kind": "goal", "id": "migrated", "when": [["entity.db.schema", "eq", 2]]},
68
+ ]
69
+
70
+ r = reachable(build(entries), "migrated")
71
+ r["answer"] # "yes"
72
+ [s["action"] for s in r["plan"]["steps"]] # ["deploy_api", "migrate"]
73
+ r["basis"] # "depends_on_reports"
74
+ r["dependsOn"][0]["ref"] # "entity.api.max_schema" - the weakest fact
75
+ ```
76
+
77
+ More in [`examples/`](examples): a release migration, story threads with who-knows-what, and
78
+ a decision with unknown facts.
79
+
80
+ ## Answers
81
+
82
+ | answer | meaning |
83
+ |---|---|
84
+ | `yes` | a plan exists and every hard constraint on it can be evaluated |
85
+ | `yes_if_facts` | a plan exists, but facts its hard constraints need are not recorded |
86
+ | `not_within_depth` | no plan within the search depth; deeper plans were not searched |
87
+ | `no` | a definitive hard path-invariant violation at the start |
88
+ | `undetermined` | a budget cut the search short, or the search found no plan and encountered rule-order conflicts |
89
+
90
+ | basis | meaning |
91
+ |---|---|
92
+ | `observed` | every fact used was seen directly, or is a declared closed-world default |
93
+ | `depends_on_reports` | at least one fact is only reported |
94
+ | `depends_on_assumptions` | at least one fact is assumed, or an unrecorded field was read as absent (by a precondition or by a propagation rule) |
95
+ | `hypothetical` | the answer uses a what-if value |
96
+
97
+ Propagation rules fire once after every step, after that step's action. By default a rule is
98
+ a reaction and does not run on the recorded state, so an action can still come first. A rule
99
+ marked `"settle": true` is a standing derivation (it may only assign values): it already
100
+ holds in the recorded state, so it is also applied once before the first step. The planner,
101
+ the simulator and `check_constraints` all start from that same state. If a settling rule
102
+ replaces a recorded value, the answer lists it under `startOverwrites`; if a field's value
103
+ depends on the order in which settling rules run, under `startWriteConflicts`.
104
+
105
+ Rules that fire in the same round are applied in rule-id order, and a field whose value
106
+ would differ under some other order is reported as a write conflict: the answer then depends
107
+ only on rule ids, so fix the rules. Every order is covered, not a sample: rules that share no
108
+ field cannot affect each other and are checked apart, partial orders that leave the same values
109
+ are explored once, and pure additions (or pure maxima) of 4-decimal amounts from sources the
110
+ group does not change are known to give the same result in any order. If a group is too large
111
+ to check within the budget, its fields are still reported, with `"orderVerified": false`.
112
+ Values are compared as JSON values: `true` and `1` differ, `2` and `2.0` do not. A rule that
113
+ reads a field it wrote itself in an earlier effect reads its own value, which is no conflict.
114
+
115
+ Every answer carries `dependsOnRuleOrder`. When it is true, the reported result may differ
116
+ under another rule order. `ask_reachable` prefers a plan without conflicts and lists any
117
+ conflicts on the plan shown under `planWriteConflicts`, with the step, hop, actual writes
118
+ and `orderVerified`. If no plan was found, the flag still records conflicts encountered
119
+ before the search stopped, including when it ran out of budget. In strict mode a plan
120
+ with conflicts alone can still be evaluated under the current order, but it cannot prove
121
+ reachability. Missing hard-constraint facts are reported separately.
122
+ In Python's `plan()`, a plan with write conflicts and otherwise proven hard constraints
123
+ has `hardConstraintStatus` set to `unknown_rule_order`.
124
+
125
+ In `simulate`, `branchesWithWriteConflicts` counts returned branches with a conflict at
126
+ step 0 or later. The flag also covers conflicts found before a branch was merged or dropped.
127
+ In Python's `counterfactual()`, the top-level flag covers both simulations and the goal
128
+ comparison. The flag inside `goalDelta` applies to reachability only. An Agent that needs a
129
+ result independent of rule ids can use the flag to decide when to inspect the rules.
130
+
131
+ Facts that rules read and that can affect the plan, the goal or a hard constraint count
132
+ toward the basis whether or not the rule fired, and a recorded fact counts even when some
133
+ rule could overwrite it. A field nobody recorded is flagged when a rule tests it, unless
134
+ something fills it later on the path; an `exists` or `missing` test always counts. A rule
135
+ whose relation stayed inactive was never tested, so only that relation's `active` field
136
+ matters. Values the rules actually produced are listed under `derived`.
137
+
138
+ ### Concurrent planning
139
+
140
+ Use the MCP tool `ask_concurrent(world, goal)` or `abacist ask-concurrent <handle> <goal>`
141
+ to find the earliest tick that a goal can be reached. Each tick lets different actors take
142
+ one action each when those actions can safely run together. Use `max_ticks` (default 6),
143
+ `max_states` (default 20,000) and `max_joint_steps` (1 to 16,384 per state, default 4,096)
144
+ to bound the search.
145
+ The CLI accepts `--max-ticks`, `--max-states` and `--max-joint-steps`.
146
+
147
+ Every action checks its `pre` against the state at the start of its tick. If a migration
148
+ requires earlier compatibility checks, put those requirements in the migration action's `pre`.
149
+ A final constraint checks the goal state. When it is the only compatibility requirement,
150
+ the check actions and the migration can share a tick.
151
+
152
+ `minTicks` is the earliest tick with a goal witness. `minProvenTicks` is the earliest tick
153
+ with a witness whose hard constraints are satisfied in their required scope and whose rules
154
+ have no write conflicts. A missing witness is `null`. The main `plan` shows the earliest
155
+ proven route if one was found, with actions grouped by tick. Otherwise it shows an earliest
156
+ conditional route when available. A faster conditional route alongside a proven one appears
157
+ under `fasterUnprovenPlan`, with `pendingHardFacts` and any `planWriteConflicts` explaining
158
+ what needs checking. `dependsOnRuleOrder` describes the main answer and is also reported for
159
+ the faster route when present. Conflicts and overwritten values at tick 0 are shared by all
160
+ routes and reported under `startWriteConflicts` and `startOverwrites` when present.
161
+
162
+ Each shown route has its own `basis` and `dependsOn` evidence. A proven route can have
163
+ `basis: "depends_on_reports"` when it relies on a reported fact. The `search` object separates
164
+ `stateBudgetTruncated` from `jointStepEnumerationTruncated`. Either sets `search.truncated`.
165
+ When truncated, tick counts apply to the witnesses found. With no witness, the answer is
166
+ `undetermined` with `reachabilityStatus: "undetermined_truncated"`.
167
+
168
+ #### Python API
169
+
170
+ `plan_concurrent()` searches by tick and reports the earliest goal witness in `minTicks`
171
+ and the earliest proven witness in `minProvenTicks`. It keeps searching for proof when an
172
+ early witness has missing hard facts or rule-order conflicts. `plans` contains the earliest
173
+ witnesses from both groups without duplicates, and `provenPlans` contains only the earliest
174
+ proven routes. A missing witness has a tick value of `None`. When a conflict-free proof is
175
+ found, `dependsOnRuleOrder` is false for reachability even if a quicker route still lists
176
+ its full conflicts under `writeConflicts`.
177
+
178
+ With `require_hard_constraints=False`, a route can meet the goal despite a known hard
179
+ violation, including at tick 0. If every returned route has a known violation, the status
180
+ is `reachable_relaxed_constraints` and `provenReachable` is false. Each plan reports
181
+ `firstInvariantViolationDepth` as the first tick that violated a hard path constraint,
182
+ or `None`. Later recovery cannot clear an earlier path violation. Final hard constraints
183
+ are checked at the goal witness.
184
+
185
+ `max_joint_steps` limits the number of legal joint steps examined per state (default 4096).
186
+ When the limit omits combinations, `jointStepEnumerationTruncated` and `truncated` are true.
187
+ When the state budget cuts the search short, `stateBudgetTruncated` and `truncated` are true.
188
+ If no goal witness was found, the planner reports `undetermined_truncated` with
189
+ `joint_step_budget_truncated`. With either search budget exhausted, reported minima apply
190
+ to the routes found.
191
+
192
+ ## The ledger
193
+
194
+ A world is an ordered list of entries: `entity`, `relation`, `claim`, `closed`, `action`,
195
+ `schema`, `constraint`, `rule`, `goal`, `retract`. Each claim carries `evidence`
196
+ (`observed`, `reported`, `assumed`) and a `source`. A `closed` entry declares that a search
197
+ was complete, so missing values of that field mean a stated default rather than "unknown".
198
+
199
+ Worlds are stored as JSON-lines files. Revisions are a hash chain over the entries, so a
200
+ handle `id@revision` names exactly one state of the ledger, the same entries give the same
201
+ revision anywhere, and every answer can be recomputed later. Writes name the revision they
202
+ were based on and are refused if the world has moved on.
203
+
204
+ See [`src/abacist/world.py`](src/abacist/world.py) for the full entry format.
205
+
206
+ ## MCP server
207
+
208
+ ```bash
209
+ abacist-mcp --root ./worlds
210
+ ```
211
+
212
+ It speaks MCP over stdio (protocol 2026-07-28, with fallback for older clients through the
213
+ SDK). The thirteen tools are `world_new`, `world_list`, `world_record`, `world_show`,
214
+ `ask_reachable`, `ask_concurrent`, `ask_without`, `ask_what_if`, `check_constraints`, `simulate`,
215
+ `job_status`, `job_cancel`, `abacist_guide`. Everything works with plain tool calls, so any
216
+ MCP client can use all of it; two MCP extensions improve it where the client supports them.
217
+
218
+ **Guides.** `abacist_guide` returns the usage guides: `abacist-basics`,
219
+ `abacist-code-changes`, `abacist-story-threads`, `abacist-decisions`. They also ship as skills
220
+ through the MCP Skills extension (`io.modelcontextprotocol/skills`), for hosts that load
221
+ skills on demand.
222
+
223
+ **Long searches.** The search tools (`ask_reachable`, `ask_concurrent`, `ask_without`, `ask_what_if`,
224
+ `simulate`) take `wait_seconds` (default 20). A search still running after that long returns
225
+ `{"job": <id>, "status": "working"}` instead of its answer and keeps running in the
226
+ background; `job_status` reports its progress and, when it has finished, the answer exactly
227
+ as the tool would have returned it; `job_cancel` stops it. `wait_seconds: 0` starts a search
228
+ in the background at once. Clients that declare the MCP Tasks extension
229
+ (`io.modelcontextprotocol/tasks`) on the call get a search that runs past two seconds
230
+ (`--task-after`) back as an MCP task instead, polled with `tasks/get`.
231
+
232
+ Jobs and tasks are kept in memory by the server process. They live an hour from creation and
233
+ end with the server: for a stdio server, when the client disconnects. A client that starts a
234
+ new server for every call (some command-line clients do, unless told to keep it running) keeps
235
+ the worlds, which are files, but loses its job ids. A cancelled or expired search stops at its
236
+ next step rather than running on in the background.
237
+
238
+ Several agents can share one server. It computes at most four searches at once
239
+ (`--max-running`); further ones wait in line and report `"status": "queued"` with their
240
+ position, and can be cancelled while they wait. When 32 are already waiting (`--max-waiting`),
241
+ a new search is refused at once with a "busy" tool error, rather than left waiting until the
242
+ client times out.
243
+
244
+ Example client configuration (adjust to your host):
245
+
246
+ ```json
247
+ {"mcpServers": {"abacist": {"command": "abacist-mcp", "args": ["--root", "/path/to/worlds"]}}}
248
+ ```
249
+
250
+ ### Tested hosts
251
+
252
+ These counts describe the runs on 2026-11-30. Those builds listed ten or twelve tools.
253
+ The current server lists thirteen, including `ask_concurrent`.
254
+
255
+ | Host | Protocol | Tools called / listed | Guides | Long searches |
256
+ |---|---|---|---|---|
257
+ | Claude Code 2.1.332, interactive | 2026-07-28 | 4 / 10 \* | `abacist_guide`; skills listed | MCP tasks, polled by the host |
258
+ | Claude Code 2.1.332, `claude -p` | 2026-07-28 | 4 / 10 \* | `abacist_guide` | not tried |
259
+ | Codex CLI 0.172, `codex exec` | 2025-06-18 | 6 / 12 | `abacist_guide` | jobs: start, progress, cancel, result |
260
+ | DeepSeek Harness 0.2.2-rc.5, `dsh headless` | 2026-07-28 | 6 / 12 | `abacist_guide`, or the `skill://` resources | jobs: start, progress, cancel, result |
261
+ | mcporter 0.12 (no model) | 2025-11-25 | 11 / 12 | `abacist_guide` | jobs, with the server kept alive between calls |
262
+
263
+ \* Run before `job_status` and `job_cancel` existed, when the server had ten tools.
264
+
265
+ In the Claude Code, Codex and DeepSeek Harness runs, the model read the basics guide, recorded
266
+ a small migration with the right evidence kinds and sources, and reported the answer with its
267
+ weakest fact. DeepSeek Harness was run through two DeepSeek connections (its default API
268
+ model and a relay serving `deepseek-v4.1-flash`).
269
+
270
+ ## Command line
271
+
272
+ For agents that can run commands but not connect to MCP servers, `abacist` offers the same
273
+ operations and prints JSON (ASCII only, so any console can read it):
274
+
275
+ ```bash
276
+ abacist --root ./worlds new "release" # {"world": "release-...@..."}
277
+ abacist --root ./worlds record <handle> entries.json # or "-" to read stdin
278
+ abacist --root ./worlds ask <handle> migrated
279
+ abacist --root ./worlds ask <handle> --when '[["entity.db.schema", "eq", 2]]'
280
+ abacist --root ./worlds ask-concurrent <handle> migrated --max-ticks 3 --max-joint-steps 4096
281
+ abacist --root ./worlds what-if <handle> --changes @changes.json --goals '["migrated"]'
282
+ abacist --root ./worlds check <handle>
283
+ abacist --root ./worlds simulate <handle> --horizon 3
284
+ abacist guide abacist-basics
285
+ ```
286
+
287
+ Most JSON options accept literal JSON or `@file`. For `record`, choose a JSON file, `-`
288
+ (or no source argument) to read standard input, or `--entries-json` with a literal JSON list.
289
+ The [basics guide](src/abacist/skills/abacist-basics/SKILL.md#from-the-command-line) shows
290
+ single-command examples for Git Bash and PowerShell. Searches accept `--max-seconds`
291
+ to stop after a time limit. Exit status is 0 on success, 1 for a refusal (with `"error"` in
292
+ the JSON), 3 for a stopped search, or 2 for a malformed command.
293
+
294
+ ### Hand off a world from MCP to the CLI
295
+
296
+ Point the MCP server and CLI at the same world directory. Give the receiving agent the
297
+ question and evidence, and pass the exact `world` field (`id@revision`) from the previous
298
+ response verbatim. Keep the full ID, including its suffix, and the full revision. An incomplete
299
+ handle is refused. If the world can be identified, the error shows its current complete handle
300
+ for reference. Retrieve the original `world` field to replay the intended revision.
301
+
302
+ The receiving agent can read `abacist guide abacist-basics` and inspect the claims with
303
+ `abacist show <handle> --section claims`. Record new evidence with
304
+ `abacist record <handle> correction.json` or `--entries-json`, then pass the write's
305
+ `world` field to the next query. A complete historical handle still reads that revision.
306
+ Use `world_list` or `abacist list` to get the current handle explicitly.
307
+
308
+ Run the [MCP-to-CLI handoff example](examples/mcp_cli_handoff.py) from a checkout with the
309
+ MCP extra installed:
310
+
311
+ ```bash
312
+ python examples/mcp_cli_handoff.py
313
+ ```
314
+
315
+ The script builds a temporary world over MCP stdio, updates it through the CLI, and
316
+ checks that both interfaces agree at both revisions. A failed CLI capability probe initially
317
+ blocks a modeled offline audit. A passing probe after the CLI change replaces that evidence
318
+ and makes the goal reachable in one tick. The example needs no model or API key.
319
+
320
+ ## Limits
321
+
322
+ - Abacist checks consistency, not modelling. A wrongly written action gives a wrong answer
323
+ that is consistent with it.
324
+ - Search is exhaustive within a budget. It suits a handful of actors and a few steps at a
325
+ time; large models come back `undetermined`.
326
+ - It has no probabilities. Costs are what you give it.
327
+ - Background jobs and tasks do not survive a server restart, and never ask for input while
328
+ they run. The command line runs each search in the foreground.
329
+
330
+ ## Development
331
+
332
+ ```bash
333
+ python -m unittest discover -s tests # with PYTHONPATH=src, or after pip install -e .
334
+ ```
335
+
336
+ ## License
337
+
338
+ Apache License 2.0. See [LICENSE](LICENSE).