@xoxoai/checkmate 0.6.6 → 0.7.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 (382) hide show
  1. package/dist/checkmate.js +13375 -0
  2. package/package.json +14 -100
  3. package/plugin/.claude-plugin/plugin.json +10 -0
  4. package/plugin/bin/checkmate.ts +3 -0
  5. package/plugin/contracts/finding.schema.json +78 -0
  6. package/plugin/contracts/gap.schema.json +56 -0
  7. package/plugin/contracts/plan-candidate.schema.json +103 -0
  8. package/plugin/contracts/plan-delta.schema.json +63 -0
  9. package/plugin/contracts/plan-patch.schema.json +116 -0
  10. package/plugin/contracts/plan-request.schema.json +108 -0
  11. package/plugin/contracts/plan.schema.json +313 -0
  12. package/plugin/contracts/profile.schema.json +154 -0
  13. package/plugin/contracts/response.schema.json +25 -0
  14. package/plugin/contracts/result.schema.json +410 -0
  15. package/plugin/dist/checkmate.js +13012 -0
  16. package/plugin/package.json +4 -0
  17. package/plugin/references/browser.md +35 -0
  18. package/plugin/references/http.md +30 -0
  19. package/plugin/references/workflow.md +122 -0
  20. package/plugin/skills/execute/SKILL.md +92 -0
  21. package/plugin/skills/plan/SKILL.md +94 -0
  22. package/plugin/skills/report/SKILL.md +28 -0
  23. package/plugin/skills/revise/SKILL.md +43 -0
  24. package/plugin/skills/setup/SKILL.md +82 -0
  25. package/plugin/skills/status/SKILL.md +20 -0
  26. package/plugin/skills/ui/SKILL.md +26 -0
  27. package/plugin/src/actor.ts +21 -0
  28. package/plugin/src/cli.ts +1133 -0
  29. package/plugin/src/contracts.ts +342 -0
  30. package/plugin/src/index.ts +52 -0
  31. package/plugin/src/plans.ts +1028 -0
  32. package/plugin/src/render.ts +544 -0
  33. package/plugin/src/runs.ts +868 -0
  34. package/plugin/src/store.ts +384 -0
  35. package/plugin/src/targets.ts +205 -0
  36. package/plugin/src/types.ts +319 -0
  37. package/plugin/src/ui/assets/client.js +501 -0
  38. package/plugin/src/ui/assets/favicon.svg +1 -0
  39. package/plugin/src/ui/assets/fonts/inter-OFL.txt +93 -0
  40. package/plugin/src/ui/assets/fonts/inter.woff2 +0 -0
  41. package/plugin/src/ui/assets/fonts/jetbrains-mono-OFL.txt +93 -0
  42. package/plugin/src/ui/assets/fonts/jetbrains-mono.woff2 +0 -0
  43. package/plugin/src/ui/assets/fonts/space-grotesk-OFL.txt +93 -0
  44. package/plugin/src/ui/assets/fonts/space-grotesk.woff2 +0 -0
  45. package/plugin/src/ui/assets/style.css +1926 -0
  46. package/plugin/src/ui/edit.ts +305 -0
  47. package/plugin/src/ui/forms.ts +209 -0
  48. package/plugin/src/ui/html.ts +130 -0
  49. package/plugin/src/ui/layout.ts +198 -0
  50. package/plugin/src/ui/lists.ts +645 -0
  51. package/plugin/src/ui/plan.ts +577 -0
  52. package/plugin/src/ui/run.ts +489 -0
  53. package/plugin/src/ui/server.ts +684 -0
  54. package/plugin/src/validators.d.ts +13 -0
  55. package/plugin/src/validators.js +1 -0
  56. package/plugin/src/views.ts +839 -0
  57. package/LICENSE +0 -21
  58. package/README.md +0 -294
  59. package/bin/checkmate.js +0 -13
  60. package/dist/ai/client.d.ts +0 -64
  61. package/dist/ai/client.d.ts.map +0 -1
  62. package/dist/ai/client.js +0 -313
  63. package/dist/ai/client.js.map +0 -1
  64. package/dist/ai/message-handler.d.ts +0 -9
  65. package/dist/ai/message-handler.d.ts.map +0 -1
  66. package/dist/ai/message-handler.js +0 -50
  67. package/dist/ai/message-handler.js.map +0 -1
  68. package/dist/ai/message-history.d.ts +0 -17
  69. package/dist/ai/message-history.d.ts.map +0 -1
  70. package/dist/ai/message-history.js +0 -45
  71. package/dist/ai/message-history.js.map +0 -1
  72. package/dist/ai/prompts.d.ts +0 -4
  73. package/dist/ai/prompts.d.ts.map +0 -1
  74. package/dist/ai/prompts.js +0 -24
  75. package/dist/ai/prompts.js.map +0 -1
  76. package/dist/ai/rate-limit-policy.d.ts +0 -9
  77. package/dist/ai/rate-limit-policy.d.ts.map +0 -1
  78. package/dist/ai/rate-limit-policy.js +0 -34
  79. package/dist/ai/rate-limit-policy.js.map +0 -1
  80. package/dist/ai/tool-response-handler.d.ts +0 -16
  81. package/dist/ai/tool-response-handler.d.ts.map +0 -1
  82. package/dist/ai/tool-response-handler.js +0 -85
  83. package/dist/ai/tool-response-handler.js.map +0 -1
  84. package/dist/ai/turn-processor.d.ts +0 -34
  85. package/dist/ai/turn-processor.d.ts.map +0 -1
  86. package/dist/ai/turn-processor.js +0 -107
  87. package/dist/ai/turn-processor.js.map +0 -1
  88. package/dist/api/allocate-run-identity.d.ts +0 -8
  89. package/dist/api/allocate-run-identity.d.ts.map +0 -1
  90. package/dist/api/allocate-run-identity.js +0 -10
  91. package/dist/api/allocate-run-identity.js.map +0 -1
  92. package/dist/api/execute-prepared-run.d.ts +0 -22
  93. package/dist/api/execute-prepared-run.d.ts.map +0 -1
  94. package/dist/api/execute-prepared-run.js +0 -184
  95. package/dist/api/execute-prepared-run.js.map +0 -1
  96. package/dist/api/index.d.ts +0 -25
  97. package/dist/api/index.d.ts.map +0 -1
  98. package/dist/api/index.js +0 -69
  99. package/dist/api/index.js.map +0 -1
  100. package/dist/api/prepare-run.d.ts +0 -44
  101. package/dist/api/prepare-run.d.ts.map +0 -1
  102. package/dist/api/prepare-run.js +0 -261
  103. package/dist/api/prepare-run.js.map +0 -1
  104. package/dist/cli/diagnostic-relay.d.ts +0 -6
  105. package/dist/cli/diagnostic-relay.d.ts.map +0 -1
  106. package/dist/cli/diagnostic-relay.js +0 -6
  107. package/dist/cli/diagnostic-relay.js.map +0 -1
  108. package/dist/cli/main.d.ts +0 -21
  109. package/dist/cli/main.d.ts.map +0 -1
  110. package/dist/cli/main.js +0 -166
  111. package/dist/cli/main.js.map +0 -1
  112. package/dist/cli/protocol.d.ts +0 -57
  113. package/dist/cli/protocol.d.ts.map +0 -1
  114. package/dist/cli/protocol.js +0 -116
  115. package/dist/cli/protocol.js.map +0 -1
  116. package/dist/cli/reconcile-result.d.ts +0 -13
  117. package/dist/cli/reconcile-result.d.ts.map +0 -1
  118. package/dist/cli/reconcile-result.js +0 -300
  119. package/dist/cli/reconcile-result.js.map +0 -1
  120. package/dist/cli/run-parent.d.ts +0 -37
  121. package/dist/cli/run-parent.d.ts.map +0 -1
  122. package/dist/cli/run-parent.js +0 -491
  123. package/dist/cli/run-parent.js.map +0 -1
  124. package/dist/cli/signals.d.ts +0 -36
  125. package/dist/cli/signals.d.ts.map +0 -1
  126. package/dist/cli/signals.js +0 -85
  127. package/dist/cli/signals.js.map +0 -1
  128. package/dist/cli/static-commands.d.ts +0 -11
  129. package/dist/cli/static-commands.d.ts.map +0 -1
  130. package/dist/cli/static-commands.js +0 -83
  131. package/dist/cli/static-commands.js.map +0 -1
  132. package/dist/cli/worker-stream-guard.d.ts +0 -20
  133. package/dist/cli/worker-stream-guard.d.ts.map +0 -1
  134. package/dist/cli/worker-stream-guard.js +0 -41
  135. package/dist/cli/worker-stream-guard.js.map +0 -1
  136. package/dist/cli/worker.d.ts +0 -3
  137. package/dist/cli/worker.d.ts.map +0 -1
  138. package/dist/cli/worker.js +0 -111
  139. package/dist/cli/worker.js.map +0 -1
  140. package/dist/config/ingestion.d.ts +0 -58
  141. package/dist/config/ingestion.d.ts.map +0 -1
  142. package/dist/config/ingestion.js +0 -283
  143. package/dist/config/ingestion.js.map +0 -1
  144. package/dist/config/manifest.d.ts +0 -20
  145. package/dist/config/manifest.d.ts.map +0 -1
  146. package/dist/config/manifest.js +0 -91
  147. package/dist/config/manifest.js.map +0 -1
  148. package/dist/config/model-egress.d.ts +0 -10
  149. package/dist/config/model-egress.d.ts.map +0 -1
  150. package/dist/config/model-egress.js +0 -62
  151. package/dist/config/model-egress.js.map +0 -1
  152. package/dist/config/package-resolution.d.ts +0 -4
  153. package/dist/config/package-resolution.d.ts.map +0 -1
  154. package/dist/config/package-resolution.js +0 -24
  155. package/dist/config/package-resolution.js.map +0 -1
  156. package/dist/config/policy.d.ts +0 -44
  157. package/dist/config/policy.d.ts.map +0 -1
  158. package/dist/config/policy.js +0 -141
  159. package/dist/config/policy.js.map +0 -1
  160. package/dist/config/record.d.ts +0 -4
  161. package/dist/config/record.d.ts.map +0 -1
  162. package/dist/config/record.js +0 -10
  163. package/dist/config/record.js.map +0 -1
  164. package/dist/config/secrets.d.ts +0 -11
  165. package/dist/config/secrets.d.ts.map +0 -1
  166. package/dist/config/secrets.js +0 -42
  167. package/dist/config/secrets.js.map +0 -1
  168. package/dist/contracts/diagnostics.d.ts +0 -4
  169. package/dist/contracts/diagnostics.d.ts.map +0 -1
  170. package/dist/contracts/diagnostics.js +0 -31
  171. package/dist/contracts/diagnostics.js.map +0 -1
  172. package/dist/contracts/serialize.d.ts +0 -2
  173. package/dist/contracts/serialize.d.ts.map +0 -1
  174. package/dist/contracts/serialize.js +0 -90
  175. package/dist/contracts/serialize.js.map +0 -1
  176. package/dist/contracts/types.d.ts +0 -316
  177. package/dist/contracts/types.d.ts.map +0 -1
  178. package/dist/contracts/types.js +0 -74
  179. package/dist/contracts/types.js.map +0 -1
  180. package/dist/contracts/validator.d.ts +0 -8
  181. package/dist/contracts/validator.d.ts.map +0 -1
  182. package/dist/contracts/validator.js +0 -71
  183. package/dist/contracts/validator.js.map +0 -1
  184. package/dist/driver.d.ts +0 -97
  185. package/dist/driver.d.ts.map +0 -1
  186. package/dist/driver.js +0 -24
  187. package/dist/driver.js.map +0 -1
  188. package/dist/drivers/descriptor.d.ts +0 -15
  189. package/dist/drivers/descriptor.d.ts.map +0 -1
  190. package/dist/drivers/descriptor.js +0 -122
  191. package/dist/drivers/descriptor.js.map +0 -1
  192. package/dist/drivers/loader.d.ts +0 -18
  193. package/dist/drivers/loader.d.ts.map +0 -1
  194. package/dist/drivers/loader.js +0 -97
  195. package/dist/drivers/loader.js.map +0 -1
  196. package/dist/drivers/web/checkmate-driver.json +0 -47
  197. package/dist/drivers/web/index.d.ts +0 -6
  198. package/dist/drivers/web/index.d.ts.map +0 -1
  199. package/dist/drivers/web/index.js +0 -27
  200. package/dist/drivers/web/index.js.map +0 -1
  201. package/dist/drivers/web/session.d.ts +0 -25
  202. package/dist/drivers/web/session.d.ts.map +0 -1
  203. package/dist/drivers/web/session.js +0 -132
  204. package/dist/drivers/web/session.js.map +0 -1
  205. package/dist/drivers/web/tools/network-request-recorder.d.ts +0 -46
  206. package/dist/drivers/web/tools/network-request-recorder.d.ts.map +0 -1
  207. package/dist/drivers/web/tools/network-request-recorder.js +0 -164
  208. package/dist/drivers/web/tools/network-request-recorder.js.map +0 -1
  209. package/dist/drivers/web/tools/screenshot-service.d.ts +0 -10
  210. package/dist/drivers/web/tools/screenshot-service.d.ts.map +0 -1
  211. package/dist/drivers/web/tools/screenshot-service.js +0 -23
  212. package/dist/drivers/web/tools/screenshot-service.js.map +0 -1
  213. package/dist/drivers/web/tools/snapshot-filter/index.d.ts +0 -4
  214. package/dist/drivers/web/tools/snapshot-filter/index.d.ts.map +0 -1
  215. package/dist/drivers/web/tools/snapshot-filter/index.js +0 -4
  216. package/dist/drivers/web/tools/snapshot-filter/index.js.map +0 -1
  217. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts +0 -15
  218. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts.map +0 -1
  219. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js +0 -99
  220. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js.map +0 -1
  221. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts +0 -5
  222. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts.map +0 -1
  223. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js +0 -56
  224. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js.map +0 -1
  225. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts +0 -3
  226. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts.map +0 -1
  227. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js +0 -85
  228. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js.map +0 -1
  229. package/dist/drivers/web/tools/snapshot-service.d.ts +0 -31
  230. package/dist/drivers/web/tools/snapshot-service.d.ts.map +0 -1
  231. package/dist/drivers/web/tools/snapshot-service.js +0 -96
  232. package/dist/drivers/web/tools/snapshot-service.js.map +0 -1
  233. package/dist/drivers/web/tools/tool.d.ts +0 -76
  234. package/dist/drivers/web/tools/tool.d.ts.map +0 -1
  235. package/dist/drivers/web/tools/tool.js +0 -562
  236. package/dist/drivers/web/tools/tool.js.map +0 -1
  237. package/dist/drivers/web/tools/transient-state-tracker.d.ts +0 -26
  238. package/dist/drivers/web/tools/transient-state-tracker.d.ts.map +0 -1
  239. package/dist/drivers/web/tools/transient-state-tracker.js +0 -301
  240. package/dist/drivers/web/tools/transient-state-tracker.js.map +0 -1
  241. package/dist/drivers/web/tools/types.d.ts +0 -11
  242. package/dist/drivers/web/tools/types.d.ts.map +0 -1
  243. package/dist/drivers/web/tools/types.js +0 -2
  244. package/dist/drivers/web/tools/types.js.map +0 -1
  245. package/dist/evidence/atomic-file.d.ts +0 -23
  246. package/dist/evidence/atomic-file.d.ts.map +0 -1
  247. package/dist/evidence/atomic-file.js +0 -104
  248. package/dist/evidence/atomic-file.js.map +0 -1
  249. package/dist/evidence/layout.d.ts +0 -30
  250. package/dist/evidence/layout.d.ts.map +0 -1
  251. package/dist/evidence/layout.js +0 -152
  252. package/dist/evidence/layout.js.map +0 -1
  253. package/dist/evidence/retention.d.ts +0 -5
  254. package/dist/evidence/retention.d.ts.map +0 -1
  255. package/dist/evidence/retention.js +0 -10
  256. package/dist/evidence/retention.js.map +0 -1
  257. package/dist/evidence/store.d.ts +0 -101
  258. package/dist/evidence/store.d.ts.map +0 -1
  259. package/dist/evidence/store.js +0 -375
  260. package/dist/evidence/store.js.map +0 -1
  261. package/dist/evidence/terminal-finalizer.d.ts +0 -19
  262. package/dist/evidence/terminal-finalizer.d.ts.map +0 -1
  263. package/dist/evidence/terminal-finalizer.js +0 -56
  264. package/dist/evidence/terminal-finalizer.js.map +0 -1
  265. package/dist/index.d.ts +0 -9
  266. package/dist/index.d.ts.map +0 -1
  267. package/dist/index.js +0 -12
  268. package/dist/index.js.map +0 -1
  269. package/dist/logging/invocation-logger.d.ts +0 -4
  270. package/dist/logging/invocation-logger.d.ts.map +0 -1
  271. package/dist/logging/invocation-logger.js +0 -25
  272. package/dist/logging/invocation-logger.js.map +0 -1
  273. package/dist/logging/level-logger.d.ts +0 -11
  274. package/dist/logging/level-logger.d.ts.map +0 -1
  275. package/dist/logging/level-logger.js +0 -82
  276. package/dist/logging/level-logger.js.map +0 -1
  277. package/dist/logging/types.d.ts +0 -8
  278. package/dist/logging/types.d.ts.map +0 -1
  279. package/dist/logging/types.js +0 -7
  280. package/dist/logging/types.js.map +0 -1
  281. package/dist/redaction/diagnostic-sanitizer.d.ts +0 -7
  282. package/dist/redaction/diagnostic-sanitizer.d.ts.map +0 -1
  283. package/dist/redaction/diagnostic-sanitizer.js +0 -42
  284. package/dist/redaction/diagnostic-sanitizer.js.map +0 -1
  285. package/dist/redaction/redactor.d.ts +0 -40
  286. package/dist/redaction/redactor.d.ts.map +0 -1
  287. package/dist/redaction/redactor.js +0 -176
  288. package/dist/redaction/redactor.js.map +0 -1
  289. package/dist/redaction/scrub.d.ts +0 -29
  290. package/dist/redaction/scrub.d.ts.map +0 -1
  291. package/dist/redaction/scrub.js +0 -54
  292. package/dist/redaction/scrub.js.map +0 -1
  293. package/dist/runtime/config.d.ts +0 -16
  294. package/dist/runtime/config.d.ts.map +0 -1
  295. package/dist/runtime/config.js +0 -2
  296. package/dist/runtime/config.js.map +0 -1
  297. package/dist/runtime/driver-boundary.d.ts +0 -16
  298. package/dist/runtime/driver-boundary.d.ts.map +0 -1
  299. package/dist/runtime/driver-boundary.js +0 -71
  300. package/dist/runtime/driver-boundary.js.map +0 -1
  301. package/dist/runtime/driver-session.d.ts +0 -9
  302. package/dist/runtime/driver-session.d.ts.map +0 -1
  303. package/dist/runtime/driver-session.js +0 -64
  304. package/dist/runtime/driver-session.js.map +0 -1
  305. package/dist/runtime/internal-step-evidence.d.ts +0 -30
  306. package/dist/runtime/internal-step-evidence.d.ts.map +0 -1
  307. package/dist/runtime/internal-step-evidence.js +0 -82
  308. package/dist/runtime/internal-step-evidence.js.map +0 -1
  309. package/dist/runtime/result-adapter.d.ts +0 -9
  310. package/dist/runtime/result-adapter.d.ts.map +0 -1
  311. package/dist/runtime/result-adapter.js +0 -77
  312. package/dist/runtime/result-adapter.js.map +0 -1
  313. package/dist/runtime/runner.d.ts +0 -43
  314. package/dist/runtime/runner.d.ts.map +0 -1
  315. package/dist/runtime/runner.js +0 -72
  316. package/dist/runtime/runner.js.map +0 -1
  317. package/dist/runtime/scenario-control.d.ts +0 -40
  318. package/dist/runtime/scenario-control.d.ts.map +0 -1
  319. package/dist/runtime/scenario-control.js +0 -94
  320. package/dist/runtime/scenario-control.js.map +0 -1
  321. package/dist/runtime/scenario-runner.d.ts +0 -41
  322. package/dist/runtime/scenario-runner.d.ts.map +0 -1
  323. package/dist/runtime/scenario-runner.js +0 -274
  324. package/dist/runtime/scenario-runner.js.map +0 -1
  325. package/dist/runtime/scenario-state.d.ts +0 -55
  326. package/dist/runtime/scenario-state.d.ts.map +0 -1
  327. package/dist/runtime/scenario-state.js +0 -128
  328. package/dist/runtime/scenario-state.js.map +0 -1
  329. package/dist/runtime/step-execution.d.ts +0 -27
  330. package/dist/runtime/step-execution.d.ts.map +0 -1
  331. package/dist/runtime/step-execution.js +0 -143
  332. package/dist/runtime/step-execution.js.map +0 -1
  333. package/dist/runtime/text.d.ts +0 -10
  334. package/dist/runtime/text.d.ts.map +0 -1
  335. package/dist/runtime/text.js +0 -25
  336. package/dist/runtime/text.js.map +0 -1
  337. package/dist/runtime/types.d.ts +0 -53
  338. package/dist/runtime/types.d.ts.map +0 -1
  339. package/dist/runtime/types.js +0 -2
  340. package/dist/runtime/types.js.map +0 -1
  341. package/dist/runtime/usage-tracker.d.ts +0 -37
  342. package/dist/runtime/usage-tracker.d.ts.map +0 -1
  343. package/dist/runtime/usage-tracker.js +0 -110
  344. package/dist/runtime/usage-tracker.js.map +0 -1
  345. package/dist/tools/define-agent-tool.d.ts +0 -20
  346. package/dist/tools/define-agent-tool.d.ts.map +0 -1
  347. package/dist/tools/define-agent-tool.js +0 -30
  348. package/dist/tools/define-agent-tool.js.map +0 -1
  349. package/dist/tools/dispatcher.d.ts +0 -19
  350. package/dist/tools/dispatcher.d.ts.map +0 -1
  351. package/dist/tools/dispatcher.js +0 -91
  352. package/dist/tools/dispatcher.js.map +0 -1
  353. package/dist/tools/loop-detector.d.ts +0 -27
  354. package/dist/tools/loop-detector.d.ts.map +0 -1
  355. package/dist/tools/loop-detector.js +0 -76
  356. package/dist/tools/loop-detector.js.map +0 -1
  357. package/dist/tools/registry.d.ts +0 -19
  358. package/dist/tools/registry.d.ts.map +0 -1
  359. package/dist/tools/registry.js +0 -54
  360. package/dist/tools/registry.js.map +0 -1
  361. package/dist/tools/step/result-tool.d.ts +0 -7
  362. package/dist/tools/step/result-tool.d.ts.map +0 -1
  363. package/dist/tools/step/result-tool.js +0 -34
  364. package/dist/tools/step/result-tool.js.map +0 -1
  365. package/dist/tools/tool-contract.d.ts +0 -3
  366. package/dist/tools/tool-contract.d.ts.map +0 -1
  367. package/dist/tools/tool-contract.js +0 -2
  368. package/dist/tools/tool-contract.js.map +0 -1
  369. package/dist/tools/types.d.ts +0 -210
  370. package/dist/tools/types.d.ts.map +0 -1
  371. package/dist/tools/types.js +0 -4
  372. package/dist/tools/types.js.map +0 -1
  373. package/docs/CLI.md +0 -59
  374. package/docs/CONFIGURATION.md +0 -105
  375. package/docs/DRIVERS.md +0 -79
  376. package/docs/EVIDENCE.md +0 -64
  377. package/schemas/checkmate-config.v1.json +0 -176
  378. package/schemas/describe-result.v1.json +0 -414
  379. package/schemas/driver-descriptor.v1.json +0 -66
  380. package/schemas/run-request.v1.json +0 -67
  381. package/schemas/run-result.v1.json +0 -333
  382. package/schemas/validation-result.v1.json +0 -86
@@ -0,0 +1,342 @@
1
+ import type {
2
+ Finding,
3
+ Gap,
4
+ Plan,
5
+ PlanCandidate,
6
+ PlanDelta,
7
+ PlanPatch,
8
+ PlanRequest,
9
+ Profile,
10
+ Response,
11
+ Result,
12
+ } from './types.ts'
13
+ import { canonical } from './store.ts'
14
+ import * as validators from './validators.js'
15
+
16
+ export type Test = Plan['tests'][number]
17
+ export type Assertion = Test['assertions'][number]
18
+ export type ResultTest = Result['tests'][number]
19
+ export type AssertionResult = ResultTest['assertions'][number]['result']
20
+ export type Documents = {
21
+ profile: Profile
22
+ 'plan-request': PlanRequest
23
+ 'plan-candidate': PlanCandidate
24
+ 'plan-delta': PlanDelta
25
+ 'plan-patch': PlanPatch
26
+ plan: Plan
27
+ gap: Gap
28
+ finding: Finding
29
+ result: Result
30
+ response: Response
31
+ }
32
+ export type PlanDraft = Omit<Plan, 'coverage' | 'tests'> & { tests: Array<Omit<Test, 'readiness' | 'gapIds'>> }
33
+
34
+ const identifier = /^[A-Za-z0-9][A-Za-z0-9_-]{0,95}$/
35
+
36
+ export function requireCondition(condition: unknown, message: string): asserts condition {
37
+ if (!condition) throw new Error(message)
38
+ }
39
+
40
+ export function same(a: unknown, b: unknown) {
41
+ return canonical(a) === canonical(b)
42
+ }
43
+
44
+ export function validate<K extends keyof Documents>(name: K, value: unknown): Documents[K] {
45
+ const check = validators[name.replace(/-./g, (match) => match[1].toUpperCase()) as keyof typeof validators]
46
+ const errors = () => (check.errors ?? []).map((error) => `${name}${error.instancePath} ${error.message}`).join(', ')
47
+ requireCondition(check(value), `Invalid ${name}: ${errors()}`)
48
+ return value as Documents[K]
49
+ }
50
+
51
+ export function requireIdentifier(value: unknown, name: string): string {
52
+ requireCondition(
53
+ typeof value === 'string' && identifier.test(value),
54
+ `Invalid ${name}: ${String(value)}. Use 1 to 96 letters, digits, _ or -, starting with a letter or digit.`
55
+ )
56
+ return value
57
+ }
58
+
59
+ export function requireText(value: unknown, name: string): string {
60
+ requireCondition(typeof value === 'string' && value.trim().length > 0, `Missing ${name}`)
61
+ return value
62
+ }
63
+
64
+ export function requireChoice<T extends string>(value: unknown, choices: readonly T[], name: string): T {
65
+ requireCondition(
66
+ choices.includes(value as T),
67
+ `Invalid ${name}: ${String(value)}. Use one of: ${choices.join(', ')}.`
68
+ )
69
+ return value as T
70
+ }
71
+
72
+ export function revisionReference(text: string, name: string) {
73
+ const [id, revision, ...rest] = text.split('@')
74
+ requireIdentifier(id, name)
75
+ requireCondition(
76
+ !rest.length && (revision === undefined || /^[1-9][0-9]*$/.test(revision)),
77
+ `Invalid ${name}: ${text}. Use <id> or <id>@<revision>.`
78
+ )
79
+ return { id, revision: revision === undefined ? null : Number(revision) }
80
+ }
81
+
82
+ export function testReference(reference: string) {
83
+ const [planId, testId] = reference.includes(':') ? reference.split(':') : [null, reference]
84
+ return { planId, testId }
85
+ }
86
+
87
+ export function expectDigest(actual: string, expected: string | undefined, subject: string) {
88
+ if (expected === undefined) return
89
+ requireCondition(/^[a-f0-9]{8,64}$/.test(expected), `Invalid --expect-sha: ${expected}. Use 8 to 64 hex digits.`)
90
+ requireCondition(
91
+ actual.startsWith(expected),
92
+ `${subject} has digest ${actual}, not ${expected}. Read it again before you decide.`
93
+ )
94
+ }
95
+
96
+ export function index<T, K extends keyof T>(items: T[], key: K, name: string): Map<T[K], T> {
97
+ const map = new Map<T[K], T>()
98
+ for (const item of items) {
99
+ requireCondition(!map.has(item[key]), `Duplicate ${name}: ${String(item[key])}`)
100
+ map.set(item[key], item)
101
+ }
102
+ return map
103
+ }
104
+
105
+ export function references(ids: string[], map: ReadonlyMap<string, unknown>, name: string) {
106
+ for (const id of ids) requireCondition(map.has(id), `Unknown ${name}: ${id}`)
107
+ }
108
+
109
+ export function profileCheck(value: unknown): Profile {
110
+ const profile = validate('profile', value)
111
+ index(profile.tools, 'name', 'tool')
112
+ const url = new URL(profile.baseUrl)
113
+ requireCondition(['http:', 'https:'].includes(url.protocol), 'Target must use HTTP or HTTPS')
114
+ requireCondition(!url.username && !url.password, 'Use credential references, not URL credentials')
115
+ for (const tool of profile.tools)
116
+ requireCondition(
117
+ tool.version === undefined || !/resolve-and-pin|unknown/i.test(tool.version),
118
+ `Record the actual version of ${tool.name}, or leave version out`
119
+ )
120
+ return profile
121
+ }
122
+
123
+ export function approvalPolicy(profile: Profile) {
124
+ return profile.approvals ?? { plan: 'required', result: 'required' }
125
+ }
126
+
127
+ export function gapsAffecting(gaps: Gap[], test: Pick<Test, 'id' | 'requirementIds'>) {
128
+ return gaps.filter(
129
+ (gap) =>
130
+ gap.testIds.includes(test.id) ||
131
+ gap.requirementIds.some((id) => test.requirementIds.includes(id)) ||
132
+ (gap.testIds.length === 0 && gap.requirementIds.length === 0)
133
+ )
134
+ }
135
+
136
+ export function testReadiness(gaps: Gap[], test: Pick<Test, 'id' | 'requirementIds'>): Test['readiness'] {
137
+ const affected = gapsAffecting(gaps, test)
138
+ if (affected.some((gap) => gap.status === 'deferred' && gap.severity === 'blocking')) return 'deferred'
139
+ if (affected.some((gap) => gap.status === 'open' && gap.severity === 'blocking')) return 'blocked'
140
+ return 'ready'
141
+ }
142
+
143
+ export function planCoverage(plan: Pick<Plan, 'requirements' | 'tests' | 'gaps'>): Plan['coverage'] {
144
+ return plan.requirements.map((requirement) => {
145
+ const tests = plan.tests.filter((test) => test.requirementIds.includes(requirement.id))
146
+ const gaps = plan.gaps.filter(
147
+ (gap) => gap.requirementIds.includes(requirement.id) || (!gap.requirementIds.length && !gap.testIds.length)
148
+ )
149
+ const status =
150
+ gaps.some((gap) => gap.status === 'deferred' && gap.severity === 'blocking') ||
151
+ tests.some((test) => test.readiness === 'deferred')
152
+ ? 'deferred'
153
+ : gaps.some((gap) => gap.severity === 'blocking' && gap.status === 'open') ||
154
+ tests.some((test) => test.readiness === 'blocked') ||
155
+ tests.length === 0
156
+ ? 'blocked'
157
+ : 'planned'
158
+ return { requirementId: requirement.id, testIds: tests.map((test) => test.id), status }
159
+ })
160
+ }
161
+
162
+ export function derivePlan(draft: PlanDraft): Plan {
163
+ const tests = draft.tests.map((test) => ({
164
+ ...test,
165
+ gapIds: gapsAffecting(draft.gaps, test).map((gap) => gap.id),
166
+ readiness: testReadiness(draft.gaps, test),
167
+ }))
168
+ return { ...draft, tests, coverage: planCoverage({ ...draft, tests }) }
169
+ }
170
+
171
+ export function planCheck(value: unknown): Plan {
172
+ const plan = validate('plan', value)
173
+ const requirements = index(plan.requirements, 'id', 'requirement')
174
+ const tests = index(plan.tests, 'id', 'test')
175
+ const gaps = index(plan.gaps, 'id', 'gap')
176
+ const decisions = index(plan.decisions, 'id', 'decision')
177
+ index(plan.coverage, 'requirementId', 'coverage requirement')
178
+ index(plan.assumptions, 'decisionId', 'assumption decision')
179
+ const localReferences = (ids: string[]) =>
180
+ ids.filter((id) => {
181
+ const { planId } = testReference(id)
182
+ requireCondition(planId !== plan.planId, `Use the local test ID, not ${id}`)
183
+ return planId === null
184
+ })
185
+ for (const gap of plan.gaps) {
186
+ references(gap.requirementIds, requirements, `requirement in gap ${gap.id}`)
187
+ references(localReferences(gap.testIds), tests, `test in gap ${gap.id}`)
188
+ if (gap.status === 'open') requireCondition(gap.decisionId === null, `Open gap ${gap.id} has a decision`)
189
+ else {
190
+ const decision = decisions.get(gap.decisionId ?? '')
191
+ requireCondition(decision?.gapId === gap.id, `Gap ${gap.id} needs a matching decision`)
192
+ requireCondition(
193
+ (decision.kind === 'defer') === (gap.status === 'deferred'),
194
+ `Gap ${gap.id} status conflicts with decision ${decision.id}`
195
+ )
196
+ }
197
+ }
198
+ for (const decision of plan.decisions) {
199
+ requireCondition(
200
+ gaps.get(decision.gapId)?.decisionId === decision.id,
201
+ `Decision ${decision.id} does not resolve its gap`
202
+ )
203
+ if (decision.kind === 'clarify')
204
+ requireCondition(decision.source, `Clarification ${decision.id} needs a source`)
205
+ if (decision.kind === 'accept_assumption')
206
+ requireCondition(
207
+ plan.assumptions.some((a) => a.decisionId === decision.id && a.text === decision.value),
208
+ `Accepted assumption ${decision.id} must stay visible`
209
+ )
210
+ }
211
+ for (const assumption of plan.assumptions)
212
+ requireCondition(
213
+ decisions.get(assumption.decisionId)?.kind === 'accept_assumption',
214
+ `Assumption ${assumption.decisionId} lacks oracle acceptance`
215
+ )
216
+ for (const test of plan.tests) {
217
+ references(test.requirementIds, requirements, `requirement in test ${test.id}`)
218
+ references(test.gapIds, gaps, `gap in test ${test.id}`)
219
+ references(localReferences(test.dependsOn), tests, `dependency of test ${test.id}`)
220
+ index(test.assertions, 'id', `assertion in test ${test.id}`)
221
+ requireCondition(
222
+ same(
223
+ test.gapIds,
224
+ gapsAffecting(plan.gaps, test).map((gap) => gap.id)
225
+ ),
226
+ `Test ${test.id} gapIds conflict with gap scope`
227
+ )
228
+ requireCondition(
229
+ test.readiness === testReadiness(plan.gaps, test),
230
+ `Test ${test.id} readiness conflicts with gaps`
231
+ )
232
+ if (test.readiness === 'ready')
233
+ requireCondition(test.assertions.length > 0, `Ready test ${test.id} needs one or more assertions`)
234
+ }
235
+ for (const requirement of plan.requirements)
236
+ requireCondition(
237
+ plan.tests.some((test) => test.requirementIds.includes(requirement.id)) ||
238
+ plan.gaps.some((gap) => gap.requirementIds.includes(requirement.id)),
239
+ `Requirement ${requirement.id} has no test or gap`
240
+ )
241
+ requireCondition(same(plan.coverage, planCoverage(plan)), 'Plan coverage is inconsistent')
242
+ return plan
243
+ }
244
+
245
+ export function planTargetCheck(plan: Plan, profile: Profile) {
246
+ for (const test of plan.tests.filter((test) => test.readiness === 'ready')) {
247
+ requireCondition(
248
+ profile.capabilities.includes(test.capability),
249
+ `Test ${test.id} needs capability ${test.capability}, which the target lacks. Record a planning gap.`
250
+ )
251
+ for (const operation of test.operations)
252
+ requireCondition(
253
+ profile.allowedOperations.includes(operation),
254
+ `Test ${test.id} uses operation ${operation}, which the target does not permit`
255
+ )
256
+ }
257
+ }
258
+
259
+ export function dependencyCheck(plan: Plan, latest: ReadonlyMap<string, Plan>) {
260
+ const plans = new Map(latest).set(plan.planId, plan)
261
+ const crossReferences = [...plans.values()]
262
+ .flatMap((other) => [
263
+ ...other.tests.flatMap((test) => test.dependsOn),
264
+ ...other.gaps.flatMap((gap) => gap.testIds),
265
+ ])
266
+ .filter((id) => id.includes(':'))
267
+ for (const reference of crossReferences) {
268
+ const { planId, testId } = testReference(reference)
269
+ const other = plans.get(planId!)
270
+ requireCondition(other, `Unknown plan in ${reference}: ${planId}`)
271
+ requireCondition(
272
+ other.tests.some((test) => test.id === testId),
273
+ `Unknown test in ${reference}: ${testId} is not in ${planId}@${other.revision}`
274
+ )
275
+ }
276
+ const edges = new Map<string, string[]>()
277
+ for (const [planId, other] of plans)
278
+ for (const test of other.tests)
279
+ edges.set(
280
+ `${planId}:${test.id}`,
281
+ test.dependsOn.map((id) => (id.includes(':') ? id : `${planId}:${id}`))
282
+ )
283
+ const visiting: string[] = []
284
+ const visited = new Set<string>()
285
+ function visit(node: string) {
286
+ const start = visiting.indexOf(node)
287
+ requireCondition(start < 0, `Test dependency cycle: ${[...visiting.slice(start), node].join(' -> ')}`)
288
+ if (visited.has(node)) return
289
+ visiting.push(node)
290
+ for (const next of edges.get(node) ?? []) visit(next)
291
+ visiting.pop()
292
+ visited.add(node)
293
+ }
294
+ for (const node of edges.keys()) visit(node)
295
+ }
296
+
297
+ export function testOutcome(results: AssertionResult[]): 'passed' | 'failed' | 'error' | 'inconclusive' {
298
+ if (results.includes('failed')) return 'failed'
299
+ if (results.includes('not_checked')) return 'error'
300
+ if (results.includes('inconclusive')) return 'inconclusive'
301
+ return 'passed'
302
+ }
303
+
304
+ export function resultCoverage(plan: Plan, tests: ResultTest[], newGaps: Gap[]): Result['coverage'] {
305
+ const outcomes = new Map(tests.map((test) => [test.testId, test.outcome]))
306
+ const conclusive = (test: Plan['tests'][number]) => ['passed', 'failed'].includes(outcomes.get(test.id) ?? '')
307
+ const requirements = plan.requirements.map((requirement) => {
308
+ const planned = plan.tests.filter((test) => test.requirementIds.includes(requirement.id))
309
+ const gaps = [...plan.gaps, ...newGaps].filter(
310
+ (gap) => gap.requirementIds.includes(requirement.id) || (!gap.requirementIds.length && !gap.testIds.length)
311
+ )
312
+ const blocking = gaps.some((gap) => gap.status === 'open' && gap.severity === 'blocking')
313
+ const deferredGap = gaps.some((gap) => gap.status === 'deferred' && gap.severity === 'blocking')
314
+ const tested = planned.length > 0 && !blocking && !deferredGap && planned.every(conclusive)
315
+ const deferred =
316
+ !tested &&
317
+ !blocking &&
318
+ (deferredGap || planned.some((test) => test.readiness === 'deferred')) &&
319
+ planned.every((test) => test.readiness === 'deferred' || conclusive(test))
320
+ return {
321
+ requirementId: requirement.id,
322
+ status: tested ? ('tested' as const) : deferred ? ('deferred' as const) : ('uncovered' as const),
323
+ testIds: planned.map((test) => test.id),
324
+ reason: tested
325
+ ? null
326
+ : deferred
327
+ ? 'An oracle decision deferred the missing checks.'
328
+ : planned.some((test) => outcomes.get(test.id) === 'inconclusive')
329
+ ? 'An assertion is inconclusive.'
330
+ : 'At least one required check or decision is missing.',
331
+ }
332
+ })
333
+ const executed = ['passed', 'failed', 'error', 'inconclusive']
334
+ return {
335
+ status: requirements.every((row) => row.status === 'tested')
336
+ ? 'complete'
337
+ : tests.some((test) => executed.includes(test.outcome))
338
+ ? 'partial'
339
+ : 'not_executed',
340
+ requirements,
341
+ }
342
+ }
@@ -0,0 +1,52 @@
1
+ export type { Store, Reply, Status } from './store.ts'
2
+ export { openStore, openReadOnlyStore, closeStore, canonical, digest, ulid } from './store.ts'
3
+ export { validate, profileCheck, planCheck, planCoverage, resultCoverage, testOutcome } from './contracts.ts'
4
+ export { openTarget, saveTarget, showTarget, targetRevision } from './targets.ts'
5
+ export {
6
+ openPlan,
7
+ savePlan,
8
+ editPlan,
9
+ patchPlan,
10
+ adoptGaps,
11
+ planCandidate,
12
+ frozenRevision,
13
+ answerGap,
14
+ revisePlan,
15
+ approvePlan,
16
+ rejectPlan,
17
+ gate,
18
+ planRevision,
19
+ diffPlan,
20
+ jsonPatch,
21
+ planChanges,
22
+ } from './plans.ts'
23
+ export {
24
+ beginRun,
25
+ checkAssertion,
26
+ closeTest,
27
+ recordFinding,
28
+ recordGap,
29
+ finishRun,
30
+ resumeRun,
31
+ acceptResult,
32
+ rejectResult,
33
+ runResult,
34
+ } from './runs.ts'
35
+ export {
36
+ inbox,
37
+ planList,
38
+ planDetail,
39
+ planStatus,
40
+ planHistory,
41
+ runList,
42
+ runDetail,
43
+ operationLog,
44
+ changesAfter,
45
+ evidenceBytes,
46
+ approvalLabel,
47
+ pagedPlans,
48
+ pagedRuns,
49
+ pagedOperations,
50
+ } from './views.ts'
51
+ export { renderPlan, renderRun, runReport, exportPlan, exportRun } from './render.ts'
52
+ export { run, main } from './cli.ts'