project-tiny-context-harness 0.2.85 → 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 -163
  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 +4 -2
  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 -245
  275. package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -62
  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 -682
  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 -91
  313. package/dist/lib/superpowers-task-completion-output.js +0 -374
  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 -393
  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 -35
  336. package/dist/lib/superpowers-task-gates.d.ts +0 -12
  337. package/dist/lib/superpowers-task-gates.js +0 -267
  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 -460
  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 -293
@@ -0,0 +1,125 @@
1
+ export function classifyPlaywrightCounterfactual(raw, result, control) {
2
+ const reasons = [];
3
+ const expected = [...new Set(control.expected_assertion_failures)].sort();
4
+ if (expected.length !== control.expected_assertion_failures.length)
5
+ reasons.push("expected_assertion_failures_duplicate");
6
+ if (result.evidence_adapter !== "playwright_json_v1")
7
+ reasons.push("evidence_adapter_not_playwright_json_v1");
8
+ if (raw.execution_status !== "completed")
9
+ reasons.push(`execution_status_${raw.execution_status}`);
10
+ if (raw.exit_code === 0)
11
+ reasons.push("exit_code_zero_with_test_failure");
12
+ else if (raw.exit_code !== 1)
13
+ reasons.push(`exit_code_not_expected_test_failure:${raw.exit_code}`);
14
+ const reportErrorCount = count(raw.observations, "playwright.report_error_count", reasons);
15
+ const declaredUnexpectedInstances = count(raw.observations, "playwright.declared_unexpected_instances", reasons);
16
+ const unboundUnexpectedInstances = count(raw.observations, "playwright.unbound_unexpected_instances", reasons);
17
+ const reportUnexpectedInstances = count(raw.observations, "playwright.unexpected", reasons);
18
+ if (reportErrorCount !== null && reportErrorCount !== 0)
19
+ reasons.push(`playwright_report_errors:${reportErrorCount}`);
20
+ if (unboundUnexpectedInstances !== null && unboundUnexpectedInstances !== 0)
21
+ reasons.push(`playwright_unbound_unexpected_instances:${unboundUnexpectedInstances}`);
22
+ const expectedCaseIds = new Set();
23
+ let expectedUnexpectedInstances = 0;
24
+ for (const assertionKey of expected) {
25
+ const assertion = result.assertion_results.find((item) => item.key === assertionKey);
26
+ if (!assertion) {
27
+ reasons.push(`expected_assertion_missing:${assertionKey}`);
28
+ continue;
29
+ }
30
+ const caseId = playwrightCaseId(assertion.observation);
31
+ if (!caseId) {
32
+ reasons.push(`expected_assertion_not_playwright_ac:${assertionKey}`);
33
+ continue;
34
+ }
35
+ if (expectedCaseIds.has(caseId))
36
+ reasons.push(`expected_playwright_ac_duplicate:${caseId}`);
37
+ expectedCaseIds.add(caseId);
38
+ const prefix = `playwright.case.${caseId}`;
39
+ if (boolean(raw.observations, `${prefix}.executed`) !== true)
40
+ reasons.push(`expected_playwright_ac_not_executed:${caseId}`);
41
+ if (boolean(raw.observations, `${prefix}.unexpected`) !== true)
42
+ reasons.push(`expected_playwright_ac_not_unexpected:${caseId}`);
43
+ if (boolean(raw.observations, `${prefix}.skipped`) !== false)
44
+ reasons.push(`expected_playwright_ac_skipped:${caseId}`);
45
+ if (boolean(raw.observations, `${prefix}.flaky`) !== false)
46
+ reasons.push(`expected_playwright_ac_flaky:${caseId}`);
47
+ const unexpectedInstances = count(raw.observations, `${prefix}.unexpected_instances`, reasons);
48
+ const timedOutInstances = count(raw.observations, `${prefix}.timed_out_instances`, reasons);
49
+ const interruptedInstances = count(raw.observations, `${prefix}.interrupted_instances`, reasons);
50
+ if (unexpectedInstances !== null) {
51
+ expectedUnexpectedInstances += unexpectedInstances;
52
+ if (unexpectedInstances === 0)
53
+ reasons.push(`expected_playwright_ac_has_no_unexpected_instance:${caseId}`);
54
+ }
55
+ if (timedOutInstances !== null && timedOutInstances !== 0)
56
+ reasons.push(`expected_playwright_ac_timed_out:${caseId}`);
57
+ if (interruptedInstances !== null && interruptedInstances !== 0)
58
+ reasons.push(`expected_playwright_ac_interrupted:${caseId}`);
59
+ if (assertion.passed || assertion.status !== "assertion_value_mismatch")
60
+ reasons.push(`expected_assertion_not_value_mismatch:${assertionKey}`);
61
+ }
62
+ for (const assertion of result.assertion_results)
63
+ if (!expected.includes(assertion.key) && !assertion.passed)
64
+ reasons.push(`unspecified_assertion_failed:${assertion.key}`);
65
+ if (declaredUnexpectedInstances !== null &&
66
+ declaredUnexpectedInstances !== expectedUnexpectedInstances)
67
+ reasons.push(`declared_unexpected_instance_mismatch:${declaredUnexpectedInstances}:${expectedUnexpectedInstances}`);
68
+ if (reportUnexpectedInstances !== null &&
69
+ reportUnexpectedInstances !== expectedUnexpectedInstances)
70
+ reasons.push(`report_unexpected_instance_mismatch:${reportUnexpectedInstances}:${expectedUnexpectedInstances}`);
71
+ const genericTestFailures = result.findings.filter((finding) => finding.code === "test_failed" && !finding.assertion_key);
72
+ if (genericTestFailures.length !== 1)
73
+ reasons.push(`generic_test_failure_count_unexpected:${genericTestFailures.length}`);
74
+ for (const finding of result.findings) {
75
+ const expectedAcceptanceFailure = finding.code === "acceptance_case_unexpected" &&
76
+ Boolean(finding.assertion_key) &&
77
+ expected.includes(finding.assertion_key);
78
+ const genericTestFailure = finding.code === "test_failed" && !finding.assertion_key;
79
+ if (!expectedAcceptanceFailure && !genericTestFailure)
80
+ reasons.push(`unexplained_finding:${finding.code}:${finding.assertion_key ?? "none"}`);
81
+ }
82
+ for (const assertionKey of expected)
83
+ if (!result.findings.some((finding) => finding.code === "acceptance_case_unexpected" &&
84
+ finding.assertion_key === assertionKey))
85
+ reasons.push(`expected_acceptance_failure_missing:${assertionKey}`);
86
+ const rejectionReasons = [...new Set(reasons)].sort();
87
+ if (rejectionReasons.length)
88
+ return {
89
+ accepted_test_failure_exit: false,
90
+ normalized_result: result,
91
+ rejection_reasons: rejectionReasons,
92
+ };
93
+ return {
94
+ accepted_test_failure_exit: true,
95
+ normalized_result: {
96
+ ...result,
97
+ status: "assertion_failed",
98
+ claim_proofs: [],
99
+ findings: result.findings
100
+ .filter((finding) => !(finding.code === "test_failed" && !finding.assertion_key))
101
+ .map((finding) => finding.code === "acceptance_case_unexpected" &&
102
+ finding.assertion_key &&
103
+ expected.includes(finding.assertion_key)
104
+ ? { ...finding, code: "assertion_value_mismatch" }
105
+ : finding),
106
+ },
107
+ rejection_reasons: [],
108
+ };
109
+ }
110
+ function playwrightCaseId(observation) {
111
+ return (/^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(observation)?.[1] ?? null);
112
+ }
113
+ function count(observations, key, reasons) {
114
+ const value = observations[key];
115
+ if (!Number.isInteger(value) || Number(value) < 0) {
116
+ reasons.push(`playwright_diagnostic_count_invalid:${key}`);
117
+ return null;
118
+ }
119
+ return Number(value);
120
+ }
121
+ function boolean(observations, key) {
122
+ return typeof observations[key] === "boolean"
123
+ ? observations[key]
124
+ : null;
125
+ }
@@ -0,0 +1,6 @@
1
+ import type { CompiledCheckV2 } from "./long-task-delivery-types.js";
2
+ export interface PlaywrightEvidence {
3
+ observations: Record<string, unknown>;
4
+ error: string | null;
5
+ }
6
+ export declare function extractPlaywrightEvidence(check: CompiledCheckV2, report: Record<string, unknown>, exitCode: number): PlaywrightEvidence;
@@ -0,0 +1,244 @@
1
+ export function extractPlaywrightEvidence(check, report, exitCode) {
2
+ const stats = record(report.stats);
3
+ if (!stats)
4
+ return invalid("playwright_report_invalid:stats");
5
+ const expected = integer(stats.expected);
6
+ const unexpected = integer(stats.unexpected);
7
+ const skipped = integer(stats.skipped);
8
+ const flaky = integer(stats.flaky);
9
+ if ([expected, unexpected, skipped, flaky].some((value) => value === null))
10
+ return invalid("playwright_report_invalid:counts");
11
+ const total = expected + unexpected + skipped + flaky;
12
+ const reportErrors = report.errors;
13
+ if (reportErrors !== undefined && !Array.isArray(reportErrors))
14
+ return invalid("playwright_report_invalid:errors");
15
+ const observations = {
16
+ "playwright.passed": exitCode === 0,
17
+ "playwright.expected": expected,
18
+ "playwright.unexpected": unexpected,
19
+ "playwright.skipped": skipped,
20
+ "playwright.flaky": flaky,
21
+ "playwright.total": total,
22
+ "playwright.zero_or_all_skipped": total === 0 || skipped === total,
23
+ "playwright.report_error_count": Array.isArray(reportErrors)
24
+ ? reportErrors.length
25
+ : 0,
26
+ };
27
+ const collected = collectCases(report, declaredCaseIds(check));
28
+ if (collected.error)
29
+ return invalid(collected.error);
30
+ const instances = collected.cases;
31
+ observations["playwright.declared_unexpected_instances"] = instances.filter((item) => item.unexpected).length;
32
+ observations["playwright.unbound_unexpected_instances"] =
33
+ collected.unbound_unexpected_instances;
34
+ const duplicate = duplicateCaseInstance(instances);
35
+ if (duplicate)
36
+ return invalid(`playwright_ac_id_duplicate:${duplicate.id}:${duplicate.project_id}`);
37
+ const cases = aggregateCases(instances);
38
+ for (const item of cases) {
39
+ const prefix = `playwright.case.${item.id}`;
40
+ observations[`${prefix}.executed`] = item.executed;
41
+ observations[`${prefix}.passed`] = item.passed;
42
+ observations[`${prefix}.skipped`] = item.skipped;
43
+ observations[`${prefix}.flaky`] = item.flaky;
44
+ observations[`${prefix}.unexpected`] = item.unexpected;
45
+ observations[`${prefix}.status`] = item.status;
46
+ observations[`${prefix}.project_ids`] = item.project_ids;
47
+ observations[`${prefix}.executed_instances`] = item.executed_instances;
48
+ observations[`${prefix}.failed_instances`] = item.failed_instances;
49
+ observations[`${prefix}.skipped_instances`] = item.skipped_instances;
50
+ observations[`${prefix}.flaky_instances`] = item.flaky_instances;
51
+ observations[`${prefix}.unexpected_instances`] = item.unexpected_instances;
52
+ observations[`${prefix}.timed_out_instances`] = item.timed_out_instances;
53
+ observations[`${prefix}.interrupted_instances`] =
54
+ item.interrupted_instances;
55
+ }
56
+ for (const id of declaredCaseIds(check)) {
57
+ const prefix = `playwright.case.${id}`;
58
+ if (!Object.hasOwn(observations, `${prefix}.status`)) {
59
+ observations[`${prefix}.executed`] = false;
60
+ observations[`${prefix}.status`] = "missing";
61
+ }
62
+ }
63
+ observations["playwright.case_ids"] = cases.map((item) => item.id).sort();
64
+ return { observations, error: null };
65
+ }
66
+ function collectCases(report, declaredIds) {
67
+ const cases = [];
68
+ const collection = { unbound_unexpected_instances: 0 };
69
+ const error = visitSuites(report.suites, cases, declaredIds, collection);
70
+ return { cases, error, ...collection };
71
+ }
72
+ function visitSuites(value, cases, declaredIds, collection) {
73
+ if (!Array.isArray(value))
74
+ return null;
75
+ for (const suiteValue of value) {
76
+ const suite = record(suiteValue);
77
+ if (!suite)
78
+ continue;
79
+ const nestedError = visitSuites(suite.suites, cases, declaredIds, collection);
80
+ if (nestedError)
81
+ return nestedError;
82
+ if (!Array.isArray(suite.specs))
83
+ continue;
84
+ for (const specValue of suite.specs) {
85
+ const spec = record(specValue);
86
+ if (!spec || !Array.isArray(spec.tests))
87
+ continue;
88
+ for (const testValue of spec.tests) {
89
+ const test = record(testValue);
90
+ if (!test)
91
+ continue;
92
+ const title = [spec.title, test.title]
93
+ .filter((item) => typeof item === "string")
94
+ .join(" ");
95
+ const ids = declaredIdsInTitle(title, declaredIds);
96
+ if (ids.length > 1)
97
+ return `playwright_test_multiple_ac_ids:${ids.join(",")}`;
98
+ const instance = playwrightCase(ids[0] ?? "unbound", test);
99
+ if (ids.length === 1)
100
+ cases.push(instance);
101
+ else if (instance.unexpected)
102
+ collection.unbound_unexpected_instances += 1;
103
+ }
104
+ }
105
+ }
106
+ return null;
107
+ }
108
+ function declaredIdsInTitle(title, declared) {
109
+ const explicit = [...title.matchAll(/\[ac:([a-z0-9][a-z0-9-]*)\]/gu)].map((match) => match[1]);
110
+ const legacy = [...title.matchAll(/\[([a-z0-9][a-z0-9-]*)\]/gu)].map((match) => match[1]);
111
+ return [
112
+ ...new Set([...explicit, ...legacy].filter((id) => declared.has(id))),
113
+ ].sort();
114
+ }
115
+ function playwrightCase(id, test) {
116
+ const status = typeof test.status === "string" ? test.status : "invalid";
117
+ const projectId = typeof test.projectId === "string"
118
+ ? test.projectId
119
+ : typeof test.projectName === "string"
120
+ ? test.projectName
121
+ : "default";
122
+ const results = Array.isArray(test.results)
123
+ ? test.results.map(record).filter(Boolean)
124
+ : [];
125
+ const resultStatuses = results
126
+ .map((result) => result.status)
127
+ .filter((value) => typeof value === "string");
128
+ const skipped = status === "skipped" ||
129
+ (resultStatuses.length > 0 &&
130
+ resultStatuses.every((value) => value === "skipped"));
131
+ const executed = !skipped && resultStatuses.length > 0;
132
+ const flaky = status === "flaky";
133
+ const unexpected = status === "unexpected";
134
+ const timedOut = resultStatuses.includes("timedOut");
135
+ const interrupted = resultStatuses.includes("interrupted");
136
+ const passed = executed &&
137
+ !flaky &&
138
+ !unexpected &&
139
+ status === "expected" &&
140
+ resultStatuses.length > 0 &&
141
+ resultStatuses.at(-1) === "passed";
142
+ return {
143
+ id,
144
+ project_id: projectId,
145
+ executed,
146
+ passed,
147
+ skipped,
148
+ flaky,
149
+ unexpected,
150
+ timed_out: timedOut,
151
+ interrupted,
152
+ status,
153
+ };
154
+ }
155
+ function declaredCaseIds(check) {
156
+ const result = new Set();
157
+ for (const assertion of [
158
+ ...check.positive_assertions,
159
+ ...check.negative_assertions,
160
+ ]) {
161
+ if (!assertion.claims.length)
162
+ continue;
163
+ const match = /^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(assertion.observation);
164
+ if (match)
165
+ result.add(assertion.key);
166
+ }
167
+ return result;
168
+ }
169
+ function duplicateCaseInstance(values) {
170
+ const seen = new Set();
171
+ for (const value of values) {
172
+ const identity = `${value.id}\0${value.project_id}`;
173
+ if (seen.has(identity))
174
+ return value;
175
+ seen.add(identity);
176
+ }
177
+ return null;
178
+ }
179
+ function aggregateCases(instances) {
180
+ const grouped = new Map();
181
+ for (const instance of instances) {
182
+ const rows = grouped.get(instance.id) ?? [];
183
+ rows.push(instance);
184
+ grouped.set(instance.id, rows);
185
+ }
186
+ return [...grouped.entries()]
187
+ .map(([id, rows]) => {
188
+ const executedInstances = rows.filter((item) => item.executed).length;
189
+ const skippedInstances = rows.filter((item) => item.skipped).length;
190
+ const flakyInstances = rows.filter((item) => item.flaky).length;
191
+ const unexpectedInstances = rows.filter((item) => item.unexpected).length;
192
+ const timedOutInstances = rows.filter((item) => item.timed_out).length;
193
+ const interruptedInstances = rows.filter((item) => item.interrupted).length;
194
+ const failedInstances = rows.filter((item) => !item.passed && !item.skipped).length;
195
+ const executed = rows.length > 0 && rows.every((item) => item.executed);
196
+ const passed = executed &&
197
+ skippedInstances === 0 &&
198
+ flakyInstances === 0 &&
199
+ unexpectedInstances === 0 &&
200
+ rows.every((item) => item.passed);
201
+ const status = passed
202
+ ? "passed"
203
+ : skippedInstances
204
+ ? "skipped"
205
+ : flakyInstances
206
+ ? "flaky"
207
+ : timedOutInstances
208
+ ? "timed_out"
209
+ : interruptedInstances
210
+ ? "interrupted"
211
+ : unexpectedInstances
212
+ ? "unexpected"
213
+ : "failed";
214
+ return {
215
+ id,
216
+ executed,
217
+ passed,
218
+ skipped: skippedInstances > 0,
219
+ flaky: flakyInstances > 0,
220
+ unexpected: unexpectedInstances > 0,
221
+ status,
222
+ project_ids: rows.map((item) => item.project_id).sort(),
223
+ executed_instances: executedInstances,
224
+ failed_instances: failedInstances,
225
+ skipped_instances: skippedInstances,
226
+ flaky_instances: flakyInstances,
227
+ unexpected_instances: unexpectedInstances,
228
+ timed_out_instances: timedOutInstances,
229
+ interrupted_instances: interruptedInstances,
230
+ };
231
+ })
232
+ .sort((left, right) => left.id.localeCompare(right.id));
233
+ }
234
+ function record(value) {
235
+ return value && typeof value === "object" && !Array.isArray(value)
236
+ ? value
237
+ : null;
238
+ }
239
+ function integer(value) {
240
+ return Number.isInteger(value) && Number(value) >= 0 ? Number(value) : null;
241
+ }
242
+ function invalid(error) {
243
+ return { observations: {}, error };
244
+ }
@@ -0,0 +1,6 @@
1
+ import type { DeliveryControlV2, DeliveryObligationV2, DeliveryOwnerV2, KeyedPathV2, KeyedStatementV2 } from "./long-task-delivery-types.js";
2
+ export declare function parseKeyedStatements(value: unknown, label: string): KeyedStatementV2[];
3
+ export declare function parseKeyedPaths(value: unknown, label: string): KeyedPathV2[];
4
+ export declare function parseControls(value: unknown, label: string): DeliveryControlV2[];
5
+ export declare function parseOwner(value: unknown, label: string): DeliveryOwnerV2;
6
+ export declare function parseObligations(value: unknown, label: string): DeliveryObligationV2[];
@@ -0,0 +1,73 @@
1
+ import { parseRequiredProofSurfaces } from "./long-task-required-proof-surfaces.js";
2
+ import { array, key, object, repositoryFiles, repositoryPattern, repositoryPatterns, string, text, } from "./long-task-shape-primitives.js";
3
+ export function parseKeyedStatements(value, label) {
4
+ return array(value, label).map((item, index) => {
5
+ const itemLabel = `${label}[${index}]`;
6
+ const row = object(item, itemLabel, ["key", "statement"]);
7
+ return {
8
+ key: key(row.key, `${itemLabel}.key`),
9
+ statement: string(row.statement, `${itemLabel}.statement`),
10
+ };
11
+ });
12
+ }
13
+ export function parseKeyedPaths(value, label) {
14
+ return array(value, label).map((item, index) => {
15
+ const itemLabel = `${label}[${index}]`;
16
+ const row = object(item, itemLabel, ["key", "path"]);
17
+ return {
18
+ key: key(row.key, `${itemLabel}.key`),
19
+ path: repositoryPattern(row.path, `${itemLabel}.path`),
20
+ };
21
+ });
22
+ }
23
+ export function parseControls(value, label) {
24
+ return array(value, label).map((item, index) => {
25
+ const itemLabel = `${label}[${index}]`;
26
+ const row = object(item, itemLabel, ["key", "location"], [
27
+ "trigger",
28
+ "input",
29
+ "loading_state",
30
+ "empty_state",
31
+ "success_state",
32
+ "failure_state",
33
+ "feedback",
34
+ ]);
35
+ return {
36
+ key: key(row.key, `${itemLabel}.key`),
37
+ location: string(row.location, `${itemLabel}.location`),
38
+ trigger: optionalText(row, "trigger", itemLabel),
39
+ input: optionalText(row, "input", itemLabel),
40
+ loading_state: optionalText(row, "loading_state", itemLabel),
41
+ empty_state: optionalText(row, "empty_state", itemLabel),
42
+ success_state: optionalText(row, "success_state", itemLabel),
43
+ failure_state: optionalText(row, "failure_state", itemLabel),
44
+ feedback: optionalText(row, "feedback", itemLabel),
45
+ };
46
+ });
47
+ }
48
+ export function parseOwner(value, label) {
49
+ const row = object(value, label, ["label", "context_refs", "path_globs"]);
50
+ return {
51
+ label: string(row.label, `${label}.label`),
52
+ context_refs: repositoryFiles(row.context_refs, `${label}.context_refs`),
53
+ path_globs: repositoryPatterns(row.path_globs, `${label}.path_globs`),
54
+ };
55
+ }
56
+ export function parseObligations(value, label) {
57
+ return array(value, label).map((item, index) => {
58
+ const itemLabel = `${label}[${index}]`;
59
+ const row = object(item, itemLabel, [
60
+ "key",
61
+ "statement",
62
+ "required_proof_surfaces",
63
+ ]);
64
+ return {
65
+ key: key(row.key, `${itemLabel}.key`),
66
+ statement: string(row.statement, `${itemLabel}.statement`),
67
+ required_proof_surfaces: parseRequiredProofSurfaces(row.required_proof_surfaces, `${itemLabel}.required_proof_surfaces`),
68
+ };
69
+ });
70
+ }
71
+ function optionalText(row, field, label) {
72
+ return Object.hasOwn(row, field) ? text(row[field], `${label}.${field}`) : "";
73
+ }
@@ -0,0 +1,4 @@
1
+ import type { CheckExecutionResultV2, CompiledCheckV2, CompiledDeliveryContractV2, ProgressRecordV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
2
+ export declare function createProgressRecord(compiled: CompiledDeliveryContractV2, manifest: WorkspaceManifestV2, check: CompiledCheckV2, result: CheckExecutionResultV2): ProgressRecordV2;
3
+ export declare function progressRecordFresh(record: ProgressRecordV2, compiled: CompiledDeliveryContractV2, manifest: WorkspaceManifestV2, check: CompiledCheckV2): boolean;
4
+ export declare function checkIdentity(check: CompiledCheckV2): string;
@@ -0,0 +1,114 @@
1
+ import { outcomeAuthorityHash } from "./long-task-authority.js";
2
+ import { contextAuthorityProjection } from "./long-task-context-authority.js";
3
+ import { matchesRepoPattern } from "./long-task-paths.js";
4
+ import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
5
+ export function createProgressRecord(compiled, manifest, check, result) {
6
+ const outcome = check.outcome_key
7
+ ? (compiled.outcomes.find((item) => item.key === check.outcome_key) ?? null)
8
+ : null;
9
+ return {
10
+ schema_version: "long-task-progress-record-v2",
11
+ compiled_identity: compiled.compiled_identity,
12
+ outcome_authority_hash: progressAuthorityHash(compiled, outcome ?? null),
13
+ check_identity: checkIdentity(check),
14
+ check_internal_id: check.internal_id,
15
+ outcome_key: check.outcome_key,
16
+ check_key: check.key,
17
+ runner_verifier_identity: runnerVerifierIdentity(compiled, check),
18
+ relevant_context_identity: contextIdentity(compiled),
19
+ resolved_input_path_hashes: hashPatterns(manifest, check.input_paths),
20
+ binding_carrier_path_hashes: hashPatterns(manifest, progressBindingCarrierPatterns(compiled, check, outcome)),
21
+ dependency_interface_identities: dependencyInterfaceIdentities(compiled, manifest, outcome?.depends_on ?? []),
22
+ result: result.status,
23
+ check_result: result,
24
+ findings: result.findings,
25
+ completed_at: new Date().toISOString(),
26
+ };
27
+ }
28
+ export function progressRecordFresh(record, compiled, manifest, check) {
29
+ const outcome = check.outcome_key
30
+ ? (compiled.outcomes.find((item) => item.key === check.outcome_key) ?? null)
31
+ : null;
32
+ const expectedOutcomeAuthority = progressAuthorityHash(compiled, outcome ?? null);
33
+ return (record.check_internal_id === check.internal_id &&
34
+ record.check_identity === checkIdentity(check) &&
35
+ record.outcome_authority_hash === expectedOutcomeAuthority &&
36
+ record.runner_verifier_identity ===
37
+ runnerVerifierIdentity(compiled, check) &&
38
+ record.relevant_context_identity === contextIdentity(compiled) &&
39
+ same(record.resolved_input_path_hashes, hashPatterns(manifest, check.input_paths)) &&
40
+ same(record.binding_carrier_path_hashes, hashPatterns(manifest, progressBindingCarrierPatterns(compiled, check, outcome))) &&
41
+ same(record.dependency_interface_identities, dependencyInterfaceIdentities(compiled, manifest, outcome?.depends_on ?? [])));
42
+ }
43
+ function progressBindingCarrierPatterns(compiled, check, outcome) {
44
+ if (outcome)
45
+ return outcome.technical.bindings.flatMap((binding) => binding.carrier_paths);
46
+ const references = (compiled.global.acceptance.counterfactual_controls ?? [])
47
+ .filter((control) => control.check_key === check.key)
48
+ .map((control) => control.binding_ref);
49
+ return references.flatMap((reference) => {
50
+ const [outcomeKey, bindingKey] = reference.split(".");
51
+ return (compiled.outcomes
52
+ .find((item) => item.key === outcomeKey)
53
+ ?.technical.bindings.find((binding) => binding.key === bindingKey)
54
+ ?.carrier_paths ?? []);
55
+ });
56
+ }
57
+ function progressAuthorityHash(compiled, outcome) {
58
+ return sha256Hex(canonicalValueJson({
59
+ source: compiled.authority_hashes.source_authority_hash,
60
+ product: compiled.authority_hashes.product_authority_hash,
61
+ acceptance: compiled.authority_hashes.acceptance_authority_hash,
62
+ risk: compiled.authority_hashes.risk_authority_hash,
63
+ outcome: outcome ? outcomeAuthorityHash(outcome) : null,
64
+ }));
65
+ }
66
+ export function checkIdentity(check) {
67
+ return sha256Hex(canonicalValueJson({
68
+ internal_id: check.internal_id,
69
+ proof_surface: check.proof_surface,
70
+ evidence_adapter: check.evidence_adapter,
71
+ runner: check.runner.execution_identity,
72
+ raw_execution: check.raw_execution_identity,
73
+ verification_input_hashes: check.verification_input_hashes,
74
+ input_paths: check.input_paths,
75
+ expected_output_paths: check.expected_output_paths,
76
+ artifact_globs: check.artifact_globs,
77
+ positive_assertions: check.positive_assertions,
78
+ negative_assertions: check.negative_assertions,
79
+ environment_requirements: check.environment_requirements,
80
+ }));
81
+ }
82
+ function runnerVerifierIdentity(compiled, check) {
83
+ return sha256Hex(canonicalValueJson({
84
+ runner: check.raw_execution_identity,
85
+ verifier: compiled.verifier_identity.bundle_sha256,
86
+ }));
87
+ }
88
+ function contextIdentity(compiled) {
89
+ return sha256Hex(canonicalValueJson(contextAuthorityProjection(compiled.context_snapshot)));
90
+ }
91
+ function dependencyInterfaceIdentities(compiled, manifest, dependencies) {
92
+ const result = {};
93
+ for (const key of dependencies) {
94
+ const dependency = compiled.outcomes.find((outcome) => outcome.key === key);
95
+ if (!dependency)
96
+ continue;
97
+ result[key] = sha256Hex(canonicalValueJson({
98
+ authority: outcomeAuthorityHash(dependency),
99
+ carriers: hashPatterns(manifest, dependency.technical.bindings.flatMap((binding) => binding.carrier_paths)),
100
+ }));
101
+ }
102
+ return Object.fromEntries(Object.entries(result).sort(([a], [b]) => a.localeCompare(b)));
103
+ }
104
+ function hashPatterns(manifest, patterns) {
105
+ const result = {};
106
+ for (const pattern of patterns)
107
+ for (const file of manifest.files)
108
+ if (matchesRepoPattern(file.path, pattern))
109
+ result[file.path] = file.sha256;
110
+ return Object.fromEntries(Object.entries(result).sort(([a], [b]) => a.localeCompare(b)));
111
+ }
112
+ function same(left, right) {
113
+ return canonicalValueJson(left) === canonicalValueJson(right);
114
+ }
@@ -0,0 +1 @@
1
+ export declare function assertProtectedRepositoryFile(repositoryInput: string, fileInput: string, label: string): Promise<string>;
@@ -0,0 +1,30 @@
1
+ import { lstat, realpath } from "node:fs/promises";
2
+ import path from "node:path";
3
+ export async function assertProtectedRepositoryFile(repositoryInput, fileInput, label) {
4
+ const repositoryPath = path.resolve(repositoryInput);
5
+ const repository = await realpath(repositoryPath);
6
+ const candidate = path.resolve(fileInput);
7
+ assertInside(repositoryPath, candidate, label, fileInput);
8
+ const info = await lstat(candidate).catch(() => null);
9
+ if (!info)
10
+ throw new Error(`protected_input_not_found:${label}:${display(fileInput)}`);
11
+ if (info.isSymbolicLink())
12
+ throw new Error(`protected_input_symlink_not_allowed:${label}:${display(fileInput)}`);
13
+ if (!info.isFile())
14
+ throw new Error(`protected_input_not_regular_file:${label}:${display(fileInput)}`);
15
+ const resolved = await realpath(candidate);
16
+ assertInside(repository, resolved, label, fileInput);
17
+ if (typeof info.nlink === "number" && info.nlink > 1)
18
+ throw new Error(`protected_input_hardlink_not_allowed:${label}:${display(fileInput)}`);
19
+ return resolved;
20
+ }
21
+ function assertInside(repository, candidate, label, original) {
22
+ const relative = path.relative(repository, candidate);
23
+ if (relative === ".." ||
24
+ relative.startsWith(`..${path.sep}`) ||
25
+ path.isAbsolute(relative))
26
+ throw new Error(`protected_input_realpath_outside_repository:${label}:${display(original)}`);
27
+ }
28
+ function display(file) {
29
+ return file.replace(/\\/gu, "/");
30
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProofSurface } from "./long-task-delivery-types.js";
2
+ export declare function parseRequiredProofSurfaces(value: unknown, label: string): ProofSurface[];
@@ -0,0 +1,13 @@
1
+ import { array, fail, literal, PROOF_SURFACES, } from "./long-task-shape-primitives.js";
2
+ export function parseRequiredProofSurfaces(value, label) {
3
+ const surfaces = array(value, label).map((surface, index) => literal(surface, PROOF_SURFACES, `${label}[${index}]`));
4
+ if (!surfaces.length)
5
+ fail("required_proof_surfaces_empty", label);
6
+ const seen = new Set();
7
+ for (const surface of surfaces) {
8
+ if (seen.has(surface))
9
+ fail("required_proof_surface_duplicate", `${label}:${surface}`);
10
+ seen.add(surface);
11
+ }
12
+ return surfaces;
13
+ }
@@ -0,0 +1,2 @@
1
+ import type { DeliveryOutcomeV2 } from "./long-task-delivery-types.js";
2
+ export declare function parseRequirements(value: unknown, label: string): DeliveryOutcomeV2["product"]["requirements"];
@@ -0,0 +1,18 @@
1
+ import { parseRequiredProofSurfaces } from "./long-task-required-proof-surfaces.js";
2
+ import { array, key, object, string } from "./long-task-shape-primitives.js";
3
+ export function parseRequirements(value, label) {
4
+ return array(value, label).map((item, index) => {
5
+ const itemLabel = `${label}[${index}]`;
6
+ const row = object(item, itemLabel, [
7
+ "key",
8
+ "statement",
9
+ "required_proof_surfaces",
10
+ ]);
11
+ const surfaces = parseRequiredProofSurfaces(row.required_proof_surfaces, `${itemLabel}.required_proof_surfaces`);
12
+ return {
13
+ key: key(row.key, `${itemLabel}.key`),
14
+ statement: string(row.statement, `${itemLabel}.statement`),
15
+ required_proof_surfaces: surfaces,
16
+ };
17
+ });
18
+ }
@@ -0,0 +1,2 @@
1
+ import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
2
+ export declare function validateActualRiskSurfaces(repository: string, changedPaths: string[], contract: DeliveryContractV2): Promise<void>;