arkforge-trustlayer-client 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,53 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.pyd
5
+ .pytest_cache/
6
+ *.egg-info/
7
+ .eggs/
8
+ logs/
9
+ *.log
10
+ snapshots/
11
+ config/settings.env
12
+ config/*.credentials*
13
+ *.enc.bak
14
+
15
+ # Hot state — Postgres primary (brain_kv), backup via pg_dump
16
+ brain/ceo_state.json
17
+ brain/ceo_state.json.bak
18
+ brain/gardien_report.json
19
+ brain/funnel_health.json
20
+ brain/crm_pulse.json
21
+ brain/signal_outcomes.json
22
+ brain/signal_outcomes.json.bak
23
+ brain/activation_metrics.json
24
+ brain/epistemic_map.json
25
+ brain/epistemic_map.json.bak
26
+ brain/environment_model.json
27
+ brain/environment_model.json.bak
28
+ brain/gardien_insights.json
29
+ brain/gardien_insights.json.bak
30
+ brain/recursive_index.json
31
+ brain/calibration.json
32
+ brain/composition_candidates.json
33
+ brain/thread_archive.json
34
+ brain/working_memory.json
35
+
36
+ # Logs append-only + caches Postgres (tasks/events tables)
37
+ brain/cluster_activity.jsonl
38
+ brain/gardien_history.jsonl
39
+ brain/write_audit.jsonl
40
+ brain/event_log.jsonl
41
+ brain/task_queue.json
42
+ brain/task_queue.json.bak
43
+ brain/brain_event_log.jsonl
44
+
45
+ # Hot state — CEO rewrites continuellement
46
+ brain/cluster_state.json
47
+ brain/governance_agent_state.json
48
+ brain/hn_scan_state.json
49
+ brain/world_model.json
50
+ brain/dormant_reengagement_state.json
51
+ brain/failover_state_ovh.json
52
+ brain/gardien_alert_dedup_state.json
53
+ brain/real_results_state.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArkForge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,606 @@
1
+ Metadata-Version: 2.4
2
+ Name: arkforge-trustlayer-client
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the ArkForge Trust Layer — cryptographic proof for every AI agent API call
5
+ Project-URL: Homepage, https://arkforge.tech
6
+ Project-URL: Documentation, https://trust.arkforge.tech
7
+ Project-URL: Repository, https://github.com/ark-forge/arkforge-agent-client
8
+ Project-URL: Bug Tracker, https://github.com/ark-forge/arkforge-agent-client/issues
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: AI agents,EU AI Act,MCP,RFC 3161,agent-to-agent,audit trail,compliance,cryptographic proof,sigstore,trust layer
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Security :: Cryptography
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: requests>=2.28
23
+ Provides-Extra: stripe
24
+ Requires-Dist: stripe>=7.0.0; extra == 'stripe'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # ArkForge Agent Client
28
+
29
+ [![GitHub Stars](https://img.shields.io/github/stars/ark-forge/arkforge-agent-client?style=flat&label=Star)](https://github.com/ark-forge/arkforge-agent-client/stargazers)
30
+
31
+ A proof-of-concept demonstrating **autonomous agent-to-agent paid transactions** through the [ArkForge Trust Layer](https://github.com/ark-forge/trust-layer).
32
+
33
+ One agent (this client) calls another agent (the [ArkForge MCP EU AI Act](https://github.com/ark-forge/mcp-eu-ai-act) scanner) to scan a code repository for EU AI Act compliance. Every transaction flows through the Trust Layer, which produces a tamper-proof cryptographic proof (SHA-256 chain + Ed25519 signature + RFC 3161 certified timestamp + Sigstore Rekor public log entry).
34
+
35
+ **Free tier:** fully autonomous — the agent signs up and runs with a single curl, no card required.
36
+ **Pro tier:** one-time human setup (Stripe Checkout to save a card), fully autonomous after that.
37
+
38
+ ## Quick Start
39
+
40
+ ### 1. Get an API key
41
+
42
+ **Free plan** — no card required:
43
+
44
+ ```bash
45
+ curl -X POST https://trust.arkforge.tech/v1/keys/free-signup \
46
+ -H "Content-Type: application/json" \
47
+ -d '{"email": "your@email.com"}'
48
+ ```
49
+
50
+ Your `mcp_free_*` API key will be emailed automatically. 100 calls/month, 3 witnesses (Ed25519, RFC 3161, Sigstore Rekor — no Stripe required).
51
+
52
+ **Pro plan** — buy initial credits and save card (once):
53
+
54
+ **Option A — via setup_card.py:**
55
+
56
+ ```bash
57
+ python3 setup_card.py your@email.com --test # Test mode (Stripe test card)
58
+ python3 setup_card.py your@email.com # Live mode (real charges)
59
+ ```
60
+
61
+ **Option B — via curl:**
62
+
63
+ ```bash
64
+ curl -X POST https://trust.arkforge.tech/v1/keys/setup \
65
+ -H "Content-Type: application/json" \
66
+ -d '{"email": "your@email.com", "mode": "test", "amount": 10}'
67
+ ```
68
+
69
+ Open the returned `checkout_url` in a browser. The initial purchase (minimum 10 EUR = 100 proofs) is charged immediately and your card is saved for future top-ups. For test mode, use Stripe test card `4242 4242 4242 4242` (any future expiry, any CVC). Your API key and credits are set up automatically after payment.
70
+
71
+ ### 2. Top up credits (Pro plan)
72
+
73
+ Buy more credits any time — the saved card is charged directly, no browser required.
74
+
75
+ **Via agent.py:**
76
+
77
+ ```bash
78
+ pip install requests
79
+ export TRUST_LAYER_API_KEY="mcp_pro_..."
80
+ python3 agent.py credits 10 # Buy 10 EUR = 100 proofs — receipt auto-saved
81
+ ```
82
+
83
+ **Via curl:**
84
+
85
+ ```bash
86
+ curl -X POST https://trust.arkforge.tech/v1/credits/buy \
87
+ -H "Content-Type: application/json" \
88
+ -H "X-Api-Key: mcp_pro_..." \
89
+ -d '{"amount": 10}'
90
+ # Returns: {"credits_added": 10.0, "balance": 10.0, "proofs_available": 100, ...}
91
+ ```
92
+
93
+ Each proof costs 0.10 EUR. Min 1 EUR, max 100 EUR. Credits are deducted automatically on each proxy call. Credits never expire.
94
+
95
+ ### 3. Run a scan
96
+
97
+ ```bash
98
+ export TRUST_LAYER_API_KEY="mcp_test_..." # or mcp_pro_... for live
99
+ python3 agent.py scan https://github.com/owner/repo
100
+ ```
101
+
102
+ If you purchased credits earlier, the saved receipt is **auto-attached** as payment evidence. You can also provide one manually:
103
+
104
+ ```bash
105
+ python3 agent.py scan https://github.com/owner/repo \
106
+ --receipt-url "https://pay.stripe.com/receipts/payment/CAcaFwoV..."
107
+ ```
108
+
109
+ To skip auto-attach for a single call:
110
+
111
+ ```bash
112
+ python3 agent.py scan https://github.com/owner/repo --no-receipt
113
+ ```
114
+
115
+ **Mode B PoC — pay the scan provider directly via Stripe:**
116
+
117
+ ```bash
118
+ export STRIPE_SECRET_KEY="sk_test_..." # your agent's Stripe key
119
+ export STRIPE_PAYMENT_METHOD="pm_xxx" # saved payment method
120
+ export SCAN_PROVIDER_PRICE="100" # optional, cents EUR (default: 100 = 1.00 EUR)
121
+ python3 agent.py scan https://github.com/owner/repo --pay-provider
122
+ ```
123
+
124
+ The agent creates a Stripe `PaymentIntent` off-session, retrieves the `receipt_url` from the resulting `Charge`, and attaches it automatically as `provider_payment` to the Trust Layer call. ArkForge does not handle this money — the payment goes directly between agents.
125
+
126
+ ### 4. Just pay (no scan)
127
+
128
+ ```bash
129
+ python3 agent.py pay # auto-attaches saved receipt if any
130
+ python3 agent.py pay --no-receipt # skip auto-attach
131
+ python3 agent.py pay --receipt-url "https://pay.stripe.com/receipts/payment/..."
132
+ ```
133
+
134
+ ### 5. Verify a proof
135
+
136
+ ```bash
137
+ python3 agent.py verify prf_20260225_171714_4ebb28
138
+ ```
139
+
140
+ ### 6. Check reputation
141
+
142
+ ```bash
143
+ python3 agent.py reputation <agent_id>
144
+ ```
145
+
146
+ ```
147
+ ============================================================
148
+ AGENT REPUTATION
149
+ ============================================================
150
+ Agent: sha256:buyer_abc123...
151
+ Score: 85/100
152
+ Success rate: 100.0%
153
+ Confidence: 0.85
154
+ Formula: floor(success_rate × confidence) − penalties
155
+ Total proofs: 10
156
+ Signature: ed25519:T3hY8kLm9nPq...(verified)
157
+ ============================================================
158
+ ```
159
+
160
+ The score is publicly auditable: `score = floor(success_rate × confidence)`.
161
+ Confidence grows with volume (0.60 at 1 proof → 1.00 at 20+ proofs).
162
+ One optional penalty: −15 if the agent changed its declared identity.
163
+
164
+ ### 7. File a dispute
165
+
166
+ ```bash
167
+ python3 agent.py dispute prf_20260301_120000_abc123 "Response was empty"
168
+ ```
169
+
170
+ ```
171
+ ============================================================
172
+ DISPUTE FILED
173
+ ============================================================
174
+ Dispute ID: disp_a1b2c3d4
175
+ Proof ID: prf_20260301_120000_abc123
176
+ Status: open
177
+ Resolution: PENDING
178
+ ============================================================
179
+ ```
180
+
181
+ ### 8. View dispute history
182
+
183
+ ```bash
184
+ python3 agent.py disputes <agent_id>
185
+ ```
186
+
187
+ ```
188
+ ============================================================
189
+ DISPUTE HISTORY
190
+ ============================================================
191
+ Filed: 3
192
+ Won: 2
193
+ Lost: 1
194
+
195
+ Recent disputes:
196
+ disp_a1b2c3d4 | prf_20260301_120000_abc123 | UPHELD
197
+ disp_e5f6g7h8 | prf_20260228_090000_def456 | DENIED
198
+ disp_i9j0k1l2 | prf_20260227_150000_ghi789 | UPHELD
199
+ ============================================================
200
+ ```
201
+
202
+ ### 9. Assess an MCP server
203
+
204
+ Analyze an MCP server manifest for security risks: dangerous capabilities, tool drift since the last call, version changes.
205
+
206
+ **Quick demo** (built-in manifest with intentionally dangerous tools):
207
+
208
+ ```bash
209
+ python3 agent.py assess my-mcp-server --demo
210
+ ```
211
+
212
+ **From a manifest file:**
213
+
214
+ ```bash
215
+ # tools.json — list of tool objects (name + description minimum)
216
+ python3 agent.py assess my-mcp-server --tools-file tools.json --version 1.2.0
217
+ ```
218
+
219
+ **From a remote MCP server** (client and server on different machines):
220
+
221
+ ```bash
222
+ python3 agent.py assess my-mcp-server --server-url https://mcp.example.com --version 1.5.0
223
+ ```
224
+
225
+ The client tries in order: `GET /manifest.json`, `GET /tools`, `GET /v1/tools`, then MCP JSON-RPC `tools/list`. First successful response with a non-empty tools list is used.
226
+
227
+ ```json
228
+ [
229
+ {"name": "get_weather", "description": "Fetch weather from public API"},
230
+ {"name": "read_file", "description": "Read any file from the local filesystem"},
231
+ {"name": "exec_shell", "description": "Execute a shell command"}
232
+ ]
233
+ ```
234
+
235
+ **Example output:**
236
+
237
+ ```
238
+ ============================================================
239
+ MCP SECURITY ASSESSMENT — my-mcp-server
240
+ ============================================================
241
+ Assessment ID: asr_20260403_121500_a1b2c3
242
+ Assessed at: 2026-04-03T12:15:00Z
243
+ Risk score: 75/100 [HIGH]
244
+ Baseline: updated
245
+ Drift detected: YES
246
+ Drift summary: 1 tool added: exec_shell
247
+
248
+ Findings (3 total):
249
+ [CRITICAL] exec_shell: Tool description matches code execution pattern
250
+ [HIGH] read_file: Tool description matches filesystem read pattern
251
+ [MEDIUM] get_weather: network_access pattern detected
252
+ ============================================================
253
+ ```
254
+
255
+ Call the same server twice to see drift detection in action — the second call compares against the baseline saved by the first.
256
+
257
+ Rate limit: 100 assessments/day per API key. No credits consumed.
258
+
259
+ ### 10. Generate a compliance report
260
+
261
+ Aggregate all proofs certified under your API key over a date range and map them to a compliance framework. Four frameworks are supported:
262
+
263
+ | Framework | `--framework` value | Scope |
264
+ |-----------|---------------------|-------|
265
+ | EU AI Act (Regulation 2024/1689) | `eu_ai_act` *(default)* | Articles 9, 10, 13, 14, 17, 22 |
266
+ | ISO/IEC 42001:2023 | `iso_42001` | Clauses 6.1, 8.2, 8.4, 9.1, 9.2, 10.1 |
267
+ | NIST AI RMF 1.0 | `nist_ai_rmf` | GOVERN 1.1, MAP 1.1/5.2, MEASURE 1.1/2.5, MANAGE 1.3/4.1 |
268
+ | SOC 2 Readiness | `soc2_readiness` | CC6.1, CC6.7, CC7.2, PI1.1, PI1.2, A1.1 |
269
+
270
+ > **SOC 2 note:** `soc2_readiness` produces readiness evidence, not a formal SOC 2 audit opinion. A SOC 2 Type II report requires an independent CPA firm accredited by the AICPA.
271
+
272
+ ```bash
273
+ # Last 30 days, EU AI Act (default)
274
+ python3 agent.py compliance
275
+
276
+ # Custom range, specific framework
277
+ python3 agent.py compliance --from 2026-01-01 --to 2026-12-31 --framework eu_ai_act
278
+ python3 agent.py compliance --from 2026-01-01 --to 2026-12-31 --framework iso_42001
279
+ python3 agent.py compliance --from 2026-01-01 --to 2026-12-31 --framework nist_ai_rmf
280
+ python3 agent.py compliance --from 2026-01-01 --to 2026-12-31 --framework soc2_readiness
281
+ ```
282
+
283
+ **Example output (eu_ai_act):**
284
+
285
+ ```
286
+ ============================================================
287
+ COMPLIANCE REPORT — EU_AI_ACT
288
+ ============================================================
289
+ Report ID: rpt_20260403_122000_d4e5f6
290
+ Framework: eu_ai_act v1.0
291
+ Date range: 2026-01-01 → 2026-04-03
292
+ Proofs analyzed:47
293
+ Coverage since: indexed
294
+
295
+ Summary (6 clauses/articles):
296
+ Covered: 4
297
+ Partial: 1
298
+ Gap: 0
299
+ Not applicable: 1
300
+
301
+ Article coverage:
302
+ [OK] Art. 9 — Risk Management System: covered
303
+ [NA] Art. 10 — Data and Data Governance: not applicable
304
+ Organisational obligation — not verifiable from transaction proofs
305
+ [OK] Art. 13 — Transparency and Provision of Information: covered
306
+ [~~] Art. 14 — Human Oversight: partial
307
+ Human-controlled API key used (buyer_fingerprint present); agent not DID-verified
308
+ [OK] Art. 17 — Quality Management System: covered
309
+ [OK] Art. 22 — Record-keeping: covered
310
+
311
+ No gaps identified.
312
+ ============================================================
313
+ ```
314
+
315
+ **Example output (nist_ai_rmf):**
316
+
317
+ ```
318
+ ============================================================
319
+ COMPLIANCE REPORT — NIST_AI_RMF
320
+ ============================================================
321
+ Framework: nist_ai_rmf v1.0
322
+ Summary (7 clauses/articles):
323
+ Covered: 5
324
+ Partial: 1
325
+ Gap: 0
326
+ Not applicable: 1
327
+
328
+ Article coverage:
329
+ [NA] GOVERN 1.1 — AI Risk Policies and Procedures: not applicable
330
+ [OK] MAP 1.1 — AI System Context Established: covered
331
+ [OK] MAP 5.2 — AI Risk Tracking Practices: covered
332
+ [~~] MEASURE 1.1 — Risk Measurement Methods: partial
333
+ [OK] MEASURE 2.5 — AI System Performance Monitored: covered
334
+ [OK] MANAGE 1.3 — Risk Treatment Documented: covered
335
+ [OK] MANAGE 4.1 — Risk Monitoring Established: covered
336
+ ============================================================
337
+ ```
338
+
339
+ Requires proofs created after Trust Layer v1.3.18 (or a backfill run). No credits consumed.
340
+
341
+ ### Example scan output
342
+
343
+ ```
344
+ ============================================================
345
+ EU AI ACT COMPLIANCE SCAN — via Trust Layer
346
+ ============================================================
347
+ Timestamp: 2026-02-25T17:17:12.560154+00:00
348
+ Target: https://github.com/openai/openai-quickstart-python
349
+ Price: 0.10 EUR (from prepaid credits)
350
+ Trust Layer: https://trust.arkforge.tech/v1/proxy
351
+ Scan API: https://arkforge.tech/api/v1/scan-repo
352
+ API Key: mcp_te...
353
+
354
+ [PAYMENT]
355
+ Amount: 0.1 eur
356
+ Status: succeeded
357
+ Txn ID: crd_20260227_143012_a1b2c3
358
+
359
+ [SCAN RESULT]
360
+ Compliance: 2/3 (66.7%)
361
+ Risk Cat: limited
362
+ Frameworks: openai, anthropic
363
+
364
+ [PROOF — Trust Layer]
365
+ ID: prf_20260225_171714_4ebb28
366
+ Spec: 1.1
367
+ Chain Hash: sha256:5319f160352fea2c1889cf6dcbb9d1b431...
368
+ Request Hash: sha256:0b801bccb76376504cb2c5f92c55cd7cfd...
369
+ Signature: ed25519:T3hY8k...(verified)
370
+ Verify URL: https://trust.arkforge.tech/v1/proof/prf_20260225_171714_4ebb28
371
+ Share URL: https://arkforge.tech/trust/v/prf_20260225_171714_4ebb28
372
+ Timestamp: 2026-02-25T17:17:12Z
373
+ Upstream: Wed, 25 Feb 2026 17:17:13 GMT
374
+ TSA: pending
375
+
376
+ [ATTESTATION — Digital Stamp]
377
+ Embedded in scan result body as _arkforge_attestation
378
+ Status: VERIFIED_TRANSACTION
379
+
380
+ [RESPONSE HEADERS — Ghost Stamp]
381
+ X-ArkForge-Verified: true
382
+ X-ArkForge-Proof-ID: prf_20260225_171714_4ebb28
383
+ X-ArkForge-Trust-Link: https://arkforge.tech/trust/v/prf_20260225_171714_4ebb28
384
+
385
+ [SAVED] logs/scan_20260225_171715.json
386
+ ============================================================
387
+ ```
388
+
389
+ With `--receipt-url` or `--pay-provider`, an additional section appears:
390
+
391
+ ```
392
+ [PAYMENT EVIDENCE — External Receipt]
393
+ Fetch: OK (fetched)
394
+ Hash: sha256:af65b75f3901dfd0ed9590a009bf7283e318...
395
+ Parsing: success
396
+ Amount: 25.0 usd
397
+ Status: Paid
398
+ Date: February 28, 2026
399
+ Verified: fetched
400
+ ```
401
+
402
+ With `--pay-provider`, the Stripe payment is shown before the scan:
403
+
404
+ ```
405
+ [MODE B] Paying scan provider directly via Stripe (1.00 EUR)...
406
+ [MODE B] PaymentIntent: pi_3Pxxx
407
+ [MODE B] Amount: 1.00 EUR
408
+ [MODE B] Receipt: https://pay.stripe.com/receipts/payment/CAcaFwoV...
409
+
410
+ ============================================================
411
+ EU AI ACT COMPLIANCE SCAN — via Trust Layer
412
+ ============================================================
413
+ ...
414
+ Receipt URL: https://pay.stripe.com/receipts/payment/CAcaFwoV...
415
+ ```
416
+
417
+ The proof is emitted with `spec_version: 2.0` and includes `receipt_content_hash` in the chain.
418
+
419
+ ## Library usage
420
+
421
+ `agent.py` can be imported as a Python module:
422
+
423
+ ```python
424
+ from agent import (
425
+ scan_repo, verify_proof, get_reputation, file_dispute, get_disputes,
426
+ assess_mcp, compliance_report,
427
+ )
428
+
429
+ # Compliance report — choose any framework
430
+ report = compliance_report("2026-01-01", "2026-03-31", framework="nist_ai_rmf")
431
+ report = compliance_report("2026-01-01", "2026-03-31", framework="soc2_readiness")
432
+ report = compliance_report("2026-01-01", "2026-03-31", framework="iso_42001")
433
+ report = compliance_report("2026-01-01", "2026-03-31") # defaults to eu_ai_act
434
+
435
+ # All functions return dicts — check for "error" key on failure
436
+ result = scan_repo("https://github.com/owner/repo")
437
+ if "error" in result:
438
+ print(result["error"])
439
+ else:
440
+ proof = result["proof"]
441
+ print(proof["proof_id"])
442
+
443
+ # Public endpoints (no API key required)
444
+ rep = get_reputation("buyer_abc123")
445
+ disputes = get_disputes("buyer_abc123")
446
+
447
+ # Authenticated endpoints (TRUST_LAYER_API_KEY env var)
448
+ result = file_dispute("prf_...", "Response was empty")
449
+ ```
450
+
451
+ Config is read from environment variables at call time, so you can set them after import:
452
+
453
+ ```python
454
+ import os
455
+ os.environ["TRUST_LAYER_API_KEY"] = "mcp_pro_..."
456
+ os.environ["TRUST_LAYER_BASE"] = "http://localhost:8100" # local dev
457
+
458
+ from agent import scan_repo
459
+ result = scan_repo("https://github.com/owner/repo")
460
+ ```
461
+
462
+ ## Why does this matter?
463
+
464
+ AI agents are starting to act on behalf of humans — browsing, coding, deploying. The next step is agents **paying for services autonomously**. But autonomous payments create a trust problem:
465
+
466
+ - How does the buyer agent know it got what it paid for?
467
+ - How does the seller agent prove it delivered?
468
+ - How does the human owner verify what happened?
469
+
470
+ ## How the Trust Layer works
471
+
472
+ Every transaction produces a chain of verifiable proofs:
473
+
474
+ ```
475
+ Agent Client
476
+ |
477
+ v
478
+ Trust Layer (/v1/proxy)
479
+ |--- Validates API key
480
+ |--- Debits prepaid credits (Pro only — Free skips this)
481
+ |--- Fetches external receipt if --receipt-url provided (optional)
482
+ |--- Forwards scan request to upstream API
483
+ |--- Hashes request + response (SHA-256 chain)
484
+ |--- Binds receipt content hash to chain (if present)
485
+ |--- Signs with Ed25519
486
+ |--- Submits to RFC 3161 TSA (certified timestamp)
487
+ |--- Returns proof + scan result
488
+ |
489
+ v
490
+ Agent receives: scan report + cryptographic proof [+ payment evidence]
491
+ ```
492
+
493
+ **Each layer is independently verifiable:**
494
+
495
+ | Proof | Verified by | Can be faked? | Plan |
496
+ |---|---|---|---|
497
+ | Ed25519 signature | Verify with ArkForge public key | No (cryptographic) | All |
498
+ | SHA-256 hash chain | Trust Layer verification URL | No (deterministic) | All |
499
+ | RFC 3161 TSA | `openssl ts -verify` | No (certified by trusted TSA) | All |
500
+ | Sigstore Rekor | [search.sigstore.dev](https://search.sigstore.dev) — public log by Linux Foundation | No (append-only public log) | All |
501
+ | Stripe receipt | Stripe dashboard (for credit purchase) | No (Stripe is source of truth) | Pro only |
502
+ | External receipt | `--receipt-url` — fetched, hashed, bound to proof | No (SHA-256 of raw content) | All (optional) |
503
+ | Scan result | Re-running scan on same repo | No (deterministic) | All |
504
+ | Local log | `logs/*.json` + `proofs/*.json` | Tamper-evident (contains hashes) | All |
505
+
506
+ ### Three-layer proof system
507
+
508
+ Every transaction carries the ArkForge mark at 3 levels:
509
+
510
+ | Level | Where | For whom | What |
511
+ |-------|-------|----------|------|
512
+ | **1 — Digital Stamp** | `service_response.body._arkforge_attestation` | Agents (JSON consumers) | Proof ID, seal URL, verification status |
513
+ | **2 — Ghost Stamp** | HTTP response headers | Infra / monitoring | `X-ArkForge-Verified`, `X-ArkForge-Proof-ID`, `X-ArkForge-Trust-Link` |
514
+ | **3 — Visual Stamp** | HTML proof page | Humans / legal | Colored badge (green/orange/red), full proof details |
515
+
516
+ Open any proof in a browser: `https://arkforge.tech/trust/v/prf_...` — the short URL redirects to a self-contained HTML page with all verification details.
517
+
518
+ ## Transparency Notice
519
+
520
+ Both this agent (buyer) and the ArkForge scan API (seller) are built and controlled by the same team (ArkForge). This is a proof-of-concept — not an attempt to simulate independent entities. The architecture is designed so that it **would work identically** between independent parties.
521
+
522
+ ## Proof fields
523
+
524
+ | Field | Description |
525
+ |-------|-------------|
526
+ | `proof.spec_version` | Proof format version: `1.1` (standard) or `2.0` (with receipt). See [proof-spec](https://github.com/ark-forge/proof-spec) |
527
+ | `proof.arkforge_signature` | Ed25519 signature of the chain hash |
528
+ | `proof.arkforge_pubkey` | ArkForge's public key for verification |
529
+ | `proof.upstream_timestamp` | Upstream service's `Date` header |
530
+ | `proof.timestamp_authority.tsr_base64` | Embedded TSR file (base64, available after background processing) |
531
+ | `proof.provider_payment` | Provider payment receipt verification — present when `--receipt-url` or `--pay-provider` was used (Mode B). Not the ArkForge certification fee. |
532
+ | `proof.provider_payment.receipt_content_hash` | SHA-256 of raw receipt bytes — bound to chain hash (triggers spec 2.0) |
533
+ | `proof.provider_payment.parsed_fields` | Extracted amount, currency, status, date (best-effort) |
534
+ | `proof.transaction_success` | Whether the upstream service returned a success response (HTTP status < 400) |
535
+ | `proof.upstream_status_code` | HTTP status code returned by the upstream service |
536
+ | `proof.disputed` | Whether this proof has been disputed |
537
+ | `proof.dispute_id` | Reference to the dispute record (e.g. `disp_a1b2c3d4`) |
538
+
539
+ ## Commands
540
+
541
+ | Command | Description |
542
+ |---------|-------------|
543
+ | `python3 agent.py scan <repo_url>` | Scan repo via Trust Layer (auto-attaches saved receipt) |
544
+ | `python3 agent.py scan <repo_url> --pay-provider` | Mode B PoC: pay provider via Stripe then scan (proof spec 2.0) |
545
+ | `python3 agent.py scan <repo_url> --receipt-url URL` | Attach a manual provider receipt (Mode B, manual) |
546
+ | `python3 agent.py scan <repo_url> --no-receipt` | Skip auto-attach for this call |
547
+ | `python3 agent.py pay [--receipt-url URL] [--no-receipt]` | Payment + proof only (auto-attaches saved receipt) |
548
+ | `python3 agent.py credits <amount>` | Buy prepaid credits — **saves receipt URL** for future calls |
549
+ | `python3 agent.py verify <proof_id>` | Verify an existing proof (shows payment evidence if present) |
550
+ | `python3 agent.py reputation <agent_id>` | Check agent reputation score (0-100) |
551
+ | `python3 agent.py dispute <proof_id> "reason"` | File a dispute against a proof |
552
+ | `python3 agent.py disputes <agent_id>` | View dispute history for an agent |
553
+ | `python3 agent.py assess <server_id> --demo` | Assess MCP server security posture (built-in demo manifest) |
554
+ | `python3 agent.py assess <server_id> --tools-file f.json` | Assess MCP server from manifest file |
555
+ | `python3 agent.py assess <server_id> --server-url URL [--version V]` | Fetch manifest from remote server, then assess |
556
+ | `python3 agent.py compliance` | Compliance report — EU AI Act, last 30 days (default) |
557
+ | `python3 agent.py compliance --from DATE --to DATE [--framework F]` | Compliance report — custom range and framework (`eu_ai_act`, `iso_42001`, `nist_ai_rmf`, `soc2_readiness`) |
558
+
559
+ ## Plans
560
+
561
+ | Key prefix | Plan | Stripe | Witnesses | Limits |
562
+ |---|---|---|---|---|
563
+ | `mcp_free_*` | Free | No | 3 (Ed25519, RFC 3161 TSA, Sigstore Rekor) + optional external receipt | 100/month |
564
+ | `mcp_test_*` | Test | Test mode (no real charges) | 3 + optional external receipt | Dev only |
565
+ | `mcp_pro_*` | Pro | Prepaid credits (0.10 EUR/proof) | 3 (+ Stripe receipt) + optional external receipt | 100/day |
566
+
567
+ ## Prerequisites
568
+
569
+ - Python 3.10+
570
+ - `pip install requests`
571
+ - `pip install stripe` (only for `--pay-provider`)
572
+
573
+ ## Environment variables
574
+
575
+ | Variable | Default | Description |
576
+ |----------|---------|-------------|
577
+ | `TRUST_LAYER_API_KEY` | — | API key (required) |
578
+ | `TRUST_LAYER_BASE` | `https://trust.arkforge.tech` | Trust Layer URL |
579
+ | `SCAN_API_TARGET` | `https://arkforge.tech/api/v1/scan-repo` | Upstream scan endpoint |
580
+ | `STRIPE_SECRET_KEY` | — | Agent's Stripe secret key (`sk_test_…` / `sk_live_…`) — Mode B only |
581
+ | `STRIPE_PAYMENT_METHOD` | — | Saved Stripe payment method ID (`pm_…`) — Mode B only |
582
+ | `SCAN_PROVIDER_PRICE` | `100` | Provider payment amount in cents EUR (100 = 1.00 EUR) — Mode B only |
583
+
584
+ ## Architecture
585
+
586
+ ```
587
+ arkforge-agent-client/
588
+ agent.py # CLI + importable library (10 commands)
589
+ setup_card.py # One-time: buy initial credits + save card via Stripe Checkout
590
+ requirements.txt # requests + stripe (optional for --pay-provider)
591
+ .last_receipt.json # Auto-saved Stripe receipt URL (gitignored)
592
+ logs/ # Transaction logs (JSON, gitignored)
593
+ proofs/ # Cryptographic proofs (JSON, gitignored)
594
+ ```
595
+
596
+ ## Roadmap
597
+
598
+ Third-party provider support and multi-PSP payment verification are coming. See the [Trust Layer roadmap](https://github.com/ark-forge/trust-layer/blob/main/ROADMAP.md).
599
+
600
+ ## License
601
+
602
+ MIT
603
+
604
+ ---
605
+
606
+ Questions or feedback? Open an [issue](https://github.com/ark-forge/arkforge-agent-client/issues).