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,214 @@
1
+ import type { DeliveryCheckV2, DeliveryContractV2, DeliveryOutcomeV2, DeliveryRunnerV2, ProofSurface } from "./long-task-contract-types.js";
2
+ import type { AuthorityHashesV2, ContextAuthoritySnapshotV2, InitialTaskBaseV2, NextAuthorityMaterialsV2, VerifierIdentityV2 } from "./long-task-authority-types.js";
3
+ import type { EvidenceAdapter } from "./long-task-evidence-adapter-types.js";
4
+ import type { EffectiveRiskLevel, RiskFactName } from "./long-task-risk-types.js";
5
+ import type { CompiledSourceItemV2 } from "./long-task-source-authority-types.js";
6
+ import type { WorkspaceManifestV2 } from "./long-task-workspace-runtime-types.js";
7
+ export interface FrozenRunnerV2 extends DeliveryRunnerV2 {
8
+ executable: string;
9
+ executable_argv_prefix: string[];
10
+ resolved_cwd: string;
11
+ resolved_target: string;
12
+ definition_sha256: string;
13
+ frozen_files: Record<string, string>;
14
+ package_script: string | null;
15
+ execution_identity: string;
16
+ }
17
+ export interface CompiledCheckV2 extends Omit<DeliveryCheckV2, "runner"> {
18
+ internal_id: string;
19
+ outcome_key: string | null;
20
+ runner: FrozenRunnerV2;
21
+ evidence_adapter: EvidenceAdapter;
22
+ verification_input_hashes: Record<string, string>;
23
+ raw_execution_identity: string;
24
+ }
25
+ export interface ProductClaimV2 {
26
+ id: string;
27
+ outcome_key: string;
28
+ local_key: string;
29
+ kind: "result" | "requirement" | "control" | "non_completing" | "obligation" | "forbidden_shortcut";
30
+ required_proof_surfaces: ProofSurface[];
31
+ }
32
+ export interface GlobalClaimV2 {
33
+ id: string;
34
+ local_key: string;
35
+ kind: "global_non_goal" | "global_constraint" | "global_forbidden_shortcut";
36
+ required_polarity: "any" | "negative";
37
+ }
38
+ export interface ClaimProofV2 {
39
+ check_key: string;
40
+ assertion_key: string | null;
41
+ polarity: "positive" | "negative" | "population" | "counterfactual";
42
+ proof_surface: ProofSurface;
43
+ }
44
+ export interface ClaimCoverageSummaryV2 {
45
+ claims_total: number;
46
+ claims_covered: number;
47
+ uncovered_claims: string[];
48
+ claims_by_global: Record<string, {
49
+ covered: boolean;
50
+ proofs: ClaimProofV2[];
51
+ }>;
52
+ claims_by_outcome: Record<string, Record<string, {
53
+ required_surfaces: ProofSurface[];
54
+ covered_surfaces: ProofSurface[];
55
+ missing_surfaces: ProofSurface[];
56
+ covered: boolean;
57
+ proofs: ClaimProofV2[];
58
+ }>>;
59
+ }
60
+ export interface CompiledOutcomeV2 extends Omit<DeliveryOutcomeV2, "acceptance"> {
61
+ internal_id: string;
62
+ generated_claims: ProductClaimV2[];
63
+ risk_reasons: RiskFactName[];
64
+ acceptance: Omit<DeliveryOutcomeV2["acceptance"], "checks"> & {
65
+ checks: CompiledCheckV2[];
66
+ };
67
+ }
68
+ export interface CompiledDeliveryContractV2 {
69
+ schema_version: "compiled-long-task-delivery-v2";
70
+ compiled_identity: string;
71
+ repository_root: string;
72
+ workdir: string;
73
+ contract_file: string;
74
+ contract_sha256: string;
75
+ contract_files: Record<string, string>;
76
+ source_hashes: Record<string, string>;
77
+ source_items: CompiledSourceItemV2[];
78
+ context_snapshot: ContextAuthoritySnapshotV2;
79
+ verifier_identity: VerifierIdentityV2;
80
+ effective_risk: EffectiveRiskLevel;
81
+ risk_reasons: string[];
82
+ baseline_workspace: WorkspaceManifestV2;
83
+ initial_task_base: InitialTaskBaseV2;
84
+ authority_hashes: AuthorityHashesV2;
85
+ authority_materials: NextAuthorityMaterialsV2;
86
+ authority_revision: number;
87
+ claim_coverage: ClaimCoverageSummaryV2;
88
+ task: DeliveryContractV2["task"];
89
+ risk: DeliveryContractV2["risk"];
90
+ source_claims: DeliveryContractV2["source_claims"];
91
+ global: Omit<DeliveryContractV2["global"], "acceptance"> & {
92
+ acceptance: {
93
+ checks: CompiledCheckV2[];
94
+ counterfactual_controls: DeliveryContractV2["global"]["acceptance"]["counterfactual_controls"];
95
+ external_confirmations: DeliveryContractV2["global"]["acceptance"]["external_confirmations"];
96
+ };
97
+ };
98
+ outcomes: CompiledOutcomeV2[];
99
+ }
100
+ export interface LongTaskFindingV2 {
101
+ code: string;
102
+ outcome_key: string | null;
103
+ check_key: string | null;
104
+ source_claim_keys?: string[];
105
+ source_target_refs?: string[];
106
+ claim_keys?: string[];
107
+ assertion_key?: string;
108
+ binding_ref?: string;
109
+ owning_outcome_key?: string;
110
+ criterion?: string;
111
+ observation?: string;
112
+ owner_paths?: string[];
113
+ message: string;
114
+ expected?: unknown;
115
+ actual?: unknown;
116
+ next_action: string;
117
+ }
118
+ export type CheckExecutionStatusV2 = "passed" | "assertion_failed" | "test_failed" | "blocked_external" | "infrastructure_error" | "invalid_evidence";
119
+ export interface AssertionResultV2 {
120
+ key: string;
121
+ criterion?: string;
122
+ polarity: "positive" | "negative";
123
+ passed: boolean;
124
+ claims: string[];
125
+ observation: string;
126
+ status: "passed" | "observation_missing" | "observation_type_mismatch" | "assertion_value_mismatch";
127
+ expected?: unknown;
128
+ actual?: unknown;
129
+ }
130
+ export interface RawCommandExecutionV2 {
131
+ raw_execution_identity: string;
132
+ execution_identity: string;
133
+ execution_status: "completed" | "blocked_external" | "infrastructure_error" | "invalid_evidence";
134
+ exit_code: number;
135
+ observations: Record<string, unknown>;
136
+ stdout_sha256: string;
137
+ stderr_sha256: string;
138
+ attempts: number;
139
+ duration_ms: number;
140
+ error: string | null;
141
+ }
142
+ export interface CheckExecutionResultV2 {
143
+ internal_id: string;
144
+ outcome_key: string | null;
145
+ check_key: string;
146
+ status: CheckExecutionStatusV2;
147
+ evidence_adapter: EvidenceAdapter;
148
+ execution_identity: string;
149
+ assertion_results: AssertionResultV2[];
150
+ observations: Record<string, unknown>;
151
+ artifact_hashes: Record<string, string>;
152
+ claim_proofs: ClaimProofV2[];
153
+ findings: LongTaskFindingV2[];
154
+ attempts: number;
155
+ duration_ms: number;
156
+ }
157
+ export interface ProgressRecordV2 {
158
+ schema_version: "long-task-progress-record-v2";
159
+ compiled_identity: string;
160
+ outcome_authority_hash: string;
161
+ check_identity: string;
162
+ check_internal_id: string;
163
+ outcome_key: string | null;
164
+ check_key: string;
165
+ runner_verifier_identity: string;
166
+ relevant_context_identity: string;
167
+ resolved_input_path_hashes: Record<string, string>;
168
+ binding_carrier_path_hashes: Record<string, string>;
169
+ dependency_interface_identities: Record<string, string>;
170
+ result: CheckExecutionStatusV2;
171
+ check_result: CheckExecutionResultV2;
172
+ findings: LongTaskFindingV2[];
173
+ completed_at: string;
174
+ }
175
+ export interface TargetedVerificationResultV2 {
176
+ schema_version: "long-task-targeted-progress-v2";
177
+ compiled_identity: string;
178
+ snapshot_sha256: string;
179
+ acceptance_authorized: false;
180
+ selected_outcome: string | null;
181
+ selected_check: string | null;
182
+ updated_progress_records: string[];
183
+ check_results: CheckExecutionResultV2[];
184
+ findings: LongTaskFindingV2[];
185
+ completed_at: string;
186
+ }
187
+ export type OutcomeStatusV2 = "unverified" | "progress_passing" | "progress_failing" | "progress_stale" | "blocked_external";
188
+ export interface FinalReceiptV2 {
189
+ schema_version: "long-task-final-receipt-v2";
190
+ receipt_sha256: string;
191
+ authority_scope: "audit_only";
192
+ reusable_for_acceptance: false;
193
+ workflow_status: "machine_accepted" | "machine_accepted_external_pending" | "needs_work" | "blocked_external";
194
+ compiled_identity: string;
195
+ contract_sha256: string;
196
+ snapshot_sha256: string;
197
+ git_head: string;
198
+ git_tree: string;
199
+ source_hashes: Record<string, string>;
200
+ context_hashes: Record<string, string>;
201
+ verifier_identity: VerifierIdentityV2;
202
+ check_results: CheckExecutionResultV2[];
203
+ outcome_results: Record<string, "passed" | "failed" | "blocked_external">;
204
+ external_confirmations: DeliveryContractV2["global"]["acceptance"]["external_confirmations"];
205
+ findings: LongTaskFindingV2[];
206
+ snapshot_preparation_ms: number;
207
+ started_at: string;
208
+ completed_at: string;
209
+ }
210
+ export type StrictRiskObligationV2 = {
211
+ outcome_key: string;
212
+ risk_fact: RiskFactName;
213
+ obligations: string[];
214
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ export type Shape = Record<string, unknown>;
2
+ export declare function object(value: unknown, label: string, required: string[], optional?: string[]): Shape;
3
+ export declare function array(value: unknown, label: string): unknown[];
4
+ export declare function string(value: unknown, label: string): string;
5
+ export declare function text(value: unknown, label: string): string;
6
+ export declare function strings(value: unknown, label: string): string[];
7
+ export declare function repositoryFile(value: unknown, label: string): string;
8
+ export declare function repositoryFiles(value: unknown, label: string): string[];
9
+ export declare function repositoryPattern(value: unknown, label: string): string;
10
+ export declare function repositoryPatterns(value: unknown, label: string): string[];
11
+ export declare function repositoryCwd(value: unknown, label: string): string;
12
+ export declare function repositorySourceRef(value: unknown, label: string): string;
13
+ export declare function literal<T extends string>(value: unknown, allowed: readonly T[], label: string): T;
14
+ export declare function key(value: unknown, label: string): string;
15
+ export declare function nullable<T>(value: unknown, parser: (value: unknown) => T): T | null;
16
+ export declare const PROOF_SURFACES: readonly ["ui_browser", "runtime_behavior", "api_contract", "data_state", "security_boundary", "population_coverage", "implementation_structure"];
17
+ export declare function fail(label: string, message: string): never;
@@ -0,0 +1,81 @@
1
+ import { normalizeRepositoryCwd, normalizeRepositoryFile, parseRepositoryPattern, } from "./long-task-paths.js";
2
+ export function object(value, label, required, optional = []) {
3
+ if (!value || typeof value !== "object" || Array.isArray(value))
4
+ fail(label, "must be an object");
5
+ const row = value;
6
+ const allowed = new Set([...required, ...optional]);
7
+ const unknown = Object.keys(row).filter((name) => !allowed.has(name));
8
+ if (unknown.length)
9
+ fail(label, `unknown keys: ${unknown.join(",")}`);
10
+ const missing = required.filter((name) => !(name in row));
11
+ if (missing.length)
12
+ fail(label, `missing keys: ${missing.join(",")}`);
13
+ return row;
14
+ }
15
+ export function array(value, label) {
16
+ if (!Array.isArray(value))
17
+ fail(label, "must be an array");
18
+ return value;
19
+ }
20
+ export function string(value, label) {
21
+ if (typeof value !== "string" || !value.trim())
22
+ fail(label, "must be a non-empty string");
23
+ return value;
24
+ }
25
+ export function text(value, label) {
26
+ if (typeof value !== "string")
27
+ fail(label, "must be a string");
28
+ return value;
29
+ }
30
+ export function strings(value, label) {
31
+ return array(value, label).map((item, index) => string(item, `${label}[${index}]`));
32
+ }
33
+ export function repositoryFile(value, label) {
34
+ return normalizeRepositoryFile(string(value, label), label);
35
+ }
36
+ export function repositoryFiles(value, label) {
37
+ return array(value, label).map((item, index) => repositoryFile(item, `${label}[${index}]`));
38
+ }
39
+ export function repositoryPattern(value, label) {
40
+ return parseRepositoryPattern(string(value, label), label).normalized;
41
+ }
42
+ export function repositoryPatterns(value, label) {
43
+ return array(value, label).map((item, index) => repositoryPattern(item, `${label}[${index}]`));
44
+ }
45
+ export function repositoryCwd(value, label) {
46
+ return normalizeRepositoryCwd(string(value, label), label);
47
+ }
48
+ export function repositorySourceRef(value, label) {
49
+ const sourceRef = string(value, label);
50
+ const [file, anchor, ...extra] = sourceRef.split("#");
51
+ if (!file || extra.length || (anchor !== undefined && !anchor))
52
+ fail(label, "source_claim_ref_invalid");
53
+ const normalized = normalizeRepositoryFile(file, `${label}.file`);
54
+ return anchor === undefined ? normalized : `${normalized}#${anchor}`;
55
+ }
56
+ export function literal(value, allowed, label) {
57
+ if (typeof value !== "string" || !allowed.includes(value))
58
+ fail(label, `must be one of ${allowed.join(",")}`);
59
+ return value;
60
+ }
61
+ export function key(value, label) {
62
+ const result = string(value, label);
63
+ if (!/^[a-z0-9][a-z0-9-]*$/u.test(result))
64
+ fail(label, "must match ^[a-z0-9][a-z0-9-]*$");
65
+ return result;
66
+ }
67
+ export function nullable(value, parser) {
68
+ return value === null ? null : parser(value);
69
+ }
70
+ export const PROOF_SURFACES = [
71
+ "ui_browser",
72
+ "runtime_behavior",
73
+ "api_contract",
74
+ "data_state",
75
+ "security_boundary",
76
+ "population_coverage",
77
+ "implementation_structure",
78
+ ];
79
+ export function fail(label, message) {
80
+ throw new Error(`delivery_contract_invalid:${label}:${message}`);
81
+ }
@@ -0,0 +1,13 @@
1
+ import type { RiskFactName } from "./long-task-risk-types.js";
2
+ export type SourceItemKind = "outcome_result" | "requirement" | "control" | "acceptance" | "technical_obligation" | "non_completing" | "non_goal" | "forbidden_shortcut" | "risk_fact" | "external_confirmation" | "decision";
3
+ export interface CompiledSourceItemV2 {
4
+ key: string;
5
+ kind: SourceItemKind;
6
+ source_path: string;
7
+ normalized_text: string;
8
+ text_sha256: string;
9
+ risk_semantics?: {
10
+ fact: RiskFactName;
11
+ affected_outcome: string;
12
+ };
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
2
+ import type { compileProductClaimCoverage } from "./long-task-claims.js";
3
+ export declare function validateSourceClaimMappings(contract: DeliveryContractV2, compiledClaims: ReturnType<typeof compileProductClaimCoverage>, report?: ValidationReporter): void;
4
+ type ValidationReporter = (message: string) => void;
5
+ export {};
@@ -0,0 +1,96 @@
1
+ import { resolveAcceptanceAssertion } from "./long-task-acceptance-reference.js";
2
+ import { fail } from "./long-task-delivery-shape.js";
3
+ export function validateSourceClaimMappings(contract, compiledClaims, report) {
4
+ validateSourcePresence(contract, report);
5
+ const sources = new Set(contract.task.source_paths);
6
+ const productClaims = new Set(Object.values(compiledClaims.by_outcome)
7
+ .flat()
8
+ .map((claim) => claim.id));
9
+ const globalClaims = new Map(compiledClaims.by_global.map((claim) => [claim.local_key, claim]));
10
+ const coveredGlobalClaims = new Set(Object.entries(compiledClaims.summary.claims_by_global)
11
+ .filter(([, value]) => value.covered)
12
+ .map(([key]) => key));
13
+ const forbiddenPaths = new Set(contract.global.technical.forbidden_paths.map((item) => `forbidden_path.${item.key}`));
14
+ const outcomeResults = new Set(contract.outcomes.map((outcome) => `${outcome.key}.result`));
15
+ const externalConfirmations = new Set(contract.global.acceptance.external_confirmations.map((item) => item.key));
16
+ for (const claim of contract.source_claims) {
17
+ validateSourceReference(claim.key, claim.source_ref, sources, report);
18
+ const disposition = claim.disposition;
19
+ if ("refs" in disposition && !disposition.refs.length)
20
+ issue(report, "source_claim_disposition_refs_empty", claim.key);
21
+ if (disposition.type === "claim")
22
+ for (const reference of disposition.refs) {
23
+ if (reference.endsWith(".result"))
24
+ issue(report, "source_claim_result_overcompression", `${claim.key}:${reference}`);
25
+ if (!productClaims.has(reference))
26
+ issue(report, "source_claim_product_ref_unknown", `${claim.key}:${reference}`);
27
+ }
28
+ if (disposition.type === "acceptance") {
29
+ if (disposition.refs.length !== 1)
30
+ issue(report, "source_claim_acceptance_ref_count", claim.key);
31
+ const reference = disposition.refs[0];
32
+ const resolved = resolveAcceptanceAssertion(contract, reference);
33
+ if (!resolved)
34
+ issue(report, "source_claim_acceptance_ref_unknown", `${claim.key}:${reference}`);
35
+ else if (resolved.scope === "outcome" &&
36
+ (!resolved.assertion.claims.length ||
37
+ resolved.assertion.claims.every((item) => item === "result")))
38
+ issue(report, "source_claim_acceptance_result_only", `${claim.key}:${reference}`);
39
+ else if (resolved.scope === "global" && !resolved.assertion.claims.length)
40
+ issue(report, "source_claim_acceptance_global_claim_required", `${claim.key}:${reference}`);
41
+ }
42
+ if (disposition.type === "outcome_result" &&
43
+ !outcomeResults.has(disposition.ref))
44
+ issue(report, "source_claim_outcome_result_ref_unknown", `${claim.key}:${disposition.ref}`);
45
+ if (disposition.type === "external_confirmation")
46
+ validateRefs(claim.key, disposition.refs, externalConfirmations, "source_claim_external_confirmation_ref_unknown", report);
47
+ if (disposition.type === "global_constraint")
48
+ validateGlobalRefs(claim.key, disposition.refs, forbiddenPaths, globalClaims, coveredGlobalClaims, report);
49
+ if (disposition.type === "risk_fact")
50
+ validateRiskRefs(contract, claim.key, disposition.refs, report);
51
+ }
52
+ }
53
+ function validateSourcePresence(contract, report) {
54
+ if (!contract.task.source_paths.length || !contract.source_claims.length)
55
+ issue(report, "source_authority_required", "source_paths and source_claims must be non-empty");
56
+ }
57
+ function validateRiskRefs(contract, claimKey, refs, report) {
58
+ for (const reference of refs) {
59
+ const separator = reference.indexOf(":");
60
+ const fact = reference.slice(0, separator);
61
+ const outcome = reference.slice(separator + 1);
62
+ if (separator <= 0 ||
63
+ !outcome ||
64
+ !Object.hasOwn(contract.risk.facts, fact) ||
65
+ !contract.risk.facts[fact].includes(outcome))
66
+ issue(report, "source_claim_risk_fact_ref_unknown", `${claimKey}:${reference}`);
67
+ }
68
+ }
69
+ function validateSourceReference(key, sourceRef, sources, report) {
70
+ const [sourceFile, anchor, ...extra] = sourceRef.split("#");
71
+ if (!sourceFile || extra.length || (anchor !== undefined && !anchor))
72
+ issue(report, "source_claim_ref_invalid", `${key}:${sourceRef}`);
73
+ if (!sources.has(sourceFile))
74
+ issue(report, "source_claim_ref_unknown", `${key}:${sourceRef}`);
75
+ }
76
+ function validateRefs(claimKey, refs, known, code, report) {
77
+ for (const reference of refs)
78
+ if (!known.has(reference))
79
+ issue(report, code, `${claimKey}:${reference}`);
80
+ }
81
+ function validateGlobalRefs(claimKey, refs, forbiddenPaths, globalClaims, coveredGlobalClaims, report) {
82
+ for (const reference of refs)
83
+ if (reference.startsWith("forbidden_path.")) {
84
+ if (!forbiddenPaths.has(reference))
85
+ issue(report, "source_claim_global_ref_unknown", `${claimKey}:${reference}`);
86
+ }
87
+ else if (!globalClaims.has(reference))
88
+ issue(report, "source_claim_global_ref_unknown", `${claimKey}:${reference}`);
89
+ else if (!coveredGlobalClaims.has(reference))
90
+ issue(report, "source_claim_global_ref_uncovered", `${claimKey}:${reference}`);
91
+ }
92
+ function issue(report, code, detail) {
93
+ if (!report)
94
+ fail(code, detail);
95
+ report(`delivery_contract_invalid:${code}:${detail}`);
96
+ }
@@ -0,0 +1,4 @@
1
+ import type { CompiledSourceItemV2, DeliveryContractV2 } from "./long-task-delivery-types.js";
2
+ export declare function validateSourceContinuity(contract: DeliveryContractV2, items: CompiledSourceItemV2[], report?: ValidationReporter): void;
3
+ type ValidationReporter = (message: string) => void;
4
+ export {};
@@ -0,0 +1,57 @@
1
+ import { resolveAcceptanceAssertion } from "./long-task-acceptance-reference.js";
2
+ import { normalizeSourceItemText } from "./long-task-source-item-parser.js";
3
+ export function validateSourceContinuity(contract, items, report) {
4
+ const itemByKey = new Map(items.map((item) => [item.key, item]));
5
+ const claimByKey = new Map(contract.source_claims.map((claim) => [claim.key, claim]));
6
+ for (const claim of contract.source_claims) {
7
+ const item = itemByKey.get(claim.key);
8
+ if (!item) {
9
+ issue(report, `source_claim_item_unknown:${claim.key}`);
10
+ continue;
11
+ }
12
+ const sourcePath = claim.source_ref.split("#")[0];
13
+ if (sourcePath !== item.source_path)
14
+ issue(report, `source_claim_item_file_mismatch:${claim.key}:${sourcePath}:${item.source_path}`);
15
+ if (normalizeSourceItemText(claim.statement) !== item.normalized_text)
16
+ issue(report, `source_claim_statement_mismatch:${claim.key}`);
17
+ validateDispositionKind(claim, item.kind, report);
18
+ if (claim.disposition.type === "acceptance") {
19
+ const resolved = resolveAcceptanceAssertion(contract, claim.disposition.refs[0]);
20
+ if (!resolved?.assertion.criterion ||
21
+ normalizeSourceItemText(resolved.assertion.criterion) !==
22
+ item.normalized_text)
23
+ issue(report, `source_acceptance_criterion_mismatch:${claim.key}`);
24
+ }
25
+ }
26
+ for (const item of items)
27
+ if (!claimByKey.has(item.key))
28
+ issue(report, `source_item_unmapped:${item.key}`);
29
+ }
30
+ function validateDispositionKind(claim, kind, report) {
31
+ const allowed = new Set(kind === "outcome_result"
32
+ ? ["outcome_result"]
33
+ : kind === "technical_obligation"
34
+ ? ["claim", "global_constraint"]
35
+ : kind === "requirement" ||
36
+ kind === "control" ||
37
+ kind === "non_completing"
38
+ ? ["claim"]
39
+ : kind === "acceptance"
40
+ ? ["acceptance"]
41
+ : kind === "non_goal"
42
+ ? ["global_constraint"]
43
+ : kind === "forbidden_shortcut"
44
+ ? ["claim", "global_constraint"]
45
+ : kind === "risk_fact"
46
+ ? ["risk_fact"]
47
+ : kind === "external_confirmation"
48
+ ? ["external_confirmation"]
49
+ : ["decision_required"]);
50
+ if (!allowed.has(claim.disposition.type))
51
+ issue(report, `source_item_disposition_mismatch:${claim.key}:${kind}:${claim.disposition.type}`);
52
+ }
53
+ function issue(report, message) {
54
+ if (!report)
55
+ throw new Error(message);
56
+ report(message);
57
+ }
@@ -0,0 +1,2 @@
1
+ import type { CompiledSourceItemV2 } from "./long-task-delivery-types.js";
2
+ export declare function compileSourceInventory(repository: string, sourcePaths: string[]): Promise<CompiledSourceItemV2[]>;
@@ -0,0 +1,21 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { assertProtectedRepositoryFile } from "./long-task-protected-files.js";
4
+ import { parseSourceItems } from "./long-task-source-item-parser.js";
5
+ export async function compileSourceInventory(repository, sourcePaths) {
6
+ const items = [];
7
+ const seen = new Set();
8
+ for (const [index, relative] of sourcePaths.entries()) {
9
+ const file = await assertProtectedRepositoryFile(repository, path.resolve(repository, ...relative.split("/")), `source[${index}]`);
10
+ const parsed = parseSourceItems(relative, await readFile(file, "utf8"));
11
+ if (!parsed.length)
12
+ throw new Error(`source_file_material_item_required:${relative}`);
13
+ for (const item of parsed) {
14
+ if (seen.has(item.key))
15
+ throw new Error(`source_item_key_duplicate:${item.key}`);
16
+ seen.add(item.key);
17
+ items.push(item);
18
+ }
19
+ }
20
+ return items.sort((left, right) => left.key.localeCompare(right.key));
21
+ }
@@ -0,0 +1,3 @@
1
+ import type { CompiledSourceItemV2 } from "./long-task-delivery-types.js";
2
+ export declare function parseSourceItems(sourcePath: string, content: string): CompiledSourceItemV2[];
3
+ export declare function normalizeSourceItemText(value: string): string;
@@ -0,0 +1,112 @@
1
+ import { RISK_FACT_NAMES } from "./long-task-risk-types.js";
2
+ import { sha256Hex } from "./strict-codec.js";
3
+ const KINDS = new Set([
4
+ "outcome_result",
5
+ "requirement",
6
+ "control",
7
+ "acceptance",
8
+ "technical_obligation",
9
+ "non_completing",
10
+ "non_goal",
11
+ "forbidden_shortcut",
12
+ "risk_fact",
13
+ "external_confirmation",
14
+ "decision",
15
+ ]);
16
+ const RISK_FACTS = new Set(RISK_FACT_NAMES);
17
+ const START = /^\s*<!--\s*ty-source-item:start\s+(.+?)\s*-->\s*$/u;
18
+ const END = /^\s*<!--\s*ty-source-item:end\s*-->\s*$/u;
19
+ export function parseSourceItems(sourcePath, content) {
20
+ const items = [];
21
+ const seen = new Set();
22
+ let open = null;
23
+ const lines = content.replace(/\r\n?/gu, "\n").split("\n");
24
+ for (const [index, line] of lines.entries()) {
25
+ const start = START.exec(line);
26
+ if (start) {
27
+ if (open)
28
+ throw new Error(`source_item_nested_or_overlapping:${sourcePath}:${open.key}:${index + 1}`);
29
+ const marker = parseStartMarker(sourcePath, index + 1, start[1]);
30
+ open = { ...marker, lines: [], line: index + 1 };
31
+ continue;
32
+ }
33
+ if (END.test(line)) {
34
+ if (!open)
35
+ throw new Error(`source_item_end_without_start:${sourcePath}:${index + 1}`);
36
+ const normalizedText = normalizeSourceItemText(open.lines.join("\n"));
37
+ if (!normalizedText)
38
+ throw new Error(`source_item_empty:${sourcePath}:${open.key}`);
39
+ if (seen.has(open.key))
40
+ throw new Error(`source_item_key_duplicate:${open.key}`);
41
+ seen.add(open.key);
42
+ items.push({
43
+ key: open.key,
44
+ kind: open.kind,
45
+ source_path: sourcePath,
46
+ normalized_text: normalizedText,
47
+ text_sha256: sha256Hex(normalizedText),
48
+ ...(open.risk_semantics ? { risk_semantics: open.risk_semantics } : {}),
49
+ });
50
+ open = null;
51
+ continue;
52
+ }
53
+ if (line.includes("ty-source-item:start") ||
54
+ line.includes("ty-source-item:end"))
55
+ throw new Error(`source_item_marker_invalid:${sourcePath}:${index + 1}`);
56
+ if (open)
57
+ open.lines.push(line);
58
+ }
59
+ if (open)
60
+ throw new Error(`source_item_unclosed:${sourcePath}:${open.key}:${open.line}`);
61
+ return items;
62
+ }
63
+ function parseStartMarker(sourcePath, line, declaration) {
64
+ const attributes = new Map();
65
+ for (const token of declaration.trim().split(/\s+/u)) {
66
+ const match = /^([a-z_]+)=([^\s=]+)$/u.exec(token);
67
+ if (!match)
68
+ throw new Error(`source_item_marker_invalid:${sourcePath}:${line}`);
69
+ if (attributes.has(match[1]))
70
+ throw new Error(`source_item_marker_attribute_duplicate:${sourcePath}:${line}:${match[1]}`);
71
+ attributes.set(match[1], match[2]);
72
+ }
73
+ for (const name of attributes.keys())
74
+ if (!["key", "kind", "fact", "outcome"].includes(name))
75
+ throw new Error(`source_item_marker_attribute_unknown:${sourcePath}:${line}:${name}`);
76
+ const key = attributes.get("key") ?? "";
77
+ const kind = (attributes.get("kind") ?? "");
78
+ if (!/^[a-z0-9][a-z0-9-]*$/u.test(key) || !KINDS.has(kind))
79
+ throw new Error(`source_item_marker_invalid:${sourcePath}:${line}`);
80
+ const fact = attributes.get("fact");
81
+ const outcome = attributes.get("outcome");
82
+ if (kind !== "risk_fact") {
83
+ if (fact !== undefined || outcome !== undefined)
84
+ throw new Error(`source_item_marker_attributes_forbidden:${sourcePath}:${key}:${kind}`);
85
+ return { key, kind };
86
+ }
87
+ if (!fact || !outcome)
88
+ throw new Error(`source_item_risk_semantics_required:${sourcePath}:${key}`);
89
+ if (!RISK_FACTS.has(fact))
90
+ throw new Error(`source_item_risk_fact_invalid:${sourcePath}:${key}:${fact}`);
91
+ if (!/^[a-z0-9][a-z0-9-]*$/u.test(outcome))
92
+ throw new Error(`source_item_risk_outcome_invalid:${sourcePath}:${key}:${outcome}`);
93
+ return {
94
+ key,
95
+ kind,
96
+ risk_semantics: {
97
+ fact: fact,
98
+ affected_outcome: outcome,
99
+ },
100
+ };
101
+ }
102
+ export function normalizeSourceItemText(value) {
103
+ const lines = value
104
+ .replace(/\r\n?/gu, "\n")
105
+ .split("\n")
106
+ .map((line) => line.replace(/[ \t]+$/gu, ""));
107
+ while (lines.length && !lines[0].trim())
108
+ lines.shift();
109
+ while (lines.length && !lines.at(-1).trim())
110
+ lines.pop();
111
+ return lines.join("\n");
112
+ }
@@ -0,0 +1,2 @@
1
+ import type { SourceClaimV2 } from "./long-task-delivery-types.js";
2
+ export declare function parseSourceClaims(value: unknown, label: string): SourceClaimV2[];