@redditech/agent-protocol 0.0.0-stage → 0.2.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +21 -0
  3. package/README.md +394 -2
  4. package/dist/adl.d.ts +141 -0
  5. package/dist/adl.js +3601 -0
  6. package/dist/agent-stack-fixtures.d.ts +743 -0
  7. package/dist/agent-stack-fixtures.js +1554 -0
  8. package/dist/ai-catalog.d.ts +128 -0
  9. package/dist/ai-catalog.js +373 -0
  10. package/dist/attestation-reputation.d.ts +102 -0
  11. package/dist/attestation-reputation.js +279 -0
  12. package/dist/audd-rail-config.d.ts +102 -0
  13. package/dist/audd-rail-config.js +294 -0
  14. package/dist/browser-wallet-approval.d.ts +293 -0
  15. package/dist/browser-wallet-approval.js +1201 -0
  16. package/dist/discovery-source.d.ts +115 -0
  17. package/dist/discovery-source.js +251 -0
  18. package/dist/evidence-archive.d.ts +73 -0
  19. package/dist/evidence-archive.js +238 -0
  20. package/dist/index.d.ts +23 -0
  21. package/dist/index.js +23 -0
  22. package/dist/mpp-tempo-receipt-shapes.d.ts +201 -0
  23. package/dist/mpp-tempo-receipt-shapes.js +330 -0
  24. package/dist/okf-adapter.d.ts +229 -0
  25. package/dist/okf-adapter.js +556 -0
  26. package/dist/okf-conformance.d.ts +208 -0
  27. package/dist/okf-conformance.js +651 -0
  28. package/dist/okf-instruction-safety.d.ts +192 -0
  29. package/dist/okf-instruction-safety.js +509 -0
  30. package/dist/onboarding-analyser-handoff.d.ts +391 -0
  31. package/dist/onboarding-analyser-handoff.js +959 -0
  32. package/dist/onboarding-state-machine.d.ts +228 -0
  33. package/dist/onboarding-state-machine.js +432 -0
  34. package/dist/payment-records.d.ts +181 -0
  35. package/dist/payment-records.js +599 -0
  36. package/dist/policy.d.ts +33 -0
  37. package/dist/policy.js +45 -0
  38. package/dist/provider-trust.d.ts +113 -0
  39. package/dist/provider-trust.js +346 -0
  40. package/dist/quasar-registry-compatibility.d.ts +113 -0
  41. package/dist/quasar-registry-compatibility.js +214 -0
  42. package/dist/ranking-explainability.d.ts +202 -0
  43. package/dist/ranking-explainability.js +302 -0
  44. package/dist/receipt-v2.d.ts +202 -0
  45. package/dist/receipt-v2.js +418 -0
  46. package/dist/repo-explorer-evidence-manifest.d.ts +387 -0
  47. package/dist/repo-explorer-evidence-manifest.js +1187 -0
  48. package/dist/source-diagnostics.d.ts +84 -0
  49. package/dist/source-diagnostics.js +193 -0
  50. package/dist/source-trust-conformance-matrix.d.ts +207 -0
  51. package/dist/source-trust-conformance-matrix.js +672 -0
  52. package/examples/ard-no-spend-ai-catalog.json +51 -0
  53. package/examples/ard-no-spend-demo.mjs +355 -0
  54. package/examples/interpretation-guide-scenarios.mjs +302 -0
  55. package/package.json +144 -4
@@ -0,0 +1,23 @@
1
+ export * from './policy.js';
2
+ export * from './receipt-v2.js';
3
+ export * from './ai-catalog.js';
4
+ export * from './provider-trust.js';
5
+ export * from './discovery-source.js';
6
+ export * from './evidence-archive.js';
7
+ export * from './source-diagnostics.js';
8
+ export * from './source-trust-conformance-matrix.js';
9
+ export * from './attestation-reputation.js';
10
+ export * from './audd-rail-config.js';
11
+ export * from './payment-records.js';
12
+ export * from './agent-stack-fixtures.js';
13
+ export * from './quasar-registry-compatibility.js';
14
+ export * from './mpp-tempo-receipt-shapes.js';
15
+ export * from './okf-adapter.js';
16
+ export * from './okf-conformance.js';
17
+ export * from './okf-instruction-safety.js';
18
+ export * from './onboarding-analyser-handoff.js';
19
+ export * from './onboarding-state-machine.js';
20
+ export * from './repo-explorer-evidence-manifest.js';
21
+ export * from './ranking-explainability.js';
22
+ export * from './browser-wallet-approval.js';
23
+ export * from './adl.js';
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ export * from './policy.js';
2
+ export * from './receipt-v2.js';
3
+ export * from './ai-catalog.js';
4
+ export * from './provider-trust.js';
5
+ export * from './discovery-source.js';
6
+ export * from './evidence-archive.js';
7
+ export * from './source-diagnostics.js';
8
+ export * from './source-trust-conformance-matrix.js';
9
+ export * from './attestation-reputation.js';
10
+ export * from './audd-rail-config.js';
11
+ export * from './payment-records.js';
12
+ export * from './agent-stack-fixtures.js';
13
+ export * from './quasar-registry-compatibility.js';
14
+ export * from './mpp-tempo-receipt-shapes.js';
15
+ export * from './okf-adapter.js';
16
+ export * from './okf-conformance.js';
17
+ export * from './okf-instruction-safety.js';
18
+ export * from './onboarding-analyser-handoff.js';
19
+ export * from './onboarding-state-machine.js';
20
+ export * from './repo-explorer-evidence-manifest.js';
21
+ export * from './ranking-explainability.js';
22
+ export * from './browser-wallet-approval.js';
23
+ export * from './adl.js';
@@ -0,0 +1,201 @@
1
+ export declare const MPP_TEMPO_RECEIPT_SHAPE_SCHEMA_VERSION: "reddi.mpp-tempo-receipt-shape.v1";
2
+ export type MppTempoReceiptFixtureCase = 'mpp_single_charge_tempo_candidate' | 'mpp_session_probe' | 'mpp_split_probe' | 'tempo_live_receipt_unsupported';
3
+ export type MppTempoReceiptSupportState = 'binding_candidate' | 'probe_only' | 'unsupported_live_rail';
4
+ export type MppTempoPaymentMethod = 'tempo-stablecoin';
5
+ export type MppTempoChallengeShape = {
6
+ protocol: 'mpp';
7
+ status: 402;
8
+ intent: 'charge' | 'session';
9
+ paymentMethod: MppTempoPaymentMethod;
10
+ network: 'tempo';
11
+ asset: 'USDC' | 'pathUSD';
12
+ amount: string;
13
+ unit: 'microusd' | 'base-units';
14
+ endpoint: string;
15
+ nonce: string;
16
+ recipientRef: string;
17
+ sessionCap?: string;
18
+ splitRecipients?: string[];
19
+ };
20
+ export type MppTempoReceiptShape = {
21
+ protocol: 'mpp';
22
+ paymentMethod: MppTempoPaymentMethod;
23
+ network: 'tempo';
24
+ asset: 'USDC' | 'pathUSD';
25
+ amount: string;
26
+ status: 'success';
27
+ nonce: string;
28
+ receiptRef: string;
29
+ settledAt: string;
30
+ };
31
+ export type MppTempoFixtureSummary = {
32
+ schema: string;
33
+ case: MppTempoReceiptFixtureCase;
34
+ sourceRefs: string[];
35
+ artifactPath: string;
36
+ challenge: MppTempoChallengeShape;
37
+ receipt?: MppTempoReceiptShape;
38
+ liveReceipt?: unknown;
39
+ claimBoundary: string[];
40
+ };
41
+ export type MppTempoBindingRefs = {
42
+ sourceId: 'mpp-tempo:fixture-corpus';
43
+ challengeRef: string;
44
+ paymentProofRef: string;
45
+ evidenceRef: string;
46
+ requestHash: string;
47
+ responseHash: string;
48
+ recipientRef: string;
49
+ nonceRef: string;
50
+ operatorApprovalRef: string;
51
+ };
52
+ export type MppTempoReceiptShapeFixture = {
53
+ schemaVersion: typeof MPP_TEMPO_RECEIPT_SHAPE_SCHEMA_VERSION;
54
+ case: MppTempoReceiptFixtureCase;
55
+ supportState: MppTempoReceiptSupportState;
56
+ artifactPath: string;
57
+ challenge: MppTempoChallengeShape;
58
+ receipt?: MppTempoReceiptShape;
59
+ bindingRefs: MppTempoBindingRefs;
60
+ guardrails: {
61
+ fixtureOnly: true;
62
+ walletSigning: false;
63
+ rpcCall: false;
64
+ providerCall: false;
65
+ livePayment: false;
66
+ hostedRegistryWrite: false;
67
+ trustUpgrade: false;
68
+ reputationMutation: false;
69
+ };
70
+ claimBoundary: string[];
71
+ };
72
+ export type MppTempoReceiptShapeErrorCode = 'malformed_fixture' | 'unsupported_protocol' | 'unsupported_payment_method' | 'malformed_challenge' | 'malformed_receipt' | 'receipt_challenge_mismatch' | 'live_path_rejected' | 'unsupported_live_rail';
73
+ export type MppTempoReceiptShapeError = {
74
+ code: MppTempoReceiptShapeErrorCode;
75
+ path: string;
76
+ message: string;
77
+ };
78
+ export type MppTempoReceiptShapeResult = {
79
+ ok: true;
80
+ fixture: MppTempoReceiptShapeFixture;
81
+ } | {
82
+ ok: false;
83
+ errors: MppTempoReceiptShapeError[];
84
+ };
85
+ export declare const MPP_TEMPO_RECEIPT_SHAPE_GUARDRAILS: {
86
+ readonly fixtureOnly: true;
87
+ readonly walletSigning: false;
88
+ readonly rpcCall: false;
89
+ readonly providerCall: false;
90
+ readonly livePayment: false;
91
+ readonly hostedRegistryWrite: false;
92
+ readonly trustUpgrade: false;
93
+ readonly reputationMutation: false;
94
+ };
95
+ export declare const mppTempoReceiptShapeSummaries: {
96
+ tempoSingleChargeCandidate: {
97
+ schema: string;
98
+ case: "mpp_single_charge_tempo_candidate";
99
+ sourceRefs: string[];
100
+ artifactPath: string;
101
+ challenge: {
102
+ protocol: "mpp";
103
+ status: 402;
104
+ intent: "charge";
105
+ paymentMethod: "tempo-stablecoin";
106
+ network: "tempo";
107
+ asset: "USDC";
108
+ amount: string;
109
+ unit: "microusd";
110
+ endpoint: string;
111
+ nonce: string;
112
+ recipientRef: string;
113
+ };
114
+ receipt: {
115
+ protocol: "mpp";
116
+ paymentMethod: "tempo-stablecoin";
117
+ network: "tempo";
118
+ asset: "USDC";
119
+ amount: string;
120
+ status: "success";
121
+ nonce: string;
122
+ receiptRef: string;
123
+ settledAt: string;
124
+ };
125
+ claimBoundary: string[];
126
+ };
127
+ tempoSessionProbe: {
128
+ schema: string;
129
+ case: "mpp_session_probe";
130
+ sourceRefs: string[];
131
+ artifactPath: string;
132
+ challenge: {
133
+ protocol: "mpp";
134
+ status: 402;
135
+ intent: "session";
136
+ paymentMethod: "tempo-stablecoin";
137
+ network: "tempo";
138
+ asset: "pathUSD";
139
+ amount: string;
140
+ unit: "base-units";
141
+ endpoint: string;
142
+ nonce: string;
143
+ recipientRef: string;
144
+ sessionCap: string;
145
+ };
146
+ claimBoundary: string[];
147
+ };
148
+ tempoSplitProbe: {
149
+ schema: string;
150
+ case: "mpp_split_probe";
151
+ sourceRefs: string[];
152
+ artifactPath: string;
153
+ challenge: {
154
+ protocol: "mpp";
155
+ status: 402;
156
+ intent: "charge";
157
+ paymentMethod: "tempo-stablecoin";
158
+ network: "tempo";
159
+ asset: "USDC";
160
+ amount: string;
161
+ unit: "microusd";
162
+ endpoint: string;
163
+ nonce: string;
164
+ recipientRef: string;
165
+ splitRecipients: string[];
166
+ };
167
+ claimBoundary: string[];
168
+ };
169
+ tempoLiveReceiptUnsupported: {
170
+ schema: string;
171
+ case: "tempo_live_receipt_unsupported";
172
+ sourceRefs: string[];
173
+ artifactPath: string;
174
+ challenge: {
175
+ protocol: "mpp";
176
+ status: 402;
177
+ intent: "charge";
178
+ paymentMethod: "tempo-stablecoin";
179
+ network: "tempo";
180
+ asset: "USDC";
181
+ amount: string;
182
+ unit: "microusd";
183
+ endpoint: string;
184
+ nonce: string;
185
+ recipientRef: string;
186
+ };
187
+ liveReceipt: {
188
+ status: string;
189
+ network: string;
190
+ txHash: string;
191
+ };
192
+ claimBoundary: string[];
193
+ };
194
+ };
195
+ export declare function createMppTempoReceiptShapeFixture(summary: MppTempoFixtureSummary): MppTempoReceiptShapeFixture;
196
+ export declare function deriveMppTempoReceiptShapeFixture(summary: MppTempoFixtureSummary): MppTempoReceiptShapeResult;
197
+ export declare const mppTempoReceiptShapeFixtures: {
198
+ readonly tempoSingleChargeCandidate: MppTempoReceiptShapeFixture;
199
+ readonly tempoSessionProbe: MppTempoReceiptShapeFixture;
200
+ readonly tempoSplitProbe: MppTempoReceiptShapeFixture;
201
+ };
@@ -0,0 +1,330 @@
1
+ import { createHash } from 'node:crypto';
2
+ export const MPP_TEMPO_RECEIPT_SHAPE_SCHEMA_VERSION = 'reddi.mpp-tempo-receipt-shape.v1';
3
+ export const MPP_TEMPO_RECEIPT_SHAPE_GUARDRAILS = {
4
+ fixtureOnly: true,
5
+ walletSigning: false,
6
+ rpcCall: false,
7
+ providerCall: false,
8
+ livePayment: false,
9
+ hostedRegistryWrite: false,
10
+ trustUpgrade: false,
11
+ reputationMutation: false,
12
+ };
13
+ const OPERATOR_APPROVAL_REF = 'github-issue:#455:fixture-only-approval';
14
+ const MPP_DOC_REF = 'https://docs.stripe.com/payments/machine/mpp';
15
+ const TEMPO_DOC_REF = 'https://docs.tempo.xyz/';
16
+ const PARALLEL_MPP_REF = 'https://docs.parallel.ai/integrations/agentic-payments';
17
+ export const mppTempoReceiptShapeSummaries = {
18
+ tempoSingleChargeCandidate: {
19
+ schema: 'reddi.mpp-tempo.fixture-summary.v1',
20
+ case: 'mpp_single_charge_tempo_candidate',
21
+ sourceRefs: [MPP_DOC_REF, TEMPO_DOC_REF, PARALLEL_MPP_REF],
22
+ artifactPath: 'fixtures/payment/mpp-tempo/single-charge-candidate.json',
23
+ challenge: {
24
+ protocol: 'mpp',
25
+ status: 402,
26
+ intent: 'charge',
27
+ paymentMethod: 'tempo-stablecoin',
28
+ network: 'tempo',
29
+ asset: 'USDC',
30
+ amount: '1000',
31
+ unit: 'microusd',
32
+ endpoint: 'https://example.invalid/paid/search',
33
+ nonce: 'mpp-tempo-nonce-single-charge',
34
+ recipientRef: 'tempo:recipient:operator-approved-fixture',
35
+ },
36
+ receipt: {
37
+ protocol: 'mpp',
38
+ paymentMethod: 'tempo-stablecoin',
39
+ network: 'tempo',
40
+ asset: 'USDC',
41
+ amount: '1000',
42
+ status: 'success',
43
+ nonce: 'mpp-tempo-nonce-single-charge',
44
+ receiptRef: 'mpp-tempo-receipt:single-charge-fixture',
45
+ settledAt: '2026-06-22T00:00:00.000Z',
46
+ },
47
+ claimBoundary: [
48
+ 'MPP Tempo single-charge fixture is a receipt-shape binding candidate only.',
49
+ 'No Tempo wallet, RPC, provider call, live payment, hosted registry write, trust upgrade, or reputation mutation is performed.',
50
+ ],
51
+ },
52
+ tempoSessionProbe: {
53
+ schema: 'reddi.mpp-tempo.fixture-summary.v1',
54
+ case: 'mpp_session_probe',
55
+ sourceRefs: [MPP_DOC_REF, TEMPO_DOC_REF],
56
+ artifactPath: 'fixtures/payment/mpp-tempo/session-probe.json',
57
+ challenge: {
58
+ protocol: 'mpp',
59
+ status: 402,
60
+ intent: 'session',
61
+ paymentMethod: 'tempo-stablecoin',
62
+ network: 'tempo',
63
+ asset: 'pathUSD',
64
+ amount: '1000000',
65
+ unit: 'base-units',
66
+ endpoint: 'https://example.invalid/paid/session',
67
+ nonce: 'mpp-tempo-nonce-session',
68
+ recipientRef: 'tempo:recipient:operator-approved-fixture',
69
+ sessionCap: '1000000',
70
+ },
71
+ claimBoundary: [
72
+ 'MPP Tempo session fixture records challenge shape only.',
73
+ 'RAP does not claim settlement, repeated-call authorization, wallet signing, provider execution, or live activation from this fixture.',
74
+ ],
75
+ },
76
+ tempoSplitProbe: {
77
+ schema: 'reddi.mpp-tempo.fixture-summary.v1',
78
+ case: 'mpp_split_probe',
79
+ sourceRefs: [MPP_DOC_REF, TEMPO_DOC_REF],
80
+ artifactPath: 'fixtures/payment/mpp-tempo/split-probe.json',
81
+ challenge: {
82
+ protocol: 'mpp',
83
+ status: 402,
84
+ intent: 'charge',
85
+ paymentMethod: 'tempo-stablecoin',
86
+ network: 'tempo',
87
+ asset: 'USDC',
88
+ amount: '2000',
89
+ unit: 'microusd',
90
+ endpoint: 'https://example.invalid/paid/split',
91
+ nonce: 'mpp-tempo-nonce-split',
92
+ recipientRef: 'tempo:recipient:operator-approved-fixture',
93
+ splitRecipients: ['tempo:recipient:downstream-specialist-fixture'],
94
+ },
95
+ claimBoundary: [
96
+ 'MPP Tempo split fixture records challenge metadata only.',
97
+ 'RAP does not claim split settlement, provider payment, trust upgrade, reputation mutation, or live activation from this fixture.',
98
+ ],
99
+ },
100
+ tempoLiveReceiptUnsupported: {
101
+ schema: 'reddi.mpp-tempo.fixture-summary.v1',
102
+ case: 'tempo_live_receipt_unsupported',
103
+ sourceRefs: [TEMPO_DOC_REF],
104
+ artifactPath: 'fixtures/payment/mpp-tempo/live-receipt-unsupported.json',
105
+ challenge: {
106
+ protocol: 'mpp',
107
+ status: 402,
108
+ intent: 'charge',
109
+ paymentMethod: 'tempo-stablecoin',
110
+ network: 'tempo',
111
+ asset: 'USDC',
112
+ amount: '1000',
113
+ unit: 'microusd',
114
+ endpoint: 'https://example.invalid/live/paid/search',
115
+ nonce: 'mpp-tempo-nonce-live-unsupported',
116
+ recipientRef: 'tempo:recipient:operator-approved-fixture',
117
+ },
118
+ liveReceipt: {
119
+ status: 'success',
120
+ network: 'tempo',
121
+ txHash: '0xlive-path-not-accepted-in-fixtures',
122
+ },
123
+ claimBoundary: [
124
+ 'Live Tempo receipts are unsupported in this fixture corpus.',
125
+ 'A future live lane needs explicit wallet, spend, verifier, and operator approval gates before RAP can accept live settlement claims.',
126
+ ],
127
+ },
128
+ };
129
+ export function createMppTempoReceiptShapeFixture(summary) {
130
+ const result = deriveMppTempoReceiptShapeFixture(summary);
131
+ if (!result.ok) {
132
+ throw new Error(`invalid_mpp_tempo_receipt_shape:${result.errors.map((item) => `${item.code}:${item.path}`).join(',')}`);
133
+ }
134
+ return result.fixture;
135
+ }
136
+ export function deriveMppTempoReceiptShapeFixture(summary) {
137
+ const errors = [];
138
+ validateFixture(summary, errors);
139
+ validateChallenge(summary.challenge, errors);
140
+ validateNoLivePath(summary, errors);
141
+ if (summary.case === 'tempo_live_receipt_unsupported') {
142
+ errors.push(error('unsupported_live_rail', '$.liveReceipt', 'live Tempo receipts require a separate approved live verifier lane'));
143
+ }
144
+ else if (summary.case === 'mpp_single_charge_tempo_candidate') {
145
+ validateReceipt(summary, errors);
146
+ }
147
+ else if (summary.receipt) {
148
+ errors.push(error('malformed_receipt', '$.receipt', 'probe-only fixtures must not include receipt success claims'));
149
+ }
150
+ if (errors.length > 0)
151
+ return { ok: false, errors };
152
+ return {
153
+ ok: true,
154
+ fixture: {
155
+ schemaVersion: MPP_TEMPO_RECEIPT_SHAPE_SCHEMA_VERSION,
156
+ case: summary.case,
157
+ supportState: summary.case === 'mpp_single_charge_tempo_candidate' ? 'binding_candidate' : 'probe_only',
158
+ artifactPath: summary.artifactPath,
159
+ challenge: summary.challenge,
160
+ receipt: summary.receipt,
161
+ bindingRefs: createBindingRefs(summary),
162
+ guardrails: MPP_TEMPO_RECEIPT_SHAPE_GUARDRAILS,
163
+ claimBoundary: summary.claimBoundary,
164
+ },
165
+ };
166
+ }
167
+ export const mppTempoReceiptShapeFixtures = {
168
+ tempoSingleChargeCandidate: createMppTempoReceiptShapeFixture(mppTempoReceiptShapeSummaries.tempoSingleChargeCandidate),
169
+ tempoSessionProbe: createMppTempoReceiptShapeFixture(mppTempoReceiptShapeSummaries.tempoSessionProbe),
170
+ tempoSplitProbe: createMppTempoReceiptShapeFixture(mppTempoReceiptShapeSummaries.tempoSplitProbe),
171
+ };
172
+ function validateFixture(summary, errors) {
173
+ if (!isPlainObject(summary)) {
174
+ errors.push(error('malformed_fixture', '$', 'fixture summary must be an object'));
175
+ return;
176
+ }
177
+ if (!isNonEmptyString(summary.schema)) {
178
+ errors.push(error('malformed_fixture', '$.schema', 'schema is required'));
179
+ }
180
+ if (!['mpp_single_charge_tempo_candidate', 'mpp_session_probe', 'mpp_split_probe', 'tempo_live_receipt_unsupported'].includes(String(summary.case))) {
181
+ errors.push(error('malformed_fixture', '$.case', 'unsupported fixture case'));
182
+ }
183
+ if (!Array.isArray(summary.sourceRefs) || summary.sourceRefs.length === 0 || !summary.sourceRefs.every(isNonEmptyString)) {
184
+ errors.push(error('malformed_fixture', '$.sourceRefs', 'docs-backed source refs are required'));
185
+ }
186
+ if (!isNonEmptyString(summary.artifactPath)) {
187
+ errors.push(error('malformed_fixture', '$.artifactPath', 'artifact path is required'));
188
+ }
189
+ if (!Array.isArray(summary.claimBoundary) || summary.claimBoundary.length === 0) {
190
+ errors.push(error('malformed_fixture', '$.claimBoundary', 'claim boundary notes are required'));
191
+ }
192
+ }
193
+ function validateChallenge(challenge, errors) {
194
+ if (!isPlainObject(challenge)) {
195
+ errors.push(error('malformed_challenge', '$.challenge', 'challenge must be an object'));
196
+ return;
197
+ }
198
+ if (challenge.protocol !== 'mpp') {
199
+ errors.push(error('unsupported_protocol', '$.challenge.protocol', 'challenge protocol must be mpp'));
200
+ }
201
+ if (challenge.status !== 402) {
202
+ errors.push(error('malformed_challenge', '$.challenge.status', 'challenge status must be 402'));
203
+ }
204
+ if (!['charge', 'session'].includes(String(challenge.intent))) {
205
+ errors.push(error('malformed_challenge', '$.challenge.intent', 'challenge intent must be charge or session'));
206
+ }
207
+ if (challenge.paymentMethod !== 'tempo-stablecoin') {
208
+ errors.push(error('unsupported_payment_method', '$.challenge.paymentMethod', 'only Tempo stablecoin MPP fixtures are accepted'));
209
+ }
210
+ if (challenge.network !== 'tempo') {
211
+ errors.push(error('unsupported_payment_method', '$.challenge.network', 'network must be tempo'));
212
+ }
213
+ if (!['USDC', 'pathUSD'].includes(String(challenge.asset))) {
214
+ errors.push(error('unsupported_payment_method', '$.challenge.asset', 'asset must be USDC or pathUSD'));
215
+ }
216
+ if (!positiveAmount(challenge.amount)) {
217
+ errors.push(error('malformed_challenge', '$.challenge.amount', 'amount must be a positive integer string'));
218
+ }
219
+ if (!['microusd', 'base-units'].includes(String(challenge.unit))) {
220
+ errors.push(error('malformed_challenge', '$.challenge.unit', 'unit is unsupported'));
221
+ }
222
+ if (!isHttpsUrl(challenge.endpoint)) {
223
+ errors.push(error('malformed_challenge', '$.challenge.endpoint', 'endpoint must be an HTTPS URL'));
224
+ }
225
+ if (!isNonEmptyString(challenge.nonce)) {
226
+ errors.push(error('malformed_challenge', '$.challenge.nonce', 'nonce is required'));
227
+ }
228
+ if (!isNonEmptyString(challenge.recipientRef)) {
229
+ errors.push(error('malformed_challenge', '$.challenge.recipientRef', 'recipient ref is required'));
230
+ }
231
+ if (challenge.intent === 'session' && !positiveAmount(challenge.sessionCap)) {
232
+ errors.push(error('malformed_challenge', '$.challenge.sessionCap', 'session fixtures require a positive cap'));
233
+ }
234
+ if (challenge.splitRecipients && (!Array.isArray(challenge.splitRecipients) || challenge.splitRecipients.length === 0 || !challenge.splitRecipients.every(isNonEmptyString))) {
235
+ errors.push(error('malformed_challenge', '$.challenge.splitRecipients', 'split recipients must be non-empty string refs'));
236
+ }
237
+ }
238
+ function validateReceipt(summary, errors) {
239
+ const { receipt, challenge } = summary;
240
+ if (!isPlainObject(receipt)) {
241
+ errors.push(error('malformed_receipt', '$.receipt', 'single-charge candidates require a receipt shape'));
242
+ return;
243
+ }
244
+ if (receipt.protocol !== 'mpp') {
245
+ errors.push(error('unsupported_protocol', '$.receipt.protocol', 'receipt protocol must be mpp'));
246
+ }
247
+ if (receipt.paymentMethod !== challenge.paymentMethod || receipt.network !== challenge.network || receipt.asset !== challenge.asset || receipt.amount !== challenge.amount || receipt.nonce !== challenge.nonce) {
248
+ errors.push(error('receipt_challenge_mismatch', '$.receipt', 'receipt must bind method, network, asset, amount, and nonce to the challenge'));
249
+ }
250
+ if (receipt.status !== 'success') {
251
+ errors.push(error('malformed_receipt', '$.receipt.status', 'receipt status must be success'));
252
+ }
253
+ if (!isNonEmptyString(receipt.receiptRef)) {
254
+ errors.push(error('malformed_receipt', '$.receipt.receiptRef', 'receipt ref is required'));
255
+ }
256
+ if (!isNonEmptyString(receipt.settledAt) || Number.isNaN(Date.parse(receipt.settledAt))) {
257
+ errors.push(error('malformed_receipt', '$.receipt.settledAt', 'settledAt must be an ISO timestamp'));
258
+ }
259
+ }
260
+ function validateNoLivePath(summary, errors) {
261
+ const serialized = JSON.stringify(summary).toLowerCase();
262
+ const rejectedMarkers = [
263
+ 'wallet_private_key',
264
+ 'private_key',
265
+ 'rpc_url',
266
+ 'provider call completed',
267
+ 'provider call performed',
268
+ 'hosted-registry-write',
269
+ 'hosted registry write completed',
270
+ 'hosted registry write performed',
271
+ 'trust-upgrade',
272
+ 'trust upgrade completed',
273
+ 'trust upgrade performed',
274
+ 'reputation-mutation',
275
+ 'reputation mutation completed',
276
+ 'reputation mutation performed',
277
+ 'live payment completed',
278
+ 'live tempo payment accepted',
279
+ ];
280
+ for (const marker of rejectedMarkers) {
281
+ if (serialized.includes(marker)) {
282
+ errors.push(error('live_path_rejected', '$', `fixture contains rejected live-path marker: ${marker}`));
283
+ }
284
+ }
285
+ }
286
+ function createBindingRefs(summary) {
287
+ return {
288
+ sourceId: 'mpp-tempo:fixture-corpus',
289
+ challengeRef: `mpp-tempo-challenge:${summary.challenge.nonce}`,
290
+ paymentProofRef: summary.receipt?.receiptRef ?? `mpp-tempo-probe:${summary.case}:${hashJson(summary.challenge)}`,
291
+ evidenceRef: `file://${summary.artifactPath}`,
292
+ requestHash: hashJson(summary.challenge),
293
+ responseHash: hashJson({
294
+ receipt: summary.receipt ?? null,
295
+ supportState: summary.case === 'mpp_single_charge_tempo_candidate' ? 'binding_candidate' : 'probe_only',
296
+ claimBoundary: summary.claimBoundary,
297
+ }),
298
+ recipientRef: summary.challenge.recipientRef,
299
+ nonceRef: `mpp-tempo-nonce:${summary.challenge.nonce}`,
300
+ operatorApprovalRef: OPERATOR_APPROVAL_REF,
301
+ };
302
+ }
303
+ function error(code, path, message) {
304
+ return { code, path, message };
305
+ }
306
+ function isPlainObject(value) {
307
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
308
+ return false;
309
+ const prototype = Object.getPrototypeOf(value);
310
+ return prototype === Object.prototype || prototype === null;
311
+ }
312
+ function isNonEmptyString(value) {
313
+ return typeof value === 'string' && value.trim().length > 0;
314
+ }
315
+ function positiveAmount(value) {
316
+ return typeof value === 'string' && /^[1-9]\d*$/.test(value);
317
+ }
318
+ function isHttpsUrl(value) {
319
+ if (!isNonEmptyString(value))
320
+ return false;
321
+ try {
322
+ return new URL(value).protocol === 'https:';
323
+ }
324
+ catch {
325
+ return false;
326
+ }
327
+ }
328
+ function hashJson(value) {
329
+ return `sha256:${createHash('sha256').update(JSON.stringify(value)).digest('hex')}`;
330
+ }