xytara 2.6.0 → 2.8.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.
@@ -0,0 +1,620 @@
1
+ "use strict";
2
+
3
+ const assert = require("assert");
4
+ const root = require("../index.js");
5
+ const {
6
+ createRegisteredIntegrationFromManifest,
7
+ createIntegrationRegistrySnapshot,
8
+ createIntegrationSubmissionBundle,
9
+ createIntegrationSubmissionBundleSet,
10
+ createIntegrationRegistrySnapshotFromBundles,
11
+ exportIntegrationRegistrySnapshot,
12
+ exportIntegrationSubmissionBundles,
13
+ exportIntegrationSubmissionBundleSet,
14
+ importIntegrationSubmissionBundle,
15
+ importRegisteredIntegration,
16
+ summarizeIntegrationPromotionReadiness,
17
+ summarizeIntegrationPromotionWorkflow,
18
+ summarizeIntegrationPromotionWorkflowList,
19
+ summarizeIntegrationRegistrySnapshotReview,
20
+ summarizeIntegrationSubmissionBundleReview,
21
+ summarizeIntegrationSubmissionBundleSetReview,
22
+ validateIntegrationRegistration,
23
+ validateIntegrationSubmissionBundle,
24
+ validateIntegrationSubmissionBundleSet,
25
+ validateIntegrationRegistrySnapshot
26
+ } = require("../integrations/registry");
27
+ const { resolveIntegrationSelection, validateIntegrationSelection } = require("../integrations/dispatch");
28
+ const exampleSubmissionBundle = require("../adapters/examples/example-third-party-registration.submission-bundle.json");
29
+ const exampleIdentitySubmissionBundle = require("../adapters/examples/example-third-party-identity-registration.submission-bundle.json");
30
+ const exampleSettlementSubmissionBundle = require("../adapters/examples/example-third-party-settlement-registration.submission-bundle.json");
31
+
32
+ async function main() {
33
+ const integrations = root.listIntegrations();
34
+ assert.ok(Array.isArray(integrations), "integrations list missing");
35
+ assert.ok(integrations.length >= 5, "built-in integration breadth missing");
36
+ assert.ok(integrations.some((integration) => integration.integration_id === "builtin.protocol.mcp"), "mcp integration missing");
37
+ assert.ok(integrations.some((integration) => integration.integration_id === "builtin.payment.x402"), "x402 integration missing");
38
+ assert.ok(integrations.some((integration) => integration.integration_id === "builtin.settlement.chain"), "chain settlement integration missing");
39
+ assert.ok(integrations.some((integration) => integration.integration_id === "partner.protocol.acme_mcp"), "third-party example integration missing");
40
+ assert.ok(integrations.some((integration) => integration.integration_id === "partner.identity.attest_registry"), "third-party identity integration missing");
41
+ assert.ok(integrations.some((integration) => integration.integration_id === "partner.settlement.lattice_anchor"), "third-party settlement integration missing");
42
+
43
+ const detail = root.getIntegration("builtin.protocol.mcp");
44
+ assert.ok(detail, "integration detail missing");
45
+ assert.strictEqual(detail.adapter_class, "agent_protocol_adapter", "integration class mismatch");
46
+ assert.strictEqual(detail.certification_state, "certified", "integration certification state mismatch");
47
+ assert.strictEqual(detail.integration_maturity, "production_default", "integration maturity mismatch");
48
+ assert.strictEqual(detail.operational_readiness.supports_default_selection, true, "integration default selection posture mismatch");
49
+ assert.strictEqual(detail.registration.registration_state, "unregistered", "builtin registration state mismatch");
50
+
51
+ const summary = root.summarizeIntegrations();
52
+ assert.strictEqual(summary.ok, true, "integration summary ok mismatch");
53
+ assert.ok(summary.integration_count >= integrations.length, "integration summary count mismatch");
54
+ assert.ok(summary.certified_integration_count >= 5, "integration summary certified count mismatch");
55
+ assert.ok(summary.production_default_count >= 5, "integration summary production-default count mismatch");
56
+ assert.ok(summary.integrations.some((entry) => entry.registration_state === "staging_registered"), "integration summary registration state missing");
57
+
58
+ const certifiedBuiltins = root.listIntegrations({
59
+ source: "builtin",
60
+ certification_state: "certified",
61
+ integration_maturity: "production_default",
62
+ bundled: "true"
63
+ });
64
+ assert.ok(certifiedBuiltins.length >= 5, "certified builtin integration filtering mismatch");
65
+
66
+ const thirdPartyIntegrations = root.listIntegrations({
67
+ source: "third_party_example",
68
+ bundled: "false"
69
+ });
70
+ assert.ok(thirdPartyIntegrations.length >= 3, "third-party integration filtering mismatch");
71
+ assert.ok(thirdPartyIntegrations.every((entry) => entry.registration.registration_state === "staging_registered"), "third-party registration state mismatch");
72
+ assert.ok(thirdPartyIntegrations.every((entry) => entry.registration.requires_explicit_selection === true), "third-party explicit-selection posture mismatch");
73
+ assert.ok(thirdPartyIntegrations.some((entry) => entry.adapter_class === "agent_protocol_adapter"), "third-party protocol integration class missing");
74
+ assert.ok(thirdPartyIntegrations.some((entry) => entry.adapter_class === "identity_registry_adapter"), "third-party identity integration class missing");
75
+ assert.ok(thirdPartyIntegrations.some((entry) => entry.adapter_class === "settlement_adapter"), "third-party settlement integration class missing");
76
+
77
+ const importedIntegration = createRegisteredIntegrationFromManifest({
78
+ adapter_id: "partner.execution.echo_plus",
79
+ adapter_class: "execution_adapter",
80
+ adapter_version: "0.2.0",
81
+ interface_version: "commerce-adapter-interface/v1",
82
+ display_name: "Echo Plus Partner Execution",
83
+ description: "Imported partner execution adapter used to validate registry ingestion.",
84
+ capabilities: ["task.execute"],
85
+ compatibility: {
86
+ node: ">=18",
87
+ commerce_contract: "xytara/v1",
88
+ proof_contract: "xoonya/v1"
89
+ },
90
+ health_contract: {
91
+ check_kind: "self_reported",
92
+ supports_readiness: true
93
+ },
94
+ idempotency_contract: {
95
+ strategy: "caller_supplied_key",
96
+ scope: "task_execution"
97
+ },
98
+ failure_contract: {
99
+ categories: ["invalid_input", "timeout"],
100
+ retryable_categories: ["timeout"]
101
+ },
102
+ proof_contract: {
103
+ emits_proof_compatible_facts: true,
104
+ proof_mode: "execution_facts_only"
105
+ },
106
+ supported_settlement_modes: ["none"]
107
+ }, {
108
+ integration_id: "partner.execution.echo_plus",
109
+ adapter_id: "partner.execution.echo_plus",
110
+ adapter_class: "execution_adapter",
111
+ registration_state: "staging_registered",
112
+ integration_maturity: "staging_candidate",
113
+ certification_state: "self_attested",
114
+ bundled: false,
115
+ default_selection_enabled: false,
116
+ selection_priority: 620,
117
+ requires_explicit_selection: true,
118
+ registered_at: "2026-03-20T00:00:00.000Z"
119
+ }, {
120
+ source: "third_party_example",
121
+ task_refs: ["trust.verify"],
122
+ protocols: [],
123
+ execution_backends: ["http"],
124
+ adapter_lanes: ["http"]
125
+ });
126
+ assert.strictEqual(importedIntegration.integration_id, "partner.execution.echo_plus", "imported integration id mismatch");
127
+ assert.strictEqual(importedIntegration.registration.registration_state, "staging_registered", "imported integration registration state mismatch");
128
+ assert.strictEqual(importedIntegration.registration.default_selection_enabled, false, "imported integration default selection mismatch");
129
+ assert.strictEqual(importedIntegration.registration.selection_priority, 620, "imported integration selection priority mismatch");
130
+
131
+ const importedSettlementIntegration = createRegisteredIntegrationFromManifest({
132
+ adapter_id: "partner.settlement.echo_anchor",
133
+ adapter_class: "settlement_adapter",
134
+ adapter_version: "0.2.0",
135
+ interface_version: "commerce-adapter-interface/v1",
136
+ display_name: "Echo Anchor Partner Settlement",
137
+ description: "Imported partner settlement adapter used to validate registry ingestion.",
138
+ capabilities: ["anchoring.submit", "settlement.reference"],
139
+ compatibility: {
140
+ node: ">=18",
141
+ commerce_contract: "xytara/v1",
142
+ proof_contract: "xoonya/v1"
143
+ },
144
+ health_contract: {
145
+ check_kind: "self_reported",
146
+ supports_readiness: true
147
+ },
148
+ idempotency_contract: {
149
+ strategy: "quote_and_target_binding",
150
+ scope: "settlement_request"
151
+ },
152
+ failure_contract: {
153
+ categories: ["invalid_input", "timeout", "settlement_failure"],
154
+ retryable_categories: ["timeout"]
155
+ },
156
+ proof_contract: {
157
+ emits_proof_compatible_facts: true,
158
+ proof_mode: "settlement_reference_only"
159
+ },
160
+ supported_settlement_modes: ["anchor_commit"]
161
+ }, {
162
+ integration_id: "partner.settlement.echo_anchor",
163
+ adapter_id: "partner.settlement.echo_anchor",
164
+ adapter_class: "settlement_adapter",
165
+ registration_state: "staging_registered",
166
+ integration_maturity: "staging_candidate",
167
+ certification_state: "self_attested",
168
+ bundled: false,
169
+ default_selection_enabled: false,
170
+ selection_priority: 645,
171
+ requires_explicit_selection: true,
172
+ registered_at: "2026-03-20T00:00:00.000Z"
173
+ }, {
174
+ source: "third_party_example",
175
+ task_refs: ["anchoring.submit"],
176
+ protocols: [],
177
+ execution_backends: ["chain"],
178
+ adapter_lanes: ["chain"]
179
+ });
180
+ assert.strictEqual(importedSettlementIntegration.integration_id, "partner.settlement.echo_anchor", "imported settlement integration id mismatch");
181
+ assert.strictEqual(importedSettlementIntegration.registration.registration_state, "staging_registered", "imported settlement registration state mismatch");
182
+ assert.strictEqual(importedSettlementIntegration.registration.selection_priority, 645, "imported settlement selection priority mismatch");
183
+
184
+ const importedIdentityIntegration = createRegisteredIntegrationFromManifest({
185
+ adapter_id: "partner.identity.echo_registry",
186
+ adapter_class: "identity_registry_adapter",
187
+ adapter_version: "0.2.0",
188
+ interface_version: "commerce-adapter-interface/v1",
189
+ display_name: "Echo Partner Identity Registry",
190
+ description: "Imported partner identity adapter used to validate registry ingestion.",
191
+ capabilities: ["registry.register", "trust.handoff.emit"],
192
+ compatibility: {
193
+ node: ">=18",
194
+ commerce_contract: "xytara/v1",
195
+ proof_contract: "xoonya/v1"
196
+ },
197
+ health_contract: {
198
+ check_kind: "self_reported",
199
+ supports_readiness: true
200
+ },
201
+ idempotency_contract: {
202
+ strategy: "record_ref_binding",
203
+ scope: "registry_request"
204
+ },
205
+ failure_contract: {
206
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
207
+ retryable_categories: ["timeout"]
208
+ },
209
+ proof_contract: {
210
+ emits_proof_compatible_facts: true,
211
+ proof_mode: "registry_reference_facts"
212
+ },
213
+ supported_settlement_modes: []
214
+ }, {
215
+ integration_id: "partner.identity.echo_registry",
216
+ adapter_id: "partner.identity.echo_registry",
217
+ adapter_class: "identity_registry_adapter",
218
+ registration_state: "staging_registered",
219
+ integration_maturity: "staging_candidate",
220
+ certification_state: "self_attested",
221
+ bundled: false,
222
+ default_selection_enabled: false,
223
+ selection_priority: 635,
224
+ requires_explicit_selection: true,
225
+ registered_at: "2026-03-20T00:00:00.000Z"
226
+ }, {
227
+ source: "third_party_example",
228
+ task_refs: ["registry.register", "trust.handoff.emit"],
229
+ protocols: [],
230
+ execution_backends: ["http", "chain"],
231
+ adapter_lanes: ["http", "chain"]
232
+ });
233
+ assert.strictEqual(importedIdentityIntegration.integration_id, "partner.identity.echo_registry", "imported identity integration id mismatch");
234
+ assert.strictEqual(importedIdentityIntegration.registration.registration_state, "staging_registered", "imported identity registration state mismatch");
235
+ assert.strictEqual(importedIdentityIntegration.registration.selection_priority, 635, "imported identity selection priority mismatch");
236
+
237
+ const validRegistration = validateIntegrationRegistration({
238
+ adapter_id: "partner.execution.validated",
239
+ adapter_class: "execution_adapter"
240
+ }, {
241
+ integration_id: "partner.execution.validated",
242
+ adapter_id: "partner.execution.validated",
243
+ adapter_class: "execution_adapter"
244
+ });
245
+ assert.strictEqual(validRegistration.ok, true, "valid integration registration should pass");
246
+
247
+ const invalidRegistration = validateIntegrationRegistration({
248
+ adapter_id: "partner.execution.alpha",
249
+ adapter_class: "execution_adapter"
250
+ }, {
251
+ integration_id: "partner.execution.beta",
252
+ adapter_id: "partner.execution.beta",
253
+ adapter_class: "settlement_adapter"
254
+ });
255
+ assert.strictEqual(invalidRegistration.ok, false, "invalid integration registration should fail");
256
+ assert.ok(invalidRegistration.errors.some((entry) => entry.includes("manifest.adapter_id")), "invalid registration adapter id mismatch missing");
257
+
258
+ const importedViaToolkit = importRegisteredIntegration({
259
+ adapter_id: "partner.protocol.bridge",
260
+ adapter_class: "agent_protocol_adapter",
261
+ adapter_version: "0.3.0",
262
+ interface_version: "commerce-adapter-interface/v1",
263
+ display_name: "Bridge Partner Protocol",
264
+ description: "Imported partner protocol adapter used to validate registry toolkit import.",
265
+ capabilities: ["adapter.mcp.invoke"],
266
+ compatibility: {
267
+ node: ">=18",
268
+ commerce_contract: "xytara/v1",
269
+ proof_contract: "xoonya/v1"
270
+ },
271
+ health_contract: {
272
+ check_kind: "self_reported",
273
+ supports_readiness: true
274
+ },
275
+ idempotency_contract: {
276
+ strategy: "quote_bound_invocation",
277
+ scope: "protocol_invocation"
278
+ },
279
+ failure_contract: {
280
+ categories: ["invalid_input", "timeout"],
281
+ retryable_categories: ["timeout"]
282
+ },
283
+ proof_contract: {
284
+ emits_proof_compatible_facts: true,
285
+ proof_mode: "protocol_invocation_facts"
286
+ },
287
+ supported_settlement_modes: ["evm_payment"]
288
+ }, {
289
+ integration_id: "partner.protocol.bridge",
290
+ adapter_id: "partner.protocol.bridge",
291
+ adapter_class: "agent_protocol_adapter",
292
+ registration_state: "staging_registered",
293
+ integration_maturity: "staging_candidate",
294
+ certification_state: "self_attested",
295
+ bundled: false,
296
+ default_selection_enabled: false,
297
+ selection_priority: 630,
298
+ requires_explicit_selection: true,
299
+ registered_at: "2026-03-20T00:00:00.000Z"
300
+ }, {
301
+ source: "third_party_example",
302
+ task_refs: ["adapter.mcp.invoke"],
303
+ protocols: ["mcp"],
304
+ execution_backends: ["mcp"],
305
+ adapter_lanes: ["mcp"]
306
+ });
307
+ assert.strictEqual(importedViaToolkit.integration_id, "partner.protocol.bridge", "toolkit import integration id mismatch");
308
+ assert.strictEqual(importedViaToolkit.registration.registration_state, "staging_registered", "toolkit import registration state mismatch");
309
+
310
+ const snapshot = createIntegrationRegistrySnapshot(thirdPartyIntegrations, {
311
+ source: "third_party_example",
312
+ bundled: "false"
313
+ });
314
+ assert.strictEqual(snapshot.integration_count, thirdPartyIntegrations.length, "registry snapshot count mismatch");
315
+ const snapshotValidation = validateIntegrationRegistrySnapshot(snapshot);
316
+ assert.strictEqual(snapshotValidation.ok, true, "registry snapshot validation should pass");
317
+
318
+ const exportedSnapshot = exportIntegrationRegistrySnapshot({
319
+ source: "third_party_example",
320
+ bundled: "false"
321
+ });
322
+ assert.strictEqual(exportedSnapshot.integration_count >= 2, true, "exported registry snapshot breadth mismatch");
323
+ assert.strictEqual(exportedSnapshot.filters.source, "third_party_example", "exported registry snapshot filters missing");
324
+
325
+ const submissionBundleValidation = validateIntegrationSubmissionBundle(exampleSubmissionBundle);
326
+ assert.strictEqual(submissionBundleValidation.ok, true, "submission bundle validation mismatch");
327
+ const settlementSubmissionBundleValidation = validateIntegrationSubmissionBundle(exampleSettlementSubmissionBundle);
328
+ assert.strictEqual(settlementSubmissionBundleValidation.ok, true, "settlement submission bundle validation mismatch");
329
+ const identitySubmissionBundleValidation = validateIntegrationSubmissionBundle(exampleIdentitySubmissionBundle);
330
+ assert.strictEqual(identitySubmissionBundleValidation.ok, true, "identity submission bundle validation mismatch");
331
+
332
+ const createdSubmissionBundle = createIntegrationSubmissionBundle(exampleSubmissionBundle, {
333
+ source: "third_party_example",
334
+ protocols: ["mcp"],
335
+ execution_backends: ["mcp"],
336
+ adapter_lanes: ["mcp"],
337
+ task_refs: ["adapter.mcp.invoke"]
338
+ });
339
+ assert.strictEqual(createdSubmissionBundle.bundle_version, "xytara/integration-submission-bundle/v1", "submission bundle version mismatch");
340
+ assert.strictEqual(createdSubmissionBundle.snapshot_entry.integration_id, "partner.protocol.acme_mcp", "submission bundle snapshot entry mismatch");
341
+
342
+ const bundleReview = summarizeIntegrationSubmissionBundleReview(exampleSubmissionBundle);
343
+ assert.strictEqual(bundleReview.ok, true, "bundle review summary mismatch");
344
+ assert.strictEqual(bundleReview.integration.integration_id, "partner.protocol.acme_mcp", "bundle review integration id mismatch");
345
+ assert.strictEqual(bundleReview.registration.requires_explicit_selection, true, "bundle review explicit selection mismatch");
346
+ assert.strictEqual(bundleReview.review_summary.default_eligible, false, "bundle review default eligibility mismatch");
347
+
348
+ const identityBundleReview = summarizeIntegrationSubmissionBundleReview(exampleIdentitySubmissionBundle);
349
+ assert.strictEqual(identityBundleReview.ok, true, "identity bundle review summary mismatch");
350
+ assert.strictEqual(identityBundleReview.integration.integration_id, "partner.identity.attest_registry", "identity bundle review integration id mismatch");
351
+ assert.strictEqual(identityBundleReview.review_summary.default_eligible, false, "identity bundle review default eligibility mismatch");
352
+
353
+ const importedSubmissionBundle = importIntegrationSubmissionBundle(exampleSettlementSubmissionBundle, {
354
+ source: "third_party_example",
355
+ protocols: [],
356
+ execution_backends: ["chain"],
357
+ adapter_lanes: ["chain"],
358
+ task_refs: ["anchoring.submit"]
359
+ });
360
+ assert.strictEqual(importedSubmissionBundle.registration_record.integration_id, "partner.settlement.lattice_anchor", "imported submission bundle integration mismatch");
361
+
362
+ const importedIdentitySubmissionBundle = importIntegrationSubmissionBundle(exampleIdentitySubmissionBundle, {
363
+ source: "third_party_example",
364
+ protocols: [],
365
+ execution_backends: ["http", "chain"],
366
+ adapter_lanes: ["http", "chain"],
367
+ task_refs: ["registry.register", "trust.handoff.emit", "trust.handoff.validate"]
368
+ });
369
+ assert.strictEqual(importedIdentitySubmissionBundle.registration_record.integration_id, "partner.identity.attest_registry", "imported identity submission bundle integration mismatch");
370
+
371
+ const exportedSubmissionBundles = exportIntegrationSubmissionBundles({
372
+ source: "third_party_example",
373
+ bundled: "false"
374
+ });
375
+ assert.strictEqual(exportedSubmissionBundles.length >= 3, true, "exported submission bundle breadth mismatch");
376
+ assert.ok(exportedSubmissionBundles.every((bundle) => bundle.bundle_version === "xytara/integration-submission-bundle/v1"), "exported submission bundle version mismatch");
377
+
378
+ const bundleSnapshot = createIntegrationRegistrySnapshotFromBundles(exportedSubmissionBundles, {
379
+ source: "third_party_example"
380
+ }, {
381
+ source: "third_party_example"
382
+ });
383
+ assert.strictEqual(bundleSnapshot.integration_count >= 3, true, "bundle snapshot breadth mismatch");
384
+ assert.strictEqual(bundleSnapshot.filters.snapshot_source, "submission_bundle", "bundle snapshot source marker missing");
385
+
386
+ const bundleSet = createIntegrationSubmissionBundleSet(exportedSubmissionBundles, {
387
+ source: "third_party_example"
388
+ }, "staging candidate bundle set");
389
+ assert.strictEqual(bundleSet.bundle_count, exportedSubmissionBundles.length, "bundle set count mismatch");
390
+ assert.strictEqual(validateIntegrationSubmissionBundleSet(bundleSet).ok, true, "bundle set validation mismatch");
391
+
392
+ const bundleSetReview = summarizeIntegrationSubmissionBundleSetReview(bundleSet);
393
+ assert.strictEqual(bundleSetReview.ok, true, "bundle-set review summary mismatch");
394
+ assert.strictEqual(bundleSetReview.bundle_count, exportedSubmissionBundles.length, "bundle-set review count mismatch");
395
+ assert.ok(bundleSetReview.review_summary.registration_states.some((entry) => entry.registration_state === "staging_registered"), "bundle-set review registration summary missing");
396
+
397
+ const exportedBundleSet = exportIntegrationSubmissionBundleSet({
398
+ source: "third_party_example",
399
+ bundled: "false"
400
+ }, "exported bundle set");
401
+ assert.strictEqual(exportedBundleSet.bundle_count >= 3, true, "exported bundle set breadth mismatch");
402
+ assert.strictEqual(exportedBundleSet.filters.source, "third_party_example", "exported bundle set filters missing");
403
+
404
+ const snapshotReview = summarizeIntegrationRegistrySnapshotReview(bundleSnapshot);
405
+ assert.strictEqual(snapshotReview.ok, true, "snapshot review summary mismatch");
406
+ assert.strictEqual(snapshotReview.integration_count, bundleSnapshot.integration_count, "snapshot review count mismatch");
407
+ assert.ok(snapshotReview.review_summary.registration_states.some((entry) => entry.registration_state === "staging_registered"), "snapshot review registration summary missing");
408
+
409
+ const protocolSummary = root.summarizeIntegrationProtocols();
410
+ assert.ok(protocolSummary.protocols.some((entry) => entry.protocol === "mcp"), "protocol summary missing mcp");
411
+ assert.ok(protocolSummary.protocols.some((entry) => entry.protocol === "x402"), "protocol summary missing x402");
412
+
413
+ const settlementSummary = root.summarizeIntegrationSettlementModes();
414
+ assert.ok(settlementSummary.settlement_modes.some((entry) => entry.settlement_mode === "evm_payment"), "settlement mode summary missing evm");
415
+ assert.ok(settlementSummary.settlement_modes.some((entry) => entry.settlement_mode === "bsv_teranode"), "settlement mode summary missing bsv");
416
+
417
+ const classSummary = root.summarizeIntegrationClasses();
418
+ assert.ok(classSummary.adapter_classes.some((entry) => entry.adapter_class === "execution_adapter"), "class summary missing execution");
419
+ assert.ok(classSummary.adapter_classes.some((entry) => entry.adapter_class === "settlement_adapter"), "class summary missing settlement");
420
+
421
+ const builtinPromotion = summarizeIntegrationPromotionReadiness("builtin.protocol.mcp");
422
+ assert.strictEqual(builtinPromotion.ok, true, "builtin promotion readiness mismatch");
423
+ assert.strictEqual(builtinPromotion.promotion_readiness.default_eligible, true, "builtin default eligibility mismatch");
424
+ assert.strictEqual(builtinPromotion.promotion_readiness.production_default_ready, true, "builtin production-default readiness mismatch");
425
+
426
+ const stagedPromotion = summarizeIntegrationPromotionReadiness("partner.protocol.acme_mcp");
427
+ assert.strictEqual(stagedPromotion.ok, true, "staged promotion readiness mismatch");
428
+ assert.strictEqual(stagedPromotion.promotion_readiness.review_ready, true, "staged review-ready mismatch");
429
+ assert.strictEqual(stagedPromotion.promotion_readiness.default_eligible, false, "staged default eligibility mismatch");
430
+ assert.strictEqual(stagedPromotion.promotion_readiness.production_default_ready, false, "staged production-default readiness mismatch");
431
+ assert.ok(stagedPromotion.promotion_readiness.blockers.includes("not_certified"), "staged promotion blockers missing certification");
432
+ assert.ok(stagedPromotion.promotion_readiness.blockers.includes("default_selection_disabled"), "staged promotion blockers missing default-selection");
433
+
434
+ const stagedIdentityPromotion = summarizeIntegrationPromotionReadiness("partner.identity.attest_registry");
435
+ assert.strictEqual(stagedIdentityPromotion.ok, true, "staged identity promotion readiness mismatch");
436
+ assert.strictEqual(stagedIdentityPromotion.promotion_readiness.review_ready, true, "staged identity review-ready mismatch");
437
+ assert.strictEqual(stagedIdentityPromotion.promotion_readiness.default_eligible, false, "staged identity default eligibility mismatch");
438
+ assert.ok(stagedIdentityPromotion.promotion_readiness.blockers.includes("not_certified"), "staged identity promotion blockers missing certification");
439
+
440
+ const stagedPromotionWorkflow = summarizeIntegrationPromotionWorkflow("partner.protocol.acme_mcp");
441
+ assert.strictEqual(stagedPromotionWorkflow.ok, true, "staged promotion workflow mismatch");
442
+ assert.strictEqual(stagedPromotionWorkflow.next_transition.action, "complete_certification", "staged promotion workflow next-transition mismatch");
443
+ assert.strictEqual(
444
+ stagedPromotionWorkflow.next_transition.later_actions.includes("promote_maturity"),
445
+ true,
446
+ "staged promotion workflow later-actions maturity mismatch"
447
+ );
448
+ assert.strictEqual(stagedPromotionWorkflow.promotion_recommendation.recommendation, "keep_staged_until_requirements_clear", "staged promotion workflow recommendation mismatch");
449
+ assert.strictEqual(
450
+ stagedPromotionWorkflow.certification_gaps.missing_requirements.includes("certification_state"),
451
+ true,
452
+ "staged promotion workflow certification gap mismatch"
453
+ );
454
+ assert.ok(
455
+ stagedPromotionWorkflow.blocker_categories.some((entry) => entry.category === "certification"),
456
+ "staged promotion workflow blocker categories missing certification"
457
+ );
458
+
459
+ const builtinPromotionWorkflow = summarizeIntegrationPromotionWorkflow("builtin.protocol.mcp");
460
+ assert.strictEqual(builtinPromotionWorkflow.ok, true, "builtin promotion workflow mismatch");
461
+ assert.strictEqual(builtinPromotionWorkflow.next_transition.action, "maintain_production_default", "builtin promotion workflow next-transition mismatch");
462
+ assert.strictEqual(builtinPromotionWorkflow.next_transition.later_actions.length, 0, "builtin promotion workflow later-actions mismatch");
463
+ assert.strictEqual(builtinPromotionWorkflow.promotion_recommendation.recommendation, "eligible_for_production_default", "builtin promotion workflow recommendation mismatch");
464
+ assert.strictEqual(builtinPromotionWorkflow.certification_gaps.certifiable, true, "builtin promotion workflow certification gaps mismatch");
465
+
466
+ const promotionWorkflowList = summarizeIntegrationPromotionWorkflowList({
467
+ source: "third_party_example",
468
+ bundled: "false"
469
+ });
470
+ assert.strictEqual(promotionWorkflowList.ok, true, "promotion workflow list mismatch");
471
+ assert.strictEqual(promotionWorkflowList.integration_count >= 3, true, "promotion workflow list breadth mismatch");
472
+ assert.strictEqual(
473
+ promotionWorkflowList.next_actions.some((entry) => entry.action === "complete_certification"),
474
+ true,
475
+ "promotion workflow list next-action summary mismatch"
476
+ );
477
+ assert.strictEqual(
478
+ promotionWorkflowList.recommendations.some((entry) => entry.recommendation === "keep_staged_until_requirements_clear"),
479
+ true,
480
+ "promotion workflow list recommendation summary mismatch"
481
+ );
482
+ assert.strictEqual(
483
+ promotionWorkflowList.blocker_categories.some((entry) => entry.category === "certification"),
484
+ true,
485
+ "promotion workflow list blocker-category summary mismatch"
486
+ );
487
+ assert.strictEqual(
488
+ promotionWorkflowList.blocker_categories.some(
489
+ (entry) => entry.category === "certification" && entry.severity === "high" && entry.owner === "review_operator"
490
+ ),
491
+ true,
492
+ "promotion workflow list blocker-category severity/owner mismatch"
493
+ );
494
+ assert.strictEqual(
495
+ promotionWorkflowList.owner_queue.some((entry) => entry.owner === "review_operator"),
496
+ true,
497
+ "promotion workflow list owner queue mismatch"
498
+ );
499
+ assert.strictEqual(
500
+ promotionWorkflowList.severity_queue.some((entry) => entry.severity === "high"),
501
+ true,
502
+ "promotion workflow list severity queue mismatch"
503
+ );
504
+ assert.strictEqual(
505
+ promotionWorkflowList.next_action_queues.some((entry) => entry.action === "complete_certification" && entry.count >= 3),
506
+ true,
507
+ "promotion workflow list next-action queue mismatch"
508
+ );
509
+ assert.strictEqual(
510
+ promotionWorkflowList.next_action_queues.some(
511
+ (entry) =>
512
+ entry.action === "complete_certification" &&
513
+ entry.owner_queue.some((ownerEntry) => ownerEntry.owner === "review_operator")
514
+ ),
515
+ true,
516
+ "promotion workflow list next-action owner queue mismatch"
517
+ );
518
+
519
+ const stagedPromotionActionPreview = root.summarizeIntegrationPromotionActionPreview({
520
+ integration_id: "partner.protocol.acme_mcp",
521
+ action: "complete_certification"
522
+ });
523
+ assert.strictEqual(stagedPromotionActionPreview.ok, true, "staged promotion action preview mismatch");
524
+ assert.strictEqual(stagedPromotionActionPreview.valid_now, true, "staged promotion action preview validity mismatch");
525
+ assert.strictEqual(stagedPromotionActionPreview.action.stage, "certification", "staged promotion action stage mismatch");
526
+ assert.strictEqual(
527
+ stagedPromotionActionPreview.resulting_posture.promotion_readiness.blockers.includes("not_marked_production_default"),
528
+ true,
529
+ "staged promotion action resulting posture maturity blocker mismatch"
530
+ );
531
+
532
+ const builtinPromotionActionSet = root.summarizeIntegrationPromotionActionSet("builtin.protocol.mcp");
533
+ assert.strictEqual(builtinPromotionActionSet.ok, true, "builtin promotion action-set mismatch");
534
+ assert.strictEqual(
535
+ builtinPromotionActionSet.actions.some((entry) => entry.request.action === "maintain_production_default" && entry.valid_now === true),
536
+ true,
537
+ "builtin promotion action-set steady-state preview mismatch"
538
+ );
539
+
540
+ const promotionActionSetList = root.summarizeIntegrationPromotionActionSetList({
541
+ source: "third_party_example",
542
+ bundled: "false"
543
+ });
544
+ assert.strictEqual(promotionActionSetList.ok, true, "promotion action-set list mismatch");
545
+ assert.strictEqual(promotionActionSetList.integration_count >= 3, true, "promotion action-set list breadth mismatch");
546
+ assert.strictEqual(
547
+ promotionActionSetList.valid_actions.some((entry) => entry.action === "complete_certification"),
548
+ true,
549
+ "promotion action-set list valid-action summary mismatch"
550
+ );
551
+
552
+ const trustSelection = resolveIntegrationSelection({
553
+ task_ref: "trust.verify"
554
+ });
555
+ assert.ok(trustSelection.integration_ids.includes("builtin.execution.http"), "trust selection missing http execution integration");
556
+ assert.ok(trustSelection.settlement_integration_id === "builtin.settlement.chain", "trust selection settlement integration mismatch");
557
+
558
+ const trustHandoffSelection = resolveIntegrationSelection({
559
+ task_ref: "trust.handoff.emit"
560
+ });
561
+ assert.ok(trustHandoffSelection.integration_ids.includes("builtin.identity.registry"), "trust handoff selection missing builtin identity integration");
562
+ assert.ok(!trustHandoffSelection.integration_ids.includes("partner.identity.attest_registry"), "trust handoff selection should not auto-pick staged identity integration");
563
+
564
+ const explicitIdentitySelection = resolveIntegrationSelection({
565
+ task_ref: "trust.handoff.emit",
566
+ integration_id: "partner.identity.attest_registry"
567
+ });
568
+ assert.strictEqual(explicitIdentitySelection.ok, true, "explicit identity selection should pass");
569
+ assert.ok(explicitIdentitySelection.integration_ids.includes("partner.identity.attest_registry"), "explicit identity selection missing requested integration");
570
+
571
+ const mcpSelection = resolveIntegrationSelection({
572
+ task_ref: "adapter.mcp.invoke",
573
+ protocol: "mcp"
574
+ });
575
+ assert.ok(mcpSelection.integration_ids.includes("builtin.protocol.mcp"), "mcp selection missing protocol integration");
576
+ assert.ok(mcpSelection.protocols.includes("mcp"), "mcp selection protocol mismatch");
577
+ assert.ok(!mcpSelection.integration_ids.includes("partner.protocol.acme_mcp"), "mcp selection should not auto-pick staged protocol integration");
578
+
579
+ const x402McpSelection = resolveIntegrationSelection({
580
+ task_ref: "adapter.mcp.invoke",
581
+ protocol: "mcp",
582
+ payment_protocol: "x402"
583
+ });
584
+ assert.ok(x402McpSelection.integration_ids.includes("builtin.protocol.mcp"), "x402 mcp selection missing protocol integration");
585
+ assert.ok(x402McpSelection.integration_ids.includes("builtin.payment.x402"), "x402 mcp selection missing payment integration");
586
+ assert.ok(x402McpSelection.protocols.includes("x402"), "x402 protocol missing from selection");
587
+ assert.ok(!x402McpSelection.integration_ids.includes("partner.protocol.acme_mcp"), "x402 mcp selection should not auto-pick staged protocol integration");
588
+
589
+ const explicitThirdPartyProtocolSelection = resolveIntegrationSelection({
590
+ task_ref: "adapter.mcp.invoke",
591
+ protocol: "mcp",
592
+ integration_id: "partner.protocol.acme_mcp"
593
+ });
594
+ assert.strictEqual(explicitThirdPartyProtocolSelection.ok, true, "explicit third-party protocol selection should pass");
595
+ assert.ok(
596
+ explicitThirdPartyProtocolSelection.integration_ids.includes("partner.protocol.acme_mcp"),
597
+ "explicit third-party protocol selection missing requested integration"
598
+ );
599
+
600
+ const invalidUnknown = validateIntegrationSelection({
601
+ task_ref: "trust.verify",
602
+ integration_id: "unknown.integration"
603
+ });
604
+ assert.strictEqual(invalidUnknown.ok, false, "unknown integration should fail validation");
605
+ assert.ok(invalidUnknown.errors.some((entry) => entry.includes("unknown integration ids")), "unknown integration error missing");
606
+
607
+ const invalidIncompatible = validateIntegrationSelection({
608
+ task_ref: "trust.verify",
609
+ integration_id: "builtin.protocol.mcp"
610
+ });
611
+ assert.strictEqual(invalidIncompatible.ok, false, "incompatible integration should fail validation");
612
+ assert.ok(invalidIncompatible.errors.some((entry) => entry.includes("incompatible")), "incompatible integration error missing");
613
+
614
+ console.log("xytara verify:integrations passed");
615
+ }
616
+
617
+ main().catch((error) => {
618
+ console.error(error);
619
+ process.exit(1);
620
+ });