Skip to content

Commit ce463d9

Browse files
authored
Merge pull request #50 from mpcp-protocol/fix/spec-coherence-review
fix: spec coherence review — Trust Bundle pipeline, vendor terminology, docs alignment
2 parents 612229e + 5b0590c commit ce463d9

62 files changed

Lines changed: 637 additions & 1706 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 84 additions & 299 deletions
Large diffs are not rendered by default.

ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mpcp-reference — Implementation Roadmap
22

3-
TypeScript reference implementation and canonical protocol SDK for the [Machine Payment Control Protocol (MPCP)](https://mpcp-protocol.github.io/spec/).
3+
TypeScript reference implementation and canonical protocol SDK for the [Machine Payment Control Protocol (MPCP)](https://github.com/mpcp-protocol/mpcp-spec).
44

55
Implements: protocol verification engine, artifact schemas, cryptographic signing, on-chain anchoring adapters, golden test vectors, and the full SDK consumed by `mpcp-policy-authority`, `mpcp-wallet-sdk`, and `mpcp-merchant-sdk`.
66

@@ -96,7 +96,7 @@ Implements: protocol verification engine, artifact schemas, cryptographic signin
9696

9797
## PR29 — Trust Bundle
9898

99-
Implement the [Trust Bundle](https://mpcp-protocol.github.io/spec/protocol/trust-bundles/) specification as defined in the MPCP spec.
99+
Implement the Trust Bundle specification as defined in the MPCP spec (see `mpcp-spec/docs/protocol/trust-bundles.md`).
100100

101101
Trust Bundles are pre-distributed signed documents that package trusted issuer public keys for MPCP verifiers operating without network access at verification time.
102102

docs/animation/MPCP_ANIMATION_PACK.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ PolicyGrant
3333
3434
SignedBudgetAuthorization (SBA)
3535
36-
SignedPaymentAuthorization (SPA)
36+
Trust Gateway
3737
38-
SettlementIntent
39-
40-
Settlement
38+
XRPL Settlement
4139

4240
Narration:
4341
"MPCP introduces a simple chain of authorization for machine payments."
4442

45-
"Policies define payment rules. Budgets define session limits. Each payment is explicitly authorized and verifiable."
43+
"Policies define payment rules. Budgets define per-payment limits. The Trust Gateway verifies the chain and executes on XRPL, attaching a grant ID to every transaction for a permanent audit trail."
4644

4745
---
4846

@@ -51,26 +49,26 @@ Visual sequence:
5149
1. Autonomous vehicle enters parking garage
5250
2. PolicyGrant appears
5351
3. SignedBudgetAuthorization (SBA) appears
54-
4. SignedPaymentAuthorization (SPA) triggers
55-
5. Settlement confirmation
52+
4. Trust Gateway verifies chain
53+
5. XRPL settlement confirmation with mpcp/grant-id memo
5654

5755
Narration:
5856
"A vehicle receives a policy defining where and how it can pay."
5957

60-
"A session budget allows spending within defined limits."
58+
"A budget authorization allows spending within defined limits for this payment."
6159

62-
"Each payment request is cryptographically authorized."
60+
"The Trust Gateway verifies the authorization chain and submits the XRPL transaction."
6361

64-
"The final settlement records the completed transaction."
62+
"The final settlement records the completed transaction on-chain."
6563

6664
---
6765

68-
## Scene 5 — Ledger Anchor
66+
## Scene 5 — Policy Anchoring
6967
Visual:
70-
Intent hash flowing into a public ledger.
68+
Policy document hash flowing into a public ledger (Hedera HCS or XRPL NFT).
7169

7270
Narration:
73-
"An optional intent hash can be anchored to a public ledger for audit and dispute resolution."
71+
"An optional anchorRef on the PolicyGrant links it to a public ledger record — providing tamper-evident policy history for audit and dispute resolution."
7472

7573
---
7674

@@ -79,7 +77,7 @@ Visual:
7977
Verification chain replay.
8078

8179
Narration:
82-
"Any dispute can be independently verified using the MPCP authorization chain."
80+
"Any dispute can be independently verified using the MPCP authorization chain and the on-chain XRPL audit trail."
8381

8482
---
8583

@@ -112,10 +110,10 @@ Blocks stacking vertically
112110

113111
Scene 4
114112
Autonomous parking example
115-
Vehicle enters → policy → budget → payment → settlement
113+
Vehicle enters → policy → budget → Trust Gateway → XRPL settlement
116114

117115
Scene 5
118-
Intent hash anchored to ledger
116+
Policy document anchored to ledger (Hedera HCS / XRPL NFT)
119117

120118
Scene 6
121119
Verification replay animation
@@ -134,13 +132,13 @@ Protocol comparison diagram
134132
"clean animated diagram showing protocols MCP A2A ACP communicating between agents and tools, arrows moving between nodes, modern developer diagram style"
135133

136134
## Prompt 3 — MPCP Authorization Chain
137-
"layered protocol diagram animation PolicyGrant SignedBudgetAuthorization SignedPaymentAuthorization SettlementIntent Settlement blocks stacking vertically with glowing arrows"
135+
"layered protocol diagram animation PolicyGrant SignedBudgetAuthorization Trust Gateway XRPL Settlement blocks stacking vertically with glowing arrows"
138136

139137
## Prompt 4 — Autonomous Parking Payment
140138
"autonomous car entering smart parking garage, digital authorization layers appearing around vehicle, futuristic payment confirmation animation"
141139

142-
## Prompt 5 — Ledger Anchoring
143-
"cryptographic hash transforming into glowing data stream entering blockchain ledger block, modern protocol visualization"
140+
## Prompt 5 — Policy Anchoring
141+
"cryptographic policy document transforming into glowing data stream entering blockchain ledger block, modern protocol visualization"
144142

145143
## Prompt 6 — Dispute Verification
146144
"digital verification chain lighting up sequentially representing audit verification process"
@@ -160,9 +158,8 @@ Protocol blocks
160158
- Fleet Policy
161159
- PolicyGrant
162160
- SignedBudgetAuthorization (SBA)
163-
- SignedPaymentAuthorization (SPA)
164-
- SettlementIntent
165-
- Settlement
161+
- Trust Gateway
162+
- XRPL Settlement
166163

167164
Animation style
168165
- minimal vector graphics

docs/examples/charging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MPCP for EV charging: variable session length, multiple kWh, charging operator d
44

55
## Scenario
66

7-
EV connects to a charging station. The station requests payment authorization. The vehicle (or charging session manager) evaluates policy and budget, signs an SPA for the charging session, and the station verifies the MPCP chain before supplying power.
7+
EV connects to a charging station. The station requests payment authorization. The vehicle (or charging session manager) evaluates policy and budget, issues an SBA for the charging session, and the station verifies the MPCP chain before supplying power. The Trust Gateway executes the XRPL payment when the session ends.
88

99
## Profile
1010

@@ -35,9 +35,9 @@ Similar to parking, but with higher `maxSessionSpend` and charging-specific dest
3535

3636
1. Vehicle (or fleet) obtains PolicyGrant + SBA with charging destinations
3737
2. Charging station requests payment (amount may be estimated or updated during session)
38-
3. Vehicle signs SPA for the authorized amount
39-
4. Station verifies MPCP chain
40-
5. Power is supplied; settlement executes when session ends
38+
3. Vehicle issues SBA for the authorized amount
39+
4. Station verifies MPCP chain locally
40+
5. Power is supplied; Trust Gateway submits XRPL settlement when session ends
4141

4242
## Run Parking Example (Same Flow)
4343

docs/examples/fleet.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Machine-to-machine payment loop for autonomous fleet vehicles.
44

55
## Scenario
66

7-
Robotaxi enters parking facility → parking meter sends payment request → vehicle evaluates fleet policy and session budget → vehicle signs SPApayment executes on rail → parking system verifies MPCP chain → gate opens.
7+
Robotaxi enters parking facility → parking meter sends payment request → vehicle evaluates fleet policy and session budget → vehicle issues SBATrust Gateway verifies chain and executes XRPL payment → parking system verifies MPCP chain → gate opens.
88

99
## Architecture
1010

@@ -15,18 +15,24 @@ Robotaxi enters parking facility → parking meter sends payment request → veh
1515
│ │ │ wallet) │
1616
│ • request │ MPCP artifacts │ │
1717
│ • verify │ ◄──────────────────────── │ • policy check │
18-
└────────┬────────┘ (SBA, SPA, intent) │ • budget check │
19-
│ │ • sign SPA
18+
└────────┬────────┘ (PolicyGrant, SBA) │ • budget check │
19+
│ │ • issue SBA
2020
│ verify └────────┬────────┘
2121
▼ │
22-
┌─────────────────┐ │ execute
22+
┌─────────────────┐ │ SBA to gateway
2323
│ Verifier │ ▼
2424
│ (local, no API) │ ┌─────────────────┐
25-
└─────────────────┘ │ Settlement Rail │
26-
│ │ (mock / XRPL) │
27-
│ PASS └─────────────────┘
28-
29-
Gate opens
25+
└─────────────────┘ │ Trust Gateway │
26+
│ │ verify chain + │
27+
│ PASS │ submit XRPL │
28+
▼ └────────┬────────┘
29+
Gate opens │
30+
31+
┌─────────────────┐
32+
│ XRPL Ledger │
33+
│ (mpcp/grant-id │
34+
│ memo attached) │
35+
└─────────────────┘
3036
```
3137

3238
## Components
@@ -35,8 +41,8 @@ Robotaxi enters parking facility → parking meter sends payment request → veh
3541
|-----------|------|
3642
| **Vehicle Agent** | MPCP SDK, wallet/signing keys, policy + budget enforcement |
3743
| **Parking Service** | Payment request endpoint, MPCP verification |
38-
| **Verifier** | Validates PolicyGrant → SBA → SPA → SettlementIntent chain |
39-
| **Settlement Rail** | Mock rail or XRPL |
44+
| **Verifier** | Validates PolicyGrant → SBA → Settlement chain |
45+
| **Trust Gateway** | Verifies SBA chain, submits XRPL payment with `mpcp/grant-id` memo |
4046

4147
## Run
4248

@@ -73,7 +79,7 @@ Uses `examples/machine-commerce/fleet-policy.json` and `simulate.mjs`.
7379

7480
- Autonomous payment authorization within fleet limits
7581
- Session budget enforcement
76-
- Deterministic SettlementIntent hashing
82+
- Trust Gateway handles XRPL execution with on-chain audit trail
7783
- Verification without centralized payment infrastructure
7884

7985
## See Also

docs/examples/machine-wallet-guardrails.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Runnable example showing how MPCP acts as a **machine wallet guardrail layer**.
44

55
## Overview
66

7-
A machine wallet should not send funds unless payment requests satisfy:
7+
A machine wallet should not authorize payments unless payment requests satisfy:
88

99
- **PolicyGrant** constraints (rails, assets, expiration)
1010
- **SignedBudgetAuthorization** session limits (max amount, destination allowlist)
11-
- **SignedPaymentAuthorization** approval rules (amount binding, intent hash)
1211

13-
This example shows the integration pattern: check all three layers before signing.
12+
Once the SBA is issued, the **Trust Gateway** verifies the chain and executes the XRPL payment.
13+
14+
This example shows the integration pattern: check both layers before issuing an SBA.
1415

1516
This example focuses on wallet-side guardrail logic and uses a preloaded SBA-shaped authorization object rather than demonstrating full SBA issuance and signature verification.
1617

@@ -29,14 +30,14 @@ node examples/machine-wallet-guardrails/wallet-integration.mjs
2930

3031
## What It Demonstrates
3132

32-
1. **Allowed request** — $15 to rParking passes all checks; SignedPaymentAuthorization is created
33+
1. **Allowed request** — $15 to rParking passes all checks; SignedBudgetAuthorization is created
3334
2. **Wrong destination** — $5 to rAttacker is rejected (not in allowlist)
3435
3. **Would exceed budget** — $20 to rCharging when session already spent $15 is rejected
3536

3637
## Guardrail Check Flow
3738

3839
```
39-
Payment request → PolicyGrant validation → SignedBudgetAuthorization validation → SignedPaymentAuthorization creation (or reject)
40+
Payment request → PolicyGrant validation → SignedBudgetAuthorization validation → SBA issued (or reject) → Trust Gateway → XRPL
4041
```
4142

4243
See [Machine Wallet Guardrails](../implementation/machine-wallet-guardrails.md) for the full guide and threat model.

docs/examples/parking.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A full MPCP settlement flow for a parking payment scenario.
44

55
## Scenario
66

7-
Vehicle parks at a meter or garage gate. The parking system requests payment. The vehicle evaluates fleet policy and session budget, signs an SPA, and returns the authorization. The parking system verifies the MPCP chain locally and opens the gate.
7+
Vehicle parks at a meter or garage gate. The parking system requests payment. The vehicle evaluates fleet policy and session budget, issues an SBA, and presents it to the Trust Gateway. The Trust Gateway verifies the MPCP chain and executes the XRPL payment. The parking system verifies the chain locally and opens the gate.
88

99
## Artifacts
1010

@@ -13,9 +13,7 @@ Vehicle parks at a meter or garage gate. The parking system requests payment. Th
1313
| policy-grant.json | Grant derived from policy constraints |
1414
| budget-auth.json | Unsigned budget authorization |
1515
| signed-budget-auth.json | Signed budget auth (SBA) |
16-
| spa.json | Signed payment authorization |
17-
| settlement-intent.json | Settlement intent |
18-
| settlement.json | Settlement result |
16+
| settlement.json | Settlement result (XRPL via Trust Gateway) |
1917
| settlement-bundle.json | Combined bundle for verification |
2018

2119
## Run
@@ -55,7 +53,7 @@ npm run example:guardrails
5553

5654
### Offline Payment
5755

58-
Demonstrates offline machine payments: vehicle holds pre-authorized policy chain, completes payment when network is unavailable.
56+
Demonstrates offline machine payments: vehicle holds pre-authorized policy chain, authorizes payment when network is unavailable, Trust Gateway settles on XRPL when connectivity returns.
5957

6058
```bash
6159
npm run example:offline

docs/implementation/conformance.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MPCP implementations can be verified for conformance to the protocol specificati
66

77
| Level | Scope | Description |
88
|-------|-------|-------------|
9-
| **Artifact** | Single artifact | Produces valid PolicyGrant, SBA, SPA, SettlementIntent per spec |
9+
| **Artifact** | Single artifact | Produces valid PolicyGrant and SBA per spec |
1010
| **Chain** | Full authorization chain | Links artifacts correctly (policyHash, sessionId, constraints) |
1111
| **Verification** | Settlement verification | Passes all verification checks for valid bundles |
1212
| **Profile** | Deployment profile | Matches a reference profile (parking, charging, fleet-offline, hosted-rail) |
@@ -18,8 +18,7 @@ The reference implementation includes golden vectors in `test/vectors/` for conf
1818
- `valid-settlement.json` — Full valid chain, must pass
1919
- `expired-grant.json` — Expired PolicyGrant, must fail
2020
- `budget-exceeded.json` — Amount exceeds budget, must fail
21-
- `intent-hash-mismatch.json` — Intent hash mismatch, must fail
22-
- `settlement-mismatch.json` — Settlement does not match SPA, must fail
21+
- `settlement-mismatch.json` — Settlement does not match SBA constraints, must fail
2322

2423
Run the conformance tests:
2524

@@ -36,7 +35,7 @@ Implementers should verify:
3635
2. **Canonical JSON** — Deterministic serialization for hashing
3736
3. **Domain-separated hashing** — Correct prefix per artifact type
3837
4. **Signature verification** — Valid key resolution and signature check
39-
5. **Constraint propagation** — SBA ⊆ PolicyGrant, SPA ⊆ SBA
38+
5. **Constraint propagation** — SBA ⊆ PolicyGrant
4039

4140
## See Also
4241

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# Dispute Verification
22

3-
Tooling to verify disputed settlements using the full MPCP chain plus optional ledger anchor.
3+
Tooling to verify disputed settlements using the full MPCP chain plus optional policy anchor.
44

55
## Purpose
66

77
When a settlement is disputed, `verifyDisputedSettlement` validates:
88

9-
1. **MPCP chain** — PolicyGrant → SignedBudgetAuthorization → SignedPaymentAuthorization → SettlementIntent
10-
2. **Ledger anchor** (optional) — When provided, verifies the anchor is consistent with the settlement intent
9+
1. **MPCP chain** — PolicyGrant → SignedBudgetAuthorization → Settlement
10+
2. **Policy anchor** (optional) — When provided, verifies the `anchorRef` on the PolicyGrant is consistent with an on-chain record of the policy document
1111

1212
## Usage
1313

1414
```typescript
15-
import { verifyDisputedSettlement, mockAnchorIntentHash } from "mpcp-service";
16-
import { computeSettlementIntentHash } from "mpcp-service";
15+
import { verifyDisputedSettlement } from "mpcp-service";
1716

1817
const result = verifyDisputedSettlement({
1918
context: settlementVerificationContext,
20-
ledgerAnchor: await mockAnchorIntentHash(computeSettlementIntentHash(intent)),
19+
// Optional: ledger anchor result from policy document anchoring
20+
ledgerAnchor: {
21+
anchorRef: grant.anchorRef, // "hcs:0.0.12345:42" or "xrpl:nft:ABC123..."
22+
rail: "hedera-hcs",
23+
sequenceNumber: "42",
24+
topicId: "0.0.12345",
25+
},
2126
});
2227

2328
if (result.verified) {
@@ -29,8 +34,8 @@ if (result.verified) {
2934

3035
## Inputs
3136

32-
- **context** — Full `SettlementVerificationContext` (settlement, artifacts, policy grant, SBA, SPA, decision, settlement intent)
33-
- **ledgerAnchor** — Optional `AnchorResult` from intent anchoring
37+
- **context** — Full `SettlementVerificationContext` (settlement, policyGrant, signedBudgetAuthorization, decision)
38+
- **ledgerAnchor** — Optional `PolicyAnchorResult` from policy document anchoring
3439

3540
## Output
3641

@@ -40,10 +45,23 @@ if (result.verified) {
4045
## Failure Reasons
4146

4247
- `settlement_verification_failed` — Standard MPCP chain verification failed
43-
- `anchor_provided_but_settlement_intent_missing` — Anchor provided but context has no settlement intent
44-
- `anchor_mismatch: ...`Mock anchor txHash does not match intent hash
45-
- `anchor_rail_not_supported: ...`Real ledger anchor verification not yet implemented
48+
- `anchor_provided_but_anchor_ref_missing` — Anchor provided but PolicyGrant has no `anchorRef`
49+
- `anchor_mismatch`PolicyGrant `anchorRef` does not match the provided ledger anchor
50+
- `anchor_rail_not_supported`Anchor rail not available for verification
4651

47-
## Mock Anchor
52+
## Async Verification (Hedera HCS Mirror)
4853

49-
Only mock anchors are supported. Real ledger verification (Hedera HCS, XRPL, EVM) is future work.
54+
Use `verifyDisputedSettlementAsync` to verify a Hedera HCS anchor by querying the mirror node:
55+
56+
```typescript
57+
const result = await verifyDisputedSettlementAsync({
58+
context: settlementVerificationContext,
59+
ledgerAnchor: hcsAnchorResult,
60+
});
61+
```
62+
63+
This fetches the anchored policy document from the Hedera mirror node and confirms it matches the PolicyGrant's `policyHash`.
64+
65+
## XRPL Audit Trail
66+
67+
Even without a policy document anchor, every XRPL payment submitted via the Trust Gateway includes an `mpcp/grant-id` memo. Disputes can reference this memo to confirm the on-chain payment was associated with the correct PolicyGrant.

0 commit comments

Comments
 (0)