@xoxoai/checkmate 0.6.7 → 0.7.1

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 (381) hide show
  1. package/README.md +54 -257
  2. package/dist/checkmate.js +13375 -0
  3. package/package.json +30 -94
  4. package/plugin/.claude-plugin/plugin.json +10 -0
  5. package/plugin/bin/checkmate.ts +3 -0
  6. package/plugin/contracts/finding.schema.json +78 -0
  7. package/plugin/contracts/gap.schema.json +56 -0
  8. package/plugin/contracts/plan-candidate.schema.json +103 -0
  9. package/plugin/contracts/plan-delta.schema.json +63 -0
  10. package/plugin/contracts/plan-patch.schema.json +116 -0
  11. package/plugin/contracts/plan-request.schema.json +108 -0
  12. package/plugin/contracts/plan.schema.json +313 -0
  13. package/plugin/contracts/profile.schema.json +154 -0
  14. package/plugin/contracts/response.schema.json +25 -0
  15. package/plugin/contracts/result.schema.json +410 -0
  16. package/plugin/dist/checkmate.js +13012 -0
  17. package/plugin/package.json +4 -0
  18. package/plugin/references/browser.md +35 -0
  19. package/plugin/references/http.md +30 -0
  20. package/plugin/references/workflow.md +122 -0
  21. package/plugin/skills/execute/SKILL.md +92 -0
  22. package/plugin/skills/plan/SKILL.md +94 -0
  23. package/plugin/skills/report/SKILL.md +28 -0
  24. package/plugin/skills/revise/SKILL.md +43 -0
  25. package/plugin/skills/setup/SKILL.md +82 -0
  26. package/plugin/skills/status/SKILL.md +20 -0
  27. package/plugin/skills/ui/SKILL.md +26 -0
  28. package/plugin/src/actor.ts +21 -0
  29. package/plugin/src/cli.ts +1133 -0
  30. package/plugin/src/contracts.ts +342 -0
  31. package/plugin/src/index.ts +52 -0
  32. package/plugin/src/plans.ts +1028 -0
  33. package/plugin/src/render.ts +544 -0
  34. package/plugin/src/runs.ts +868 -0
  35. package/plugin/src/store.ts +384 -0
  36. package/plugin/src/targets.ts +205 -0
  37. package/plugin/src/types.ts +319 -0
  38. package/plugin/src/ui/assets/client.js +501 -0
  39. package/plugin/src/ui/assets/favicon.svg +1 -0
  40. package/plugin/src/ui/assets/fonts/inter-OFL.txt +93 -0
  41. package/plugin/src/ui/assets/fonts/inter.woff2 +0 -0
  42. package/plugin/src/ui/assets/fonts/jetbrains-mono-OFL.txt +93 -0
  43. package/plugin/src/ui/assets/fonts/jetbrains-mono.woff2 +0 -0
  44. package/plugin/src/ui/assets/fonts/space-grotesk-OFL.txt +93 -0
  45. package/plugin/src/ui/assets/fonts/space-grotesk.woff2 +0 -0
  46. package/plugin/src/ui/assets/style.css +1926 -0
  47. package/plugin/src/ui/edit.ts +305 -0
  48. package/plugin/src/ui/forms.ts +209 -0
  49. package/plugin/src/ui/html.ts +130 -0
  50. package/plugin/src/ui/layout.ts +198 -0
  51. package/plugin/src/ui/lists.ts +645 -0
  52. package/plugin/src/ui/plan.ts +577 -0
  53. package/plugin/src/ui/run.ts +489 -0
  54. package/plugin/src/ui/server.ts +684 -0
  55. package/plugin/src/validators.d.ts +13 -0
  56. package/plugin/src/validators.js +1 -0
  57. package/plugin/src/views.ts +839 -0
  58. package/bin/checkmate.js +0 -13
  59. package/dist/ai/client.d.ts +0 -64
  60. package/dist/ai/client.d.ts.map +0 -1
  61. package/dist/ai/client.js +0 -313
  62. package/dist/ai/client.js.map +0 -1
  63. package/dist/ai/message-handler.d.ts +0 -9
  64. package/dist/ai/message-handler.d.ts.map +0 -1
  65. package/dist/ai/message-handler.js +0 -50
  66. package/dist/ai/message-handler.js.map +0 -1
  67. package/dist/ai/message-history.d.ts +0 -17
  68. package/dist/ai/message-history.d.ts.map +0 -1
  69. package/dist/ai/message-history.js +0 -45
  70. package/dist/ai/message-history.js.map +0 -1
  71. package/dist/ai/prompts.d.ts +0 -4
  72. package/dist/ai/prompts.d.ts.map +0 -1
  73. package/dist/ai/prompts.js +0 -24
  74. package/dist/ai/prompts.js.map +0 -1
  75. package/dist/ai/rate-limit-policy.d.ts +0 -9
  76. package/dist/ai/rate-limit-policy.d.ts.map +0 -1
  77. package/dist/ai/rate-limit-policy.js +0 -34
  78. package/dist/ai/rate-limit-policy.js.map +0 -1
  79. package/dist/ai/tool-response-handler.d.ts +0 -16
  80. package/dist/ai/tool-response-handler.d.ts.map +0 -1
  81. package/dist/ai/tool-response-handler.js +0 -85
  82. package/dist/ai/tool-response-handler.js.map +0 -1
  83. package/dist/ai/turn-processor.d.ts +0 -34
  84. package/dist/ai/turn-processor.d.ts.map +0 -1
  85. package/dist/ai/turn-processor.js +0 -107
  86. package/dist/ai/turn-processor.js.map +0 -1
  87. package/dist/api/allocate-run-identity.d.ts +0 -8
  88. package/dist/api/allocate-run-identity.d.ts.map +0 -1
  89. package/dist/api/allocate-run-identity.js +0 -10
  90. package/dist/api/allocate-run-identity.js.map +0 -1
  91. package/dist/api/execute-prepared-run.d.ts +0 -22
  92. package/dist/api/execute-prepared-run.d.ts.map +0 -1
  93. package/dist/api/execute-prepared-run.js +0 -184
  94. package/dist/api/execute-prepared-run.js.map +0 -1
  95. package/dist/api/index.d.ts +0 -25
  96. package/dist/api/index.d.ts.map +0 -1
  97. package/dist/api/index.js +0 -69
  98. package/dist/api/index.js.map +0 -1
  99. package/dist/api/prepare-run.d.ts +0 -44
  100. package/dist/api/prepare-run.d.ts.map +0 -1
  101. package/dist/api/prepare-run.js +0 -261
  102. package/dist/api/prepare-run.js.map +0 -1
  103. package/dist/cli/diagnostic-relay.d.ts +0 -6
  104. package/dist/cli/diagnostic-relay.d.ts.map +0 -1
  105. package/dist/cli/diagnostic-relay.js +0 -6
  106. package/dist/cli/diagnostic-relay.js.map +0 -1
  107. package/dist/cli/main.d.ts +0 -21
  108. package/dist/cli/main.d.ts.map +0 -1
  109. package/dist/cli/main.js +0 -166
  110. package/dist/cli/main.js.map +0 -1
  111. package/dist/cli/protocol.d.ts +0 -57
  112. package/dist/cli/protocol.d.ts.map +0 -1
  113. package/dist/cli/protocol.js +0 -116
  114. package/dist/cli/protocol.js.map +0 -1
  115. package/dist/cli/reconcile-result.d.ts +0 -13
  116. package/dist/cli/reconcile-result.d.ts.map +0 -1
  117. package/dist/cli/reconcile-result.js +0 -300
  118. package/dist/cli/reconcile-result.js.map +0 -1
  119. package/dist/cli/run-parent.d.ts +0 -37
  120. package/dist/cli/run-parent.d.ts.map +0 -1
  121. package/dist/cli/run-parent.js +0 -491
  122. package/dist/cli/run-parent.js.map +0 -1
  123. package/dist/cli/signals.d.ts +0 -36
  124. package/dist/cli/signals.d.ts.map +0 -1
  125. package/dist/cli/signals.js +0 -85
  126. package/dist/cli/signals.js.map +0 -1
  127. package/dist/cli/static-commands.d.ts +0 -11
  128. package/dist/cli/static-commands.d.ts.map +0 -1
  129. package/dist/cli/static-commands.js +0 -83
  130. package/dist/cli/static-commands.js.map +0 -1
  131. package/dist/cli/worker-stream-guard.d.ts +0 -20
  132. package/dist/cli/worker-stream-guard.d.ts.map +0 -1
  133. package/dist/cli/worker-stream-guard.js +0 -41
  134. package/dist/cli/worker-stream-guard.js.map +0 -1
  135. package/dist/cli/worker.d.ts +0 -3
  136. package/dist/cli/worker.d.ts.map +0 -1
  137. package/dist/cli/worker.js +0 -111
  138. package/dist/cli/worker.js.map +0 -1
  139. package/dist/config/ingestion.d.ts +0 -58
  140. package/dist/config/ingestion.d.ts.map +0 -1
  141. package/dist/config/ingestion.js +0 -283
  142. package/dist/config/ingestion.js.map +0 -1
  143. package/dist/config/manifest.d.ts +0 -20
  144. package/dist/config/manifest.d.ts.map +0 -1
  145. package/dist/config/manifest.js +0 -91
  146. package/dist/config/manifest.js.map +0 -1
  147. package/dist/config/model-egress.d.ts +0 -10
  148. package/dist/config/model-egress.d.ts.map +0 -1
  149. package/dist/config/model-egress.js +0 -62
  150. package/dist/config/model-egress.js.map +0 -1
  151. package/dist/config/package-resolution.d.ts +0 -4
  152. package/dist/config/package-resolution.d.ts.map +0 -1
  153. package/dist/config/package-resolution.js +0 -24
  154. package/dist/config/package-resolution.js.map +0 -1
  155. package/dist/config/policy.d.ts +0 -44
  156. package/dist/config/policy.d.ts.map +0 -1
  157. package/dist/config/policy.js +0 -141
  158. package/dist/config/policy.js.map +0 -1
  159. package/dist/config/record.d.ts +0 -4
  160. package/dist/config/record.d.ts.map +0 -1
  161. package/dist/config/record.js +0 -10
  162. package/dist/config/record.js.map +0 -1
  163. package/dist/config/secrets.d.ts +0 -11
  164. package/dist/config/secrets.d.ts.map +0 -1
  165. package/dist/config/secrets.js +0 -42
  166. package/dist/config/secrets.js.map +0 -1
  167. package/dist/contracts/diagnostics.d.ts +0 -4
  168. package/dist/contracts/diagnostics.d.ts.map +0 -1
  169. package/dist/contracts/diagnostics.js +0 -31
  170. package/dist/contracts/diagnostics.js.map +0 -1
  171. package/dist/contracts/serialize.d.ts +0 -2
  172. package/dist/contracts/serialize.d.ts.map +0 -1
  173. package/dist/contracts/serialize.js +0 -90
  174. package/dist/contracts/serialize.js.map +0 -1
  175. package/dist/contracts/types.d.ts +0 -316
  176. package/dist/contracts/types.d.ts.map +0 -1
  177. package/dist/contracts/types.js +0 -74
  178. package/dist/contracts/types.js.map +0 -1
  179. package/dist/contracts/validator.d.ts +0 -8
  180. package/dist/contracts/validator.d.ts.map +0 -1
  181. package/dist/contracts/validator.js +0 -71
  182. package/dist/contracts/validator.js.map +0 -1
  183. package/dist/driver.d.ts +0 -97
  184. package/dist/driver.d.ts.map +0 -1
  185. package/dist/driver.js +0 -24
  186. package/dist/driver.js.map +0 -1
  187. package/dist/drivers/descriptor.d.ts +0 -15
  188. package/dist/drivers/descriptor.d.ts.map +0 -1
  189. package/dist/drivers/descriptor.js +0 -122
  190. package/dist/drivers/descriptor.js.map +0 -1
  191. package/dist/drivers/loader.d.ts +0 -18
  192. package/dist/drivers/loader.d.ts.map +0 -1
  193. package/dist/drivers/loader.js +0 -97
  194. package/dist/drivers/loader.js.map +0 -1
  195. package/dist/drivers/web/checkmate-driver.json +0 -47
  196. package/dist/drivers/web/index.d.ts +0 -6
  197. package/dist/drivers/web/index.d.ts.map +0 -1
  198. package/dist/drivers/web/index.js +0 -27
  199. package/dist/drivers/web/index.js.map +0 -1
  200. package/dist/drivers/web/session.d.ts +0 -25
  201. package/dist/drivers/web/session.d.ts.map +0 -1
  202. package/dist/drivers/web/session.js +0 -132
  203. package/dist/drivers/web/session.js.map +0 -1
  204. package/dist/drivers/web/tools/network-request-recorder.d.ts +0 -46
  205. package/dist/drivers/web/tools/network-request-recorder.d.ts.map +0 -1
  206. package/dist/drivers/web/tools/network-request-recorder.js +0 -164
  207. package/dist/drivers/web/tools/network-request-recorder.js.map +0 -1
  208. package/dist/drivers/web/tools/screenshot-service.d.ts +0 -10
  209. package/dist/drivers/web/tools/screenshot-service.d.ts.map +0 -1
  210. package/dist/drivers/web/tools/screenshot-service.js +0 -23
  211. package/dist/drivers/web/tools/screenshot-service.js.map +0 -1
  212. package/dist/drivers/web/tools/snapshot-filter/index.d.ts +0 -4
  213. package/dist/drivers/web/tools/snapshot-filter/index.d.ts.map +0 -1
  214. package/dist/drivers/web/tools/snapshot-filter/index.js +0 -4
  215. package/dist/drivers/web/tools/snapshot-filter/index.js.map +0 -1
  216. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts +0 -15
  217. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.d.ts.map +0 -1
  218. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js +0 -99
  219. package/dist/drivers/web/tools/snapshot-filter/semantic-scorer.js.map +0 -1
  220. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts +0 -5
  221. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.d.ts.map +0 -1
  222. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js +0 -56
  223. package/dist/drivers/web/tools/snapshot-filter/snapshot-filter.js.map +0 -1
  224. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts +0 -3
  225. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.d.ts.map +0 -1
  226. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js +0 -85
  227. package/dist/drivers/web/tools/snapshot-filter/tree-reconstructor.js.map +0 -1
  228. package/dist/drivers/web/tools/snapshot-service.d.ts +0 -31
  229. package/dist/drivers/web/tools/snapshot-service.d.ts.map +0 -1
  230. package/dist/drivers/web/tools/snapshot-service.js +0 -96
  231. package/dist/drivers/web/tools/snapshot-service.js.map +0 -1
  232. package/dist/drivers/web/tools/tool.d.ts +0 -76
  233. package/dist/drivers/web/tools/tool.d.ts.map +0 -1
  234. package/dist/drivers/web/tools/tool.js +0 -562
  235. package/dist/drivers/web/tools/tool.js.map +0 -1
  236. package/dist/drivers/web/tools/transient-state-tracker.d.ts +0 -26
  237. package/dist/drivers/web/tools/transient-state-tracker.d.ts.map +0 -1
  238. package/dist/drivers/web/tools/transient-state-tracker.js +0 -301
  239. package/dist/drivers/web/tools/transient-state-tracker.js.map +0 -1
  240. package/dist/drivers/web/tools/types.d.ts +0 -11
  241. package/dist/drivers/web/tools/types.d.ts.map +0 -1
  242. package/dist/drivers/web/tools/types.js +0 -2
  243. package/dist/drivers/web/tools/types.js.map +0 -1
  244. package/dist/evidence/atomic-file.d.ts +0 -23
  245. package/dist/evidence/atomic-file.d.ts.map +0 -1
  246. package/dist/evidence/atomic-file.js +0 -104
  247. package/dist/evidence/atomic-file.js.map +0 -1
  248. package/dist/evidence/layout.d.ts +0 -30
  249. package/dist/evidence/layout.d.ts.map +0 -1
  250. package/dist/evidence/layout.js +0 -152
  251. package/dist/evidence/layout.js.map +0 -1
  252. package/dist/evidence/retention.d.ts +0 -5
  253. package/dist/evidence/retention.d.ts.map +0 -1
  254. package/dist/evidence/retention.js +0 -10
  255. package/dist/evidence/retention.js.map +0 -1
  256. package/dist/evidence/store.d.ts +0 -101
  257. package/dist/evidence/store.d.ts.map +0 -1
  258. package/dist/evidence/store.js +0 -375
  259. package/dist/evidence/store.js.map +0 -1
  260. package/dist/evidence/terminal-finalizer.d.ts +0 -19
  261. package/dist/evidence/terminal-finalizer.d.ts.map +0 -1
  262. package/dist/evidence/terminal-finalizer.js +0 -56
  263. package/dist/evidence/terminal-finalizer.js.map +0 -1
  264. package/dist/index.d.ts +0 -9
  265. package/dist/index.d.ts.map +0 -1
  266. package/dist/index.js +0 -12
  267. package/dist/index.js.map +0 -1
  268. package/dist/logging/invocation-logger.d.ts +0 -4
  269. package/dist/logging/invocation-logger.d.ts.map +0 -1
  270. package/dist/logging/invocation-logger.js +0 -25
  271. package/dist/logging/invocation-logger.js.map +0 -1
  272. package/dist/logging/level-logger.d.ts +0 -11
  273. package/dist/logging/level-logger.d.ts.map +0 -1
  274. package/dist/logging/level-logger.js +0 -82
  275. package/dist/logging/level-logger.js.map +0 -1
  276. package/dist/logging/types.d.ts +0 -8
  277. package/dist/logging/types.d.ts.map +0 -1
  278. package/dist/logging/types.js +0 -7
  279. package/dist/logging/types.js.map +0 -1
  280. package/dist/redaction/diagnostic-sanitizer.d.ts +0 -7
  281. package/dist/redaction/diagnostic-sanitizer.d.ts.map +0 -1
  282. package/dist/redaction/diagnostic-sanitizer.js +0 -42
  283. package/dist/redaction/diagnostic-sanitizer.js.map +0 -1
  284. package/dist/redaction/redactor.d.ts +0 -40
  285. package/dist/redaction/redactor.d.ts.map +0 -1
  286. package/dist/redaction/redactor.js +0 -176
  287. package/dist/redaction/redactor.js.map +0 -1
  288. package/dist/redaction/scrub.d.ts +0 -29
  289. package/dist/redaction/scrub.d.ts.map +0 -1
  290. package/dist/redaction/scrub.js +0 -54
  291. package/dist/redaction/scrub.js.map +0 -1
  292. package/dist/runtime/config.d.ts +0 -16
  293. package/dist/runtime/config.d.ts.map +0 -1
  294. package/dist/runtime/config.js +0 -2
  295. package/dist/runtime/config.js.map +0 -1
  296. package/dist/runtime/driver-boundary.d.ts +0 -16
  297. package/dist/runtime/driver-boundary.d.ts.map +0 -1
  298. package/dist/runtime/driver-boundary.js +0 -71
  299. package/dist/runtime/driver-boundary.js.map +0 -1
  300. package/dist/runtime/driver-session.d.ts +0 -9
  301. package/dist/runtime/driver-session.d.ts.map +0 -1
  302. package/dist/runtime/driver-session.js +0 -64
  303. package/dist/runtime/driver-session.js.map +0 -1
  304. package/dist/runtime/internal-step-evidence.d.ts +0 -30
  305. package/dist/runtime/internal-step-evidence.d.ts.map +0 -1
  306. package/dist/runtime/internal-step-evidence.js +0 -82
  307. package/dist/runtime/internal-step-evidence.js.map +0 -1
  308. package/dist/runtime/result-adapter.d.ts +0 -9
  309. package/dist/runtime/result-adapter.d.ts.map +0 -1
  310. package/dist/runtime/result-adapter.js +0 -77
  311. package/dist/runtime/result-adapter.js.map +0 -1
  312. package/dist/runtime/runner.d.ts +0 -43
  313. package/dist/runtime/runner.d.ts.map +0 -1
  314. package/dist/runtime/runner.js +0 -72
  315. package/dist/runtime/runner.js.map +0 -1
  316. package/dist/runtime/scenario-control.d.ts +0 -40
  317. package/dist/runtime/scenario-control.d.ts.map +0 -1
  318. package/dist/runtime/scenario-control.js +0 -94
  319. package/dist/runtime/scenario-control.js.map +0 -1
  320. package/dist/runtime/scenario-runner.d.ts +0 -41
  321. package/dist/runtime/scenario-runner.d.ts.map +0 -1
  322. package/dist/runtime/scenario-runner.js +0 -274
  323. package/dist/runtime/scenario-runner.js.map +0 -1
  324. package/dist/runtime/scenario-state.d.ts +0 -55
  325. package/dist/runtime/scenario-state.d.ts.map +0 -1
  326. package/dist/runtime/scenario-state.js +0 -128
  327. package/dist/runtime/scenario-state.js.map +0 -1
  328. package/dist/runtime/step-execution.d.ts +0 -27
  329. package/dist/runtime/step-execution.d.ts.map +0 -1
  330. package/dist/runtime/step-execution.js +0 -143
  331. package/dist/runtime/step-execution.js.map +0 -1
  332. package/dist/runtime/text.d.ts +0 -10
  333. package/dist/runtime/text.d.ts.map +0 -1
  334. package/dist/runtime/text.js +0 -25
  335. package/dist/runtime/text.js.map +0 -1
  336. package/dist/runtime/types.d.ts +0 -53
  337. package/dist/runtime/types.d.ts.map +0 -1
  338. package/dist/runtime/types.js +0 -2
  339. package/dist/runtime/types.js.map +0 -1
  340. package/dist/runtime/usage-tracker.d.ts +0 -37
  341. package/dist/runtime/usage-tracker.d.ts.map +0 -1
  342. package/dist/runtime/usage-tracker.js +0 -110
  343. package/dist/runtime/usage-tracker.js.map +0 -1
  344. package/dist/tools/define-agent-tool.d.ts +0 -20
  345. package/dist/tools/define-agent-tool.d.ts.map +0 -1
  346. package/dist/tools/define-agent-tool.js +0 -30
  347. package/dist/tools/define-agent-tool.js.map +0 -1
  348. package/dist/tools/dispatcher.d.ts +0 -19
  349. package/dist/tools/dispatcher.d.ts.map +0 -1
  350. package/dist/tools/dispatcher.js +0 -91
  351. package/dist/tools/dispatcher.js.map +0 -1
  352. package/dist/tools/loop-detector.d.ts +0 -27
  353. package/dist/tools/loop-detector.d.ts.map +0 -1
  354. package/dist/tools/loop-detector.js +0 -76
  355. package/dist/tools/loop-detector.js.map +0 -1
  356. package/dist/tools/registry.d.ts +0 -19
  357. package/dist/tools/registry.d.ts.map +0 -1
  358. package/dist/tools/registry.js +0 -54
  359. package/dist/tools/registry.js.map +0 -1
  360. package/dist/tools/step/result-tool.d.ts +0 -7
  361. package/dist/tools/step/result-tool.d.ts.map +0 -1
  362. package/dist/tools/step/result-tool.js +0 -34
  363. package/dist/tools/step/result-tool.js.map +0 -1
  364. package/dist/tools/tool-contract.d.ts +0 -3
  365. package/dist/tools/tool-contract.d.ts.map +0 -1
  366. package/dist/tools/tool-contract.js +0 -2
  367. package/dist/tools/tool-contract.js.map +0 -1
  368. package/dist/tools/types.d.ts +0 -210
  369. package/dist/tools/types.d.ts.map +0 -1
  370. package/dist/tools/types.js +0 -4
  371. package/dist/tools/types.js.map +0 -1
  372. package/docs/CLI.md +0 -59
  373. package/docs/CONFIGURATION.md +0 -105
  374. package/docs/DRIVERS.md +0 -79
  375. package/docs/EVIDENCE.md +0 -64
  376. package/schemas/checkmate-config.v1.json +0 -176
  377. package/schemas/describe-result.v1.json +0 -414
  378. package/schemas/driver-descriptor.v1.json +0 -66
  379. package/schemas/run-request.v1.json +0 -67
  380. package/schemas/run-result.v1.json +0 -333
  381. 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'