@agenttrust-sdk/mcp 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/embedded-data/devnet-attestor-trace.json +32 -0
  2. package/dist/embedded-data/devnet-chained-validation.json +52 -0
  3. package/dist/embedded-data/devnet-counterparties.json +53 -0
  4. package/dist/embedded-data/devnet-demo-policies.json +46 -0
  5. package/dist/embedded-data/devnet-namespaces.json +107 -0
  6. package/dist/embedded-data/devnet-smoke.json +24 -0
  7. package/dist/embedded-docs/getting-started/architecture-overview.mdx +85 -0
  8. package/dist/embedded-docs/getting-started/quickstart.mdx +100 -0
  9. package/dist/embedded-docs/index.mdx +64 -0
  10. package/dist/embedded-docs/integration-guides/capability-namespaces.mdx +15 -0
  11. package/dist/embedded-docs/integration-guides/custom-attestor.mdx +15 -0
  12. package/dist/embedded-docs/integration-guides/facilitator-adapters.mdx +85 -0
  13. package/dist/embedded-docs/integration-guides/pay-sh-adapter.mdx +110 -0
  14. package/dist/embedded-docs/integration-guides/x402-facilitator.mdx +79 -0
  15. package/dist/embedded-docs/programs/policy-vault/counterparty-tier-policy.mdx +15 -0
  16. package/dist/embedded-docs/programs/policy-vault/index.mdx +68 -0
  17. package/dist/embedded-docs/programs/policy-vault/kill-switch-policy.mdx +15 -0
  18. package/dist/embedded-docs/programs/policy-vault/require-validation-policy.mdx +15 -0
  19. package/dist/embedded-docs/programs/policy-vault/spending-policy.mdx +15 -0
  20. package/dist/embedded-docs/programs/policy-vault/velocity-policy.mdx +15 -0
  21. package/dist/embedded-docs/programs/trustgate.mdx +53 -0
  22. package/dist/embedded-docs/programs/validation-registry.mdx +49 -0
  23. package/dist/embedded-docs/reference/byte-offset-reference.mdx +20 -0
  24. package/dist/embedded-docs/reference/changelog.mdx +19 -0
  25. package/dist/embedded-docs/reference/devnet-program-ids.mdx +24 -0
  26. package/dist/embedded-docs/reference/discriminator-constants.mdx +16 -0
  27. package/dist/embedded-docs/reference/formal-verification.mdx +19 -0
  28. package/dist/embedded-docs/reference/mainnet-program-ids.mdx +16 -0
  29. package/dist/embedded-docs/reference/quantu-agent-registry.mdx +15 -0
  30. package/dist/embedded-docs/sdk/atomic-tx-invariant.mdx +37 -0
  31. package/dist/embedded-docs/sdk/gate-payment.mdx +22 -0
  32. package/dist/embedded-docs/sdk/index.mdx +73 -0
  33. package/dist/embedded-docs/sdk/mount-trustgate.mdx +15 -0
  34. package/dist/embedded-examples/attestor-demo/README.md +100 -0
  35. package/dist/embedded-examples/pay-sh-demo/README.md +136 -0
  36. package/dist/embedded-examples/pay-sh-demo/src/deps-real.ts +150 -0
  37. package/dist/embedded-examples/pay-sh-demo/src/deps.ts +150 -0
  38. package/dist/embedded-examples/pay-sh-demo/src/index.ts +471 -0
  39. package/dist/embedded-examples/pay-sh-demo/src/middleware.ts +198 -0
  40. package/dist/embedded-examples/pay-sh-demo/src/policy.ts +247 -0
  41. package/dist/embedded-examples/pay-sh-demo/src/x402.ts +140 -0
  42. package/dist/index.js +73 -18
  43. package/dist/index.js.map +1 -1
  44. package/dist/resources/docs.js +69 -46
  45. package/dist/resources/docs.js.map +1 -1
  46. package/dist/server.js +6 -1
  47. package/dist/server.js.map +1 -1
  48. package/dist/tools/discovery/docs.js +7 -0
  49. package/dist/tools/discovery/docs.js.map +1 -1
  50. package/dist/tools/discovery/facilitator-walkthrough.js +44 -18
  51. package/dist/tools/discovery/facilitator-walkthrough.js.map +1 -1
  52. package/dist/tools/read/demo-state.js +7 -4
  53. package/dist/tools/read/demo-state.js.map +1 -1
  54. package/dist/trustgate/server/src/facilitators/README.md +241 -0
  55. package/package.json +2 -2
@@ -0,0 +1,85 @@
1
+ ---
2
+ title: Facilitator adapters
3
+ description: Add a new x402 facilitator without rewriting AgentTrust routes or policy.
4
+ ---
5
+
6
+ The adapter layer is the reason AgentTrust is not locked to Pay.sh. Pay.sh is live today; Dexter is the next worked path; atxp_ai and MCPay are marked roadmap through explicit stubs.
7
+
8
+ ## Mental model
9
+
10
+ ```txt
11
+ HTTP request
12
+ -> routes/{verify,settle}
13
+ -> FacilitatorRegistry
14
+ -> active FacilitatorAdapter
15
+ -> VerifyContext
16
+ -> policy decision
17
+ -> settlement proof validation
18
+ -> feedback emission
19
+ ```
20
+
21
+ Routes, policy logic, and registry reads stay unchanged. Protocol quirks live in one adapter file.
22
+
23
+ ## The five-method contract
24
+
25
+ | Method | Why it exists |
26
+ | --- | --- |
27
+ | `parseRequest(req)` | translate the facilitator's request body and headers into `VerifyContext` |
28
+ | `formatChallenge(decision, ctx)` | render Allow / Deny / RequireValidation in that facilitator's wire format |
29
+ | `formatSettlement(ctx)` | return protocol-specific settlement metadata or an unsigned transaction skeleton |
30
+ | `validatePaymentProof(proof, ctx)` | verify proof shape and cross-check it against the verify-time context |
31
+ | `emitFeedback(ctx, settlement)` | emit the AgentTrust feedback record after settlement |
32
+
33
+ If an adapter needs a sixth method, that is a contract change, not a one-off escape hatch.
34
+
35
+ ## Status map
36
+
37
+ | Facilitator | Repo status | Meaning |
38
+ | --- | --- | --- |
39
+ | Pay.sh | concrete adapter | ready path for the demo and production dependency factory |
40
+ | Dexter | stub / in flight | worked example for proving adapter portability |
41
+ | atxp_ai | stub | roadmap, not silently unsupported |
42
+ | MCPay | stub | roadmap, not silently unsupported |
43
+
44
+ ## Add a facilitator
45
+
46
+ 1. Read the facilitator's wire format. Identify challenge headers, proof headers, body shape, recipient encoding, payment ID hints, and Allow / Deny responses.
47
+ 2. Define strict Zod schemas for the request body and proof payload.
48
+ 3. Implement one `FacilitatorAdapter` class.
49
+ 4. Re-export it from `trustgate/server/src/facilitators/index.ts`.
50
+ 5. Register it with `FacilitatorRegistry`.
51
+ 6. Add unit tests that mirror Pay.sh coverage.
52
+ 7. Add a demo under `examples/<name>-demo` if the integration needs a runnable walkthrough.
53
+
54
+ ## Registry wiring
55
+
56
+ ```ts
57
+ import {
58
+ FacilitatorRegistry,
59
+ PaySh,
60
+ } from "@agenttrust/trustgate-server";
61
+
62
+ const registry = new FacilitatorRegistry();
63
+ registry.register(new PaySh(payShDeps));
64
+ registry.setDefault("pay-sh");
65
+ ```
66
+
67
+ Request-time selection can come from `X-Facilitator`, environment defaults, or a programmatic default. The active adapter is the only code that knows about the chosen facilitator.
68
+
69
+ ## Security checklist
70
+
71
+ Every adapter must preserve the same proof-of-payment checks:
72
+
73
+ - replay defense
74
+ - self-pay defense
75
+ - amount, mint, and recipient cross-checks
76
+ - network match
77
+ - expiry window
78
+ - idempotent feedback emission
79
+ - stable reason codes on Deny
80
+
81
+ Pay.sh's `proof-validator.ts` and `feedback.ts` are the reference pattern.
82
+
83
+ ## Target integration time
84
+
85
+ The architecture target is under two hours for a facilitator that already has a clear x402 wire spec. If adding a facilitator forces route edits, policy edits, or registry read changes, the adapter boundary failed and should be fixed before the integration is considered done.
@@ -0,0 +1,110 @@
1
+ ---
2
+ title: Pay.sh adapter
3
+ description: The live Pay.sh + AgentTrust integration path.
4
+ ---
5
+
6
+ Pay.sh is the first concrete AgentTrust facilitator adapter. It translates Pay.sh's x402 headers and `PaymentRequirements` body into the `VerifyContext` that the on-chain policy path understands.
7
+
8
+ Pay.sh launch reference: [Solana Foundation launch note](https://solana.com/news/solana-foundation-launches-pay-sh-in-collaboration-with-google-cloud).
9
+
10
+ ## What the adapter does
11
+
12
+ | Stage | Pay.sh / x402 surface | AgentTrust action |
13
+ | --- | --- | --- |
14
+ | Initial request | no payment proof | emit `402 Payment Required` with a base64 x402 v2 envelope |
15
+ | Challenge | `paymentRequirements.extra.agentTrust` | include payer agent, payee agent, payee recipient, policy ID, `issuedAt`, and `serviceSignature` |
16
+ | Retry | `PAYMENT-SIGNATURE` or `X-PAYMENT` | parse proof and rebuild `VerifyContext` |
17
+ | Policy | `VerifyContext` | run the gate decision |
18
+ | Allow | signed payment proof | validate transfer fields, emit feedback, forward resource |
19
+ | Deny | gate decision | return `402` with reason code and reason name |
20
+
21
+ ## Files to read
22
+
23
+ | File | Purpose |
24
+ | --- | --- |
25
+ | `trustgate/server/src/facilitators/pay-sh/index.ts` | the five-method `PaySh` class |
26
+ | `trustgate/server/src/facilitators/pay-sh/schemas.ts` | strict Zod wire schemas |
27
+ | `trustgate/server/src/facilitators/pay-sh/sig.ts` | SERVICE challenge signature helpers |
28
+ | `trustgate/server/src/facilitators/pay-sh/proof-validator.ts` | replay, self-pay, amount, mint, recipient checks |
29
+ | `trustgate/server/src/facilitators/pay-sh/feedback.ts` | idempotent feedback emission |
30
+ | `examples/pay-sh-demo/src/middleware.ts` | Express route bridge from Pay.sh retry to AgentTrust |
31
+
32
+ ## SERVICE-signed challenge
33
+
34
+ The SERVICE emits a signed challenge when it returns the Pay.sh `402` response. The signature binds:
35
+
36
+ - `issuedAt`
37
+ - network
38
+ - amount
39
+ - asset
40
+ - `payTo`
41
+ - payer agent
42
+ - payee agent
43
+ - payee recipient
44
+ - policy ID
45
+ - payment ID hash
46
+
47
+ `PaySh.parseRequest()` verifies that signature against the facilitator public key before it accepts the request. This closes the race window where a forged `paymentRequirements` envelope could be raced against the legitimate one.
48
+
49
+ ## Run the demo
50
+
51
+ ```bash
52
+ pnpm --filter ./examples/pay-sh-demo dev
53
+ ```
54
+
55
+ ```bash
56
+ pay --sandbox curl https://demo.agenttrust.tech/protected
57
+ ```
58
+
59
+ The demo uses three deterministic counterparties:
60
+
61
+ | Counterparty tier | Expected result |
62
+ | --- | --- |
63
+ | 0 | `402 Deny` with `CounterpartyTierBelowMin` |
64
+ | 1 | `402 Deny` with `CounterpartyTierBelowMin` |
65
+ | 3 | `200 Allow` with `X-Payment-Receipt` |
66
+
67
+ Get the exact payer agent keys:
68
+
69
+ ```bash
70
+ curl -s https://demo.agenttrust.tech/health | jq '.counterparties'
71
+ ```
72
+
73
+ ## Production wiring
74
+
75
+ The demo proves the pipeline without requiring devnet RPC in CI. The server package carries the real devnet Anchor route: `trustgate/server/src/chain.ts` loads deployed program IDLs, `/verify` simulates `gate_payment`, and `/settle` delegates proof validation plus feedback emission through the active adapter.
76
+
77
+ Production swaps three dependency seams:
78
+
79
+ ```ts
80
+ const adapter = new PaySh({
81
+ signingNetwork: "solana-devnet",
82
+ feePayer: facilitator.publicKey,
83
+ validateOnChainTx,
84
+ emitFeedbackCpi,
85
+ priorEmissionLookup,
86
+ replayCache,
87
+ signDecision,
88
+ });
89
+ ```
90
+
91
+ | Dependency | Production implementation |
92
+ | --- | --- |
93
+ | `validateOnChainTx` | parse the confirmed SPL transfer transaction from RPC |
94
+ | `emitFeedbackCpi` | build and send `trustgate::emit_feedback` through Anchor |
95
+ | `priorEmissionLookup` | read the `FeedbackEmissionLog` PDA by payment hash |
96
+ | `signDecision` | sign canonical decision bytes with the facilitator key |
97
+
98
+ ## Failure cases to keep
99
+
100
+ Do not remove these checks when adapting Pay.sh into a production server:
101
+
102
+ - reject unknown schema fields at the root
103
+ - reject zero or u64-overflow amounts
104
+ - reject network mismatch
105
+ - reject `payTo` / `payeeRecipient` mismatch
106
+ - reject expired challenges
107
+ - reject replayed proof bindings
108
+ - reject transfer authority equal to facilitator fee payer
109
+
110
+ These checks are part of the adapter, not the route layer.
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: x402 facilitator
3
+ description: Add AgentTrust decisions to an x402 facilitator without coupling to one vendor.
4
+ ---
5
+
6
+ This guide is for a facilitator that already accepts x402 payment requests and wants AgentTrust decisions before settlement. If you are using Pay.sh, start with the [Pay.sh adapter guide](/integration-guides/pay-sh-adapter). If you are adding a new facilitator, start with the [adapter pattern](/integration-guides/facilitator-adapters).
7
+
8
+ ## Integration points
9
+
10
+ | Step | Facilitator action | AgentTrust call |
11
+ | --- | --- | --- |
12
+ | 1 | receive x402 request or retry proof | `FacilitatorAdapter.parseRequest` |
13
+ | 2 | translate into payer, payee, mint, amount, and policy ID | `VerifyContext` |
14
+ | 3 | check policy | `gate_payment` or `gatePayment()` |
15
+ | 4 | return x402 denial or validation need | `adapter.formatChallenge` |
16
+ | 5 | settle payment | one signed transaction path |
17
+ | 6 | emit feedback | `adapter.emitFeedback` |
18
+
19
+ ## Minimal Express mount
20
+
21
+ ```ts
22
+ import express from "express";
23
+ import { mountTrustGate } from "@agenttrust-sdk/trustgate/express";
24
+
25
+ const app = express();
26
+ app.use(express.json());
27
+
28
+ await mountTrustGate(app, {
29
+ rpcUrl: process.env.SOLANA_RPC_URL!,
30
+ facilitatorKeypair,
31
+ defaultPolicyId: 1,
32
+ network: "solana-devnet",
33
+ atomicityEnforced: true,
34
+ });
35
+ ```
36
+
37
+ ## Verify request shape
38
+
39
+ ```http
40
+ POST /verify
41
+ Content-Type: application/json
42
+
43
+ {
44
+ "payerAgentAsset": "payer-agent-asset-pubkey",
45
+ "payeeAgentAsset": "payee-agent-asset-pubkey",
46
+ "amount": "1000000",
47
+ "mint": "mint-pubkey",
48
+ "policyId": 1
49
+ }
50
+ ```
51
+
52
+ For Pay.sh, the adapter reads this context from `paymentRequirements.extra.agentTrust`, verifies `serviceSignature`, derives `paymentIdHash` from `extra.memo`, and rejects mismatched `payTo` / `payeeRecipient` values.
53
+
54
+ ## Denial response
55
+
56
+ ```http
57
+ HTTP/1.1 402 Payment Required
58
+ X-Payment-Network: solana-devnet
59
+ X-Agent-Trust-Decision: Deny
60
+ X-Payment-Required: denied
61
+ X-Payment-Reason-Code: 6
62
+ X-Payment-Reason-Name: CounterpartyTierBelowMin
63
+ ```
64
+
65
+ ## Validation response
66
+
67
+ ```http
68
+ HTTP/1.1 402 Payment Required
69
+ X-Payment-Network: solana-devnet
70
+ X-Agent-Trust-Decision: RequireValidation
71
+ X-Payment-Required: validation
72
+ X-Capability-Required: <32-byte-capability-hash>
73
+ ```
74
+
75
+ ## Settlement rule
76
+
77
+ The facilitator must keep the policy gate, token transfer, and feedback emission in one signed Solana path once the settlement builder is wired. The SDK makes that requirement explicit with `atomicityEnforced: true`.
78
+
79
+ Source: `trustgate/server/src/facilitators`, `trustgate/server/src/x402.ts`, `trustgate/sdk/src/express.ts`.
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Counterparty tier policy
3
+ description: Quantu AtomStats trust-tier and risk checks used by the PolicyVault composer.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ The CounterpartyTier policy reads Quantu AtomStats fields through a manual byte parser, then checks trust tier, risk score, and confidence before payment release.
9
+
10
+ | Source | Path |
11
+ | --- | --- |
12
+ | evaluator | [`programs/policy-vault/src/policies/counterparty_tier.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/counterparty_tier.rs) |
13
+ | AtomStats parser | [`programs/policy-vault/src/ext/atom_engine.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/ext/atom_engine.rs) |
14
+ | proof | [`programs/policy-vault/src/proofs/inv_counterparty_tier_monotone.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/proofs/inv_counterparty_tier_monotone.rs) |
15
+
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: PolicyVault
3
+ description: The policy composer that returns Allow, Deny, or RequireValidation.
4
+ ---
5
+
6
+ PolicyVault is the decision engine for AgentTrust. It reads payer, payee, policy, velocity, kill-switch, and optional attestation data, then returns a `GateDecision`.
7
+
8
+ ## Composer order
9
+
10
+ The order is fixed and fail-fast:
11
+
12
+ | Order | Policy | Why it runs there |
13
+ | --- | --- | --- |
14
+ | 1 | `KillSwitch` | cheapest global stop |
15
+ | 2 | `Spending` | pure amount and calendar bounds |
16
+ | 3 | `Velocity` | sliding-window spend bound keyed by payer tier |
17
+ | 4 | `CounterpartyTier` | reads payee AtomStats trust data |
18
+ | 5 | `RequireValidation` | reads the attestation PDA last |
19
+
20
+ ```rust
21
+ pub fn compose_decision(input: ComposerInput) -> ComposerResult {
22
+ // KillSwitch -> Spending -> Velocity -> CounterpartyTier -> RequireValidation
23
+ // On Allow, deltas are returned for the Anchor wrapper to apply.
24
+ // On Deny or RequireValidation, deltas are None.
25
+ }
26
+ ```
27
+
28
+ ## Decision shape
29
+
30
+ ```rust
31
+ pub enum GateDecision {
32
+ Allow,
33
+ Deny(DenyReason),
34
+ RequireValidation([u8; 32]),
35
+ }
36
+ ```
37
+
38
+ `DenyReason::code()` is stable for clients even though the Borsh enum order is internal to Anchor.
39
+
40
+ ## Policy kinds
41
+
42
+ | Policy | Inputs | State mutation on Allow |
43
+ | --- | --- | --- |
44
+ | Spending | `amount`, UTC day, ISO week | daily and weekly counters |
45
+ | Velocity | `amount`, slot window, payer tier | `VelocityLedger.cumulative_amount` |
46
+ | CounterpartyTier | payee tier, risk, confidence | none |
47
+ | RequireValidation | subject, capability hash, attestor, expiry | none |
48
+ | KillSwitch | per-agent paused flag | none |
49
+
50
+ ## Safety rule
51
+
52
+ The Anchor handler snapshots all accounts before composing, then applies returned deltas only when the decision is `Allow`.
53
+
54
+ ```rust
55
+ match result.decision {
56
+ GateDecision::Allow => {
57
+ spending::apply_deltas(&mut ctx.accounts.policy_account, d);
58
+ velocity::apply_deltas(&mut ctx.accounts.velocity_ledger, d);
59
+ }
60
+ GateDecision::Deny(_) | GateDecision::RequireValidation(_) => {}
61
+ }
62
+ ```
63
+
64
+ ## Formal checks
65
+
66
+ <KaniProofBadge />
67
+
68
+ Source: `programs/policy-vault/src/policies/composer.rs`.
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: KillSwitch policy
3
+ description: Multisig-gated pause control for PolicyVault decisions.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ KillSwitch is the first policy in the composer. When it is paused, the composer cannot return `Allow`.
9
+
10
+ | Source | Path |
11
+ | --- | --- |
12
+ | evaluator | [`programs/policy-vault/src/policies/killswitch.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/killswitch.rs) |
13
+ | pause instruction | [`programs/policy-vault/src/instructions/set_killswitch.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/instructions/set_killswitch.rs) |
14
+ | proof | [`programs/policy-vault/src/proofs/inv_paused_implies_no_allow.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/proofs/inv_paused_implies_no_allow.rs) |
15
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: RequireValidation policy
3
+ description: Capability-attestation checks for payments that need validation evidence.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ RequireValidation returns `RequireValidation` when the required capability is missing, and returns `Deny` when the supplied attestation is expired, revoked, or not issued by an accepted attestor.
9
+
10
+ | Source | Path |
11
+ | --- | --- |
12
+ | evaluator | [`programs/policy-vault/src/policies/require_validation.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/require_validation.rs) |
13
+ | attestation parser | [`programs/policy-vault/src/ext/validation_registry.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/ext/validation_registry.rs) |
14
+ | proof | [`programs/policy-vault/src/proofs/inv_validation_expiry_correct.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/proofs/inv_validation_expiry_correct.rs) |
15
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Spending policy
3
+ description: Per-transaction, daily, and weekly limits enforced before payment settlement.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ The Spending policy gates a payment against configured per-transaction, daily, and weekly limits. Allow-path deltas are applied only after the full PolicyVault composer returns `Allow`.
9
+
10
+ | Source | Path |
11
+ | --- | --- |
12
+ | evaluator | [`programs/policy-vault/src/policies/spending.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/spending.rs) |
13
+ | composer | [`programs/policy-vault/src/policies/composer.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/composer.rs) |
14
+ | policy init | [`programs/policy-vault/src/instructions/init_policy.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/instructions/init_policy.rs) |
15
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Velocity policy
3
+ description: Sliding-window payment counters with tier-adjusted limits.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ The Velocity policy applies a rolling counter before a payment can proceed. The composer carries velocity deltas only on the all-policies-allowed branch.
9
+
10
+ | Source | Path |
11
+ | --- | --- |
12
+ | evaluator | [`programs/policy-vault/src/policies/velocity.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/policies/velocity.rs) |
13
+ | account state | [`programs/policy-vault/src/state/velocity_ledger.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/state/velocity_ledger.rs) |
14
+ | proof | [`programs/policy-vault/src/proofs/inv_velocity_counter_le_limit.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/proofs/inv_velocity_counter_le_limit.rs) |
15
+
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: TrustGate
3
+ description: The x402 facilitator program that emits ERC-8004 feedback through Quantu.
4
+ ---
5
+
6
+ TrustGate is the on-chain feedback bridge for x402 facilitators. It owns a per-facilitator PDA, signs feedback CPI calls into Quantu, and records idempotency by payment hash.
7
+
8
+ Pay.sh uses this path through the `PaySh` adapter. Other facilitators should reach the same on-chain instruction through their own adapter rather than adding facilitator-specific branches to routes.
9
+
10
+ ## Instructions
11
+
12
+ | Instruction | Purpose |
13
+ | --- | --- |
14
+ | `init_authority(facilitator)` | creates the facilitator PDA |
15
+ | `emit_feedback(...)` | CPI into Quantu `agent_registry_8004::give_feedback` |
16
+ | `dispute_payment(...)` | emits negative-score feedback for disputed payments |
17
+
18
+ ## PDA signer
19
+
20
+ TrustGate signs CPI with:
21
+
22
+ ```txt
23
+ ["trustgate_auth", facilitator_pubkey, bump]
24
+ ```
25
+
26
+ That PDA is the feedback authority, not the payee agent. This prevents self-feedback while allowing a facilitator to write receipt-grade feedback after settlement.
27
+
28
+ ## Feedback idempotency
29
+
30
+ `FeedbackEmissionLog` is initialized at:
31
+
32
+ ```txt
33
+ ["feedback_log", payment_id_hash]
34
+ ```
35
+
36
+ Reusing the same payment hash fails account initialization, so retries cannot double-emit feedback.
37
+
38
+ ## x402 mapping
39
+
40
+ The SDK and server map PolicyVault outcomes into response headers:
41
+
42
+ | Decision | HTTP | Headers |
43
+ | --- | --- | --- |
44
+ | `Allow` | `200` | `X-Agent-Trust-Decision: Allow` |
45
+ | `Deny` | `402` | reason code and reason name |
46
+ | `RequireValidation` | `402` | required capability hash |
47
+
48
+ ## Source
49
+
50
+ - Program: `programs/trustgate/src/lib.rs`
51
+ - CPI wrapper: `programs/trustgate/src/ext/agent_registry.rs`
52
+ - Server route layer: `trustgate/server/src/routes/verify.ts`
53
+ - Pay.sh adapter: `trustgate/server/src/facilitators/pay-sh/index.ts`
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: ValidationRegistry
3
+ description: Capability namespaces, attestors, requests, responses, and revocations.
4
+ ---
5
+
6
+ ValidationRegistry is the attestation leg of AgentTrust. PolicyVault reads `ValidationAttestation` accounts when `RequireValidation` is enabled.
7
+
8
+ ## Accounts
9
+
10
+ | PDA | Role |
11
+ | --- | --- |
12
+ | `CapabilityNamespace` | names a validation capability and schema URI |
13
+ | `AttestorProfile` | records an attestor identity URI |
14
+ | `ValidationRequest` | opens a request for an agent and capability |
15
+ | `ValidationAttestation` | stores a response, expiry, and revoked flag |
16
+
17
+ ## Instructions
18
+
19
+ | Instruction | Notes |
20
+ | --- | --- |
21
+ | `register_namespace` | permissionless, caller computes `SHA256(name_utf8)` |
22
+ | `register_attestor` | self-registration with display URI |
23
+ | `request_validation` | subject owner or third party opens a request |
24
+ | `respond_to_validation` | attestor writes the attestation |
25
+ | `revoke_validation` | original attestor sets `revoked = true` |
26
+
27
+ The program source currently exposes five instructions. The docs reserve the sixth slot for the next attestor-management extension.
28
+
29
+ ## Attestation message
30
+
31
+ The response path uses a domain-separated message:
32
+
33
+ ```txt
34
+ AGENTTRUST_ATTEST || subject || capability || payload || expires
35
+ ```
36
+
37
+ PolicyVault does not trust arbitrary attestations. `RequireValidation` checks the subject, capability hash, expiry, revoked flag, and allowed attestor list.
38
+
39
+ ## Byte fields consumed by PolicyVault
40
+
41
+ | Field | Offset |
42
+ | --- | --- |
43
+ | subject asset | `8` |
44
+ | capability hash | `40` |
45
+ | attestor | `72` |
46
+ | expires at slot | `208` |
47
+ | revoked flag | `216` |
48
+
49
+ Source: `programs/validation-registry/src/lib.rs`.
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: Byte-offset reference
3
+ description: Fixed offsets used by AgentTrust cross-program readers.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ | Account | Field | Offset |
9
+ | --- | --- | --- |
10
+ | `AtomStats` | `risk_score` | `549` |
11
+ | `AtomStats` | `trust_tier` | `551` |
12
+ | `AtomStats` | `confidence` | `557..558` |
13
+ | `ValidationAttestation` | `subject` | `8` |
14
+ | `ValidationAttestation` | `capability` | `40` |
15
+ | `ValidationAttestation` | `attestor` | `72` |
16
+ | `ValidationAttestation` | `expires` | `208` |
17
+ | `ValidationAttestation` | `revoked` | `216` |
18
+
19
+ Sources: [`programs/policy-vault/src/ext/atom_engine.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/ext/atom_engine.rs), [`programs/policy-vault/src/ext/validation_registry.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/ext/validation_registry.rs)
20
+
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: Changelog
3
+ description: Documentation-facing release notes for the Frontier build.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ | Date | Change |
9
+ | --- | --- |
10
+ | 2026-05-06 | Pay.sh adapter layer documented with SERVICE-signed challenges and proof validation. |
11
+ | 2026-05-06 | `examples/pay-sh-demo` added as the Pay.sh + AgentTrust x402 walkthrough. |
12
+ | 2026-05-06 | FacilitatorAdapter contract added for Pay.sh today and Dexter / atxp_ai / MCPay roadmap adapters. |
13
+ | 2026-05-06 | Atomic settlement narrative updated: policy check, SPL transfer, and feedback stay tied to one settlement path. |
14
+ | 2026-05-02 | PolicyVault composer and all five policies completed. |
15
+ | 2026-05-02 | Five Kani invariants proved green in CI. |
16
+ | 2026-05-02 | TrustGate Anchor program and Express x402 service shipped. |
17
+ | 2026-05-02 | `@agenttrust-sdk/trustgate@0.1.0` published. |
18
+
19
+ Source: [`execution.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/execution.md)
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: Devnet program IDs
3
+ description: Current AgentTrust devnet deployment addresses.
4
+ ---
5
+
6
+ These are the pinned devnet program IDs for the Frontier build.
7
+
8
+ <ProgramIdsTable />
9
+
10
+ ## TypeScript constants
11
+
12
+ ```ts
13
+ import { DEFAULT_DEVNET_PROGRAM_IDS } from "@agenttrust-sdk/trustgate";
14
+ ```
15
+
16
+ The SDK currently exposes PolicyVault and TrustGate by default. ValidationRegistry is read by PolicyVault through its account parser and is listed here for deploy verification.
17
+
18
+ ## Anchor declarations
19
+
20
+ | Program | Source |
21
+ | --- | --- |
22
+ | `policy_vault` | `programs/policy-vault/src/lib.rs` |
23
+ | `trustgate` | `programs/trustgate/src/lib.rs` |
24
+ | `validation_registry` | `programs/validation-registry/src/lib.rs` |
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: Discriminator constants
3
+ description: Pinned instruction and account constants used across AgentTrust.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ | Constant | Value |
9
+ | --- | --- |
10
+ | Quantu `give_feedback` discriminator | `[145, 136, 123, 3, 215, 165, 98, 41]` |
11
+ | TrustGate authority seed | `trustgate_auth` |
12
+ | Feedback log seed | `feedback_log` |
13
+ | Capability namespace seed | `capability` |
14
+ | Validation attestation parser size | `290` bytes |
15
+
16
+ Sources: [`programs/trustgate/src/ext/agent_registry.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/trustgate/src/ext/agent_registry.rs), [`programs/validation-registry/src/state`](https://github.com/agenttrust-labs/agenttrust/tree/main/programs/validation-registry/src/state)
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: Formal verification
3
+ description: Kani proof harnesses that guard PolicyVault invariants.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ AgentTrust runs five Kani harnesses for the current PolicyVault safety surface.
9
+
10
+ | Harness | Property |
11
+ | --- | --- |
12
+ | `paused_implies_no_allow` | paused KillSwitch cannot allow |
13
+ | `velocity_counter_le_limit` | allow-path counter stays within limit |
14
+ | `counterparty_tier_monotone` | looser tier requirement cannot fail after tighter pass |
15
+ | `validation_expiry_correct` | expired attestation cannot allow |
16
+ | `multisig_threshold_enforced` | threshold requires distinct signing members |
17
+
18
+ Sources: [`programs/policy-vault/src/proofs`](https://github.com/agenttrust-labs/agenttrust/tree/main/programs/policy-vault/src/proofs), [`.github/workflows/kani-prove.yml`](https://github.com/agenttrust-labs/agenttrust/blob/main/.github/workflows/kani-prove.yml)
19
+
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: Mainnet program IDs
3
+ description: Quantu program IDs used by AgentTrust on Solana mainnet.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ AgentTrust currently targets its own programs on devnet and reads Quantu trust data from the Quantu registry and Atom engine IDs below.
9
+
10
+ | Program | Mainnet ID |
11
+ | --- | --- |
12
+ | `agent-registry-8004` | `8oo4dC4JvBLwy5tGgiH3WwK4B9PWxL9Z4XjA2jzkQMbQ` |
13
+ | `atom-engine` | `AToMw53aiPQ8j7iHVb4fGt6nzUNxUhcPc3tbPBZuzVVb` |
14
+
15
+ Source: [`docs/plan/research/02-quantu-erc8004-archaeology.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/plan/research/02-quantu-erc8004-archaeology.md)
16
+
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Quantu Agent Registry
3
+ description: Quantu ERC-8004 accounts and feedback CPI used by AgentTrust.
4
+ ---
5
+
6
+ `In progress`
7
+
8
+ TrustGate emits feedback through Quantu `agent-registry-8004::give_feedback`, while PolicyVault reads Quantu AtomStats for counterparty policy checks.
9
+
10
+ | Surface | Source |
11
+ | --- | --- |
12
+ | feedback CPI | [`programs/trustgate/src/ext/agent_registry.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/trustgate/src/ext/agent_registry.rs) |
13
+ | AtomStats parser | [`programs/policy-vault/src/ext/atom_engine.rs`](https://github.com/agenttrust-labs/agenttrust/blob/main/programs/policy-vault/src/ext/atom_engine.rs) |
14
+ | research notes | [`docs/plan/research/02-quantu-erc8004-archaeology.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/plan/research/02-quantu-erc8004-archaeology.md) |
15
+