@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,959 @@
1
+ /**
2
+ * Onboarding analyser handoff contracts + no-network fixture matrix (#509).
3
+ *
4
+ * Defines the stable typed handoff shapes for the AI onboarding analyser
5
+ * pipeline before implementation splits across endpoint inspection (#459/#371),
6
+ * profile generation (#372), readiness analysis (#373), seller wrapper
7
+ * generation (#375), and operator review UI lanes:
8
+ *
9
+ * intake descriptor
10
+ * -> normalized capability inventory
11
+ * -> generated RAP profile draft
12
+ * -> readiness result
13
+ * -> seller wrapper / payment-plan draft
14
+ * -> listing / export draft
15
+ *
16
+ * This module is PURE and offline-only. It performs no network fetch, plugin
17
+ * install, command execution, MCP call, endpoint invocation, wallet/RPC call,
18
+ * paid call, secret read, hosted write, publication, or reputation mutation.
19
+ * It only validates and re-shapes in-memory fixture descriptors that the
20
+ * caller already holds. All imported metadata is treated as UNTRUSTED data:
21
+ * it can never instruct the analyser to run commands, read secrets, publish
22
+ * listings, enable payments, or upgrade its own trust.
23
+ *
24
+ * Field provenance is separated into exactly five categories:
25
+ * discovered (present in imported metadata), inferred (derived by analyser
26
+ * heuristics), user_provided (supplied by the operator), verified (backed by
27
+ * non-empty evidence refs), and blocked (absent or disallowed until supplied
28
+ * and reviewed).
29
+ */
30
+ export const ONBOARDING_INTAKE_DESCRIPTOR_SCHEMA_VERSION = 'reddi.onboarding-intake-descriptor.v1';
31
+ export const ONBOARDING_CAPABILITY_INVENTORY_SCHEMA_VERSION = 'reddi.onboarding-capability-inventory.v1';
32
+ export const ONBOARDING_RAP_PROFILE_DRAFT_SCHEMA_VERSION = 'reddi.onboarding-rap-profile-draft.v1';
33
+ export const ONBOARDING_READINESS_RESULT_SCHEMA_VERSION = 'reddi.onboarding-readiness-result.v1';
34
+ export const ONBOARDING_SELLER_WRAPPER_DRAFT_SCHEMA_VERSION = 'reddi.onboarding-seller-wrapper-draft.v1';
35
+ export const ONBOARDING_LISTING_EXPORT_DRAFT_SCHEMA_VERSION = 'reddi.onboarding-listing-export-draft.v1';
36
+ export const ONBOARDING_ANALYSER_HANDOFF_SCHEMA_VERSION = 'reddi.onboarding-analyser-handoff.v1';
37
+ export const ONBOARDING_ANALYSER_FIXTURE_MATRIX_SCHEMA_VERSION = 'reddi.onboarding-analyser-fixture-matrix.v1';
38
+ /** Issue anchors so downstream implementations can trace contract ownership. */
39
+ export const ONBOARDING_ANALYSER_HANDOFF_ISSUE = 509;
40
+ export const ONBOARDING_ANALYSER_HANDOFF_PARENT_ISSUES = Object.freeze({
41
+ onboardingAssistantEpic: 370,
42
+ capabilityInventoryFeature: 371,
43
+ rapProfileSchemaTask: 372,
44
+ readinessAnalysisFeature: 373,
45
+ liveAdapterSplitTask: 459,
46
+ });
47
+ /**
48
+ * Hard no-live boundary. Every guardrail is `false` by construction and every
49
+ * emitted payload carries this object so downstream consumers can assert the
50
+ * boundary instead of trusting prose.
51
+ */
52
+ export const ONBOARDING_ANALYSER_GUARDRAILS = Object.freeze({
53
+ networkFetchAllowed: false,
54
+ pluginInstallAllowed: false,
55
+ commandExecutionAllowed: false,
56
+ mcpCallAllowed: false,
57
+ endpointInvocationAllowed: false,
58
+ walletOrRpcAllowed: false,
59
+ paidCallAllowed: false,
60
+ secretReadAllowed: false,
61
+ hostedWriteAllowed: false,
62
+ publicationAllowed: false,
63
+ reputationMutationAllowed: false,
64
+ liveAuthRegistrationAllowed: false,
65
+ });
66
+ export const ONBOARDING_FIXTURE_CLASSES = Object.freeze([
67
+ 'mcp-metadata',
68
+ 'openapi',
69
+ 'a2a-card',
70
+ 'ard-ai-catalog',
71
+ 'manual-descriptor',
72
+ 'static-agent-stack-snapshot',
73
+ 'malformed-input',
74
+ 'credential-shaped-input',
75
+ 'partial-metadata',
76
+ ]);
77
+ const FORBIDDEN_OPERATION_REASONS = {
78
+ network_fetch: 'forbidden_operation_rejected',
79
+ plugin_install: 'command_execution_rejected',
80
+ command_execution: 'command_execution_rejected',
81
+ mcp_call: 'forbidden_operation_rejected',
82
+ endpoint_invocation: 'forbidden_operation_rejected',
83
+ wallet_rpc: 'wallet_rpc_rejected',
84
+ paid_call: 'paid_call_rejected',
85
+ secret_read: 'forbidden_operation_rejected',
86
+ hosted_write: 'forbidden_operation_rejected',
87
+ publication: 'forbidden_operation_rejected',
88
+ reputation_mutation: 'forbidden_operation_rejected',
89
+ };
90
+ /**
91
+ * Upgrade a field to `verified` provenance. Fails closed: verification without
92
+ * at least one evidence ref is rejected with `missing_evidence`.
93
+ */
94
+ export function verifyOnboardingField(field, evidenceRefs) {
95
+ const refs = evidenceRefs.map((ref) => ref.trim()).filter((ref) => ref.length > 0);
96
+ if (refs.length === 0 || field.value === undefined) {
97
+ return { ok: false, reasonCode: 'missing_evidence' };
98
+ }
99
+ return {
100
+ ok: true,
101
+ field: { provenance: 'verified', value: field.value, evidenceRefs: refs },
102
+ };
103
+ }
104
+ export const ONBOARDING_READINESS_LANES = Object.freeze([
105
+ 'capability_fit',
106
+ 'source_identity',
107
+ 'static_source_authenticity',
108
+ 'imported_content_trust',
109
+ 'trust_evidence',
110
+ 'payment_readiness',
111
+ 'policy_fit',
112
+ 'endpoint_safety',
113
+ 'auth_scope_risk',
114
+ 'data_retention_risk',
115
+ 'reputation_readiness',
116
+ ]);
117
+ // ---------------------------------------------------------------------------
118
+ // Validation internals
119
+ // ---------------------------------------------------------------------------
120
+ const RFC3339_UTC_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;
121
+ const SECRET_KEY_PATTERN = /(^|[_-])(api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|client[_-]?secret|authorization|bearer|cookie|password|secret|seed|session[_-]?token|signature|token)($|[_-])|apiKey|accessToken|refreshToken|sessionToken|privateKey/i;
122
+ const SECRET_VALUE_PATTERN = /(authorization:\s*bearer\s+|bearer\s+[a-z0-9._-]{8,}|sk-[a-z0-9_-]{8,}|xox[baprs]-|ghp_[a-z0-9]{16,}|-----BEGIN [A-Z ]*PRIVATE KEY-----)/i;
123
+ const PRIVATE_HOST_PATTERN = /^(localhost|0\.0\.0\.0|127\.(?:\d{1,3}\.){2}\d{1,3}|10\.(?:\d{1,3}\.){2}\d{1,3}|192\.168\.(?:\d{1,3})\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01])\.(?:\d{1,3})\.\d{1,3}|169\.254\.(?:\d{1,3})\.\d{1,3}|\[?::1\]?)$/i;
124
+ const PRIVATE_HOST_SUFFIXES = ['.local', '.internal', '.lan', '.home.arpa'];
125
+ const SIDE_EFFECT_RISKS = ['none', 'read', 'write', 'execute'];
126
+ const SOURCE_KINDS = [
127
+ 'mcp-metadata',
128
+ 'openapi',
129
+ 'a2a-card',
130
+ 'ard-ai-catalog',
131
+ 'manual-descriptor',
132
+ 'static-agent-stack-snapshot',
133
+ ];
134
+ function intakeError(code, path, message) {
135
+ return { code, path, message };
136
+ }
137
+ function isPlainObject(value) {
138
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
139
+ return false;
140
+ const prototype = Object.getPrototypeOf(value);
141
+ return prototype === Object.prototype || prototype === null;
142
+ }
143
+ function isNonEmptyString(value) {
144
+ return typeof value === 'string' && value.trim().length > 0;
145
+ }
146
+ function isOptionalString(value) {
147
+ return value === undefined || isNonEmptyString(value);
148
+ }
149
+ function isOptionalStringArray(value) {
150
+ return value === undefined || (Array.isArray(value) && value.every((item) => typeof item === 'string'));
151
+ }
152
+ function isPrivateOrLocalUrl(parsed) {
153
+ const host = parsed.hostname.toLowerCase();
154
+ if (PRIVATE_HOST_PATTERN.test(host))
155
+ return true;
156
+ return PRIVATE_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
157
+ }
158
+ function validatePublicHttpsUrl(value, path, errors) {
159
+ if (!isNonEmptyString(value)) {
160
+ errors.push(intakeError('malformed_intake_descriptor', path, 'URL must be a non-empty string'));
161
+ return;
162
+ }
163
+ let parsed;
164
+ try {
165
+ parsed = new URL(value);
166
+ }
167
+ catch {
168
+ errors.push(intakeError('malformed_intake_descriptor', path, 'URL must be a valid URL'));
169
+ return;
170
+ }
171
+ if (parsed.protocol !== 'https:') {
172
+ errors.push(intakeError('private_url_blocked', path, 'URL must use public HTTPS'));
173
+ }
174
+ if (isPrivateOrLocalUrl(parsed)) {
175
+ errors.push(intakeError('private_url_blocked', path, 'private, localhost, or link-local URLs are blocked'));
176
+ }
177
+ if (parsed.username || parsed.password) {
178
+ errors.push(intakeError('credential_leakage_rejected', path, 'URL must not embed credentials'));
179
+ }
180
+ for (const key of parsed.searchParams.keys()) {
181
+ if (SECRET_KEY_PATTERN.test(key)) {
182
+ errors.push(intakeError('credential_leakage_rejected', `${path}.${key}`, 'URL must not include credential-shaped query keys'));
183
+ }
184
+ }
185
+ }
186
+ function findCredentialMaterial(value, path = '$') {
187
+ if (typeof value === 'string')
188
+ return SECRET_VALUE_PATTERN.test(value) ? path : undefined;
189
+ if (!value || typeof value !== 'object')
190
+ return undefined;
191
+ if (Array.isArray(value)) {
192
+ for (let index = 0; index < value.length; index += 1) {
193
+ const found = findCredentialMaterial(value[index], `${path}[${index}]`);
194
+ if (found)
195
+ return found;
196
+ }
197
+ return undefined;
198
+ }
199
+ for (const [key, child] of Object.entries(value)) {
200
+ const childPath = `${path}.${key}`;
201
+ if (SECRET_KEY_PATTERN.test(key))
202
+ return childPath;
203
+ const found = findCredentialMaterial(child, childPath);
204
+ if (found)
205
+ return found;
206
+ }
207
+ return undefined;
208
+ }
209
+ function validateDeclaredCapability(value, path, errors) {
210
+ if (!isPlainObject(value)) {
211
+ errors.push(intakeError('malformed_intake_descriptor', path, 'capability must be an object'));
212
+ return;
213
+ }
214
+ if (!isNonEmptyString(value.name)) {
215
+ errors.push(intakeError('malformed_intake_descriptor', `${path}.name`, 'capability name must be a non-empty string'));
216
+ }
217
+ for (const key of ['description', 'inputShape', 'outputShape']) {
218
+ if (!isOptionalString(value[key])) {
219
+ errors.push(intakeError('malformed_intake_descriptor', `${path}.${key}`, `capability ${key} must be a non-empty string when present`));
220
+ }
221
+ }
222
+ if (!isOptionalStringArray(value.examplePrompts)) {
223
+ errors.push(intakeError('malformed_intake_descriptor', `${path}.examplePrompts`, 'examplePrompts must be a string array when present'));
224
+ }
225
+ if (value.sideEffectHint !== undefined && !SIDE_EFFECT_RISKS.includes(value.sideEffectHint)) {
226
+ errors.push(intakeError('malformed_intake_descriptor', `${path}.sideEffectHint`, 'sideEffectHint is unsupported'));
227
+ }
228
+ }
229
+ /**
230
+ * Validate an intake descriptor. Fails closed on malformed shapes, private or
231
+ * credential-shaped URLs, credential-shaped metadata, self-asserted trust
232
+ * claims, and any requested forbidden operation.
233
+ */
234
+ export function validateOnboardingIntakeDescriptor(input) {
235
+ if (!isPlainObject(input)) {
236
+ return { ok: false, errors: [intakeError('malformed_intake_descriptor', '$', 'intake descriptor must be a plain object')] };
237
+ }
238
+ const credentialPath = findCredentialMaterial(input);
239
+ if (credentialPath) {
240
+ return {
241
+ ok: false,
242
+ errors: [intakeError('credential_leakage_rejected', credentialPath, 'intake descriptor must not contain credential-shaped material')],
243
+ };
244
+ }
245
+ const errors = [];
246
+ if (input.schemaVersion !== ONBOARDING_INTAKE_DESCRIPTOR_SCHEMA_VERSION) {
247
+ errors.push(intakeError('malformed_intake_descriptor', '$.schemaVersion', `expected ${ONBOARDING_INTAKE_DESCRIPTOR_SCHEMA_VERSION}`));
248
+ }
249
+ if (!isNonEmptyString(input.intakeId)) {
250
+ errors.push(intakeError('malformed_intake_descriptor', '$.intakeId', 'intakeId must be a non-empty string'));
251
+ }
252
+ if (!SOURCE_KINDS.includes(input.sourceKind)) {
253
+ errors.push(intakeError('malformed_intake_descriptor', '$.sourceKind', 'sourceKind is unsupported'));
254
+ }
255
+ if (input.ingestionMode !== 'static-fixture') {
256
+ errors.push(intakeError('malformed_intake_descriptor', '$.ingestionMode', 'contract intake only accepts static-fixture ingestion'));
257
+ }
258
+ if (input.staticOnly !== true) {
259
+ errors.push(intakeError('malformed_intake_descriptor', '$.staticOnly', 'intake descriptor must declare staticOnly=true'));
260
+ }
261
+ if (!isPlainObject(input.source)) {
262
+ errors.push(intakeError('malformed_intake_descriptor', '$.source', 'source must be an object'));
263
+ }
264
+ else {
265
+ if (input.source.sourceUrl !== undefined) {
266
+ validatePublicHttpsUrl(input.source.sourceUrl, '$.source.sourceUrl', errors);
267
+ }
268
+ if (!isNonEmptyString(input.source.snapshotRef)) {
269
+ errors.push(intakeError('malformed_intake_descriptor', '$.source.snapshotRef', 'snapshotRef must be a non-empty string'));
270
+ }
271
+ if (!isOptionalString(input.source.checkedCommit) || !isOptionalString(input.source.checkedRef) || !isOptionalString(input.source.license)) {
272
+ errors.push(intakeError('malformed_intake_descriptor', '$.source', 'checkedCommit/checkedRef/license must be non-empty strings when present'));
273
+ }
274
+ if (!isNonEmptyString(input.source.crawlTimestamp) || !RFC3339_UTC_PATTERN.test(input.source.crawlTimestamp)) {
275
+ errors.push(intakeError('malformed_intake_descriptor', '$.source.crawlTimestamp', 'crawlTimestamp must be an RFC3339 UTC timestamp'));
276
+ }
277
+ }
278
+ if (!isPlainObject(input.declaredMetadata)) {
279
+ errors.push(intakeError('malformed_intake_descriptor', '$.declaredMetadata', 'declaredMetadata must be an object'));
280
+ }
281
+ else {
282
+ const metadata = input.declaredMetadata;
283
+ if (!isOptionalString(metadata.displayName) || !isOptionalString(metadata.description) || !isOptionalString(metadata.termsUrl)) {
284
+ errors.push(intakeError('malformed_intake_descriptor', '$.declaredMetadata', 'displayName/description/termsUrl must be non-empty strings when present'));
285
+ }
286
+ if (!Array.isArray(metadata.capabilities)) {
287
+ errors.push(intakeError('malformed_intake_descriptor', '$.declaredMetadata.capabilities', 'capabilities must be an array'));
288
+ }
289
+ else {
290
+ metadata.capabilities.forEach((capability, index) => {
291
+ validateDeclaredCapability(capability, `$.declaredMetadata.capabilities[${index}]`, errors);
292
+ });
293
+ }
294
+ if (!isOptionalStringArray(metadata.endpointUrls)) {
295
+ errors.push(intakeError('malformed_intake_descriptor', '$.declaredMetadata.endpointUrls', 'endpointUrls must be a string array when present'));
296
+ }
297
+ else if (metadata.endpointUrls) {
298
+ metadata.endpointUrls.forEach((url, index) => {
299
+ validatePublicHttpsUrl(url, `$.declaredMetadata.endpointUrls[${index}]`, errors);
300
+ });
301
+ }
302
+ for (const key of ['authHints', 'pricingHints', 'rateLimitHints', 'trustClaims']) {
303
+ if (!isOptionalStringArray(metadata[key])) {
304
+ errors.push(intakeError('malformed_intake_descriptor', `$.declaredMetadata.${key}`, `${key} must be a string array when present`));
305
+ }
306
+ }
307
+ if (metadata.paymentMetadata !== undefined && !isPlainObject(metadata.paymentMetadata)) {
308
+ errors.push(intakeError('malformed_intake_descriptor', '$.declaredMetadata.paymentMetadata', 'paymentMetadata must be an object when present'));
309
+ }
310
+ const trustClaims = Array.isArray(metadata.trustClaims) ? metadata.trustClaims.filter((claim) => isNonEmptyString(claim)) : [];
311
+ if (trustClaims.length > 0) {
312
+ errors.push(intakeError('untrusted_imported_content_rejected', '$.declaredMetadata.trustClaims', 'imported content cannot self-assert trust, verification, approval, or live payment status'));
313
+ }
314
+ }
315
+ if (input.operatorProvided !== undefined) {
316
+ if (!isPlainObject(input.operatorProvided)) {
317
+ errors.push(intakeError('malformed_intake_descriptor', '$.operatorProvided', 'operatorProvided must be an object when present'));
318
+ }
319
+ else {
320
+ for (const key of ['displayName', 'description', 'contactRef']) {
321
+ if (!isOptionalString(input.operatorProvided[key])) {
322
+ errors.push(intakeError('malformed_intake_descriptor', `$.operatorProvided.${key}`, `${key} must be a non-empty string when present`));
323
+ }
324
+ }
325
+ }
326
+ }
327
+ if (input.requestedOperations !== undefined) {
328
+ if (!isOptionalStringArray(input.requestedOperations)) {
329
+ errors.push(intakeError('malformed_intake_descriptor', '$.requestedOperations', 'requestedOperations must be a string array when present'));
330
+ }
331
+ else {
332
+ input.requestedOperations.forEach((operation, index) => {
333
+ const reason = FORBIDDEN_OPERATION_REASONS[operation];
334
+ if (reason) {
335
+ errors.push(intakeError(reason, `$.requestedOperations[${index}]`, `requested operation "${operation}" is forbidden in the no-network contract path`));
336
+ }
337
+ else {
338
+ errors.push(intakeError('forbidden_operation_rejected', `$.requestedOperations[${index}]`, `requested operation "${operation}" is not recognised and is rejected fail-closed`));
339
+ }
340
+ });
341
+ }
342
+ }
343
+ return errors.length === 0
344
+ ? { ok: true, descriptor: input }
345
+ : { ok: false, errors };
346
+ }
347
+ // ---------------------------------------------------------------------------
348
+ // Stage builders (pure, deterministic)
349
+ // ---------------------------------------------------------------------------
350
+ function discoveredField(value) {
351
+ if (value === undefined || (Array.isArray(value) && value.length === 0)) {
352
+ return { provenance: 'blocked', evidenceRefs: [], blockedReason: 'missing_evidence' };
353
+ }
354
+ return { provenance: 'discovered', value, evidenceRefs: [] };
355
+ }
356
+ function userProvidedField(value) {
357
+ if (value === undefined) {
358
+ return { provenance: 'blocked', evidenceRefs: [], blockedReason: 'missing_evidence' };
359
+ }
360
+ return { provenance: 'user_provided', value, evidenceRefs: [] };
361
+ }
362
+ function inferSideEffectRisk(capability) {
363
+ const haystack = [capability.name, capability.description ?? ''].join(' ').toLowerCase();
364
+ if (/\b(exec|execute|shell|command|deploy|install|script)\b/.test(haystack))
365
+ return 'execute';
366
+ if (/\b(write|create|update|delete|mutate|post|put|patch)\b/.test(haystack))
367
+ return 'write';
368
+ if (/\b(read|get|list|search|fetch|query|lookup)\b/.test(haystack))
369
+ return 'read';
370
+ return 'none';
371
+ }
372
+ function rawSnapshotRefs(source) {
373
+ return [
374
+ `snapshot:${source.snapshotRef}`,
375
+ ...(source.sourceUrl ? [`source:${source.sourceUrl}${source.checkedCommit ? `#${source.checkedCommit}` : ''}`] : []),
376
+ ];
377
+ }
378
+ /** Normalize a validated intake descriptor into a capability inventory. */
379
+ export function buildOnboardingCapabilityInventory(descriptor) {
380
+ const diagnostics = [];
381
+ const sharedAuthHints = descriptor.declaredMetadata.authHints ?? [];
382
+ const sharedPricingHints = descriptor.declaredMetadata.pricingHints ?? [];
383
+ const endpointUrls = descriptor.declaredMetadata.endpointUrls ?? [];
384
+ const entries = descriptor.declaredMetadata.capabilities.map((capability, index) => {
385
+ const sideEffectRisk = capability.sideEffectHint !== undefined
386
+ ? { provenance: 'discovered', value: capability.sideEffectHint, evidenceRefs: [] }
387
+ : { provenance: 'inferred', value: inferSideEffectRisk(capability), evidenceRefs: [] };
388
+ const entry = {
389
+ capabilityId: `${descriptor.intakeId}:capability:${index}`,
390
+ name: discoveredField(capability.name),
391
+ description: capability.description !== undefined
392
+ ? discoveredField(capability.description)
393
+ : userProvidedField(descriptor.operatorProvided?.description),
394
+ inputShape: discoveredField(capability.inputShape),
395
+ outputShape: discoveredField(capability.outputShape),
396
+ sideEffectRisk,
397
+ endpointUrl: discoveredField(endpointUrls[0]),
398
+ authHints: discoveredField(sharedAuthHints.length > 0 ? sharedAuthHints : undefined),
399
+ pricingHints: discoveredField(sharedPricingHints.length > 0 ? sharedPricingHints : undefined),
400
+ contentTrustBoundary: 'untrusted_imported_content',
401
+ };
402
+ for (const [fieldName, field] of Object.entries({
403
+ inputShape: entry.inputShape,
404
+ outputShape: entry.outputShape,
405
+ endpointUrl: entry.endpointUrl,
406
+ authHints: entry.authHints,
407
+ })) {
408
+ if (field.provenance === 'blocked') {
409
+ diagnostics.push({
410
+ severity: 'warning',
411
+ code: 'missing_evidence',
412
+ path: `$.entries[${index}].${fieldName}`,
413
+ message: `${fieldName} is missing from imported metadata and stays blocked until supplied and reviewed`,
414
+ });
415
+ }
416
+ }
417
+ return entry;
418
+ });
419
+ if (entries.length === 0) {
420
+ diagnostics.push({
421
+ severity: 'blocked',
422
+ code: 'missing_evidence',
423
+ path: '$.entries',
424
+ message: 'no capabilities were declared; capability fit cannot be assessed',
425
+ });
426
+ }
427
+ return {
428
+ schemaVersion: ONBOARDING_CAPABILITY_INVENTORY_SCHEMA_VERSION,
429
+ intakeRef: descriptor.intakeId,
430
+ sourceKind: descriptor.sourceKind,
431
+ source: descriptor.source,
432
+ entries,
433
+ diagnostics,
434
+ rawSnapshotRefs: rawSnapshotRefs(descriptor.source),
435
+ staticOnly: true,
436
+ };
437
+ }
438
+ const REQUIRED_PAYMENT_FIELDS = ['settlementAddress', 'network', 'price', 'currency'];
439
+ function missingPaymentFields(metadata) {
440
+ if (!metadata)
441
+ return [...REQUIRED_PAYMENT_FIELDS];
442
+ return REQUIRED_PAYMENT_FIELDS.filter((field) => !isNonEmptyString(metadata[field]));
443
+ }
444
+ /** Generate the RAP profile draft handed to readiness analysis and review. */
445
+ export function buildOnboardingRapProfileDraft(descriptor, inventory) {
446
+ const endpointUrls = descriptor.declaredMetadata.endpointUrls ?? [];
447
+ const paymentMetadata = descriptor.declaredMetadata.paymentMetadata;
448
+ const missingFields = missingPaymentFields(paymentMetadata);
449
+ const operatorDisplayName = descriptor.operatorProvided?.displayName;
450
+ const displayName = operatorDisplayName !== undefined
451
+ ? userProvidedField(operatorDisplayName)
452
+ : discoveredField(descriptor.declaredMetadata.displayName);
453
+ return {
454
+ schemaVersion: ONBOARDING_RAP_PROFILE_DRAFT_SCHEMA_VERSION,
455
+ profileId: `draft-profile:${descriptor.intakeId}`,
456
+ intakeRef: descriptor.intakeId,
457
+ identity: {
458
+ displayName,
459
+ sourceKind: descriptor.sourceKind,
460
+ publisherContactRef: userProvidedField(descriptor.operatorProvided?.contactRef),
461
+ },
462
+ provenance: descriptor.source,
463
+ capabilities: inventory.entries,
464
+ invocation: {
465
+ endpointUrls,
466
+ missingEndpoint: endpointUrls.length === 0,
467
+ invocationAllowed: false,
468
+ },
469
+ authRequirements: descriptor.declaredMetadata.authHints ?? [],
470
+ payment: {
471
+ metadata: paymentMetadata,
472
+ status: missingFields.length === 0 ? 'declared_unverified' : 'missing_payment_metadata',
473
+ missingFields,
474
+ activation: 'disabled',
475
+ },
476
+ policyRequirements: [
477
+ 'operator_review_required',
478
+ 'payment_verification_required',
479
+ ...(endpointUrls.length === 0 ? ['endpoint_binding_required'] : []),
480
+ ],
481
+ evidenceExpectations: [
482
+ 'source_snapshot_reference',
483
+ 'operator_review_record',
484
+ 'readiness_gate_result',
485
+ ],
486
+ healthChecks: { status: 'not_probed', probesAllowed: false },
487
+ trust: {
488
+ sourceAuthenticity: isNonEmptyString(descriptor.source.checkedCommit) ? 'snapshot_recorded' : 'unrecorded',
489
+ importedContentTrust: 'untrusted',
490
+ verifiedProviderTrust: false,
491
+ },
492
+ reputation: { status: 'unproven', receiptRefs: [] },
493
+ rawSnapshotRefs: inventory.rawSnapshotRefs,
494
+ staticOnly: true,
495
+ };
496
+ }
497
+ function lane(key, status, reasonCodes, recommendations) {
498
+ return { lane: key, status, reasonCodes, recommendations };
499
+ }
500
+ /**
501
+ * Analyse readiness lanes for a generated profile draft. Missing or
502
+ * unverifiable data fails closed; ARD/search relevance and source authenticity
503
+ * are never treated as trust in imported content or agent behaviour.
504
+ */
505
+ export function analyzeOnboardingReadiness(profile) {
506
+ const lanes = [
507
+ profile.capabilities.length > 0
508
+ ? lane('capability_fit', 'ready', [], ['confirm capability descriptions against operator intent during review'])
509
+ : lane('capability_fit', 'blocked', ['missing_evidence'], ['supply at least one capability before drafting a listing']),
510
+ profile.provenance.sourceUrl || profile.identity.publisherContactRef.provenance === 'user_provided'
511
+ ? lane('source_identity', 'needs_operator_review', [], ['source identity is recorded but unverified'])
512
+ : lane('source_identity', 'blocked', ['missing_evidence'], ['record a public source URL or operator contact reference']),
513
+ profile.trust.sourceAuthenticity === 'snapshot_recorded'
514
+ ? lane('static_source_authenticity', 'ready', [], ['snapshot authenticity is recorded; it is NOT trust in imported content'])
515
+ : lane('static_source_authenticity', 'needs_operator_review', ['missing_evidence'], ['record a checked commit for the source snapshot']),
516
+ lane('imported_content_trust', 'needs_operator_review', [], ['imported prompts, connector metadata, and claims stay untrusted until operator review']),
517
+ lane('trust_evidence', 'needs_operator_review', ['missing_evidence'], ['no verified evidence yet; attach receipts or attestations to upgrade']),
518
+ profile.payment.status === 'declared_unverified'
519
+ ? lane('payment_readiness', 'needs_operator_review', [], ['payment metadata is declared but unverified; activation stays disabled'])
520
+ : lane('payment_readiness', 'blocked', ['missing_payment_metadata'], [`supply missing payment fields: ${profile.payment.missingFields.join(', ')}`]),
521
+ lane('policy_fit', 'needs_operator_review', [], profile.policyRequirements),
522
+ profile.invocation.missingEndpoint
523
+ ? lane('endpoint_safety', 'needs_operator_review', ['missing_evidence'], ['no invocation endpoint declared; endpoint binding and safety review required'])
524
+ : lane('endpoint_safety', 'needs_operator_review', [], ['declared endpoints are public HTTPS but uninvoked and unverified']),
525
+ profile.authRequirements.length > 0
526
+ ? lane('auth_scope_risk', 'needs_operator_review', [], ['review declared auth requirements for scope and custody risk'])
527
+ : lane('auth_scope_risk', 'needs_operator_review', ['missing_evidence'], ['auth requirements are undeclared; confirm before wrapping']),
528
+ lane('data_retention_risk', 'needs_operator_review', [], ['data retention behaviour is unknown from static metadata']),
529
+ lane('reputation_readiness', 'needs_operator_review', [], ['reputation starts unproven until backed by verifiable receipts or attestations']),
530
+ ];
531
+ const failClosedReasons = [...new Set(lanes.flatMap((item) => item.reasonCodes))];
532
+ const overall = lanes.some((item) => item.status === 'blocked')
533
+ ? 'blocked'
534
+ : 'needs_operator_review';
535
+ return {
536
+ schemaVersion: ONBOARDING_READINESS_RESULT_SCHEMA_VERSION,
537
+ profileRef: profile.profileId,
538
+ lanes,
539
+ overall,
540
+ failClosedReasons,
541
+ staticOnly: true,
542
+ };
543
+ }
544
+ /** Draft the seller wrapper / payment plan. Activation is always disabled. */
545
+ export function buildOnboardingSellerWrapperDraft(profile) {
546
+ const metadata = profile.payment.metadata;
547
+ return {
548
+ schemaVersion: ONBOARDING_SELLER_WRAPPER_DRAFT_SCHEMA_VERSION,
549
+ wrapperId: `seller-wrapper-draft:${profile.intakeRef}`,
550
+ profileRef: profile.profileId,
551
+ wrapperRoutes: {
552
+ quoteRoute: `/api/onboarding/wrappers/${profile.intakeRef}/quote`,
553
+ policyPreflightRoute: `/api/onboarding/wrappers/${profile.intakeRef}/policy-preflight`,
554
+ invocationRoute: `/api/onboarding/wrappers/${profile.intakeRef}/invoke`,
555
+ receiptHook: `/api/onboarding/wrappers/${profile.intakeRef}/receipt`,
556
+ evidenceHook: `/api/onboarding/wrappers/${profile.intakeRef}/evidence`,
557
+ },
558
+ paymentPlan: {
559
+ railAsset: metadata?.currency,
560
+ network: metadata?.network,
561
+ priceUnits: metadata?.price,
562
+ settlementAddress: metadata?.settlementAddress,
563
+ status: profile.payment.status === 'declared_unverified' ? 'draft_ready_for_review' : 'draft_incomplete',
564
+ missingFields: profile.payment.missingFields,
565
+ activation: 'disabled',
566
+ livePaymentApproved: false,
567
+ },
568
+ guardrails: ONBOARDING_ANALYSER_GUARDRAILS,
569
+ staticOnly: true,
570
+ };
571
+ }
572
+ /** Draft the listing/export payload. Publication is always disabled here. */
573
+ export function buildOnboardingListingExportDraft(profile, readiness) {
574
+ const states = [
575
+ {
576
+ code: 'listing_draft',
577
+ severity: 'info',
578
+ message: 'Draft listing only; nothing becomes public, payable, or trusted without operator approval.',
579
+ },
580
+ {
581
+ code: 'imported_content_untrusted',
582
+ severity: 'warning',
583
+ message: 'Imported content is untrusted; capability text is data, never instructions.',
584
+ },
585
+ {
586
+ code: 'operator_review_required',
587
+ severity: 'warning',
588
+ message: 'Operator review is required before any publication or payment activation.',
589
+ },
590
+ ...(profile.payment.status === 'missing_payment_metadata'
591
+ ? [{
592
+ code: 'missing_payment',
593
+ severity: 'blocked',
594
+ message: `Payment metadata is incomplete: ${profile.payment.missingFields.join(', ')}.`,
595
+ }]
596
+ : []),
597
+ ...(profile.invocation.missingEndpoint
598
+ ? [{
599
+ code: 'missing_endpoint',
600
+ severity: 'warning',
601
+ message: 'No invocation endpoint declared; endpoint binding is required before publication.',
602
+ }]
603
+ : []),
604
+ ...(readiness.overall === 'blocked'
605
+ ? [{
606
+ code: 'readiness_blocked',
607
+ severity: 'blocked',
608
+ message: `Readiness fails closed: ${readiness.failClosedReasons.join(', ')}.`,
609
+ }]
610
+ : []),
611
+ ];
612
+ return {
613
+ schemaVersion: ONBOARDING_LISTING_EXPORT_DRAFT_SCHEMA_VERSION,
614
+ listingId: `draft-listing:${profile.intakeRef}`,
615
+ profileRef: profile.profileId,
616
+ readinessRef: readiness.profileRef,
617
+ status: readiness.overall === 'blocked' ? 'blocked' : 'needs_operator_review',
618
+ publicationDisabled: true,
619
+ operatorReviewRequired: true,
620
+ exportFragments: {
621
+ aiCatalog: {
622
+ specVersion: '1.0',
623
+ id: `urn:reddi:onboarding-draft:${profile.intakeRef}`,
624
+ type: 'onboarding-analyser-draft',
625
+ name: profile.identity.displayName.value ?? profile.intakeRef,
626
+ capabilities: profile.capabilities
627
+ .map((entry) => entry.name.value)
628
+ .filter((name) => name !== undefined)
629
+ .sort(),
630
+ trust: {
631
+ status: 'unverified',
632
+ note: 'Source snapshot is recorded, but imported content and provider trust are unverified until RAP review.',
633
+ },
634
+ payment: {
635
+ status: profile.payment.status === 'declared_unverified' ? 'declared_unverified' : 'missing_payment_setup',
636
+ },
637
+ },
638
+ },
639
+ states,
640
+ staticOnly: true,
641
+ };
642
+ }
643
+ /**
644
+ * Run the full contract handoff: intake -> capability inventory -> RAP profile
645
+ * draft -> readiness result -> seller wrapper draft -> listing/export draft.
646
+ * Pure and deterministic; fails closed with intake errors on invalid input.
647
+ */
648
+ export function runOnboardingAnalyserHandoff(input) {
649
+ const validation = validateOnboardingIntakeDescriptor(input);
650
+ if (!validation.ok) {
651
+ return {
652
+ ok: false,
653
+ schemaVersion: ONBOARDING_ANALYSER_HANDOFF_SCHEMA_VERSION,
654
+ failClosed: true,
655
+ errors: validation.errors,
656
+ guardrails: ONBOARDING_ANALYSER_GUARDRAILS,
657
+ staticOnly: true,
658
+ };
659
+ }
660
+ const descriptor = validation.descriptor;
661
+ const capabilityInventory = buildOnboardingCapabilityInventory(descriptor);
662
+ const rapProfileDraft = buildOnboardingRapProfileDraft(descriptor, capabilityInventory);
663
+ const readiness = analyzeOnboardingReadiness(rapProfileDraft);
664
+ const sellerWrapperDraft = buildOnboardingSellerWrapperDraft(rapProfileDraft);
665
+ const listingExportDraft = buildOnboardingListingExportDraft(rapProfileDraft, readiness);
666
+ return {
667
+ ok: true,
668
+ schemaVersion: ONBOARDING_ANALYSER_HANDOFF_SCHEMA_VERSION,
669
+ intake: descriptor,
670
+ capabilityInventory,
671
+ rapProfileDraft,
672
+ readiness,
673
+ sellerWrapperDraft,
674
+ listingExportDraft,
675
+ guardrails: ONBOARDING_ANALYSER_GUARDRAILS,
676
+ staticOnly: true,
677
+ };
678
+ }
679
+ /**
680
+ * Partition every provenanced field in a capability inventory entry into the
681
+ * five provenance buckets required by #509.
682
+ */
683
+ export function partitionOnboardingEntryFieldsByProvenance(entry) {
684
+ const partition = {
685
+ discovered: [],
686
+ inferred: [],
687
+ user_provided: [],
688
+ verified: [],
689
+ blocked: [],
690
+ };
691
+ const fields = {
692
+ name: entry.name,
693
+ description: entry.description,
694
+ inputShape: entry.inputShape,
695
+ outputShape: entry.outputShape,
696
+ sideEffectRisk: entry.sideEffectRisk,
697
+ endpointUrl: entry.endpointUrl,
698
+ authHints: entry.authHints,
699
+ pricingHints: entry.pricingHints,
700
+ };
701
+ for (const [fieldName, field] of Object.entries(fields)) {
702
+ partition[field.provenance].push(fieldName);
703
+ }
704
+ return partition;
705
+ }
706
+ const FIXTURE_COMMIT = 'a3f8c2e91b7d4650a3f8c2e91b7d4650a3f8c2e9';
707
+ const FIXTURE_TIMESTAMP = '2026-07-06T00:00:00Z';
708
+ const FIXTURE_PAYMENT = {
709
+ settlementAddress: 'FixtureSettlementAddress1111111111111111111',
710
+ network: 'solana-devnet',
711
+ price: '2.50',
712
+ currency: 'AUDD',
713
+ };
714
+ function fixtureDescriptor(intakeId, sourceKind, overrides = {}) {
715
+ const { declaredMetadata: metadataOverrides, source: sourceOverride, ...rest } = overrides;
716
+ return {
717
+ schemaVersion: ONBOARDING_INTAKE_DESCRIPTOR_SCHEMA_VERSION,
718
+ intakeId,
719
+ sourceKind,
720
+ ingestionMode: 'static-fixture',
721
+ source: sourceOverride ?? {
722
+ sourceUrl: `https://fixtures.example.com/${sourceKind}/${intakeId}`,
723
+ snapshotRef: `fixtures/onboarding/${intakeId}.json`,
724
+ checkedCommit: FIXTURE_COMMIT,
725
+ checkedRef: 'main',
726
+ license: 'MIT',
727
+ crawlTimestamp: FIXTURE_TIMESTAMP,
728
+ },
729
+ declaredMetadata: {
730
+ displayName: `Fixture ${intakeId}`,
731
+ description: `Static ${sourceKind} fixture used by the #509 contract matrix.`,
732
+ capabilities: [
733
+ {
734
+ name: 'summarize-document',
735
+ description: 'Summarize a provided document into key points.',
736
+ inputShape: '{ "document": "string" }',
737
+ outputShape: '{ "summary": "string" }',
738
+ sideEffectHint: 'none',
739
+ },
740
+ ],
741
+ endpointUrls: [`https://fixtures.example.com/${sourceKind}/${intakeId}/invoke`],
742
+ authHints: ['api-key header (name only, no value)'],
743
+ pricingHints: ['per-call flat rate'],
744
+ paymentMetadata: FIXTURE_PAYMENT,
745
+ ...metadataOverrides,
746
+ },
747
+ staticOnly: true,
748
+ ...rest,
749
+ };
750
+ }
751
+ /**
752
+ * Golden no-network fixture matrix. Every fixture class required by #509 is
753
+ * represented, plus negative fail-closed cases for private URLs, credential
754
+ * leakage, command execution, paid calls, wallet/RPC, and imported trust
755
+ * claims. All descriptors are in-memory literals — nothing is fetched.
756
+ */
757
+ export function listOnboardingAnalyserFixtureMatrix() {
758
+ return [
759
+ {
760
+ key: 'mcp_metadata_full',
761
+ fixtureClass: 'mcp-metadata',
762
+ description: 'MCP server metadata snapshot with declared tools and payment metadata.',
763
+ descriptor: fixtureDescriptor('mcp-metadata-full', 'mcp-metadata', {
764
+ declaredMetadata: {
765
+ capabilities: [
766
+ {
767
+ name: 'list-issues',
768
+ description: 'Read and list issues from a public tracker.',
769
+ inputShape: '{ "repo": "string" }',
770
+ outputShape: '{ "issues": "array" }',
771
+ },
772
+ {
773
+ name: 'summarize-thread',
774
+ description: 'Summarize a discussion thread.',
775
+ inputShape: '{ "threadUrl": "string" }',
776
+ outputShape: '{ "summary": "string" }',
777
+ sideEffectHint: 'none',
778
+ },
779
+ ],
780
+ },
781
+ }),
782
+ expectedValid: true,
783
+ expectedErrorCodes: [],
784
+ expectedOverallReadiness: 'needs_operator_review',
785
+ expectedFailClosedReasons: ['missing_evidence'],
786
+ },
787
+ {
788
+ key: 'openapi_service',
789
+ fixtureClass: 'openapi',
790
+ description: 'OpenAPI description snapshot for a paid HTTP service.',
791
+ descriptor: fixtureDescriptor('openapi-service', 'openapi'),
792
+ expectedValid: true,
793
+ expectedErrorCodes: [],
794
+ expectedOverallReadiness: 'needs_operator_review',
795
+ },
796
+ {
797
+ key: 'a2a_card_missing_payment',
798
+ fixtureClass: 'a2a-card',
799
+ description: 'A2A agent card snapshot with no payment metadata; fails closed at payment readiness.',
800
+ descriptor: fixtureDescriptor('a2a-card-missing-payment', 'a2a-card', {
801
+ declaredMetadata: { paymentMetadata: undefined },
802
+ }),
803
+ expectedValid: true,
804
+ expectedErrorCodes: [],
805
+ expectedOverallReadiness: 'blocked',
806
+ expectedFailClosedReasons: ['missing_payment_metadata'],
807
+ },
808
+ {
809
+ key: 'ard_ai_catalog_entry',
810
+ fixtureClass: 'ard-ai-catalog',
811
+ description: 'ARD/AI Catalog entry snapshot; catalog relevance is never treated as trust.',
812
+ descriptor: fixtureDescriptor('ard-ai-catalog-entry', 'ard-ai-catalog'),
813
+ expectedValid: true,
814
+ expectedErrorCodes: [],
815
+ expectedOverallReadiness: 'needs_operator_review',
816
+ },
817
+ {
818
+ key: 'manual_descriptor_operator',
819
+ fixtureClass: 'manual-descriptor',
820
+ description: 'Operator-typed manual descriptor with user-provided identity fields and no source URL.',
821
+ descriptor: fixtureDescriptor('manual-descriptor-operator', 'manual-descriptor', {
822
+ source: {
823
+ snapshotRef: 'fixtures/onboarding/manual-descriptor-operator.json',
824
+ crawlTimestamp: FIXTURE_TIMESTAMP,
825
+ },
826
+ declaredMetadata: { displayName: undefined },
827
+ operatorProvided: {
828
+ displayName: 'Manually Described Agent',
829
+ description: 'Operator-supplied description of a private-in-progress agent.',
830
+ contactRef: 'operator:fixture-operator-1',
831
+ },
832
+ }),
833
+ expectedValid: true,
834
+ expectedErrorCodes: [],
835
+ expectedOverallReadiness: 'needs_operator_review',
836
+ },
837
+ {
838
+ key: 'static_agent_stack_snapshot',
839
+ fixtureClass: 'static-agent-stack-snapshot',
840
+ description: 'Static agent-stack fixture snapshot (#402/#414 lane) with no invocation endpoint.',
841
+ descriptor: fixtureDescriptor('static-agent-stack-snapshot', 'static-agent-stack-snapshot', {
842
+ declaredMetadata: {
843
+ endpointUrls: undefined,
844
+ capabilities: [
845
+ {
846
+ name: 'repo-skill:release-notes',
847
+ description: 'Draft release notes from repository metadata.',
848
+ inputShape: '{ "tag": "string" }',
849
+ outputShape: '{ "notes": "string" }',
850
+ sideEffectHint: 'read',
851
+ },
852
+ ],
853
+ },
854
+ }),
855
+ expectedValid: true,
856
+ expectedErrorCodes: [],
857
+ expectedOverallReadiness: 'needs_operator_review',
858
+ expectedFailClosedReasons: ['missing_evidence'],
859
+ },
860
+ {
861
+ key: 'malformed_input',
862
+ fixtureClass: 'malformed-input',
863
+ description: 'Structurally malformed descriptor: wrong schema version, missing source and capabilities.',
864
+ descriptor: {
865
+ schemaVersion: 'reddi.onboarding-intake-descriptor.v999',
866
+ intakeId: '',
867
+ sourceKind: 'unsupported-kind',
868
+ ingestionMode: 'live-probe',
869
+ declaredMetadata: { capabilities: 'not-an-array' },
870
+ staticOnly: false,
871
+ },
872
+ expectedValid: false,
873
+ expectedErrorCodes: ['malformed_intake_descriptor'],
874
+ },
875
+ {
876
+ key: 'credential_shaped_input',
877
+ fixtureClass: 'credential-shaped-input',
878
+ description: 'Descriptor whose imported metadata carries credential-shaped material; rejected before any parsing.',
879
+ descriptor: fixtureDescriptor('credential-shaped-input', 'mcp-metadata', {
880
+ declaredMetadata: {
881
+ authHints: ['Authorization: Bearer sk-fixture12345678'],
882
+ },
883
+ }),
884
+ expectedValid: false,
885
+ expectedErrorCodes: ['credential_leakage_rejected'],
886
+ },
887
+ {
888
+ key: 'partial_metadata',
889
+ fixtureClass: 'partial-metadata',
890
+ description: 'Partial metadata: capability with no shapes, no endpoint, no auth hints; blocked fields stay blocked.',
891
+ descriptor: fixtureDescriptor('partial-metadata', 'openapi', {
892
+ declaredMetadata: {
893
+ endpointUrls: undefined,
894
+ authHints: undefined,
895
+ pricingHints: undefined,
896
+ capabilities: [{ name: 'translate-text' }],
897
+ },
898
+ }),
899
+ expectedValid: true,
900
+ expectedErrorCodes: [],
901
+ expectedOverallReadiness: 'needs_operator_review',
902
+ expectedFailClosedReasons: ['missing_evidence'],
903
+ },
904
+ {
905
+ key: 'private_url_rejected',
906
+ fixtureClass: 'malformed-input',
907
+ description: 'Negative: private/localhost endpoint URLs are blocked fail-closed.',
908
+ descriptor: fixtureDescriptor('private-url-rejected', 'openapi', {
909
+ declaredMetadata: {
910
+ endpointUrls: ['http://192.168.1.20/api', 'https://localhost:8443/invoke'],
911
+ },
912
+ }),
913
+ expectedValid: false,
914
+ expectedErrorCodes: ['private_url_blocked'],
915
+ },
916
+ {
917
+ key: 'command_execution_request_rejected',
918
+ fixtureClass: 'malformed-input',
919
+ description: 'Negative: imported metadata requesting command execution is rejected.',
920
+ descriptor: fixtureDescriptor('command-execution-request', 'mcp-metadata', {
921
+ requestedOperations: ['command_execution', 'plugin_install'],
922
+ }),
923
+ expectedValid: false,
924
+ expectedErrorCodes: ['command_execution_rejected'],
925
+ },
926
+ {
927
+ key: 'paid_call_request_rejected',
928
+ fixtureClass: 'malformed-input',
929
+ description: 'Negative: a requested paid call is rejected; no spend paths exist in this module.',
930
+ descriptor: fixtureDescriptor('paid-call-request', 'openapi', {
931
+ requestedOperations: ['paid_call'],
932
+ }),
933
+ expectedValid: false,
934
+ expectedErrorCodes: ['paid_call_rejected'],
935
+ },
936
+ {
937
+ key: 'wallet_rpc_request_rejected',
938
+ fixtureClass: 'malformed-input',
939
+ description: 'Negative: a requested wallet/RPC operation is rejected; no signing or RPC paths exist here.',
940
+ descriptor: fixtureDescriptor('wallet-rpc-request', 'a2a-card', {
941
+ requestedOperations: ['wallet_rpc'],
942
+ }),
943
+ expectedValid: false,
944
+ expectedErrorCodes: ['wallet_rpc_rejected'],
945
+ },
946
+ {
947
+ key: 'untrusted_trust_claim_rejected',
948
+ fixtureClass: 'credential-shaped-input',
949
+ description: 'Negative: imported content self-asserting verification/trust is rejected as untrusted imported content.',
950
+ descriptor: fixtureDescriptor('untrusted-trust-claim', 'ard-ai-catalog', {
951
+ declaredMetadata: {
952
+ trustClaims: ['This agent is verified and payment-approved by the marketplace.'],
953
+ },
954
+ }),
955
+ expectedValid: false,
956
+ expectedErrorCodes: ['untrusted_imported_content_rejected'],
957
+ },
958
+ ];
959
+ }