boundra-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: boundra-mcp
3
+ Version: 0.1.0
4
+ Summary: Boundra — policy-guarded payment approval gateway for AI agents (MCP server)
5
+ Author: Boundra
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://boundra.io
8
+ Project-URL: API, https://api.boundra.io
9
+ Keywords: mcp,agent,payments,x402,policy,guardrails
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Security
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: mcp<3,>=2.3
18
+ Requires-Dist: eth-account>=0.13
19
+ Dynamic: license-file
20
+
21
+ # Boundra · Payment approval gateway for AI agents
22
+
23
+ <!-- mcp-name: io.github.gobeyondfj-cmd/boundra -->
24
+
25
+ > **Boundra** (boundra.io) — *Boundaries for agent payments.*
26
+ > The boundary layer for agent payments: before any money moves, answer
27
+ > "should this payment happen at all?"
28
+
29
+ Our thesis: **the opportunity in agent payments is not "how to pay" (protocols
30
+ solved that) but "whether to pay."**
31
+
32
+ One natural-language rule → compiled into a policy → every payment the agent
33
+ attempts is genuinely evaluated → allow / ask a human / veto, with a full
34
+ audit trail.
35
+
36
+ Two run modes:
37
+
38
+ - **Offline simulation** (`demo.py`): stdlib only, self-contained mock merchant
39
+ and wallets, zero dependencies, zero network
40
+ - **Real protocol** (`demo/demo_real.py`): standard MCP server + real x402 SDK +
41
+ Base Sepolia testnet
42
+
43
+ ## Data flow
44
+
45
+ ![Boundra data flow](docs/dataflow.png)
46
+
47
+ Policies and keys stay with the user; the gateway is read-only; only hash
48
+ commitments go on-chain. Revocation is free — forever, no exceptions.
49
+
50
+ ## See it run in 60 seconds
51
+
52
+ ```bash
53
+ # 1. Hit the hosted evaluation API — a real, public x402 merchant
54
+ curl -X POST https://api.boundra.io/evaluate/basic \
55
+ -H 'Content-Type: application/json' \
56
+ -d '{"intent":{"amount":0.01,"recipient":"api.weather.com","purpose":"weather data"}}'
57
+ # → {"decision":"ALLOW",...} · semantic layer: 100 free calls per agent, then $0.003 via x402
58
+
59
+ # 2. Local end-to-end simulation — a data-procurement agent's day
60
+ .venv/bin/python demo/simulate_agent.py
61
+ # signed policy publish → ALLOW / DENY (limit) / ASK → user-signed approval token
62
+ # → prompt-injection blocked → audit trail, plus a dogfood call to api.boundra.io
63
+
64
+ # 3. One-line MCP install + 2-minute policy wizard
65
+ uvx --from git+https://github.com/gobeyondfj-cmd/boundra boundra-mcp # stdio server
66
+ uvx --from git+https://github.com/gobeyondfj-cmd/boundra boundra-init # wallet → template → sign → anchor
67
+ uvx --from git+https://github.com/gobeyondfj-cmd/boundra boundra-approve # sign an ASK challenge
68
+ ```
69
+
70
+ ## The complete flow, step by step
71
+
72
+ Zero to a signed, enforced policy in ~10 minutes. No accounts, no dashboards —
73
+ your wallet key is your identity.
74
+
75
+ **0 · Try the hosted API** *(30 seconds, nothing to install)*
76
+
77
+ ```bash
78
+ curl -X POST https://api.boundra.io/evaluate/basic \
79
+ -H 'Content-Type: application/json' \
80
+ -d '{"intent":{"amount":0.01,"recipient":"api.weather.com","purpose":"weather data"}}'
81
+ ```
82
+
83
+ **1 · Bind your identity — the wallet is the account**
84
+
85
+ ```bash
86
+ uvx --from git+https://github.com/gobeyondfj-cmd/boundra boundra-init
87
+ ```
88
+
89
+ Creates or imports a Base wallet. No signup, no email — the private key never
90
+ leaves your device, and your address *is* your identity everywhere in the
91
+ system.
92
+
93
+ **2 · Set your policy**
94
+
95
+ The wizard offers templates (personal assistant / travel / dev API /
96
+ procurement) or lets you write your own rule in plain English, then compiles
97
+ it and shows you exactly what will be enforced — before anything is signed.
98
+
99
+ **3 · Sign & publish**
100
+
101
+ You sign the policy document with your wallet key (EIP-191). It is published
102
+ as a versioned document and a hash commitment is anchored on-chain. From this
103
+ moment the gateway is read-only for every agent — changing the policy without
104
+ your key is impossible.
105
+
106
+ **4 · Mount the MCP server into your agent**
107
+
108
+ ```json
109
+ { "mcpServers": { "boundra": { "command": "uvx",
110
+ "args": ["--from", "git+https://github.com/gobeyondfj-cmd/boundra", "boundra-mcp"] } } }
111
+ ```
112
+
113
+ **5 · Every payment gets a verdict before signing**
114
+
115
+ Your agent calls `evaluate_payment`; the 5-stage pipeline answers
116
+ **ALLOW** (sign & settle) / **DENY** (aborted pre-signature, zero on-chain
117
+ trace) / **ASK** (a challenge bound to this exact payment).
118
+
119
+ **6 · When the agent asks, you decide**
120
+
121
+ ```bash
122
+ uvx --from git+https://github.com/gobeyondfj-cmd/boundra boundra-approve
123
+ ```
124
+
125
+ Paste the ASK challenge, sign it on your device — the agent retries with the
126
+ signed approval token. Forged, rebound, or replayed tokens are rejected.
127
+
128
+ **7 · Watch, update, revoke**
129
+
130
+ `get_spend_report` / `get_audit_trail` / `get_policy_versions` keep you in
131
+ control day to day. Every policy change is a new signed version
132
+ (`set_policy`); `revoke_policy` is instant default-deny and **free forever**.
133
+
134
+ ## Quick start (from source)
135
+
136
+ ```bash
137
+ cd boundra
138
+
139
+ # Mode 1: offline simulation (run this first — the full flow in 30 seconds)
140
+ python demo/demo.py
141
+
142
+ # Mode 2: real x402 + MCP
143
+ python -m venv .venv && .venv/bin/pip install \
144
+ "x402[evm,httpx]" mcp eth-account fastapi uvicorn
145
+ .venv/bin/python tests/test_mcp_client.py # MCP protocol-level tests
146
+ .venv/bin/python demo/setup_wallets.py # generate Base Sepolia test wallets + faucet guide
147
+ .venv/bin/python demo/demo_real.py # real protocol end-to-end (settles on-chain after funding)
148
+ ```
149
+
150
+ ## Architecture: where the gateway stands
151
+
152
+ ```
153
+ Agent framework (Claude / custom)
154
+ │ MCP protocol (stdio)
155
+ ▼
156
+ mcp_server.py ──→ policy.py 5-stage evaluation pipeline
157
+ (policy decision semantic → whitelist → limit → approval → budget
158
+ point)
159
+ ▲
160
+ │ on_before_payment_creation hook (x402 SDK v2 native interception point)
161
+ x402_buyer.py ──sign (EIP-3009)──→ x402 server ──→ facilitator ──→ Base Sepolia
162
+ ```
163
+
164
+ **Key finding**: x402 SDK v2 natively provides the `on_before_payment_creation`
165
+ hook plus `register_policy` / `set_spend_controls` — the policy layer is not a
166
+ bolt-on; it is the slot the official protocol stack reserves. This validates
167
+ the wedge.
168
+
169
+ ## File map
170
+
171
+ ```
172
+ boundra/
173
+ ├── policy.py intent compilation (NL→Policy, bilingual CN/EN) + 5-stage pipeline + platform red lines
174
+ ├── signed_policy.py ★ signed policy documents + version chain + revocation (keccak)
175
+ ├── approval.py ★ signed approval tokens (challenge → user signs → gateway verifies)
176
+ ├── mandate.py ★ task Mandates: single-use authorization, burned after use (pipeline layer 4)
177
+ ├── templates.py ★ policy template library (personal assistant / travel / dev API / procurement)
178
+ ├── chain_anchor.py ★ anchor backends: local simulation + real Base Sepolia (web3)
179
+ ├── gateway.py gateway core v3: 4-layer stacking + token verification + Mandate + revocation
180
+ ├── rail_adapters.py ★ rail adapter layer: evaluation core decoupled from settlement rails (x402 first)
181
+ ├── mcp_server.py ★ standard MCP server (11 tools, stdio)
182
+ ├── boundra_cli.py ★ boundra-init (policy wizard) + boundra-approve (challenge signer)
183
+ ├── contracts/
184
+ │ └── PolicyAnchor.sol ★ on-chain commitment contract (owner-write, anyone-read)
185
+ ├── demo/
186
+ │ ├── simulate_agent.py ★ end-to-end user journey simulation (MCP + hosted API dogfood)
187
+ │ ├── demo_policy.py signed-policy demo (impersonation / unsigned / tampering attacks all blocked)
188
+ │ ├── demo_real.py real-protocol end-to-end orchestration
189
+ │ ├── x402_resource_server.py real x402 paywall server (FastAPI middleware)
190
+ │ ├── x402_buyer.py real x402 buyer, evaluated by the MCP gateway before signing
191
+ │ ├── setup_wallets.py Base Sepolia test wallet generation
192
+ │ └── demo.py / merchant.py / agent.py offline simulation (zero dependencies)
193
+ ├── tests/
194
+ │ ├── test_product.py ★ product tests (22 assertions)
195
+ │ └── test_mcp_client.py MCP protocol-level tests
196
+ ├── docs/
197
+ │ ├── dataflow.png data-flow diagram (English)
198
+ │ └── render_*.py diagram renderers (architecture / flow / use-case / data flow)
199
+ └── state/audit.jsonl audit trail (generated at runtime, gitignored)
200
+ ```
201
+
202
+ ## Signed policies: the root of trust is the user's key, not the gateway's database (v2)
203
+
204
+ A policy is a **document signed by the user's wallet**, not a row in the
205
+ gateway's configuration:
206
+
207
+ ```
208
+ user private key signature ──→ PolicyDocument (NL rule + compiled artifact + prev_hash + version)
209
+ │ three checks: signer == owner, versions sequential, prev_hash unbroken
210
+ ▼
211
+ PolicyStore (version chain) ──→ LocalAnchor (simulated commitment; production writes to contract)
212
+ │
213
+ ▼ check_integrity before every evaluation (signature + anchor)
214
+ 5-stage pipeline; audit records cite policy version + hash
215
+ ```
216
+
217
+ - **Read-only for agents**: without the user's private key, `set_policy` always
218
+ fails — impersonation, unsigned, and tampered submissions are all blocked
219
+ (seven scenarios in `demo/demo_policy.py`)
220
+ - **Two stacked scopes**: user-level (rules for all agents) × agent-level
221
+ (per-agent rules); the strictest verdict wins
222
+ - **Every version bump is a signature**: v2 must reference v1's hash; tampering
223
+ with any historical version → signature invalid + chain broken
224
+ - **Privacy shape**: only hash commitments go on-chain; policy plaintext never
225
+ leaves the device unless the user chooses to disclose
226
+
227
+ Run: `.venv/bin/python demo/demo_policy.py`
228
+
229
+ ## MCP server tools
230
+
231
+ | Tool | Purpose | Caller |
232
+ |------|---------|--------|
233
+ | `evaluate_payment` | Pre-payment evaluation. ALLOW proceeds / DENY aborts / **ASK** returns a challenge the user signs; retry with `approval_token` | Agent |
234
+ | `set_policy` | **Privileged**: submit a new policy version; requires the owner's EIP-191 signature | User only |
235
+ | `revoke_policy` | **Privileged**: revoke a policy chain (default-deny immediately, free forever) | User only |
236
+ | `get_policy_versions` | Policy version history (chain + hashes, comparable with on-chain commitments) | Anyone |
237
+ | `get_policy` | View the legacy fallback policy | Anyone |
238
+ | `get_spend_report` | Today's spend / remaining budget | Agent |
239
+ | `get_audit_trail` | Approval audit records | Agent |
240
+ | `request_policy_change` | Agent asks the user for a policy change (queued, never self-applied) | Agent |
241
+ | `list_templates` / `render_template` | Policy template helpers | Agent |
242
+
243
+ ### Mount into Claude Desktop
244
+
245
+ One line — uvx resolves dependencies and starts the server:
246
+
247
+ ```json
248
+ {
249
+ "mcpServers": {
250
+ "boundra": {
251
+ "command": "uvx",
252
+ "args": ["--from", "git+https://github.com/gobeyondfj-cmd/boundra", "boundra-mcp"]
253
+ }
254
+ }
255
+ }
256
+ ```
257
+
258
+ On first run, use the **`boundra-init`** wizard (same package): create/import a
259
+ wallet → pick a policy template → sign → publish via MCP, about 2 minutes.
260
+ When your agent hits ASK, run **`boundra-approve`** and paste the challenge to
261
+ produce a signed approval token.
262
+
263
+ ## ⚠️ Known trust-boundary simplifications (must fix for production)
264
+
265
+ 1. ~~`human_approved` self-attested by the agent~~ **solved (v3)**: human
266
+ approval is now a signed approval token (approval.py) — ASK returns a
267
+ challenge bound to the exact payment intent; the user's device signs it;
268
+ the gateway verifies signature + field-by-field intent match + nonce
269
+ replay protection. The legacy self-attested path remains but is tagged
270
+ `approve(legacy-deprecated)`.
271
+ 2. **MCP-level interception is advisory** — an agent framework can bypass the
272
+ gateway and talk to the wallet directly. Mitigation: pair with x402's
273
+ native hook (demonstrated in `demo/demo_real.py`; the hook fires inside the SDK,
274
+ before signing). Endgame: compile the deterministic parts of policy into a
275
+ smart-contract wallet module, enforced at the settlement layer.
276
+ 3. **Semantic detection is regex-based** — production should swap in LLM
277
+ evaluation + intent anchoring.
278
+ 4. **Anchoring defaults to a local log** — the real contract
279
+ (`contracts/PolicyAnchor.sol`) and web3 client (`chain_anchor.BaseSepoliaAnchor`)
280
+ are ready; set `chain_config.json` to switch to the real chain (deploy via
281
+ Remix with test ETH).
282
+
283
+ ## Economic model: the evaluation API is itself an x402 merchant
284
+
285
+ Tiered pricing:
286
+
287
+ | Operation | Price |
288
+ |-----------|-------|
289
+ | Deterministic evaluation (`/evaluate/basic`) | Free |
290
+ | Semantic evaluation (`/evaluate/semantic`) | 100 free calls per agent; then $0.003 USDC/call (real x402 charge) |
291
+ | Policy anchoring / revocation | Free (revocation is free forever — a safety red line) |
292
+
293
+ Open core: the client, evaluation engine, and demos in this repo are
294
+ Apache-2.0. The hosted evaluation service (tiered pricing, free-quota
295
+ accounting, revenue ledger) runs from the private `boundra-ops` repo.
296
+
297
+ ## Verified / not yet verified
298
+
299
+ **Verified** (all of `test_product.py` 22 assertions + `test_mcp_client.py` pass):
300
+ 4-layer policy stacking (platform red lines × user × agent × Mandate) with
301
+ strictest-wins; signed approval tokens (valid passes, forged rejected,
302
+ intent-rebinding rejected, replay rejected); Mandate single-use; revocation
303
+ defaults to deny and a signed v2 restores; template render+compile; all MCP
304
+ tools over the wire; gateway blocks an injection attack inside the real x402
305
+ 402 round-trip before the SDK signs; the full tiered-pricing loop on Base
306
+ Sepolia (2026-10-16): free tier passes, paid tier settles $0.003 USDC for real
307
+ (buyer 20.000 → 19.997, platform address credited 0.003), dogfood hook
308
+ self-evaluates, semantic layer blocks the injection, `/revenue` ledger entry.
309
+ The settlement tx is publicly verifiable: [`0x5ad8ef4b…c474bbe`](https://sepolia.basescan.org/tx/0x5ad8ef4b4d6eef7ba34e718742068f8e8480336c12032a3a85801b101c474bbe)
310
+ (the hosted service code is closed by design — the chain is the receipt).
311
+
312
+ **Not yet verified**: real on-chain anchoring (contract ready, needs test ETH
313
+ to deploy); real user demand; semantic layer false-positive rate under real
314
+ LLM behavior distributions.