abe-ai 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 (39) hide show
  1. abe_ai-0.1.0/LICENSE +201 -0
  2. abe_ai-0.1.0/NOTICE +19 -0
  3. abe_ai-0.1.0/PKG-INFO +179 -0
  4. abe_ai-0.1.0/README.md +145 -0
  5. abe_ai-0.1.0/abe/__init__.py +21 -0
  6. abe_ai-0.1.0/abe/__main__.py +5 -0
  7. abe_ai-0.1.0/abe/canonical.py +118 -0
  8. abe_ai-0.1.0/abe/cli.py +289 -0
  9. abe_ai-0.1.0/abe/conformance/__init__.py +240 -0
  10. abe_ai-0.1.0/abe/conformance/fixtures/canonical.json +107 -0
  11. abe_ai-0.1.0/abe/conformance/fixtures/decisions.json +108 -0
  12. abe_ai-0.1.0/abe/conformance/fixtures/policies/standard.yaml +143 -0
  13. abe_ai-0.1.0/abe/conformance/fjp_conf.py +270 -0
  14. abe_ai-0.1.0/abe/evaluator.py +113 -0
  15. abe_ai-0.1.0/abe/exceptions.py +25 -0
  16. abe_ai-0.1.0/abe/gate.py +429 -0
  17. abe_ai-0.1.0/abe/ids.py +21 -0
  18. abe_ai-0.1.0/abe/mcp_server.py +76 -0
  19. abe_ai-0.1.0/abe/models.py +168 -0
  20. abe_ai-0.1.0/abe/policy.py +363 -0
  21. abe_ai-0.1.0/abe/py.typed +0 -0
  22. abe_ai-0.1.0/abe/reason_codes.py +42 -0
  23. abe_ai-0.1.0/abe/records.py +304 -0
  24. abe_ai-0.1.0/abe/server.py +141 -0
  25. abe_ai-0.1.0/abe/signing.py +66 -0
  26. abe_ai-0.1.0/abe/stores/__init__.py +160 -0
  27. abe_ai-0.1.0/abe/stores/contrib.py +81 -0
  28. abe_ai-0.1.0/abe/templates/request.json +9 -0
  29. abe_ai-0.1.0/abe/templates/starter.yaml +74 -0
  30. abe_ai-0.1.0/abe/yaml_safe.py +91 -0
  31. abe_ai-0.1.0/abe_ai.egg-info/PKG-INFO +179 -0
  32. abe_ai-0.1.0/abe_ai.egg-info/SOURCES.txt +37 -0
  33. abe_ai-0.1.0/abe_ai.egg-info/dependency_links.txt +1 -0
  34. abe_ai-0.1.0/abe_ai.egg-info/entry_points.txt +2 -0
  35. abe_ai-0.1.0/abe_ai.egg-info/requires.txt +16 -0
  36. abe_ai-0.1.0/abe_ai.egg-info/top_level.txt +1 -0
  37. abe_ai-0.1.0/pyproject.toml +47 -0
  38. abe_ai-0.1.0/setup.cfg +4 -0
  39. abe_ai-0.1.0/tests/test_gate.py +630 -0
abe_ai-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
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 2026 Flow Information Systems
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.
abe_ai-0.1.0/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ Abe (FJP Gate reference implementation)
2
+ Copyright 2026 Flow Information Systems
3
+
4
+ This product was created and is maintained by Flow Information Systems
5
+ (https://flowinfo.co).
6
+
7
+ It includes the FJP-CONF v0.1 conformance checks from
8
+ https://github.com/flowinfosystems-index/fjp-conformance (Apache-2.0),
9
+ vendored in python/fjp/conformance/fjp_conf.py and typescript/src/fjpConf.ts.
10
+
11
+ Flow Judgment Protocol™, FJP™, FJP Gate™, Abe™, FJP-CONF™, FJP Compatible™,
12
+ Judgment-Grounded Agent™, Judgment-Grounded™, Flow™, and Flow Information
13
+ Systems™ are trademarks of Flow Information Systems. See TRADEMARKS.md.
14
+
15
+ The Apache License, Version 2.0 (LICENSE) governs use of the source code in this
16
+ repository. It does not grant any right to use the trademarks listed above.
17
+
18
+ This NOTICE file must be preserved in redistributions of this work, per Section 4
19
+ of the Apache License, Version 2.0.
abe_ai-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: abe-ai
3
+ Version: 0.1.0
4
+ Summary: Abe: one control point before an AI agent acts. Deterministic ACT / BLOCK / ESCALATE with an immutable Judgment-Grounded Record. Local, offline, no account.
5
+ Author-email: Flow Information Systems <flowinfosystems@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://fjp.flowinfo.co/abe
8
+ Project-URL: Source, https://github.com/flowinfosystems-index/abe
9
+ Project-URL: Specification, https://fjp.flowinfo.co/abe/spec
10
+ Keywords: ai-agents,guardrails,policy,audit,abe,fjp,mcp,agent-safety
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Security
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: PyYAML>=6.0
22
+ Provides-Extra: signing
23
+ Requires-Dist: cryptography>=42; extra == "signing"
24
+ Provides-Extra: mcp
25
+ Requires-Dist: mcp<2,>=1.27; extra == "mcp"
26
+ Provides-Extra: all
27
+ Requires-Dist: cryptography>=42; extra == "all"
28
+ Requires-Dist: mcp<2,>=1.27; extra == "all"
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8; extra == "dev"
31
+ Requires-Dist: cryptography>=42; extra == "dev"
32
+ Requires-Dist: jsonschema>=4; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # Abe (Python) — `pip install abe-ai`
36
+
37
+ > **Abe is one control point before an AI agent acts.**
38
+
39
+ It checks a proposed action against your policy and returns **`ACT`**, **`BLOCK`** or **`ESCALATE`**, plus an immutable,
40
+ hash-verified **Judgment-Grounded Record** of why. It runs entirely on your machine: no account, no API key, no
41
+ network, no model. Median evaluation time is well under a millisecond.
42
+
43
+ ```bash
44
+ pip install abe-ai # or: npm install abe-ai
45
+ abe init # writes abe-policy.yaml + request.json
46
+ abe check request.json
47
+ ```
48
+ ```text
49
+ Decision: ESCALATE
50
+ Reason: FINANCIAL_THRESHOLD_EXCEEDED
51
+ Rules: purchase_review_limit
52
+ Risk: MEDIUM
53
+ Record: jgr_01M3Q4...
54
+ ```
55
+
56
+ ## Python
57
+
58
+ ```python
59
+ from abe import Abe
60
+
61
+ abe = Abe("abe-policy.yaml")
62
+
63
+ result = abe.check(
64
+ action={"type": "wire_transfer", "amount": 50000},
65
+ context={"agent_id": "finance-agent"},
66
+ )
67
+
68
+ if result.decision == "ACT":
69
+ ... # execute exactly as evaluated
70
+ elif result.decision == "BLOCK":
71
+ ... # do not execute; tell the user result.reason_code
72
+ else: # ESCALATE
73
+ ... # hold; ask a human, or let a resolver decide
74
+
75
+ result.record.to_dict() # the Judgment-Grounded Record (store it, ship it to your SIEM)
76
+ ```
77
+
78
+ ## TypeScript
79
+
80
+ ```typescript
81
+ import { Abe } from "abe-ai";
82
+
83
+ const abe = new Abe({ policy: "./abe-policy.yaml" });
84
+ const result = await abe.check({
85
+ action: { type: "purchase", amount: 12500, currency: "USD" },
86
+ context: { agent_id: "procurement-agent", principal_id: "user_123" },
87
+ });
88
+ console.log(result.decision); // "ESCALATE"
89
+ ```
90
+
91
+ ## A policy
92
+
93
+ ```yaml
94
+ version: "0.1"
95
+ defaults: { unmatched: ESCALATE } # nothing matched -> needs judgment (fail closed)
96
+ rules:
97
+ - id: purchase_hard_limit
98
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: gt, value: 100000 } ] }
99
+ decision: BLOCK
100
+ reason_code: HARD_POLICY_VIOLATION
101
+ - id: purchase_review_limit
102
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: gt, value: 10000 } ] }
103
+ decision: ESCALATE
104
+ reason_code: FINANCIAL_THRESHOLD_EXCEEDED
105
+ - id: routine_purchase
106
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: lte, value: 500 } ] }
107
+ decision: ACT
108
+ judgment_required:
109
+ - action.type: terminate_employee
110
+ ```
111
+
112
+ Also: authorization per agent, required evidence, risk and irreversibility thresholds, confidence minimums.
113
+ `BLOCK` beats `ESCALATE` beats `ACT`. Bad input or a broken rule returns `ESCALATE` / `EVALUATION_FAILURE`, never `ACT`.
114
+ Full reference: [SPEC.md](https://github.com/flowinfosystems-index/abe/blob/main/SPEC.md).
115
+
116
+ ## Every way to run it
117
+
118
+ | | |
119
+ |---|---|
120
+ | Library | `pip install abe-ai` · `npm install abe-ai` |
121
+ | CLI | `abe check · validate-policy · validate-record · conformance · keygen` |
122
+ | Local HTTP sidecar | `abe serve --policy abe-policy.yaml` → `POST http://127.0.0.1:8787/v1/check` (any language) |
123
+ | Docker sidecar | `docker run -e ABE_TOKEN=… -v $PWD:/policy:ro -p 127.0.0.1:8787:8787 ghcr.io/flowinfosystems-index/abe` |
124
+ | MCP server | `pip install "abe-ai[mcp]"` → `abe mcp --policy /abs/abe-policy.yaml` (tool: `fjp_check_action`) |
125
+
126
+ ## Records you can audit
127
+
128
+ Every call returns a record with the decision, every matched rule, the **exact policy hash**, the **request hash**,
129
+ and a SHA-256 `record_hash` (optionally Ed25519-signed with `abe keygen`). Records never change: outcomes and
130
+ resolutions are appended as linked records. Each one is a valid FJP-CONF v0.1 Judgment-Grounded Record.
131
+
132
+ ```bash
133
+ abe check request.json --record-out jgr.json --sign-key abe-signing-key.pem
134
+ abe validate-record jgr.json --public-key abe-signing-key.pub.pem
135
+ ```
136
+
137
+ ## When rules aren't enough: Flow
138
+
139
+ Abe is deliberately useful without Flow. When it returns `ESCALATE`, you can hand that one action to
140
+ [Flow's judgment service](https://fjp.flowinfo.co) and get a verb, a reason and a falsifiable record back:
141
+
142
+ ```python
143
+ from abe import Abe
144
+ from abe_flow import FlowResolver # pip install abe-flow
145
+
146
+ abe = Abe("abe-policy.yaml", resolver=FlowResolver(api_key=os.environ["FLOW_API_KEY"]))
147
+ ```
148
+
149
+ `ACT` and `BLOCK` never leave your machine. Only escalations are sent (redacted), and if Flow is unreachable the
150
+ answer simply stays `ESCALATE`. Human-approval escalations are never auto-resolved.
151
+
152
+ ## Conformance
153
+
154
+ ```bash
155
+ abe conformance --bench # FJP-CONF v0.1 Gate profile, Level 3 — 160 checks, offline
156
+ ```
157
+
158
+ ## Repository
159
+
160
+ ```
161
+ SPEC.md the normative specification
162
+ schemas/ JSON Schemas (request, response, record, policy)
163
+ python/ abe-ai (PyPI): core, CLI, HTTP, MCP, stores, signing, conformance
164
+ typescript/ abe-ai (npm): same API, same records, same hashes
165
+ flow-resolver/ abe-flow (PyPI): Gate → Flow for ESCALATE only
166
+ conformance/fixtures/ golden decisions + canonical-JSON vectors shared by every SDK
167
+ examples/ purchasing, software agent, physical agent, travel (+ Judd), Flow
168
+ ```
169
+
170
+ Apache-2.0. FJP™, Abe™ (Abe) and FJP-CONF™ are trademarks of Flow Information Systems — see [TRADEMARKS.md](https://github.com/flowinfosystems-index/abe/blob/main/TRADEMARKS.md).
171
+
172
+ ## Extras
173
+
174
+ | Install | Adds |
175
+ |---|---|
176
+ | `pip install abe-ai` | core, CLI, HTTP server, stores (memory, file, SQLite), conformance — one dependency (PyYAML) |
177
+ | `pip install "abe-ai[signing]"` | Ed25519 record signing (`abe keygen`, `--sign-key`) |
178
+ | `pip install "abe-ai[mcp]"` | MCP server (`abe mcp`) |
179
+ | `abe.stores.contrib` | `PostgresStore` (psycopg 3), `MongoStore` (pymongo) — bring your own driver |
abe_ai-0.1.0/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # Abe (Python) — `pip install abe-ai`
2
+
3
+ > **Abe is one control point before an AI agent acts.**
4
+
5
+ It checks a proposed action against your policy and returns **`ACT`**, **`BLOCK`** or **`ESCALATE`**, plus an immutable,
6
+ hash-verified **Judgment-Grounded Record** of why. It runs entirely on your machine: no account, no API key, no
7
+ network, no model. Median evaluation time is well under a millisecond.
8
+
9
+ ```bash
10
+ pip install abe-ai # or: npm install abe-ai
11
+ abe init # writes abe-policy.yaml + request.json
12
+ abe check request.json
13
+ ```
14
+ ```text
15
+ Decision: ESCALATE
16
+ Reason: FINANCIAL_THRESHOLD_EXCEEDED
17
+ Rules: purchase_review_limit
18
+ Risk: MEDIUM
19
+ Record: jgr_01M3Q4...
20
+ ```
21
+
22
+ ## Python
23
+
24
+ ```python
25
+ from abe import Abe
26
+
27
+ abe = Abe("abe-policy.yaml")
28
+
29
+ result = abe.check(
30
+ action={"type": "wire_transfer", "amount": 50000},
31
+ context={"agent_id": "finance-agent"},
32
+ )
33
+
34
+ if result.decision == "ACT":
35
+ ... # execute exactly as evaluated
36
+ elif result.decision == "BLOCK":
37
+ ... # do not execute; tell the user result.reason_code
38
+ else: # ESCALATE
39
+ ... # hold; ask a human, or let a resolver decide
40
+
41
+ result.record.to_dict() # the Judgment-Grounded Record (store it, ship it to your SIEM)
42
+ ```
43
+
44
+ ## TypeScript
45
+
46
+ ```typescript
47
+ import { Abe } from "abe-ai";
48
+
49
+ const abe = new Abe({ policy: "./abe-policy.yaml" });
50
+ const result = await abe.check({
51
+ action: { type: "purchase", amount: 12500, currency: "USD" },
52
+ context: { agent_id: "procurement-agent", principal_id: "user_123" },
53
+ });
54
+ console.log(result.decision); // "ESCALATE"
55
+ ```
56
+
57
+ ## A policy
58
+
59
+ ```yaml
60
+ version: "0.1"
61
+ defaults: { unmatched: ESCALATE } # nothing matched -> needs judgment (fail closed)
62
+ rules:
63
+ - id: purchase_hard_limit
64
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: gt, value: 100000 } ] }
65
+ decision: BLOCK
66
+ reason_code: HARD_POLICY_VIOLATION
67
+ - id: purchase_review_limit
68
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: gt, value: 10000 } ] }
69
+ decision: ESCALATE
70
+ reason_code: FINANCIAL_THRESHOLD_EXCEEDED
71
+ - id: routine_purchase
72
+ when: { all: [ { field: action.type, op: eq, value: purchase }, { field: action.amount, op: lte, value: 500 } ] }
73
+ decision: ACT
74
+ judgment_required:
75
+ - action.type: terminate_employee
76
+ ```
77
+
78
+ Also: authorization per agent, required evidence, risk and irreversibility thresholds, confidence minimums.
79
+ `BLOCK` beats `ESCALATE` beats `ACT`. Bad input or a broken rule returns `ESCALATE` / `EVALUATION_FAILURE`, never `ACT`.
80
+ Full reference: [SPEC.md](https://github.com/flowinfosystems-index/abe/blob/main/SPEC.md).
81
+
82
+ ## Every way to run it
83
+
84
+ | | |
85
+ |---|---|
86
+ | Library | `pip install abe-ai` · `npm install abe-ai` |
87
+ | CLI | `abe check · validate-policy · validate-record · conformance · keygen` |
88
+ | Local HTTP sidecar | `abe serve --policy abe-policy.yaml` → `POST http://127.0.0.1:8787/v1/check` (any language) |
89
+ | Docker sidecar | `docker run -e ABE_TOKEN=… -v $PWD:/policy:ro -p 127.0.0.1:8787:8787 ghcr.io/flowinfosystems-index/abe` |
90
+ | MCP server | `pip install "abe-ai[mcp]"` → `abe mcp --policy /abs/abe-policy.yaml` (tool: `fjp_check_action`) |
91
+
92
+ ## Records you can audit
93
+
94
+ Every call returns a record with the decision, every matched rule, the **exact policy hash**, the **request hash**,
95
+ and a SHA-256 `record_hash` (optionally Ed25519-signed with `abe keygen`). Records never change: outcomes and
96
+ resolutions are appended as linked records. Each one is a valid FJP-CONF v0.1 Judgment-Grounded Record.
97
+
98
+ ```bash
99
+ abe check request.json --record-out jgr.json --sign-key abe-signing-key.pem
100
+ abe validate-record jgr.json --public-key abe-signing-key.pub.pem
101
+ ```
102
+
103
+ ## When rules aren't enough: Flow
104
+
105
+ Abe is deliberately useful without Flow. When it returns `ESCALATE`, you can hand that one action to
106
+ [Flow's judgment service](https://fjp.flowinfo.co) and get a verb, a reason and a falsifiable record back:
107
+
108
+ ```python
109
+ from abe import Abe
110
+ from abe_flow import FlowResolver # pip install abe-flow
111
+
112
+ abe = Abe("abe-policy.yaml", resolver=FlowResolver(api_key=os.environ["FLOW_API_KEY"]))
113
+ ```
114
+
115
+ `ACT` and `BLOCK` never leave your machine. Only escalations are sent (redacted), and if Flow is unreachable the
116
+ answer simply stays `ESCALATE`. Human-approval escalations are never auto-resolved.
117
+
118
+ ## Conformance
119
+
120
+ ```bash
121
+ abe conformance --bench # FJP-CONF v0.1 Gate profile, Level 3 — 160 checks, offline
122
+ ```
123
+
124
+ ## Repository
125
+
126
+ ```
127
+ SPEC.md the normative specification
128
+ schemas/ JSON Schemas (request, response, record, policy)
129
+ python/ abe-ai (PyPI): core, CLI, HTTP, MCP, stores, signing, conformance
130
+ typescript/ abe-ai (npm): same API, same records, same hashes
131
+ flow-resolver/ abe-flow (PyPI): Gate → Flow for ESCALATE only
132
+ conformance/fixtures/ golden decisions + canonical-JSON vectors shared by every SDK
133
+ examples/ purchasing, software agent, physical agent, travel (+ Judd), Flow
134
+ ```
135
+
136
+ Apache-2.0. FJP™, Abe™ (Abe) and FJP-CONF™ are trademarks of Flow Information Systems — see [TRADEMARKS.md](https://github.com/flowinfosystems-index/abe/blob/main/TRADEMARKS.md).
137
+
138
+ ## Extras
139
+
140
+ | Install | Adds |
141
+ |---|---|
142
+ | `pip install abe-ai` | core, CLI, HTTP server, stores (memory, file, SQLite), conformance — one dependency (PyYAML) |
143
+ | `pip install "abe-ai[signing]"` | Ed25519 record signing (`abe keygen`, `--sign-key`) |
144
+ | `pip install "abe-ai[mcp]"` | MCP server (`abe mcp`) |
145
+ | `abe.stores.contrib` | `PostgresStore` (psycopg 3), `MongoStore` (pymongo) — bring your own driver |
@@ -0,0 +1,21 @@
1
+ """Abe — Act. Block. Escalate. One control point before an AI agent acts.
2
+
3
+ Deterministic ACT / BLOCK / ESCALATE plus an immutable Judgment-Grounded Record for every call.
4
+ Runs entirely locally: no network, no model, no Flow account.
5
+ """
6
+ __version__ = "0.1.0"
7
+
8
+ from .exceptions import (EvaluationError, FJPError, PolicyError, RecordImmutableError, # noqa: E402
9
+ RequestError, SigningError)
10
+ from .models import GateResult, Record, Resolution # noqa: E402
11
+ from .policy import Policy, load_policy # noqa: E402
12
+ from .gate import Gate, Resolver # noqa: E402
13
+
14
+ Abe = Gate # the product name; Gate is the protocol role (FJP Gate)
15
+ from .records import evaluate_falsifier, verify_hash # noqa: E402
16
+
17
+ ACT, BLOCK, ESCALATE = "ACT", "BLOCK", "ESCALATE"
18
+
19
+ __all__ = ["Abe", "Gate", "GateResult", "Record", "Resolution", "Resolver", "Policy", "load_policy",
20
+ "verify_hash", "evaluate_falsifier", "FJPError", "PolicyError", "RequestError", "EvaluationError",
21
+ "RecordImmutableError", "SigningError", "ACT", "BLOCK", "ESCALATE", "__version__"]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())