xytara 3.1.0 → 3.1.2

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 (373) hide show
  1. package/.env.example +67 -58
  2. package/ADAPTER_START_HERE.md +56 -56
  3. package/CARRIED_HANDOFF_DEMO.md +60 -60
  4. package/EXAMPLE_PATHS.md +53 -53
  5. package/FINAL_CONTRACT.md +498 -498
  6. package/LICENSE +201 -201
  7. package/NOTICE +3 -3
  8. package/PARTNER_READY_PATH.md +71 -71
  9. package/PUBLIC_DEMO_SCRIPT.md +78 -78
  10. package/README.md +6 -1
  11. package/REAL_PAYMENT_SETUP.md +32 -3
  12. package/RELEASE_NOTES.md +14 -14
  13. package/SERVICE_CONTRACT.md +419 -419
  14. package/START_HERE.md +1 -1
  15. package/SUPABASE_RUNTIME_STATE_SETUP.md +61 -61
  16. package/TERMINOLOGY.md +50 -50
  17. package/WHY_XYTARA_XOONYA.md +63 -63
  18. package/XT1_EXECUTION_TRUTH_STANDARD.md +78 -78
  19. package/XYTARA_ADAPTER_PROTOCOL_TRUTH_MODEL.md +75 -75
  20. package/XYTARA_AUTONOMOUS_ENTRY_MODEL.md +124 -124
  21. package/XYTARA_DEFAULT_PATH_MODEL.md +84 -84
  22. package/XYTARA_EXECUTION_TRUTH_MODEL.md +171 -171
  23. package/XYTARA_PAYMENT_RAIL_TRUTH_MODEL.md +68 -68
  24. package/adapters/AUTHORING_GUIDE.md +243 -243
  25. package/adapters/ONBOARDING_POSTURE.md +61 -61
  26. package/adapters/THIRD_PARTY_SUBMISSION_PROCESS.md +84 -84
  27. package/adapters/adapter-manifest.schema.json +283 -283
  28. package/adapters/examples/example-execution-adapter.js +61 -61
  29. package/adapters/examples/example-execution-adapter.manifest.json +81 -81
  30. package/adapters/examples/example-settlement-adapter.js +55 -55
  31. package/adapters/examples/example-settlement-adapter.manifest.json +78 -78
  32. package/adapters/examples/example-third-party-acp-registration.submission-bundle.json +124 -124
  33. package/adapters/examples/example-third-party-erc8004-registration.submission-bundle.json +121 -121
  34. package/adapters/examples/example-third-party-identity-registration.certification-pack.json +22 -22
  35. package/adapters/examples/example-third-party-identity-registration.record.json +26 -26
  36. package/adapters/examples/example-third-party-identity-registration.submission-bundle.json +126 -126
  37. package/adapters/examples/example-third-party-langchain-registration.submission-bundle.json +124 -124
  38. package/adapters/examples/example-third-party-mpp-registration.submission-bundle.json +120 -120
  39. package/adapters/examples/example-third-party-registration.certification-pack.json +22 -22
  40. package/adapters/examples/example-third-party-registration.record.json +28 -28
  41. package/adapters/examples/example-third-party-registration.submission-bundle.json +126 -126
  42. package/adapters/examples/example-third-party-settlement-registration.certification-pack.json +22 -22
  43. package/adapters/examples/example-third-party-settlement-registration.record.json +26 -26
  44. package/adapters/examples/example-third-party-settlement-registration.submission-bundle.json +127 -127
  45. package/adapters/examples/langchain-reference-execution-adapter.js +81 -81
  46. package/adapters/examples/langchain-reference-execution-adapter.manifest.json +79 -79
  47. package/adapters/examples/langgraph-reference-execution-adapter.js +81 -81
  48. package/adapters/examples/langgraph-reference-execution-adapter.manifest.json +79 -79
  49. package/adapters/examples/minimal-third-party-execution-adapter.js +61 -61
  50. package/adapters/examples/minimal-third-party-execution-adapter.manifest.json +79 -79
  51. package/adapters/examples/minimal-third-party-execution-registration.record.json +26 -26
  52. package/adapters/examples/minimal-third-party-execution.certification-pack.json +22 -22
  53. package/adapters/examples/minimal-third-party-execution.submission-bundle.json +126 -126
  54. package/adapters/integration-certification-pack.schema.json +82 -82
  55. package/adapters/integration-registration-record.schema.json +114 -114
  56. package/adapters/integration-submission-bundle-set.schema.json +39 -39
  57. package/adapters/integration-submission-bundle.schema.json +34 -34
  58. package/adapters/interfaces.js +56 -56
  59. package/bin/xytara-first-run.js +244 -244
  60. package/bin/xytara-release.js +1429 -1429
  61. package/bin/xytara-run.js +186 -186
  62. package/bin/xytara.js +80 -80
  63. package/client.js +3 -3
  64. package/examples/_demo_env.js +40 -0
  65. package/examples/adapter_review_walkthrough.js +54 -53
  66. package/examples/export_carried_handoff.js +81 -80
  67. package/examples/funded_runtime_walkthrough.js +71 -70
  68. package/examples/generated.carried-handoff.json +30 -0
  69. package/examples/partner_launch_walkthrough.js +44 -43
  70. package/examples/quickstart.js +3256 -3255
  71. package/fixtures/catalog.js +1134 -1134
  72. package/index.js +395 -395
  73. package/integrations/dispatch.js +276 -276
  74. package/integrations/registry-snapshot.schema.json +36 -36
  75. package/integrations/registry.js +2261 -2261
  76. package/integrations/views.js +28 -28
  77. package/lib/a2a_lane_contract.js +104 -104
  78. package/lib/a2c_lane_contract.js +111 -111
  79. package/lib/account_auth.js +518 -518
  80. package/lib/acp_lane_contract.js +54 -54
  81. package/lib/activity_audit_contract.js +322 -322
  82. package/lib/adapter_certification_contract.js +130 -130
  83. package/lib/adapter_depth_contract.js +156 -156
  84. package/lib/adapter_pack.js +118 -118
  85. package/lib/adapter_partner_pack.js +89 -89
  86. package/lib/adapter_promotion_pack.js +89 -89
  87. package/lib/adapter_protocol_truth_contract.js +229 -229
  88. package/lib/announcement_pack.js +61 -61
  89. package/lib/artifact_distribution_lane_contract.js +54 -54
  90. package/lib/asyncapi_contract.js +150 -150
  91. package/lib/auth_interop_contract.js +80 -80
  92. package/lib/authority_binding_lifecycle_contract.js +182 -182
  93. package/lib/autonomous_entry_contract.js +409 -409
  94. package/lib/bolt_lane_contract.js +55 -55
  95. package/lib/bolt_payment_front.js +172 -172
  96. package/lib/business_cockpit.js +378 -378
  97. package/lib/capability_execution_truth.js +272 -272
  98. package/lib/capability_registry.js +633 -633
  99. package/lib/catalog_contract.js +966 -966
  100. package/lib/catalog_family_model.js +193 -193
  101. package/lib/catalog_views.js +55 -55
  102. package/lib/checkout_event_security.js +142 -142
  103. package/lib/cloudevents_contract.js +80 -80
  104. package/lib/command_flow.js +411 -406
  105. package/lib/commerce_artifacts.js +503 -503
  106. package/lib/commerce_authority.js +449 -449
  107. package/lib/commerce_cases.js +317 -317
  108. package/lib/commerce_checkout.js +509 -509
  109. package/lib/commerce_client.js +7687 -7676
  110. package/lib/commerce_coordination.js +346 -346
  111. package/lib/commerce_economics.js +4017 -4016
  112. package/lib/commerce_identity.js +578 -578
  113. package/lib/commerce_quotes.js +237 -237
  114. package/lib/commerce_reports.js +14461 -14461
  115. package/lib/commerce_runtime.js +315 -315
  116. package/lib/commerce_shell.js +257 -257
  117. package/lib/crypto_agility_matrix.js +125 -125
  118. package/lib/default_path_contract.js +412 -412
  119. package/lib/delivery_summary_contract.js +95 -95
  120. package/lib/ecosystem_entry.js +64 -64
  121. package/lib/erc8004_lane_contract.js +65 -65
  122. package/lib/event_system_lane_contract.js +75 -75
  123. package/lib/execution_truth_contract.js +234 -234
  124. package/lib/external_credit_bridge.js +142 -142
  125. package/lib/external_execution_runtime.js +132 -132
  126. package/lib/feature_control_lane_contract.js +54 -54
  127. package/lib/first_run_conversion_contract.js +290 -290
  128. package/lib/framework_lane_contract.js +89 -89
  129. package/lib/framework_provider_promotion.js +235 -235
  130. package/lib/full_catalog_contract.js +525 -525
  131. package/lib/go_live_operator_pack.js +391 -391
  132. package/lib/http_transport.js +73 -73
  133. package/lib/identity_auth.js +175 -175
  134. package/lib/identity_interop_contract.js +82 -82
  135. package/lib/integration_matrix_contract.js +102 -102
  136. package/lib/l402_lane_contract.js +55 -55
  137. package/lib/l402_payment_front.js +192 -192
  138. package/lib/launch_narrative.js +53 -53
  139. package/lib/lifecycle_continuity_contract.js +115 -115
  140. package/lib/machine_identity_registry_contract.js +199 -199
  141. package/lib/major_rails_lane_contract.js +150 -150
  142. package/lib/market_lane_contract.js +467 -467
  143. package/lib/market_lane_depth_contract.js +182 -182
  144. package/lib/market_lane_promotion_contract.js +210 -210
  145. package/lib/market_lane_trace_contract.js +278 -278
  146. package/lib/mcp_lane_contract.js +137 -137
  147. package/lib/network_transport.js +110 -110
  148. package/lib/offline_verifiability_recovery_contract.js +155 -155
  149. package/lib/openapi_contract.js +296 -296
  150. package/lib/operational_receipt_contract.js +165 -165
  151. package/lib/operator_intelligence.js +407 -407
  152. package/lib/outreach_copy_pack.js +51 -51
  153. package/lib/outreach_message_pack.js +71 -71
  154. package/lib/outreach_proof.js +71 -71
  155. package/lib/outreach_target_pack.js +60 -60
  156. package/lib/partner_intelligence.js +105 -105
  157. package/lib/payment_config.js +239 -191
  158. package/lib/payment_front_registry.js +53 -53
  159. package/lib/payment_protocol_contract.js +165 -165
  160. package/lib/payment_rail_truth_contract.js +324 -324
  161. package/lib/payment_verification.js +312 -264
  162. package/lib/phase_10_closeout_pack.js +45 -45
  163. package/lib/phase_10_completion_pack.js +76 -76
  164. package/lib/phase_10_decision_record_pack.js +54 -54
  165. package/lib/phase_10_decision_resolution_pack.js +53 -53
  166. package/lib/phase_10_demand_signal_adapters_runtime_pack.js +74 -74
  167. package/lib/phase_10_ecosystem_backlog_triage_runtime_pack.js +74 -74
  168. package/lib/phase_10_freeze_baseline_pack.js +67 -67
  169. package/lib/phase_10_freeze_review_pack.js +64 -64
  170. package/lib/phase_10_gate_pack.js +57 -57
  171. package/lib/phase_10_long_tail_continuity_pack.js +80 -80
  172. package/lib/phase_10_long_tail_ecosystem_pack.js +66 -66
  173. package/lib/phase_10_niche_extension_registry_runtime_pack.js +74 -74
  174. package/lib/phase_1_claude_mcp_pack.js +60 -60
  175. package/lib/phase_1_claude_mcp_runtime_pack.js +52 -52
  176. package/lib/phase_1_ecosystem_pack.js +67 -67
  177. package/lib/phase_1_openai_codex_pack.js +60 -60
  178. package/lib/phase_1_openai_codex_runtime_pack.js +52 -52
  179. package/lib/phase_2_base_runtime_pack.js +71 -71
  180. package/lib/phase_2_base_usdc_runtime_pack.js +72 -72
  181. package/lib/phase_2_closeout_pack.js +65 -65
  182. package/lib/phase_2_completion_pack.js +113 -113
  183. package/lib/phase_2_decision_record_pack.js +66 -66
  184. package/lib/phase_2_decision_resolution_pack.js +69 -69
  185. package/lib/phase_2_eth_runtime_pack.js +70 -70
  186. package/lib/phase_2_evm_base_runtime_pack.js +73 -73
  187. package/lib/phase_2_evm_runtime_pack.js +71 -71
  188. package/lib/phase_2_flip_preview_pack.js +60 -60
  189. package/lib/phase_2_freeze_review_pack.js +99 -99
  190. package/lib/phase_2_gate_pack.js +77 -77
  191. package/lib/phase_2_payment_rails_pack.js +71 -71
  192. package/lib/phase_2_usdc_runtime_pack.js +71 -71
  193. package/lib/phase_3_brc_runtime_pack.js +81 -81
  194. package/lib/phase_3_bsv_teranode_runtime_pack.js +83 -83
  195. package/lib/phase_3_closeout_pack.js +62 -62
  196. package/lib/phase_3_completion_pack.js +94 -94
  197. package/lib/phase_3_decision_record_pack.js +64 -64
  198. package/lib/phase_3_decision_resolution_pack.js +69 -69
  199. package/lib/phase_3_freeze_baseline_pack.js +67 -67
  200. package/lib/phase_3_freeze_review_pack.js +80 -80
  201. package/lib/phase_3_gate_pack.js +76 -76
  202. package/lib/phase_3_metanet_runtime_pack.js +81 -81
  203. package/lib/phase_3_native_bsv_pack.js +91 -91
  204. package/lib/phase_3_native_continuity_pack.js +82 -82
  205. package/lib/phase_4_attestation_runtime_pack.js +75 -75
  206. package/lib/phase_4_closeout_pack.js +45 -45
  207. package/lib/phase_4_completion_pack.js +94 -94
  208. package/lib/phase_4_decision_record_pack.js +54 -54
  209. package/lib/phase_4_decision_resolution_pack.js +45 -45
  210. package/lib/phase_4_erc8004_runtime_pack.js +76 -76
  211. package/lib/phase_4_freeze_baseline_pack.js +67 -67
  212. package/lib/phase_4_freeze_review_pack.js +68 -68
  213. package/lib/phase_4_gate_pack.js +58 -58
  214. package/lib/phase_4_identity_registry_runtime_pack.js +75 -75
  215. package/lib/phase_4_identity_trust_pack.js +73 -73
  216. package/lib/phase_4_trust_continuity_pack.js +86 -86
  217. package/lib/phase_5_antelope_runtime_pack.js +76 -76
  218. package/lib/phase_5_closeout_pack.js +44 -44
  219. package/lib/phase_5_completion_pack.js +82 -82
  220. package/lib/phase_5_constellation_dag_runtime_pack.js +76 -76
  221. package/lib/phase_5_decision_record_pack.js +54 -54
  222. package/lib/phase_5_decision_resolution_pack.js +45 -45
  223. package/lib/phase_5_digibyte_dgb_runtime_pack.js +76 -76
  224. package/lib/phase_5_freeze_baseline_pack.js +67 -67
  225. package/lib/phase_5_freeze_review_pack.js +68 -68
  226. package/lib/phase_5_gate_pack.js +58 -58
  227. package/lib/phase_5_hedera_hbar_runtime_pack.js +76 -76
  228. package/lib/phase_5_kaspa_kas_runtime_pack.js +76 -76
  229. package/lib/phase_5_major_rails_continuity_pack.js +86 -86
  230. package/lib/phase_5_major_rails_pack.js +110 -110
  231. package/lib/phase_5_metal_runtime_pack.js +76 -76
  232. package/lib/phase_5_polkadot_dot_runtime_pack.js +76 -76
  233. package/lib/phase_5_proton_xpr_runtime_pack.js +76 -76
  234. package/lib/phase_5_solana_runtime_pack.js +76 -76
  235. package/lib/phase_6_autogen_runtime_pack.js +72 -72
  236. package/lib/phase_6_closeout_pack.js +46 -46
  237. package/lib/phase_6_completion_pack.js +77 -77
  238. package/lib/phase_6_decision_record_pack.js +54 -54
  239. package/lib/phase_6_decision_resolution_pack.js +53 -53
  240. package/lib/phase_6_framework_continuity_pack.js +81 -81
  241. package/lib/phase_6_framework_runtime_pack.js +68 -68
  242. package/lib/phase_6_freeze_baseline_pack.js +68 -68
  243. package/lib/phase_6_freeze_review_pack.js +65 -65
  244. package/lib/phase_6_gate_pack.js +59 -59
  245. package/lib/phase_6_langchain_runtime_pack.js +72 -72
  246. package/lib/phase_6_langgraph_runtime_pack.js +72 -72
  247. package/lib/phase_6_semantic_kernel_runtime_pack.js +72 -72
  248. package/lib/phase_7_closeout_pack.js +45 -45
  249. package/lib/phase_7_completion_pack.js +85 -85
  250. package/lib/phase_7_decision_record_pack.js +53 -53
  251. package/lib/phase_7_decision_resolution_pack.js +53 -53
  252. package/lib/phase_7_event_system_continuity_pack.js +89 -89
  253. package/lib/phase_7_event_system_pack.js +76 -76
  254. package/lib/phase_7_freeze_baseline_pack.js +74 -74
  255. package/lib/phase_7_freeze_review_pack.js +65 -65
  256. package/lib/phase_7_gate_pack.js +58 -58
  257. package/lib/phase_7_kafka_runtime_pack.js +74 -74
  258. package/lib/phase_7_mqtt_runtime_pack.js +74 -74
  259. package/lib/phase_7_nats_runtime_pack.js +74 -74
  260. package/lib/phase_7_webhook_event_bus_runtime_pack.js +74 -74
  261. package/lib/phase_8_closeout_pack.js +46 -46
  262. package/lib/phase_8_completion_pack.js +82 -82
  263. package/lib/phase_8_decision_record_pack.js +54 -54
  264. package/lib/phase_8_decision_resolution_pack.js +53 -53
  265. package/lib/phase_8_external_receipt_import_runtime_pack.js +74 -74
  266. package/lib/phase_8_external_result_import_runtime_pack.js +74 -74
  267. package/lib/phase_8_freeze_baseline_pack.js +71 -71
  268. package/lib/phase_8_freeze_review_pack.js +64 -64
  269. package/lib/phase_8_gate_pack.js +58 -58
  270. package/lib/phase_8_proof_bridge_continuity_pack.js +86 -86
  271. package/lib/phase_8_proof_bridges_pack.js +72 -72
  272. package/lib/phase_8_proof_bundle_normalization_runtime_pack.js +74 -74
  273. package/lib/phase_9_closeout_pack.js +46 -46
  274. package/lib/phase_9_completion_pack.js +82 -82
  275. package/lib/phase_9_custody_refs_runtime_pack.js +74 -74
  276. package/lib/phase_9_decision_record_pack.js +54 -54
  277. package/lib/phase_9_decision_resolution_pack.js +53 -53
  278. package/lib/phase_9_freeze_baseline_pack.js +71 -71
  279. package/lib/phase_9_freeze_review_pack.js +64 -64
  280. package/lib/phase_9_gate_pack.js +58 -58
  281. package/lib/phase_9_operator_accounting_bridges_runtime_pack.js +74 -74
  282. package/lib/phase_9_treasury_connectivity_pack.js +72 -72
  283. package/lib/phase_9_treasury_continuity_pack.js +86 -86
  284. package/lib/phase_9_treasury_destinations_runtime_pack.js +74 -74
  285. package/lib/phase_program_pack.js +120 -120
  286. package/lib/pricing_optimization_contract.js +775 -775
  287. package/lib/protocol_lane_contract.js +117 -117
  288. package/lib/provenance_lane_contract.js +54 -54
  289. package/lib/provider_lane_contract.js +240 -240
  290. package/lib/provider_runtime_journey_contract.js +183 -183
  291. package/lib/public_surface_policy_contract.js +111 -111
  292. package/lib/publish_plan.js +51 -51
  293. package/lib/record_queries.js +48 -48
  294. package/lib/release_candidate.js +50 -50
  295. package/lib/release_center.js +1093 -1093
  296. package/lib/release_history.js +205 -205
  297. package/lib/release_manifest.js +113 -113
  298. package/lib/release_pack.js +453 -453
  299. package/lib/request_rate_limit.js +144 -144
  300. package/lib/resource_views.js +31 -31
  301. package/lib/revenue_launch_path_contract.js +326 -326
  302. package/lib/route_matchers.js +34 -34
  303. package/lib/route_params.js +19 -19
  304. package/lib/runtime_bridge.js +124 -124
  305. package/lib/runtime_operations_worker.js +282 -282
  306. package/lib/runtime_state_store.js +354 -354
  307. package/lib/settlement_lane_contract.js +111 -111
  308. package/lib/shared_signals_lane_contract.js +54 -54
  309. package/lib/signed_audit_provenance_contract.js +83 -83
  310. package/lib/soft_launch_pack.js +78 -78
  311. package/lib/stablecoin_lane_contract.js +76 -76
  312. package/lib/stripe_mpp_lane_contract.js +96 -96
  313. package/lib/stripe_mpp_payment_front.js +158 -158
  314. package/lib/telemetry_lane_contract.js +54 -54
  315. package/lib/treasury_destinations_contract.js +764 -764
  316. package/lib/treasury_egress_policy_contract.js +91 -91
  317. package/lib/treasury_lane_contract.js +84 -84
  318. package/lib/trust_portability_boundary_contract.js +72 -72
  319. package/lib/x402_facilitator.js +155 -0
  320. package/lib/x402_lane_contract.js +118 -118
  321. package/package.json +106 -105
  322. package/scripts/registry_cli.js +275 -275
  323. package/scripts/verify_adapters.js +554 -554
  324. package/scripts/verify_all.js +4962 -4962
  325. package/scripts/verify_control_plane_contracts.js +34 -34
  326. package/scripts/verify_control_plane_routes.js +70 -70
  327. package/scripts/verify_delivery_summary.js +112 -112
  328. package/scripts/verify_examples.js +19 -19
  329. package/scripts/verify_first_run_conversions.js +81 -81
  330. package/scripts/verify_framework_provider_promotion.js +152 -152
  331. package/scripts/verify_full_catalog.js +174 -174
  332. package/scripts/verify_integrations.js +620 -620
  333. package/scripts/verify_lifecycle_continuity.js +96 -96
  334. package/scripts/verify_market_lane_depth.js +94 -94
  335. package/scripts/verify_market_lane_promotion.js +103 -103
  336. package/scripts/verify_market_lane_traces.js +98 -98
  337. package/scripts/verify_market_lanes.js +102 -102
  338. package/scripts/verify_operator_observability_boundary.js +83 -83
  339. package/scripts/verify_pricing_experiment_plan.js +124 -124
  340. package/scripts/verify_provider_runtime_breadth.js +109 -109
  341. package/scripts/verify_provider_runtime_journeys.js +111 -111
  342. package/scripts/verify_revenue_launch_paths.js +105 -105
  343. package/scripts/verify_runtime_durability.js +52 -52
  344. package/scripts/verify_service.js +15410 -15250
  345. package/scripts/verify_tooling.js +1412 -1412
  346. package/scripts/verify_treasury_public_boundary.js +97 -97
  347. package/scripts/verify_x402_facilitator.js +174 -0
  348. package/server.js +11117 -11006
  349. package/.env.production.checklist +0 -77
  350. package/.env.production.template +0 -54
  351. package/.github/workflows/publish-mcp-executor.yml +0 -43
  352. package/ADAPTER_PARTNER_PATH.md +0 -47
  353. package/ADAPTER_PROMOTION_START_HERE.md +0 -44
  354. package/BOLT_BINDINGS.production.worksheet.json +0 -31
  355. package/EXECUTION_TARGETS.production.worksheet.json +0 -73
  356. package/GO_LIVE_OPERATOR_PACK.md +0 -412
  357. package/L402_BINDINGS.production.worksheet.json +0 -30
  358. package/OPERATIONS_RUNBOOK.md +0 -115
  359. package/OPERATOR_START_HERE.md +0 -63
  360. package/OUTREACH_MESSAGES.md +0 -19
  361. package/OUTREACH_START_HERE.md +0 -36
  362. package/PRODUCTION_MANUAL_CLOSEOUT_SEQUENCE.md +0 -172
  363. package/PROGRAM_COMPLETE_RELEASE.md +0 -63
  364. package/PROGRAM_STATUS.md +0 -57
  365. package/PUBLISH_PLAN.md +0 -26
  366. package/RELEASE_CHECKLIST.md +0 -16
  367. package/SOFT_LAUNCH_KIT.md +0 -47
  368. package/services/mcp-execution-target/DISCOVERY_REGISTRY_PLAYBOOK.md +0 -141
  369. package/services/mcp-execution-target/README.md +0 -319
  370. package/services/mcp-execution-target/package.json +0 -14
  371. package/services/mcp-execution-target/server.js +0 -1031
  372. package/services/mcp-execution-target/server.json +0 -16
  373. package/services/mcp-execution-target/verify.js +0 -308
@@ -1,2261 +1,2261 @@
1
- "use strict";
2
-
3
- const executionExampleManifest = require("../adapters/examples/example-execution-adapter.manifest.json");
4
- const settlementExampleManifest = require("../adapters/examples/example-settlement-adapter.manifest.json");
5
- const exampleThirdPartyRegistrationRecord = require("../adapters/examples/example-third-party-registration.record.json");
6
- const exampleThirdPartyIdentityRegistrationRecord = require("../adapters/examples/example-third-party-identity-registration.record.json");
7
- const exampleThirdPartySettlementRegistrationRecord = require("../adapters/examples/example-third-party-settlement-registration.record.json");
8
- const { catalog } = require("../fixtures/catalog");
9
-
10
- function clone(value) {
11
- return JSON.parse(JSON.stringify(value));
12
- }
13
-
14
- function sortStrings(values) {
15
- return Array.from(new Set((Array.isArray(values) ? values : []).filter(Boolean))).sort();
16
- }
17
-
18
- function collectTaskRefsByAdapter(adapterName) {
19
- return (Array.isArray(catalog.tasks) ? catalog.tasks : [])
20
- .filter((task) => Array.isArray(task.adapters) && task.adapters.includes(adapterName))
21
- .map((task) => task.public_task_ref);
22
- }
23
-
24
- function collectWorkflowRefsByTaskRefs(taskRefs) {
25
- const allowed = new Set(Array.isArray(taskRefs) ? taskRefs : []);
26
- return (Array.isArray(catalog.workflows) ? catalog.workflows : [])
27
- .filter((workflow) => Array.isArray(workflow.task_refs) && workflow.task_refs.some((taskRef) => allowed.has(taskRef)))
28
- .map((workflow) => workflow.workflow_ref);
29
- }
30
-
31
- function createBuiltinBreadthIntegration({
32
- integration_id,
33
- display_name,
34
- description,
35
- adapter_class,
36
- capabilities = [],
37
- protocols = [],
38
- settlement_modes = [],
39
- execution_backends = [],
40
- adapter_lanes = [],
41
- task_refs = [],
42
- workflow_refs = [],
43
- required_secrets = [],
44
- required_permissions = [],
45
- supported_profiles = ["default"],
46
- pricing_basis = "per_task",
47
- latency_class = "mixed",
48
- proof_mode = "adjacent_reference_only"
49
- }) {
50
- return {
51
- integration_id,
52
- display_name,
53
- description,
54
- adapter_class,
55
- adapter_version: "1.26.0",
56
- interface_version: "commerce-adapter-interface/v1",
57
- bundled: true,
58
- source: "builtin",
59
- status: "available",
60
- certification_state: "certified",
61
- certification_scope: ["builtin_registry", "service_contract", "sdk_contract"],
62
- integration_maturity: "production_supported",
63
- selection_priority: 250,
64
- capabilities: sortStrings(capabilities),
65
- protocols: sortStrings(protocols),
66
- settlement_modes: sortStrings(settlement_modes),
67
- execution_backends: sortStrings(execution_backends),
68
- adapter_lanes: sortStrings(adapter_lanes),
69
- task_refs: sortStrings(task_refs),
70
- workflow_refs: sortStrings(workflow_refs),
71
- required_secrets: sortStrings(required_secrets),
72
- required_permissions: sortStrings(required_permissions),
73
- supported_profiles: sortStrings(supported_profiles),
74
- supported_regions: ["global"],
75
- pricing_basis,
76
- latency_class,
77
- proof_contract: {
78
- emits_proof_compatible_facts: true,
79
- proof_mode
80
- },
81
- health_contract: {
82
- check_kind: "internal",
83
- supports_readiness: true
84
- },
85
- idempotency_contract: {
86
- strategy: "quote_bound_selection",
87
- scope: "integration_selection"
88
- },
89
- failure_contract: {
90
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
91
- retryable_categories: ["timeout", "upstream_unavailable"]
92
- },
93
- compatibility: {
94
- node: ">=18",
95
- commerce_contract: "xytara/v1"
96
- },
97
- operational_readiness: {
98
- supports_default_selection: false,
99
- supports_forced_selection: true,
100
- lifecycle: "managed_builtin",
101
- health_source: "internal"
102
- },
103
- selection_hints: {
104
- default_for_task_refs: [],
105
- default_for_protocols: [],
106
- default_for_settlement_modes: []
107
- }
108
- };
109
- }
110
-
111
- function mapManifestToIntegration(manifest, extras = {}) {
112
- const taskRefs = sortStrings(extras.task_refs);
113
- return {
114
- integration_id: manifest.adapter_id,
115
- display_name: manifest.display_name,
116
- description: manifest.description,
117
- adapter_class: manifest.adapter_class,
118
- adapter_version: manifest.adapter_version,
119
- interface_version: manifest.interface_version,
120
- bundled: extras.bundled !== false,
121
- source: extras.source || "example",
122
- status: extras.status || "available",
123
- certification_state: extras.certification_state || "reference_example",
124
- certification_scope: sortStrings(extras.certification_scope || ["contract_shape"]),
125
- integration_maturity: extras.integration_maturity || "reference_example",
126
- selection_priority: Number.isFinite(Number(extras.selection_priority)) ? Number(extras.selection_priority) : 900,
127
- capabilities: sortStrings(manifest.capabilities),
128
- protocols: sortStrings(extras.protocols),
129
- settlement_modes: sortStrings(manifest.supported_settlement_modes),
130
- execution_backends: sortStrings(extras.execution_backends),
131
- adapter_lanes: sortStrings(extras.adapter_lanes),
132
- task_refs: taskRefs,
133
- workflow_refs: sortStrings(extras.workflow_refs || collectWorkflowRefsByTaskRefs(taskRefs)),
134
- required_secrets: sortStrings(manifest.required_secrets),
135
- required_permissions: sortStrings(manifest.required_permissions),
136
- supported_profiles: sortStrings(manifest.supported_profiles),
137
- supported_regions: sortStrings(manifest.supported_regions),
138
- pricing_basis: manifest.pricing_basis || null,
139
- latency_class: manifest.latency_class || null,
140
- proof_contract: manifest.proof_contract || null,
141
- health_contract: manifest.health_contract || null,
142
- idempotency_contract: manifest.idempotency_contract || null,
143
- failure_contract: manifest.failure_contract || null,
144
- compatibility: manifest.compatibility || {},
145
- operational_readiness: {
146
- supports_default_selection: extras.supports_default_selection === true,
147
- supports_forced_selection: extras.supports_forced_selection !== false,
148
- lifecycle: extras.lifecycle || "reference",
149
- health_source: extras.health_source || "self_reported"
150
- },
151
- selection_hints: {
152
- default_for_task_refs: sortStrings(extras.default_for_task_refs || taskRefs),
153
- default_for_protocols: sortStrings(extras.default_for_protocols || extras.protocols),
154
- default_for_settlement_modes: sortStrings(extras.default_for_settlement_modes || manifest.supported_settlement_modes)
155
- }
156
- };
157
- }
158
-
159
- function buildIntegrationRegistrationView(integration, registrationRecord) {
160
- const integrationEntry = integration || {};
161
- const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : null;
162
- const selectionPriority = record && Number.isFinite(Number(record.selection_priority))
163
- ? Number(record.selection_priority)
164
- : integrationEntry.selection_priority;
165
- return {
166
- registration_state: record ? record.registration_state : "unregistered",
167
- bundled: record ? record.bundled : integrationEntry.bundled === true,
168
- default_selection_enabled: record
169
- ? record.default_selection_enabled === true
170
- : !!(
171
- integrationEntry.operational_readiness &&
172
- integrationEntry.operational_readiness.supports_default_selection
173
- ),
174
- requires_explicit_selection: record
175
- ? record.requires_explicit_selection === true
176
- : !(
177
- integrationEntry.operational_readiness &&
178
- integrationEntry.operational_readiness.supports_default_selection
179
- ),
180
- selection_priority: selectionPriority,
181
- registered_at: record ? record.registered_at : null,
182
- registered_by: record ? record.registered_by || null : null,
183
- verified_with: sortStrings(record && record.verified_with),
184
- notes: record ? record.notes || null : null
185
- };
186
- }
187
-
188
- function buildIntegrationView(integration, registrationRecord) {
189
- const entry = clone(integration);
190
- entry.registration = buildIntegrationRegistrationView(entry, registrationRecord);
191
- return entry;
192
- }
193
-
194
- function createRegisteredIntegrationFromManifest(manifest, registrationRecord, extras = {}) {
195
- const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
196
- const integration = mapManifestToIntegration(manifest, {
197
- ...extras,
198
- bundled: Object.prototype.hasOwnProperty.call(record, "bundled")
199
- ? record.bundled
200
- : extras.bundled,
201
- certification_state: record.certification_state || extras.certification_state,
202
- certification_scope: record.certification_scope || extras.certification_scope,
203
- integration_maturity: record.integration_maturity || extras.integration_maturity,
204
- selection_priority: Object.prototype.hasOwnProperty.call(record, "selection_priority")
205
- ? record.selection_priority
206
- : extras.selection_priority,
207
- supports_default_selection: Object.prototype.hasOwnProperty.call(record, "default_selection_enabled")
208
- ? record.default_selection_enabled
209
- : extras.supports_default_selection,
210
- lifecycle: record.registration_state || extras.lifecycle,
211
- default_for_task_refs: record.default_selection_enabled === true
212
- ? extras.default_for_task_refs
213
- : [],
214
- default_for_protocols: record.default_selection_enabled === true
215
- ? extras.default_for_protocols
216
- : [],
217
- default_for_settlement_modes: record.default_selection_enabled === true
218
- ? extras.default_for_settlement_modes
219
- : []
220
- });
221
- return buildIntegrationView(integration, record);
222
- }
223
-
224
- function validateIntegrationRegistration(manifest, registrationRecord) {
225
- const errors = [];
226
- const manifestEntry = manifest && typeof manifest === "object" ? manifest : {};
227
- const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
228
-
229
- if (!manifestEntry.adapter_id) {
230
- errors.push("manifest.adapter_id is required");
231
- }
232
- if (!record.integration_id) {
233
- errors.push("registration_record.integration_id is required");
234
- }
235
- if (!record.adapter_id) {
236
- errors.push("registration_record.adapter_id is required");
237
- }
238
- if (!record.adapter_class) {
239
- errors.push("registration_record.adapter_class is required");
240
- }
241
- if (manifestEntry.adapter_id && record.adapter_id && manifestEntry.adapter_id !== record.adapter_id) {
242
- errors.push("manifest.adapter_id must match registration_record.adapter_id");
243
- }
244
- if (manifestEntry.adapter_id && record.integration_id && manifestEntry.adapter_id !== record.integration_id) {
245
- errors.push("manifest.adapter_id must match registration_record.integration_id");
246
- }
247
- if (manifestEntry.adapter_class && record.adapter_class && manifestEntry.adapter_class !== record.adapter_class) {
248
- errors.push("manifest.adapter_class must match registration_record.adapter_class");
249
- }
250
-
251
- return {
252
- ok: errors.length === 0,
253
- errors
254
- };
255
- }
256
-
257
- function validateIntegrationCertificationPack(certificationPack) {
258
- const pack = certificationPack && typeof certificationPack === "object" ? certificationPack : {};
259
- const errors = [];
260
- if (!pack.integration_id) errors.push("certification_pack.integration_id is required");
261
- if (!pack.adapter_id) errors.push("certification_pack.adapter_id is required");
262
- if (!pack.adapter_class) errors.push("certification_pack.adapter_class is required");
263
- if (!pack.certification_state) errors.push("certification_pack.certification_state is required");
264
- if (!Array.isArray(pack.certification_scope) || pack.certification_scope.length < 1) {
265
- errors.push("certification_pack.certification_scope must contain at least one entry");
266
- }
267
- if (!Array.isArray(pack.verified_with) || pack.verified_with.length < 1) {
268
- errors.push("certification_pack.verified_with must contain at least one entry");
269
- }
270
- if (!pack.submitted_at) errors.push("certification_pack.submitted_at is required");
271
- return {
272
- ok: errors.length === 0,
273
- errors
274
- };
275
- }
276
-
277
- function validateIntegrationSubmission(manifest, registrationRecord, certificationPack) {
278
- const registrationValidation = validateIntegrationRegistration(manifest, registrationRecord);
279
- const certificationValidation = validateIntegrationCertificationPack(certificationPack);
280
- const errors = registrationValidation.errors.concat(certificationValidation.errors);
281
- const manifestEntry = manifest && typeof manifest === "object" ? manifest : {};
282
- const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
283
- const pack = certificationPack && typeof certificationPack === "object" ? certificationPack : {};
284
-
285
- if (manifestEntry.adapter_id && pack.adapter_id && manifestEntry.adapter_id !== pack.adapter_id) {
286
- errors.push("manifest.adapter_id must match certification_pack.adapter_id");
287
- }
288
- if (record.integration_id && pack.integration_id && record.integration_id !== pack.integration_id) {
289
- errors.push("registration_record.integration_id must match certification_pack.integration_id");
290
- }
291
- if (record.adapter_class && pack.adapter_class && record.adapter_class !== pack.adapter_class) {
292
- errors.push("registration_record.adapter_class must match certification_pack.adapter_class");
293
- }
294
- if (record.certification_state && pack.certification_state && record.certification_state !== pack.certification_state) {
295
- errors.push("registration_record.certification_state must match certification_pack.certification_state");
296
- }
297
-
298
- return {
299
- ok: errors.length === 0,
300
- errors
301
- };
302
- }
303
-
304
- function importRegisteredIntegration(manifest, registrationRecord, extras = {}) {
305
- const validation = validateIntegrationRegistration(manifest, registrationRecord);
306
- if (!validation.ok) {
307
- const error = new Error(`invalid integration registration:\n${validation.errors.join("\n")}`);
308
- error.code = "invalid_integration_registration";
309
- error.validation = validation;
310
- throw error;
311
- }
312
- return createRegisteredIntegrationFromManifest(manifest, registrationRecord, extras);
313
- }
314
-
315
- function createIntegrationRegistrySnapshot(integrations, filters = {}) {
316
- const rows = Array.isArray(integrations) ? integrations.map(clone) : [];
317
- return {
318
- snapshot_version: "xytara/integration-registry-snapshot/v1",
319
- generated_at: new Date().toISOString(),
320
- integration_count: rows.length,
321
- filters: clone(filters || {}),
322
- integrations: rows
323
- };
324
- }
325
-
326
- function exportIntegrationRegistrySnapshot(filters = {}) {
327
- return createIntegrationRegistrySnapshot(listIntegrations(filters), filters);
328
- }
329
-
330
- function validateIntegrationRegistrySnapshot(snapshot) {
331
- const entry = snapshot && typeof snapshot === "object" ? snapshot : {};
332
- const errors = [];
333
- if (!entry.snapshot_version) errors.push("snapshot.snapshot_version is required");
334
- if (!entry.generated_at) errors.push("snapshot.generated_at is required");
335
- if (!Number.isInteger(entry.integration_count) || entry.integration_count < 0) {
336
- errors.push("snapshot.integration_count must be a non-negative integer");
337
- }
338
- if (!Array.isArray(entry.integrations)) {
339
- errors.push("snapshot.integrations must be an array");
340
- } else if (entry.integration_count !== entry.integrations.length) {
341
- errors.push("snapshot.integration_count must match snapshot.integrations.length");
342
- }
343
- return {
344
- ok: errors.length === 0,
345
- errors
346
- };
347
- }
348
-
349
- function validateIntegrationSubmissionBundle(bundle) {
350
- const entry = bundle && typeof bundle === "object" ? bundle : {};
351
- const errors = [];
352
- if (!entry.bundle_version) {
353
- errors.push("submission_bundle.bundle_version is required");
354
- }
355
- if (!entry.manifest || typeof entry.manifest !== "object") {
356
- errors.push("submission_bundle.manifest is required");
357
- }
358
- if (!entry.registration_record || typeof entry.registration_record !== "object") {
359
- errors.push("submission_bundle.registration_record is required");
360
- }
361
- if (!entry.certification_pack || typeof entry.certification_pack !== "object") {
362
- errors.push("submission_bundle.certification_pack is required");
363
- }
364
- const submissionValidation = validateIntegrationSubmission(
365
- entry.manifest,
366
- entry.registration_record,
367
- entry.certification_pack
368
- );
369
- return {
370
- ok: errors.length === 0 && submissionValidation.ok,
371
- errors: errors.concat(submissionValidation.errors)
372
- };
373
- }
374
-
375
- function createIntegrationSubmissionBundle(bundleInput = {}, extras = {}) {
376
- const manifest = clone(bundleInput.manifest || {});
377
- const registrationRecord = clone(bundleInput.registration_record || {});
378
- const certificationPack = clone(bundleInput.certification_pack || {});
379
- const importedIntegration = importRegisteredIntegration(manifest, registrationRecord, extras);
380
- const snapshotEntry = clone(bundleInput.snapshot_entry || importedIntegration);
381
- return {
382
- bundle_version: "xytara/integration-submission-bundle/v1",
383
- manifest,
384
- registration_record: registrationRecord,
385
- certification_pack: certificationPack,
386
- snapshot_entry: snapshotEntry,
387
- notes: typeof bundleInput.notes === "string" ? bundleInput.notes : null
388
- };
389
- }
390
-
391
- function importIntegrationSubmissionBundle(bundleInput = {}, extras = {}) {
392
- const bundle = createIntegrationSubmissionBundle(bundleInput, extras);
393
- const validation = validateIntegrationSubmissionBundle(bundle);
394
- if (!validation.ok) {
395
- const error = new Error(`invalid integration submission bundle:\n${validation.errors.join("\n")}`);
396
- error.code = "invalid_integration_submission_bundle";
397
- error.validation = validation;
398
- throw error;
399
- }
400
- return bundle;
401
- }
402
-
403
- function createIntegrationRegistrySnapshotFromBundles(bundles, filters = {}, bundleExtras = {}) {
404
- const bundleList = Array.isArray(bundles) ? bundles : [];
405
- const integrations = bundleList.map((bundle) => importIntegrationSubmissionBundle(bundle, bundleExtras).snapshot_entry);
406
- return createIntegrationRegistrySnapshot(integrations, {
407
- ...clone(filters || {}),
408
- snapshot_source: "submission_bundle"
409
- });
410
- }
411
-
412
- function exportIntegrationSubmissionBundles(filters = {}) {
413
- return listIntegrations(filters)
414
- .filter((integration) => integration.source === "third_party_example")
415
- .map((integration) => {
416
- const registrationRecord = clone(INTEGRATION_REGISTRATION_RECORDS[integration.integration_id] || {});
417
- const certificationPack = {
418
- integration_id: integration.integration_id,
419
- adapter_id: integration.integration_id,
420
- adapter_class: integration.adapter_class,
421
- certification_state: integration.certification_state,
422
- certification_scope: clone(integration.certification_scope || []),
423
- verified_with: clone(integration.registration.verified_with || []),
424
- submitted_at: integration.registration.registered_at || new Date().toISOString(),
425
- submitted_by: integration.registration.registered_by || "unknown",
426
- last_verified_contract_version: "xytara/v1",
427
- notes: integration.registration.notes || null
428
- };
429
- const manifest = {
430
- adapter_id: integration.integration_id,
431
- adapter_class: integration.adapter_class,
432
- adapter_version: integration.adapter_version,
433
- interface_version: integration.interface_version,
434
- display_name: integration.display_name,
435
- description: integration.description,
436
- capabilities: clone(integration.capabilities || []),
437
- required_secrets: clone(integration.required_secrets || []),
438
- required_permissions: clone(integration.required_permissions || []),
439
- supported_profiles: clone(integration.supported_profiles || []),
440
- supported_regions: clone(integration.supported_regions || []),
441
- supported_settlement_modes: clone(integration.settlement_modes || []),
442
- pricing_basis: integration.pricing_basis,
443
- latency_class: integration.latency_class,
444
- registration_contract: {
445
- integration_id: integration.integration_id,
446
- integration_maturity: integration.integration_maturity,
447
- bundled: integration.registration.bundled,
448
- default_selection_enabled: integration.registration.default_selection_enabled,
449
- requires_explicit_selection: integration.registration.requires_explicit_selection
450
- },
451
- certification_contract: {
452
- certification_state: integration.certification_state,
453
- certification_scope: clone(integration.certification_scope || []),
454
- verified_with: clone(integration.registration.verified_with || []),
455
- last_verified_contract_version: "xytara/v1"
456
- },
457
- compatibility: clone(integration.compatibility || {}),
458
- health_contract: clone(integration.health_contract || {}),
459
- idempotency_contract: clone(integration.idempotency_contract || {}),
460
- failure_contract: clone(integration.failure_contract || {}),
461
- proof_contract: clone(integration.proof_contract || {})
462
- };
463
- return createIntegrationSubmissionBundle({
464
- manifest,
465
- registration_record: registrationRecord,
466
- certification_pack: certificationPack,
467
- snapshot_entry: integration,
468
- notes: integration.registration.notes || null
469
- }, {
470
- source: integration.source,
471
- protocols: clone(integration.protocols || []),
472
- execution_backends: clone(integration.execution_backends || []),
473
- adapter_lanes: clone(integration.adapter_lanes || []),
474
- task_refs: clone(integration.task_refs || []),
475
- workflow_refs: clone(integration.workflow_refs || [])
476
- });
477
- });
478
- }
479
-
480
- function createIntegrationSubmissionBundleSet(bundles, filters = {}, notes = null) {
481
- const bundleList = Array.isArray(bundles) ? bundles.map(clone) : [];
482
- return {
483
- bundle_set_version: "xytara/integration-submission-bundle-set/v1",
484
- generated_at: new Date().toISOString(),
485
- bundle_count: bundleList.length,
486
- filters: clone(filters || {}),
487
- bundles: bundleList,
488
- notes: typeof notes === "string" ? notes : null
489
- };
490
- }
491
-
492
- function validateIntegrationSubmissionBundleSet(bundleSet) {
493
- const entry = bundleSet && typeof bundleSet === "object" ? bundleSet : {};
494
- const errors = [];
495
- if (!entry.bundle_set_version) errors.push("bundle_set.bundle_set_version is required");
496
- if (!entry.generated_at) errors.push("bundle_set.generated_at is required");
497
- if (!Number.isInteger(entry.bundle_count) || entry.bundle_count < 0) {
498
- errors.push("bundle_set.bundle_count must be a non-negative integer");
499
- }
500
- if (!Array.isArray(entry.bundles)) {
501
- errors.push("bundle_set.bundles must be an array");
502
- } else if (entry.bundle_count !== entry.bundles.length) {
503
- errors.push("bundle_set.bundle_count must match bundle_set.bundles.length");
504
- } else {
505
- entry.bundles.forEach((bundle, index) => {
506
- const validation = validateIntegrationSubmissionBundle(bundle);
507
- if (!validation.ok) {
508
- validation.errors.forEach((error) => {
509
- errors.push(`bundle_set.bundles[${index}]: ${error}`);
510
- });
511
- }
512
- });
513
- }
514
- return {
515
- ok: errors.length === 0,
516
- errors
517
- };
518
- }
519
-
520
- function exportIntegrationSubmissionBundleSet(filters = {}, notes = null) {
521
- return createIntegrationSubmissionBundleSet(
522
- exportIntegrationSubmissionBundles(filters),
523
- filters,
524
- notes
525
- );
526
- }
527
-
528
- function summarizeCounts(values, fieldName) {
529
- return sortStrings(values).map((value) => ({
530
- [fieldName]: value,
531
- count: values.filter((entry) => entry === value).length
532
- }));
533
- }
534
-
535
- function summarizeStructuredCounts(entries, fields = []) {
536
- const rows = Array.isArray(entries) ? entries.filter((entry) => entry && typeof entry === "object") : [];
537
- const normalizedFields = Array.isArray(fields) ? fields.filter(Boolean) : [];
538
- const seen = new Map();
539
-
540
- rows.forEach((entry) => {
541
- const key = normalizedFields.map((field) => String(entry[field] || "")).join("::");
542
- if (!seen.has(key)) {
543
- const item = {};
544
- normalizedFields.forEach((field) => {
545
- item[field] = entry[field] || null;
546
- });
547
- item.count = 0;
548
- seen.set(key, item);
549
- }
550
- seen.get(key).count += 1;
551
- });
552
-
553
- return Array.from(seen.values()).sort((left, right) => {
554
- const leftKey = normalizedFields.map((field) => String(left[field] || "")).join("::");
555
- const rightKey = normalizedFields.map((field) => String(right[field] || "")).join("::");
556
- return leftKey.localeCompare(rightKey);
557
- });
558
- }
559
-
560
- function buildPromotionReadinessSummary(input = {}) {
561
- const registration = input.registration && typeof input.registration === "object" ? input.registration : {};
562
- const certification = input.certification && typeof input.certification === "object" ? input.certification : {};
563
- const integration = input.integration && typeof input.integration === "object" ? input.integration : {};
564
- const blockers = [];
565
- const registrationState = registration.registration_state || null;
566
- const certificationState = certification.certification_state || integration.certification_state || null;
567
- const maturity = integration.integration_maturity || null;
568
- const defaultSelectionEnabled = registration.default_selection_enabled === true;
569
- const requiresExplicitSelection = registration.requires_explicit_selection === true;
570
- const bundled = registration.bundled === true;
571
-
572
- if (!registrationState) blockers.push("registration_state_missing");
573
- if (!certificationState) blockers.push("certification_state_missing");
574
- if (!maturity) blockers.push("integration_maturity_missing");
575
- if (certificationState !== "certified") blockers.push("not_certified");
576
- if (maturity !== "production_default") blockers.push("not_marked_production_default");
577
- if (!defaultSelectionEnabled) blockers.push("default_selection_disabled");
578
- if (requiresExplicitSelection) blockers.push("still_requires_explicit_selection");
579
- if (!bundled) blockers.push("not_bundled_for_default_rollout");
580
-
581
- const reviewReady = registrationState === "staging_registered";
582
- const selectionReady = defaultSelectionEnabled || requiresExplicitSelection;
583
- const explicitSelectionReady = requiresExplicitSelection || defaultSelectionEnabled;
584
- const productionDefaultReady = blockers.length === 0;
585
-
586
- let posture = "unknown";
587
- if (productionDefaultReady) {
588
- posture = "production_default_ready";
589
- } else if (reviewReady && certificationState === "certified") {
590
- posture = "promotion_candidate";
591
- } else if (reviewReady) {
592
- posture = "staged_review";
593
- } else if (selectionReady) {
594
- posture = "selectable_non_default";
595
- }
596
-
597
- return {
598
- registration_state: registrationState,
599
- certification_state: certificationState,
600
- integration_maturity: maturity,
601
- selection_ready: selectionReady,
602
- explicit_selection_ready: explicitSelectionReady,
603
- default_eligible: defaultSelectionEnabled,
604
- production_default_ready: productionDefaultReady,
605
- review_ready: reviewReady,
606
- posture,
607
- blockers
608
- };
609
- }
610
-
611
- function summarizePromotionBlockerCategories(blockers = []) {
612
- const values = Array.isArray(blockers) ? blockers : [];
613
- const categories = [];
614
- if (values.some((entry) => entry === "registration_state_missing")) {
615
- categories.push({
616
- category: "registration",
617
- severity: "high",
618
- owner: "integration_author"
619
- });
620
- }
621
- if (values.some((entry) => entry === "certification_state_missing" || entry === "not_certified")) {
622
- categories.push({
623
- category: "certification",
624
- severity: "high",
625
- owner: "review_operator"
626
- });
627
- }
628
- if (values.some((entry) => entry === "integration_maturity_missing" || entry === "not_marked_production_default")) {
629
- categories.push({
630
- category: "maturity",
631
- severity: "medium",
632
- owner: "review_operator"
633
- });
634
- }
635
- if (values.some((entry) => entry === "default_selection_disabled" || entry === "still_requires_explicit_selection")) {
636
- categories.push({
637
- category: "selection",
638
- severity: "medium",
639
- owner: "platform_operator"
640
- });
641
- }
642
- if (values.some((entry) => entry === "not_bundled_for_default_rollout")) {
643
- categories.push({
644
- category: "rollout",
645
- severity: "low",
646
- owner: "release_operator"
647
- });
648
- }
649
- return summarizeStructuredCounts(categories, ["category", "severity", "owner"]);
650
- }
651
-
652
- function buildCertificationGapSummary(readiness = {}, integration = {}) {
653
- const blockers = Array.isArray(readiness.blockers) ? readiness.blockers : [];
654
- const certificationScope = Array.isArray(integration.certification_scope) ? integration.certification_scope.filter(Boolean) : [];
655
- const verifiedWith = integration.registration && Array.isArray(integration.registration.verified_with)
656
- ? integration.registration.verified_with.filter(Boolean)
657
- : [];
658
- const missingRequirements = [];
659
- const productionReady = readiness.production_default_ready === true;
660
-
661
- if (blockers.includes("certification_state_missing") || blockers.includes("not_certified")) {
662
- missingRequirements.push("certification_state");
663
- }
664
- if (!productionReady && certificationScope.length < 1) {
665
- missingRequirements.push("certification_scope");
666
- }
667
- if (!productionReady && verifiedWith.length < 1) {
668
- missingRequirements.push("verified_with");
669
- }
670
-
671
- return {
672
- certification_state: readiness.certification_state || null,
673
- certification_scope_count: certificationScope.length,
674
- verified_with_count: verifiedWith.length,
675
- missing_requirements: missingRequirements,
676
- certifiable: missingRequirements.length === 0
677
- };
678
- }
679
-
680
- function buildNextTransitionSummary(readiness = {}) {
681
- const blockers = Array.isArray(readiness.blockers) ? readiness.blockers : [];
682
- if (readiness.production_default_ready === true) {
683
- return {
684
- action: "maintain_production_default",
685
- reason: "integration already satisfies production-default posture",
686
- requirements: [],
687
- later_actions: []
688
- };
689
- }
690
- if (blockers.includes("registration_state_missing")) {
691
- return {
692
- action: "register_integration",
693
- reason: "integration is missing a registration state",
694
- requirements: ["registration_state"],
695
- later_actions: ["complete_certification", "promote_maturity", "enable_default_selection", "bundle_for_default_rollout"]
696
- };
697
- }
698
- if (blockers.includes("not_certified") || blockers.includes("certification_state_missing")) {
699
- return {
700
- action: "complete_certification",
701
- reason: "integration is not yet certified",
702
- requirements: ["certification_state"],
703
- later_actions: ["promote_maturity", "enable_default_selection", "bundle_for_default_rollout"]
704
- };
705
- }
706
- if (blockers.includes("not_marked_production_default") || blockers.includes("integration_maturity_missing")) {
707
- return {
708
- action: "promote_maturity",
709
- reason: "integration maturity is not yet aligned with production default rollout",
710
- requirements: ["integration_maturity"],
711
- later_actions: ["enable_default_selection", "bundle_for_default_rollout"]
712
- };
713
- }
714
- if (blockers.includes("default_selection_disabled") || blockers.includes("still_requires_explicit_selection")) {
715
- return {
716
- action: "enable_default_selection",
717
- reason: "integration remains explicit-selection only",
718
- requirements: ["default_selection_enabled", "requires_explicit_selection=false"],
719
- later_actions: blockers.includes("not_bundled_for_default_rollout") ? ["bundle_for_default_rollout"] : []
720
- };
721
- }
722
- if (blockers.includes("not_bundled_for_default_rollout")) {
723
- return {
724
- action: "bundle_for_default_rollout",
725
- reason: "integration is not yet bundled for production default rollout",
726
- requirements: ["bundled=true"],
727
- later_actions: []
728
- };
729
- }
730
- return {
731
- action: "review_manually",
732
- reason: "integration posture needs operator review",
733
- requirements: [],
734
- later_actions: []
735
- };
736
- }
737
-
738
- function buildPromotionRecommendationSummary(readiness = {}) {
739
- const nextTransition = buildNextTransitionSummary(readiness);
740
- if (readiness.production_default_ready === true) {
741
- return {
742
- recommendation: "eligible_for_production_default",
743
- rationale: "integration is ready for production-default posture"
744
- };
745
- }
746
- if (readiness.review_ready === true && readiness.default_eligible === false) {
747
- return {
748
- recommendation: "keep_staged_until_requirements_clear",
749
- rationale: nextTransition.reason
750
- };
751
- }
752
- if (readiness.review_ready === true) {
753
- return {
754
- recommendation: "review_for_promotion",
755
- rationale: nextTransition.reason
756
- };
757
- }
758
- return {
759
- recommendation: "complete_prerequisites_first",
760
- rationale: nextTransition.reason
761
- };
762
- }
763
-
764
- const PROMOTION_ACTION_DEFINITIONS = {
765
- register_integration: {
766
- action: "register_integration",
767
- title: "Register Integration",
768
- stage: "registration",
769
- description: "Move an integration into an explicit staged registration posture."
770
- },
771
- complete_certification: {
772
- action: "complete_certification",
773
- title: "Complete Certification",
774
- stage: "certification",
775
- description: "Mark the integration as certified for the current public contract."
776
- },
777
- promote_maturity: {
778
- action: "promote_maturity",
779
- title: "Promote Maturity",
780
- stage: "maturity",
781
- description: "Align integration maturity with production-default rollout posture."
782
- },
783
- enable_default_selection: {
784
- action: "enable_default_selection",
785
- title: "Enable Default Selection",
786
- stage: "selection",
787
- description: "Allow the integration to participate in default selection instead of explicit-only use."
788
- },
789
- bundle_for_default_rollout: {
790
- action: "bundle_for_default_rollout",
791
- title: "Bundle For Default Rollout",
792
- stage: "rollout",
793
- description: "Mark the integration as bundled for production-default rollout."
794
- },
795
- maintain_production_default: {
796
- action: "maintain_production_default",
797
- title: "Maintain Production Default",
798
- stage: "steady_state",
799
- description: "Confirm the integration already satisfies production-default posture."
800
- }
801
- };
802
-
803
- function getPromotionActionDefinition(action) {
804
- const lookup = String(action || "").trim();
805
- return PROMOTION_ACTION_DEFINITIONS[lookup] || null;
806
- }
807
-
808
- function clonePromotionSubject(summary = {}) {
809
- return {
810
- registration: clone(summary.registration || {}),
811
- certification_state: summary.certification_state || null,
812
- integration_maturity: summary.integration_maturity || null
813
- };
814
- }
815
-
816
- function simulatePromotionActionSubject(summary = {}, action) {
817
- const subject = clonePromotionSubject(summary);
818
- switch (action) {
819
- case "register_integration":
820
- subject.registration.registration_state = "staging_registered";
821
- if (subject.registration.default_selection_enabled !== true) {
822
- subject.registration.default_selection_enabled = false;
823
- }
824
- if (subject.registration.requires_explicit_selection !== false) {
825
- subject.registration.requires_explicit_selection = true;
826
- }
827
- break;
828
- case "complete_certification":
829
- subject.certification_state = "certified";
830
- break;
831
- case "promote_maturity":
832
- subject.integration_maturity = "production_default";
833
- break;
834
- case "enable_default_selection":
835
- subject.registration.default_selection_enabled = true;
836
- subject.registration.requires_explicit_selection = false;
837
- break;
838
- case "bundle_for_default_rollout":
839
- subject.registration.bundled = true;
840
- break;
841
- case "maintain_production_default":
842
- break;
843
- default:
844
- break;
845
- }
846
- return subject;
847
- }
848
-
849
- function buildPromotionActionResultingReadiness(summary = {}, subject = {}) {
850
- return buildPromotionReadinessSummary({
851
- registration: subject.registration,
852
- certification: {
853
- certification_state: subject.certification_state || summary.certification_state || null
854
- },
855
- integration: {
856
- integration_maturity: subject.integration_maturity || summary.integration_maturity || null
857
- }
858
- });
859
- }
860
-
861
- function buildPromotionActionStateChanges(current = {}, simulated = {}) {
862
- const changes = [];
863
- const currentRegistration = current.registration || {};
864
- const simulatedRegistration = simulated.registration || {};
865
- const fieldPairs = [
866
- ["registration.registration_state", currentRegistration.registration_state, simulatedRegistration.registration_state],
867
- ["registration.default_selection_enabled", currentRegistration.default_selection_enabled, simulatedRegistration.default_selection_enabled],
868
- ["registration.requires_explicit_selection", currentRegistration.requires_explicit_selection, simulatedRegistration.requires_explicit_selection],
869
- ["registration.bundled", currentRegistration.bundled, simulatedRegistration.bundled],
870
- ["certification_state", current.certification_state, simulated.certification_state],
871
- ["integration_maturity", current.integration_maturity, simulated.integration_maturity]
872
- ];
873
- fieldPairs.forEach(([field, fromValue, toValue]) => {
874
- if (fromValue !== toValue) {
875
- changes.push({
876
- field,
877
- from: fromValue === undefined ? null : fromValue,
878
- to: toValue === undefined ? null : toValue
879
- });
880
- }
881
- });
882
- return changes;
883
- }
884
-
885
- function validatePromotionActionRequest(request = {}) {
886
- const entry = request && typeof request === "object" && !Array.isArray(request) ? request : {};
887
- const errors = [];
888
- const integrationId = String(entry.integration_id || "").trim();
889
- const action = String(entry.action || "").trim();
890
- if (!integrationId) {
891
- errors.push("promotion_action_request.integration_id is required");
892
- }
893
- if (!action) {
894
- errors.push("promotion_action_request.action is required");
895
- } else if (!getPromotionActionDefinition(action)) {
896
- errors.push("promotion_action_request.action must be a supported promotion action");
897
- }
898
- return {
899
- ok: errors.length === 0,
900
- errors,
901
- request: {
902
- integration_id: integrationId || null,
903
- action: action || null
904
- }
905
- };
906
- }
907
-
908
- function summarizeIntegrationPromotionActionPreview(request = {}) {
909
- const validation = validatePromotionActionRequest(request);
910
- if (!validation.ok) {
911
- return {
912
- ok: false,
913
- reason: "invalid_promotion_action_request",
914
- errors: validation.errors
915
- };
916
- }
917
- const workflow = summarizeIntegrationPromotionWorkflow(validation.request.integration_id);
918
- if (!workflow.ok) {
919
- return workflow;
920
- }
921
-
922
- const action = validation.request.action;
923
- const definition = getPromotionActionDefinition(action);
924
- const currentSubject = clonePromotionSubject(workflow);
925
- const simulatedSubject = simulatePromotionActionSubject(workflow, action);
926
- const resultingReadiness = buildPromotionActionResultingReadiness(workflow, simulatedSubject);
927
- const stateChanges = buildPromotionActionStateChanges(currentSubject, simulatedSubject);
928
- const currentNextAction = workflow.next_transition && workflow.next_transition.action
929
- ? workflow.next_transition.action
930
- : null;
931
- const currentLaterActions = Array.isArray(workflow.next_transition && workflow.next_transition.later_actions)
932
- ? workflow.next_transition.later_actions
933
- : [];
934
- const validNow = currentNextAction === action || currentLaterActions.includes(action);
935
- const invalidReasons = [];
936
- if (!validNow) {
937
- invalidReasons.push(action === "maintain_production_default"
938
- ? "integration_is_not_yet_production_default_ready"
939
- : "action_is_not_currently_recommended_from_present_posture");
940
- }
941
-
942
- return {
943
- ok: true,
944
- integration_id: workflow.integration_id,
945
- display_name: workflow.display_name,
946
- adapter_class: workflow.adapter_class,
947
- source: workflow.source,
948
- request: clone(validation.request),
949
- action: clone(definition),
950
- current_posture: {
951
- registration_state: workflow.registration.registration_state || null,
952
- certification_state: workflow.certification_state || null,
953
- integration_maturity: workflow.integration_maturity || null,
954
- promotion_readiness: clone(workflow.promotion_readiness || {})
955
- },
956
- valid_now: validNow,
957
- is_recommended_next: currentNextAction === action,
958
- invalid_reasons: invalidReasons,
959
- requirements: currentNextAction === action
960
- ? clone(workflow.next_transition.requirements || [])
961
- : clone(buildNextTransitionSummary(resultingReadiness).requirements || []),
962
- blockers: clone(workflow.promotion_readiness.blockers || []),
963
- blocker_categories: clone(workflow.blocker_categories || []),
964
- resulting_posture: {
965
- registration_state: simulatedSubject.registration.registration_state || null,
966
- certification_state: simulatedSubject.certification_state || null,
967
- integration_maturity: simulatedSubject.integration_maturity || null,
968
- promotion_readiness: clone(resultingReadiness)
969
- },
970
- state_changes: stateChanges,
971
- current_transition: clone(workflow.next_transition || {}),
972
- resulting_transition: buildNextTransitionSummary(resultingReadiness)
973
- };
974
- }
975
-
976
- function summarizeIntegrationPromotionActionSet(integrationOrId) {
977
- const workflow = summarizeIntegrationPromotionWorkflow(integrationOrId);
978
- if (!workflow.ok) {
979
- return workflow;
980
- }
981
- const actionOrder = [
982
- workflow.next_transition && workflow.next_transition.action ? workflow.next_transition.action : null,
983
- ...(Array.isArray(workflow.next_transition && workflow.next_transition.later_actions)
984
- ? workflow.next_transition.later_actions
985
- : []),
986
- "maintain_production_default"
987
- ].filter(Boolean);
988
- const actions = sortStrings(actionOrder).map((action) => summarizeIntegrationPromotionActionPreview({
989
- integration_id: workflow.integration_id,
990
- action
991
- }));
992
- return {
993
- ...workflow,
994
- action_count: actions.length,
995
- valid_now_count: actions.filter((entry) => entry.valid_now === true).length,
996
- actions
997
- };
998
- }
999
-
1000
- function summarizeIntegrationPromotionActionSetList(filters = {}) {
1001
- const integrations = listIntegrations(filters).map((integration) => summarizeIntegrationPromotionActionSet(integration));
1002
- return {
1003
- ok: true,
1004
- integration_count: integrations.length,
1005
- valid_now_count: integrations.reduce((total, entry) => total + Number(entry.valid_now_count || 0), 0),
1006
- recommended_actions: summarizeCounts(
1007
- integrations
1008
- .map((entry) => entry.next_transition && entry.next_transition.action)
1009
- .filter(Boolean),
1010
- "action"
1011
- ),
1012
- valid_actions: summarizeCounts(
1013
- integrations
1014
- .flatMap((entry) => Array.isArray(entry.actions) ? entry.actions : [])
1015
- .filter((entry) => entry.valid_now === true)
1016
- .map((entry) => entry.request && entry.request.action)
1017
- .filter(Boolean),
1018
- "action"
1019
- ),
1020
- integrations
1021
- };
1022
- }
1023
-
1024
- function buildPromotionActionQueues(integrations = []) {
1025
- const rows = Array.isArray(integrations) ? integrations.filter((entry) => entry && entry.next_transition) : [];
1026
- const groups = new Map();
1027
-
1028
- rows.forEach((entry) => {
1029
- const action = entry.next_transition && entry.next_transition.action
1030
- ? entry.next_transition.action
1031
- : "review_manually";
1032
- if (!groups.has(action)) {
1033
- groups.set(action, []);
1034
- }
1035
- groups.get(action).push(entry);
1036
- });
1037
-
1038
- return Array.from(groups.keys()).sort().map((action) => {
1039
- const entries = groups.get(action) || [];
1040
- const blockerEntries = entries.flatMap((entry) => entry.blocker_categories || []);
1041
- return {
1042
- action,
1043
- count: entries.length,
1044
- recommendation_counts: summarizeCounts(
1045
- entries.map((entry) => entry.promotion_recommendation && entry.promotion_recommendation.recommendation).filter(Boolean),
1046
- "recommendation"
1047
- ),
1048
- owner_queue: summarizeCounts(
1049
- blockerEntries.map((entry) => entry.owner).filter(Boolean),
1050
- "owner"
1051
- ),
1052
- severity_queue: summarizeCounts(
1053
- blockerEntries.map((entry) => entry.severity).filter(Boolean),
1054
- "severity"
1055
- ),
1056
- integration_ids: entries.map((entry) => entry.integration_id).filter(Boolean).sort(),
1057
- integrations: entries.map((entry) => ({
1058
- integration_id: entry.integration_id,
1059
- display_name: entry.display_name,
1060
- adapter_class: entry.adapter_class,
1061
- recommendation: entry.promotion_recommendation && entry.promotion_recommendation.recommendation,
1062
- review_ready: entry.promotion_readiness && entry.promotion_readiness.review_ready === true,
1063
- production_default_ready: entry.promotion_readiness && entry.promotion_readiness.production_default_ready === true
1064
- }))
1065
- };
1066
- });
1067
- }
1068
-
1069
- function buildSubmissionBundleReviewWarnings(bundle) {
1070
- const warnings = [];
1071
- const registrationRecord = bundle && bundle.registration_record && typeof bundle.registration_record === "object"
1072
- ? bundle.registration_record
1073
- : {};
1074
- const certificationPack = bundle && bundle.certification_pack && typeof bundle.certification_pack === "object"
1075
- ? bundle.certification_pack
1076
- : {};
1077
-
1078
- if (registrationRecord.registration_state === "staging_registered") {
1079
- warnings.push("integration is staging-registered and should be reviewed before broader promotion");
1080
- }
1081
- if (registrationRecord.requires_explicit_selection === true) {
1082
- warnings.push("integration requires explicit selection and should not be treated as default");
1083
- }
1084
- if (registrationRecord.default_selection_enabled !== true) {
1085
- warnings.push("integration is not currently eligible for default selection");
1086
- }
1087
- if (certificationPack.certification_state && certificationPack.certification_state !== "certified") {
1088
- warnings.push("integration is not yet fully certified");
1089
- }
1090
-
1091
- return warnings;
1092
- }
1093
-
1094
- function summarizeIntegrationSubmissionBundleReview(bundleInput = {}) {
1095
- const bundle = clone(bundleInput || {});
1096
- const validation = validateIntegrationSubmissionBundle(bundle);
1097
- const snapshotEntry = bundle.snapshot_entry && typeof bundle.snapshot_entry === "object"
1098
- ? clone(bundle.snapshot_entry)
1099
- : {};
1100
- const manifest = bundle.manifest && typeof bundle.manifest === "object" ? bundle.manifest : {};
1101
- const registrationRecord = bundle.registration_record && typeof bundle.registration_record === "object"
1102
- ? bundle.registration_record
1103
- : {};
1104
- const certificationPack = bundle.certification_pack && typeof bundle.certification_pack === "object"
1105
- ? bundle.certification_pack
1106
- : {};
1107
- const integrationId = registrationRecord.integration_id || manifest.adapter_id || snapshotEntry.integration_id || null;
1108
- const adapterClass = registrationRecord.adapter_class || manifest.adapter_class || snapshotEntry.adapter_class || null;
1109
- const protocols = sortStrings(snapshotEntry.protocols);
1110
- const settlementModes = sortStrings(snapshotEntry.settlement_modes || manifest.supported_settlement_modes);
1111
- const taskRefs = sortStrings(snapshotEntry.task_refs);
1112
- const workflowRefs = sortStrings(snapshotEntry.workflow_refs);
1113
- const warnings = buildSubmissionBundleReviewWarnings(bundle);
1114
- const promotionReadiness = buildPromotionReadinessSummary({
1115
- registration: {
1116
- registration_state: registrationRecord.registration_state || null,
1117
- bundled: registrationRecord.bundled === true,
1118
- default_selection_enabled: registrationRecord.default_selection_enabled === true,
1119
- requires_explicit_selection: registrationRecord.requires_explicit_selection === true
1120
- },
1121
- certification: {
1122
- certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null
1123
- },
1124
- integration: {
1125
- integration_maturity: registrationRecord.integration_maturity || snapshotEntry.integration_maturity || null,
1126
- certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null
1127
- }
1128
- });
1129
-
1130
- return {
1131
- ok: validation.ok,
1132
- review_kind: "integration_submission_bundle",
1133
- validation,
1134
- integration: {
1135
- integration_id: integrationId,
1136
- display_name: manifest.display_name || snapshotEntry.display_name || null,
1137
- adapter_id: manifest.adapter_id || registrationRecord.adapter_id || null,
1138
- adapter_class: adapterClass,
1139
- adapter_version: manifest.adapter_version || snapshotEntry.adapter_version || null,
1140
- source: snapshotEntry.source || null,
1141
- certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null,
1142
- integration_maturity: registrationRecord.integration_maturity || snapshotEntry.integration_maturity || null,
1143
- protocols,
1144
- settlement_modes: settlementModes,
1145
- task_refs: taskRefs,
1146
- workflow_refs: workflowRefs
1147
- },
1148
- registration: {
1149
- registration_state: registrationRecord.registration_state || null,
1150
- bundled: registrationRecord.bundled === true,
1151
- default_selection_enabled: registrationRecord.default_selection_enabled === true,
1152
- requires_explicit_selection: registrationRecord.requires_explicit_selection === true,
1153
- selection_priority: Number.isFinite(Number(registrationRecord.selection_priority))
1154
- ? Number(registrationRecord.selection_priority)
1155
- : null,
1156
- registered_at: registrationRecord.registered_at || null,
1157
- registered_by: registrationRecord.registered_by || null
1158
- },
1159
- certification: {
1160
- certification_state: certificationPack.certification_state || null,
1161
- certification_scope: sortStrings(certificationPack.certification_scope),
1162
- verified_with: sortStrings(certificationPack.verified_with),
1163
- submitted_at: certificationPack.submitted_at || null,
1164
- submitted_by: certificationPack.submitted_by || null
1165
- },
1166
- promotion_readiness: promotionReadiness,
1167
- review_summary: {
1168
- warning_count: warnings.length,
1169
- warnings,
1170
- capability_count: Array.isArray(manifest.capabilities) ? manifest.capabilities.length : 0,
1171
- protocol_count: protocols.length,
1172
- settlement_mode_count: settlementModes.length,
1173
- task_count: taskRefs.length,
1174
- workflow_count: workflowRefs.length,
1175
- selectable_via_explicit_request: registrationRecord.requires_explicit_selection === true
1176
- || registrationRecord.default_selection_enabled === true,
1177
- default_eligible: registrationRecord.default_selection_enabled === true,
1178
- production_default_ready: promotionReadiness.production_default_ready
1179
- }
1180
- };
1181
- }
1182
-
1183
- function summarizeIntegrationSubmissionBundleSetReview(bundleSetInput = {}) {
1184
- const bundleSet = clone(bundleSetInput || {});
1185
- const validation = validateIntegrationSubmissionBundleSet(bundleSet);
1186
- const bundleReviews = (Array.isArray(bundleSet.bundles) ? bundleSet.bundles : []).map((bundle) =>
1187
- summarizeIntegrationSubmissionBundleReview(bundle)
1188
- );
1189
- const adapterClasses = bundleReviews.map((review) => review.integration.adapter_class).filter(Boolean);
1190
- const registrationStates = bundleReviews.map((review) => review.registration.registration_state).filter(Boolean);
1191
- const certificationStates = bundleReviews.map((review) => review.certification.certification_state).filter(Boolean);
1192
-
1193
- return {
1194
- ok: validation.ok,
1195
- review_kind: "integration_submission_bundle_set",
1196
- validation,
1197
- bundle_set_version: bundleSet.bundle_set_version || null,
1198
- bundle_count: Array.isArray(bundleSet.bundles) ? bundleSet.bundles.length : 0,
1199
- generated_at: bundleSet.generated_at || null,
1200
- filters: clone(bundleSet.filters || {}),
1201
- notes: typeof bundleSet.notes === "string" ? bundleSet.notes : null,
1202
- review_summary: {
1203
- warning_count: bundleReviews.reduce((total, review) => total + review.review_summary.warning_count, 0),
1204
- explicit_selection_required_count: bundleReviews.filter((review) => review.registration.requires_explicit_selection).length,
1205
- default_eligible_count: bundleReviews.filter((review) => review.registration.default_selection_enabled).length,
1206
- production_default_ready_count: bundleReviews.filter((review) => review.promotion_readiness.production_default_ready).length,
1207
- review_ready_count: bundleReviews.filter((review) => review.promotion_readiness.review_ready).length,
1208
- bundled_count: bundleReviews.filter((review) => review.registration.bundled).length,
1209
- adapter_classes: summarizeCounts(adapterClasses, "adapter_class"),
1210
- registration_states: summarizeCounts(registrationStates, "registration_state"),
1211
- certification_states: summarizeCounts(certificationStates, "certification_state"),
1212
- postures: summarizeCounts(bundleReviews.map((review) => review.promotion_readiness.posture).filter(Boolean), "posture")
1213
- },
1214
- bundles: bundleReviews
1215
- };
1216
- }
1217
-
1218
- function summarizeIntegrationRegistrySnapshotReview(snapshotInput = {}) {
1219
- const snapshot = clone(snapshotInput || {});
1220
- const validation = validateIntegrationRegistrySnapshot(snapshot);
1221
- const integrations = Array.isArray(snapshot.integrations) ? snapshot.integrations : [];
1222
- const adapterClasses = integrations.map((integration) => integration.adapter_class).filter(Boolean);
1223
- const sources = integrations.map((integration) => integration.source).filter(Boolean);
1224
- const certificationStates = integrations.map((integration) => integration.certification_state).filter(Boolean);
1225
- const registrationStates = integrations
1226
- .map((integration) => integration.registration && integration.registration.registration_state)
1227
- .filter(Boolean);
1228
- const promotionReviews = integrations.map((integration) => buildPromotionReadinessSummary({
1229
- registration: integration.registration,
1230
- certification: {
1231
- certification_state: integration.certification_state || null
1232
- },
1233
- integration
1234
- }));
1235
-
1236
- return {
1237
- ok: validation.ok,
1238
- review_kind: "integration_registry_snapshot",
1239
- validation,
1240
- snapshot_version: snapshot.snapshot_version || null,
1241
- integration_count: integrations.length,
1242
- generated_at: snapshot.generated_at || null,
1243
- filters: clone(snapshot.filters || {}),
1244
- review_summary: {
1245
- production_default_count: integrations.filter((integration) => integration.integration_maturity === "production_default").length,
1246
- staged_registration_count: integrations.filter((integration) => integration.registration && integration.registration.registration_state === "staging_registered").length,
1247
- explicit_selection_required_count: integrations.filter((integration) => integration.registration && integration.registration.requires_explicit_selection === true).length,
1248
- default_selection_enabled_count: integrations.filter((integration) => integration.registration && integration.registration.default_selection_enabled === true).length,
1249
- production_default_ready_count: promotionReviews.filter((review) => review.production_default_ready).length,
1250
- review_ready_count: promotionReviews.filter((review) => review.review_ready).length,
1251
- adapter_classes: summarizeCounts(adapterClasses, "adapter_class"),
1252
- sources: summarizeCounts(sources, "source"),
1253
- certification_states: summarizeCounts(certificationStates, "certification_state"),
1254
- registration_states: summarizeCounts(registrationStates, "registration_state"),
1255
- postures: summarizeCounts(promotionReviews.map((review) => review.posture).filter(Boolean), "posture")
1256
- }
1257
- };
1258
- }
1259
-
1260
- function summarizeIntegrationPromotionReadiness(integrationOrId) {
1261
- const integration = typeof integrationOrId === "string"
1262
- ? getIntegration(integrationOrId)
1263
- : clone(integrationOrId || null);
1264
- if (!integration) {
1265
- return {
1266
- ok: false,
1267
- reason: "integration_not_found"
1268
- };
1269
- }
1270
- return {
1271
- ok: true,
1272
- integration_id: integration.integration_id,
1273
- display_name: integration.display_name,
1274
- adapter_class: integration.adapter_class,
1275
- source: integration.source,
1276
- registration: clone(integration.registration || {}),
1277
- certification_state: integration.certification_state || null,
1278
- integration_maturity: integration.integration_maturity || null,
1279
- promotion_readiness: buildPromotionReadinessSummary({
1280
- registration: integration.registration,
1281
- certification: {
1282
- certification_state: integration.certification_state || null
1283
- },
1284
- integration
1285
- })
1286
- };
1287
- }
1288
-
1289
- function summarizeIntegrationPromotionWorkflow(integrationOrId) {
1290
- const summary = summarizeIntegrationPromotionReadiness(integrationOrId);
1291
- if (!summary.ok) {
1292
- return summary;
1293
- }
1294
- const readiness = clone(summary.promotion_readiness || {});
1295
- return {
1296
- ...summary,
1297
- certification_gaps: buildCertificationGapSummary(readiness, summary),
1298
- blocker_categories: summarizePromotionBlockerCategories(readiness.blockers),
1299
- next_transition: buildNextTransitionSummary(readiness),
1300
- promotion_recommendation: buildPromotionRecommendationSummary(readiness)
1301
- };
1302
- }
1303
-
1304
- function summarizeIntegrationPromotionWorkflowList(filters = {}) {
1305
- const integrations = listIntegrations(filters).map((integration) => summarizeIntegrationPromotionWorkflow(integration));
1306
- const blockerCategoryEntries = integrations.flatMap((entry) => entry.blocker_categories || []);
1307
- return {
1308
- ok: true,
1309
- integration_count: integrations.length,
1310
- review_ready_count: integrations.filter((entry) => entry.promotion_readiness.review_ready).length,
1311
- production_default_ready_count: integrations.filter((entry) => entry.promotion_readiness.production_default_ready).length,
1312
- certifiable_count: integrations.filter((entry) => entry.certification_gaps.certifiable).length,
1313
- next_actions: summarizeCounts(
1314
- integrations.map((entry) => entry.next_transition.action).filter(Boolean),
1315
- "action"
1316
- ),
1317
- recommendations: summarizeCounts(
1318
- integrations.map((entry) => entry.promotion_recommendation.recommendation).filter(Boolean),
1319
- "recommendation"
1320
- ),
1321
- blocker_categories: summarizeStructuredCounts(
1322
- blockerCategoryEntries,
1323
- ["category", "severity", "owner"]
1324
- ),
1325
- owner_queue: summarizeCounts(
1326
- blockerCategoryEntries.map((entry) => entry.owner).filter(Boolean),
1327
- "owner"
1328
- ),
1329
- severity_queue: summarizeCounts(
1330
- blockerCategoryEntries.map((entry) => entry.severity).filter(Boolean),
1331
- "severity"
1332
- ),
1333
- next_action_queues: buildPromotionActionQueues(integrations),
1334
- integrations
1335
- };
1336
- }
1337
-
1338
- function buildBuiltInIntegrations() {
1339
- const httpTaskRefs = collectTaskRefsByAdapter("http");
1340
- const mcpTaskRefs = collectTaskRefsByAdapter("mcp");
1341
- const chainTaskRefs = collectTaskRefsByAdapter("chain");
1342
- const settlementModes = (Array.isArray(catalog.settlement_profiles) ? catalog.settlement_profiles : []).map((profile) => profile.mode);
1343
-
1344
- return [
1345
- {
1346
- integration_id: "builtin.execution.http",
1347
- display_name: "Built-In HTTP Execution",
1348
- description: "Default execution path for task and workflow lanes served directly by xytara.",
1349
- adapter_class: "execution_adapter",
1350
- adapter_version: "1.4.0",
1351
- interface_version: "commerce-adapter-interface/v1",
1352
- bundled: true,
1353
- source: "builtin",
1354
- status: "available",
1355
- certification_state: "certified",
1356
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1357
- integration_maturity: "production_default",
1358
- selection_priority: 100,
1359
- capabilities: sortStrings(
1360
- (Array.isArray(catalog.tasks) ? catalog.tasks : [])
1361
- .filter((task) => Array.isArray(task.adapters) && task.adapters.includes("http"))
1362
- .flatMap((task) => task.capabilities || [])
1363
- ),
1364
- protocols: [],
1365
- settlement_modes: [],
1366
- execution_backends: ["http"],
1367
- adapter_lanes: ["http"],
1368
- task_refs: sortStrings(httpTaskRefs),
1369
- workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(httpTaskRefs)),
1370
- required_secrets: [],
1371
- required_permissions: [],
1372
- supported_profiles: ["default"],
1373
- supported_regions: ["global"],
1374
- pricing_basis: "per_task",
1375
- latency_class: "mixed",
1376
- proof_contract: {
1377
- emits_proof_compatible_facts: true,
1378
- proof_mode: "execution_facts_only"
1379
- },
1380
- health_contract: {
1381
- check_kind: "internal",
1382
- supports_readiness: true
1383
- },
1384
- idempotency_contract: {
1385
- strategy: "command_quote_binding",
1386
- scope: "task_execution"
1387
- },
1388
- failure_contract: {
1389
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
1390
- retryable_categories: ["timeout", "upstream_unavailable"]
1391
- },
1392
- compatibility: {
1393
- node: ">=18",
1394
- commerce_contract: "xytara/v1"
1395
- },
1396
- operational_readiness: {
1397
- supports_default_selection: true,
1398
- supports_forced_selection: true,
1399
- lifecycle: "managed_builtin",
1400
- health_source: "internal"
1401
- },
1402
- selection_hints: {
1403
- default_for_task_refs: sortStrings(httpTaskRefs),
1404
- default_for_protocols: [],
1405
- default_for_settlement_modes: []
1406
- }
1407
- },
1408
- {
1409
- integration_id: "builtin.protocol.mcp",
1410
- display_name: "Built-In MCP Protocol Lane",
1411
- description: "Built-in machine protocol lane for MCP tool discovery and invocation through the commerce flow.",
1412
- adapter_class: "agent_protocol_adapter",
1413
- adapter_version: "1.4.0",
1414
- interface_version: "commerce-adapter-interface/v1",
1415
- bundled: true,
1416
- source: "builtin",
1417
- status: "available",
1418
- certification_state: "certified",
1419
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1420
- integration_maturity: "production_default",
1421
- selection_priority: 80,
1422
- capabilities: ["adapter.mcp.invoke"],
1423
- protocols: ["mcp"],
1424
- settlement_modes: [],
1425
- execution_backends: ["mcp"],
1426
- adapter_lanes: ["mcp"],
1427
- task_refs: sortStrings(mcpTaskRefs),
1428
- workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(mcpTaskRefs)),
1429
- required_secrets: [],
1430
- required_permissions: [],
1431
- supported_profiles: ["default"],
1432
- supported_regions: ["global"],
1433
- pricing_basis: "per_task",
1434
- latency_class: "near_real_time",
1435
- proof_contract: {
1436
- emits_proof_compatible_facts: true,
1437
- proof_mode: "protocol_invocation_facts"
1438
- },
1439
- health_contract: {
1440
- check_kind: "internal",
1441
- supports_readiness: true
1442
- },
1443
- idempotency_contract: {
1444
- strategy: "quote_bound_invocation",
1445
- scope: "protocol_invocation"
1446
- },
1447
- failure_contract: {
1448
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
1449
- retryable_categories: ["timeout", "upstream_unavailable"]
1450
- },
1451
- compatibility: {
1452
- node: ">=18",
1453
- commerce_contract: "xytara/v1"
1454
- },
1455
- operational_readiness: {
1456
- supports_default_selection: true,
1457
- supports_forced_selection: true,
1458
- lifecycle: "managed_builtin",
1459
- health_source: "internal"
1460
- },
1461
- selection_hints: {
1462
- default_for_task_refs: sortStrings(mcpTaskRefs),
1463
- default_for_protocols: ["mcp"],
1464
- default_for_settlement_modes: []
1465
- }
1466
- },
1467
- {
1468
- integration_id: "builtin.payment.x402",
1469
- display_name: "Built-In x402 Payment Admission",
1470
- description: "Built-in exact-payment challenge lane for x402-style machine payment admission.",
1471
- adapter_class: "payment_rail_adapter",
1472
- adapter_version: "1.4.0",
1473
- interface_version: "commerce-adapter-interface/v1",
1474
- bundled: true,
1475
- source: "builtin",
1476
- status: "available",
1477
- certification_state: "certified",
1478
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1479
- integration_maturity: "production_default",
1480
- selection_priority: 60,
1481
- capabilities: ["payment.admission", "payment.challenge", "payment.exact"],
1482
- protocols: ["x402"],
1483
- settlement_modes: sortStrings(settlementModes),
1484
- execution_backends: [],
1485
- adapter_lanes: ["x402"],
1486
- task_refs: [],
1487
- workflow_refs: [],
1488
- required_secrets: [],
1489
- required_permissions: [],
1490
- supported_profiles: ["default"],
1491
- supported_regions: ["global"],
1492
- pricing_basis: "quote_then_settle",
1493
- latency_class: "near_real_time",
1494
- proof_contract: {
1495
- emits_proof_compatible_facts: true,
1496
- proof_mode: "payment_admission_facts"
1497
- },
1498
- health_contract: {
1499
- check_kind: "internal",
1500
- supports_readiness: true
1501
- },
1502
- idempotency_contract: {
1503
- strategy: "quote_id",
1504
- scope: "payment_admission"
1505
- },
1506
- failure_contract: {
1507
- categories: ["invalid_input", "quote_expired", "payment_missing"],
1508
- retryable_categories: []
1509
- },
1510
- compatibility: {
1511
- node: ">=18",
1512
- commerce_contract: "xytara/v1"
1513
- },
1514
- operational_readiness: {
1515
- supports_default_selection: true,
1516
- supports_forced_selection: true,
1517
- lifecycle: "managed_builtin",
1518
- health_source: "internal"
1519
- },
1520
- selection_hints: {
1521
- default_for_task_refs: [],
1522
- default_for_protocols: ["x402"],
1523
- default_for_settlement_modes: sortStrings(settlementModes)
1524
- }
1525
- },
1526
- {
1527
- integration_id: "builtin.payment.l402",
1528
- display_name: "Built-In L402 Payment Admission",
1529
- description: "Built-in L402-style Lightning payment admission through a gateway-signed payment front.",
1530
- adapter_class: "payment_rail_adapter",
1531
- adapter_version: "1.4.0",
1532
- interface_version: "commerce-adapter-interface/v1",
1533
- bundled: true,
1534
- source: "builtin",
1535
- status: "available",
1536
- certification_state: "certified",
1537
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1538
- integration_maturity: "production_supported",
1539
- selection_priority: 65,
1540
- capabilities: ["payment.admission", "payment.challenge", "payment.permissionless_front"],
1541
- protocols: ["l402"],
1542
- settlement_modes: sortStrings(settlementModes),
1543
- execution_backends: [],
1544
- adapter_lanes: ["l402"],
1545
- task_refs: [],
1546
- workflow_refs: [],
1547
- required_secrets: ["XYTARA_L402_SHARED_SECRET"],
1548
- required_permissions: [],
1549
- supported_profiles: ["default"],
1550
- supported_regions: ["global"],
1551
- pricing_basis: "quote_then_settle",
1552
- latency_class: "near_real_time",
1553
- proof_contract: {
1554
- emits_proof_compatible_facts: true,
1555
- proof_mode: "payment_admission_facts"
1556
- },
1557
- health_contract: {
1558
- check_kind: "internal",
1559
- supports_readiness: true
1560
- },
1561
- idempotency_contract: {
1562
- strategy: "quote_id",
1563
- scope: "payment_admission"
1564
- },
1565
- failure_contract: {
1566
- categories: ["invalid_input", "quote_expired", "payment_missing"],
1567
- retryable_categories: []
1568
- },
1569
- compatibility: {
1570
- node: ">=18",
1571
- commerce_contract: "xytara/v1"
1572
- },
1573
- operational_readiness: {
1574
- supports_default_selection: false,
1575
- supports_forced_selection: true,
1576
- lifecycle: "managed_builtin",
1577
- health_source: "internal"
1578
- },
1579
- selection_hints: {
1580
- default_for_task_refs: [],
1581
- default_for_protocols: [],
1582
- default_for_settlement_modes: sortStrings(settlementModes)
1583
- }
1584
- },
1585
- {
1586
- integration_id: "builtin.payment.bolt",
1587
- display_name: "Built-In BOLT Payment Admission",
1588
- description: "Built-in BOLT-style UTXO/SPV payment admission through a signed proof-carrying payment front.",
1589
- adapter_class: "payment_rail_adapter",
1590
- adapter_version: "1.4.0",
1591
- interface_version: "commerce-adapter-interface/v1",
1592
- bundled: true,
1593
- source: "builtin",
1594
- status: "available",
1595
- certification_state: "certified",
1596
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1597
- integration_maturity: "production_supported",
1598
- selection_priority: 66,
1599
- capabilities: ["payment.admission", "payment.challenge", "payment.permissionless_front", "payment.spv_proof"],
1600
- protocols: ["bolt"],
1601
- settlement_modes: sortStrings(settlementModes),
1602
- execution_backends: [],
1603
- adapter_lanes: ["bolt"],
1604
- task_refs: [],
1605
- workflow_refs: [],
1606
- required_secrets: ["XYTARA_BOLT_SHARED_SECRET"],
1607
- required_permissions: [],
1608
- supported_profiles: ["default"],
1609
- supported_regions: ["global"],
1610
- pricing_basis: "quote_then_settle",
1611
- latency_class: "near_real_time",
1612
- proof_contract: {
1613
- emits_proof_compatible_facts: true,
1614
- proof_mode: "spv_or_block_header_verifiable_payment_facts"
1615
- },
1616
- health_contract: {
1617
- check_kind: "internal",
1618
- supports_readiness: true
1619
- },
1620
- idempotency_contract: {
1621
- strategy: "quote_id",
1622
- scope: "payment_admission"
1623
- },
1624
- failure_contract: {
1625
- categories: ["invalid_input", "quote_expired", "payment_missing"],
1626
- retryable_categories: []
1627
- },
1628
- compatibility: {
1629
- node: ">=18",
1630
- commerce_contract: "xytara/v1"
1631
- },
1632
- operational_readiness: {
1633
- supports_default_selection: false,
1634
- supports_forced_selection: true,
1635
- lifecycle: "managed_builtin",
1636
- health_source: "internal"
1637
- },
1638
- selection_hints: {
1639
- default_for_task_refs: [],
1640
- default_for_protocols: [],
1641
- default_for_settlement_modes: sortStrings(settlementModes)
1642
- }
1643
- },
1644
- {
1645
- integration_id: "builtin.settlement.chain",
1646
- display_name: "Built-In Chain Settlement",
1647
- description: "Built-in settlement lane spanning the canonical chain-backed settlement profiles bundled in xytara.",
1648
- adapter_class: "settlement_adapter",
1649
- adapter_version: "1.4.0",
1650
- interface_version: "commerce-adapter-interface/v1",
1651
- bundled: true,
1652
- source: "builtin",
1653
- status: "available",
1654
- certification_state: "certified",
1655
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1656
- integration_maturity: "production_default",
1657
- selection_priority: 90,
1658
- capabilities: sortStrings(
1659
- (Array.isArray(catalog.tasks) ? catalog.tasks : [])
1660
- .filter((task) => Array.isArray(task.adapters) && task.adapters.includes("chain"))
1661
- .flatMap((task) => task.capabilities || [])
1662
- ),
1663
- protocols: [],
1664
- settlement_modes: sortStrings(settlementModes),
1665
- execution_backends: ["chain"],
1666
- adapter_lanes: ["chain"],
1667
- task_refs: sortStrings(chainTaskRefs),
1668
- workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(chainTaskRefs)),
1669
- required_secrets: [],
1670
- required_permissions: [],
1671
- supported_profiles: ["default", "anchored"],
1672
- supported_regions: ["global"],
1673
- pricing_basis: "per_settlement",
1674
- latency_class: "governed_async",
1675
- proof_contract: {
1676
- emits_proof_compatible_facts: true,
1677
- proof_mode: "settlement_reference_only"
1678
- },
1679
- health_contract: {
1680
- check_kind: "internal",
1681
- supports_readiness: true
1682
- },
1683
- idempotency_contract: {
1684
- strategy: "quote_and_target_binding",
1685
- scope: "settlement_request"
1686
- },
1687
- failure_contract: {
1688
- categories: ["invalid_input", "timeout", "upstream_unavailable", "settlement_failure"],
1689
- retryable_categories: ["timeout", "upstream_unavailable"]
1690
- },
1691
- compatibility: {
1692
- node: ">=18",
1693
- commerce_contract: "xytara/v1"
1694
- },
1695
- operational_readiness: {
1696
- supports_default_selection: true,
1697
- supports_forced_selection: true,
1698
- lifecycle: "managed_builtin",
1699
- health_source: "internal"
1700
- },
1701
- selection_hints: {
1702
- default_for_task_refs: sortStrings(chainTaskRefs),
1703
- default_for_protocols: [],
1704
- default_for_settlement_modes: sortStrings(settlementModes)
1705
- }
1706
- },
1707
- {
1708
- integration_id: "builtin.identity.registry",
1709
- display_name: "Built-In Registry Identity Surface",
1710
- description: "Built-in registry and anchoring surface used by trust, registry, and lifecycle records.",
1711
- adapter_class: "identity_registry_adapter",
1712
- adapter_version: "1.4.0",
1713
- interface_version: "commerce-adapter-interface/v1",
1714
- bundled: true,
1715
- source: "builtin",
1716
- status: "available",
1717
- certification_state: "certified",
1718
- certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1719
- integration_maturity: "production_default",
1720
- selection_priority: 70,
1721
- capabilities: ["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"],
1722
- protocols: [],
1723
- settlement_modes: [],
1724
- execution_backends: ["http", "chain"],
1725
- adapter_lanes: ["http", "chain"],
1726
- task_refs: sortStrings(["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"]),
1727
- workflow_refs: sortStrings(["registry.anchor.flow", "trust.flow"]),
1728
- required_secrets: [],
1729
- required_permissions: [],
1730
- supported_profiles: ["registry", "trust"],
1731
- supported_regions: ["global"],
1732
- pricing_basis: "per_task",
1733
- latency_class: "mixed",
1734
- proof_contract: {
1735
- emits_proof_compatible_facts: true,
1736
- proof_mode: "registry_reference_facts"
1737
- },
1738
- health_contract: {
1739
- check_kind: "internal",
1740
- supports_readiness: true
1741
- },
1742
- idempotency_contract: {
1743
- strategy: "record_ref_binding",
1744
- scope: "registry_request"
1745
- },
1746
- failure_contract: {
1747
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
1748
- retryable_categories: ["timeout", "upstream_unavailable"]
1749
- },
1750
- compatibility: {
1751
- node: ">=18",
1752
- commerce_contract: "xytara/v1"
1753
- },
1754
- operational_readiness: {
1755
- supports_default_selection: true,
1756
- supports_forced_selection: true,
1757
- lifecycle: "managed_builtin",
1758
- health_source: "internal"
1759
- },
1760
- selection_hints: {
1761
- default_for_task_refs: sortStrings(["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"]),
1762
- default_for_protocols: [],
1763
- default_for_settlement_modes: []
1764
- }
1765
- },
1766
- createBuiltinBreadthIntegration({
1767
- integration_id: "builtin.protocol.a2a",
1768
- display_name: "Built-In A2A Protocol Surface",
1769
- description: "Built-in explicit agent-to-agent protocol surface for negotiation, commit, and settlement flow handoff.",
1770
- adapter_class: "agent_protocol_adapter",
1771
- capabilities: ["a2a.negotiate", "a2a.commit"],
1772
- protocols: ["a2a"],
1773
- execution_backends: ["a2a"],
1774
- adapter_lanes: ["a2a"],
1775
- task_refs: ["a2a.negotiate", "a2a.commit"],
1776
- workflow_refs: ["a2a.settlement.flow"],
1777
- supported_profiles: ["interaction"]
1778
- }),
1779
- createBuiltinBreadthIntegration({
1780
- integration_id: "builtin.protocol.acp",
1781
- display_name: "Built-In ACP Protocol Surface",
1782
- description: "Built-in explicit ACP integration surface for third-party commerce and agent marketplace bridging.",
1783
- adapter_class: "agent_protocol_adapter",
1784
- capabilities: ["protocol.acp.bridge"],
1785
- protocols: ["acp"],
1786
- execution_backends: ["acp"],
1787
- adapter_lanes: ["acp"],
1788
- supported_profiles: ["marketplace", "interaction"]
1789
- }),
1790
- createBuiltinBreadthIntegration({
1791
- integration_id: "builtin.protocol.mqtt",
1792
- display_name: "Built-In MQTT Protocol Surface",
1793
- description: "Built-in MQTT-facing protocol surface for message-driven machine interaction ingestion.",
1794
- adapter_class: "agent_protocol_adapter",
1795
- capabilities: ["protocol.mqtt.bridge"],
1796
- protocols: ["mqtt"],
1797
- execution_backends: ["mqtt"],
1798
- adapter_lanes: ["mqtt"],
1799
- supported_profiles: ["message_bus"]
1800
- }),
1801
- createBuiltinBreadthIntegration({
1802
- integration_id: "builtin.protocol.grpc",
1803
- display_name: "Built-In gRPC Protocol Surface",
1804
- description: "Built-in gRPC-facing protocol surface for service-to-service commerce integration.",
1805
- adapter_class: "agent_protocol_adapter",
1806
- capabilities: ["protocol.grpc.bridge"],
1807
- protocols: ["grpc"],
1808
- execution_backends: ["grpc"],
1809
- adapter_lanes: ["grpc"],
1810
- supported_profiles: ["service_mesh"]
1811
- }),
1812
- createBuiltinBreadthIntegration({
1813
- integration_id: "builtin.protocol.kafka",
1814
- display_name: "Built-In Kafka Protocol Surface",
1815
- description: "Built-in Kafka-facing protocol surface for streaming commerce/event ingress.",
1816
- adapter_class: "agent_protocol_adapter",
1817
- capabilities: ["protocol.kafka.bridge"],
1818
- protocols: ["kafka"],
1819
- execution_backends: ["kafka"],
1820
- adapter_lanes: ["kafka"],
1821
- supported_profiles: ["streaming"]
1822
- }),
1823
- createBuiltinBreadthIntegration({
1824
- integration_id: "builtin.protocol.nats",
1825
- display_name: "Built-In NATS Protocol Surface",
1826
- description: "Built-in NATS-facing protocol surface for lightweight message-bus integration.",
1827
- adapter_class: "agent_protocol_adapter",
1828
- capabilities: ["protocol.nats.bridge"],
1829
- protocols: ["nats"],
1830
- execution_backends: ["nats"],
1831
- adapter_lanes: ["nats"],
1832
- supported_profiles: ["streaming"]
1833
- }),
1834
- createBuiltinBreadthIntegration({
1835
- integration_id: "builtin.protocol.ros2",
1836
- display_name: "Built-In ROS2 Protocol Surface",
1837
- description: "Built-in ROS2-facing protocol surface for robotics-adjacent machine interaction integration.",
1838
- adapter_class: "agent_protocol_adapter",
1839
- capabilities: ["protocol.ros2.bridge"],
1840
- protocols: ["ros2"],
1841
- execution_backends: ["ros2"],
1842
- adapter_lanes: ["ros2"],
1843
- supported_profiles: ["robotics"]
1844
- }),
1845
- createBuiltinBreadthIntegration({
1846
- integration_id: "builtin.execution.langchain",
1847
- display_name: "Built-In LangChain Execution Surface",
1848
- description: "Built-in execution-front surface for LangChain-style orchestration interoperability.",
1849
- adapter_class: "execution_adapter",
1850
- capabilities: ["execution.langchain.chain"],
1851
- execution_backends: ["langchain"],
1852
- adapter_lanes: ["langchain"],
1853
- supported_profiles: ["agent_runtime"]
1854
- }),
1855
- createBuiltinBreadthIntegration({
1856
- integration_id: "builtin.execution.langgraph",
1857
- display_name: "Built-In LangGraph Execution Surface",
1858
- description: "Built-in execution-front surface for LangGraph-style graph orchestration interoperability.",
1859
- adapter_class: "execution_adapter",
1860
- capabilities: ["execution.langgraph.graph"],
1861
- execution_backends: ["langgraph"],
1862
- adapter_lanes: ["langgraph"],
1863
- supported_profiles: ["agent_runtime"]
1864
- }),
1865
- createBuiltinBreadthIntegration({
1866
- integration_id: "builtin.execution.semantic_kernel",
1867
- display_name: "Built-In Semantic Kernel Execution Surface",
1868
- description: "Built-in execution-front surface for Semantic Kernel-style orchestration interoperability.",
1869
- adapter_class: "execution_adapter",
1870
- capabilities: ["execution.semantic_kernel.plan"],
1871
- execution_backends: ["semantic_kernel"],
1872
- adapter_lanes: ["semantic_kernel"],
1873
- supported_profiles: ["agent_runtime"]
1874
- }),
1875
- createBuiltinBreadthIntegration({
1876
- integration_id: "builtin.execution.autogen",
1877
- display_name: "Built-In AutoGen Execution Surface",
1878
- description: "Built-in execution-front surface for AutoGen-style multi-agent orchestration interoperability.",
1879
- adapter_class: "execution_adapter",
1880
- capabilities: ["execution.autogen.session"],
1881
- execution_backends: ["autogen"],
1882
- adapter_lanes: ["autogen"],
1883
- supported_profiles: ["agent_runtime"]
1884
- }),
1885
- createBuiltinBreadthIntegration({
1886
- integration_id: "builtin.execution.crewai",
1887
- display_name: "Built-In CrewAI Execution Surface",
1888
- description: "Built-in execution-front surface for CrewAI-style workflow interoperability.",
1889
- adapter_class: "execution_adapter",
1890
- capabilities: ["execution.crewai.crew"],
1891
- execution_backends: ["crewai"],
1892
- adapter_lanes: ["crewai"],
1893
- supported_profiles: ["agent_runtime"]
1894
- }),
1895
- createBuiltinBreadthIntegration({
1896
- integration_id: "builtin.execution.llamaindex",
1897
- display_name: "Built-In LlamaIndex Execution Surface",
1898
- description: "Built-in execution-front surface for LlamaIndex-style retrieval and agent interoperability.",
1899
- adapter_class: "execution_adapter",
1900
- capabilities: ["execution.llamaindex.workflow"],
1901
- execution_backends: ["llamaindex"],
1902
- adapter_lanes: ["llamaindex"],
1903
- supported_profiles: ["agent_runtime", "retrieval"]
1904
- }),
1905
- createBuiltinBreadthIntegration({
1906
- integration_id: "builtin.payment.mpp",
1907
- display_name: "Built-In MPP Payment Surface",
1908
- description: "Built-in multi-party payment admission surface for broader machine payment interoperability.",
1909
- adapter_class: "payment_rail_adapter",
1910
- capabilities: ["payment.mpp.admission"],
1911
- protocols: ["mpp"],
1912
- settlement_modes: sortStrings(settlementModes),
1913
- adapter_lanes: ["mpp"],
1914
- required_secrets: ["XYTARA_MPP_SHARED_SECRET"],
1915
- supported_profiles: ["payment"]
1916
- }),
1917
- createBuiltinBreadthIntegration({
1918
- integration_id: "builtin.identity.erc8004",
1919
- display_name: "Built-In ERC-8004 Identity Surface",
1920
- description: "Built-in ERC-8004-oriented identity action surface for broader machine identity interoperability.",
1921
- adapter_class: "identity_registry_adapter",
1922
- capabilities: ["identity.erc8004.action"],
1923
- protocols: ["erc8004"],
1924
- execution_backends: ["erc8004"],
1925
- adapter_lanes: ["erc8004"],
1926
- supported_profiles: ["identity", "registry"]
1927
- })
1928
- ];
1929
- }
1930
-
1931
- const EXAMPLE_INTEGRATIONS = [
1932
- mapManifestToIntegration(executionExampleManifest, {
1933
- source: "example",
1934
- execution_backends: ["echo"],
1935
- adapter_lanes: ["http"],
1936
- certification_state: "reference_example",
1937
- certification_scope: ["contract_shape"],
1938
- integration_maturity: "reference_example",
1939
- selection_priority: 950,
1940
- supports_default_selection: false,
1941
- supports_forced_selection: true,
1942
- lifecycle: "example_only",
1943
- health_source: "self_reported",
1944
- default_for_task_refs: [],
1945
- default_for_protocols: [],
1946
- default_for_settlement_modes: []
1947
- }),
1948
- mapManifestToIntegration(settlementExampleManifest, {
1949
- source: "example",
1950
- adapter_lanes: ["chain"],
1951
- certification_state: "reference_example",
1952
- certification_scope: ["contract_shape"],
1953
- integration_maturity: "reference_example",
1954
- selection_priority: 960,
1955
- supports_default_selection: false,
1956
- supports_forced_selection: true,
1957
- lifecycle: "example_only",
1958
- health_source: "self_reported",
1959
- default_for_task_refs: [],
1960
- default_for_protocols: [],
1961
- default_for_settlement_modes: []
1962
- }),
1963
- createRegisteredIntegrationFromManifest({
1964
- adapter_id: exampleThirdPartyRegistrationRecord.adapter_id,
1965
- adapter_class: exampleThirdPartyRegistrationRecord.adapter_class,
1966
- adapter_version: "0.1.0",
1967
- interface_version: "commerce-adapter-interface/v1",
1968
- display_name: "Acme MCP Partner Adapter",
1969
- description: "Reference third-party MCP integration showing how staged non-bundled registration should appear in discovery.",
1970
- capabilities: ["adapter.mcp.invoke"],
1971
- compatibility: {
1972
- node: ">=18",
1973
- commerce_contract: "xytara/v1",
1974
- proof_contract: "xoonya/v1"
1975
- },
1976
- health_contract: {
1977
- check_kind: "self_reported",
1978
- supports_readiness: true
1979
- },
1980
- idempotency_contract: {
1981
- strategy: "quote_bound_invocation",
1982
- scope: "protocol_invocation"
1983
- },
1984
- failure_contract: {
1985
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
1986
- retryable_categories: ["timeout", "upstream_unavailable"]
1987
- },
1988
- proof_contract: {
1989
- emits_proof_compatible_facts: true,
1990
- proof_mode: "protocol_invocation_facts"
1991
- },
1992
- latency_class: "near_real_time",
1993
- pricing_basis: "per_task",
1994
- required_secrets: ["ACME_MCP_TOKEN"],
1995
- required_permissions: ["network:outbound"],
1996
- supported_profiles: ["partner"],
1997
- supported_regions: ["global"],
1998
- supported_settlement_modes: exampleThirdPartyRegistrationRecord.settlement_modes
1999
- }, exampleThirdPartyRegistrationRecord, {
2000
- source: "third_party_example",
2001
- status: "available",
2002
- certification_scope: ["self_attested_contract_shape", "staging_smoke"],
2003
- protocols: sortStrings(exampleThirdPartyRegistrationRecord.protocols),
2004
- execution_backends: ["mcp"],
2005
- adapter_lanes: ["mcp"],
2006
- task_refs: sortStrings(exampleThirdPartyRegistrationRecord.task_refs),
2007
- workflow_refs: [],
2008
- supports_forced_selection: true,
2009
- health_source: "self_reported"
2010
- }),
2011
- createRegisteredIntegrationFromManifest({
2012
- adapter_id: exampleThirdPartyIdentityRegistrationRecord.adapter_id,
2013
- adapter_class: exampleThirdPartyIdentityRegistrationRecord.adapter_class,
2014
- adapter_version: "0.1.0",
2015
- interface_version: "commerce-adapter-interface/v1",
2016
- display_name: "Attest Registry Partner Identity Adapter",
2017
- description: "Reference third-party identity registry integration showing how staged non-bundled identity registration should appear in discovery.",
2018
- capabilities: ["registry.register", "trust.handoff.emit", "trust.handoff.validate"],
2019
- compatibility: {
2020
- node: ">=18",
2021
- commerce_contract: "xytara/v1",
2022
- proof_contract: "xoonya/v1"
2023
- },
2024
- health_contract: {
2025
- check_kind: "self_reported",
2026
- supports_readiness: true
2027
- },
2028
- idempotency_contract: {
2029
- strategy: "record_ref_binding",
2030
- scope: "registry_request"
2031
- },
2032
- failure_contract: {
2033
- categories: ["invalid_input", "timeout", "upstream_unavailable"],
2034
- retryable_categories: ["timeout", "upstream_unavailable"]
2035
- },
2036
- proof_contract: {
2037
- emits_proof_compatible_facts: true,
2038
- proof_mode: "registry_reference_facts"
2039
- },
2040
- latency_class: "near_real_time",
2041
- pricing_basis: "per_task",
2042
- required_secrets: ["ATTEST_REGISTRY_TOKEN"],
2043
- required_permissions: ["network:outbound"],
2044
- supported_profiles: ["partner", "registry", "trust"],
2045
- supported_regions: ["global"],
2046
- supported_settlement_modes: []
2047
- }, exampleThirdPartyIdentityRegistrationRecord, {
2048
- source: "third_party_example",
2049
- status: "available",
2050
- certification_scope: ["self_attested_contract_shape", "staging_identity_smoke"],
2051
- protocols: sortStrings(exampleThirdPartyIdentityRegistrationRecord.protocols),
2052
- execution_backends: ["http", "chain"],
2053
- adapter_lanes: ["http", "chain"],
2054
- task_refs: sortStrings(exampleThirdPartyIdentityRegistrationRecord.task_refs),
2055
- workflow_refs: [],
2056
- supports_forced_selection: true,
2057
- health_source: "self_reported"
2058
- }),
2059
- createRegisteredIntegrationFromManifest({
2060
- adapter_id: exampleThirdPartySettlementRegistrationRecord.adapter_id,
2061
- adapter_class: exampleThirdPartySettlementRegistrationRecord.adapter_class,
2062
- adapter_version: "0.1.0",
2063
- interface_version: "commerce-adapter-interface/v1",
2064
- display_name: "Lattice Anchor Settlement Adapter",
2065
- description: "Reference third-party settlement integration showing how staged non-bundled settlement registration should appear in discovery.",
2066
- capabilities: ["anchoring.submit", "settlement.reference"],
2067
- compatibility: {
2068
- node: ">=18",
2069
- commerce_contract: "xytara/v1",
2070
- proof_contract: "xoonya/v1"
2071
- },
2072
- health_contract: {
2073
- check_kind: "self_reported",
2074
- supports_readiness: true
2075
- },
2076
- idempotency_contract: {
2077
- strategy: "quote_and_target_binding",
2078
- scope: "settlement_request"
2079
- },
2080
- failure_contract: {
2081
- categories: ["invalid_input", "timeout", "upstream_unavailable", "settlement_failure"],
2082
- retryable_categories: ["timeout", "upstream_unavailable"]
2083
- },
2084
- proof_contract: {
2085
- emits_proof_compatible_facts: true,
2086
- proof_mode: "settlement_reference_only"
2087
- },
2088
- latency_class: "governed_async",
2089
- pricing_basis: "per_settlement",
2090
- required_secrets: ["LATTICE_SETTLEMENT_TOKEN"],
2091
- required_permissions: ["network:outbound"],
2092
- supported_profiles: ["partner", "anchored"],
2093
- supported_regions: ["global"],
2094
- supported_settlement_modes: exampleThirdPartySettlementRegistrationRecord.settlement_modes
2095
- }, exampleThirdPartySettlementRegistrationRecord, {
2096
- source: "third_party_example",
2097
- status: "available",
2098
- certification_scope: ["self_attested_contract_shape", "staging_settlement_smoke"],
2099
- protocols: sortStrings(exampleThirdPartySettlementRegistrationRecord.protocols),
2100
- execution_backends: ["chain"],
2101
- adapter_lanes: ["chain"],
2102
- task_refs: sortStrings(exampleThirdPartySettlementRegistrationRecord.task_refs),
2103
- workflow_refs: [],
2104
- supports_forced_selection: true,
2105
- health_source: "self_reported"
2106
- })
2107
- ];
2108
-
2109
- const INTEGRATIONS = buildBuiltInIntegrations().concat(EXAMPLE_INTEGRATIONS).map(clone);
2110
-
2111
- const INTEGRATION_REGISTRATION_RECORDS = {
2112
- [exampleThirdPartyRegistrationRecord.integration_id]: clone(exampleThirdPartyRegistrationRecord),
2113
- [exampleThirdPartyIdentityRegistrationRecord.integration_id]: clone(exampleThirdPartyIdentityRegistrationRecord),
2114
- [exampleThirdPartySettlementRegistrationRecord.integration_id]: clone(exampleThirdPartySettlementRegistrationRecord)
2115
- };
2116
-
2117
- function listIntegrations(filters = {}) {
2118
- const normalized = {
2119
- adapter_class: String(filters.adapter_class || filters.class || "").trim(),
2120
- protocol: String(filters.protocol || "").trim(),
2121
- settlement_mode: String(filters.settlement_mode || "").trim(),
2122
- capability: String(filters.capability || "").trim(),
2123
- task_ref: String(filters.task_ref || "").trim(),
2124
- source: String(filters.source || "").trim(),
2125
- certification_state: String(filters.certification_state || "").trim(),
2126
- integration_maturity: String(filters.integration_maturity || filters.maturity || "").trim(),
2127
- bundled: String(filters.bundled || "").trim()
2128
- };
2129
- return INTEGRATIONS.filter((integration) => {
2130
- if (normalized.adapter_class && integration.adapter_class !== normalized.adapter_class) return false;
2131
- if (normalized.protocol && !integration.protocols.includes(normalized.protocol)) return false;
2132
- if (normalized.settlement_mode && !integration.settlement_modes.includes(normalized.settlement_mode)) return false;
2133
- if (normalized.capability && !integration.capabilities.includes(normalized.capability)) return false;
2134
- if (normalized.task_ref && !integration.task_refs.includes(normalized.task_ref)) return false;
2135
- if (normalized.source && integration.source !== normalized.source) return false;
2136
- if (normalized.certification_state && integration.certification_state !== normalized.certification_state) return false;
2137
- if (normalized.integration_maturity && integration.integration_maturity !== normalized.integration_maturity) return false;
2138
- if (normalized.bundled && String(integration.bundled) !== normalized.bundled) return false;
2139
- return true;
2140
- }).map((integration) => buildIntegrationView(integration, INTEGRATION_REGISTRATION_RECORDS[integration.integration_id]));
2141
- }
2142
-
2143
- function getIntegration(integrationId) {
2144
- const lookup = String(integrationId || "").trim();
2145
- const found = INTEGRATIONS.find((integration) => integration.integration_id === lookup);
2146
- return found ? buildIntegrationView(found, INTEGRATION_REGISTRATION_RECORDS[found.integration_id]) : null;
2147
- }
2148
-
2149
- function summarizeIntegrations(filters = {}) {
2150
- const integrations = listIntegrations(filters);
2151
- return {
2152
- ok: true,
2153
- integration_count: integrations.length,
2154
- integration_ids: integrations.map((integration) => integration.integration_id),
2155
- class_count: sortStrings(integrations.map((integration) => integration.adapter_class)).length,
2156
- protocol_count: sortStrings(integrations.flatMap((integration) => integration.protocols)).length,
2157
- settlement_mode_count: sortStrings(integrations.flatMap((integration) => integration.settlement_modes)).length,
2158
- certified_integration_count: integrations.filter((integration) => integration.certification_state === "certified").length,
2159
- production_default_count: integrations.filter((integration) => integration.integration_maturity === "production_default").length,
2160
- integrations: integrations.map((integration) => ({
2161
- integration_id: integration.integration_id,
2162
- display_name: integration.display_name,
2163
- adapter_class: integration.adapter_class,
2164
- source: integration.source,
2165
- certification_state: integration.certification_state,
2166
- integration_maturity: integration.integration_maturity,
2167
- registration_state: integration.registration.registration_state,
2168
- bundled: integration.registration.bundled,
2169
- selection_priority: integration.selection_priority,
2170
- protocols: integration.protocols,
2171
- settlement_modes: integration.settlement_modes,
2172
- task_count: integration.task_refs.length,
2173
- workflow_count: integration.workflow_refs.length,
2174
- capability_count: integration.capabilities.length
2175
- }))
2176
- };
2177
- }
2178
-
2179
- function summarizeIntegrationClasses(filters = {}) {
2180
- const integrations = listIntegrations(filters);
2181
- const classes = sortStrings(integrations.map((integration) => integration.adapter_class)).map((adapterClass) => ({
2182
- adapter_class: adapterClass,
2183
- integration_count: integrations.filter((integration) => integration.adapter_class === adapterClass).length
2184
- }));
2185
- return {
2186
- ok: true,
2187
- adapter_class_count: classes.length,
2188
- adapter_classes: classes
2189
- };
2190
- }
2191
-
2192
- function summarizeIntegrationProtocols(filters = {}) {
2193
- const integrations = listIntegrations(filters);
2194
- const protocols = sortStrings(integrations.flatMap((integration) => integration.protocols)).map((protocol) => ({
2195
- protocol,
2196
- integration_count: integrations.filter((integration) => integration.protocols.includes(protocol)).length
2197
- }));
2198
- return {
2199
- ok: true,
2200
- protocol_count: protocols.length,
2201
- protocols
2202
- };
2203
- }
2204
-
2205
- function summarizeIntegrationSettlementModes(filters = {}) {
2206
- const integrations = listIntegrations(filters);
2207
- const settlementModes = sortStrings(integrations.flatMap((integration) => integration.settlement_modes)).map((settlementMode) => ({
2208
- settlement_mode: settlementMode,
2209
- integration_count: integrations.filter((integration) => integration.settlement_modes.includes(settlementMode)).length
2210
- }));
2211
- return {
2212
- ok: true,
2213
- settlement_mode_count: settlementModes.length,
2214
- settlement_modes: settlementModes
2215
- };
2216
- }
2217
-
2218
- // 1.3.0 Phase 1 anchor:
2219
- // The next workflow layer should stay read-only and build on top of
2220
- // summarizeIntegrationPromotionReadiness(...), adding:
2221
- // - promotion recommendation summaries
2222
- // - next eligible transition summaries
2223
- // - normalized blocker categories
2224
- // without introducing mutation flows or persistent registry state.
2225
-
2226
- module.exports = {
2227
- getIntegration,
2228
- listIntegrations,
2229
- summarizeIntegrations,
2230
- summarizeIntegrationClasses,
2231
- summarizeIntegrationProtocols,
2232
- summarizeIntegrationSettlementModes,
2233
- validateIntegrationRegistration,
2234
- validateIntegrationCertificationPack,
2235
- validateIntegrationSubmission,
2236
- importRegisteredIntegration,
2237
- createIntegrationRegistrySnapshot,
2238
- exportIntegrationRegistrySnapshot,
2239
- validateIntegrationRegistrySnapshot,
2240
- validateIntegrationSubmissionBundle,
2241
- createIntegrationSubmissionBundle,
2242
- importIntegrationSubmissionBundle,
2243
- createIntegrationRegistrySnapshotFromBundles,
2244
- exportIntegrationSubmissionBundles,
2245
- createIntegrationSubmissionBundleSet,
2246
- validateIntegrationSubmissionBundleSet,
2247
- exportIntegrationSubmissionBundleSet,
2248
- summarizeIntegrationSubmissionBundleReview,
2249
- summarizeIntegrationSubmissionBundleSetReview,
2250
- summarizeIntegrationRegistrySnapshotReview,
2251
- summarizeIntegrationPromotionReadiness,
2252
- summarizeIntegrationPromotionWorkflow,
2253
- summarizeIntegrationPromotionWorkflowList,
2254
- validatePromotionActionRequest,
2255
- summarizeIntegrationPromotionActionPreview,
2256
- summarizeIntegrationPromotionActionSet,
2257
- summarizeIntegrationPromotionActionSetList,
2258
- createRegisteredIntegrationFromManifest,
2259
- buildIntegrationRegistrationView,
2260
- buildIntegrationView
2261
- };
1
+ "use strict";
2
+
3
+ const executionExampleManifest = require("../adapters/examples/example-execution-adapter.manifest.json");
4
+ const settlementExampleManifest = require("../adapters/examples/example-settlement-adapter.manifest.json");
5
+ const exampleThirdPartyRegistrationRecord = require("../adapters/examples/example-third-party-registration.record.json");
6
+ const exampleThirdPartyIdentityRegistrationRecord = require("../adapters/examples/example-third-party-identity-registration.record.json");
7
+ const exampleThirdPartySettlementRegistrationRecord = require("../adapters/examples/example-third-party-settlement-registration.record.json");
8
+ const { catalog } = require("../fixtures/catalog");
9
+
10
+ function clone(value) {
11
+ return JSON.parse(JSON.stringify(value));
12
+ }
13
+
14
+ function sortStrings(values) {
15
+ return Array.from(new Set((Array.isArray(values) ? values : []).filter(Boolean))).sort();
16
+ }
17
+
18
+ function collectTaskRefsByAdapter(adapterName) {
19
+ return (Array.isArray(catalog.tasks) ? catalog.tasks : [])
20
+ .filter((task) => Array.isArray(task.adapters) && task.adapters.includes(adapterName))
21
+ .map((task) => task.public_task_ref);
22
+ }
23
+
24
+ function collectWorkflowRefsByTaskRefs(taskRefs) {
25
+ const allowed = new Set(Array.isArray(taskRefs) ? taskRefs : []);
26
+ return (Array.isArray(catalog.workflows) ? catalog.workflows : [])
27
+ .filter((workflow) => Array.isArray(workflow.task_refs) && workflow.task_refs.some((taskRef) => allowed.has(taskRef)))
28
+ .map((workflow) => workflow.workflow_ref);
29
+ }
30
+
31
+ function createBuiltinBreadthIntegration({
32
+ integration_id,
33
+ display_name,
34
+ description,
35
+ adapter_class,
36
+ capabilities = [],
37
+ protocols = [],
38
+ settlement_modes = [],
39
+ execution_backends = [],
40
+ adapter_lanes = [],
41
+ task_refs = [],
42
+ workflow_refs = [],
43
+ required_secrets = [],
44
+ required_permissions = [],
45
+ supported_profiles = ["default"],
46
+ pricing_basis = "per_task",
47
+ latency_class = "mixed",
48
+ proof_mode = "adjacent_reference_only"
49
+ }) {
50
+ return {
51
+ integration_id,
52
+ display_name,
53
+ description,
54
+ adapter_class,
55
+ adapter_version: "1.26.0",
56
+ interface_version: "commerce-adapter-interface/v1",
57
+ bundled: true,
58
+ source: "builtin",
59
+ status: "available",
60
+ certification_state: "certified",
61
+ certification_scope: ["builtin_registry", "service_contract", "sdk_contract"],
62
+ integration_maturity: "production_supported",
63
+ selection_priority: 250,
64
+ capabilities: sortStrings(capabilities),
65
+ protocols: sortStrings(protocols),
66
+ settlement_modes: sortStrings(settlement_modes),
67
+ execution_backends: sortStrings(execution_backends),
68
+ adapter_lanes: sortStrings(adapter_lanes),
69
+ task_refs: sortStrings(task_refs),
70
+ workflow_refs: sortStrings(workflow_refs),
71
+ required_secrets: sortStrings(required_secrets),
72
+ required_permissions: sortStrings(required_permissions),
73
+ supported_profiles: sortStrings(supported_profiles),
74
+ supported_regions: ["global"],
75
+ pricing_basis,
76
+ latency_class,
77
+ proof_contract: {
78
+ emits_proof_compatible_facts: true,
79
+ proof_mode
80
+ },
81
+ health_contract: {
82
+ check_kind: "internal",
83
+ supports_readiness: true
84
+ },
85
+ idempotency_contract: {
86
+ strategy: "quote_bound_selection",
87
+ scope: "integration_selection"
88
+ },
89
+ failure_contract: {
90
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
91
+ retryable_categories: ["timeout", "upstream_unavailable"]
92
+ },
93
+ compatibility: {
94
+ node: ">=18",
95
+ commerce_contract: "xytara/v1"
96
+ },
97
+ operational_readiness: {
98
+ supports_default_selection: false,
99
+ supports_forced_selection: true,
100
+ lifecycle: "managed_builtin",
101
+ health_source: "internal"
102
+ },
103
+ selection_hints: {
104
+ default_for_task_refs: [],
105
+ default_for_protocols: [],
106
+ default_for_settlement_modes: []
107
+ }
108
+ };
109
+ }
110
+
111
+ function mapManifestToIntegration(manifest, extras = {}) {
112
+ const taskRefs = sortStrings(extras.task_refs);
113
+ return {
114
+ integration_id: manifest.adapter_id,
115
+ display_name: manifest.display_name,
116
+ description: manifest.description,
117
+ adapter_class: manifest.adapter_class,
118
+ adapter_version: manifest.adapter_version,
119
+ interface_version: manifest.interface_version,
120
+ bundled: extras.bundled !== false,
121
+ source: extras.source || "example",
122
+ status: extras.status || "available",
123
+ certification_state: extras.certification_state || "reference_example",
124
+ certification_scope: sortStrings(extras.certification_scope || ["contract_shape"]),
125
+ integration_maturity: extras.integration_maturity || "reference_example",
126
+ selection_priority: Number.isFinite(Number(extras.selection_priority)) ? Number(extras.selection_priority) : 900,
127
+ capabilities: sortStrings(manifest.capabilities),
128
+ protocols: sortStrings(extras.protocols),
129
+ settlement_modes: sortStrings(manifest.supported_settlement_modes),
130
+ execution_backends: sortStrings(extras.execution_backends),
131
+ adapter_lanes: sortStrings(extras.adapter_lanes),
132
+ task_refs: taskRefs,
133
+ workflow_refs: sortStrings(extras.workflow_refs || collectWorkflowRefsByTaskRefs(taskRefs)),
134
+ required_secrets: sortStrings(manifest.required_secrets),
135
+ required_permissions: sortStrings(manifest.required_permissions),
136
+ supported_profiles: sortStrings(manifest.supported_profiles),
137
+ supported_regions: sortStrings(manifest.supported_regions),
138
+ pricing_basis: manifest.pricing_basis || null,
139
+ latency_class: manifest.latency_class || null,
140
+ proof_contract: manifest.proof_contract || null,
141
+ health_contract: manifest.health_contract || null,
142
+ idempotency_contract: manifest.idempotency_contract || null,
143
+ failure_contract: manifest.failure_contract || null,
144
+ compatibility: manifest.compatibility || {},
145
+ operational_readiness: {
146
+ supports_default_selection: extras.supports_default_selection === true,
147
+ supports_forced_selection: extras.supports_forced_selection !== false,
148
+ lifecycle: extras.lifecycle || "reference",
149
+ health_source: extras.health_source || "self_reported"
150
+ },
151
+ selection_hints: {
152
+ default_for_task_refs: sortStrings(extras.default_for_task_refs || taskRefs),
153
+ default_for_protocols: sortStrings(extras.default_for_protocols || extras.protocols),
154
+ default_for_settlement_modes: sortStrings(extras.default_for_settlement_modes || manifest.supported_settlement_modes)
155
+ }
156
+ };
157
+ }
158
+
159
+ function buildIntegrationRegistrationView(integration, registrationRecord) {
160
+ const integrationEntry = integration || {};
161
+ const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : null;
162
+ const selectionPriority = record && Number.isFinite(Number(record.selection_priority))
163
+ ? Number(record.selection_priority)
164
+ : integrationEntry.selection_priority;
165
+ return {
166
+ registration_state: record ? record.registration_state : "unregistered",
167
+ bundled: record ? record.bundled : integrationEntry.bundled === true,
168
+ default_selection_enabled: record
169
+ ? record.default_selection_enabled === true
170
+ : !!(
171
+ integrationEntry.operational_readiness &&
172
+ integrationEntry.operational_readiness.supports_default_selection
173
+ ),
174
+ requires_explicit_selection: record
175
+ ? record.requires_explicit_selection === true
176
+ : !(
177
+ integrationEntry.operational_readiness &&
178
+ integrationEntry.operational_readiness.supports_default_selection
179
+ ),
180
+ selection_priority: selectionPriority,
181
+ registered_at: record ? record.registered_at : null,
182
+ registered_by: record ? record.registered_by || null : null,
183
+ verified_with: sortStrings(record && record.verified_with),
184
+ notes: record ? record.notes || null : null
185
+ };
186
+ }
187
+
188
+ function buildIntegrationView(integration, registrationRecord) {
189
+ const entry = clone(integration);
190
+ entry.registration = buildIntegrationRegistrationView(entry, registrationRecord);
191
+ return entry;
192
+ }
193
+
194
+ function createRegisteredIntegrationFromManifest(manifest, registrationRecord, extras = {}) {
195
+ const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
196
+ const integration = mapManifestToIntegration(manifest, {
197
+ ...extras,
198
+ bundled: Object.prototype.hasOwnProperty.call(record, "bundled")
199
+ ? record.bundled
200
+ : extras.bundled,
201
+ certification_state: record.certification_state || extras.certification_state,
202
+ certification_scope: record.certification_scope || extras.certification_scope,
203
+ integration_maturity: record.integration_maturity || extras.integration_maturity,
204
+ selection_priority: Object.prototype.hasOwnProperty.call(record, "selection_priority")
205
+ ? record.selection_priority
206
+ : extras.selection_priority,
207
+ supports_default_selection: Object.prototype.hasOwnProperty.call(record, "default_selection_enabled")
208
+ ? record.default_selection_enabled
209
+ : extras.supports_default_selection,
210
+ lifecycle: record.registration_state || extras.lifecycle,
211
+ default_for_task_refs: record.default_selection_enabled === true
212
+ ? extras.default_for_task_refs
213
+ : [],
214
+ default_for_protocols: record.default_selection_enabled === true
215
+ ? extras.default_for_protocols
216
+ : [],
217
+ default_for_settlement_modes: record.default_selection_enabled === true
218
+ ? extras.default_for_settlement_modes
219
+ : []
220
+ });
221
+ return buildIntegrationView(integration, record);
222
+ }
223
+
224
+ function validateIntegrationRegistration(manifest, registrationRecord) {
225
+ const errors = [];
226
+ const manifestEntry = manifest && typeof manifest === "object" ? manifest : {};
227
+ const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
228
+
229
+ if (!manifestEntry.adapter_id) {
230
+ errors.push("manifest.adapter_id is required");
231
+ }
232
+ if (!record.integration_id) {
233
+ errors.push("registration_record.integration_id is required");
234
+ }
235
+ if (!record.adapter_id) {
236
+ errors.push("registration_record.adapter_id is required");
237
+ }
238
+ if (!record.adapter_class) {
239
+ errors.push("registration_record.adapter_class is required");
240
+ }
241
+ if (manifestEntry.adapter_id && record.adapter_id && manifestEntry.adapter_id !== record.adapter_id) {
242
+ errors.push("manifest.adapter_id must match registration_record.adapter_id");
243
+ }
244
+ if (manifestEntry.adapter_id && record.integration_id && manifestEntry.adapter_id !== record.integration_id) {
245
+ errors.push("manifest.adapter_id must match registration_record.integration_id");
246
+ }
247
+ if (manifestEntry.adapter_class && record.adapter_class && manifestEntry.adapter_class !== record.adapter_class) {
248
+ errors.push("manifest.adapter_class must match registration_record.adapter_class");
249
+ }
250
+
251
+ return {
252
+ ok: errors.length === 0,
253
+ errors
254
+ };
255
+ }
256
+
257
+ function validateIntegrationCertificationPack(certificationPack) {
258
+ const pack = certificationPack && typeof certificationPack === "object" ? certificationPack : {};
259
+ const errors = [];
260
+ if (!pack.integration_id) errors.push("certification_pack.integration_id is required");
261
+ if (!pack.adapter_id) errors.push("certification_pack.adapter_id is required");
262
+ if (!pack.adapter_class) errors.push("certification_pack.adapter_class is required");
263
+ if (!pack.certification_state) errors.push("certification_pack.certification_state is required");
264
+ if (!Array.isArray(pack.certification_scope) || pack.certification_scope.length < 1) {
265
+ errors.push("certification_pack.certification_scope must contain at least one entry");
266
+ }
267
+ if (!Array.isArray(pack.verified_with) || pack.verified_with.length < 1) {
268
+ errors.push("certification_pack.verified_with must contain at least one entry");
269
+ }
270
+ if (!pack.submitted_at) errors.push("certification_pack.submitted_at is required");
271
+ return {
272
+ ok: errors.length === 0,
273
+ errors
274
+ };
275
+ }
276
+
277
+ function validateIntegrationSubmission(manifest, registrationRecord, certificationPack) {
278
+ const registrationValidation = validateIntegrationRegistration(manifest, registrationRecord);
279
+ const certificationValidation = validateIntegrationCertificationPack(certificationPack);
280
+ const errors = registrationValidation.errors.concat(certificationValidation.errors);
281
+ const manifestEntry = manifest && typeof manifest === "object" ? manifest : {};
282
+ const record = registrationRecord && typeof registrationRecord === "object" ? registrationRecord : {};
283
+ const pack = certificationPack && typeof certificationPack === "object" ? certificationPack : {};
284
+
285
+ if (manifestEntry.adapter_id && pack.adapter_id && manifestEntry.adapter_id !== pack.adapter_id) {
286
+ errors.push("manifest.adapter_id must match certification_pack.adapter_id");
287
+ }
288
+ if (record.integration_id && pack.integration_id && record.integration_id !== pack.integration_id) {
289
+ errors.push("registration_record.integration_id must match certification_pack.integration_id");
290
+ }
291
+ if (record.adapter_class && pack.adapter_class && record.adapter_class !== pack.adapter_class) {
292
+ errors.push("registration_record.adapter_class must match certification_pack.adapter_class");
293
+ }
294
+ if (record.certification_state && pack.certification_state && record.certification_state !== pack.certification_state) {
295
+ errors.push("registration_record.certification_state must match certification_pack.certification_state");
296
+ }
297
+
298
+ return {
299
+ ok: errors.length === 0,
300
+ errors
301
+ };
302
+ }
303
+
304
+ function importRegisteredIntegration(manifest, registrationRecord, extras = {}) {
305
+ const validation = validateIntegrationRegistration(manifest, registrationRecord);
306
+ if (!validation.ok) {
307
+ const error = new Error(`invalid integration registration:\n${validation.errors.join("\n")}`);
308
+ error.code = "invalid_integration_registration";
309
+ error.validation = validation;
310
+ throw error;
311
+ }
312
+ return createRegisteredIntegrationFromManifest(manifest, registrationRecord, extras);
313
+ }
314
+
315
+ function createIntegrationRegistrySnapshot(integrations, filters = {}) {
316
+ const rows = Array.isArray(integrations) ? integrations.map(clone) : [];
317
+ return {
318
+ snapshot_version: "xytara/integration-registry-snapshot/v1",
319
+ generated_at: new Date().toISOString(),
320
+ integration_count: rows.length,
321
+ filters: clone(filters || {}),
322
+ integrations: rows
323
+ };
324
+ }
325
+
326
+ function exportIntegrationRegistrySnapshot(filters = {}) {
327
+ return createIntegrationRegistrySnapshot(listIntegrations(filters), filters);
328
+ }
329
+
330
+ function validateIntegrationRegistrySnapshot(snapshot) {
331
+ const entry = snapshot && typeof snapshot === "object" ? snapshot : {};
332
+ const errors = [];
333
+ if (!entry.snapshot_version) errors.push("snapshot.snapshot_version is required");
334
+ if (!entry.generated_at) errors.push("snapshot.generated_at is required");
335
+ if (!Number.isInteger(entry.integration_count) || entry.integration_count < 0) {
336
+ errors.push("snapshot.integration_count must be a non-negative integer");
337
+ }
338
+ if (!Array.isArray(entry.integrations)) {
339
+ errors.push("snapshot.integrations must be an array");
340
+ } else if (entry.integration_count !== entry.integrations.length) {
341
+ errors.push("snapshot.integration_count must match snapshot.integrations.length");
342
+ }
343
+ return {
344
+ ok: errors.length === 0,
345
+ errors
346
+ };
347
+ }
348
+
349
+ function validateIntegrationSubmissionBundle(bundle) {
350
+ const entry = bundle && typeof bundle === "object" ? bundle : {};
351
+ const errors = [];
352
+ if (!entry.bundle_version) {
353
+ errors.push("submission_bundle.bundle_version is required");
354
+ }
355
+ if (!entry.manifest || typeof entry.manifest !== "object") {
356
+ errors.push("submission_bundle.manifest is required");
357
+ }
358
+ if (!entry.registration_record || typeof entry.registration_record !== "object") {
359
+ errors.push("submission_bundle.registration_record is required");
360
+ }
361
+ if (!entry.certification_pack || typeof entry.certification_pack !== "object") {
362
+ errors.push("submission_bundle.certification_pack is required");
363
+ }
364
+ const submissionValidation = validateIntegrationSubmission(
365
+ entry.manifest,
366
+ entry.registration_record,
367
+ entry.certification_pack
368
+ );
369
+ return {
370
+ ok: errors.length === 0 && submissionValidation.ok,
371
+ errors: errors.concat(submissionValidation.errors)
372
+ };
373
+ }
374
+
375
+ function createIntegrationSubmissionBundle(bundleInput = {}, extras = {}) {
376
+ const manifest = clone(bundleInput.manifest || {});
377
+ const registrationRecord = clone(bundleInput.registration_record || {});
378
+ const certificationPack = clone(bundleInput.certification_pack || {});
379
+ const importedIntegration = importRegisteredIntegration(manifest, registrationRecord, extras);
380
+ const snapshotEntry = clone(bundleInput.snapshot_entry || importedIntegration);
381
+ return {
382
+ bundle_version: "xytara/integration-submission-bundle/v1",
383
+ manifest,
384
+ registration_record: registrationRecord,
385
+ certification_pack: certificationPack,
386
+ snapshot_entry: snapshotEntry,
387
+ notes: typeof bundleInput.notes === "string" ? bundleInput.notes : null
388
+ };
389
+ }
390
+
391
+ function importIntegrationSubmissionBundle(bundleInput = {}, extras = {}) {
392
+ const bundle = createIntegrationSubmissionBundle(bundleInput, extras);
393
+ const validation = validateIntegrationSubmissionBundle(bundle);
394
+ if (!validation.ok) {
395
+ const error = new Error(`invalid integration submission bundle:\n${validation.errors.join("\n")}`);
396
+ error.code = "invalid_integration_submission_bundle";
397
+ error.validation = validation;
398
+ throw error;
399
+ }
400
+ return bundle;
401
+ }
402
+
403
+ function createIntegrationRegistrySnapshotFromBundles(bundles, filters = {}, bundleExtras = {}) {
404
+ const bundleList = Array.isArray(bundles) ? bundles : [];
405
+ const integrations = bundleList.map((bundle) => importIntegrationSubmissionBundle(bundle, bundleExtras).snapshot_entry);
406
+ return createIntegrationRegistrySnapshot(integrations, {
407
+ ...clone(filters || {}),
408
+ snapshot_source: "submission_bundle"
409
+ });
410
+ }
411
+
412
+ function exportIntegrationSubmissionBundles(filters = {}) {
413
+ return listIntegrations(filters)
414
+ .filter((integration) => integration.source === "third_party_example")
415
+ .map((integration) => {
416
+ const registrationRecord = clone(INTEGRATION_REGISTRATION_RECORDS[integration.integration_id] || {});
417
+ const certificationPack = {
418
+ integration_id: integration.integration_id,
419
+ adapter_id: integration.integration_id,
420
+ adapter_class: integration.adapter_class,
421
+ certification_state: integration.certification_state,
422
+ certification_scope: clone(integration.certification_scope || []),
423
+ verified_with: clone(integration.registration.verified_with || []),
424
+ submitted_at: integration.registration.registered_at || new Date().toISOString(),
425
+ submitted_by: integration.registration.registered_by || "unknown",
426
+ last_verified_contract_version: "xytara/v1",
427
+ notes: integration.registration.notes || null
428
+ };
429
+ const manifest = {
430
+ adapter_id: integration.integration_id,
431
+ adapter_class: integration.adapter_class,
432
+ adapter_version: integration.adapter_version,
433
+ interface_version: integration.interface_version,
434
+ display_name: integration.display_name,
435
+ description: integration.description,
436
+ capabilities: clone(integration.capabilities || []),
437
+ required_secrets: clone(integration.required_secrets || []),
438
+ required_permissions: clone(integration.required_permissions || []),
439
+ supported_profiles: clone(integration.supported_profiles || []),
440
+ supported_regions: clone(integration.supported_regions || []),
441
+ supported_settlement_modes: clone(integration.settlement_modes || []),
442
+ pricing_basis: integration.pricing_basis,
443
+ latency_class: integration.latency_class,
444
+ registration_contract: {
445
+ integration_id: integration.integration_id,
446
+ integration_maturity: integration.integration_maturity,
447
+ bundled: integration.registration.bundled,
448
+ default_selection_enabled: integration.registration.default_selection_enabled,
449
+ requires_explicit_selection: integration.registration.requires_explicit_selection
450
+ },
451
+ certification_contract: {
452
+ certification_state: integration.certification_state,
453
+ certification_scope: clone(integration.certification_scope || []),
454
+ verified_with: clone(integration.registration.verified_with || []),
455
+ last_verified_contract_version: "xytara/v1"
456
+ },
457
+ compatibility: clone(integration.compatibility || {}),
458
+ health_contract: clone(integration.health_contract || {}),
459
+ idempotency_contract: clone(integration.idempotency_contract || {}),
460
+ failure_contract: clone(integration.failure_contract || {}),
461
+ proof_contract: clone(integration.proof_contract || {})
462
+ };
463
+ return createIntegrationSubmissionBundle({
464
+ manifest,
465
+ registration_record: registrationRecord,
466
+ certification_pack: certificationPack,
467
+ snapshot_entry: integration,
468
+ notes: integration.registration.notes || null
469
+ }, {
470
+ source: integration.source,
471
+ protocols: clone(integration.protocols || []),
472
+ execution_backends: clone(integration.execution_backends || []),
473
+ adapter_lanes: clone(integration.adapter_lanes || []),
474
+ task_refs: clone(integration.task_refs || []),
475
+ workflow_refs: clone(integration.workflow_refs || [])
476
+ });
477
+ });
478
+ }
479
+
480
+ function createIntegrationSubmissionBundleSet(bundles, filters = {}, notes = null) {
481
+ const bundleList = Array.isArray(bundles) ? bundles.map(clone) : [];
482
+ return {
483
+ bundle_set_version: "xytara/integration-submission-bundle-set/v1",
484
+ generated_at: new Date().toISOString(),
485
+ bundle_count: bundleList.length,
486
+ filters: clone(filters || {}),
487
+ bundles: bundleList,
488
+ notes: typeof notes === "string" ? notes : null
489
+ };
490
+ }
491
+
492
+ function validateIntegrationSubmissionBundleSet(bundleSet) {
493
+ const entry = bundleSet && typeof bundleSet === "object" ? bundleSet : {};
494
+ const errors = [];
495
+ if (!entry.bundle_set_version) errors.push("bundle_set.bundle_set_version is required");
496
+ if (!entry.generated_at) errors.push("bundle_set.generated_at is required");
497
+ if (!Number.isInteger(entry.bundle_count) || entry.bundle_count < 0) {
498
+ errors.push("bundle_set.bundle_count must be a non-negative integer");
499
+ }
500
+ if (!Array.isArray(entry.bundles)) {
501
+ errors.push("bundle_set.bundles must be an array");
502
+ } else if (entry.bundle_count !== entry.bundles.length) {
503
+ errors.push("bundle_set.bundle_count must match bundle_set.bundles.length");
504
+ } else {
505
+ entry.bundles.forEach((bundle, index) => {
506
+ const validation = validateIntegrationSubmissionBundle(bundle);
507
+ if (!validation.ok) {
508
+ validation.errors.forEach((error) => {
509
+ errors.push(`bundle_set.bundles[${index}]: ${error}`);
510
+ });
511
+ }
512
+ });
513
+ }
514
+ return {
515
+ ok: errors.length === 0,
516
+ errors
517
+ };
518
+ }
519
+
520
+ function exportIntegrationSubmissionBundleSet(filters = {}, notes = null) {
521
+ return createIntegrationSubmissionBundleSet(
522
+ exportIntegrationSubmissionBundles(filters),
523
+ filters,
524
+ notes
525
+ );
526
+ }
527
+
528
+ function summarizeCounts(values, fieldName) {
529
+ return sortStrings(values).map((value) => ({
530
+ [fieldName]: value,
531
+ count: values.filter((entry) => entry === value).length
532
+ }));
533
+ }
534
+
535
+ function summarizeStructuredCounts(entries, fields = []) {
536
+ const rows = Array.isArray(entries) ? entries.filter((entry) => entry && typeof entry === "object") : [];
537
+ const normalizedFields = Array.isArray(fields) ? fields.filter(Boolean) : [];
538
+ const seen = new Map();
539
+
540
+ rows.forEach((entry) => {
541
+ const key = normalizedFields.map((field) => String(entry[field] || "")).join("::");
542
+ if (!seen.has(key)) {
543
+ const item = {};
544
+ normalizedFields.forEach((field) => {
545
+ item[field] = entry[field] || null;
546
+ });
547
+ item.count = 0;
548
+ seen.set(key, item);
549
+ }
550
+ seen.get(key).count += 1;
551
+ });
552
+
553
+ return Array.from(seen.values()).sort((left, right) => {
554
+ const leftKey = normalizedFields.map((field) => String(left[field] || "")).join("::");
555
+ const rightKey = normalizedFields.map((field) => String(right[field] || "")).join("::");
556
+ return leftKey.localeCompare(rightKey);
557
+ });
558
+ }
559
+
560
+ function buildPromotionReadinessSummary(input = {}) {
561
+ const registration = input.registration && typeof input.registration === "object" ? input.registration : {};
562
+ const certification = input.certification && typeof input.certification === "object" ? input.certification : {};
563
+ const integration = input.integration && typeof input.integration === "object" ? input.integration : {};
564
+ const blockers = [];
565
+ const registrationState = registration.registration_state || null;
566
+ const certificationState = certification.certification_state || integration.certification_state || null;
567
+ const maturity = integration.integration_maturity || null;
568
+ const defaultSelectionEnabled = registration.default_selection_enabled === true;
569
+ const requiresExplicitSelection = registration.requires_explicit_selection === true;
570
+ const bundled = registration.bundled === true;
571
+
572
+ if (!registrationState) blockers.push("registration_state_missing");
573
+ if (!certificationState) blockers.push("certification_state_missing");
574
+ if (!maturity) blockers.push("integration_maturity_missing");
575
+ if (certificationState !== "certified") blockers.push("not_certified");
576
+ if (maturity !== "production_default") blockers.push("not_marked_production_default");
577
+ if (!defaultSelectionEnabled) blockers.push("default_selection_disabled");
578
+ if (requiresExplicitSelection) blockers.push("still_requires_explicit_selection");
579
+ if (!bundled) blockers.push("not_bundled_for_default_rollout");
580
+
581
+ const reviewReady = registrationState === "staging_registered";
582
+ const selectionReady = defaultSelectionEnabled || requiresExplicitSelection;
583
+ const explicitSelectionReady = requiresExplicitSelection || defaultSelectionEnabled;
584
+ const productionDefaultReady = blockers.length === 0;
585
+
586
+ let posture = "unknown";
587
+ if (productionDefaultReady) {
588
+ posture = "production_default_ready";
589
+ } else if (reviewReady && certificationState === "certified") {
590
+ posture = "promotion_candidate";
591
+ } else if (reviewReady) {
592
+ posture = "staged_review";
593
+ } else if (selectionReady) {
594
+ posture = "selectable_non_default";
595
+ }
596
+
597
+ return {
598
+ registration_state: registrationState,
599
+ certification_state: certificationState,
600
+ integration_maturity: maturity,
601
+ selection_ready: selectionReady,
602
+ explicit_selection_ready: explicitSelectionReady,
603
+ default_eligible: defaultSelectionEnabled,
604
+ production_default_ready: productionDefaultReady,
605
+ review_ready: reviewReady,
606
+ posture,
607
+ blockers
608
+ };
609
+ }
610
+
611
+ function summarizePromotionBlockerCategories(blockers = []) {
612
+ const values = Array.isArray(blockers) ? blockers : [];
613
+ const categories = [];
614
+ if (values.some((entry) => entry === "registration_state_missing")) {
615
+ categories.push({
616
+ category: "registration",
617
+ severity: "high",
618
+ owner: "integration_author"
619
+ });
620
+ }
621
+ if (values.some((entry) => entry === "certification_state_missing" || entry === "not_certified")) {
622
+ categories.push({
623
+ category: "certification",
624
+ severity: "high",
625
+ owner: "review_operator"
626
+ });
627
+ }
628
+ if (values.some((entry) => entry === "integration_maturity_missing" || entry === "not_marked_production_default")) {
629
+ categories.push({
630
+ category: "maturity",
631
+ severity: "medium",
632
+ owner: "review_operator"
633
+ });
634
+ }
635
+ if (values.some((entry) => entry === "default_selection_disabled" || entry === "still_requires_explicit_selection")) {
636
+ categories.push({
637
+ category: "selection",
638
+ severity: "medium",
639
+ owner: "platform_operator"
640
+ });
641
+ }
642
+ if (values.some((entry) => entry === "not_bundled_for_default_rollout")) {
643
+ categories.push({
644
+ category: "rollout",
645
+ severity: "low",
646
+ owner: "release_operator"
647
+ });
648
+ }
649
+ return summarizeStructuredCounts(categories, ["category", "severity", "owner"]);
650
+ }
651
+
652
+ function buildCertificationGapSummary(readiness = {}, integration = {}) {
653
+ const blockers = Array.isArray(readiness.blockers) ? readiness.blockers : [];
654
+ const certificationScope = Array.isArray(integration.certification_scope) ? integration.certification_scope.filter(Boolean) : [];
655
+ const verifiedWith = integration.registration && Array.isArray(integration.registration.verified_with)
656
+ ? integration.registration.verified_with.filter(Boolean)
657
+ : [];
658
+ const missingRequirements = [];
659
+ const productionReady = readiness.production_default_ready === true;
660
+
661
+ if (blockers.includes("certification_state_missing") || blockers.includes("not_certified")) {
662
+ missingRequirements.push("certification_state");
663
+ }
664
+ if (!productionReady && certificationScope.length < 1) {
665
+ missingRequirements.push("certification_scope");
666
+ }
667
+ if (!productionReady && verifiedWith.length < 1) {
668
+ missingRequirements.push("verified_with");
669
+ }
670
+
671
+ return {
672
+ certification_state: readiness.certification_state || null,
673
+ certification_scope_count: certificationScope.length,
674
+ verified_with_count: verifiedWith.length,
675
+ missing_requirements: missingRequirements,
676
+ certifiable: missingRequirements.length === 0
677
+ };
678
+ }
679
+
680
+ function buildNextTransitionSummary(readiness = {}) {
681
+ const blockers = Array.isArray(readiness.blockers) ? readiness.blockers : [];
682
+ if (readiness.production_default_ready === true) {
683
+ return {
684
+ action: "maintain_production_default",
685
+ reason: "integration already satisfies production-default posture",
686
+ requirements: [],
687
+ later_actions: []
688
+ };
689
+ }
690
+ if (blockers.includes("registration_state_missing")) {
691
+ return {
692
+ action: "register_integration",
693
+ reason: "integration is missing a registration state",
694
+ requirements: ["registration_state"],
695
+ later_actions: ["complete_certification", "promote_maturity", "enable_default_selection", "bundle_for_default_rollout"]
696
+ };
697
+ }
698
+ if (blockers.includes("not_certified") || blockers.includes("certification_state_missing")) {
699
+ return {
700
+ action: "complete_certification",
701
+ reason: "integration is not yet certified",
702
+ requirements: ["certification_state"],
703
+ later_actions: ["promote_maturity", "enable_default_selection", "bundle_for_default_rollout"]
704
+ };
705
+ }
706
+ if (blockers.includes("not_marked_production_default") || blockers.includes("integration_maturity_missing")) {
707
+ return {
708
+ action: "promote_maturity",
709
+ reason: "integration maturity is not yet aligned with production default rollout",
710
+ requirements: ["integration_maturity"],
711
+ later_actions: ["enable_default_selection", "bundle_for_default_rollout"]
712
+ };
713
+ }
714
+ if (blockers.includes("default_selection_disabled") || blockers.includes("still_requires_explicit_selection")) {
715
+ return {
716
+ action: "enable_default_selection",
717
+ reason: "integration remains explicit-selection only",
718
+ requirements: ["default_selection_enabled", "requires_explicit_selection=false"],
719
+ later_actions: blockers.includes("not_bundled_for_default_rollout") ? ["bundle_for_default_rollout"] : []
720
+ };
721
+ }
722
+ if (blockers.includes("not_bundled_for_default_rollout")) {
723
+ return {
724
+ action: "bundle_for_default_rollout",
725
+ reason: "integration is not yet bundled for production default rollout",
726
+ requirements: ["bundled=true"],
727
+ later_actions: []
728
+ };
729
+ }
730
+ return {
731
+ action: "review_manually",
732
+ reason: "integration posture needs operator review",
733
+ requirements: [],
734
+ later_actions: []
735
+ };
736
+ }
737
+
738
+ function buildPromotionRecommendationSummary(readiness = {}) {
739
+ const nextTransition = buildNextTransitionSummary(readiness);
740
+ if (readiness.production_default_ready === true) {
741
+ return {
742
+ recommendation: "eligible_for_production_default",
743
+ rationale: "integration is ready for production-default posture"
744
+ };
745
+ }
746
+ if (readiness.review_ready === true && readiness.default_eligible === false) {
747
+ return {
748
+ recommendation: "keep_staged_until_requirements_clear",
749
+ rationale: nextTransition.reason
750
+ };
751
+ }
752
+ if (readiness.review_ready === true) {
753
+ return {
754
+ recommendation: "review_for_promotion",
755
+ rationale: nextTransition.reason
756
+ };
757
+ }
758
+ return {
759
+ recommendation: "complete_prerequisites_first",
760
+ rationale: nextTransition.reason
761
+ };
762
+ }
763
+
764
+ const PROMOTION_ACTION_DEFINITIONS = {
765
+ register_integration: {
766
+ action: "register_integration",
767
+ title: "Register Integration",
768
+ stage: "registration",
769
+ description: "Move an integration into an explicit staged registration posture."
770
+ },
771
+ complete_certification: {
772
+ action: "complete_certification",
773
+ title: "Complete Certification",
774
+ stage: "certification",
775
+ description: "Mark the integration as certified for the current public contract."
776
+ },
777
+ promote_maturity: {
778
+ action: "promote_maturity",
779
+ title: "Promote Maturity",
780
+ stage: "maturity",
781
+ description: "Align integration maturity with production-default rollout posture."
782
+ },
783
+ enable_default_selection: {
784
+ action: "enable_default_selection",
785
+ title: "Enable Default Selection",
786
+ stage: "selection",
787
+ description: "Allow the integration to participate in default selection instead of explicit-only use."
788
+ },
789
+ bundle_for_default_rollout: {
790
+ action: "bundle_for_default_rollout",
791
+ title: "Bundle For Default Rollout",
792
+ stage: "rollout",
793
+ description: "Mark the integration as bundled for production-default rollout."
794
+ },
795
+ maintain_production_default: {
796
+ action: "maintain_production_default",
797
+ title: "Maintain Production Default",
798
+ stage: "steady_state",
799
+ description: "Confirm the integration already satisfies production-default posture."
800
+ }
801
+ };
802
+
803
+ function getPromotionActionDefinition(action) {
804
+ const lookup = String(action || "").trim();
805
+ return PROMOTION_ACTION_DEFINITIONS[lookup] || null;
806
+ }
807
+
808
+ function clonePromotionSubject(summary = {}) {
809
+ return {
810
+ registration: clone(summary.registration || {}),
811
+ certification_state: summary.certification_state || null,
812
+ integration_maturity: summary.integration_maturity || null
813
+ };
814
+ }
815
+
816
+ function simulatePromotionActionSubject(summary = {}, action) {
817
+ const subject = clonePromotionSubject(summary);
818
+ switch (action) {
819
+ case "register_integration":
820
+ subject.registration.registration_state = "staging_registered";
821
+ if (subject.registration.default_selection_enabled !== true) {
822
+ subject.registration.default_selection_enabled = false;
823
+ }
824
+ if (subject.registration.requires_explicit_selection !== false) {
825
+ subject.registration.requires_explicit_selection = true;
826
+ }
827
+ break;
828
+ case "complete_certification":
829
+ subject.certification_state = "certified";
830
+ break;
831
+ case "promote_maturity":
832
+ subject.integration_maturity = "production_default";
833
+ break;
834
+ case "enable_default_selection":
835
+ subject.registration.default_selection_enabled = true;
836
+ subject.registration.requires_explicit_selection = false;
837
+ break;
838
+ case "bundle_for_default_rollout":
839
+ subject.registration.bundled = true;
840
+ break;
841
+ case "maintain_production_default":
842
+ break;
843
+ default:
844
+ break;
845
+ }
846
+ return subject;
847
+ }
848
+
849
+ function buildPromotionActionResultingReadiness(summary = {}, subject = {}) {
850
+ return buildPromotionReadinessSummary({
851
+ registration: subject.registration,
852
+ certification: {
853
+ certification_state: subject.certification_state || summary.certification_state || null
854
+ },
855
+ integration: {
856
+ integration_maturity: subject.integration_maturity || summary.integration_maturity || null
857
+ }
858
+ });
859
+ }
860
+
861
+ function buildPromotionActionStateChanges(current = {}, simulated = {}) {
862
+ const changes = [];
863
+ const currentRegistration = current.registration || {};
864
+ const simulatedRegistration = simulated.registration || {};
865
+ const fieldPairs = [
866
+ ["registration.registration_state", currentRegistration.registration_state, simulatedRegistration.registration_state],
867
+ ["registration.default_selection_enabled", currentRegistration.default_selection_enabled, simulatedRegistration.default_selection_enabled],
868
+ ["registration.requires_explicit_selection", currentRegistration.requires_explicit_selection, simulatedRegistration.requires_explicit_selection],
869
+ ["registration.bundled", currentRegistration.bundled, simulatedRegistration.bundled],
870
+ ["certification_state", current.certification_state, simulated.certification_state],
871
+ ["integration_maturity", current.integration_maturity, simulated.integration_maturity]
872
+ ];
873
+ fieldPairs.forEach(([field, fromValue, toValue]) => {
874
+ if (fromValue !== toValue) {
875
+ changes.push({
876
+ field,
877
+ from: fromValue === undefined ? null : fromValue,
878
+ to: toValue === undefined ? null : toValue
879
+ });
880
+ }
881
+ });
882
+ return changes;
883
+ }
884
+
885
+ function validatePromotionActionRequest(request = {}) {
886
+ const entry = request && typeof request === "object" && !Array.isArray(request) ? request : {};
887
+ const errors = [];
888
+ const integrationId = String(entry.integration_id || "").trim();
889
+ const action = String(entry.action || "").trim();
890
+ if (!integrationId) {
891
+ errors.push("promotion_action_request.integration_id is required");
892
+ }
893
+ if (!action) {
894
+ errors.push("promotion_action_request.action is required");
895
+ } else if (!getPromotionActionDefinition(action)) {
896
+ errors.push("promotion_action_request.action must be a supported promotion action");
897
+ }
898
+ return {
899
+ ok: errors.length === 0,
900
+ errors,
901
+ request: {
902
+ integration_id: integrationId || null,
903
+ action: action || null
904
+ }
905
+ };
906
+ }
907
+
908
+ function summarizeIntegrationPromotionActionPreview(request = {}) {
909
+ const validation = validatePromotionActionRequest(request);
910
+ if (!validation.ok) {
911
+ return {
912
+ ok: false,
913
+ reason: "invalid_promotion_action_request",
914
+ errors: validation.errors
915
+ };
916
+ }
917
+ const workflow = summarizeIntegrationPromotionWorkflow(validation.request.integration_id);
918
+ if (!workflow.ok) {
919
+ return workflow;
920
+ }
921
+
922
+ const action = validation.request.action;
923
+ const definition = getPromotionActionDefinition(action);
924
+ const currentSubject = clonePromotionSubject(workflow);
925
+ const simulatedSubject = simulatePromotionActionSubject(workflow, action);
926
+ const resultingReadiness = buildPromotionActionResultingReadiness(workflow, simulatedSubject);
927
+ const stateChanges = buildPromotionActionStateChanges(currentSubject, simulatedSubject);
928
+ const currentNextAction = workflow.next_transition && workflow.next_transition.action
929
+ ? workflow.next_transition.action
930
+ : null;
931
+ const currentLaterActions = Array.isArray(workflow.next_transition && workflow.next_transition.later_actions)
932
+ ? workflow.next_transition.later_actions
933
+ : [];
934
+ const validNow = currentNextAction === action || currentLaterActions.includes(action);
935
+ const invalidReasons = [];
936
+ if (!validNow) {
937
+ invalidReasons.push(action === "maintain_production_default"
938
+ ? "integration_is_not_yet_production_default_ready"
939
+ : "action_is_not_currently_recommended_from_present_posture");
940
+ }
941
+
942
+ return {
943
+ ok: true,
944
+ integration_id: workflow.integration_id,
945
+ display_name: workflow.display_name,
946
+ adapter_class: workflow.adapter_class,
947
+ source: workflow.source,
948
+ request: clone(validation.request),
949
+ action: clone(definition),
950
+ current_posture: {
951
+ registration_state: workflow.registration.registration_state || null,
952
+ certification_state: workflow.certification_state || null,
953
+ integration_maturity: workflow.integration_maturity || null,
954
+ promotion_readiness: clone(workflow.promotion_readiness || {})
955
+ },
956
+ valid_now: validNow,
957
+ is_recommended_next: currentNextAction === action,
958
+ invalid_reasons: invalidReasons,
959
+ requirements: currentNextAction === action
960
+ ? clone(workflow.next_transition.requirements || [])
961
+ : clone(buildNextTransitionSummary(resultingReadiness).requirements || []),
962
+ blockers: clone(workflow.promotion_readiness.blockers || []),
963
+ blocker_categories: clone(workflow.blocker_categories || []),
964
+ resulting_posture: {
965
+ registration_state: simulatedSubject.registration.registration_state || null,
966
+ certification_state: simulatedSubject.certification_state || null,
967
+ integration_maturity: simulatedSubject.integration_maturity || null,
968
+ promotion_readiness: clone(resultingReadiness)
969
+ },
970
+ state_changes: stateChanges,
971
+ current_transition: clone(workflow.next_transition || {}),
972
+ resulting_transition: buildNextTransitionSummary(resultingReadiness)
973
+ };
974
+ }
975
+
976
+ function summarizeIntegrationPromotionActionSet(integrationOrId) {
977
+ const workflow = summarizeIntegrationPromotionWorkflow(integrationOrId);
978
+ if (!workflow.ok) {
979
+ return workflow;
980
+ }
981
+ const actionOrder = [
982
+ workflow.next_transition && workflow.next_transition.action ? workflow.next_transition.action : null,
983
+ ...(Array.isArray(workflow.next_transition && workflow.next_transition.later_actions)
984
+ ? workflow.next_transition.later_actions
985
+ : []),
986
+ "maintain_production_default"
987
+ ].filter(Boolean);
988
+ const actions = sortStrings(actionOrder).map((action) => summarizeIntegrationPromotionActionPreview({
989
+ integration_id: workflow.integration_id,
990
+ action
991
+ }));
992
+ return {
993
+ ...workflow,
994
+ action_count: actions.length,
995
+ valid_now_count: actions.filter((entry) => entry.valid_now === true).length,
996
+ actions
997
+ };
998
+ }
999
+
1000
+ function summarizeIntegrationPromotionActionSetList(filters = {}) {
1001
+ const integrations = listIntegrations(filters).map((integration) => summarizeIntegrationPromotionActionSet(integration));
1002
+ return {
1003
+ ok: true,
1004
+ integration_count: integrations.length,
1005
+ valid_now_count: integrations.reduce((total, entry) => total + Number(entry.valid_now_count || 0), 0),
1006
+ recommended_actions: summarizeCounts(
1007
+ integrations
1008
+ .map((entry) => entry.next_transition && entry.next_transition.action)
1009
+ .filter(Boolean),
1010
+ "action"
1011
+ ),
1012
+ valid_actions: summarizeCounts(
1013
+ integrations
1014
+ .flatMap((entry) => Array.isArray(entry.actions) ? entry.actions : [])
1015
+ .filter((entry) => entry.valid_now === true)
1016
+ .map((entry) => entry.request && entry.request.action)
1017
+ .filter(Boolean),
1018
+ "action"
1019
+ ),
1020
+ integrations
1021
+ };
1022
+ }
1023
+
1024
+ function buildPromotionActionQueues(integrations = []) {
1025
+ const rows = Array.isArray(integrations) ? integrations.filter((entry) => entry && entry.next_transition) : [];
1026
+ const groups = new Map();
1027
+
1028
+ rows.forEach((entry) => {
1029
+ const action = entry.next_transition && entry.next_transition.action
1030
+ ? entry.next_transition.action
1031
+ : "review_manually";
1032
+ if (!groups.has(action)) {
1033
+ groups.set(action, []);
1034
+ }
1035
+ groups.get(action).push(entry);
1036
+ });
1037
+
1038
+ return Array.from(groups.keys()).sort().map((action) => {
1039
+ const entries = groups.get(action) || [];
1040
+ const blockerEntries = entries.flatMap((entry) => entry.blocker_categories || []);
1041
+ return {
1042
+ action,
1043
+ count: entries.length,
1044
+ recommendation_counts: summarizeCounts(
1045
+ entries.map((entry) => entry.promotion_recommendation && entry.promotion_recommendation.recommendation).filter(Boolean),
1046
+ "recommendation"
1047
+ ),
1048
+ owner_queue: summarizeCounts(
1049
+ blockerEntries.map((entry) => entry.owner).filter(Boolean),
1050
+ "owner"
1051
+ ),
1052
+ severity_queue: summarizeCounts(
1053
+ blockerEntries.map((entry) => entry.severity).filter(Boolean),
1054
+ "severity"
1055
+ ),
1056
+ integration_ids: entries.map((entry) => entry.integration_id).filter(Boolean).sort(),
1057
+ integrations: entries.map((entry) => ({
1058
+ integration_id: entry.integration_id,
1059
+ display_name: entry.display_name,
1060
+ adapter_class: entry.adapter_class,
1061
+ recommendation: entry.promotion_recommendation && entry.promotion_recommendation.recommendation,
1062
+ review_ready: entry.promotion_readiness && entry.promotion_readiness.review_ready === true,
1063
+ production_default_ready: entry.promotion_readiness && entry.promotion_readiness.production_default_ready === true
1064
+ }))
1065
+ };
1066
+ });
1067
+ }
1068
+
1069
+ function buildSubmissionBundleReviewWarnings(bundle) {
1070
+ const warnings = [];
1071
+ const registrationRecord = bundle && bundle.registration_record && typeof bundle.registration_record === "object"
1072
+ ? bundle.registration_record
1073
+ : {};
1074
+ const certificationPack = bundle && bundle.certification_pack && typeof bundle.certification_pack === "object"
1075
+ ? bundle.certification_pack
1076
+ : {};
1077
+
1078
+ if (registrationRecord.registration_state === "staging_registered") {
1079
+ warnings.push("integration is staging-registered and should be reviewed before broader promotion");
1080
+ }
1081
+ if (registrationRecord.requires_explicit_selection === true) {
1082
+ warnings.push("integration requires explicit selection and should not be treated as default");
1083
+ }
1084
+ if (registrationRecord.default_selection_enabled !== true) {
1085
+ warnings.push("integration is not currently eligible for default selection");
1086
+ }
1087
+ if (certificationPack.certification_state && certificationPack.certification_state !== "certified") {
1088
+ warnings.push("integration is not yet fully certified");
1089
+ }
1090
+
1091
+ return warnings;
1092
+ }
1093
+
1094
+ function summarizeIntegrationSubmissionBundleReview(bundleInput = {}) {
1095
+ const bundle = clone(bundleInput || {});
1096
+ const validation = validateIntegrationSubmissionBundle(bundle);
1097
+ const snapshotEntry = bundle.snapshot_entry && typeof bundle.snapshot_entry === "object"
1098
+ ? clone(bundle.snapshot_entry)
1099
+ : {};
1100
+ const manifest = bundle.manifest && typeof bundle.manifest === "object" ? bundle.manifest : {};
1101
+ const registrationRecord = bundle.registration_record && typeof bundle.registration_record === "object"
1102
+ ? bundle.registration_record
1103
+ : {};
1104
+ const certificationPack = bundle.certification_pack && typeof bundle.certification_pack === "object"
1105
+ ? bundle.certification_pack
1106
+ : {};
1107
+ const integrationId = registrationRecord.integration_id || manifest.adapter_id || snapshotEntry.integration_id || null;
1108
+ const adapterClass = registrationRecord.adapter_class || manifest.adapter_class || snapshotEntry.adapter_class || null;
1109
+ const protocols = sortStrings(snapshotEntry.protocols);
1110
+ const settlementModes = sortStrings(snapshotEntry.settlement_modes || manifest.supported_settlement_modes);
1111
+ const taskRefs = sortStrings(snapshotEntry.task_refs);
1112
+ const workflowRefs = sortStrings(snapshotEntry.workflow_refs);
1113
+ const warnings = buildSubmissionBundleReviewWarnings(bundle);
1114
+ const promotionReadiness = buildPromotionReadinessSummary({
1115
+ registration: {
1116
+ registration_state: registrationRecord.registration_state || null,
1117
+ bundled: registrationRecord.bundled === true,
1118
+ default_selection_enabled: registrationRecord.default_selection_enabled === true,
1119
+ requires_explicit_selection: registrationRecord.requires_explicit_selection === true
1120
+ },
1121
+ certification: {
1122
+ certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null
1123
+ },
1124
+ integration: {
1125
+ integration_maturity: registrationRecord.integration_maturity || snapshotEntry.integration_maturity || null,
1126
+ certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null
1127
+ }
1128
+ });
1129
+
1130
+ return {
1131
+ ok: validation.ok,
1132
+ review_kind: "integration_submission_bundle",
1133
+ validation,
1134
+ integration: {
1135
+ integration_id: integrationId,
1136
+ display_name: manifest.display_name || snapshotEntry.display_name || null,
1137
+ adapter_id: manifest.adapter_id || registrationRecord.adapter_id || null,
1138
+ adapter_class: adapterClass,
1139
+ adapter_version: manifest.adapter_version || snapshotEntry.adapter_version || null,
1140
+ source: snapshotEntry.source || null,
1141
+ certification_state: certificationPack.certification_state || snapshotEntry.certification_state || null,
1142
+ integration_maturity: registrationRecord.integration_maturity || snapshotEntry.integration_maturity || null,
1143
+ protocols,
1144
+ settlement_modes: settlementModes,
1145
+ task_refs: taskRefs,
1146
+ workflow_refs: workflowRefs
1147
+ },
1148
+ registration: {
1149
+ registration_state: registrationRecord.registration_state || null,
1150
+ bundled: registrationRecord.bundled === true,
1151
+ default_selection_enabled: registrationRecord.default_selection_enabled === true,
1152
+ requires_explicit_selection: registrationRecord.requires_explicit_selection === true,
1153
+ selection_priority: Number.isFinite(Number(registrationRecord.selection_priority))
1154
+ ? Number(registrationRecord.selection_priority)
1155
+ : null,
1156
+ registered_at: registrationRecord.registered_at || null,
1157
+ registered_by: registrationRecord.registered_by || null
1158
+ },
1159
+ certification: {
1160
+ certification_state: certificationPack.certification_state || null,
1161
+ certification_scope: sortStrings(certificationPack.certification_scope),
1162
+ verified_with: sortStrings(certificationPack.verified_with),
1163
+ submitted_at: certificationPack.submitted_at || null,
1164
+ submitted_by: certificationPack.submitted_by || null
1165
+ },
1166
+ promotion_readiness: promotionReadiness,
1167
+ review_summary: {
1168
+ warning_count: warnings.length,
1169
+ warnings,
1170
+ capability_count: Array.isArray(manifest.capabilities) ? manifest.capabilities.length : 0,
1171
+ protocol_count: protocols.length,
1172
+ settlement_mode_count: settlementModes.length,
1173
+ task_count: taskRefs.length,
1174
+ workflow_count: workflowRefs.length,
1175
+ selectable_via_explicit_request: registrationRecord.requires_explicit_selection === true
1176
+ || registrationRecord.default_selection_enabled === true,
1177
+ default_eligible: registrationRecord.default_selection_enabled === true,
1178
+ production_default_ready: promotionReadiness.production_default_ready
1179
+ }
1180
+ };
1181
+ }
1182
+
1183
+ function summarizeIntegrationSubmissionBundleSetReview(bundleSetInput = {}) {
1184
+ const bundleSet = clone(bundleSetInput || {});
1185
+ const validation = validateIntegrationSubmissionBundleSet(bundleSet);
1186
+ const bundleReviews = (Array.isArray(bundleSet.bundles) ? bundleSet.bundles : []).map((bundle) =>
1187
+ summarizeIntegrationSubmissionBundleReview(bundle)
1188
+ );
1189
+ const adapterClasses = bundleReviews.map((review) => review.integration.adapter_class).filter(Boolean);
1190
+ const registrationStates = bundleReviews.map((review) => review.registration.registration_state).filter(Boolean);
1191
+ const certificationStates = bundleReviews.map((review) => review.certification.certification_state).filter(Boolean);
1192
+
1193
+ return {
1194
+ ok: validation.ok,
1195
+ review_kind: "integration_submission_bundle_set",
1196
+ validation,
1197
+ bundle_set_version: bundleSet.bundle_set_version || null,
1198
+ bundle_count: Array.isArray(bundleSet.bundles) ? bundleSet.bundles.length : 0,
1199
+ generated_at: bundleSet.generated_at || null,
1200
+ filters: clone(bundleSet.filters || {}),
1201
+ notes: typeof bundleSet.notes === "string" ? bundleSet.notes : null,
1202
+ review_summary: {
1203
+ warning_count: bundleReviews.reduce((total, review) => total + review.review_summary.warning_count, 0),
1204
+ explicit_selection_required_count: bundleReviews.filter((review) => review.registration.requires_explicit_selection).length,
1205
+ default_eligible_count: bundleReviews.filter((review) => review.registration.default_selection_enabled).length,
1206
+ production_default_ready_count: bundleReviews.filter((review) => review.promotion_readiness.production_default_ready).length,
1207
+ review_ready_count: bundleReviews.filter((review) => review.promotion_readiness.review_ready).length,
1208
+ bundled_count: bundleReviews.filter((review) => review.registration.bundled).length,
1209
+ adapter_classes: summarizeCounts(adapterClasses, "adapter_class"),
1210
+ registration_states: summarizeCounts(registrationStates, "registration_state"),
1211
+ certification_states: summarizeCounts(certificationStates, "certification_state"),
1212
+ postures: summarizeCounts(bundleReviews.map((review) => review.promotion_readiness.posture).filter(Boolean), "posture")
1213
+ },
1214
+ bundles: bundleReviews
1215
+ };
1216
+ }
1217
+
1218
+ function summarizeIntegrationRegistrySnapshotReview(snapshotInput = {}) {
1219
+ const snapshot = clone(snapshotInput || {});
1220
+ const validation = validateIntegrationRegistrySnapshot(snapshot);
1221
+ const integrations = Array.isArray(snapshot.integrations) ? snapshot.integrations : [];
1222
+ const adapterClasses = integrations.map((integration) => integration.adapter_class).filter(Boolean);
1223
+ const sources = integrations.map((integration) => integration.source).filter(Boolean);
1224
+ const certificationStates = integrations.map((integration) => integration.certification_state).filter(Boolean);
1225
+ const registrationStates = integrations
1226
+ .map((integration) => integration.registration && integration.registration.registration_state)
1227
+ .filter(Boolean);
1228
+ const promotionReviews = integrations.map((integration) => buildPromotionReadinessSummary({
1229
+ registration: integration.registration,
1230
+ certification: {
1231
+ certification_state: integration.certification_state || null
1232
+ },
1233
+ integration
1234
+ }));
1235
+
1236
+ return {
1237
+ ok: validation.ok,
1238
+ review_kind: "integration_registry_snapshot",
1239
+ validation,
1240
+ snapshot_version: snapshot.snapshot_version || null,
1241
+ integration_count: integrations.length,
1242
+ generated_at: snapshot.generated_at || null,
1243
+ filters: clone(snapshot.filters || {}),
1244
+ review_summary: {
1245
+ production_default_count: integrations.filter((integration) => integration.integration_maturity === "production_default").length,
1246
+ staged_registration_count: integrations.filter((integration) => integration.registration && integration.registration.registration_state === "staging_registered").length,
1247
+ explicit_selection_required_count: integrations.filter((integration) => integration.registration && integration.registration.requires_explicit_selection === true).length,
1248
+ default_selection_enabled_count: integrations.filter((integration) => integration.registration && integration.registration.default_selection_enabled === true).length,
1249
+ production_default_ready_count: promotionReviews.filter((review) => review.production_default_ready).length,
1250
+ review_ready_count: promotionReviews.filter((review) => review.review_ready).length,
1251
+ adapter_classes: summarizeCounts(adapterClasses, "adapter_class"),
1252
+ sources: summarizeCounts(sources, "source"),
1253
+ certification_states: summarizeCounts(certificationStates, "certification_state"),
1254
+ registration_states: summarizeCounts(registrationStates, "registration_state"),
1255
+ postures: summarizeCounts(promotionReviews.map((review) => review.posture).filter(Boolean), "posture")
1256
+ }
1257
+ };
1258
+ }
1259
+
1260
+ function summarizeIntegrationPromotionReadiness(integrationOrId) {
1261
+ const integration = typeof integrationOrId === "string"
1262
+ ? getIntegration(integrationOrId)
1263
+ : clone(integrationOrId || null);
1264
+ if (!integration) {
1265
+ return {
1266
+ ok: false,
1267
+ reason: "integration_not_found"
1268
+ };
1269
+ }
1270
+ return {
1271
+ ok: true,
1272
+ integration_id: integration.integration_id,
1273
+ display_name: integration.display_name,
1274
+ adapter_class: integration.adapter_class,
1275
+ source: integration.source,
1276
+ registration: clone(integration.registration || {}),
1277
+ certification_state: integration.certification_state || null,
1278
+ integration_maturity: integration.integration_maturity || null,
1279
+ promotion_readiness: buildPromotionReadinessSummary({
1280
+ registration: integration.registration,
1281
+ certification: {
1282
+ certification_state: integration.certification_state || null
1283
+ },
1284
+ integration
1285
+ })
1286
+ };
1287
+ }
1288
+
1289
+ function summarizeIntegrationPromotionWorkflow(integrationOrId) {
1290
+ const summary = summarizeIntegrationPromotionReadiness(integrationOrId);
1291
+ if (!summary.ok) {
1292
+ return summary;
1293
+ }
1294
+ const readiness = clone(summary.promotion_readiness || {});
1295
+ return {
1296
+ ...summary,
1297
+ certification_gaps: buildCertificationGapSummary(readiness, summary),
1298
+ blocker_categories: summarizePromotionBlockerCategories(readiness.blockers),
1299
+ next_transition: buildNextTransitionSummary(readiness),
1300
+ promotion_recommendation: buildPromotionRecommendationSummary(readiness)
1301
+ };
1302
+ }
1303
+
1304
+ function summarizeIntegrationPromotionWorkflowList(filters = {}) {
1305
+ const integrations = listIntegrations(filters).map((integration) => summarizeIntegrationPromotionWorkflow(integration));
1306
+ const blockerCategoryEntries = integrations.flatMap((entry) => entry.blocker_categories || []);
1307
+ return {
1308
+ ok: true,
1309
+ integration_count: integrations.length,
1310
+ review_ready_count: integrations.filter((entry) => entry.promotion_readiness.review_ready).length,
1311
+ production_default_ready_count: integrations.filter((entry) => entry.promotion_readiness.production_default_ready).length,
1312
+ certifiable_count: integrations.filter((entry) => entry.certification_gaps.certifiable).length,
1313
+ next_actions: summarizeCounts(
1314
+ integrations.map((entry) => entry.next_transition.action).filter(Boolean),
1315
+ "action"
1316
+ ),
1317
+ recommendations: summarizeCounts(
1318
+ integrations.map((entry) => entry.promotion_recommendation.recommendation).filter(Boolean),
1319
+ "recommendation"
1320
+ ),
1321
+ blocker_categories: summarizeStructuredCounts(
1322
+ blockerCategoryEntries,
1323
+ ["category", "severity", "owner"]
1324
+ ),
1325
+ owner_queue: summarizeCounts(
1326
+ blockerCategoryEntries.map((entry) => entry.owner).filter(Boolean),
1327
+ "owner"
1328
+ ),
1329
+ severity_queue: summarizeCounts(
1330
+ blockerCategoryEntries.map((entry) => entry.severity).filter(Boolean),
1331
+ "severity"
1332
+ ),
1333
+ next_action_queues: buildPromotionActionQueues(integrations),
1334
+ integrations
1335
+ };
1336
+ }
1337
+
1338
+ function buildBuiltInIntegrations() {
1339
+ const httpTaskRefs = collectTaskRefsByAdapter("http");
1340
+ const mcpTaskRefs = collectTaskRefsByAdapter("mcp");
1341
+ const chainTaskRefs = collectTaskRefsByAdapter("chain");
1342
+ const settlementModes = (Array.isArray(catalog.settlement_profiles) ? catalog.settlement_profiles : []).map((profile) => profile.mode);
1343
+
1344
+ return [
1345
+ {
1346
+ integration_id: "builtin.execution.http",
1347
+ display_name: "Built-In HTTP Execution",
1348
+ description: "Default execution path for task and workflow lanes served directly by xytara.",
1349
+ adapter_class: "execution_adapter",
1350
+ adapter_version: "1.4.0",
1351
+ interface_version: "commerce-adapter-interface/v1",
1352
+ bundled: true,
1353
+ source: "builtin",
1354
+ status: "available",
1355
+ certification_state: "certified",
1356
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1357
+ integration_maturity: "production_default",
1358
+ selection_priority: 100,
1359
+ capabilities: sortStrings(
1360
+ (Array.isArray(catalog.tasks) ? catalog.tasks : [])
1361
+ .filter((task) => Array.isArray(task.adapters) && task.adapters.includes("http"))
1362
+ .flatMap((task) => task.capabilities || [])
1363
+ ),
1364
+ protocols: [],
1365
+ settlement_modes: [],
1366
+ execution_backends: ["http"],
1367
+ adapter_lanes: ["http"],
1368
+ task_refs: sortStrings(httpTaskRefs),
1369
+ workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(httpTaskRefs)),
1370
+ required_secrets: [],
1371
+ required_permissions: [],
1372
+ supported_profiles: ["default"],
1373
+ supported_regions: ["global"],
1374
+ pricing_basis: "per_task",
1375
+ latency_class: "mixed",
1376
+ proof_contract: {
1377
+ emits_proof_compatible_facts: true,
1378
+ proof_mode: "execution_facts_only"
1379
+ },
1380
+ health_contract: {
1381
+ check_kind: "internal",
1382
+ supports_readiness: true
1383
+ },
1384
+ idempotency_contract: {
1385
+ strategy: "command_quote_binding",
1386
+ scope: "task_execution"
1387
+ },
1388
+ failure_contract: {
1389
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
1390
+ retryable_categories: ["timeout", "upstream_unavailable"]
1391
+ },
1392
+ compatibility: {
1393
+ node: ">=18",
1394
+ commerce_contract: "xytara/v1"
1395
+ },
1396
+ operational_readiness: {
1397
+ supports_default_selection: true,
1398
+ supports_forced_selection: true,
1399
+ lifecycle: "managed_builtin",
1400
+ health_source: "internal"
1401
+ },
1402
+ selection_hints: {
1403
+ default_for_task_refs: sortStrings(httpTaskRefs),
1404
+ default_for_protocols: [],
1405
+ default_for_settlement_modes: []
1406
+ }
1407
+ },
1408
+ {
1409
+ integration_id: "builtin.protocol.mcp",
1410
+ display_name: "Built-In MCP Protocol Lane",
1411
+ description: "Built-in machine protocol lane for MCP tool discovery and invocation through the commerce flow.",
1412
+ adapter_class: "agent_protocol_adapter",
1413
+ adapter_version: "1.4.0",
1414
+ interface_version: "commerce-adapter-interface/v1",
1415
+ bundled: true,
1416
+ source: "builtin",
1417
+ status: "available",
1418
+ certification_state: "certified",
1419
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1420
+ integration_maturity: "production_default",
1421
+ selection_priority: 80,
1422
+ capabilities: ["adapter.mcp.invoke"],
1423
+ protocols: ["mcp"],
1424
+ settlement_modes: [],
1425
+ execution_backends: ["mcp"],
1426
+ adapter_lanes: ["mcp"],
1427
+ task_refs: sortStrings(mcpTaskRefs),
1428
+ workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(mcpTaskRefs)),
1429
+ required_secrets: [],
1430
+ required_permissions: [],
1431
+ supported_profiles: ["default"],
1432
+ supported_regions: ["global"],
1433
+ pricing_basis: "per_task",
1434
+ latency_class: "near_real_time",
1435
+ proof_contract: {
1436
+ emits_proof_compatible_facts: true,
1437
+ proof_mode: "protocol_invocation_facts"
1438
+ },
1439
+ health_contract: {
1440
+ check_kind: "internal",
1441
+ supports_readiness: true
1442
+ },
1443
+ idempotency_contract: {
1444
+ strategy: "quote_bound_invocation",
1445
+ scope: "protocol_invocation"
1446
+ },
1447
+ failure_contract: {
1448
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
1449
+ retryable_categories: ["timeout", "upstream_unavailable"]
1450
+ },
1451
+ compatibility: {
1452
+ node: ">=18",
1453
+ commerce_contract: "xytara/v1"
1454
+ },
1455
+ operational_readiness: {
1456
+ supports_default_selection: true,
1457
+ supports_forced_selection: true,
1458
+ lifecycle: "managed_builtin",
1459
+ health_source: "internal"
1460
+ },
1461
+ selection_hints: {
1462
+ default_for_task_refs: sortStrings(mcpTaskRefs),
1463
+ default_for_protocols: ["mcp"],
1464
+ default_for_settlement_modes: []
1465
+ }
1466
+ },
1467
+ {
1468
+ integration_id: "builtin.payment.x402",
1469
+ display_name: "Built-In x402 Payment Admission",
1470
+ description: "Built-in exact-payment challenge lane for x402-style machine payment admission.",
1471
+ adapter_class: "payment_rail_adapter",
1472
+ adapter_version: "1.4.0",
1473
+ interface_version: "commerce-adapter-interface/v1",
1474
+ bundled: true,
1475
+ source: "builtin",
1476
+ status: "available",
1477
+ certification_state: "certified",
1478
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1479
+ integration_maturity: "production_default",
1480
+ selection_priority: 60,
1481
+ capabilities: ["payment.admission", "payment.challenge", "payment.exact"],
1482
+ protocols: ["x402"],
1483
+ settlement_modes: sortStrings(settlementModes),
1484
+ execution_backends: [],
1485
+ adapter_lanes: ["x402"],
1486
+ task_refs: [],
1487
+ workflow_refs: [],
1488
+ required_secrets: [],
1489
+ required_permissions: [],
1490
+ supported_profiles: ["default"],
1491
+ supported_regions: ["global"],
1492
+ pricing_basis: "quote_then_settle",
1493
+ latency_class: "near_real_time",
1494
+ proof_contract: {
1495
+ emits_proof_compatible_facts: true,
1496
+ proof_mode: "payment_admission_facts"
1497
+ },
1498
+ health_contract: {
1499
+ check_kind: "internal",
1500
+ supports_readiness: true
1501
+ },
1502
+ idempotency_contract: {
1503
+ strategy: "quote_id",
1504
+ scope: "payment_admission"
1505
+ },
1506
+ failure_contract: {
1507
+ categories: ["invalid_input", "quote_expired", "payment_missing"],
1508
+ retryable_categories: []
1509
+ },
1510
+ compatibility: {
1511
+ node: ">=18",
1512
+ commerce_contract: "xytara/v1"
1513
+ },
1514
+ operational_readiness: {
1515
+ supports_default_selection: true,
1516
+ supports_forced_selection: true,
1517
+ lifecycle: "managed_builtin",
1518
+ health_source: "internal"
1519
+ },
1520
+ selection_hints: {
1521
+ default_for_task_refs: [],
1522
+ default_for_protocols: ["x402"],
1523
+ default_for_settlement_modes: sortStrings(settlementModes)
1524
+ }
1525
+ },
1526
+ {
1527
+ integration_id: "builtin.payment.l402",
1528
+ display_name: "Built-In L402 Payment Admission",
1529
+ description: "Built-in L402-style Lightning payment admission through a gateway-signed payment front.",
1530
+ adapter_class: "payment_rail_adapter",
1531
+ adapter_version: "1.4.0",
1532
+ interface_version: "commerce-adapter-interface/v1",
1533
+ bundled: true,
1534
+ source: "builtin",
1535
+ status: "available",
1536
+ certification_state: "certified",
1537
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1538
+ integration_maturity: "production_supported",
1539
+ selection_priority: 65,
1540
+ capabilities: ["payment.admission", "payment.challenge", "payment.permissionless_front"],
1541
+ protocols: ["l402"],
1542
+ settlement_modes: sortStrings(settlementModes),
1543
+ execution_backends: [],
1544
+ adapter_lanes: ["l402"],
1545
+ task_refs: [],
1546
+ workflow_refs: [],
1547
+ required_secrets: ["XYTARA_L402_SHARED_SECRET"],
1548
+ required_permissions: [],
1549
+ supported_profiles: ["default"],
1550
+ supported_regions: ["global"],
1551
+ pricing_basis: "quote_then_settle",
1552
+ latency_class: "near_real_time",
1553
+ proof_contract: {
1554
+ emits_proof_compatible_facts: true,
1555
+ proof_mode: "payment_admission_facts"
1556
+ },
1557
+ health_contract: {
1558
+ check_kind: "internal",
1559
+ supports_readiness: true
1560
+ },
1561
+ idempotency_contract: {
1562
+ strategy: "quote_id",
1563
+ scope: "payment_admission"
1564
+ },
1565
+ failure_contract: {
1566
+ categories: ["invalid_input", "quote_expired", "payment_missing"],
1567
+ retryable_categories: []
1568
+ },
1569
+ compatibility: {
1570
+ node: ">=18",
1571
+ commerce_contract: "xytara/v1"
1572
+ },
1573
+ operational_readiness: {
1574
+ supports_default_selection: false,
1575
+ supports_forced_selection: true,
1576
+ lifecycle: "managed_builtin",
1577
+ health_source: "internal"
1578
+ },
1579
+ selection_hints: {
1580
+ default_for_task_refs: [],
1581
+ default_for_protocols: [],
1582
+ default_for_settlement_modes: sortStrings(settlementModes)
1583
+ }
1584
+ },
1585
+ {
1586
+ integration_id: "builtin.payment.bolt",
1587
+ display_name: "Built-In BOLT Payment Admission",
1588
+ description: "Built-in BOLT-style UTXO/SPV payment admission through a signed proof-carrying payment front.",
1589
+ adapter_class: "payment_rail_adapter",
1590
+ adapter_version: "1.4.0",
1591
+ interface_version: "commerce-adapter-interface/v1",
1592
+ bundled: true,
1593
+ source: "builtin",
1594
+ status: "available",
1595
+ certification_state: "certified",
1596
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1597
+ integration_maturity: "production_supported",
1598
+ selection_priority: 66,
1599
+ capabilities: ["payment.admission", "payment.challenge", "payment.permissionless_front", "payment.spv_proof"],
1600
+ protocols: ["bolt"],
1601
+ settlement_modes: sortStrings(settlementModes),
1602
+ execution_backends: [],
1603
+ adapter_lanes: ["bolt"],
1604
+ task_refs: [],
1605
+ workflow_refs: [],
1606
+ required_secrets: ["XYTARA_BOLT_SHARED_SECRET"],
1607
+ required_permissions: [],
1608
+ supported_profiles: ["default"],
1609
+ supported_regions: ["global"],
1610
+ pricing_basis: "quote_then_settle",
1611
+ latency_class: "near_real_time",
1612
+ proof_contract: {
1613
+ emits_proof_compatible_facts: true,
1614
+ proof_mode: "spv_or_block_header_verifiable_payment_facts"
1615
+ },
1616
+ health_contract: {
1617
+ check_kind: "internal",
1618
+ supports_readiness: true
1619
+ },
1620
+ idempotency_contract: {
1621
+ strategy: "quote_id",
1622
+ scope: "payment_admission"
1623
+ },
1624
+ failure_contract: {
1625
+ categories: ["invalid_input", "quote_expired", "payment_missing"],
1626
+ retryable_categories: []
1627
+ },
1628
+ compatibility: {
1629
+ node: ">=18",
1630
+ commerce_contract: "xytara/v1"
1631
+ },
1632
+ operational_readiness: {
1633
+ supports_default_selection: false,
1634
+ supports_forced_selection: true,
1635
+ lifecycle: "managed_builtin",
1636
+ health_source: "internal"
1637
+ },
1638
+ selection_hints: {
1639
+ default_for_task_refs: [],
1640
+ default_for_protocols: [],
1641
+ default_for_settlement_modes: sortStrings(settlementModes)
1642
+ }
1643
+ },
1644
+ {
1645
+ integration_id: "builtin.settlement.chain",
1646
+ display_name: "Built-In Chain Settlement",
1647
+ description: "Built-in settlement lane spanning the canonical chain-backed settlement profiles bundled in xytara.",
1648
+ adapter_class: "settlement_adapter",
1649
+ adapter_version: "1.4.0",
1650
+ interface_version: "commerce-adapter-interface/v1",
1651
+ bundled: true,
1652
+ source: "builtin",
1653
+ status: "available",
1654
+ certification_state: "certified",
1655
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1656
+ integration_maturity: "production_default",
1657
+ selection_priority: 90,
1658
+ capabilities: sortStrings(
1659
+ (Array.isArray(catalog.tasks) ? catalog.tasks : [])
1660
+ .filter((task) => Array.isArray(task.adapters) && task.adapters.includes("chain"))
1661
+ .flatMap((task) => task.capabilities || [])
1662
+ ),
1663
+ protocols: [],
1664
+ settlement_modes: sortStrings(settlementModes),
1665
+ execution_backends: ["chain"],
1666
+ adapter_lanes: ["chain"],
1667
+ task_refs: sortStrings(chainTaskRefs),
1668
+ workflow_refs: sortStrings(collectWorkflowRefsByTaskRefs(chainTaskRefs)),
1669
+ required_secrets: [],
1670
+ required_permissions: [],
1671
+ supported_profiles: ["default", "anchored"],
1672
+ supported_regions: ["global"],
1673
+ pricing_basis: "per_settlement",
1674
+ latency_class: "governed_async",
1675
+ proof_contract: {
1676
+ emits_proof_compatible_facts: true,
1677
+ proof_mode: "settlement_reference_only"
1678
+ },
1679
+ health_contract: {
1680
+ check_kind: "internal",
1681
+ supports_readiness: true
1682
+ },
1683
+ idempotency_contract: {
1684
+ strategy: "quote_and_target_binding",
1685
+ scope: "settlement_request"
1686
+ },
1687
+ failure_contract: {
1688
+ categories: ["invalid_input", "timeout", "upstream_unavailable", "settlement_failure"],
1689
+ retryable_categories: ["timeout", "upstream_unavailable"]
1690
+ },
1691
+ compatibility: {
1692
+ node: ">=18",
1693
+ commerce_contract: "xytara/v1"
1694
+ },
1695
+ operational_readiness: {
1696
+ supports_default_selection: true,
1697
+ supports_forced_selection: true,
1698
+ lifecycle: "managed_builtin",
1699
+ health_source: "internal"
1700
+ },
1701
+ selection_hints: {
1702
+ default_for_task_refs: sortStrings(chainTaskRefs),
1703
+ default_for_protocols: [],
1704
+ default_for_settlement_modes: sortStrings(settlementModes)
1705
+ }
1706
+ },
1707
+ {
1708
+ integration_id: "builtin.identity.registry",
1709
+ display_name: "Built-In Registry Identity Surface",
1710
+ description: "Built-in registry and anchoring surface used by trust, registry, and lifecycle records.",
1711
+ adapter_class: "identity_registry_adapter",
1712
+ adapter_version: "1.4.0",
1713
+ interface_version: "commerce-adapter-interface/v1",
1714
+ bundled: true,
1715
+ source: "builtin",
1716
+ status: "available",
1717
+ certification_state: "certified",
1718
+ certification_scope: ["builtin_runtime", "service_contract", "sdk_contract"],
1719
+ integration_maturity: "production_default",
1720
+ selection_priority: 70,
1721
+ capabilities: ["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"],
1722
+ protocols: [],
1723
+ settlement_modes: [],
1724
+ execution_backends: ["http", "chain"],
1725
+ adapter_lanes: ["http", "chain"],
1726
+ task_refs: sortStrings(["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"]),
1727
+ workflow_refs: sortStrings(["registry.anchor.flow", "trust.flow"]),
1728
+ required_secrets: [],
1729
+ required_permissions: [],
1730
+ supported_profiles: ["registry", "trust"],
1731
+ supported_regions: ["global"],
1732
+ pricing_basis: "per_task",
1733
+ latency_class: "mixed",
1734
+ proof_contract: {
1735
+ emits_proof_compatible_facts: true,
1736
+ proof_mode: "registry_reference_facts"
1737
+ },
1738
+ health_contract: {
1739
+ check_kind: "internal",
1740
+ supports_readiness: true
1741
+ },
1742
+ idempotency_contract: {
1743
+ strategy: "record_ref_binding",
1744
+ scope: "registry_request"
1745
+ },
1746
+ failure_contract: {
1747
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
1748
+ retryable_categories: ["timeout", "upstream_unavailable"]
1749
+ },
1750
+ compatibility: {
1751
+ node: ">=18",
1752
+ commerce_contract: "xytara/v1"
1753
+ },
1754
+ operational_readiness: {
1755
+ supports_default_selection: true,
1756
+ supports_forced_selection: true,
1757
+ lifecycle: "managed_builtin",
1758
+ health_source: "internal"
1759
+ },
1760
+ selection_hints: {
1761
+ default_for_task_refs: sortStrings(["registry.register", "anchoring.submit", "trust.handoff.emit", "trust.handoff.validate"]),
1762
+ default_for_protocols: [],
1763
+ default_for_settlement_modes: []
1764
+ }
1765
+ },
1766
+ createBuiltinBreadthIntegration({
1767
+ integration_id: "builtin.protocol.a2a",
1768
+ display_name: "Built-In A2A Protocol Surface",
1769
+ description: "Built-in explicit agent-to-agent protocol surface for negotiation, commit, and settlement flow handoff.",
1770
+ adapter_class: "agent_protocol_adapter",
1771
+ capabilities: ["a2a.negotiate", "a2a.commit"],
1772
+ protocols: ["a2a"],
1773
+ execution_backends: ["a2a"],
1774
+ adapter_lanes: ["a2a"],
1775
+ task_refs: ["a2a.negotiate", "a2a.commit"],
1776
+ workflow_refs: ["a2a.settlement.flow"],
1777
+ supported_profiles: ["interaction"]
1778
+ }),
1779
+ createBuiltinBreadthIntegration({
1780
+ integration_id: "builtin.protocol.acp",
1781
+ display_name: "Built-In ACP Protocol Surface",
1782
+ description: "Built-in explicit ACP integration surface for third-party commerce and agent marketplace bridging.",
1783
+ adapter_class: "agent_protocol_adapter",
1784
+ capabilities: ["protocol.acp.bridge"],
1785
+ protocols: ["acp"],
1786
+ execution_backends: ["acp"],
1787
+ adapter_lanes: ["acp"],
1788
+ supported_profiles: ["marketplace", "interaction"]
1789
+ }),
1790
+ createBuiltinBreadthIntegration({
1791
+ integration_id: "builtin.protocol.mqtt",
1792
+ display_name: "Built-In MQTT Protocol Surface",
1793
+ description: "Built-in MQTT-facing protocol surface for message-driven machine interaction ingestion.",
1794
+ adapter_class: "agent_protocol_adapter",
1795
+ capabilities: ["protocol.mqtt.bridge"],
1796
+ protocols: ["mqtt"],
1797
+ execution_backends: ["mqtt"],
1798
+ adapter_lanes: ["mqtt"],
1799
+ supported_profiles: ["message_bus"]
1800
+ }),
1801
+ createBuiltinBreadthIntegration({
1802
+ integration_id: "builtin.protocol.grpc",
1803
+ display_name: "Built-In gRPC Protocol Surface",
1804
+ description: "Built-in gRPC-facing protocol surface for service-to-service commerce integration.",
1805
+ adapter_class: "agent_protocol_adapter",
1806
+ capabilities: ["protocol.grpc.bridge"],
1807
+ protocols: ["grpc"],
1808
+ execution_backends: ["grpc"],
1809
+ adapter_lanes: ["grpc"],
1810
+ supported_profiles: ["service_mesh"]
1811
+ }),
1812
+ createBuiltinBreadthIntegration({
1813
+ integration_id: "builtin.protocol.kafka",
1814
+ display_name: "Built-In Kafka Protocol Surface",
1815
+ description: "Built-in Kafka-facing protocol surface for streaming commerce/event ingress.",
1816
+ adapter_class: "agent_protocol_adapter",
1817
+ capabilities: ["protocol.kafka.bridge"],
1818
+ protocols: ["kafka"],
1819
+ execution_backends: ["kafka"],
1820
+ adapter_lanes: ["kafka"],
1821
+ supported_profiles: ["streaming"]
1822
+ }),
1823
+ createBuiltinBreadthIntegration({
1824
+ integration_id: "builtin.protocol.nats",
1825
+ display_name: "Built-In NATS Protocol Surface",
1826
+ description: "Built-in NATS-facing protocol surface for lightweight message-bus integration.",
1827
+ adapter_class: "agent_protocol_adapter",
1828
+ capabilities: ["protocol.nats.bridge"],
1829
+ protocols: ["nats"],
1830
+ execution_backends: ["nats"],
1831
+ adapter_lanes: ["nats"],
1832
+ supported_profiles: ["streaming"]
1833
+ }),
1834
+ createBuiltinBreadthIntegration({
1835
+ integration_id: "builtin.protocol.ros2",
1836
+ display_name: "Built-In ROS2 Protocol Surface",
1837
+ description: "Built-in ROS2-facing protocol surface for robotics-adjacent machine interaction integration.",
1838
+ adapter_class: "agent_protocol_adapter",
1839
+ capabilities: ["protocol.ros2.bridge"],
1840
+ protocols: ["ros2"],
1841
+ execution_backends: ["ros2"],
1842
+ adapter_lanes: ["ros2"],
1843
+ supported_profiles: ["robotics"]
1844
+ }),
1845
+ createBuiltinBreadthIntegration({
1846
+ integration_id: "builtin.execution.langchain",
1847
+ display_name: "Built-In LangChain Execution Surface",
1848
+ description: "Built-in execution-front surface for LangChain-style orchestration interoperability.",
1849
+ adapter_class: "execution_adapter",
1850
+ capabilities: ["execution.langchain.chain"],
1851
+ execution_backends: ["langchain"],
1852
+ adapter_lanes: ["langchain"],
1853
+ supported_profiles: ["agent_runtime"]
1854
+ }),
1855
+ createBuiltinBreadthIntegration({
1856
+ integration_id: "builtin.execution.langgraph",
1857
+ display_name: "Built-In LangGraph Execution Surface",
1858
+ description: "Built-in execution-front surface for LangGraph-style graph orchestration interoperability.",
1859
+ adapter_class: "execution_adapter",
1860
+ capabilities: ["execution.langgraph.graph"],
1861
+ execution_backends: ["langgraph"],
1862
+ adapter_lanes: ["langgraph"],
1863
+ supported_profiles: ["agent_runtime"]
1864
+ }),
1865
+ createBuiltinBreadthIntegration({
1866
+ integration_id: "builtin.execution.semantic_kernel",
1867
+ display_name: "Built-In Semantic Kernel Execution Surface",
1868
+ description: "Built-in execution-front surface for Semantic Kernel-style orchestration interoperability.",
1869
+ adapter_class: "execution_adapter",
1870
+ capabilities: ["execution.semantic_kernel.plan"],
1871
+ execution_backends: ["semantic_kernel"],
1872
+ adapter_lanes: ["semantic_kernel"],
1873
+ supported_profiles: ["agent_runtime"]
1874
+ }),
1875
+ createBuiltinBreadthIntegration({
1876
+ integration_id: "builtin.execution.autogen",
1877
+ display_name: "Built-In AutoGen Execution Surface",
1878
+ description: "Built-in execution-front surface for AutoGen-style multi-agent orchestration interoperability.",
1879
+ adapter_class: "execution_adapter",
1880
+ capabilities: ["execution.autogen.session"],
1881
+ execution_backends: ["autogen"],
1882
+ adapter_lanes: ["autogen"],
1883
+ supported_profiles: ["agent_runtime"]
1884
+ }),
1885
+ createBuiltinBreadthIntegration({
1886
+ integration_id: "builtin.execution.crewai",
1887
+ display_name: "Built-In CrewAI Execution Surface",
1888
+ description: "Built-in execution-front surface for CrewAI-style workflow interoperability.",
1889
+ adapter_class: "execution_adapter",
1890
+ capabilities: ["execution.crewai.crew"],
1891
+ execution_backends: ["crewai"],
1892
+ adapter_lanes: ["crewai"],
1893
+ supported_profiles: ["agent_runtime"]
1894
+ }),
1895
+ createBuiltinBreadthIntegration({
1896
+ integration_id: "builtin.execution.llamaindex",
1897
+ display_name: "Built-In LlamaIndex Execution Surface",
1898
+ description: "Built-in execution-front surface for LlamaIndex-style retrieval and agent interoperability.",
1899
+ adapter_class: "execution_adapter",
1900
+ capabilities: ["execution.llamaindex.workflow"],
1901
+ execution_backends: ["llamaindex"],
1902
+ adapter_lanes: ["llamaindex"],
1903
+ supported_profiles: ["agent_runtime", "retrieval"]
1904
+ }),
1905
+ createBuiltinBreadthIntegration({
1906
+ integration_id: "builtin.payment.mpp",
1907
+ display_name: "Built-In MPP Payment Surface",
1908
+ description: "Built-in multi-party payment admission surface for broader machine payment interoperability.",
1909
+ adapter_class: "payment_rail_adapter",
1910
+ capabilities: ["payment.mpp.admission"],
1911
+ protocols: ["mpp"],
1912
+ settlement_modes: sortStrings(settlementModes),
1913
+ adapter_lanes: ["mpp"],
1914
+ required_secrets: ["XYTARA_MPP_SHARED_SECRET"],
1915
+ supported_profiles: ["payment"]
1916
+ }),
1917
+ createBuiltinBreadthIntegration({
1918
+ integration_id: "builtin.identity.erc8004",
1919
+ display_name: "Built-In ERC-8004 Identity Surface",
1920
+ description: "Built-in ERC-8004-oriented identity action surface for broader machine identity interoperability.",
1921
+ adapter_class: "identity_registry_adapter",
1922
+ capabilities: ["identity.erc8004.action"],
1923
+ protocols: ["erc8004"],
1924
+ execution_backends: ["erc8004"],
1925
+ adapter_lanes: ["erc8004"],
1926
+ supported_profiles: ["identity", "registry"]
1927
+ })
1928
+ ];
1929
+ }
1930
+
1931
+ const EXAMPLE_INTEGRATIONS = [
1932
+ mapManifestToIntegration(executionExampleManifest, {
1933
+ source: "example",
1934
+ execution_backends: ["echo"],
1935
+ adapter_lanes: ["http"],
1936
+ certification_state: "reference_example",
1937
+ certification_scope: ["contract_shape"],
1938
+ integration_maturity: "reference_example",
1939
+ selection_priority: 950,
1940
+ supports_default_selection: false,
1941
+ supports_forced_selection: true,
1942
+ lifecycle: "example_only",
1943
+ health_source: "self_reported",
1944
+ default_for_task_refs: [],
1945
+ default_for_protocols: [],
1946
+ default_for_settlement_modes: []
1947
+ }),
1948
+ mapManifestToIntegration(settlementExampleManifest, {
1949
+ source: "example",
1950
+ adapter_lanes: ["chain"],
1951
+ certification_state: "reference_example",
1952
+ certification_scope: ["contract_shape"],
1953
+ integration_maturity: "reference_example",
1954
+ selection_priority: 960,
1955
+ supports_default_selection: false,
1956
+ supports_forced_selection: true,
1957
+ lifecycle: "example_only",
1958
+ health_source: "self_reported",
1959
+ default_for_task_refs: [],
1960
+ default_for_protocols: [],
1961
+ default_for_settlement_modes: []
1962
+ }),
1963
+ createRegisteredIntegrationFromManifest({
1964
+ adapter_id: exampleThirdPartyRegistrationRecord.adapter_id,
1965
+ adapter_class: exampleThirdPartyRegistrationRecord.adapter_class,
1966
+ adapter_version: "0.1.0",
1967
+ interface_version: "commerce-adapter-interface/v1",
1968
+ display_name: "Acme MCP Partner Adapter",
1969
+ description: "Reference third-party MCP integration showing how staged non-bundled registration should appear in discovery.",
1970
+ capabilities: ["adapter.mcp.invoke"],
1971
+ compatibility: {
1972
+ node: ">=18",
1973
+ commerce_contract: "xytara/v1",
1974
+ proof_contract: "xoonya/v1"
1975
+ },
1976
+ health_contract: {
1977
+ check_kind: "self_reported",
1978
+ supports_readiness: true
1979
+ },
1980
+ idempotency_contract: {
1981
+ strategy: "quote_bound_invocation",
1982
+ scope: "protocol_invocation"
1983
+ },
1984
+ failure_contract: {
1985
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
1986
+ retryable_categories: ["timeout", "upstream_unavailable"]
1987
+ },
1988
+ proof_contract: {
1989
+ emits_proof_compatible_facts: true,
1990
+ proof_mode: "protocol_invocation_facts"
1991
+ },
1992
+ latency_class: "near_real_time",
1993
+ pricing_basis: "per_task",
1994
+ required_secrets: ["ACME_MCP_TOKEN"],
1995
+ required_permissions: ["network:outbound"],
1996
+ supported_profiles: ["partner"],
1997
+ supported_regions: ["global"],
1998
+ supported_settlement_modes: exampleThirdPartyRegistrationRecord.settlement_modes
1999
+ }, exampleThirdPartyRegistrationRecord, {
2000
+ source: "third_party_example",
2001
+ status: "available",
2002
+ certification_scope: ["self_attested_contract_shape", "staging_smoke"],
2003
+ protocols: sortStrings(exampleThirdPartyRegistrationRecord.protocols),
2004
+ execution_backends: ["mcp"],
2005
+ adapter_lanes: ["mcp"],
2006
+ task_refs: sortStrings(exampleThirdPartyRegistrationRecord.task_refs),
2007
+ workflow_refs: [],
2008
+ supports_forced_selection: true,
2009
+ health_source: "self_reported"
2010
+ }),
2011
+ createRegisteredIntegrationFromManifest({
2012
+ adapter_id: exampleThirdPartyIdentityRegistrationRecord.adapter_id,
2013
+ adapter_class: exampleThirdPartyIdentityRegistrationRecord.adapter_class,
2014
+ adapter_version: "0.1.0",
2015
+ interface_version: "commerce-adapter-interface/v1",
2016
+ display_name: "Attest Registry Partner Identity Adapter",
2017
+ description: "Reference third-party identity registry integration showing how staged non-bundled identity registration should appear in discovery.",
2018
+ capabilities: ["registry.register", "trust.handoff.emit", "trust.handoff.validate"],
2019
+ compatibility: {
2020
+ node: ">=18",
2021
+ commerce_contract: "xytara/v1",
2022
+ proof_contract: "xoonya/v1"
2023
+ },
2024
+ health_contract: {
2025
+ check_kind: "self_reported",
2026
+ supports_readiness: true
2027
+ },
2028
+ idempotency_contract: {
2029
+ strategy: "record_ref_binding",
2030
+ scope: "registry_request"
2031
+ },
2032
+ failure_contract: {
2033
+ categories: ["invalid_input", "timeout", "upstream_unavailable"],
2034
+ retryable_categories: ["timeout", "upstream_unavailable"]
2035
+ },
2036
+ proof_contract: {
2037
+ emits_proof_compatible_facts: true,
2038
+ proof_mode: "registry_reference_facts"
2039
+ },
2040
+ latency_class: "near_real_time",
2041
+ pricing_basis: "per_task",
2042
+ required_secrets: ["ATTEST_REGISTRY_TOKEN"],
2043
+ required_permissions: ["network:outbound"],
2044
+ supported_profiles: ["partner", "registry", "trust"],
2045
+ supported_regions: ["global"],
2046
+ supported_settlement_modes: []
2047
+ }, exampleThirdPartyIdentityRegistrationRecord, {
2048
+ source: "third_party_example",
2049
+ status: "available",
2050
+ certification_scope: ["self_attested_contract_shape", "staging_identity_smoke"],
2051
+ protocols: sortStrings(exampleThirdPartyIdentityRegistrationRecord.protocols),
2052
+ execution_backends: ["http", "chain"],
2053
+ adapter_lanes: ["http", "chain"],
2054
+ task_refs: sortStrings(exampleThirdPartyIdentityRegistrationRecord.task_refs),
2055
+ workflow_refs: [],
2056
+ supports_forced_selection: true,
2057
+ health_source: "self_reported"
2058
+ }),
2059
+ createRegisteredIntegrationFromManifest({
2060
+ adapter_id: exampleThirdPartySettlementRegistrationRecord.adapter_id,
2061
+ adapter_class: exampleThirdPartySettlementRegistrationRecord.adapter_class,
2062
+ adapter_version: "0.1.0",
2063
+ interface_version: "commerce-adapter-interface/v1",
2064
+ display_name: "Lattice Anchor Settlement Adapter",
2065
+ description: "Reference third-party settlement integration showing how staged non-bundled settlement registration should appear in discovery.",
2066
+ capabilities: ["anchoring.submit", "settlement.reference"],
2067
+ compatibility: {
2068
+ node: ">=18",
2069
+ commerce_contract: "xytara/v1",
2070
+ proof_contract: "xoonya/v1"
2071
+ },
2072
+ health_contract: {
2073
+ check_kind: "self_reported",
2074
+ supports_readiness: true
2075
+ },
2076
+ idempotency_contract: {
2077
+ strategy: "quote_and_target_binding",
2078
+ scope: "settlement_request"
2079
+ },
2080
+ failure_contract: {
2081
+ categories: ["invalid_input", "timeout", "upstream_unavailable", "settlement_failure"],
2082
+ retryable_categories: ["timeout", "upstream_unavailable"]
2083
+ },
2084
+ proof_contract: {
2085
+ emits_proof_compatible_facts: true,
2086
+ proof_mode: "settlement_reference_only"
2087
+ },
2088
+ latency_class: "governed_async",
2089
+ pricing_basis: "per_settlement",
2090
+ required_secrets: ["LATTICE_SETTLEMENT_TOKEN"],
2091
+ required_permissions: ["network:outbound"],
2092
+ supported_profiles: ["partner", "anchored"],
2093
+ supported_regions: ["global"],
2094
+ supported_settlement_modes: exampleThirdPartySettlementRegistrationRecord.settlement_modes
2095
+ }, exampleThirdPartySettlementRegistrationRecord, {
2096
+ source: "third_party_example",
2097
+ status: "available",
2098
+ certification_scope: ["self_attested_contract_shape", "staging_settlement_smoke"],
2099
+ protocols: sortStrings(exampleThirdPartySettlementRegistrationRecord.protocols),
2100
+ execution_backends: ["chain"],
2101
+ adapter_lanes: ["chain"],
2102
+ task_refs: sortStrings(exampleThirdPartySettlementRegistrationRecord.task_refs),
2103
+ workflow_refs: [],
2104
+ supports_forced_selection: true,
2105
+ health_source: "self_reported"
2106
+ })
2107
+ ];
2108
+
2109
+ const INTEGRATIONS = buildBuiltInIntegrations().concat(EXAMPLE_INTEGRATIONS).map(clone);
2110
+
2111
+ const INTEGRATION_REGISTRATION_RECORDS = {
2112
+ [exampleThirdPartyRegistrationRecord.integration_id]: clone(exampleThirdPartyRegistrationRecord),
2113
+ [exampleThirdPartyIdentityRegistrationRecord.integration_id]: clone(exampleThirdPartyIdentityRegistrationRecord),
2114
+ [exampleThirdPartySettlementRegistrationRecord.integration_id]: clone(exampleThirdPartySettlementRegistrationRecord)
2115
+ };
2116
+
2117
+ function listIntegrations(filters = {}) {
2118
+ const normalized = {
2119
+ adapter_class: String(filters.adapter_class || filters.class || "").trim(),
2120
+ protocol: String(filters.protocol || "").trim(),
2121
+ settlement_mode: String(filters.settlement_mode || "").trim(),
2122
+ capability: String(filters.capability || "").trim(),
2123
+ task_ref: String(filters.task_ref || "").trim(),
2124
+ source: String(filters.source || "").trim(),
2125
+ certification_state: String(filters.certification_state || "").trim(),
2126
+ integration_maturity: String(filters.integration_maturity || filters.maturity || "").trim(),
2127
+ bundled: String(filters.bundled || "").trim()
2128
+ };
2129
+ return INTEGRATIONS.filter((integration) => {
2130
+ if (normalized.adapter_class && integration.adapter_class !== normalized.adapter_class) return false;
2131
+ if (normalized.protocol && !integration.protocols.includes(normalized.protocol)) return false;
2132
+ if (normalized.settlement_mode && !integration.settlement_modes.includes(normalized.settlement_mode)) return false;
2133
+ if (normalized.capability && !integration.capabilities.includes(normalized.capability)) return false;
2134
+ if (normalized.task_ref && !integration.task_refs.includes(normalized.task_ref)) return false;
2135
+ if (normalized.source && integration.source !== normalized.source) return false;
2136
+ if (normalized.certification_state && integration.certification_state !== normalized.certification_state) return false;
2137
+ if (normalized.integration_maturity && integration.integration_maturity !== normalized.integration_maturity) return false;
2138
+ if (normalized.bundled && String(integration.bundled) !== normalized.bundled) return false;
2139
+ return true;
2140
+ }).map((integration) => buildIntegrationView(integration, INTEGRATION_REGISTRATION_RECORDS[integration.integration_id]));
2141
+ }
2142
+
2143
+ function getIntegration(integrationId) {
2144
+ const lookup = String(integrationId || "").trim();
2145
+ const found = INTEGRATIONS.find((integration) => integration.integration_id === lookup);
2146
+ return found ? buildIntegrationView(found, INTEGRATION_REGISTRATION_RECORDS[found.integration_id]) : null;
2147
+ }
2148
+
2149
+ function summarizeIntegrations(filters = {}) {
2150
+ const integrations = listIntegrations(filters);
2151
+ return {
2152
+ ok: true,
2153
+ integration_count: integrations.length,
2154
+ integration_ids: integrations.map((integration) => integration.integration_id),
2155
+ class_count: sortStrings(integrations.map((integration) => integration.adapter_class)).length,
2156
+ protocol_count: sortStrings(integrations.flatMap((integration) => integration.protocols)).length,
2157
+ settlement_mode_count: sortStrings(integrations.flatMap((integration) => integration.settlement_modes)).length,
2158
+ certified_integration_count: integrations.filter((integration) => integration.certification_state === "certified").length,
2159
+ production_default_count: integrations.filter((integration) => integration.integration_maturity === "production_default").length,
2160
+ integrations: integrations.map((integration) => ({
2161
+ integration_id: integration.integration_id,
2162
+ display_name: integration.display_name,
2163
+ adapter_class: integration.adapter_class,
2164
+ source: integration.source,
2165
+ certification_state: integration.certification_state,
2166
+ integration_maturity: integration.integration_maturity,
2167
+ registration_state: integration.registration.registration_state,
2168
+ bundled: integration.registration.bundled,
2169
+ selection_priority: integration.selection_priority,
2170
+ protocols: integration.protocols,
2171
+ settlement_modes: integration.settlement_modes,
2172
+ task_count: integration.task_refs.length,
2173
+ workflow_count: integration.workflow_refs.length,
2174
+ capability_count: integration.capabilities.length
2175
+ }))
2176
+ };
2177
+ }
2178
+
2179
+ function summarizeIntegrationClasses(filters = {}) {
2180
+ const integrations = listIntegrations(filters);
2181
+ const classes = sortStrings(integrations.map((integration) => integration.adapter_class)).map((adapterClass) => ({
2182
+ adapter_class: adapterClass,
2183
+ integration_count: integrations.filter((integration) => integration.adapter_class === adapterClass).length
2184
+ }));
2185
+ return {
2186
+ ok: true,
2187
+ adapter_class_count: classes.length,
2188
+ adapter_classes: classes
2189
+ };
2190
+ }
2191
+
2192
+ function summarizeIntegrationProtocols(filters = {}) {
2193
+ const integrations = listIntegrations(filters);
2194
+ const protocols = sortStrings(integrations.flatMap((integration) => integration.protocols)).map((protocol) => ({
2195
+ protocol,
2196
+ integration_count: integrations.filter((integration) => integration.protocols.includes(protocol)).length
2197
+ }));
2198
+ return {
2199
+ ok: true,
2200
+ protocol_count: protocols.length,
2201
+ protocols
2202
+ };
2203
+ }
2204
+
2205
+ function summarizeIntegrationSettlementModes(filters = {}) {
2206
+ const integrations = listIntegrations(filters);
2207
+ const settlementModes = sortStrings(integrations.flatMap((integration) => integration.settlement_modes)).map((settlementMode) => ({
2208
+ settlement_mode: settlementMode,
2209
+ integration_count: integrations.filter((integration) => integration.settlement_modes.includes(settlementMode)).length
2210
+ }));
2211
+ return {
2212
+ ok: true,
2213
+ settlement_mode_count: settlementModes.length,
2214
+ settlement_modes: settlementModes
2215
+ };
2216
+ }
2217
+
2218
+ // 1.3.0 Phase 1 anchor:
2219
+ // The next workflow layer should stay read-only and build on top of
2220
+ // summarizeIntegrationPromotionReadiness(...), adding:
2221
+ // - promotion recommendation summaries
2222
+ // - next eligible transition summaries
2223
+ // - normalized blocker categories
2224
+ // without introducing mutation flows or persistent registry state.
2225
+
2226
+ module.exports = {
2227
+ getIntegration,
2228
+ listIntegrations,
2229
+ summarizeIntegrations,
2230
+ summarizeIntegrationClasses,
2231
+ summarizeIntegrationProtocols,
2232
+ summarizeIntegrationSettlementModes,
2233
+ validateIntegrationRegistration,
2234
+ validateIntegrationCertificationPack,
2235
+ validateIntegrationSubmission,
2236
+ importRegisteredIntegration,
2237
+ createIntegrationRegistrySnapshot,
2238
+ exportIntegrationRegistrySnapshot,
2239
+ validateIntegrationRegistrySnapshot,
2240
+ validateIntegrationSubmissionBundle,
2241
+ createIntegrationSubmissionBundle,
2242
+ importIntegrationSubmissionBundle,
2243
+ createIntegrationRegistrySnapshotFromBundles,
2244
+ exportIntegrationSubmissionBundles,
2245
+ createIntegrationSubmissionBundleSet,
2246
+ validateIntegrationSubmissionBundleSet,
2247
+ exportIntegrationSubmissionBundleSet,
2248
+ summarizeIntegrationSubmissionBundleReview,
2249
+ summarizeIntegrationSubmissionBundleSetReview,
2250
+ summarizeIntegrationRegistrySnapshotReview,
2251
+ summarizeIntegrationPromotionReadiness,
2252
+ summarizeIntegrationPromotionWorkflow,
2253
+ summarizeIntegrationPromotionWorkflowList,
2254
+ validatePromotionActionRequest,
2255
+ summarizeIntegrationPromotionActionPreview,
2256
+ summarizeIntegrationPromotionActionSet,
2257
+ summarizeIntegrationPromotionActionSetList,
2258
+ createRegisteredIntegrationFromManifest,
2259
+ buildIntegrationRegistrationView,
2260
+ buildIntegrationView
2261
+ };