project-tiny-context-harness 0.2.84 → 0.6.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 (361) hide show
  1. package/README.md +163 -428
  2. package/assets/README.md +283 -455
  3. package/assets/README.zh-CN.md +199 -123
  4. package/assets/agents/AGENTS_CORE.md +54 -67
  5. package/assets/context_templates/context.toml +3 -0
  6. package/assets/context_templates/global.md +6 -6
  7. package/assets/github/harness.yml +2 -2
  8. package/assets/skills/context_development_engineer/SKILL.md +91 -107
  9. package/assets/skills/context_product_plan/SKILL.md +18 -28
  10. package/assets/skills/context_surface_contract/SKILL.md +35 -38
  11. package/assets/skills/context_uiux_design/SKILL.md +31 -30
  12. package/assets/skills/long-task-workflow/SKILL.md +76 -0
  13. package/assets/skills/long-task-workflow/agents/openai.yaml +4 -0
  14. package/assets/skills/long-task-workflow/references/authority-lifecycle.md +41 -0
  15. package/assets/skills/long-task-workflow/references/contract-authoring.md +62 -0
  16. package/assets/skills/long-task-workflow/references/evidence-design.md +45 -0
  17. package/assets/skills/normal-long-task/SKILL.md +12 -489
  18. package/assets/skills/source-plan-authoring/SKILL.md +379 -0
  19. package/assets/tools/validate_context.py +293 -127
  20. package/dist/cli.js +3 -1
  21. package/dist/commands/check-modularity.js +33 -10
  22. package/dist/commands/composite-campaign.d.ts +1 -0
  23. package/dist/commands/composite-campaign.js +8 -0
  24. package/dist/commands/composite-long-task.d.ts +1 -6
  25. package/dist/commands/composite-long-task.js +7 -157
  26. package/dist/commands/delivery-set.d.ts +1 -0
  27. package/dist/commands/delivery-set.js +8 -0
  28. package/dist/commands/disable.d.ts +1 -0
  29. package/dist/commands/disable.js +15 -0
  30. package/dist/commands/enable.d.ts +1 -0
  31. package/dist/commands/enable.js +14 -0
  32. package/dist/commands/export-context-args.js +13 -4
  33. package/dist/commands/export-context.js +18 -7
  34. package/dist/commands/index.js +42 -30
  35. package/dist/commands/init.js +12 -6
  36. package/dist/commands/long-task-authoring.d.ts +3 -0
  37. package/dist/commands/long-task-authoring.js +92 -0
  38. package/dist/commands/long-task-explain.d.ts +1 -0
  39. package/dist/commands/long-task-explain.js +52 -0
  40. package/dist/commands/long-task.d.ts +1 -0
  41. package/dist/commands/long-task.js +226 -0
  42. package/dist/commands/package-source.js +2 -2
  43. package/dist/commands/upgrade.js +10 -10
  44. package/dist/index.d.ts +11 -1
  45. package/dist/index.js +8 -0
  46. package/dist/lib/config.js +34 -8
  47. package/dist/lib/context-default-footprint.d.ts +16 -0
  48. package/dist/lib/context-default-footprint.js +107 -0
  49. package/dist/lib/context-export.js +105 -41
  50. package/dist/lib/context-graph-snapshot.d.ts +18 -0
  51. package/dist/lib/context-graph-snapshot.js +171 -0
  52. package/dist/lib/context-manifest-schema.d.ts +28 -0
  53. package/dist/lib/context-manifest-schema.js +150 -0
  54. package/dist/lib/context-manifest.js +28 -20
  55. package/dist/lib/context-templates.js +5 -5
  56. package/dist/lib/design-md.js +1 -1
  57. package/dist/lib/doctor.js +54 -1
  58. package/dist/lib/harness-root.js +25 -8
  59. package/dist/lib/init.js +6 -3
  60. package/dist/lib/legacy-managed-scan.js +23 -7
  61. package/dist/lib/legacy-sdlc-migration.js +21 -11
  62. package/dist/lib/long-task-acceptance-reference.d.ts +22 -0
  63. package/dist/lib/long-task-acceptance-reference.js +46 -0
  64. package/dist/lib/long-task-acceptance-shape.d.ts +5 -0
  65. package/dist/lib/long-task-acceptance-shape.js +131 -0
  66. package/dist/lib/long-task-activation-validation.d.ts +21 -0
  67. package/dist/lib/long-task-activation-validation.js +136 -0
  68. package/dist/lib/long-task-artifacts.d.ts +5 -0
  69. package/dist/lib/long-task-artifacts.js +34 -0
  70. package/dist/lib/long-task-assertions-v2.d.ts +22 -0
  71. package/dist/lib/long-task-assertions-v2.js +212 -0
  72. package/dist/lib/long-task-authoring-authority-preview.d.ts +5 -0
  73. package/dist/lib/long-task-authoring-authority-preview.js +85 -0
  74. package/dist/lib/long-task-authoring-preflight-diagnostics.d.ts +8 -0
  75. package/dist/lib/long-task-authoring-preflight-diagnostics.js +179 -0
  76. package/dist/lib/long-task-authoring-preflight-repair-order.d.ts +8 -0
  77. package/dist/lib/long-task-authoring-preflight-repair-order.js +95 -0
  78. package/dist/lib/long-task-authoring-preflight-types.d.ts +46 -0
  79. package/dist/lib/long-task-authoring-preflight-types.js +38 -0
  80. package/dist/lib/long-task-authoring-preflight.d.ts +3 -0
  81. package/dist/lib/long-task-authoring-preflight.js +44 -0
  82. package/dist/lib/long-task-authority-material-diff.d.ts +17 -0
  83. package/dist/lib/long-task-authority-material-diff.js +152 -0
  84. package/dist/lib/long-task-authority-materials.d.ts +7 -0
  85. package/dist/lib/long-task-authority-materials.js +83 -0
  86. package/dist/lib/long-task-authority-policy.d.ts +168 -0
  87. package/dist/lib/long-task-authority-policy.js +181 -0
  88. package/dist/lib/long-task-authority-revision-details.d.ts +19 -0
  89. package/dist/lib/long-task-authority-revision-details.js +192 -0
  90. package/dist/lib/long-task-authority-revision-enforcement.d.ts +3 -0
  91. package/dist/lib/long-task-authority-revision-enforcement.js +41 -0
  92. package/dist/lib/long-task-authority-revision-types.d.ts +50 -0
  93. package/dist/lib/long-task-authority-revision-types.js +1 -0
  94. package/dist/lib/long-task-authority-revision.d.ts +4 -0
  95. package/dist/lib/long-task-authority-revision.js +188 -0
  96. package/dist/lib/long-task-authority-transition-policy.d.ts +62 -0
  97. package/dist/lib/long-task-authority-transition-policy.js +62 -0
  98. package/dist/lib/long-task-authority-types.d.ts +96 -0
  99. package/dist/lib/long-task-authority-types.js +1 -0
  100. package/dist/lib/long-task-authority.d.ts +7 -0
  101. package/dist/lib/long-task-authority.js +142 -0
  102. package/dist/lib/long-task-boundary-check.d.ts +15 -0
  103. package/dist/lib/long-task-boundary-check.js +9 -0
  104. package/dist/lib/long-task-check-evidence-decoder.d.ts +3 -0
  105. package/dist/lib/long-task-check-evidence-decoder.js +74 -0
  106. package/dist/lib/long-task-check-execution-policy.d.ts +18 -0
  107. package/dist/lib/long-task-check-execution-policy.js +36 -0
  108. package/dist/lib/long-task-check-runner.d.ts +2 -0
  109. package/dist/lib/long-task-check-runner.js +181 -0
  110. package/dist/lib/long-task-check-shape.d.ts +2 -0
  111. package/dist/lib/long-task-check-shape.js +136 -0
  112. package/dist/lib/long-task-claim-definitions.d.ts +7 -0
  113. package/dist/lib/long-task-claim-definitions.js +78 -0
  114. package/dist/lib/long-task-claim-proof-policy.d.ts +4 -0
  115. package/dist/lib/long-task-claim-proof-policy.js +57 -0
  116. package/dist/lib/long-task-claims.d.ts +10 -0
  117. package/dist/lib/long-task-claims.js +187 -0
  118. package/dist/lib/long-task-context-authority-topology.d.ts +7 -0
  119. package/dist/lib/long-task-context-authority-topology.js +37 -0
  120. package/dist/lib/long-task-context-authority.d.ts +14 -0
  121. package/dist/lib/long-task-context-authority.js +66 -0
  122. package/dist/lib/long-task-contract-types.d.ts +203 -0
  123. package/dist/lib/long-task-contract-types.js +1 -0
  124. package/dist/lib/long-task-counterfactual-claim-policy.d.ts +10 -0
  125. package/dist/lib/long-task-counterfactual-claim-policy.js +57 -0
  126. package/dist/lib/long-task-counterfactual-sandbox.d.ts +6 -0
  127. package/dist/lib/long-task-counterfactual-sandbox.js +87 -0
  128. package/dist/lib/long-task-counterfactual-types.d.ts +24 -0
  129. package/dist/lib/long-task-counterfactual-types.js +1 -0
  130. package/dist/lib/long-task-delivery-compiler.d.ts +10 -0
  131. package/dist/lib/long-task-delivery-compiler.js +129 -0
  132. package/dist/lib/long-task-delivery-parser.d.ts +13 -0
  133. package/dist/lib/long-task-delivery-parser.js +90 -0
  134. package/dist/lib/long-task-delivery-preflight.d.ts +5 -0
  135. package/dist/lib/long-task-delivery-preflight.js +151 -0
  136. package/dist/lib/long-task-delivery-shape.d.ts +5 -0
  137. package/dist/lib/long-task-delivery-shape.js +5 -0
  138. package/dist/lib/long-task-delivery-types.d.ts +8 -0
  139. package/dist/lib/long-task-delivery-types.js +8 -0
  140. package/dist/lib/long-task-delivery-validation.d.ts +3 -0
  141. package/dist/lib/long-task-delivery-validation.js +175 -0
  142. package/dist/lib/long-task-evidence-adapter-policy.d.ts +4 -0
  143. package/dist/lib/long-task-evidence-adapter-policy.js +15 -0
  144. package/dist/lib/long-task-evidence-adapter-types.d.ts +1 -0
  145. package/dist/lib/long-task-evidence-adapter-types.js +1 -0
  146. package/dist/lib/long-task-evidence-findings.d.ts +5 -0
  147. package/dist/lib/long-task-evidence-findings.js +113 -0
  148. package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +4 -0
  149. package/dist/lib/long-task-evidence-sensitivity-policy.js +98 -0
  150. package/dist/lib/long-task-evidence-v2.d.ts +5 -0
  151. package/dist/lib/long-task-evidence-v2.js +226 -0
  152. package/dist/lib/long-task-explain-acceptance-link.d.ts +46 -0
  153. package/dist/lib/long-task-explain-acceptance-link.js +96 -0
  154. package/dist/lib/long-task-explain-claim-links.d.ts +45 -0
  155. package/dist/lib/long-task-explain-claim-links.js +88 -0
  156. package/dist/lib/long-task-explain-source-links.d.ts +93 -0
  157. package/dist/lib/long-task-explain-source-links.js +51 -0
  158. package/dist/lib/long-task-final-v2.d.ts +2 -0
  159. package/dist/lib/long-task-final-v2.js +124 -0
  160. package/dist/lib/long-task-finding-context.d.ts +3 -0
  161. package/dist/lib/long-task-finding-context.js +63 -0
  162. package/dist/lib/long-task-freshness.d.ts +3 -0
  163. package/dist/lib/long-task-freshness.js +80 -0
  164. package/dist/lib/long-task-hook-install.d.ts +9 -0
  165. package/dist/lib/long-task-hook-install.js +184 -0
  166. package/dist/lib/long-task-hook-preflight.d.ts +7 -0
  167. package/dist/lib/long-task-hook-preflight.js +58 -0
  168. package/dist/lib/long-task-observation-ownership.d.ts +2 -0
  169. package/dist/lib/long-task-observation-ownership.js +22 -0
  170. package/dist/lib/long-task-outcome-parser.d.ts +4 -0
  171. package/dist/lib/long-task-outcome-parser.js +100 -0
  172. package/dist/lib/long-task-paths.d.ts +49 -0
  173. package/dist/lib/long-task-paths.js +418 -0
  174. package/dist/lib/long-task-playwright-counterfactual-policy.d.ts +7 -0
  175. package/dist/lib/long-task-playwright-counterfactual-policy.js +125 -0
  176. package/dist/lib/long-task-playwright-evidence.d.ts +6 -0
  177. package/dist/lib/long-task-playwright-evidence.js +244 -0
  178. package/dist/lib/long-task-product-shape.d.ts +6 -0
  179. package/dist/lib/long-task-product-shape.js +73 -0
  180. package/dist/lib/long-task-progress.d.ts +4 -0
  181. package/dist/lib/long-task-progress.js +114 -0
  182. package/dist/lib/long-task-protected-files.d.ts +1 -0
  183. package/dist/lib/long-task-protected-files.js +30 -0
  184. package/dist/lib/long-task-required-proof-surfaces.d.ts +2 -0
  185. package/dist/lib/long-task-required-proof-surfaces.js +13 -0
  186. package/dist/lib/long-task-requirement-shape.d.ts +2 -0
  187. package/dist/lib/long-task-requirement-shape.js +18 -0
  188. package/dist/lib/long-task-risk-surfaces.d.ts +2 -0
  189. package/dist/lib/long-task-risk-surfaces.js +60 -0
  190. package/dist/lib/long-task-risk-types.d.ts +5 -0
  191. package/dist/lib/long-task-risk-types.js +12 -0
  192. package/dist/lib/long-task-risk.d.ts +9 -0
  193. package/dist/lib/long-task-risk.js +132 -0
  194. package/dist/lib/long-task-root-shape.d.ts +4 -0
  195. package/dist/lib/long-task-root-shape.js +86 -0
  196. package/dist/lib/long-task-runner-environment.d.ts +7 -0
  197. package/dist/lib/long-task-runner-environment.js +57 -0
  198. package/dist/lib/long-task-runner-files.d.ts +3 -0
  199. package/dist/lib/long-task-runner-files.js +39 -0
  200. package/dist/lib/long-task-runner-freeze.d.ts +2 -0
  201. package/dist/lib/long-task-runner-freeze.js +168 -0
  202. package/dist/lib/long-task-runtime-types.d.ts +214 -0
  203. package/dist/lib/long-task-runtime-types.js +1 -0
  204. package/dist/lib/long-task-shape-primitives.d.ts +17 -0
  205. package/dist/lib/long-task-shape-primitives.js +81 -0
  206. package/dist/lib/long-task-source-authority-types.d.ts +13 -0
  207. package/dist/lib/long-task-source-authority-types.js +1 -0
  208. package/dist/lib/long-task-source-claim-validation.d.ts +5 -0
  209. package/dist/lib/long-task-source-claim-validation.js +96 -0
  210. package/dist/lib/long-task-source-continuity.d.ts +4 -0
  211. package/dist/lib/long-task-source-continuity.js +57 -0
  212. package/dist/lib/long-task-source-inventory.d.ts +2 -0
  213. package/dist/lib/long-task-source-inventory.js +21 -0
  214. package/dist/lib/long-task-source-item-parser.d.ts +3 -0
  215. package/dist/lib/long-task-source-item-parser.js +112 -0
  216. package/dist/lib/long-task-source-shape.d.ts +2 -0
  217. package/dist/lib/long-task-source-shape.js +56 -0
  218. package/dist/lib/long-task-source-target-continuity.d.ts +4 -0
  219. package/dist/lib/long-task-source-target-continuity.js +80 -0
  220. package/dist/lib/long-task-source-target-index.d.ts +12 -0
  221. package/dist/lib/long-task-source-target-index.js +76 -0
  222. package/dist/lib/long-task-source-validation.d.ts +3 -0
  223. package/dist/lib/long-task-source-validation.js +46 -0
  224. package/dist/lib/long-task-state.d.ts +91 -0
  225. package/dist/lib/long-task-state.js +611 -0
  226. package/dist/lib/long-task-status-projection.d.ts +21 -0
  227. package/dist/lib/long-task-status-projection.js +116 -0
  228. package/dist/lib/long-task-status-v2.d.ts +37 -0
  229. package/dist/lib/long-task-status-v2.js +306 -0
  230. package/dist/lib/long-task-technical-shape.d.ts +3 -0
  231. package/dist/lib/long-task-technical-shape.js +44 -0
  232. package/dist/lib/long-task-verifier-authority.d.ts +12 -0
  233. package/dist/lib/long-task-verifier-authority.js +47 -0
  234. package/dist/lib/long-task-verifier-identity.d.ts +2 -0
  235. package/dist/lib/long-task-verifier-identity.js +55 -0
  236. package/dist/lib/long-task-verifier-v2.d.ts +13 -0
  237. package/dist/lib/long-task-verifier-v2.js +266 -0
  238. package/dist/lib/long-task-workspace-runtime-types.d.ts +23 -0
  239. package/dist/lib/long-task-workspace-runtime-types.js +1 -0
  240. package/dist/lib/long-task-workspace.d.ts +25 -0
  241. package/dist/lib/long-task-workspace.js +366 -0
  242. package/dist/lib/managed-file.js +20 -5
  243. package/dist/lib/migrations.js +156 -32
  244. package/dist/lib/modularity.d.ts +27 -1
  245. package/dist/lib/modularity.js +499 -23
  246. package/dist/lib/package-json-config.js +14 -5
  247. package/dist/lib/package-source.js +15 -3
  248. package/dist/lib/profiles.d.ts +13 -0
  249. package/dist/lib/profiles.js +66 -0
  250. package/dist/lib/schema-guard.js +4 -2
  251. package/dist/lib/source-files.js +14 -7
  252. package/dist/lib/source-pack-classify.js +91 -19
  253. package/dist/lib/source-pack-config.js +25 -8
  254. package/dist/lib/source-pack-export.js +84 -25
  255. package/dist/lib/source-pack-manifest.js +18 -6
  256. package/dist/lib/source-pack-records.js +35 -11
  257. package/dist/lib/source-pack-render.js +47 -18
  258. package/dist/lib/stable-json.d.ts +2 -0
  259. package/dist/lib/stable-json.js +21 -0
  260. package/dist/lib/strict-codec.d.ts +4 -0
  261. package/dist/lib/strict-codec.js +65 -0
  262. package/dist/lib/sync-engine.js +76 -24
  263. package/dist/lib/types.d.ts +8 -1
  264. package/dist/lib/upgrade.js +4 -3
  265. package/dist/lib/validators.js +218 -191
  266. package/dist/long-task-hook.d.ts +2 -0
  267. package/dist/long-task-hook.js +55 -0
  268. package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +340 -0
  269. package/dist/schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json +18 -0
  270. package/migrations/README.md +8 -3
  271. package/package.json +17 -6
  272. package/source-mappings.yaml +0 -3
  273. package/assets/protected-harness-baseline.json +0 -20
  274. package/assets/skills/composite-long-task-workflow/SKILL.md +0 -244
  275. package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -57
  276. package/assets/skills/composite-long-task-workflow/assets/goal-objective.template.md +0 -17
  277. package/assets/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md +0 -675
  278. package/dist/commands/superpowers.d.ts +0 -1
  279. package/dist/commands/superpowers.js +0 -8
  280. package/dist/lib/composite-long-task-renderer.d.ts +0 -12
  281. package/dist/lib/composite-long-task-renderer.js +0 -109
  282. package/dist/lib/plan-acceptance-artifacts.d.ts +0 -1
  283. package/dist/lib/plan-acceptance-artifacts.js +0 -220
  284. package/dist/lib/plan-acceptance-evidence.d.ts +0 -2
  285. package/dist/lib/plan-acceptance-evidence.js +0 -108
  286. package/dist/lib/plan-acceptance-json.d.ts +0 -15
  287. package/dist/lib/plan-acceptance-json.js +0 -133
  288. package/dist/lib/plan-acceptance-validator.d.ts +0 -2
  289. package/dist/lib/plan-acceptance-validator.js +0 -209
  290. package/dist/lib/plan-contract-validator.d.ts +0 -2
  291. package/dist/lib/plan-contract-validator.js +0 -127
  292. package/dist/lib/plan-validator-common.d.ts +0 -24
  293. package/dist/lib/plan-validator-common.js +0 -196
  294. package/dist/lib/superpowers-task-ac010.d.ts +0 -6
  295. package/dist/lib/superpowers-task-ac010.js +0 -26
  296. package/dist/lib/superpowers-task-assertion-normalizers.d.ts +0 -3
  297. package/dist/lib/superpowers-task-assertion-normalizers.js +0 -74
  298. package/dist/lib/superpowers-task-assertions.d.ts +0 -20
  299. package/dist/lib/superpowers-task-assertions.js +0 -257
  300. package/dist/lib/superpowers-task-attempt.d.ts +0 -4
  301. package/dist/lib/superpowers-task-attempt.js +0 -102
  302. package/dist/lib/superpowers-task-command-run-correlation.d.ts +0 -8
  303. package/dist/lib/superpowers-task-command-run-correlation.js +0 -103
  304. package/dist/lib/superpowers-task-command-specs.d.ts +0 -3
  305. package/dist/lib/superpowers-task-command-specs.js +0 -52
  306. package/dist/lib/superpowers-task-compile-diagnostics.d.ts +0 -5
  307. package/dist/lib/superpowers-task-compile-diagnostics.js +0 -20
  308. package/dist/lib/superpowers-task-compile-guards.d.ts +0 -2
  309. package/dist/lib/superpowers-task-compile-guards.js +0 -66
  310. package/dist/lib/superpowers-task-compile.d.ts +0 -6
  311. package/dist/lib/superpowers-task-compile.js +0 -133
  312. package/dist/lib/superpowers-task-completion-output.d.ts +0 -52
  313. package/dist/lib/superpowers-task-completion-output.js +0 -228
  314. package/dist/lib/superpowers-task-conformance.d.ts +0 -2
  315. package/dist/lib/superpowers-task-conformance.js +0 -24
  316. package/dist/lib/superpowers-task-contradictions.d.ts +0 -6
  317. package/dist/lib/superpowers-task-contradictions.js +0 -126
  318. package/dist/lib/superpowers-task-current-evidence.d.ts +0 -3
  319. package/dist/lib/superpowers-task-current-evidence.js +0 -176
  320. package/dist/lib/superpowers-task-delivery.d.ts +0 -4
  321. package/dist/lib/superpowers-task-delivery.js +0 -96
  322. package/dist/lib/superpowers-task-derive.d.ts +0 -14
  323. package/dist/lib/superpowers-task-derive.js +0 -382
  324. package/dist/lib/superpowers-task-events.d.ts +0 -1
  325. package/dist/lib/superpowers-task-events.js +0 -13
  326. package/dist/lib/superpowers-task-evidence-kernel.d.ts +0 -19
  327. package/dist/lib/superpowers-task-evidence-kernel.js +0 -347
  328. package/dist/lib/superpowers-task-evidence-records.d.ts +0 -2
  329. package/dist/lib/superpowers-task-evidence-records.js +0 -55
  330. package/dist/lib/superpowers-task-evidence.d.ts +0 -10
  331. package/dist/lib/superpowers-task-evidence.js +0 -147
  332. package/dist/lib/superpowers-task-fields.d.ts +0 -22
  333. package/dist/lib/superpowers-task-fields.js +0 -276
  334. package/dist/lib/superpowers-task-final-card.d.ts +0 -3
  335. package/dist/lib/superpowers-task-final-card.js +0 -24
  336. package/dist/lib/superpowers-task-gates.d.ts +0 -12
  337. package/dist/lib/superpowers-task-gates.js +0 -155
  338. package/dist/lib/superpowers-task-harness-drift.d.ts +0 -11
  339. package/dist/lib/superpowers-task-harness-drift.js +0 -90
  340. package/dist/lib/superpowers-task-next-slices.d.ts +0 -1
  341. package/dist/lib/superpowers-task-next-slices.js +0 -12
  342. package/dist/lib/superpowers-task-protected-baseline.d.ts +0 -10
  343. package/dist/lib/superpowers-task-protected-baseline.js +0 -66
  344. package/dist/lib/superpowers-task-source-compile.d.ts +0 -5
  345. package/dist/lib/superpowers-task-source-compile.js +0 -226
  346. package/dist/lib/superpowers-task-source-parser.d.ts +0 -23
  347. package/dist/lib/superpowers-task-source-parser.js +0 -218
  348. package/dist/lib/superpowers-task-state-schema.d.ts +0 -440
  349. package/dist/lib/superpowers-task-state-schema.js +0 -66
  350. package/dist/lib/superpowers-task-state-shape.d.ts +0 -3
  351. package/dist/lib/superpowers-task-state-shape.js +0 -50
  352. package/dist/lib/superpowers-task-state.d.ts +0 -16
  353. package/dist/lib/superpowers-task-state.js +0 -246
  354. package/dist/lib/superpowers-task-status.d.ts +0 -2
  355. package/dist/lib/superpowers-task-status.js +0 -24
  356. package/dist/lib/superpowers-task-under-specified.d.ts +0 -7
  357. package/dist/lib/superpowers-task-under-specified.js +0 -61
  358. package/dist/lib/superpowers-task-unregistered-evidence.d.ts +0 -11
  359. package/dist/lib/superpowers-task-unregistered-evidence.js +0 -72
  360. package/dist/lib/superpowers-task-validator.d.ts +0 -5
  361. package/dist/lib/superpowers-task-validator.js +0 -290
@@ -0,0 +1,96 @@
1
+ import type { ProofSurface } from "./long-task-contract-types.js";
2
+ import type { CompiledSourceItemV2 } from "./long-task-source-authority-types.js";
3
+ import type { WorkspaceManifestV2 } from "./long-task-workspace-runtime-types.js";
4
+ export interface AuthorityHashesV2 {
5
+ source_authority_hash: string;
6
+ product_authority_hash: string;
7
+ acceptance_authority_hash: string;
8
+ risk_authority_hash: string;
9
+ technical_authority_hash: string;
10
+ }
11
+ export interface ProductSemanticProjectionV2 {
12
+ task_goal: string;
13
+ global_non_goals: Array<{
14
+ key: string;
15
+ statement: string;
16
+ }>;
17
+ outcomes: Array<{
18
+ key: string;
19
+ title: string;
20
+ observable_result: string;
21
+ owner: {
22
+ label: string;
23
+ owner_surfaces: string[];
24
+ };
25
+ requirements: Array<{
26
+ key: string;
27
+ statement: string;
28
+ required_proof_surfaces: ProofSurface[];
29
+ }>;
30
+ controls: Array<{
31
+ key: string;
32
+ location: string;
33
+ trigger: string;
34
+ input: string;
35
+ loading_state: string;
36
+ empty_state: string;
37
+ success_state: string;
38
+ failure_state: string;
39
+ feedback: string;
40
+ }>;
41
+ non_completing_outcomes: Array<{
42
+ key: string;
43
+ statement: string;
44
+ }>;
45
+ }>;
46
+ }
47
+ export interface GlobalSemanticProjectionV2 {
48
+ constraints: Array<{
49
+ key: string;
50
+ statement: string;
51
+ }>;
52
+ forbidden_shortcuts: Array<{
53
+ key: string;
54
+ statement: string;
55
+ }>;
56
+ }
57
+ export interface ContextAuthoritySnapshotV2 {
58
+ mode: "referenced" | "full";
59
+ topology_sha256: string;
60
+ files: string[];
61
+ sha256: Record<string, string>;
62
+ controlling_files?: string[];
63
+ supporting_files?: string[];
64
+ }
65
+ export interface NextAuthorityMaterialsV2 {
66
+ source_hashes: Record<string, string>;
67
+ source_items: CompiledSourceItemV2[];
68
+ context_snapshot: ContextAuthoritySnapshotV2;
69
+ product_semantics: ProductSemanticProjectionV2;
70
+ global_semantics: GlobalSemanticProjectionV2;
71
+ }
72
+ export interface AuthorityMaterialHashesV2 {
73
+ source_hashes_sha256: string;
74
+ context_snapshot_sha256: string;
75
+ product_semantics_sha256: string;
76
+ global_semantics_sha256: string;
77
+ }
78
+ export interface InitialTaskBaseV2 {
79
+ git_commit: string;
80
+ git_tree: string;
81
+ workspace_manifest: WorkspaceManifestV2;
82
+ }
83
+ export interface VerifierContentAuthority {
84
+ package_name: string;
85
+ bundle_sha256: string;
86
+ schema_sha256: string;
87
+ hook_sha256: string;
88
+ bundle_files: Record<string, string>;
89
+ }
90
+ export interface VerifierRuntimeLocator {
91
+ package_version: string;
92
+ package_root: string;
93
+ }
94
+ export interface VerifierIdentityV2 extends VerifierContentAuthority, VerifierRuntimeLocator {
95
+ package_name: "project-tiny-context-harness";
96
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { AuthorityHashesV2, CompiledDeliveryContractV2, DeliveryContractV2, DeliveryOutcomeV2 } from "./long-task-delivery-types.js";
2
+ export declare function computeAuthorityHashes(contract: DeliveryContractV2): AuthorityHashesV2;
3
+ export declare function outcomeAuthorityHash(outcome: DeliveryOutcomeV2): string;
4
+ export declare function changedAuthoritySections(previous: AuthorityHashesV2, next: AuthorityHashesV2): string[];
5
+ export declare function protectedAuthorityChanged(previous: CompiledDeliveryContractV2, next: AuthorityHashesV2): string[];
6
+ export declare function acceptanceSemanticsChanged(previous: CompiledDeliveryContractV2, next: DeliveryContractV2): boolean;
7
+ export declare function isMonotonicAcceptanceStrengthening(previous: CompiledDeliveryContractV2, next: DeliveryContractV2): boolean;
@@ -0,0 +1,142 @@
1
+ import { CHECK_AUTHORITY_POLICY, projectFieldsByPolicy, } from "./long-task-authority-policy.js";
2
+ import { evidenceAdapterForRunner } from "./long-task-evidence-adapter-policy.js";
3
+ import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
4
+ const ACCEPTANCE_CHECK_POLICIES = new Set([
5
+ "identity",
6
+ "semantic_user_review",
7
+ "proof_additive",
8
+ "output_requirement",
9
+ ]);
10
+ const TECHNICAL_CHECK_POLICIES = new Set([
11
+ "identity",
12
+ "runner_authority",
13
+ "input_coverage",
14
+ ]);
15
+ export function computeAuthorityHashes(contract) {
16
+ return {
17
+ source_authority_hash: hash({
18
+ source_paths: contract.task.source_paths,
19
+ source_claims: contract.source_claims,
20
+ }),
21
+ product_authority_hash: hash({
22
+ goal: contract.task.goal,
23
+ global: contract.global.product,
24
+ outcomes: contract.outcomes.map((outcome) => ({
25
+ key: outcome.key,
26
+ product: outcome.product,
27
+ })),
28
+ }),
29
+ acceptance_authority_hash: hash({
30
+ external_confirmations: contract.global.acceptance.external_confirmations,
31
+ global_checks: contract.global.acceptance.checks.map(acceptanceCheck),
32
+ global_counterfactual_controls: contract.global.acceptance.counterfactual_controls,
33
+ outcomes: contract.outcomes.map((outcome) => ({
34
+ key: outcome.key,
35
+ checks: outcome.acceptance.checks.map(acceptanceCheck),
36
+ population: outcome.acceptance.population,
37
+ counterfactual_controls: outcome.acceptance.counterfactual_controls,
38
+ })),
39
+ }),
40
+ risk_authority_hash: hash(contract.risk),
41
+ technical_authority_hash: hash({
42
+ global: contract.global.technical,
43
+ outcomes: contract.outcomes.map((outcome) => ({
44
+ key: outcome.key,
45
+ technical: outcome.technical,
46
+ checks: [...outcome.acceptance.checks.map(technicalCheck)],
47
+ })),
48
+ global_checks: contract.global.acceptance.checks.map(technicalCheck),
49
+ }),
50
+ };
51
+ }
52
+ export function outcomeAuthorityHash(outcome) {
53
+ return hash({
54
+ product: outcome.product,
55
+ acceptance: {
56
+ checks: outcome.acceptance.checks.map(acceptanceCheck),
57
+ population: outcome.acceptance.population,
58
+ counterfactual_controls: outcome.acceptance.counterfactual_controls,
59
+ },
60
+ });
61
+ }
62
+ export function changedAuthoritySections(previous, next) {
63
+ return Object.keys(previous)
64
+ .filter((key) => previous[key] !== next[key])
65
+ .map((key) => key.replace(/_authority_hash$/u, ""));
66
+ }
67
+ export function protectedAuthorityChanged(previous, next) {
68
+ return changedAuthoritySections(previous.authority_hashes, next).filter((section) => section !== "technical");
69
+ }
70
+ export function acceptanceSemanticsChanged(previous, next) {
71
+ return !same(acceptanceSemantics(previous), acceptanceSemantics(next));
72
+ }
73
+ export function isMonotonicAcceptanceStrengthening(previous, next) {
74
+ if (!acceptanceSemanticsChanged(previous, next))
75
+ return false;
76
+ if (!subset(previous.global.acceptance.external_confirmations, next.global.acceptance.external_confirmations) ||
77
+ !subset(previous.global.acceptance.counterfactual_controls ?? [], next.global.acceptance.counterfactual_controls) ||
78
+ !checksStrengthened(previous.global.acceptance.checks, next.global.acceptance.checks))
79
+ return false;
80
+ const nextOutcomes = new Map(next.outcomes.map((outcome) => [outcome.key, outcome]));
81
+ if (nextOutcomes.size !== previous.outcomes.length)
82
+ return false;
83
+ for (const previousOutcome of previous.outcomes) {
84
+ const nextOutcome = nextOutcomes.get(previousOutcome.key);
85
+ if (!nextOutcome)
86
+ return false;
87
+ if (!checksStrengthened(previousOutcome.acceptance.checks, nextOutcome.acceptance.checks) ||
88
+ !optionalStrengthened(previousOutcome.acceptance.population, nextOutcome.acceptance.population) ||
89
+ !subset(previousOutcome.acceptance.counterfactual_controls, nextOutcome.acceptance.counterfactual_controls))
90
+ return false;
91
+ }
92
+ return true;
93
+ }
94
+ function acceptanceCheck(check) {
95
+ return {
96
+ ...projectFieldsByPolicy(check, CHECK_AUTHORITY_POLICY, ACCEPTANCE_CHECK_POLICIES),
97
+ evidence_adapter: evidenceAdapterForRunner(check.runner.type),
98
+ };
99
+ }
100
+ function technicalCheck(check) {
101
+ return projectFieldsByPolicy(check, CHECK_AUTHORITY_POLICY, TECHNICAL_CHECK_POLICIES);
102
+ }
103
+ function acceptanceSemantics(contract) {
104
+ return {
105
+ external_confirmations: contract.global.acceptance.external_confirmations,
106
+ global_checks: contract.global.acceptance.checks.map(acceptanceCheck),
107
+ global_counterfactual_controls: contract.global.acceptance.counterfactual_controls ?? [],
108
+ outcomes: contract.outcomes.map((outcome) => ({
109
+ key: outcome.key,
110
+ checks: outcome.acceptance.checks.map(acceptanceCheck),
111
+ population: outcome.acceptance.population,
112
+ counterfactual_controls: outcome.acceptance.counterfactual_controls,
113
+ })),
114
+ };
115
+ }
116
+ function checksStrengthened(previous, next) {
117
+ const nextChecks = new Map(next.map((check) => [check.key, check]));
118
+ for (const previousCheck of previous) {
119
+ const nextCheck = nextChecks.get(previousCheck.key);
120
+ if (!nextCheck ||
121
+ previousCheck.proof_surface !== nextCheck.proof_surface ||
122
+ !subset(previousCheck.positive_assertions, nextCheck.positive_assertions) ||
123
+ !subset(previousCheck.negative_assertions, nextCheck.negative_assertions))
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+ function subset(previous, next) {
129
+ const available = new Set(next.map((item) => canonicalValueJson(item)));
130
+ return previous.every((item) => available.has(canonicalValueJson(item)));
131
+ }
132
+ function optionalStrengthened(previous, next) {
133
+ return previous === null || previous === undefined
134
+ ? true
135
+ : same(previous, next);
136
+ }
137
+ function same(left, right) {
138
+ return canonicalValueJson(left) === canonicalValueJson(right);
139
+ }
140
+ function hash(value) {
141
+ return sha256Hex(canonicalValueJson(value));
142
+ }
@@ -0,0 +1,15 @@
1
+ export type BoundaryCheckDecisionV2 = "single_contract" | "decision_required";
2
+ export interface BoundaryCandidateV2 {
3
+ observable_result: string;
4
+ executable_acceptance: boolean;
5
+ separation_reason: string;
6
+ preserves_atomic_loop: boolean;
7
+ }
8
+ export interface BoundaryCheckInputV2 {
9
+ atomic_user_loop: boolean;
10
+ capacity_requires_fragments: boolean;
11
+ capacity_available: boolean;
12
+ split_motivations: string[];
13
+ candidates: BoundaryCandidateV2[];
14
+ }
15
+ export declare function evaluateContractBoundary(input: BoundaryCheckInputV2): BoundaryCheckDecisionV2;
@@ -0,0 +1,9 @@
1
+ export function evaluateContractBoundary(input) {
2
+ if (!input.candidates.length)
3
+ return "decision_required";
4
+ if (input.candidates.some((candidate) => !candidate.observable_result.trim() ||
5
+ !candidate.executable_acceptance ||
6
+ !candidate.separation_reason.trim()))
7
+ return "decision_required";
8
+ return "single_contract";
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { CompiledCheckV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
2
+ export declare function decodeCheckEvidence(check: CompiledCheckV2, exitCode: number, stdout: Buffer, stderr: Buffer): Pick<RawCommandExecutionV2, "execution_status" | "exit_code" | "observations" | "error">;
3
+ export declare function invalidEvidence(exitCode: number, error: string): Pick<RawCommandExecutionV2, "execution_status" | "exit_code" | "observations" | "error">;
@@ -0,0 +1,74 @@
1
+ import { extractPlaywrightEvidence } from "./long-task-playwright-evidence.js";
2
+ export function decodeCheckEvidence(check, exitCode, stdout, stderr) {
3
+ if (check.runner.type === "playwright_test")
4
+ return decodePlaywright(check, exitCode, stdout, stderr);
5
+ const lines = stdout
6
+ .toString("utf8")
7
+ .split(/\r?\n/u)
8
+ .map((line) => line.trim())
9
+ .filter(Boolean);
10
+ try {
11
+ const payload = JSON.parse(lines.at(-1) ?? "");
12
+ if (payload.schema_version !== "long-task-check-result-v2")
13
+ return invalidEvidence(exitCode, "check_evidence_schema_invalid");
14
+ if (payload.execution_status === "blocked_external")
15
+ return {
16
+ execution_status: "blocked_external",
17
+ exit_code: exitCode,
18
+ observations: {},
19
+ error: `blocked_external:${String(payload.reason ?? "unspecified")}`,
20
+ };
21
+ if (payload.execution_status !== "completed")
22
+ return invalidEvidence(exitCode, "check_evidence_execution_status_invalid");
23
+ if (!payload.observations ||
24
+ typeof payload.observations !== "object" ||
25
+ Array.isArray(payload.observations))
26
+ return invalidEvidence(exitCode, "check_evidence_observations_invalid");
27
+ return {
28
+ execution_status: "completed",
29
+ exit_code: exitCode,
30
+ observations: payload.observations,
31
+ error: null,
32
+ };
33
+ }
34
+ catch (error) {
35
+ return invalidEvidence(exitCode, `check_evidence_json_invalid:${message(error)}`);
36
+ }
37
+ }
38
+ export function invalidEvidence(exitCode, error) {
39
+ return {
40
+ execution_status: "invalid_evidence",
41
+ exit_code: exitCode,
42
+ observations: {},
43
+ error,
44
+ };
45
+ }
46
+ function decodePlaywright(check, exitCode, stdout, stderr) {
47
+ try {
48
+ const report = JSON.parse(stdout.toString("utf8"));
49
+ const extracted = extractPlaywrightEvidence(check, report, exitCode);
50
+ if (extracted.error)
51
+ return invalidEvidence(exitCode, extracted.error);
52
+ return {
53
+ execution_status: "completed",
54
+ exit_code: exitCode,
55
+ observations: extracted.observations,
56
+ error: null,
57
+ };
58
+ }
59
+ catch (error) {
60
+ const combined = `${stdout.toString("utf8")}\n${stderr.toString("utf8")}`;
61
+ if (exitCode !== 0 &&
62
+ /Cannot find module|command not found|not recognized|Executable doesn't exist|browserType\.launch/iu.test(combined))
63
+ return {
64
+ execution_status: "infrastructure_error",
65
+ exit_code: exitCode,
66
+ observations: {},
67
+ error: `playwright_startup_failed:${message(error)}`,
68
+ };
69
+ return invalidEvidence(exitCode, `playwright_report_invalid:${message(error)}`);
70
+ }
71
+ }
72
+ function message(error) {
73
+ return error instanceof Error ? error.message : String(error);
74
+ }
@@ -0,0 +1,18 @@
1
+ import type { CompiledCheckV2 } from "./long-task-delivery-types.js";
2
+ export type CheckExecutionInputPolicy = "raw_execution" | "raw_execution_via_runner_freeze" | "per_check_evidence" | "progress_scope" | "final_gate_evidence" | "authority_metadata";
3
+ export declare const CHECK_EXECUTION_INPUT_POLICY: {
4
+ key: "authority_metadata";
5
+ proof_surface: "authority_metadata";
6
+ runner: "raw_execution";
7
+ verification_inputs: "raw_execution_via_runner_freeze";
8
+ input_paths: "progress_scope";
9
+ expected_output_paths: "final_gate_evidence";
10
+ artifact_globs: "per_check_evidence";
11
+ positive_assertions: "per_check_evidence";
12
+ negative_assertions: "per_check_evidence";
13
+ environment_requirements: "raw_execution";
14
+ };
15
+ type CompiledCheckWithoutRawIdentity = Omit<CompiledCheckV2, "raw_execution_identity">;
16
+ export declare function rawExecutionInputProjection(check: CompiledCheckWithoutRawIdentity): Record<string, unknown>;
17
+ export declare function computeRawExecutionIdentity(check: CompiledCheckWithoutRawIdentity): string;
18
+ export {};
@@ -0,0 +1,36 @@
1
+ import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
2
+ export const CHECK_EXECUTION_INPUT_POLICY = {
3
+ key: "authority_metadata",
4
+ proof_surface: "authority_metadata",
5
+ runner: "raw_execution",
6
+ verification_inputs: "raw_execution_via_runner_freeze",
7
+ input_paths: "progress_scope",
8
+ expected_output_paths: "final_gate_evidence",
9
+ artifact_globs: "per_check_evidence",
10
+ positive_assertions: "per_check_evidence",
11
+ negative_assertions: "per_check_evidence",
12
+ environment_requirements: "raw_execution",
13
+ };
14
+ export function rawExecutionInputProjection(check) {
15
+ const projection = {};
16
+ projection.evidence_adapter = check.evidence_adapter;
17
+ for (const field of Object.keys(CHECK_EXECUTION_INPUT_POLICY)) {
18
+ const policy = CHECK_EXECUTION_INPUT_POLICY[field];
19
+ if (policy === "raw_execution") {
20
+ if (field === "runner")
21
+ projection[field] = check.runner.execution_identity;
22
+ else if (field === "environment_requirements")
23
+ projection[field] = [...check.environment_requirements].sort((left, right) => canonicalValueJson(left).localeCompare(canonicalValueJson(right)));
24
+ else
25
+ projection[field] = check[field];
26
+ }
27
+ else if (policy === "raw_execution_via_runner_freeze")
28
+ projection[field] = {
29
+ frozen_via_runner_execution_identity: check.runner.execution_identity,
30
+ };
31
+ }
32
+ return projection;
33
+ }
34
+ export function computeRawExecutionIdentity(check) {
35
+ return sha256Hex(canonicalValueJson(rawExecutionInputProjection(check)));
36
+ }
@@ -0,0 +1,2 @@
1
+ import type { CompiledCheckV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
2
+ export declare function executeCheckRunner(check: CompiledCheckV2, snapshotRoot: string): Promise<RawCommandExecutionV2>;
@@ -0,0 +1,181 @@
1
+ import { spawn } from "node:child_process";
2
+ import { access } from "node:fs/promises";
3
+ import net from "node:net";
4
+ import path from "node:path";
5
+ import { decodeCheckEvidence, invalidEvidence, } from "./long-task-check-evidence-decoder.js";
6
+ import { declaredEnvironmentValues, outputContainsDeclaredEnvironmentValue, runnerEnvironment, } from "./long-task-runner-environment.js";
7
+ import { resolveInsideRepository } from "./long-task-workspace.js";
8
+ import { sha256Hex } from "./strict-codec.js";
9
+ const OUTPUT_LIMIT = 2 * 1024 * 1024;
10
+ export async function executeCheckRunner(check, snapshotRoot) {
11
+ const started = Date.now();
12
+ const unavailable = await probeEnvironment(check.environment_requirements, snapshotRoot);
13
+ if (unavailable)
14
+ return {
15
+ raw_execution_identity: check.raw_execution_identity,
16
+ execution_identity: check.raw_execution_identity,
17
+ execution_status: "blocked_external",
18
+ exit_code: -1,
19
+ observations: {},
20
+ stdout_sha256: sha256Hex(""),
21
+ stderr_sha256: sha256Hex(""),
22
+ attempts: 0,
23
+ duration_ms: Date.now() - started,
24
+ error: unavailable,
25
+ };
26
+ const retryAllowed = check.runner.retry_policy === "transient_once" &&
27
+ check.runner.idempotent &&
28
+ (check.runner.effect === "read_only" ||
29
+ check.runner.effect === "test_sandbox");
30
+ const maximumAttempts = retryAllowed ? 2 : 1;
31
+ for (let attempt = 1; attempt <= maximumAttempts; attempt += 1) {
32
+ try {
33
+ const raw = await runOnce(check, snapshotRoot);
34
+ const secrets = declaredEnvironmentValues(check.environment_requirements);
35
+ const decoded = outputContainsDeclaredEnvironmentValue(raw, secrets)
36
+ ? invalidEvidence(raw.exit_code, "check_evidence_contains_declared_environment_value")
37
+ : decodeCheckEvidence(check, raw.exit_code, raw.stdout, raw.stderr);
38
+ return {
39
+ raw_execution_identity: check.raw_execution_identity,
40
+ execution_identity: check.raw_execution_identity,
41
+ ...decoded,
42
+ stdout_sha256: sha256Hex(raw.stdout),
43
+ stderr_sha256: sha256Hex(raw.stderr),
44
+ attempts: attempt,
45
+ duration_ms: Date.now() - started,
46
+ };
47
+ }
48
+ catch (error) {
49
+ const reason = message(error);
50
+ if (attempt < maximumAttempts)
51
+ continue;
52
+ return {
53
+ raw_execution_identity: check.raw_execution_identity,
54
+ execution_identity: check.raw_execution_identity,
55
+ execution_status: "infrastructure_error",
56
+ exit_code: -1,
57
+ observations: {},
58
+ stdout_sha256: sha256Hex(""),
59
+ stderr_sha256: sha256Hex(reason),
60
+ attempts: attempt,
61
+ duration_ms: Date.now() - started,
62
+ error: reason,
63
+ };
64
+ }
65
+ }
66
+ throw new Error("unreachable");
67
+ }
68
+ async function runOnce(check, snapshotRoot) {
69
+ const runner = check.runner;
70
+ const cwd = resolveInsideRepository(snapshotRoot, runner.resolved_cwd || ".", "runner.resolved_cwd");
71
+ const executable = runner.type === "project_binary"
72
+ ? resolveInsideRepository(snapshotRoot, runner.resolved_target, "runner.resolved_target")
73
+ : runner.executable;
74
+ const argv = [...runner.executable_argv_prefix, ...runner.argv];
75
+ return new Promise((resolve, reject) => {
76
+ const child = spawn(executable, argv, {
77
+ cwd,
78
+ shell: false,
79
+ windowsHide: true,
80
+ env: runnerEnvironment(check.environment_requirements),
81
+ });
82
+ const stdout = [];
83
+ const stderr = [];
84
+ let size = 0;
85
+ let settled = false;
86
+ const capture = (target) => (chunk) => {
87
+ size += chunk.length;
88
+ if (size > OUTPUT_LIMIT) {
89
+ child.kill();
90
+ if (!settled) {
91
+ settled = true;
92
+ reject(new Error("command_output_limit_exceeded"));
93
+ }
94
+ return;
95
+ }
96
+ target.push(Buffer.from(chunk));
97
+ };
98
+ child.stdout.on("data", capture(stdout));
99
+ child.stderr.on("data", capture(stderr));
100
+ child.on("error", (error) => {
101
+ if (!settled) {
102
+ settled = true;
103
+ reject(new Error(`command_spawn_error:${message(error)}`));
104
+ }
105
+ });
106
+ const timer = setTimeout(() => {
107
+ child.kill();
108
+ if (!settled) {
109
+ settled = true;
110
+ reject(new Error("command_timeout"));
111
+ }
112
+ }, runner.timeout_ms);
113
+ child.on("close", (code) => {
114
+ clearTimeout(timer);
115
+ if (settled)
116
+ return;
117
+ settled = true;
118
+ resolve({
119
+ exit_code: code ?? -1,
120
+ stdout: Buffer.concat(stdout),
121
+ stderr: Buffer.concat(stderr),
122
+ });
123
+ });
124
+ });
125
+ }
126
+ async function probeEnvironment(requirements, snapshotRoot) {
127
+ for (const requirement of requirements) {
128
+ let available = false;
129
+ if (requirement.kind === "executable")
130
+ available = await executableExists(requirement.target);
131
+ else if (requirement.kind === "env_var")
132
+ available = Boolean(process.env[requirement.target]);
133
+ else if (requirement.kind === "file")
134
+ available = Boolean((await statSafe(resolveInsideRepository(snapshotRoot, requirement.target, `environment.${requirement.key}`)))?.isFile());
135
+ else if (requirement.kind === "directory")
136
+ available = Boolean((await statSafe(resolveInsideRepository(snapshotRoot, requirement.target, `environment.${requirement.key}`)))?.isDirectory());
137
+ else if ("host" in requirement)
138
+ available = await loopbackAvailable(requirement.host, requirement.port, requirement.timeout_ms);
139
+ if (!available)
140
+ return `environment_requirement_unavailable:${requirement.key}`;
141
+ }
142
+ return null;
143
+ }
144
+ async function executableExists(target) {
145
+ if (path.isAbsolute(target))
146
+ return access(target)
147
+ .then(() => true)
148
+ .catch(() => false);
149
+ const names = process.platform === "win32"
150
+ ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM")
151
+ .split(";")
152
+ .flatMap((extension) => [target, `${target}${extension}`])
153
+ : [target];
154
+ for (const folder of (process.env.PATH ?? "").split(path.delimiter))
155
+ for (const name of names)
156
+ if (await access(path.join(folder, name))
157
+ .then(() => true)
158
+ .catch(() => false))
159
+ return true;
160
+ return false;
161
+ }
162
+ async function loopbackAvailable(host, port, timeoutMs) {
163
+ return new Promise((resolve) => {
164
+ const socket = net.createConnection({ host, port });
165
+ const finish = (value) => {
166
+ socket.destroy();
167
+ resolve(value);
168
+ };
169
+ socket.setTimeout(timeoutMs, () => finish(false));
170
+ socket.once("connect", () => finish(true));
171
+ socket.once("error", () => finish(false));
172
+ });
173
+ }
174
+ async function statSafe(file) {
175
+ return import("node:fs/promises")
176
+ .then(({ stat }) => stat(file))
177
+ .catch(() => null);
178
+ }
179
+ function message(error) {
180
+ return error instanceof Error ? error.message : String(error);
181
+ }
@@ -0,0 +1,2 @@
1
+ import type { DeliveryCheckV2 } from "./long-task-delivery-types.js";
2
+ export declare function parseCheck(value: unknown, label: string): DeliveryCheckV2;