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,136 @@
1
+ import { array, fail, key, literal, object, parseEnvironmentRequirements, PROOF_SURFACES, repositoryCwd, repositoryFile, repositoryPatterns, string, strings, } from "./long-task-delivery-shape.js";
2
+ export function parseCheck(value, label) {
3
+ const row = object(value, label, ["key", "proof_surface", "runner", "verification_inputs"], [
4
+ "input_paths",
5
+ "expected_output_paths",
6
+ "artifact_globs",
7
+ "positive_assertions",
8
+ "negative_assertions",
9
+ "environment_requirements",
10
+ ]);
11
+ return {
12
+ key: key(row.key, `${label}.key`),
13
+ proof_surface: literal(row.proof_surface, PROOF_SURFACES, `${label}.proof_surface`),
14
+ runner: parseRunner(row.runner, `${label}.runner`),
15
+ verification_inputs: repositoryPatterns(row.verification_inputs, `${label}.verification_inputs`),
16
+ input_paths: Object.hasOwn(row, "input_paths")
17
+ ? repositoryPatterns(row.input_paths, `${label}.input_paths`)
18
+ : [],
19
+ expected_output_paths: Object.hasOwn(row, "expected_output_paths")
20
+ ? repositoryPatterns(row.expected_output_paths, `${label}.expected_output_paths`)
21
+ : [],
22
+ artifact_globs: Object.hasOwn(row, "artifact_globs")
23
+ ? repositoryPatterns(row.artifact_globs, `${label}.artifact_globs`)
24
+ : [],
25
+ positive_assertions: Object.hasOwn(row, "positive_assertions")
26
+ ? parseAssertions(row.positive_assertions, `${label}.positive_assertions`)
27
+ : [],
28
+ negative_assertions: Object.hasOwn(row, "negative_assertions")
29
+ ? parseAssertions(row.negative_assertions, `${label}.negative_assertions`)
30
+ : [],
31
+ environment_requirements: Object.hasOwn(row, "environment_requirements")
32
+ ? parseEnvironmentRequirements(row.environment_requirements, `${label}.environment_requirements`)
33
+ : [],
34
+ };
35
+ }
36
+ function parseRunner(value, label) {
37
+ const row = object(value, label, ["type", "target", "effect"], ["argv", "cwd", "timeout_ms", "retry_policy", "idempotent"]);
38
+ const timeout = Object.hasOwn(row, "timeout_ms")
39
+ ? Number(row.timeout_ms)
40
+ : 30_000;
41
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 3_600_000)
42
+ fail(`${label}.timeout_ms`, "must be an integer from 100 to 3600000");
43
+ if (Object.hasOwn(row, "idempotent") && typeof row.idempotent !== "boolean")
44
+ fail(`${label}.idempotent`, "must be a boolean");
45
+ const type = literal(row.type, [
46
+ "package_script",
47
+ "project_binary",
48
+ "node_oracle",
49
+ "playwright_test",
50
+ ], `${label}.type`);
51
+ return {
52
+ type,
53
+ target: type === "package_script"
54
+ ? string(row.target, `${label}.target`)
55
+ : repositoryFile(row.target, `${label}.target`),
56
+ argv: Object.hasOwn(row, "argv") ? strings(row.argv, `${label}.argv`) : [],
57
+ cwd: Object.hasOwn(row, "cwd")
58
+ ? repositoryCwd(row.cwd, `${label}.cwd`)
59
+ : ".",
60
+ timeout_ms: timeout,
61
+ effect: literal(row.effect, ["read_only", "test_sandbox"], `${label}.effect`),
62
+ retry_policy: Object.hasOwn(row, "retry_policy")
63
+ ? literal(row.retry_policy, ["none", "transient_once"], `${label}.retry_policy`)
64
+ : "none",
65
+ idempotent: Object.hasOwn(row, "idempotent")
66
+ ? row.idempotent
67
+ : false,
68
+ };
69
+ }
70
+ function parseAssertions(value, label) {
71
+ return array(value, label).map((item, index) => {
72
+ const itemLabel = `${label}[${index}]`;
73
+ const row = object(item, itemLabel, ["key", "claims", "observation", "operator"], ["criterion", "expected"]);
74
+ const operator = literal(row.operator, [
75
+ "equals",
76
+ "not_equals",
77
+ "contains",
78
+ "not_contains",
79
+ "matches",
80
+ "not_matches",
81
+ "greater_than",
82
+ "greater_or_equal",
83
+ "less_than",
84
+ "less_or_equal",
85
+ "truthy",
86
+ "falsy",
87
+ "exists",
88
+ "set_equals",
89
+ "subset_of",
90
+ "superset_of",
91
+ ], `${itemLabel}.operator`);
92
+ const hasExpected = Object.hasOwn(row, "expected");
93
+ if (isBinaryAssertionOperator(operator) && !hasExpected)
94
+ fail(itemLabel, "assertion_expected_required");
95
+ if (!isBinaryAssertionOperator(operator) && hasExpected)
96
+ fail(itemLabel, "assertion_expected_forbidden");
97
+ if (isBinaryAssertionOperator(operator))
98
+ validateAssertionExpected(operator, row.expected, itemLabel);
99
+ const base = {
100
+ key: key(row.key, `${itemLabel}.key`),
101
+ ...(Object.hasOwn(row, "criterion")
102
+ ? { criterion: string(row.criterion, `${itemLabel}.criterion`) }
103
+ : {}),
104
+ claims: strings(row.claims, `${itemLabel}.claims`),
105
+ observation: string(row.observation, `${itemLabel}.observation`),
106
+ operator,
107
+ };
108
+ return isBinaryAssertionOperator(operator)
109
+ ? { ...base, operator, expected: row.expected }
110
+ : {
111
+ ...base,
112
+ operator: operator,
113
+ };
114
+ });
115
+ }
116
+ function isBinaryAssertionOperator(operator) {
117
+ return !["exists", "truthy", "falsy"].includes(operator);
118
+ }
119
+ function validateAssertionExpected(operator, expected, label) {
120
+ if (operator === "matches" || operator === "not_matches") {
121
+ if (typeof expected !== "string")
122
+ fail(label, "assertion_expected_string_required");
123
+ try {
124
+ new RegExp(expected, "u");
125
+ }
126
+ catch {
127
+ fail(label, "assertion_expected_invalid_regex");
128
+ }
129
+ }
130
+ if (["greater_than", "greater_or_equal", "less_than", "less_or_equal"].includes(operator) &&
131
+ (typeof expected !== "number" || !Number.isFinite(expected)))
132
+ fail(label, "assertion_expected_finite_number_required");
133
+ if (["set_equals", "subset_of", "superset_of"].includes(operator) &&
134
+ !Array.isArray(expected))
135
+ fail(label, "assertion_expected_array_required");
136
+ }
@@ -0,0 +1,7 @@
1
+ import type { ClaimProofV2, DeliveryContractV2, DeliveryOutcomeV2, GlobalClaimV2, ProductClaimV2 } from "./long-task-delivery-types.js";
2
+ export declare function generateClaims(outcome: DeliveryOutcomeV2): ProductClaimV2[];
3
+ export declare function generateGlobalClaims(global: DeliveryContractV2["global"]): GlobalClaimV2[];
4
+ export declare function validateGlobalProofPolarity(claim: GlobalClaimV2, proof: ClaimProofV2): void;
5
+ export declare function validateProofSurface(claim: ProductClaimV2, proof: ClaimProofV2, outcomeKey: string): void;
6
+ export declare function assertAllClaimsCovered(uncovered: string[]): void;
7
+ export declare function assertAllGlobalClaimsCovered(uncovered: string[]): void;
@@ -0,0 +1,78 @@
1
+ import { fail } from "./long-task-delivery-shape.js";
2
+ export function generateClaims(outcome) {
3
+ const claims = [claim(outcome.key, "result", "result")];
4
+ for (const requirement of outcome.product.requirements)
5
+ claims.push(claim(outcome.key, `requirement.${requirement.key}`, "requirement", requirement.required_proof_surfaces));
6
+ for (const control of outcome.product.controls) {
7
+ const fields = [
8
+ ["location", control.location],
9
+ ["trigger", control.trigger],
10
+ ["input", control.input],
11
+ ["loading", control.loading_state],
12
+ ["empty", control.empty_state],
13
+ ["success", control.success_state],
14
+ ["failure", control.failure_state],
15
+ ["feedback", control.feedback],
16
+ ];
17
+ for (const [field, value] of fields)
18
+ if (value.trim())
19
+ claims.push(claim(outcome.key, `control.${control.key}.${field}`, "control", [
20
+ "ui_browser",
21
+ ]));
22
+ }
23
+ for (const item of outcome.product.non_completing_outcomes)
24
+ claims.push(claim(outcome.key, `non_completing.${item.key}`, "non_completing"));
25
+ for (const item of outcome.technical.obligations)
26
+ claims.push(claim(outcome.key, `obligation.${item.key}`, "obligation", item.required_proof_surfaces));
27
+ for (const item of outcome.technical.forbidden_shortcuts)
28
+ claims.push(claim(outcome.key, `forbidden_shortcut.${item.key}`, "forbidden_shortcut"));
29
+ return claims;
30
+ }
31
+ export function generateGlobalClaims(global) {
32
+ return [
33
+ ...global.product.non_goals.map((item) => globalClaim(`non_goal.${item.key}`, "global_non_goal", "negative")),
34
+ ...global.technical.constraints.map((item) => globalClaim(`constraint.${item.key}`, "global_constraint", "any")),
35
+ ...global.technical.forbidden_shortcuts.map((item) => globalClaim(`forbidden_shortcut.${item.key}`, "global_forbidden_shortcut", "negative")),
36
+ ].sort((left, right) => left.id.localeCompare(right.id));
37
+ }
38
+ export function validateGlobalProofPolarity(claim, proof) {
39
+ if (claim.required_polarity === "negative" && proof.polarity !== "negative")
40
+ fail("global_negative_claim_proof_required", `${claim.local_key}:${proof.check_key}`);
41
+ }
42
+ export function validateProofSurface(claim, proof, outcomeKey) {
43
+ if (claim.kind === "control" && proof.proof_surface !== "ui_browser")
44
+ fail("ui_claim_requires_ui_browser", `${outcomeKey}:${claim.local_key}`);
45
+ if ((claim.kind === "non_completing" || claim.kind === "forbidden_shortcut") &&
46
+ proof.polarity !== "negative" &&
47
+ proof.polarity !== "counterfactual")
48
+ fail("negative_or_counterfactual_claim_proof_required", `${outcomeKey}:${claim.local_key}`);
49
+ if ((claim.kind === "requirement" || claim.kind === "obligation") &&
50
+ claim.required_proof_surfaces.length > 0 &&
51
+ !claim.required_proof_surfaces.includes(proof.proof_surface))
52
+ fail(`${claim.kind}_proof_surface_mismatch`, `${outcomeKey}:${claim.local_key}:${proof.proof_surface}`);
53
+ }
54
+ export function assertAllClaimsCovered(uncovered) {
55
+ if (uncovered.length)
56
+ fail("product_claim_uncovered", uncovered.sort().join(","));
57
+ }
58
+ export function assertAllGlobalClaimsCovered(uncovered) {
59
+ if (uncovered.length)
60
+ fail("global_claim_uncovered", uncovered.sort().join(","));
61
+ }
62
+ function claim(outcomeKey, localKey, kind, requiredProofSurfaces = []) {
63
+ return {
64
+ id: `${outcomeKey}.${localKey}`,
65
+ outcome_key: outcomeKey,
66
+ local_key: localKey,
67
+ kind,
68
+ required_proof_surfaces: requiredProofSurfaces,
69
+ };
70
+ }
71
+ function globalClaim(localKey, kind, requiredPolarity) {
72
+ return {
73
+ id: `GLOBAL.${localKey}`,
74
+ local_key: localKey,
75
+ kind,
76
+ required_polarity: requiredPolarity,
77
+ };
78
+ }
@@ -0,0 +1,4 @@
1
+ import type { DeliveryAssertionV2, DeliveryContractV2, ProductClaimV2, ProofSurface } from "./long-task-delivery-types.js";
2
+ export declare function validateDeclaredCheckSafety(contract: DeliveryContractV2, report?: (message: string) => void): void;
3
+ export declare function validateClaimAssertionOperator(claim: ProductClaimV2, assertion: DeliveryAssertionV2, proofSurface: ProofSurface, outcomeKey: string, checkKey: string): void;
4
+ export declare function validateGlobalAssertionOperator(assertion: DeliveryAssertionV2, checkKey: string): void;
@@ -0,0 +1,57 @@
1
+ const PRESENCE_OR_UNARY = new Set(["exists", "truthy", "falsy"]);
2
+ export function validateDeclaredCheckSafety(contract, report) {
3
+ for (const check of contract.global.acceptance.checks)
4
+ validateCheck(check, null, report);
5
+ for (const outcome of contract.outcomes)
6
+ for (const check of outcome.acceptance.checks)
7
+ validateCheck(check, outcome.key, report);
8
+ }
9
+ export function validateClaimAssertionOperator(claim, assertion, proofSurface, outcomeKey, checkKey) {
10
+ if (!assertion.claims.length || !PRESENCE_OR_UNARY.has(assertion.operator))
11
+ return;
12
+ const implementationStructureObligation = claim.kind === "obligation" &&
13
+ proofSurface === "implementation_structure" &&
14
+ claim.required_proof_surfaces.includes("implementation_structure");
15
+ if (assertion.operator === "exists" && implementationStructureObligation)
16
+ return;
17
+ throw new Error(`claim_assertion_explicit_expected_required:${outcomeKey}:${checkKey}:${assertion.key}`);
18
+ }
19
+ export function validateGlobalAssertionOperator(assertion, checkKey) {
20
+ if (assertion.claims.length && PRESENCE_OR_UNARY.has(assertion.operator))
21
+ throw new Error(`claim_assertion_explicit_expected_required:GLOBAL:${checkKey}:${assertion.key}`);
22
+ }
23
+ function validateCheck(check, outcomeKey, report) {
24
+ for (const assertion of [
25
+ ...check.positive_assertions,
26
+ ...check.negative_assertions,
27
+ ]) {
28
+ if (!assertion.criterion)
29
+ issue(report, `assertion_criterion_required:${outcomeKey ?? "GLOBAL"}.${check.key}.${assertion.key}`);
30
+ if (check.runner.type === "playwright_test" && assertion.claims.length) {
31
+ const canonical = assertion.observation === `playwright.case.${assertion.key}.passed` &&
32
+ assertion.operator === "equals" &&
33
+ assertion.expected === true;
34
+ if (!canonical)
35
+ issue(report, `playwright_claim_assertion_invalid:${outcomeKey ?? "GLOBAL"}:${check.key}:${assertion.key}`);
36
+ }
37
+ if (outcomeKey === null)
38
+ captureOrReport(report, () => validateGlobalAssertionOperator(assertion, check.key));
39
+ }
40
+ }
41
+ function issue(report, message) {
42
+ if (!report)
43
+ throw new Error(message);
44
+ report(message);
45
+ }
46
+ function captureOrReport(report, action) {
47
+ if (!report) {
48
+ action();
49
+ return;
50
+ }
51
+ try {
52
+ action();
53
+ }
54
+ catch (error) {
55
+ report(error instanceof Error ? error.message : String(error));
56
+ }
57
+ }
@@ -0,0 +1,10 @@
1
+ import type { ClaimCoverageSummaryV2, DeliveryContractV2, GlobalClaimV2, ProductClaimV2 } from "./long-task-delivery-types.js";
2
+ export interface CompiledClaimsV2 {
3
+ by_global: GlobalClaimV2[];
4
+ by_outcome: Record<string, ProductClaimV2[]>;
5
+ summary: ClaimCoverageSummaryV2;
6
+ }
7
+ export declare function compileProductClaimCoverage(contract: DeliveryContractV2, options?: {
8
+ allow_uncovered?: boolean;
9
+ }): CompiledClaimsV2;
10
+ export declare function assertCompiledClaimsCovered(compiled: CompiledClaimsV2): void;
@@ -0,0 +1,187 @@
1
+ import { assertAllClaimsCovered, assertAllGlobalClaimsCovered, generateClaims, generateGlobalClaims, validateGlobalProofPolarity, validateProofSurface, } from "./long-task-claim-definitions.js";
2
+ import { fail } from "./long-task-delivery-shape.js";
3
+ import { validateClaimAssertionOperator, validateGlobalAssertionOperator, } from "./long-task-claim-proof-policy.js";
4
+ export function compileProductClaimCoverage(contract, options = {}) {
5
+ const byGlobal = generateGlobalClaims(contract.global);
6
+ const byOutcome = Object.fromEntries(contract.outcomes.map((outcome) => [outcome.key, generateClaims(outcome)]));
7
+ for (const [outcomeKey, claims] of Object.entries(byOutcome))
8
+ if (!claims.some((claim) => claim.kind !== "result"))
9
+ fail("outcome_atomic_claim_required", outcomeKey);
10
+ const globalClaimMap = new Map(byGlobal.map((claim) => [claim.local_key, claim]));
11
+ const outcomeClaimIds = new Set(Object.values(byOutcome)
12
+ .flat()
13
+ .map((claim) => claim.id));
14
+ const globalProofs = new Map();
15
+ const addGlobalProof = (claimKey, proof) => {
16
+ const claim = globalClaimMap.get(claimKey);
17
+ if (!claim) {
18
+ if (outcomeClaimIds.has(claimKey))
19
+ fail("global_assertion_claim_cross_scope", claimKey);
20
+ fail("global_assertion_claim_unknown", claimKey);
21
+ }
22
+ validateGlobalProofPolarity(claim, proof);
23
+ const rows = globalProofs.get(claimKey) ?? [];
24
+ rows.push(proof);
25
+ globalProofs.set(claimKey, rows);
26
+ };
27
+ for (const check of contract.global.acceptance.checks) {
28
+ const assertionKeys = new Set();
29
+ for (const [polarity, assertions] of [
30
+ ["positive", check.positive_assertions],
31
+ ["negative", check.negative_assertions],
32
+ ])
33
+ for (const assertion of assertions) {
34
+ if (assertionKeys.has(assertion.key))
35
+ fail("assertion_key_duplicate", `GLOBAL:${check.key}:${assertion.key}`);
36
+ assertionKeys.add(assertion.key);
37
+ validateGlobalAssertionOperator(assertion, check.key);
38
+ for (const claimKey of assertion.claims)
39
+ addGlobalProof(claimKey, {
40
+ check_key: check.key,
41
+ assertion_key: assertion.key,
42
+ polarity,
43
+ proof_surface: check.proof_surface,
44
+ });
45
+ }
46
+ }
47
+ const globalRows = {};
48
+ const uncoveredGlobal = [];
49
+ for (const claim of byGlobal) {
50
+ const proofs = globalProofs.get(claim.local_key) ?? [];
51
+ const covered = proofs.length > 0;
52
+ globalRows[claim.local_key] = { covered, proofs };
53
+ if (!covered)
54
+ uncoveredGlobal.push(claim.id);
55
+ }
56
+ const outcomeKeys = new Set(contract.outcomes.map((outcome) => outcome.key));
57
+ const globalLocalKeys = new Set(byGlobal.map((claim) => claim.local_key));
58
+ const summaryRows = {};
59
+ const uncoveredOutcome = [];
60
+ for (const outcome of contract.outcomes) {
61
+ const claims = byOutcome[outcome.key];
62
+ const claimMap = new Map(claims.map((claim) => [claim.local_key, claim]));
63
+ const proofs = new Map();
64
+ const addProof = (claimKey, proof, observation, assertion) => {
65
+ const claim = claimMap.get(claimKey);
66
+ if (!claim) {
67
+ if (globalLocalKeys.has(claimKey))
68
+ fail("assertion_claim_cross_scope", `${outcome.key}:${claimKey}`);
69
+ const first = claimKey.split(".")[0];
70
+ if (outcomeKeys.has(first) && first !== outcome.key)
71
+ fail("assertion_claim_cross_outcome", `${outcome.key}:${claimKey}`);
72
+ fail("assertion_claim_unknown", `${outcome.key}:${claimKey}`);
73
+ }
74
+ if (observation === "playwright.passed" &&
75
+ (claim.kind === "requirement" || claim.kind === "control"))
76
+ fail("fine_grained_claim_requires_ac_observation", `${outcome.key}:${claim.local_key}`);
77
+ validateProofSurface(claim, proof, outcome.key);
78
+ if (assertion)
79
+ validateClaimAssertionOperator(claim, assertion, proof.proof_surface, outcome.key, proof.check_key);
80
+ const rows = proofs.get(claimKey) ?? [];
81
+ rows.push(proof);
82
+ proofs.set(claimKey, rows);
83
+ };
84
+ for (const check of outcome.acceptance.checks) {
85
+ const assertionKeys = new Set();
86
+ for (const [polarity, assertions] of [
87
+ ["positive", check.positive_assertions],
88
+ ["negative", check.negative_assertions],
89
+ ]) {
90
+ for (const assertion of assertions) {
91
+ if (assertionKeys.has(assertion.key))
92
+ fail("assertion_key_duplicate", `${outcome.key}:${check.key}:${assertion.key}`);
93
+ assertionKeys.add(assertion.key);
94
+ for (const claimKey of assertion.claims)
95
+ addProof(claimKey, {
96
+ check_key: check.key,
97
+ assertion_key: assertion.key,
98
+ polarity,
99
+ proof_surface: check.proof_surface,
100
+ }, assertion.observation, assertion);
101
+ }
102
+ }
103
+ }
104
+ if (outcome.acceptance.population) {
105
+ const population = outcome.acceptance.population;
106
+ const check = outcome.acceptance.checks.find((candidate) => candidate.key === population.check_key);
107
+ if (!check)
108
+ fail("outcome_check_reference_unknown", `${outcome.key}:${population.check_key}`);
109
+ for (const claimKey of population.claims)
110
+ addProof(claimKey, {
111
+ check_key: check.key,
112
+ assertion_key: null,
113
+ polarity: "population",
114
+ proof_surface: check.proof_surface,
115
+ });
116
+ }
117
+ for (const counterfactual of outcome.acceptance.counterfactual_controls) {
118
+ const check = outcome.acceptance.checks.find((candidate) => candidate.key === counterfactual.check_key);
119
+ if (!check)
120
+ fail("outcome_check_reference_unknown", `${outcome.key}:${counterfactual.check_key}`);
121
+ const assertionKeys = new Set([...check.positive_assertions, ...check.negative_assertions].map((assertion) => assertion.key));
122
+ if (!counterfactual.expected_assertion_failures.length)
123
+ fail("counterfactual_expected_assertion_required", `${outcome.key}:${counterfactual.key}`);
124
+ for (const assertionKey of counterfactual.expected_assertion_failures)
125
+ if (!assertionKeys.has(assertionKey))
126
+ fail("counterfactual_assertion_unknown", `${outcome.key}:${counterfactual.key}:${assertionKey}`);
127
+ for (const claimKey of counterfactual.claims)
128
+ addProof(claimKey, {
129
+ check_key: check.key,
130
+ assertion_key: counterfactual.expected_assertion_failures.join(","),
131
+ polarity: "counterfactual",
132
+ proof_surface: check.proof_surface,
133
+ });
134
+ }
135
+ const rows = {};
136
+ for (const claim of claims) {
137
+ const claimProofs = proofs.get(claim.local_key) ?? [];
138
+ const requiredSurfaces = [...claim.required_proof_surfaces].sort();
139
+ const coveredSurfaces = [
140
+ ...new Set(claimProofs.map((proof) => proof.proof_surface)),
141
+ ].sort();
142
+ const missingSurfaces = requiredSurfaces.filter((surface) => !coveredSurfaces.includes(surface));
143
+ const covered = claimProofs.length > 0 &&
144
+ (requiredSurfaces.length === 0 || missingSurfaces.length === 0);
145
+ rows[claim.local_key] = {
146
+ required_surfaces: requiredSurfaces,
147
+ covered_surfaces: coveredSurfaces,
148
+ missing_surfaces: missingSurfaces,
149
+ covered,
150
+ proofs: claimProofs,
151
+ };
152
+ if (claimProofs.length && missingSurfaces.length)
153
+ fail("product_claim_required_surfaces_missing", `${outcome.key}:${claim.local_key}:${missingSurfaces.join(",")}`);
154
+ if (!covered)
155
+ uncoveredOutcome.push(claim.id);
156
+ }
157
+ summaryRows[outcome.key] = rows;
158
+ }
159
+ const uncovered = [...uncoveredGlobal, ...uncoveredOutcome].sort();
160
+ const total = byGlobal.length +
161
+ Object.values(byOutcome).reduce((sum, claims) => sum + claims.length, 0);
162
+ const compiled = {
163
+ by_global: byGlobal,
164
+ by_outcome: byOutcome,
165
+ summary: {
166
+ claims_total: total,
167
+ claims_covered: total - uncovered.length,
168
+ uncovered_claims: uncovered,
169
+ claims_by_global: globalRows,
170
+ claims_by_outcome: summaryRows,
171
+ },
172
+ };
173
+ if (!options.allow_uncovered)
174
+ assertCompiledClaimsCovered(compiled);
175
+ return compiled;
176
+ }
177
+ export function assertCompiledClaimsCovered(compiled) {
178
+ const uncoveredGlobal = compiled.by_global
179
+ .filter((claim) => !compiled.summary.claims_by_global[claim.local_key]?.covered)
180
+ .map((claim) => claim.id);
181
+ const uncoveredOutcome = Object.values(compiled.by_outcome)
182
+ .flat()
183
+ .filter((claim) => !compiled.summary.claims_by_outcome[claim.outcome_key]?.[claim.local_key]?.covered)
184
+ .map((claim) => claim.id);
185
+ assertAllGlobalClaimsCovered(uncoveredGlobal);
186
+ assertAllClaimsCovered(uncoveredOutcome);
187
+ }
@@ -0,0 +1,7 @@
1
+ import type { ContextManifest } from "./context-manifest-schema.js";
2
+ /**
3
+ * Hashes only manifest structure that can change the currently selected
4
+ * durable Context authority. Retrieval aliases and load guidance remain in
5
+ * context.toml for future Agent routing but do not revise an active delivery.
6
+ */
7
+ export declare function contextAuthorityTopologyHash(manifest: ContextManifest, selectedFiles: Iterable<string>): string;
@@ -0,0 +1,37 @@
1
+ import { canonicalJson, sha256Hex } from "./strict-codec.js";
2
+ /**
3
+ * Hashes only manifest structure that can change the currently selected
4
+ * durable Context authority. Retrieval aliases and load guidance remain in
5
+ * context.toml for future Agent routing but do not revise an active delivery.
6
+ */
7
+ export function contextAuthorityTopologyHash(manifest, selectedFiles) {
8
+ const selected = new Set([...selectedFiles].map(normalizeRepoPath));
9
+ const topology = {
10
+ areas: manifest.areas
11
+ .filter((area) => selected.has(normalizeRepoPath(area.context)))
12
+ .map(({ line: _line, default: _default, forbidden_runtime_dependencies, kind, ...area }) => ({
13
+ ...area,
14
+ ...(kind === undefined ? {} : { kind }),
15
+ context: normalizeRepoPath(area.context),
16
+ forbidden_runtime_dependencies: [
17
+ ...forbidden_runtime_dependencies,
18
+ ].sort(),
19
+ }))
20
+ .sort((left, right) => left.id.localeCompare(right.id)),
21
+ contexts: manifest.contexts
22
+ .filter((context) => selected.has(normalizeRepoPath(context.path)))
23
+ .map(({ line: _line, read_when: _readWhen, read_policy: _readPolicy, triggers: _triggers, default_children, ...context }) => ({
24
+ ...context,
25
+ path: normalizeRepoPath(context.path),
26
+ default_children: [...default_children]
27
+ .map(normalizeRepoPath)
28
+ .filter((child) => selected.has(child))
29
+ .sort(),
30
+ }))
31
+ .sort((left, right) => left.path.localeCompare(right.path)),
32
+ };
33
+ return sha256Hex(canonicalJson(topology));
34
+ }
35
+ function normalizeRepoPath(value) {
36
+ return value.replace(/\\/gu, "/").replace(/^\.\//u, "");
37
+ }
@@ -0,0 +1,14 @@
1
+ import type { CompiledDeliveryContractV2, ContextAuthoritySnapshotV2 } from "./long-task-delivery-types.js";
2
+ export interface NormalizedContextAuthoritySnapshotV2 extends ContextAuthoritySnapshotV2 {
3
+ controlling_files: string[];
4
+ supporting_files: string[];
5
+ }
6
+ export declare function normalizeContextAuthoritySnapshot(snapshot: ContextAuthoritySnapshotV2): NormalizedContextAuthoritySnapshotV2;
7
+ export declare function contextAuthorityProjection(snapshot: ContextAuthoritySnapshotV2): {
8
+ mode: ContextAuthoritySnapshotV2["mode"];
9
+ topology_sha256: string;
10
+ controlling_files: string[];
11
+ sha256: Record<string, string>;
12
+ };
13
+ export declare function contextAuthorityChanged(previous: ContextAuthoritySnapshotV2, next: ContextAuthoritySnapshotV2): boolean;
14
+ export declare function canRetainProgressForSupportingContextRevision(previous: CompiledDeliveryContractV2, next: CompiledDeliveryContractV2): boolean;
@@ -0,0 +1,66 @@
1
+ import { canonicalValueJson } from "./strict-codec.js";
2
+ export function normalizeContextAuthoritySnapshot(snapshot) {
3
+ const files = uniqueSorted(snapshot.files);
4
+ const available = new Set(files);
5
+ const declaredAuthority = Array.isArray(snapshot.controlling_files)
6
+ ? snapshot.controlling_files.filter((file) => available.has(file))
7
+ : files;
8
+ const declaredSupporting = Array.isArray(snapshot.supporting_files)
9
+ ? snapshot.supporting_files.filter((file) => available.has(file))
10
+ : [];
11
+ const authority = new Set(declaredAuthority);
12
+ const supporting = new Set(declaredSupporting.filter((file) => !authority.has(file)));
13
+ for (const file of files)
14
+ if (!authority.has(file) && !supporting.has(file))
15
+ authority.add(file);
16
+ return {
17
+ mode: snapshot.mode,
18
+ topology_sha256: snapshot.topology_sha256,
19
+ files,
20
+ sha256: Object.fromEntries(files
21
+ .filter((file) => file in snapshot.sha256)
22
+ .map((file) => [file, snapshot.sha256[file]])),
23
+ controlling_files: [...authority].sort(),
24
+ supporting_files: [...supporting].sort(),
25
+ };
26
+ }
27
+ export function contextAuthorityProjection(snapshot) {
28
+ const normalized = normalizeContextAuthoritySnapshot(snapshot);
29
+ return {
30
+ mode: normalized.mode,
31
+ topology_sha256: normalized.topology_sha256,
32
+ controlling_files: normalized.controlling_files,
33
+ sha256: Object.fromEntries(normalized.controlling_files
34
+ .filter((file) => file in normalized.sha256)
35
+ .map((file) => [file, normalized.sha256[file]])),
36
+ };
37
+ }
38
+ export function contextAuthorityChanged(previous, next) {
39
+ return !same(contextAuthorityProjection(previous), contextAuthorityProjection(next));
40
+ }
41
+ export function canRetainProgressForSupportingContextRevision(previous, next) {
42
+ const previousContext = normalizeContextAuthoritySnapshot(previous.context_snapshot);
43
+ const nextContext = normalizeContextAuthoritySnapshot(next.context_snapshot);
44
+ if (same(previousContext, nextContext))
45
+ return false;
46
+ if (contextAuthorityChanged(previousContext, nextContext))
47
+ return false;
48
+ return same(progressRetentionProjection(previous), progressRetentionProjection(next));
49
+ }
50
+ function progressRetentionProjection(compiled) {
51
+ const { compiled_identity: _compiledIdentity, authority_revision: _authorityRevision, context_snapshot: contextSnapshot, authority_materials: authorityMaterials, ...rest } = compiled;
52
+ return {
53
+ ...rest,
54
+ context_snapshot: contextAuthorityProjection(contextSnapshot),
55
+ authority_materials: {
56
+ ...authorityMaterials,
57
+ context_snapshot: contextAuthorityProjection(authorityMaterials.context_snapshot),
58
+ },
59
+ };
60
+ }
61
+ function same(left, right) {
62
+ return canonicalValueJson(left) === canonicalValueJson(right);
63
+ }
64
+ function uniqueSorted(values) {
65
+ return [...new Set(values)].sort();
66
+ }