@agenttrust-sdk/mcp 0.2.5 → 0.3.0
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.
- package/dist/embedded-docs/architecture.mdx +174 -0
- package/dist/embedded-docs/getting-started/quickstart.mdx +79 -56
- package/dist/embedded-docs/index.mdx +54 -37
- package/dist/embedded-docs/integration-guides/capability-namespaces.mdx +135 -8
- package/dist/embedded-docs/integration-guides/custom-attestor.mdx +169 -8
- package/dist/embedded-docs/integration-guides/dexter-adapter.mdx +76 -0
- package/dist/embedded-docs/integration-guides/facilitator-adapters.mdx +85 -41
- package/dist/embedded-docs/integration-guides/pay-sh-adapter.mdx +90 -54
- package/dist/embedded-docs/integration-guides/x402-facilitator.mdx +55 -24
- package/dist/embedded-docs/mcp/hosted-endpoint.mdx +197 -0
- package/dist/embedded-docs/mcp/index.mdx +108 -0
- package/dist/embedded-docs/mcp/install.mdx +183 -0
- package/dist/embedded-docs/mcp/prompts.mdx +90 -0
- package/dist/embedded-docs/mcp/resources.mdx +115 -0
- package/dist/embedded-docs/mcp/tools.mdx +156 -0
- package/dist/embedded-docs/programs/policy-vault/composer.mdx +117 -0
- package/dist/embedded-docs/programs/policy-vault/counterparty-tier-policy.mdx +81 -9
- package/dist/embedded-docs/programs/policy-vault/index.mdx +77 -47
- package/dist/embedded-docs/programs/policy-vault/kill-switch-policy.mdx +65 -8
- package/dist/embedded-docs/programs/policy-vault/require-validation-policy.mdx +76 -8
- package/dist/embedded-docs/programs/policy-vault/spending-policy.mdx +83 -8
- package/dist/embedded-docs/programs/policy-vault/velocity-policy.mdx +85 -8
- package/dist/embedded-docs/programs/trustgate.mdx +112 -30
- package/dist/embedded-docs/programs/validation-registry.mdx +139 -32
- package/dist/embedded-docs/reference/byte-offset-reference.mdx +102 -13
- package/dist/embedded-docs/reference/capability-namespaces.mdx +56 -0
- package/dist/embedded-docs/reference/changelog.mdx +230 -13
- package/dist/embedded-docs/reference/deny-reason-codes.mdx +86 -0
- package/dist/embedded-docs/reference/devnet-program-ids.mdx +50 -8
- package/dist/embedded-docs/reference/discriminator-constants.mdx +104 -10
- package/dist/embedded-docs/reference/mainnet-program-ids.mdx +89 -5
- package/dist/embedded-docs/reference/quantu-agent-registry.mdx +104 -9
- package/dist/embedded-docs/sdk/exports-reference.mdx +239 -0
- package/dist/embedded-docs/sdk/gate-payment.mdx +99 -14
- package/dist/embedded-docs/sdk/index.mdx +141 -40
- package/dist/embedded-docs/sdk/mount-trustgate.mdx +178 -8
- package/dist/embedded-docs/verification/adversarial-harness.mdx +88 -0
- package/dist/embedded-docs/verification/atomic-tx-invariant.mdx +141 -0
- package/dist/embedded-docs/verification/chained-validation.mdx +87 -0
- package/dist/embedded-docs/verification/devnet-smoke.mdx +85 -0
- package/dist/embedded-docs/verification/index.mdx +31 -0
- package/dist/embedded-docs/verification/kani-proofs.mdx +144 -0
- package/dist/embedded-docs/verification/live-evidence.mdx +180 -0
- package/dist/tools/read/get-quantu-reputation.d.ts +50 -11
- package/dist/tools/read/get-quantu-reputation.js +75 -26
- package/dist/tools/read/get-quantu-reputation.js.map +1 -1
- package/dist/tools/write/emit-feedback.d.ts +6 -0
- package/dist/tools/write/emit-feedback.js +12 -1
- package/dist/tools/write/emit-feedback.js.map +1 -1
- package/package.json +16 -15
- package/scripts/install-claude-desktop.sh +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Architecture
|
|
3
|
+
description: How the three Anchor programs, the SDK, and the facilitator-adapter layer compose into one settlement path.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
AgentTrust is three Anchor programs plus a TypeScript surface that mounts them on any x402 facilitator. This page is the wiring. Byte-precise PDA layouts, instruction signatures, and deny-reason codes live under [Programs](/programs/policy-vault).
|
|
7
|
+
|
|
8
|
+
## Composition diagram
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
┌───────────────────────────────────────────────────────────────────────┐
|
|
12
|
+
│ x402 Facilitator (Pay.sh ★ default · Dexter · atxp · MCPay) │
|
|
13
|
+
│ │
|
|
14
|
+
│ import { mountTrustGate } from "@agenttrust-sdk/trustgate/express" │
|
|
15
|
+
│ await mountTrustGate(app, { atomicityEnforced: true, … }) │
|
|
16
|
+
│ │
|
|
17
|
+
│ ★ Pay.sh = Solana Foundation's first x402 facilitator (May 5, 2026) │
|
|
18
|
+
└───────────────────────────────────────────────────────────────────────┘
|
|
19
|
+
│
|
|
20
|
+
▼ POST /verify | /settle | /dispute
|
|
21
|
+
┌──────────────────────────────────────────────────────────┐
|
|
22
|
+
│ TrustGate (Anchor program) │
|
|
23
|
+
│ ├─ init_authority (per-facilitator PDA) │
|
|
24
|
+
│ ├─ emit_feedback ── PDA-signed CPI ──┐ │
|
|
25
|
+
│ └─ dispute_payment │ │
|
|
26
|
+
└─────────────────┬──────────────────────┼─────────────────┘
|
|
27
|
+
│ │
|
|
28
|
+
│ CPI │ CPI
|
|
29
|
+
▼ ▼
|
|
30
|
+
┌─────────────────────────────┐ ┌──────────────────────────────┐
|
|
31
|
+
│ PolicyVault │ │ Quantu agent-registry-8004 │
|
|
32
|
+
│ ├─ gate_payment composer │ │ ├─ give_feedback │
|
|
33
|
+
│ │ (fail-fast 5 policies) │ │ └─ atom-engine::AtomStats │
|
|
34
|
+
│ ├─ KillSwitch • Spending │ │ (tier @ byte 551) │
|
|
35
|
+
│ ├─ Velocity • Counterparty │ │ │
|
|
36
|
+
│ └─ RequireValidation │ │ Pinned commit: bfb09ad │
|
|
37
|
+
│ │ │ Read via byte-offset parser │
|
|
38
|
+
│ reads ValidationAttestation│ │ (zero Cargo dep) │
|
|
39
|
+
└─────────────────┬───────────┘ └──────────────────────────────┘
|
|
40
|
+
│
|
|
41
|
+
▼
|
|
42
|
+
┌──────────────────────────────────────────┐
|
|
43
|
+
│ ValidationRegistry │
|
|
44
|
+
│ ├─ register_namespace / _attestor │
|
|
45
|
+
│ ├─ request / respond / revoke │
|
|
46
|
+
│ └─ ValidationAttestation PDA │
|
|
47
|
+
│ (read by PolicyVault parser) │
|
|
48
|
+
└──────────────────────────────────────────┘
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A single `composeAtomicSettleTx()` call in the SDK builds one Solana transaction with three instructions in canonical order: `gate_payment_strict` → SPL `transferChecked` → `emit_feedback`. The transaction either commits all three or none — never two of three. That is the load-bearing safety property the SDK enforces at three layers.
|
|
52
|
+
|
|
53
|
+
## The three programs
|
|
54
|
+
|
|
55
|
+
### PolicyVault — the decision engine
|
|
56
|
+
|
|
57
|
+
Five orthogonal policy kinds compose under one `gate_payment` instruction with fail-fast semantics:
|
|
58
|
+
|
|
59
|
+
| Order | Policy | What it checks |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| 1 | `KillSwitch` | per-agent paused flag — multisig-controlled emergency stop |
|
|
62
|
+
| 2 | `Spending` | per-tx, daily (UTC midnight), weekly (ISO Monday) limits |
|
|
63
|
+
| 3 | `Velocity` | sliding-window cumulative spend, payer-tier-decayed limits |
|
|
64
|
+
| 4 | `CounterpartyTier` | payee `AtomStats.trust_tier` (byte 551), risk score, confidence |
|
|
65
|
+
| 5 | `RequireValidation` | gates against a `ValidationAttestation` PDA (capability proof) |
|
|
66
|
+
|
|
67
|
+
The composer returns `Allow`, `Deny(reason)`, or `RequireValidation(capability_hash)`. State changes — daily / weekly counters, velocity ledger — apply only on `Allow`. `Deny` and `RequireValidation` mutate nothing.
|
|
68
|
+
|
|
69
|
+
A strict variant — `gate_payment_strict` — converts non-`Allow` into `Err`. That is the variant the SDK's atomic composer uses: any `Deny` on the gate fails the entire bundled transaction. The Phase J5 Kani proof `gate_payment_strict_correctness` pins the biconditional — strict returns `Ok(())` if and only if the lazy composer returns `Allow` — so a future change cannot silently re-route the `Deny` arm to an `Ok` return.
|
|
70
|
+
|
|
71
|
+
Byte-precise reference: [PolicyVault](/programs/policy-vault). Composer: [Composer](/programs/policy-vault/composer).
|
|
72
|
+
|
|
73
|
+
### TrustGate — the facilitator-side program
|
|
74
|
+
|
|
75
|
+
Two PDAs, three instructions:
|
|
76
|
+
|
|
77
|
+
| PDA | Seeds | Role |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `TrustGateAuthority` | `["trustgate_auth", facilitator]` | Per-facilitator PDA signer for the CPI |
|
|
80
|
+
| `FeedbackEmissionLog` | `["feedback_log", payment_id_hash]` | Init-only idempotency receipt |
|
|
81
|
+
|
|
82
|
+
`emit_feedback` PDA-signs a CPI into Quantu's `agent-registry-8004::give_feedback`. The `FeedbackEmissionLog` is created via Anchor's `init` constraint — a second tx with the same `payment_id_hash` fails account-already-in-use, so retries cannot double-emit. `dispute_payment` writes a negative-score variant for disputed payments.
|
|
83
|
+
|
|
84
|
+
Byte-precise reference: [TrustGate](/programs/trustgate). SDK reference: [SDK → mountTrustGate](/sdk/mount-trustgate).
|
|
85
|
+
|
|
86
|
+
### ValidationRegistry — the third ERC-8004 leg
|
|
87
|
+
|
|
88
|
+
Five instructions over four PDAs:
|
|
89
|
+
|
|
90
|
+
| Instruction | Effect |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `register_namespace` | permissionless; caller computes `SHA256(name_utf8)` |
|
|
93
|
+
| `register_attestor` | self-registration with display URI |
|
|
94
|
+
| `request_validation` | open a request for `(subject, capability)` |
|
|
95
|
+
| `respond_to_validation` | attestor writes the attestation PDA |
|
|
96
|
+
| `revoke_validation` | original attestor sets `revoked = true` |
|
|
97
|
+
|
|
98
|
+
The v1 sybil-resistance model is downstream-consumer filtering: PolicyVault stores a per-policy `accepted_attestors[]` array (length 2). Only attestations from those keys flip `RequireValidation` to `Allow`. Permissionless registration plus opinionated downstream filtering trades global gatekeeping for local trust — the only model that scales with the number of facilitators.
|
|
99
|
+
|
|
100
|
+
Byte-precise reference: [ValidationRegistry](/programs/validation-registry). v1 capability namespaces seeded on devnet: [Reference → Capability namespaces](/reference/capability-namespaces).
|
|
101
|
+
|
|
102
|
+
## The FacilitatorAdapter pattern
|
|
103
|
+
|
|
104
|
+
Every x402 facilitator carries the same payment intent but differs in headers, body shape, proof payload, retry behavior, and settlement metadata. The adapter layer isolates those differences in five methods:
|
|
105
|
+
|
|
106
|
+
| Method | Responsibility |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `parseRequest(req)` | translate the facilitator's request into `VerifyContext` |
|
|
109
|
+
| `formatChallenge(decision, ctx)` | render `Allow` / `Deny` / `RequireValidation` in that facilitator's wire format |
|
|
110
|
+
| `formatSettlement(ctx)` | produce settlement metadata or an unsigned transaction skeleton |
|
|
111
|
+
| `validatePaymentProof(proof, ctx)` | verify proof shape and cross-check the verify-time context |
|
|
112
|
+
| `emitFeedback(ctx, settlement)` | call the feedback CPI idempotently |
|
|
113
|
+
|
|
114
|
+
Routes (`/verify`, `/settle`, `/dispute`), the policy gate, and the registry reads do not branch on facilitator name. Pay.sh is the canonical implementation in [`trustgate/server/src/facilitators/pay-sh/`](https://github.com/agenttrust-labs/agenttrust/tree/main/trustgate/server/src/facilitators/pay-sh); Dexter, atxp, and MCPay share the same interface. Adding a fifth facilitator stays under a hundred lines.
|
|
115
|
+
|
|
116
|
+
Walkthrough: [Pay.sh adapter](/integration-guides/pay-sh-adapter). Build your own: [Facilitator adapters](/integration-guides/facilitator-adapters).
|
|
117
|
+
|
|
118
|
+
## The atomic-tx invariant
|
|
119
|
+
|
|
120
|
+
`gate_payment_strict` mutates state on `Allow`:
|
|
121
|
+
|
|
122
|
+
- `PolicyAccount.spending_today_used`, `spending_today_anchor`
|
|
123
|
+
- `PolicyAccount.spending_week_used`, `spending_week_anchor`
|
|
124
|
+
- `VelocityLedger.cumulative_amount`, `last_commit_slot`
|
|
125
|
+
|
|
126
|
+
If the SPL transfer reverts after that mutation — and the two instructions are in *different* Solana transactions — the gate's state is durable while no value moved. Subsequent `gate_payment` calls read the inflated counters and may deny a legitimate payment, or velocity caps appear hit when nothing real has happened.
|
|
127
|
+
|
|
128
|
+
The corruption vector is most cleanly triggered by a Token-2022 mint with a `TransferHook` extension that reverts on a compliance check, but it is mint-extension-agnostic: any failing inner instruction in a split flow corrupts state the same way.
|
|
129
|
+
|
|
130
|
+
The SDK closes the corruption vector at three layers:
|
|
131
|
+
|
|
132
|
+
1. **Compile-time literal-type guard.** `AtomicityEnforced` is the literal type `{ atomicityEnforced: true }`. TypeScript rejects callers passing `false` or omitting the field. No runtime cost.
|
|
133
|
+
2. **Runtime guard.** `assertAtomicityEnforced` throws `AtomicityNotEnforcedError` for any value that isn't strictly `=== true`. Catches `as any` cast bypasses.
|
|
134
|
+
3. **Composer structure.** `composeAtomicSettleTx` returns one `Transaction` with exactly three instructions in canonical order (gate, transfer, feedback). Any other shape is a programming error.
|
|
135
|
+
|
|
136
|
+
Plus the on-chain Kani proof `gate_payment_strict_correctness` pins the strict handler's contract end-to-end: `Ok(())` if and only if the composer returned `Allow`. Full proof: [Verification → Atomic-tx invariant](/verification/atomic-tx-invariant). Background: [`docs/proofs/transfer-hook-atomicity.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/proofs/transfer-hook-atomicity.md).
|
|
137
|
+
|
|
138
|
+
## ERC-8004 wiring
|
|
139
|
+
|
|
140
|
+
Quantu Labs published two of the three ERC-8004 legs on Solana:
|
|
141
|
+
|
|
142
|
+
- `agent-registry-8004` — agent identity plus the reputation surface (the `give_feedback` instruction). Each agent gets a Metaplex Core asset plus a Borsh-typed `AgentAccount` PDA.
|
|
143
|
+
- `atom-engine` — confidence-weighted reputation aggregation. The `AtomStats` PDA stores `tier_immediate` and `tier_confirmed` as single bytes.
|
|
144
|
+
|
|
145
|
+
The third leg — capability validation — was scaffolded in `8004-solana` v0.4 then archived in v0.5.0 pending a redesign. AgentTrust's `ValidationRegistry` productizes it. The semantics align with the ERC-8004 V variant: who attests to a capability the payer's policy requires (KYC tier, audit attestation, jurisdictional compliance, model-card provenance, payment-network membership).
|
|
146
|
+
|
|
147
|
+
PolicyVault reads from both Quantu legs:
|
|
148
|
+
|
|
149
|
+
| Field | Source PDA | Offset | Width |
|
|
150
|
+
|---|---|---|---|
|
|
151
|
+
| trust tier (immediate) | `AtomStats` | byte 551 | u8 |
|
|
152
|
+
| trust tier (confirmed) | `AtomStats` | byte 555 | u8 |
|
|
153
|
+
| risk score | `AtomStats` | byte 549 | u8 |
|
|
154
|
+
| confidence | `AtomStats` | byte 557 | u16 LE |
|
|
155
|
+
| schema version canary | `AtomStats` | byte 560 | u8 (must equal 1) |
|
|
156
|
+
|
|
157
|
+
A schema bump on the Quantu side fails the canary check loud rather than silently misreading fields. Full byte-offset reference: [Reference → Byte offsets](/reference/byte-offset-reference).
|
|
158
|
+
|
|
159
|
+
## Read next
|
|
160
|
+
|
|
161
|
+
<Cards>
|
|
162
|
+
<Card title="PolicyVault composer" href="/programs/policy-vault/composer">
|
|
163
|
+
The pure-Rust orchestration that ties the five policy kinds together.
|
|
164
|
+
</Card>
|
|
165
|
+
<Card title="Atomic-tx invariant" href="/verification/atomic-tx-invariant">
|
|
166
|
+
Three layers of proof that gate + transfer + feedback execute as one tx or none.
|
|
167
|
+
</Card>
|
|
168
|
+
<Card title="Live evidence" href="/verification/live-evidence">
|
|
169
|
+
Six Kani proofs, devnet smoke traces, the chained-validation 4-sig trace.
|
|
170
|
+
</Card>
|
|
171
|
+
<Card title="Pay.sh adapter" href="/integration-guides/pay-sh-adapter">
|
|
172
|
+
The canonical FacilitatorAdapter implementation, end to end.
|
|
173
|
+
</Card>
|
|
174
|
+
</Cards>
|
|
@@ -1,100 +1,123 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Quickstart
|
|
3
|
-
description:
|
|
3
|
+
description: Hit the hosted devnet build, install the SDK, wire the MCP server. Three paths, no clone, under five minutes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Three live paths. Each runs against the hosted devnet endpoints under `*.agenttrust.tech`. None require a local clone.
|
|
7
7
|
|
|
8
|
-
## 1.
|
|
8
|
+
## 1. Hit the live demo
|
|
9
|
+
|
|
10
|
+
The demo at [`demo.agenttrust.tech`](https://demo.agenttrust.tech) runs the full Pay.sh + AgentTrust flow against deployed devnet programs. With no payment proof, `/protected` returns a real x402 v2 challenge:
|
|
9
11
|
|
|
10
12
|
```bash
|
|
11
|
-
|
|
13
|
+
curl -i https://demo.agenttrust.tech/protected
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
The
|
|
15
|
-
|
|
16
|
-
## 2. Build the demo
|
|
16
|
+
The response carries `HTTP/2 402` with a SERVICE-signed `payment-required` envelope (base64). To walk the full Allow → settle → emit_feedback path, install Pay.sh and let it pay:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
|
|
19
|
+
pay --sandbox curl https://demo.agenttrust.tech/protected
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Three deterministic counterparties drive each decision branch. Fetch their pubkeys from the demo's health endpoint:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
|
|
25
|
+
curl -s https://demo.agenttrust.tech/health | jq '.counterparties'
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
| Tier | Header | Decision |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| 0 | `X-Demo-Payer-Agent: <tier-0 pubkey>` | `402 Deny — CounterpartyTierBelowMin` |
|
|
31
|
+
| 1 | `X-Demo-Payer-Agent: <tier-1 pubkey>` | `402 Deny — CounterpartyTierBelowMin` |
|
|
32
|
+
| 3 | `X-Demo-Payer-Agent: <tier-3 pubkey>` | `200 Allow + X-Payment-Receipt` |
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| `GET /health` | deterministic demo counterparties and facilitator key |
|
|
33
|
-
| `GET /protected` | Pay.sh-gated resource |
|
|
34
|
+
The full atomic-settlement trace (gate, transfer, feedback) for the tier-3 path is captured under [Verification → Devnet smoke](/verification/devnet-smoke).
|
|
34
35
|
|
|
35
|
-
##
|
|
36
|
+
## 2. Install the SDK
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
Add [`@agenttrust-sdk/trustgate@0.2.0`](https://www.npmjs.com/package/@agenttrust-sdk/trustgate) to any Node project:
|
|
38
39
|
|
|
39
40
|
```bash
|
|
40
|
-
|
|
41
|
+
pnpm add @agenttrust-sdk/trustgate
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
Mount the middleware on an Express app:
|
|
44
45
|
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
```ts
|
|
47
|
+
import express from "express";
|
|
48
|
+
import { Keypair } from "@solana/web3.js";
|
|
49
|
+
import { mountTrustGate } from "@agenttrust-sdk/trustgate/express";
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
const app = express();
|
|
52
|
+
app.use(express.json());
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
await mountTrustGate(app, {
|
|
55
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
56
|
+
facilitatorKeypair: Keypair.fromSecretKey(/* your facilitator key */),
|
|
57
|
+
network: "solana-devnet",
|
|
58
|
+
atomicityEnforced: true, // literal `true` — TS rejects `false`
|
|
59
|
+
});
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
PAYER=$(curl -s https://demo.agenttrust.tech/health | jq -r '.counterparties[0].agent')
|
|
60
|
-
pay --sandbox curl -H "X-Demo-Payer-Agent: $PAYER" https://demo.agenttrust.tech/protected
|
|
61
|
+
app.listen(3000);
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
The `atomicityEnforced: true` literal is the SDK's load-bearing guard. The compile-time type rejects callers who omit it, the runtime throws on `as any` bypasses, and the on-chain `gate_payment_strict_correctness` Kani proof binds the strict handler's return value to the composer's `Allow` arm. Full details: [Atomic-tx invariant](/verification/atomic-tx-invariant).
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
You now have:
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
- `POST /verify` — read-only `gate_payment` simulation
|
|
69
|
+
- `POST /settle` — one-tx atomic settle (gate + transfer + feedback)
|
|
70
|
+
- `POST /dispute` — dispute path
|
|
71
|
+
- `GET /receipt/:hash` — `FeedbackEmissionLog` lookup by payment hash
|
|
70
72
|
|
|
71
|
-
##
|
|
73
|
+
## 3. Wire the MCP server
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
[`@agenttrust-sdk/mcp@0.2.6`](https://www.npmjs.com/package/@agenttrust-sdk/mcp) exposes 18 tools to any Model Context Protocol client. For Claude Desktop, drop this into your config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"agenttrust": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "@agenttrust-sdk/mcp"],
|
|
83
|
+
"env": {
|
|
84
|
+
"RPC_URL": "https://api.devnet.solana.com",
|
|
85
|
+
"NETWORK": "solana-devnet"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
```
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
Restart Claude Desktop. Then ask:
|
|
83
93
|
|
|
84
|
-
|
|
94
|
+
- *"What demo agents are available on AgentTrust?"*
|
|
95
|
+
- *"Simulate a 5-USDC payment from the tier-3 demo agent to the tier-0 demo agent against policy 1. What does the gate decide?"*
|
|
96
|
+
- *"Search the AgentTrust docs for the atomic-tx invariant."*
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
| --- | --- |
|
|
88
|
-
| `decide(ctx)` | static tier table | `simulateGatePayment` against devnet programs |
|
|
89
|
-
| `validateOnChainTx` | synthetic confirmed tx | RPC + SPL transfer parser |
|
|
90
|
-
| `emitFeedbackCpi` | synthetic feedback signature | Anchor call into `trustgate::emit_feedback` |
|
|
98
|
+
A hosted HTTP transport is also live at [`mcp.agenttrust.tech`](https://mcp.agenttrust.tech) for clients that speak `StreamableHTTPServerTransport`. Full setup: [MCP → Install](/mcp/install).
|
|
91
99
|
|
|
92
|
-
##
|
|
100
|
+
## What's running where
|
|
93
101
|
|
|
94
102
|
<ProgramIdsTable />
|
|
95
103
|
|
|
104
|
+
| Surface | URL |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| Demo | [`demo.agenttrust.tech`](https://demo.agenttrust.tech) |
|
|
107
|
+
| Facilitator (`/verify` + `/settle`) | [`api.agenttrust.tech`](https://api.agenttrust.tech) |
|
|
108
|
+
| MCP HTTP endpoint | [`mcp.agenttrust.tech`](https://mcp.agenttrust.tech) |
|
|
109
|
+
| Repo | [`github.com/agenttrust-labs/agenttrust`](https://github.com/agenttrust-labs/agenttrust) |
|
|
110
|
+
|
|
96
111
|
## Read next
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
<Cards>
|
|
114
|
+
<Card title="Architecture" href="/architecture">
|
|
115
|
+
How the three programs, the SDK, and the adapter layer compose into one settlement path.
|
|
116
|
+
</Card>
|
|
117
|
+
<Card title="Pay.sh adapter" href="/integration-guides/pay-sh-adapter">
|
|
118
|
+
The live Pay.sh integration end to end — challenge, retry, settle, feedback.
|
|
119
|
+
</Card>
|
|
120
|
+
<Card title="Atomic-tx invariant" href="/verification/atomic-tx-invariant">
|
|
121
|
+
Why gate + transfer + feedback must execute as one Solana transaction or none.
|
|
122
|
+
</Card>
|
|
123
|
+
</Cards>
|
|
@@ -1,64 +1,81 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: AgentTrust
|
|
3
|
+
description: Three Anchor programs that complete the third leg of ERC-8004 on Solana — the policy, settlement, and feedback layer for x402 facilitators.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Pay.sh is the first concrete adapter: an AgentTrust-aware service can emit a Pay.sh x402 challenge, verify the SERVICE signature, run the policy decision, and settle with feedback tied to the same payment context. The same adapter contract is designed for Dexter, atxp_ai, MCPay, and the next facilitator without rewriting the routes.
|
|
6
|
+
Quantu Labs shipped two of the three ERC-8004 legs on Solana — agent identity (`agent-registry-8004`) and reputation (`atom-engine`). The third leg, capability validation, was archived in v0.5.0 pending a redesign. AgentTrust ships that third leg, plus a policy engine that reads Quantu's reputation tier byte by byte, plus a facilitator-side program that emits feedback through Quantu's existing CPI surface.
|
|
9
7
|
|
|
10
8
|
<KaniProofBadge />
|
|
11
9
|
|
|
12
|
-
##
|
|
10
|
+
## Hit it now
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
Three live paths against the hosted devnet build. No clone, no setup.
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| TrustGate | PolicyVault decisions | Quantu feedback logs | x402 status and ERC-8004 feedback |
|
|
20
|
-
| ValidationRegistry | attestor profiles and attestations | capability attestations | reusable validation evidence |
|
|
21
|
-
| Pay.sh adapter | x402 v2 `PaymentRequirements` | SERVICE-signed challenge and feedback receipt | live Pay.sh integration path |
|
|
14
|
+
```bash
|
|
15
|
+
# 1. See an x402 challenge from a real facilitator
|
|
16
|
+
curl -i https://demo.agenttrust.tech/protected
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
# 2. Install the SDK
|
|
19
|
+
pnpm add @agenttrust-sdk/trustgate
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
| Dexter | in flight | Worked example for the next adapter path; current repo carries a roadmap stub until full wiring lands. |
|
|
29
|
-
| atxp_ai | roadmap | Stubbed explicitly so callers see a planned integration, not an accidental absence. |
|
|
30
|
-
| MCPay | roadmap | Stubbed explicitly for the same adapter contract. |
|
|
21
|
+
# 3. Wire the MCP server into Claude Desktop / Cursor
|
|
22
|
+
npx -y @agenttrust-sdk/mcp
|
|
23
|
+
```
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
## What's deployed
|
|
33
26
|
|
|
34
|
-
|
|
27
|
+
<ProgramIdsTable />
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
[SDK on npm](https://www.npmjs.com/package/@agenttrust-sdk/trustgate) ·
|
|
30
|
+
[MCP on npm](https://www.npmjs.com/package/@agenttrust-sdk/mcp) ·
|
|
31
|
+
[Repo](https://github.com/agenttrust-labs/agenttrust) ·
|
|
32
|
+
[Hosted demo](https://demo.agenttrust.tech) ·
|
|
33
|
+
[Hosted facilitator](https://api.agenttrust.tech) ·
|
|
34
|
+
[Hosted MCP](https://mcp.agenttrust.tech)
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
## The three programs
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
**PolicyVault** is the decision engine. Five orthogonal policy kinds — `KillSwitch`, `Spending`, `Velocity`, `CounterpartyTier`, `RequireValidation` — composed under one `gate_payment` instruction with fail-fast semantics. The composer returns `Allow`, `Deny(reason)`, or `RequireValidation(capability_hash)`. `CounterpartyTier` reads byte 551 of Quantu's `AtomStats` through a manual byte-offset parser pinned to commit `bfb09ad` (zero Cargo dep on Quantu's crate, schema-version canary at byte 560 catches drift).
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
**TrustGate** is the facilitator-side program. One PDA per facilitator (`TrustGateAuthority`) signs the CPI into Quantu's `agent-registry-8004::give_feedback`. `FeedbackEmissionLog` is the per-payment idempotency receipt — Anchor's `init` constraint fails on the second tx with the same `payment_id_hash`, so retries cannot double-emit. The TypeScript SDK, [`@agenttrust-sdk/trustgate@0.2.0`](https://www.npmjs.com/package/@agenttrust-sdk/trustgate), mounts on any Express app in five lines.
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
**ValidationRegistry** productizes the third leg. Five instructions — `register_namespace`, `register_attestor`, `request_validation`, `respond_to_validation`, `revoke_validation` — over four PDAs. The v1 sybil-resistance model is downstream-consumer filtering: PolicyVault stores a per-policy `accepted_attestors[]` array; only attestations from those keys flip the gate to `Allow`. Permissionless registration plus opinionated downstream filtering is the only model that scales with the number of facilitators.
|
|
43
|
+
|
|
44
|
+
## How they compose
|
|
47
45
|
|
|
48
|
-
```bash
|
|
49
|
-
pay --sandbox curl https://demo.agenttrust.tech/protected
|
|
50
46
|
```
|
|
47
|
+
x402 facilitator (Pay.sh, Dexter, atxp, MCPay)
|
|
48
|
+
│
|
|
49
|
+
▼ POST /verify | /settle | /dispute
|
|
50
|
+
TrustGate ─CPI─► agent-registry-8004::give_feedback
|
|
51
|
+
│
|
|
52
|
+
│ reads
|
|
53
|
+
▼
|
|
54
|
+
PolicyVault ─reads─► AtomStats (Quantu) ◀── byte 551 (tier)
|
|
55
|
+
│
|
|
56
|
+
└─reads─► ValidationAttestation ◀── byte 8 / 40 / 72 / 208 / 216
|
|
57
|
+
(ValidationRegistry)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The full wiring story is on [Architecture](/architecture). Byte-precise PDA layouts, instruction signatures, and deny-reason codes live under [Programs](/programs/policy-vault).
|
|
51
61
|
|
|
52
|
-
##
|
|
62
|
+
## Foundation alignment
|
|
63
|
+
|
|
64
|
+
Pay.sh is the Solana Foundation's first x402 facilitator, [launched 2026-05-05 with Google Cloud](https://solana.com/news/solana-foundation-launches-pay-sh-in-collaboration-with-google-cloud). AgentTrust ships day-one Pay.sh integration as the canonical adapter — Dexter, atxp, and MCPay share the same five-method `FacilitatorAdapter` contract, so adding a fifth facilitator stays under a hundred lines. Walkthrough: [Pay.sh adapter](/integration-guides/pay-sh-adapter).
|
|
65
|
+
|
|
66
|
+
## Where to next
|
|
53
67
|
|
|
54
68
|
<Cards>
|
|
55
69
|
<Card title="Quickstart" href="/getting-started/quickstart">
|
|
56
|
-
|
|
70
|
+
Hit the live demo, install the SDK, wire the MCP server.
|
|
71
|
+
</Card>
|
|
72
|
+
<Card title="Architecture" href="/architecture">
|
|
73
|
+
The wiring diagram, the FacilitatorAdapter pattern, the atomic-tx invariant.
|
|
57
74
|
</Card>
|
|
58
|
-
<Card title="
|
|
59
|
-
|
|
75
|
+
<Card title="Live evidence" href="/verification/live-evidence">
|
|
76
|
+
Six Kani proofs, devnet smoke traces, the chained-validation 4-sig trace, every claim with an Explorer URL.
|
|
60
77
|
</Card>
|
|
61
|
-
<Card title="
|
|
62
|
-
|
|
78
|
+
<Card title="MCP server" href="/mcp">
|
|
79
|
+
Eighteen tools that expose every SDK surface to Claude Desktop and Cursor.
|
|
63
80
|
</Card>
|
|
64
81
|
</Cards>
|
|
@@ -1,15 +1,142 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Capability namespaces
|
|
3
|
-
description:
|
|
3
|
+
description: Register a new namespace, derive its hash, gate against it from PolicyVault. Plus how the v1 sybil-resistance model devolves trust to PolicyVault's accepted_attestors[].
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`
|
|
6
|
+
Capability namespaces are the names PolicyVault gates against in `RequireValidation`. Each namespace is identified on chain by `SHA-256(name_utf8)` — that 32-byte hash is what `PolicyAccount.required_capability_hash` stores and what the `X-Capability-Required` x402 response header carries.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Source: [`programs/validation-registry/src/instructions/register_namespace.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/validation-registry/src/instructions/register_namespace.rs). State: [`state/capability_namespace.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/validation-registry/src/state/capability_namespace.rs).
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
| --- | --- |
|
|
12
|
-
| namespace state | [`programs/validation-registry/src/state/capability_namespace.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/validation-registry/src/state/capability_namespace.rs) |
|
|
13
|
-
| register instruction | [`programs/validation-registry/src/instructions/register_namespace.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/validation-registry/src/instructions/register_namespace.rs) |
|
|
14
|
-
| x402 header | [`trustgate/sdk/src/x402.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/sdk/src/x402.ts) |
|
|
10
|
+
## Register a namespace
|
|
15
11
|
|
|
12
|
+
```ts
|
|
13
|
+
import { Keypair, PublicKey, sendAndConfirmTransaction, Transaction } from "@solana/web3.js";
|
|
14
|
+
import {
|
|
15
|
+
buildRegisterNamespaceIx,
|
|
16
|
+
computeCapabilityHash,
|
|
17
|
+
loadValidationRegistry,
|
|
18
|
+
makeProvider,
|
|
19
|
+
DEFAULT_DEVNET_PROGRAM_IDS,
|
|
20
|
+
} from "@agenttrust-sdk/trustgate";
|
|
21
|
+
|
|
22
|
+
const creator = Keypair.fromSecretKey(/* funded devnet keypair */);
|
|
23
|
+
const provider = makeProvider({
|
|
24
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
25
|
+
wallet: creator,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const validationRegistry = await loadValidationRegistry(
|
|
29
|
+
provider,
|
|
30
|
+
DEFAULT_DEVNET_PROGRAM_IDS.validationRegistry,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const name = "my-org.attestation.v1"; // ≤ 32 bytes; min 3; no ':' allowed
|
|
34
|
+
const version = "v1"; // ≤ 16 bytes
|
|
35
|
+
const schemaUri = "https://my-org.example/schemas/attestation.v1.json";
|
|
36
|
+
|
|
37
|
+
const namespaceHash = computeCapabilityHash(name); // SHA-256(name)
|
|
38
|
+
|
|
39
|
+
const ix = await buildRegisterNamespaceIx({
|
|
40
|
+
program: validationRegistry,
|
|
41
|
+
creator: creator.publicKey,
|
|
42
|
+
namespaceHash,
|
|
43
|
+
name,
|
|
44
|
+
version,
|
|
45
|
+
schemaUri,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const tx = new Transaction().add(ix);
|
|
49
|
+
const sig = await sendAndConfirmTransaction(provider.connection, tx, [creator]);
|
|
50
|
+
console.log(`Namespace registered: ${sig}`);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `register_namespace` instruction enforces:
|
|
54
|
+
|
|
55
|
+
| Constraint | Limit | Error on violation |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `name.len() >= 3` | min 3 | `NameTooShort` |
|
|
58
|
+
| `name.len() <= 32` | max 32 | `NameTooLong` |
|
|
59
|
+
| `':'` not in `name` | forbidden | `NamespaceColonForbidden` (so namespace strings pack into URIs without escaping) |
|
|
60
|
+
| `version.len() <= 16` | max 16 | `VersionTooLong` |
|
|
61
|
+
| `schema_uri.len() <= 160` | max 160 | `UriTooLong` |
|
|
62
|
+
|
|
63
|
+
Anyone can register a namespace — rent (~0.0023 SOL) is the economic deterrent. PolicyVault decides per-policy which attestors it trusts via `accepted_attestors[]`, so a namespace registration alone confers no trust.
|
|
64
|
+
|
|
65
|
+
## Derive the PDA
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { deriveCapabilityNamespacePda } from "@agenttrust-sdk/trustgate";
|
|
69
|
+
|
|
70
|
+
const namespacePda = deriveCapabilityNamespacePda(
|
|
71
|
+
DEFAULT_DEVNET_PROGRAM_IDS.validationRegistry,
|
|
72
|
+
namespaceHash, // 32 bytes
|
|
73
|
+
);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
PDA seeds: `["capability", namespace_hash]`.
|
|
77
|
+
|
|
78
|
+
## Gate a policy against it
|
|
79
|
+
|
|
80
|
+
Set `required_capability_hash` on `PolicyAccount` when calling `init_policy`:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { BN } from "@coral-xyz/anchor";
|
|
84
|
+
|
|
85
|
+
await policyVault.methods
|
|
86
|
+
.initPolicy({
|
|
87
|
+
policyId: 1,
|
|
88
|
+
enabledKindsBitmask: 0b11111, // all five kinds
|
|
89
|
+
requiredCapabilityHash: Array.from(namespaceHash),
|
|
90
|
+
acceptedAttestors: [/* up to 2 trusted attestor pubkeys, or both PublicKey.default for permissionless */],
|
|
91
|
+
/* … other policy fields … */
|
|
92
|
+
})
|
|
93
|
+
.accounts({
|
|
94
|
+
/* … */
|
|
95
|
+
})
|
|
96
|
+
.rpc();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
When PolicyVault's gate runs:
|
|
100
|
+
|
|
101
|
+
1. If `required_capability_hash == [0; 32]` (zero) — policy is not enabled; pass-through.
|
|
102
|
+
2. Else, look for a `ValidationAttestation` PDA at `["attestation", payee_asset, capability_hash, attestor]`. The `attestor` slot iterates against `accepted_attestors[]`.
|
|
103
|
+
3. If no attestation exists → `RequireValidation(capability_hash)` is returned. The facilitator's `formatChallenge` includes `X-Capability-Required: <hex>` in the x402 response.
|
|
104
|
+
4. After the user obtains an attestation (off-chain claim → attestor calls `respond_to_validation` → PDA written) and re-submits the payment, the gate flips to `Allow`.
|
|
105
|
+
|
|
106
|
+
Full decision flow: [PolicyVault → RequireValidation policy](/programs/policy-vault/require-validation-policy).
|
|
107
|
+
|
|
108
|
+
## Naming conventions
|
|
109
|
+
|
|
110
|
+
The seeded v1 namespaces follow a `domain.subcategory.version` shape:
|
|
111
|
+
|
|
112
|
+
- `kyc.tier-1.v1`, `kyc.tier-2.v1`, `kyc.tier-3.v1`
|
|
113
|
+
- `audit.smart-contract.v1`, `audit.attestor-firm.v1`
|
|
114
|
+
- `model-card.v1`
|
|
115
|
+
- `jurisdiction.v1`
|
|
116
|
+
- `compliance.payments.v1`
|
|
117
|
+
- `agent-source.v1`
|
|
118
|
+
- `usdc-payment-policy.v1` (the Phase D demo capability)
|
|
119
|
+
|
|
120
|
+
Full lookup with PDAs and Explorer URLs: [Reference → Capability namespaces](/reference/capability-namespaces).
|
|
121
|
+
|
|
122
|
+
The playbook-level descriptive labels in [`docs/plan/research/06-validation-registry-class.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/plan/research/06-validation-registry-class.md) (e.g., `kyc.tier-1.v1.identity-verified`) decompose to these on-chain `name` strings plus the JSON `description` field. The chain stores the bounded name; richer metadata lives in the `schema_uri` document.
|
|
123
|
+
|
|
124
|
+
## Sybil-resistance model — local trust, not global
|
|
125
|
+
|
|
126
|
+
Permissionless registration plus per-policy `accepted_attestors[]` filtering. PolicyVault decides which attestors it trusts for a given capability, not a central allow-list. A policy that gates against `audit.smart-contract.v1` might only accept attestations from Halborn or OtterSec; a policy that gates against `kyc.tier-1.v1` might accept any registered KYC attestor.
|
|
127
|
+
|
|
128
|
+
The trade-off is local trust over global gatekeeping — the only model that scales with the number of facilitators. Detailed rationale: [ValidationRegistry](/programs/validation-registry).
|
|
129
|
+
|
|
130
|
+
## Read next
|
|
131
|
+
|
|
132
|
+
<Cards>
|
|
133
|
+
<Card title="Custom attestor" href="/integration-guides/custom-attestor">
|
|
134
|
+
The other side — register an attestor profile, respond to validation requests, revoke.
|
|
135
|
+
</Card>
|
|
136
|
+
<Card title="RequireValidation policy" href="/programs/policy-vault/require-validation-policy">
|
|
137
|
+
The PolicyVault read path that consumes the attestation PDA.
|
|
138
|
+
</Card>
|
|
139
|
+
<Card title="Capability namespaces (live)" href="/reference/capability-namespaces">
|
|
140
|
+
Every seeded v1 namespace with PDA + Explorer URL.
|
|
141
|
+
</Card>
|
|
142
|
+
</Cards>
|