@openplanr/protocol 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -0
  3. package/lib/dashboard/closed-json-contract.mjs +141 -0
  4. package/lib/dashboard/generated/operate-experience-surface-schema-data.mjs +67 -0
  5. package/lib/dashboard/generated/operate-review-schema-data.mjs +35 -0
  6. package/lib/dashboard/generated/operate-schema-token-codec.mjs +127 -0
  7. package/lib/dashboard/operate-experience-audit-display-contract.d.mts +196 -0
  8. package/lib/dashboard/operate-experience-audit-display-contract.mjs +700 -0
  9. package/lib/dashboard/operate-experience-display-contract.d.mts +572 -0
  10. package/lib/dashboard/operate-experience-display-contract.mjs +1007 -0
  11. package/lib/dashboard/operate-experience-surface-contract.d.mts +157 -0
  12. package/lib/dashboard/operate-experience-surface-contract.mjs +91 -0
  13. package/lib/dashboard/operate-review-contract.d.mts +34 -0
  14. package/lib/dashboard/operate-review-contract.mjs +175 -0
  15. package/lib/dashboard/operate-review-display-workspace-contract.d.mts +54 -0
  16. package/lib/dashboard/operate-review-display-workspace-contract.mjs +258 -0
  17. package/lib/dashboard/operate-review-payload-safety.d.mts +7 -0
  18. package/lib/dashboard/operate-review-payload-safety.mjs +42 -0
  19. package/lib/dashboard/operate-review-workspace-projection-v2.d.mts +218 -0
  20. package/lib/protocol/index.d.ts +2638 -0
  21. package/package.json +115 -0
  22. package/registries/commands.json +1952 -0
  23. package/registries/diagram-grammars.json +2407 -0
  24. package/registries/diagram-semantic-patterns.json +111 -0
  25. package/registries/output-paths.json +40 -0
  26. package/registries/outputs.json +864 -0
  27. package/registries/roles.json +661 -0
  28. package/registries/rules.json +261 -0
  29. package/registries/skill-host-profiles.json +247 -0
  30. package/registries/skill-modules.json +1112 -0
  31. package/registries/skill-routing.json +389 -0
  32. package/registries/skills.json +1545 -0
  33. package/registries/task-kinds.json +220 -0
  34. package/registry/adapters.json +110 -0
  35. package/registry/artifact-theme.json +60 -0
  36. package/registry/evaluation-graders.json +303 -0
  37. package/registry/evaluation-host-profiles.json +131 -0
  38. package/registry/frozen-commands.json +15 -0
  39. package/registry/landing-operations.json +20 -0
  40. package/registry/landing-workflows.json +70 -0
  41. package/registry/live-evidence-providers.json +1 -0
  42. package/registry/operate-v2-contracts.json +5965 -0
  43. package/registry/professional-skills.json +115 -0
  44. package/registry/roles.json +14 -0
  45. package/registry/ship-review-specialists.json +42 -0
  46. package/schemas/v1.0.0/design-approved.schema.json +35 -0
  47. package/schemas/v1.0.0/design-feedback.schema.json +169 -0
  48. package/schemas/v1.0.0/design-manifest.schema.json +90 -0
  49. package/schemas/v1.0.0/design-session.schema.json +73 -0
  50. package/schemas/v1.0.0/graph.schema.json +100 -0
  51. package/schemas/v1.0.0/pipeline-shipped.schema.json +154 -0
  52. package/schemas/v1.0.0/run-manifest.schema.json +81 -0
  53. package/schemas/v1.0.0/spec.schema.json +120 -0
  54. package/schemas/v1.0.0/stack.schema.json +184 -0
  55. package/schemas/v1.0.0/story.schema.json +95 -0
  56. package/schemas/v1.0.0/task.schema.json +171 -0
  57. package/schemas/v1.0.0/taste-profile.schema.json +96 -0
  58. package/schemas/v1.1.0/adapter-registry.schema.json +72 -0
  59. package/schemas/v1.1.0/artifact-envelope.schema.json +142 -0
  60. package/schemas/v1.1.0/artifact-paste.schema.json +49 -0
  61. package/schemas/v1.1.0/artifact-review.schema.json +97 -0
  62. package/schemas/v1.1.0/artifact-room-descriptor.schema.json +39 -0
  63. package/schemas/v1.1.0/artifact-room-event.schema.json +184 -0
  64. package/schemas/v1.1.0/artifact-room-signed-event.schema.json +58 -0
  65. package/schemas/v1.1.0/artifact-theme.schema.json +139 -0
  66. package/schemas/v1.1.0/browser-qa-gate.schema.json +21 -0
  67. package/schemas/v1.1.0/browser-qa-result.schema.json +24 -0
  68. package/schemas/v1.1.0/browser-qa-session.schema.json +12 -0
  69. package/schemas/v1.1.0/ecosystem-manifest.schema.json +46 -0
  70. package/schemas/v1.1.0/investigation-diagnosis.schema.json +12 -0
  71. package/schemas/v1.1.0/investigation-event.schema.json +15 -0
  72. package/schemas/v1.1.0/investigation-experiment.schema.json +17 -0
  73. package/schemas/v1.1.0/investigation-fix.schema.json +11 -0
  74. package/schemas/v1.1.0/investigation-hypothesis.schema.json +6 -0
  75. package/schemas/v1.1.0/investigation-observation.schema.json +10 -0
  76. package/schemas/v1.1.0/investigation-receipt.schema.json +7 -0
  77. package/schemas/v1.1.0/investigation-record.schema.json +7 -0
  78. package/schemas/v1.1.0/investigation-request.schema.json +34 -0
  79. package/schemas/v1.1.0/planning-review-event.schema.json +64 -0
  80. package/schemas/v1.1.0/planning-review-receipt.schema.json +19 -0
  81. package/schemas/v1.1.0/planning-review-record.schema.json +176 -0
  82. package/schemas/v1.1.0/planning-review-state.schema.json +19 -0
  83. package/schemas/v1.1.0/professional-skills.schema.json +105 -0
  84. package/schemas/v1.1.0/professional-specification.schema.json +111 -0
  85. package/schemas/v1.1.0/provenance-event.schema.json +82 -0
  86. package/schemas/v1.1.0/role-registry.schema.json +28 -0
  87. package/schemas/v1.1.0/runtime-lock.schema.json +39 -0
  88. package/schemas/v1.1.0/ship-closure.schema.json +353 -0
  89. package/schemas/v1.1.0/ship-review-specialist-registry.schema.json +29 -0
  90. package/schemas/v1.1.0/ship-risk-classification.schema.json +48 -0
  91. package/schemas/v1.1.0/specialist-review-result.schema.json +19 -0
  92. package/schemas/v1.10.0/design-review-bundle.schema.json +584 -0
  93. package/schemas/v1.10.0/design-review-context.schema.json +191 -0
  94. package/schemas/v1.10.0/design-review-handoff.schema.json +407 -0
  95. package/schemas/v1.10.0/design-review-metadata-payload.schema.json +106 -0
  96. package/schemas/v1.11.0/design-review-metadata-payload.schema.json +107 -0
  97. package/schemas/v1.12.0/enterprise-access-context.schema.json +217 -0
  98. package/schemas/v1.12.0/enterprise-agent-handoff.schema.json +508 -0
  99. package/schemas/v1.12.0/enterprise-artifact-revision.schema.json +87 -0
  100. package/schemas/v1.12.0/enterprise-change-proposal.schema.json +359 -0
  101. package/schemas/v1.12.0/enterprise-evidence-reference.schema.json +147 -0
  102. package/schemas/v1.12.0/enterprise-review-thread.schema.json +278 -0
  103. package/schemas/v1.12.0/enterprise-sync-state.schema.json +169 -0
  104. package/schemas/v1.2.0/adapter-registry.schema.json +83 -0
  105. package/schemas/v1.2.0/dashboard-bootstrap.schema.json +219 -0
  106. package/schemas/v1.2.0/ecosystem-release-operation.schema.json +90 -0
  107. package/schemas/v1.2.0/ecosystem-saga.schema.json +54 -0
  108. package/schemas/v1.2.0/evidence-diagnostic.schema.json +77 -0
  109. package/schemas/v1.2.0/guided-answer-envelope.schema.json +73 -0
  110. package/schemas/v1.2.0/guided-confirmation.schema.json +128 -0
  111. package/schemas/v1.2.0/guided-question.schema.json +242 -0
  112. package/schemas/v1.2.0/guided-questionnaire.schema.json +278 -0
  113. package/schemas/v1.2.0/guided-session.schema.json +141 -0
  114. package/schemas/v1.2.0/landing-confirmation.schema.json +17 -0
  115. package/schemas/v1.2.0/landing-event.schema.json +12 -0
  116. package/schemas/v1.2.0/landing-operation-registry.schema.json +16 -0
  117. package/schemas/v1.2.0/landing-phase-receipt.schema.json +19 -0
  118. package/schemas/v1.2.0/landing-plan.schema.json +36 -0
  119. package/schemas/v1.2.0/landing-receipt.schema.json +12 -0
  120. package/schemas/v1.2.0/landing-workflow-catalog.schema.json +143 -0
  121. package/schemas/v1.2.0/operate-action-display-workspace.schema.json +119 -0
  122. package/schemas/v1.2.0/operate-cycle-display-workspace.schema.json +109 -0
  123. package/schemas/v1.2.0/operate-executive-board-display-surface.schema.json +72 -0
  124. package/schemas/v1.2.0/operate-experience-audit-display-surface.schema.json +328 -0
  125. package/schemas/v1.2.0/operate-experience-display-surface.schema.json +46 -0
  126. package/schemas/v1.2.0/operate-experience-surface.schema.json +590 -0
  127. package/schemas/v1.2.0/operate-recovery-display-surface.schema.json +85 -0
  128. package/schemas/v1.2.0/structured-action.schema.json +91 -0
  129. package/schemas/v1.3.0/adapter-registry.schema.json +84 -0
  130. package/schemas/v1.3.0/ecosystem-manifest.schema.json +120 -0
  131. package/schemas/v1.3.0/release-compatibility-claim.schema.json +46 -0
  132. package/schemas/v1.3.0/release-ledger-receipt.schema.json +45 -0
  133. package/schemas/v1.3.0/release-ledger.schema.json +60 -0
  134. package/schemas/v1.4.0/adapter-registry.schema.json +62 -0
  135. package/schemas/v1.4.0/evaluation-aggregate-report.schema.json +166 -0
  136. package/schemas/v1.4.0/evaluation-budget.schema.json +49 -0
  137. package/schemas/v1.4.0/evaluation-corpus.schema.json +93 -0
  138. package/schemas/v1.4.0/evaluation-fixture.schema.json +64 -0
  139. package/schemas/v1.4.0/evaluation-gate-policy.schema.json +33 -0
  140. package/schemas/v1.4.0/evaluation-grader-registration.schema.json +141 -0
  141. package/schemas/v1.4.0/evaluation-grader-registry.schema.json +20 -0
  142. package/schemas/v1.4.0/evaluation-host-profile-registry.schema.json +20 -0
  143. package/schemas/v1.4.0/evaluation-host-profile.schema.json +73 -0
  144. package/schemas/v1.4.0/evaluation-observation.schema.json +76 -0
  145. package/schemas/v1.4.0/evaluation-run-result.schema.json +84 -0
  146. package/schemas/v1.4.0/evaluation-scenario.schema.json +231 -0
  147. package/schemas/v1.4.0/evaluation-waiver.schema.json +65 -0
  148. package/schemas/v1.4.0/skill-certification-receipt.schema.json +103 -0
  149. package/schemas/v1.5.0/command-catalog.schema.json +296 -0
  150. package/schemas/v1.5.0/common.schema.json +261 -0
  151. package/schemas/v1.5.0/generated-asset-manifest.schema.json +313 -0
  152. package/schemas/v1.5.0/implementation-result.schema.json +152 -0
  153. package/schemas/v1.5.0/migration-preservation-manifest.schema.json +749 -0
  154. package/schemas/v1.5.0/output-catalog.schema.json +210 -0
  155. package/schemas/v1.5.0/output-path-catalog.schema.json +81 -0
  156. package/schemas/v1.5.0/role-registry.schema.json +261 -0
  157. package/schemas/v1.5.0/rule-catalog.schema.json +130 -0
  158. package/schemas/v1.5.0/skill-catalog.schema.json +303 -0
  159. package/schemas/v1.5.0/task-kind-registry.schema.json +167 -0
  160. package/schemas/v1.5.0/task-manifest.schema.json +373 -0
  161. package/schemas/v1.5.0/task-output-manifest.schema.json +462 -0
  162. package/schemas/v1.6.0/common.schema.json +462 -0
  163. package/schemas/v1.6.0/diagram-consumer-reference.schema.json +167 -0
  164. package/schemas/v1.6.0/diagram-document.schema.json +699 -0
  165. package/schemas/v1.6.0/diagram-fidelity-report.schema.json +137 -0
  166. package/schemas/v1.6.0/diagram-manifest.schema.json +162 -0
  167. package/schemas/v1.6.0/diagram-quality-report.schema.json +148 -0
  168. package/schemas/v1.6.0/diagram-review-binding.schema.json +132 -0
  169. package/schemas/v1.6.0/diagram-semantic-pattern-registry.schema.json +90 -0
  170. package/schemas/v1.6.0/diagram-type-registry.schema.json +373 -0
  171. package/schemas/v1.6.0/generated-asset-manifest.schema.json +103 -0
  172. package/schemas/v1.6.0/skill-catalog.schema.json +84 -0
  173. package/schemas/v1.6.0/skill-completion-receipt.schema.json +72 -0
  174. package/schemas/v1.6.0/skill-consent-record.schema.json +74 -0
  175. package/schemas/v1.6.0/skill-host-profile-registry.schema.json +526 -0
  176. package/schemas/v1.6.0/skill-learning-record.schema.json +116 -0
  177. package/schemas/v1.6.0/skill-module-registry.schema.json +108 -0
  178. package/schemas/v1.6.0/skill-routing-registry.schema.json +93 -0
  179. package/schemas/v1.6.0/skill-session.schema.json +73 -0
  180. package/schemas/v1.6.0/skill-source.schema.json +169 -0
  181. package/schemas/v1.7.0/common.schema.json +464 -0
  182. package/schemas/v1.7.0/generated-asset-manifest.schema.json +103 -0
  183. package/schemas/v1.7.0/planning-id-sequence.schema.json +50 -0
  184. package/schemas/v1.7.0/request-authority.schema.json +71 -0
  185. package/schemas/v1.7.0/skill-catalog.schema.json +84 -0
  186. package/schemas/v1.7.0/skill-completion-receipt.schema.json +72 -0
  187. package/schemas/v1.7.0/skill-consent-record.schema.json +74 -0
  188. package/schemas/v1.7.0/skill-host-profile-registry.schema.json +526 -0
  189. package/schemas/v1.7.0/skill-learning-record.schema.json +116 -0
  190. package/schemas/v1.7.0/skill-module-registry.schema.json +108 -0
  191. package/schemas/v1.7.0/skill-routing-registry.schema.json +93 -0
  192. package/schemas/v1.7.0/skill-session.schema.json +73 -0
  193. package/schemas/v1.7.0/skill-source.schema.json +169 -0
  194. package/schemas/v1.7.0/spec.schema.json +117 -0
  195. package/schemas/v1.7.0/story.schema.json +107 -0
  196. package/schemas/v1.7.0/task.schema.json +217 -0
  197. package/schemas/v1.8.0/common.schema.json +96 -0
  198. package/schemas/v1.8.0/skill-package.schema.json +63 -0
  199. package/schemas/v1.8.0/utility-command-catalog.schema.json +82 -0
  200. package/schemas/v1.9.0/design-document.schema.json +306 -0
  201. package/schemas/v1.9.0/design-review-bundle.schema.json +346 -0
  202. package/schemas/v1.9.0/design-review-workspace.schema.json +108 -0
  203. package/schemas/v1.9.0/design-workspace-create.schema.json +170 -0
  204. package/schemas/v1.9.0/design-workspace-event.schema.json +97 -0
  205. package/schemas/v1.9.0/design-workspace-revision.schema.json +56 -0
  206. package/schemas/v2.0.0/agent-runtime-manifest.schema.json +59 -0
  207. package/schemas/v2.0.0/business-operating-snapshot-projection.schema.json +14 -0
  208. package/schemas/v2.0.0/operate-allowed-action.schema.json +181 -0
  209. package/schemas/v2.0.0/operate-api-envelope.schema.json +225 -0
  210. package/schemas/v2.0.0/operate-capability-provider-registration.schema.json +30 -0
  211. package/schemas/v2.0.0/operate-domain-registration.schema.json +284 -0
  212. package/schemas/v2.0.0/operate-evidence-provider-registration.schema.json +55 -0
  213. package/schemas/v2.0.0/operate-evidence-resolver-registration.schema.json +46 -0
  214. package/schemas/v2.0.0/operate-executor-registration.schema.json +27 -0
  215. package/schemas/v2.0.0/operate-experience-live-patch.schema.json +47 -0
  216. package/schemas/v2.0.0/operate-experience-preview.schema.json +51 -0
  217. package/schemas/v2.0.0/operate-experience-view.schema.json +281 -0
  218. package/schemas/v2.0.0/operate-live-evidence-provider-registration.schema.json +48 -0
  219. package/schemas/v2.0.0/operate-live-evidence-provider-registry.schema.json +17 -0
  220. package/schemas/v2.0.0/operate-metric-provider-registration.schema.json +12 -0
  221. package/schemas/v2.0.0/operate-policy-provider-registration.schema.json +33 -0
  222. package/schemas/v2.0.0/operate-review-bound-submission.schema.json +29 -0
  223. package/schemas/v2.0.0/operate-review-display-workspace.schema.json +390 -0
  224. package/schemas/v2.0.0/operate-snapshot-provider-registration.schema.json +16 -0
  225. package/schemas/v2.0.0/operate-tool-call.schema.json +172 -0
  226. package/schemas/v2.0.0/operate-verification-provider-registration.schema.json +12 -0
  227. package/schemas/v2.0.0/operating-action-policy.schema.json +31 -0
  228. package/schemas/v2.0.0/operating-action-verification-plan.schema.json +13 -0
  229. package/schemas/v2.0.0/operating-action.schema.json +86 -0
  230. package/schemas/v2.0.0/operating-advisor-result.schema.json +394 -0
  231. package/schemas/v2.0.0/operating-approval-record.schema.json +23 -0
  232. package/schemas/v2.0.0/operating-approval-requirement.schema.json +31 -0
  233. package/schemas/v2.0.0/operating-artifact.schema.json +52 -0
  234. package/schemas/v2.0.0/operating-assignment.schema.json +437 -0
  235. package/schemas/v2.0.0/operating-assumption.schema.json +16 -0
  236. package/schemas/v2.0.0/operating-capability-availability.schema.json +15 -0
  237. package/schemas/v2.0.0/operating-capability-grant.schema.json +14 -0
  238. package/schemas/v2.0.0/operating-challenger-review.schema.json +204 -0
  239. package/schemas/v2.0.0/operating-checkpoint.schema.json +43 -0
  240. package/schemas/v2.0.0/operating-claim.schema.json +17 -0
  241. package/schemas/v2.0.0/operating-connector-checkpoint.schema.json +28 -0
  242. package/schemas/v2.0.0/operating-context-capture.schema.json +74 -0
  243. package/schemas/v2.0.0/operating-cycle-input-binding.schema.json +30 -0
  244. package/schemas/v2.0.0/operating-cycle.schema.json +42 -0
  245. package/schemas/v2.0.0/operating-decision-ledger.schema.json +237 -0
  246. package/schemas/v2.0.0/operating-decision.schema.json +137 -0
  247. package/schemas/v2.0.0/operating-delivery-evidence.schema.json +46 -0
  248. package/schemas/v2.0.0/operating-delivery-route.schema.json +43 -0
  249. package/schemas/v2.0.0/operating-delta.schema.json +13 -0
  250. package/schemas/v2.0.0/operating-domain-projection.schema.json +15 -0
  251. package/schemas/v2.0.0/operating-event-trigger.schema.json +11 -0
  252. package/schemas/v2.0.0/operating-event.schema.json +505 -0
  253. package/schemas/v2.0.0/operating-evidence-candidate.schema.json +88 -0
  254. package/schemas/v2.0.0/operating-evidence-edge.schema.json +39 -0
  255. package/schemas/v2.0.0/operating-evidence-graph.schema.json +25 -0
  256. package/schemas/v2.0.0/operating-evidence-observation.schema.json +48 -0
  257. package/schemas/v2.0.0/operating-evidence-ref.schema.json +51 -0
  258. package/schemas/v2.0.0/operating-evidence-resolution.schema.json +54 -0
  259. package/schemas/v2.0.0/operating-execution-result.schema.json +23 -0
  260. package/schemas/v2.0.0/operating-executive-board.schema.json +78 -0
  261. package/schemas/v2.0.0/operating-finding.schema.json +116 -0
  262. package/schemas/v2.0.0/operating-governed-operation.schema.json +54 -0
  263. package/schemas/v2.0.0/operating-intelligence-input-bundle.schema.json +128 -0
  264. package/schemas/v2.0.0/operating-intelligence-plan.schema.json +302 -0
  265. package/schemas/v2.0.0/operating-learning-receipt.schema.json +31 -0
  266. package/schemas/v2.0.0/operating-learning.schema.json +13 -0
  267. package/schemas/v2.0.0/operating-live-evidence-consent-record.schema.json +42 -0
  268. package/schemas/v2.0.0/operating-live-evidence-ingestion.schema.json +31 -0
  269. package/schemas/v2.0.0/operating-measurement-plan.schema.json +18 -0
  270. package/schemas/v2.0.0/operating-measurement-schedule-receipt.schema.json +7 -0
  271. package/schemas/v2.0.0/operating-measurement-schedule.schema.json +16 -0
  272. package/schemas/v2.0.0/operating-metric-observation.schema.json +15 -0
  273. package/schemas/v2.0.0/operating-metric.schema.json +18 -0
  274. package/schemas/v2.0.0/operating-model-state.schema.json +36 -0
  275. package/schemas/v2.0.0/operating-objective.schema.json +21 -0
  276. package/schemas/v2.0.0/operating-origin.schema.json +31 -0
  277. package/schemas/v2.0.0/operating-outcome-evaluation.schema.json +46 -0
  278. package/schemas/v2.0.0/operating-outcome.schema.json +13 -0
  279. package/schemas/v2.0.0/operating-planning-proposal.schema.json +45 -0
  280. package/schemas/v2.0.0/operating-policy-evaluation.schema.json +28 -0
  281. package/schemas/v2.0.0/operating-review-read.schema.json +217 -0
  282. package/schemas/v2.0.0/operating-review-receipt.schema.json +64 -0
  283. package/schemas/v2.0.0/operating-review.schema.json +47 -0
  284. package/schemas/v2.0.0/operating-risk.schema.json +96 -0
  285. package/schemas/v2.0.0/operating-rollback-plan.schema.json +10 -0
  286. package/schemas/v2.0.0/operating-rollback-result.schema.json +20 -0
  287. package/schemas/v2.0.0/operating-runtime-state.schema.json +289 -0
  288. package/schemas/v2.0.0/operating-scenario.schema.json +13 -0
  289. package/schemas/v2.0.0/operating-snapshot.schema.json +38 -0
  290. package/schemas/v2.0.0/operating-submission.schema.json +34 -0
  291. package/schemas/v2.0.0/operating-trace-matrix.schema.json +176 -0
  292. package/schemas/v2.0.0/operating-work-change-set.schema.json +89 -0
  293. package/schemas/v2.0.0/operating-work-ledger.schema.json +40 -0
  294. package/schemas/v2.0.0/software-operating-snapshot-projection.schema.json +14 -0
  295. package/src/browser-contracts.d.mts +5 -0
  296. package/src/browser-contracts.mjs +40 -0
  297. package/src/canonical-json.d.mts +5 -0
  298. package/src/canonical-json.mjs +142 -0
  299. package/src/compat/live-evidence-v2.mjs +1019 -0
  300. package/src/compat/operate-experience-live-patch.mjs +66 -0
  301. package/src/compat/operating-planning-contracts.mjs +114 -0
  302. package/src/contracts.d.mts +42 -0
  303. package/src/contracts.mjs +990 -0
  304. package/src/design-contracts.d.mts +62 -0
  305. package/src/design-contracts.mjs +186 -0
  306. package/src/design-publication-contracts.d.mts +4 -0
  307. package/src/design-publication-contracts.mjs +85 -0
  308. package/src/diagram-contracts.d.mts +19 -0
  309. package/src/diagram-contracts.mjs +28 -0
  310. package/src/enterprise-contracts.d.mts +107 -0
  311. package/src/enterprise-contracts.mjs +463 -0
  312. package/src/errors.d.mts +11 -0
  313. package/src/errors.mjs +109 -0
  314. package/src/generated/canonical-registries.mjs +5554 -0
  315. package/src/generated/contract-catalog-v2.mjs +7076 -0
  316. package/src/generated/diagram-registries.mjs +2529 -0
  317. package/src/index.d.mts +10 -0
  318. package/src/index.mjs +40 -0
  319. package/src/json-schema.d.mts +7 -0
  320. package/src/json-schema.mjs +283 -0
  321. package/src/planning-contracts.d.mts +10 -0
  322. package/src/planning-contracts.mjs +53 -0
  323. package/src/registries.d.mts +40 -0
  324. package/src/registries.mjs +261 -0
  325. package/src/review-experience-contracts.d.mts +11 -0
  326. package/src/review-experience-contracts.mjs +103 -0
  327. package/src/semver.d.mts +2 -0
  328. package/src/semver.mjs +7 -0
  329. package/src/skill-source-contracts.d.mts +25 -0
  330. package/src/skill-source-contracts.mjs +105 -0
  331. package/src/task-contracts.d.mts +7 -0
  332. package/src/task-contracts.mjs +130 -0
  333. package/src/workspace-contracts.d.mts +26 -0
  334. package/src/workspace-contracts.mjs +83 -0
@@ -0,0 +1,1007 @@
1
+ import { validateJson } from '../../src/json-schema.mjs';
2
+ import {
3
+ contentHash,
4
+ deepFreeze,
5
+ exactEventHead,
6
+ exactJson,
7
+ jcsHash,
8
+ safeDataClone,
9
+ withoutContentHash,
10
+ } from "./closed-json-contract.mjs";
11
+ import {
12
+ OPERATE_ACTION_DISPLAY_WORKSPACE_SCHEMA as actionDisplayWorkspaceSchema,
13
+ OPERATE_ALLOWED_ACTION_SCHEMA as allowedActionSchema,
14
+ OPERATE_API_ENVELOPE_SCHEMA as apiEnvelopeSchema,
15
+ OPERATE_CYCLE_DISPLAY_WORKSPACE_SCHEMA as cycleDisplayWorkspaceSchema,
16
+ OPERATE_EXECUTIVE_BOARD_DISPLAY_SURFACE_SCHEMA as executiveBoardDisplaySurfaceSchema,
17
+ OPERATE_RECOVERY_DISPLAY_SURFACE_SCHEMA as recoveryDisplaySurfaceSchema,
18
+ OPERATE_EXPERIENCE_DISPLAY_SURFACE_SCHEMA as displaySurfaceSchema,
19
+ OPERATE_EXPERIENCE_PREVIEW_SCHEMA as experiencePreviewSchema,
20
+ OPERATE_EXPERIENCE_SURFACE_SCHEMA as surfaceSchema,
21
+ OPERATE_EXPERIENCE_VIEW_SCHEMA as experienceViewSchema,
22
+ OPERATE_REVIEW_DISPLAY_WORKSPACE_SCHEMA as reviewWorkspaceSchema,
23
+ OPERATING_FINDING_SCHEMA as findingSchema,
24
+ OPERATING_DELIVERY_ROUTE_SCHEMA as deliveryRouteSchema,
25
+ OPERATING_EVIDENCE_RESOLUTION_SCHEMA as evidenceResolutionSchema,
26
+ OPERATING_EXECUTION_RESULT_SCHEMA as executionResultSchema,
27
+ OPERATING_GOVERNED_OPERATION_SCHEMA as governedOperationSchema,
28
+ OPERATING_REVIEW_SCHEMA as reviewSchema,
29
+ OPERATING_TRACE_MATRIX_SCHEMA as traceMatrixSchema,
30
+ OPERATING_WORK_LEDGER_SCHEMA as workLedgerSchema,
31
+ } from "./generated/operate-experience-surface-schema-data.mjs";
32
+ import { assertOperateExperienceSurfaceV1 } from "./operate-experience-surface-contract.mjs";
33
+
34
+ const DISPLAY_SURFACE_DOMAIN =
35
+ "openplanr:operate-experience-display-surface:1.0.0";
36
+ const CYCLE_WORKSPACE_DOMAIN =
37
+ "openplanr:operate-cycle-display-workspace:1.0.0";
38
+ const EXECUTIVE_BOARD_DISPLAY_DOMAIN =
39
+ "openplanr:operate-executive-board-display-surface:1.0.0";
40
+ export const ACTION_WORKSPACE_DOMAIN =
41
+ "openplanr:operate-action-display-workspace:1.0.0";
42
+ export const RECOVERY_DISPLAY_DOMAIN =
43
+ "openplanr:operate-recovery-display-surface:1.0.0";
44
+ const ACTION_WORKSPACE_BOUNDARIES = Object.freeze({
45
+ approvalExecution:
46
+ "Named approval satisfies only its exact version-bound requirement. Execution receives a fresh authority check.",
47
+ verification:
48
+ "Outcome verification remains separate. No success claim appears before accepted evidence.",
49
+ retry:
50
+ "An effect may have occurred. Only Inspect, Reconcile, custody restoration, or an explicit runtime recovery route is legal.",
51
+ });
52
+ const DISPLAY_SURFACES = new Set(["today", "inbox", "cycles", "cycle", "actions"]);
53
+ const STAGE_ORDER = Object.freeze([
54
+ "observe",
55
+ "understand",
56
+ "decide",
57
+ "govern",
58
+ "act",
59
+ "verify",
60
+ "learn",
61
+ ]);
62
+ const ACTIVE_CYCLE_STAGE = Object.freeze({
63
+ created: 0,
64
+ observing: 0,
65
+ advising: 1,
66
+ challenging: 1,
67
+ synthesizing: 1,
68
+ awaiting_review: 2,
69
+ approved: 3,
70
+ executing: 4,
71
+ verifying: 5,
72
+ closed: 6,
73
+ blocked: 0,
74
+ failed: 0,
75
+ cancelled: 0,
76
+ });
77
+ const CYCLE_STATES = new Set([
78
+ ...Object.keys(ACTIVE_CYCLE_STAGE),
79
+ "closed",
80
+ "blocked",
81
+ "failed",
82
+ "cancelled",
83
+ ]);
84
+ const CYCLE_HEALTH = new Set(["normal", "quiet", "partial", "blocked"]);
85
+ const PERSISTENT_RELATIONS = Object.freeze([
86
+ "source",
87
+ "touched",
88
+ "carried-forward",
89
+ ]);
90
+ const PERSISTENT_ID = Object.freeze({
91
+ finding: /^fnd_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
92
+ decision: /^dec_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
93
+ action: /^act_[A-Za-z0-9][A-Za-z0-9._-]{7,127}$/u,
94
+ });
95
+ const PERSISTENT_STATE = Object.freeze({
96
+ finding: new Set([
97
+ "open",
98
+ "accepted",
99
+ "resolved",
100
+ "rejected",
101
+ "deferred",
102
+ "superseded",
103
+ ]),
104
+ decision: new Set([
105
+ "proposed",
106
+ "approved",
107
+ "rejected",
108
+ "deferred",
109
+ "superseded",
110
+ ]),
111
+ action: new Set([
112
+ "proposed",
113
+ "approved",
114
+ "queued",
115
+ "in_progress",
116
+ "completed",
117
+ "blocked",
118
+ "rejected",
119
+ "deferred",
120
+ "cancelled",
121
+ ]),
122
+ });
123
+
124
+ const schemas = new Map([
125
+ ["operate-experience-display-surface.schema.json", displaySurfaceSchema],
126
+ ["operate-action-display-workspace.schema.json", actionDisplayWorkspaceSchema],
127
+ ["operate-cycle-display-workspace.schema.json", cycleDisplayWorkspaceSchema],
128
+ ["operate-executive-board-display-surface.schema.json", executiveBoardDisplaySurfaceSchema],
129
+ ["operate-recovery-display-surface.schema.json", recoveryDisplaySurfaceSchema],
130
+ ["operate-experience-surface.schema.json", surfaceSchema],
131
+ ["operate-experience-view.schema.json", experienceViewSchema],
132
+ ["operate-review-display-workspace.schema.json", reviewWorkspaceSchema],
133
+ ["operating-finding.schema.json", findingSchema],
134
+ ["operate-experience-preview.schema.json", experiencePreviewSchema],
135
+ ["operate-api-envelope.schema.json", apiEnvelopeSchema],
136
+ ["operate-allowed-action.schema.json", allowedActionSchema],
137
+ ["operating-work-ledger.schema.json", workLedgerSchema],
138
+ ["operating-delivery-route.schema.json", deliveryRouteSchema],
139
+ ["operating-evidence-resolution.schema.json", evidenceResolutionSchema],
140
+ ["operating-execution-result.schema.json", executionResultSchema],
141
+ ["operating-governed-operation.schema.json", governedOperationSchema],
142
+ ["operating-review.schema.json", reviewSchema],
143
+ ["operating-trace-matrix.schema.json", traceMatrixSchema],
144
+ ]);
145
+
146
+ function jsonPointer(root, fragment) {
147
+ if (!fragment || fragment === "#") return root;
148
+ if (!fragment.startsWith("#/")) return null;
149
+ return fragment
150
+ .slice(2)
151
+ .split("/")
152
+ .map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"))
153
+ .reduce((value, part) => value?.[part], root);
154
+ }
155
+
156
+ function resolveSchemaRef(reference) {
157
+ const [path, pointer = ""] = reference.split("#");
158
+ const filename = path.split("/").at(-1);
159
+ const rootSchema = schemas.get(filename);
160
+ if (!rootSchema) return null;
161
+ return {
162
+ schema: jsonPointer(rootSchema, pointer ? `#${pointer}` : "#"),
163
+ rootSchema,
164
+ base: filename,
165
+ };
166
+ }
167
+
168
+ function validationFailure() {
169
+ return [
170
+ {
171
+ path: "$",
172
+ rule: "closedContract",
173
+ detail: "does not satisfy the closed display contract",
174
+ },
175
+ ];
176
+ }
177
+
178
+ function exactKeys(value, keys) {
179
+ if (value === null || typeof value !== "object" || Array.isArray(value))
180
+ return false;
181
+ const actual = Object.keys(value);
182
+ return actual.length === keys.length && keys.every((key) => actual.includes(key));
183
+ }
184
+
185
+ function exactExpectedBinding(
186
+ payload,
187
+ expected,
188
+ { workspace = false, executiveBoard = false, action = false, recovery = false } = {},
189
+ ) {
190
+ if (!expected) return true;
191
+ if (
192
+ payload.actorId !== expected.actorId ||
193
+ payload.scopeId !== expected.scopeId ||
194
+ payload.domainId !== expected.domainId ||
195
+ payload.domainVersion !== expected.domainVersion ||
196
+ payload.generatedAt !== expected.generatedAt ||
197
+ payload.viewHash !== expected.viewHash ||
198
+ !exactEventHead(payload.eventHead, expected.eventHead)
199
+ )
200
+ return false;
201
+ if (!workspace) {
202
+ if (expected.surface !== undefined && payload.surface !== expected.surface)
203
+ return false;
204
+ if (payload.surface === "inbox" || payload.surface === "actions") {
205
+ return (
206
+ expected.surface === payload.surface &&
207
+ typeof expected.projectId === "string" &&
208
+ Number.isSafeInteger(expected.generation) &&
209
+ payload.data.requestBinding.projectId === expected.projectId &&
210
+ payload.data.requestBinding.generation === expected.generation &&
211
+ (payload.surface !== "inbox" ||
212
+ payload.data.requestBinding.subjectId === expected.subjectId) &&
213
+ (payload.surface !== "actions" ||
214
+ (expected.subjectId === null &&
215
+ typeof expected.cycleId === "string" &&
216
+ expected.cycleId.length > 0))
217
+ );
218
+ }
219
+ if (payload.surface === "cycle") {
220
+ const committedCycleId = payload.data.cycle.cycleId;
221
+ if (
222
+ typeof expected.subjectId !== "string" ||
223
+ typeof expected.cycleId !== "string" ||
224
+ expected.subjectId !== committedCycleId ||
225
+ expected.cycleId !== committedCycleId
226
+ )
227
+ return false;
228
+ }
229
+ return true;
230
+ }
231
+ if (executiveBoard) {
232
+ return (
233
+ expected.cycleId === payload.data.cycleId &&
234
+ expected.subjectId === payload.data.cycleId
235
+ );
236
+ }
237
+ if (action) {
238
+ return (
239
+ expected.subjectId === payload.data.action.actionId &&
240
+ expected.actionId === payload.data.action.actionId
241
+ );
242
+ }
243
+ if (recovery) return true;
244
+ return (
245
+ expected.cycleId === payload.data.cycle.cycleId &&
246
+ expected.subjectId === payload.data.cycle.cycleId
247
+ );
248
+ }
249
+
250
+ function validCycleLifecycle(cycle) {
251
+ if (
252
+ !cycle ||
253
+ typeof cycle !== "object" ||
254
+ !CYCLE_STATES.has(cycle.state) ||
255
+ !CYCLE_HEALTH.has(cycle.health) ||
256
+ !Array.isArray(cycle.stages) ||
257
+ cycle.stages.length !== STAGE_ORDER.length ||
258
+ !cycle.stages.every((stage, index) => stage.id === STAGE_ORDER[index])
259
+ )
260
+ return false;
261
+ const current = ACTIVE_CYCLE_STAGE[cycle.state];
262
+ return cycle.stages.every((stage, index) => {
263
+ let expected = index < current ? "complete" : index === current ? "current" : "waiting";
264
+ if (cycle.state === "closed") expected = "complete";
265
+ if (index === current && ["blocked", "failed"].includes(cycle.state)) {
266
+ expected = cycle.state;
267
+ }
268
+ if (index === current && cycle.state === "cancelled") expected = "skipped";
269
+ const reason = ["blocked", "failed", "skipped"].includes(expected)
270
+ ? `Cycle is ${cycle.state}.`
271
+ : null;
272
+ return stage.state === expected && stage.reason === reason;
273
+ });
274
+ }
275
+
276
+ function validDisplaySurfaceSemantics(value, expected) {
277
+ const payload = value.payload;
278
+ if (
279
+ !DISPLAY_SURFACES.has(payload.surface) ||
280
+ value.integrity.sourceViewHash !== payload.viewHash ||
281
+ payload.truthSummary.sourceViewHash !== payload.viewHash ||
282
+ !exactEventHead(payload.truthSummary.sourceEventHead, payload.eventHead) ||
283
+ !exactExpectedBinding(payload, expected)
284
+ )
285
+ return false;
286
+ if (payload.surface === "inbox") {
287
+ const items = payload.data.inbox;
288
+ const subjectId = payload.data.requestBinding.subjectId;
289
+ return (
290
+ Array.isArray(items) &&
291
+ new Set(items.map((item) => item.itemId)).size === items.length &&
292
+ (subjectId === null ||
293
+ (items.length === 1 && items[0].itemId === subjectId)) &&
294
+ items.every((item, index) =>
295
+ index === 0 ||
296
+ Number(items[index - 1].blocking) > Number(item.blocking) ||
297
+ (Number(items[index - 1].blocking) === Number(item.blocking) &&
298
+ items[index - 1].itemId.localeCompare(item.itemId) < 0),
299
+ )
300
+ );
301
+ }
302
+ if (payload.surface === "actions") {
303
+ const items = payload.data.actions;
304
+ return (
305
+ Array.isArray(items) &&
306
+ new Set(items.map((item) => item.actionId)).size === items.length
307
+ );
308
+ }
309
+ const cycles =
310
+ payload.surface === "today"
311
+ ? payload.data.activeCycle === null
312
+ ? []
313
+ : [payload.data.activeCycle]
314
+ : payload.surface === "cycles"
315
+ ? payload.data.cycles
316
+ : [payload.data.cycle];
317
+ return (
318
+ new Set(cycles.map((cycle) => cycle.cycleId)).size === cycles.length &&
319
+ cycles.every(validCycleLifecycle)
320
+ );
321
+ }
322
+
323
+ function validPersistentItem(value, kind) {
324
+ return (
325
+ exactKeys(value, ["kind", "subjectId", "state", "relations"]) &&
326
+ value.kind === kind &&
327
+ typeof value.subjectId === "string" &&
328
+ PERSISTENT_ID[kind].test(value.subjectId) &&
329
+ typeof value.state === "string" &&
330
+ PERSISTENT_STATE[kind].has(value.state) &&
331
+ Array.isArray(value.relations) &&
332
+ value.relations.length >= 1 &&
333
+ value.relations.length <= PERSISTENT_RELATIONS.length &&
334
+ value.relations.every((relation) => PERSISTENT_RELATIONS.includes(relation)) &&
335
+ new Set(value.relations).size === value.relations.length
336
+ );
337
+ }
338
+
339
+ function validCycleLink(value) {
340
+ return (
341
+ exactKeys(value, ["entityKind", "entityId", "cycleId", "relation"]) &&
342
+ PERSISTENT_ID[value.entityKind]?.test(value.entityId) === true &&
343
+ typeof value.cycleId === "string" &&
344
+ PERSISTENT_RELATIONS.includes(value.relation)
345
+ );
346
+ }
347
+
348
+ function validPersistentGraph(persistent, cycleId) {
349
+ const items = [
350
+ ...persistent.findings,
351
+ ...persistent.decisions,
352
+ ...persistent.actions,
353
+ ];
354
+ const itemKeys = items.map((item) => `${item.kind}:${item.subjectId}`);
355
+ const linkKeys = persistent.cycleLinks.map(
356
+ (link) => `${link.entityKind}:${link.entityId}:${link.cycleId}:${link.relation}`,
357
+ );
358
+ if (
359
+ new Set(itemKeys).size !== itemKeys.length ||
360
+ new Set(linkKeys).size !== linkKeys.length ||
361
+ persistent.cycleLinks.some(
362
+ (link) =>
363
+ link.cycleId !== cycleId ||
364
+ !items.some(
365
+ (item) =>
366
+ item.kind === link.entityKind && item.subjectId === link.entityId,
367
+ ),
368
+ )
369
+ )
370
+ return false;
371
+ return items.every((item) =>
372
+ exactJson(
373
+ item.relations,
374
+ persistent.cycleLinks
375
+ .filter(
376
+ (link) =>
377
+ link.entityKind === item.kind && link.entityId === item.subjectId,
378
+ )
379
+ .map((link) => link.relation),
380
+ ),
381
+ );
382
+ }
383
+
384
+ function validAllowedAction(value, cycleId) {
385
+ return (
386
+ exactKeys(value, ["tool", "arguments", "label", "effect"]) &&
387
+ value.tool === "operate.cycle.get" &&
388
+ exactKeys(value.arguments, ["cycleId"]) &&
389
+ value.arguments.cycleId === cycleId &&
390
+ typeof value.label === "string" &&
391
+ value.label.length > 0 &&
392
+ value.label.length <= 256 &&
393
+ !/(?:<[^>]+>|\{\{[^}]+\}\})/u.test(value.label) &&
394
+ value.effect === "read-only"
395
+ );
396
+ }
397
+
398
+ function outcomeCarriesAffirmativeProof(outcome) {
399
+ const verification = outcome.verification;
400
+ const metric = outcome.metric;
401
+ return (
402
+ ["succeeded", "failed"].includes(outcome.status) &&
403
+ outcome.accessReason === null &&
404
+ outcome.observationIds.length > 0 &&
405
+ outcome.evidenceRefIds.length > 0 &&
406
+ metric !== null &&
407
+ metric.observed !== null &&
408
+ metric.freshness === "current" &&
409
+ verification !== null &&
410
+ verification.accessReason === null &&
411
+ outcome.verificationPlanId === verification.verificationPlanId &&
412
+ metric.metricId === verification.metricId &&
413
+ metric.metricHash === verification.metricHash
414
+ );
415
+ }
416
+
417
+ function validOutcomeLearningGraph(persistent, cycle, verification, truthSummary) {
418
+ const actionIds = persistent.actions.map((action) => action.subjectId);
419
+ const outcomeIds = persistent.outcomes.map((outcome) => outcome.outcomeId);
420
+ const learningIds = persistent.learnings.map((learning) => learning.learningId);
421
+ if (
422
+ new Set(outcomeIds).size !== outcomeIds.length ||
423
+ new Set(learningIds).size !== learningIds.length ||
424
+ persistent.outcomes.some((outcome) => !actionIds.includes(outcome.actionId)) ||
425
+ persistent.learnings.some(
426
+ (learning) => !outcomeIds.includes(learning.outcomeId),
427
+ )
428
+ )
429
+ return false;
430
+ const expected = truthSummary.proof.status === "verified"
431
+ ? "verified"
432
+ : truthSummary.proof.status === "not-required"
433
+ ? "not-required"
434
+ : "unverified";
435
+ const reasonCodes = expected === "unverified"
436
+ ? truthSummary.proof.reasonCodes.length > 0
437
+ ? truthSummary.proof.reasonCodes
438
+ : ["OPERATE_VERIFICATION_EVIDENCE_MISSING"]
439
+ : [];
440
+ return (
441
+ verification.status === expected &&
442
+ exactJson(verification.reasonCodes, reasonCodes)
443
+ );
444
+ }
445
+
446
+ function workspaceSurface(payload, surface, data) {
447
+ return {
448
+ ok: true,
449
+ kind: "operate-experience-surface",
450
+ schemaVersion: "1.0.0",
451
+ protocolVersion: payload.protocolVersion,
452
+ surface,
453
+ readOnly: true,
454
+ mutationEnabled: payload.status === "ready",
455
+ scopeId: payload.scopeId,
456
+ domainId: payload.domainId,
457
+ domainVersion: payload.domainVersion,
458
+ actorId: payload.actorId,
459
+ accessLevel: payload.accessLevel,
460
+ generatedAt: payload.generatedAt,
461
+ eventHead: payload.eventHead,
462
+ viewHash: payload.viewHash,
463
+ truthSummary: payload.truthSummary,
464
+ status: payload.status,
465
+ reasonCodes: payload.reasonCodes,
466
+ data,
467
+ };
468
+ }
469
+
470
+ function validWorkspacePayload(payload) {
471
+ const data = payload.data;
472
+ if (
473
+ !exactKeys(data.ownerCycle, [
474
+ "cycleId",
475
+ "scopeId",
476
+ "domainId",
477
+ "domainVersion",
478
+ "state",
479
+ "health",
480
+ "focus",
481
+ "createdAt",
482
+ "updatedAt",
483
+ ]) ||
484
+ !Array.isArray(data.persistentWork.findings) ||
485
+ !data.persistentWork.findings.every((item) =>
486
+ validPersistentItem(item, "finding"),
487
+ ) ||
488
+ !Array.isArray(data.persistentWork.decisions) ||
489
+ !data.persistentWork.decisions.every((item) =>
490
+ validPersistentItem(item, "decision"),
491
+ ) ||
492
+ !Array.isArray(data.persistentWork.actions) ||
493
+ !data.persistentWork.actions.every((item) =>
494
+ validPersistentItem(item, "action"),
495
+ ) ||
496
+ !Array.isArray(data.persistentWork.cycleLinks) ||
497
+ !data.persistentWork.cycleLinks.every(validCycleLink) ||
498
+ !Array.isArray(data.persistentWork.outcomes) ||
499
+ !Array.isArray(data.persistentWork.learnings) ||
500
+ data.allowedActions.length !== 1
501
+ )
502
+ return false;
503
+ try {
504
+ const cycle = data.cycle;
505
+ const schemaCycle = {
506
+ ...cycle,
507
+ assignments: cycle.assignments.map((assignment) =>
508
+ assignment.deepLink === null
509
+ ? { ...assignment, deepLink: cycle.deepLink }
510
+ : assignment,
511
+ ),
512
+ };
513
+ const schemaOutcomes = data.persistentWork.outcomes.map((outcome) =>
514
+ outcome.deepLink === null
515
+ ? {
516
+ ...outcome,
517
+ deepLink: `#/operate/outcomes/${encodeURIComponent(outcome.outcomeId)}`,
518
+ }
519
+ : outcome,
520
+ );
521
+ assertOperateExperienceSurfaceV1(
522
+ workspaceSurface(payload, "cycle", { cycle: schemaCycle }),
523
+ );
524
+ assertOperateExperienceSurfaceV1(
525
+ workspaceSurface(payload, "outcomes", {
526
+ domainMetrics: [],
527
+ outcomes: schemaOutcomes,
528
+ learnings: data.persistentWork.learnings,
529
+ }),
530
+ );
531
+ assertOperateExperienceSurfaceV1(
532
+ workspaceSurface(payload, "history", {
533
+ history: [],
534
+ replay: data.replay,
535
+ }),
536
+ );
537
+ const sourceActionIds = data.persistentWork.actions
538
+ .filter((action) => action.relations.includes("source"))
539
+ .map((action) => action.subjectId);
540
+ return (
541
+ validCycleLifecycle(cycle) &&
542
+ data.ownerCycle.cycleId === cycle.cycleId &&
543
+ data.ownerCycle.scopeId === payload.scopeId &&
544
+ data.ownerCycle.domainId === payload.domainId &&
545
+ data.ownerCycle.domainVersion === payload.domainVersion &&
546
+ data.ownerCycle.state === cycle.state &&
547
+ data.ownerCycle.health === cycle.health &&
548
+ exactJson(data.ownerCycle.focus, cycle.focus) &&
549
+ data.ownerCycle.createdAt === cycle.createdAt &&
550
+ data.ownerCycle.updatedAt === cycle.updatedAt &&
551
+ cycle.deepLink ===
552
+ `#/operate/cycles/${encodeURIComponent(cycle.cycleId)}` &&
553
+ exactEventHead(data.replay.finalHead, payload.eventHead) &&
554
+ exactJson(cycle.replayCheckpoint, data.replay.checkpoint) &&
555
+ exactJson(cycle.persistentActionIds, sourceActionIds) &&
556
+ validPersistentGraph(data.persistentWork, cycle.cycleId) &&
557
+ validOutcomeLearningGraph(
558
+ data.persistentWork,
559
+ cycle,
560
+ data.verification,
561
+ payload.truthSummary,
562
+ ) &&
563
+ validAllowedAction(data.allowedActions[0], cycle.cycleId)
564
+ );
565
+ } catch {
566
+ return false;
567
+ }
568
+ }
569
+
570
+ function validWorkspaceSemantics(value, expected) {
571
+ return (
572
+ value.integrity.sourceViewHash === value.payload.viewHash &&
573
+ value.payload.truthSummary.sourceViewHash === value.payload.viewHash &&
574
+ exactEventHead(value.payload.truthSummary.sourceEventHead, value.payload.eventHead) &&
575
+ exactExpectedBinding(value.payload, expected, { workspace: true }) &&
576
+ validWorkspacePayload(value.payload)
577
+ );
578
+ }
579
+
580
+ function validateDisplay(value, schema, base, semantics, expected) {
581
+ try {
582
+ const clone = safeDataClone(value);
583
+ const errors = validateJson(clone, schema, {
584
+ base,
585
+ resolveRef: resolveSchemaRef,
586
+ });
587
+ if (errors.length > 0 || !semantics(clone, expected))
588
+ return validationFailure();
589
+ const expectedHash = contentHash(
590
+ withoutContentHash(clone),
591
+ clone.integrity.domain,
592
+ );
593
+ return clone.integrity.contentHash === expectedHash
594
+ ? []
595
+ : validationFailure();
596
+ } catch {
597
+ return validationFailure();
598
+ }
599
+ }
600
+
601
+ export function validateOperateExperienceDisplaySurfaceV1(value, expected) {
602
+ return validateDisplay(
603
+ value,
604
+ displaySurfaceSchema,
605
+ "schemas/v1.2.0/operate-experience-display-surface.schema.json",
606
+ validDisplaySurfaceSemantics,
607
+ expected,
608
+ );
609
+ }
610
+
611
+ export function assertOperateExperienceDisplaySurfaceV1(value, expected) {
612
+ if (validateOperateExperienceDisplaySurfaceV1(value, expected).length > 0) {
613
+ const error = new TypeError(
614
+ "The Operate display surface does not satisfy its closed integrity contract.",
615
+ );
616
+ error.code = "E_OPERATE_EXPERIENCE_DISPLAY_INVALID";
617
+ throw error;
618
+ }
619
+ return value;
620
+ }
621
+
622
+ function exactExpectedPreview(value, expected) {
623
+ if (!expected) return true;
624
+ return (
625
+ value.actorId === expected.actorId &&
626
+ value.scopeId === expected.scopeId &&
627
+ value.domainId === expected.domainId &&
628
+ value.domainVersion === expected.domainVersion &&
629
+ exactEventHead(value.eventHead, expected.eventHead) &&
630
+ value.sourceViewHash === expected.sourceViewHash &&
631
+ value.subject.id === expected.subjectId &&
632
+ value.actionDigest === expected.actionDigest
633
+ );
634
+ }
635
+
636
+ function validPreviewTransition(transition) {
637
+ if (
638
+ new Set(transition.targets.map((target) => `${target.kind}:${target.id}`)).size !==
639
+ transition.targets.length
640
+ ) return false;
641
+ if (transition.kind !== "approval") return transition.threshold === null;
642
+ const threshold = transition.threshold;
643
+ if (
644
+ threshold === null ||
645
+ threshold.recorded > threshold.required ||
646
+ threshold.remaining !== threshold.required - threshold.recorded
647
+ ) return false;
648
+ return threshold.remaining === 0
649
+ ? transition.nextState === "threshold-satisfied"
650
+ : transition.nextState === "recorded-parties-remain";
651
+ }
652
+
653
+ export function validateOperateExperiencePreviewV1(value, expected) {
654
+ try {
655
+ const clone = safeDataClone(value);
656
+ const errors = validateJson(clone, experiencePreviewSchema, {
657
+ base: "schemas/v2.0.0/operate-experience-preview.schema.json",
658
+ resolveRef: resolveSchemaRef,
659
+ });
660
+ if (
661
+ errors.length > 0 ||
662
+ !exactExpectedPreview(clone, expected) ||
663
+ !validPreviewTransition(clone.transition)
664
+ ) return errors.length > 0 ? errors : validationFailure();
665
+ const base = safeDataClone(clone);
666
+ delete base.previewHash;
667
+ if (
668
+ clone.actionDigest !== jcsHash(clone.allowedAction) ||
669
+ clone.previewHash !== jcsHash(base)
670
+ ) return validationFailure();
671
+ return [];
672
+ } catch {
673
+ return validationFailure();
674
+ }
675
+ }
676
+
677
+ export function assertOperateExperiencePreviewV1(value, expected) {
678
+ if (validateOperateExperiencePreviewV1(value, expected).length > 0) {
679
+ const error = new TypeError(
680
+ "The Operate preview does not satisfy its closed integrity contract.",
681
+ );
682
+ error.code = "E_OPERATE_EXPERIENCE_PREVIEW_INVALID";
683
+ throw error;
684
+ }
685
+ return deepFreeze(safeDataClone(value));
686
+ }
687
+
688
+ export function validateOperateCycleDisplayWorkspaceV1(value, expected) {
689
+ return validateDisplay(
690
+ value,
691
+ cycleDisplayWorkspaceSchema,
692
+ "schemas/v1.2.0/operate-cycle-display-workspace.schema.json",
693
+ validWorkspaceSemantics,
694
+ expected,
695
+ );
696
+ }
697
+
698
+ export function assertOperateCycleDisplayWorkspaceV1(value, expected) {
699
+ if (validateOperateCycleDisplayWorkspaceV1(value, expected).length > 0) {
700
+ const error = new TypeError(
701
+ "The Cycle display workspace does not satisfy its closed integrity contract.",
702
+ );
703
+ error.code = "E_OPERATE_CYCLE_DISPLAY_INVALID";
704
+ throw error;
705
+ }
706
+ return value;
707
+ }
708
+
709
+ function issueDisplay(kind, domain, payload, assertIssued) {
710
+ const base = {
711
+ kind,
712
+ schemaVersion: "1.0.0",
713
+ protocolVersion: "2.0.0",
714
+ payload: safeDataClone(payload),
715
+ integrity: {
716
+ algorithm: "sha-256-jcs",
717
+ domain,
718
+ sourceViewHash: payload.viewHash,
719
+ },
720
+ };
721
+ const issued = {
722
+ ...base,
723
+ integrity: {
724
+ ...base.integrity,
725
+ contentHash: contentHash(base, domain),
726
+ },
727
+ };
728
+ assertIssued(issued);
729
+ return deepFreeze(issued);
730
+ }
731
+
732
+ export function issueOperateExperienceDisplaySurfaceV1(payload) {
733
+ return issueDisplay(
734
+ "operate-experience-display-surface",
735
+ DISPLAY_SURFACE_DOMAIN,
736
+ payload,
737
+ assertOperateExperienceDisplaySurfaceV1,
738
+ );
739
+ }
740
+
741
+ export function issueOperateCycleDisplayWorkspaceV1(payload) {
742
+ return issueDisplay(
743
+ "operate-cycle-display-workspace",
744
+ CYCLE_WORKSPACE_DOMAIN,
745
+ payload,
746
+ assertOperateCycleDisplayWorkspaceV1,
747
+ );
748
+ }
749
+
750
+ function validExecutiveBoardSeatAbsence(absence) {
751
+ if (absence === null) return true;
752
+ if (typeof absence !== "object" || Array.isArray(absence)) return false;
753
+ if (absence.kind === "omitted") {
754
+ return typeof absence.reason === "string" && absence.reason.length > 0;
755
+ }
756
+ if (absence.kind === "lens") {
757
+ return (
758
+ typeof absence.roleId === "string" &&
759
+ typeof absence.roleKind === "string" &&
760
+ typeof absence.absenceCode === "string" &&
761
+ typeof absence.reason === "string"
762
+ );
763
+ }
764
+ if (absence.kind === "terminal") {
765
+ return (
766
+ (absence.outcome === "abandoned" || absence.outcome === "failed") &&
767
+ typeof absence.code === "string" &&
768
+ typeof absence.reason === "string" &&
769
+ typeof absence.recoveryDisposition === "string"
770
+ );
771
+ }
772
+ return false;
773
+ }
774
+
775
+ function validExecutiveBoardSeat(seat) {
776
+ return (
777
+ typeof seat?.roleId === "string" &&
778
+ typeof seat?.label === "string" &&
779
+ seat.roleId !== seat.label &&
780
+ typeof seat?.roleKind === "string" &&
781
+ typeof seat?.roleVersion === "string" &&
782
+ validExecutiveBoardSeatAbsence(seat?.absence ?? null)
783
+ );
784
+ }
785
+
786
+ function validExecutiveBoardPayload(payload) {
787
+ const board = payload?.data?.executiveBoard;
788
+ if (!board || !Array.isArray(board.seats)) return false;
789
+ return board.seats.every(validExecutiveBoardSeat);
790
+ }
791
+
792
+ function validExecutiveBoardSemantics(value, expected) {
793
+ return (
794
+ value.integrity.sourceViewHash === value.payload.viewHash &&
795
+ exactExpectedBinding(value.payload, expected, { executiveBoard: true }) &&
796
+ validExecutiveBoardPayload(value.payload)
797
+ );
798
+ }
799
+
800
+ export function validateOperateExecutiveBoardDisplaySurfaceV1(value, expected) {
801
+ return validateDisplay(
802
+ value,
803
+ executiveBoardDisplaySurfaceSchema,
804
+ "schemas/v1.2.0/operate-executive-board-display-surface.schema.json",
805
+ validExecutiveBoardSemantics,
806
+ expected,
807
+ );
808
+ }
809
+
810
+ export function assertOperateExecutiveBoardDisplaySurfaceV1(value, expected) {
811
+ if (validateOperateExecutiveBoardDisplaySurfaceV1(value, expected).length > 0) {
812
+ const error = new TypeError(
813
+ "The executive board display surface does not satisfy its closed integrity contract.",
814
+ );
815
+ error.code = "E_OPERATE_EXECUTIVE_BOARD_DISPLAY_INVALID";
816
+ throw error;
817
+ }
818
+ return value;
819
+ }
820
+
821
+ export function issueOperateExecutiveBoardDisplaySurfaceV1(payload) {
822
+ return issueDisplay(
823
+ "operate-executive-board-display-surface",
824
+ EXECUTIVE_BOARD_DISPLAY_DOMAIN,
825
+ payload,
826
+ assertOperateExecutiveBoardDisplaySurfaceV1,
827
+ );
828
+ }
829
+
830
+ function actionDeepLink(actionId) {
831
+ return `#/operate/actions/${encodeURIComponent(actionId)}`;
832
+ }
833
+
834
+ function verificationFromOutcome(outcome) {
835
+ if (outcome === null) {
836
+ return Object.freeze({
837
+ status: "not-required",
838
+ reasonCodes: Object.freeze([]),
839
+ });
840
+ }
841
+ if (outcome.status === "insufficient-evidence") {
842
+ return Object.freeze({
843
+ status: "unverified",
844
+ reasonCodes: Object.freeze(["OPERATE_VERIFICATION_EVIDENCE_MISSING"]),
845
+ });
846
+ }
847
+ if (
848
+ ["succeeded", "failed"].includes(outcome.status) &&
849
+ outcomeCarriesAffirmativeProof(outcome)
850
+ ) {
851
+ return Object.freeze({
852
+ status: "verified",
853
+ reasonCodes: Object.freeze([]),
854
+ });
855
+ }
856
+ return Object.freeze({
857
+ status: "unverified",
858
+ reasonCodes: Object.freeze(["OPERATE_VERIFICATION_EVIDENCE_MISSING"]),
859
+ });
860
+ }
861
+
862
+ function recoveryStateFromInspection(inspection) {
863
+ const status = inspection?.status;
864
+ if (status === "healthy" || status === "empty") return "restored";
865
+ if (status === "corrupt") return "corrupt";
866
+ if (status === "incompatible") return "incompatible";
867
+ if (status === "locked") return "blocked";
868
+ if (status === "repairable") {
869
+ if (inspection.allowedRecovery === "clear-stale-lock") return "blocked";
870
+ if (inspection.allowedRecovery === "restore-generation") return "uncertain";
871
+ return "uncertain";
872
+ }
873
+ return "blocked";
874
+ }
875
+
876
+ function validActionWorkspacePayload(payload) {
877
+ const data = payload.data;
878
+ const action = data.action;
879
+ const expectedDeepLink = actionDeepLink(action.actionId);
880
+ const allowedActions = data.allowedActions;
881
+ const outcome = data.outcome;
882
+ const verification = verificationFromOutcome(outcome);
883
+ const commandable = allowedActions.some(
884
+ (entry) => entry.action.effect !== "read-only",
885
+ );
886
+ if (
887
+ payload.readOnly === payload.mutationEnabled ||
888
+ (payload.mutationEnabled && (payload.status !== "ready" || !commandable)) ||
889
+ action.deepLink !== expectedDeepLink ||
890
+ !exactJson(data.boundaries, ACTION_WORKSPACE_BOUNDARIES) ||
891
+ !exactJson(data.verification, verification) ||
892
+ !exactJson(data.replay.finalHead, payload.eventHead) ||
893
+ allowedActions.some((entry) => entry.subjectId !== action.actionId) ||
894
+ data.inbox.some((item) => item.subjectId !== action.actionId) ||
895
+ data.learnings.some(
896
+ (learning) =>
897
+ outcome === null || learning.outcomeId !== outcome.outcomeId,
898
+ ) ||
899
+ (outcome !== null && outcome.actionId !== action.actionId)
900
+ )
901
+ return false;
902
+ return true;
903
+ }
904
+
905
+ function validActionWorkspaceSemantics(value, expected) {
906
+ return (
907
+ value.integrity.sourceViewHash === value.payload.viewHash &&
908
+ exactExpectedBinding(value.payload, expected, { workspace: true, action: true }) &&
909
+ validActionWorkspacePayload(value.payload)
910
+ );
911
+ }
912
+
913
+ export function validateOperateActionDisplayWorkspaceV1(value, expected) {
914
+ return validateDisplay(
915
+ value,
916
+ actionDisplayWorkspaceSchema,
917
+ "schemas/v1.2.0/operate-action-display-workspace.schema.json",
918
+ validActionWorkspaceSemantics,
919
+ expected,
920
+ );
921
+ }
922
+
923
+ export function assertOperateActionDisplayWorkspaceV1(value, expected) {
924
+ if (validateOperateActionDisplayWorkspaceV1(value, expected).length > 0) {
925
+ const error = new TypeError(
926
+ "The Action display workspace does not satisfy its closed integrity contract.",
927
+ );
928
+ error.code = "E_OPERATE_ACTION_DISPLAY_INVALID";
929
+ throw error;
930
+ }
931
+ return value;
932
+ }
933
+
934
+ export function issueOperateActionDisplayWorkspaceV1(payload) {
935
+ return issueDisplay(
936
+ "operate-action-display-workspace",
937
+ ACTION_WORKSPACE_DOMAIN,
938
+ payload,
939
+ assertOperateActionDisplayWorkspaceV1,
940
+ );
941
+ }
942
+
943
+ function validRecoveryDisplayPayload(payload) {
944
+ const data = payload.data;
945
+ if (
946
+ "integrityBoundary" in data.inspection ||
947
+ data.recoveryState !== recoveryStateFromInspection(data.inspection)
948
+ )
949
+ return false;
950
+ return true;
951
+ }
952
+
953
+ function validRecoveryDisplaySemantics(value, expected) {
954
+ return (
955
+ value.integrity.sourceViewHash === value.payload.viewHash &&
956
+ exactExpectedBinding(value.payload, expected, { workspace: true, recovery: true }) &&
957
+ validRecoveryDisplayPayload(value.payload)
958
+ );
959
+ }
960
+
961
+ export function validateOperateRecoveryDisplaySurfaceV1(value, expected) {
962
+ return validateDisplay(
963
+ value,
964
+ recoveryDisplaySurfaceSchema,
965
+ "schemas/v1.2.0/operate-recovery-display-surface.schema.json",
966
+ validRecoveryDisplaySemantics,
967
+ expected,
968
+ );
969
+ }
970
+
971
+ export function assertOperateRecoveryDisplaySurfaceV1(value, expected) {
972
+ if (validateOperateRecoveryDisplaySurfaceV1(value, expected).length > 0) {
973
+ const error = new TypeError(
974
+ "The recovery display surface does not satisfy its closed integrity contract.",
975
+ );
976
+ error.code = "E_OPERATE_RECOVERY_DISPLAY_INVALID";
977
+ throw error;
978
+ }
979
+ return value;
980
+ }
981
+
982
+ export function issueOperateRecoveryDisplaySurfaceV1(payload) {
983
+ return issueDisplay(
984
+ "operate-recovery-display-surface",
985
+ RECOVERY_DISPLAY_DOMAIN,
986
+ payload,
987
+ assertOperateRecoveryDisplaySurfaceV1,
988
+ );
989
+ }
990
+
991
+ export const OPERATE_ACTION_DISPLAY_WORKSPACE_SCHEMA_V1 = Object.freeze(
992
+ structuredClone(actionDisplayWorkspaceSchema),
993
+ );
994
+ export const OPERATE_RECOVERY_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
995
+ structuredClone(recoveryDisplaySurfaceSchema),
996
+ );
997
+
998
+ export const OPERATE_EXECUTIVE_BOARD_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
999
+ structuredClone(executiveBoardDisplaySurfaceSchema),
1000
+ );
1001
+
1002
+ export const OPERATE_EXPERIENCE_DISPLAY_SURFACE_SCHEMA_V1 = Object.freeze(
1003
+ structuredClone(displaySurfaceSchema),
1004
+ );
1005
+ export const OPERATE_CYCLE_DISPLAY_WORKSPACE_SCHEMA_V1 = Object.freeze(
1006
+ structuredClone(cycleDisplayWorkspaceSchema),
1007
+ );