project-tiny-context-harness 0.2.85 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/README.md +164 -427
  2. package/assets/README.md +284 -455
  3. package/assets/README.zh-CN.md +200 -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 +63 -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 +467 -0
  19. package/assets/tools/validate_context.py +293 -127
  20. package/dist/cli.js +3 -1
  21. package/dist/commands/check-modularity.js +33 -10
  22. package/dist/commands/composite-campaign.d.ts +1 -0
  23. package/dist/commands/composite-campaign.js +8 -0
  24. package/dist/commands/composite-long-task.d.ts +1 -6
  25. package/dist/commands/composite-long-task.js +7 -163
  26. package/dist/commands/delivery-set.d.ts +1 -0
  27. package/dist/commands/delivery-set.js +8 -0
  28. package/dist/commands/disable.d.ts +1 -0
  29. package/dist/commands/disable.js +15 -0
  30. package/dist/commands/enable.d.ts +1 -0
  31. package/dist/commands/enable.js +14 -0
  32. package/dist/commands/export-context-args.js +13 -4
  33. package/dist/commands/export-context.js +18 -7
  34. package/dist/commands/index.js +42 -30
  35. package/dist/commands/init.js +12 -6
  36. package/dist/commands/long-task-authoring.d.ts +3 -0
  37. package/dist/commands/long-task-authoring.js +92 -0
  38. package/dist/commands/long-task-explain.d.ts +1 -0
  39. package/dist/commands/long-task-explain.js +52 -0
  40. package/dist/commands/long-task.d.ts +1 -0
  41. package/dist/commands/long-task.js +226 -0
  42. package/dist/commands/package-source.js +2 -2
  43. package/dist/commands/upgrade.js +10 -10
  44. package/dist/index.d.ts +11 -1
  45. package/dist/index.js +8 -0
  46. package/dist/lib/config.js +34 -8
  47. package/dist/lib/context-default-footprint.d.ts +16 -0
  48. package/dist/lib/context-default-footprint.js +107 -0
  49. package/dist/lib/context-export.js +105 -41
  50. package/dist/lib/context-graph-snapshot.d.ts +18 -0
  51. package/dist/lib/context-graph-snapshot.js +171 -0
  52. package/dist/lib/context-manifest-schema.d.ts +28 -0
  53. package/dist/lib/context-manifest-schema.js +150 -0
  54. package/dist/lib/context-manifest.js +28 -20
  55. package/dist/lib/context-templates.js +5 -5
  56. package/dist/lib/design-md.js +1 -1
  57. package/dist/lib/doctor.js +54 -1
  58. package/dist/lib/harness-root.js +25 -8
  59. package/dist/lib/init.js +6 -3
  60. package/dist/lib/legacy-managed-scan.js +23 -7
  61. package/dist/lib/legacy-sdlc-migration.js +21 -11
  62. package/dist/lib/long-task-acceptance-reference.d.ts +22 -0
  63. package/dist/lib/long-task-acceptance-reference.js +46 -0
  64. package/dist/lib/long-task-acceptance-shape.d.ts +5 -0
  65. package/dist/lib/long-task-acceptance-shape.js +131 -0
  66. package/dist/lib/long-task-activation-validation.d.ts +21 -0
  67. package/dist/lib/long-task-activation-validation.js +136 -0
  68. package/dist/lib/long-task-artifacts.d.ts +5 -0
  69. package/dist/lib/long-task-artifacts.js +34 -0
  70. package/dist/lib/long-task-assertions-v2.d.ts +22 -0
  71. package/dist/lib/long-task-assertions-v2.js +212 -0
  72. package/dist/lib/long-task-authoring-authority-preview.d.ts +5 -0
  73. package/dist/lib/long-task-authoring-authority-preview.js +85 -0
  74. package/dist/lib/long-task-authoring-preflight-diagnostics.d.ts +8 -0
  75. package/dist/lib/long-task-authoring-preflight-diagnostics.js +179 -0
  76. package/dist/lib/long-task-authoring-preflight-repair-order.d.ts +8 -0
  77. package/dist/lib/long-task-authoring-preflight-repair-order.js +95 -0
  78. package/dist/lib/long-task-authoring-preflight-types.d.ts +46 -0
  79. package/dist/lib/long-task-authoring-preflight-types.js +38 -0
  80. package/dist/lib/long-task-authoring-preflight.d.ts +3 -0
  81. package/dist/lib/long-task-authoring-preflight.js +44 -0
  82. package/dist/lib/long-task-authority-material-diff.d.ts +17 -0
  83. package/dist/lib/long-task-authority-material-diff.js +152 -0
  84. package/dist/lib/long-task-authority-materials.d.ts +7 -0
  85. package/dist/lib/long-task-authority-materials.js +83 -0
  86. package/dist/lib/long-task-authority-policy.d.ts +168 -0
  87. package/dist/lib/long-task-authority-policy.js +181 -0
  88. package/dist/lib/long-task-authority-revision-details.d.ts +19 -0
  89. package/dist/lib/long-task-authority-revision-details.js +192 -0
  90. package/dist/lib/long-task-authority-revision-enforcement.d.ts +3 -0
  91. package/dist/lib/long-task-authority-revision-enforcement.js +41 -0
  92. package/dist/lib/long-task-authority-revision-types.d.ts +50 -0
  93. package/dist/lib/long-task-authority-revision-types.js +1 -0
  94. package/dist/lib/long-task-authority-revision.d.ts +4 -0
  95. package/dist/lib/long-task-authority-revision.js +188 -0
  96. package/dist/lib/long-task-authority-transition-policy.d.ts +62 -0
  97. package/dist/lib/long-task-authority-transition-policy.js +62 -0
  98. package/dist/lib/long-task-authority-types.d.ts +96 -0
  99. package/dist/lib/long-task-authority-types.js +1 -0
  100. package/dist/lib/long-task-authority.d.ts +7 -0
  101. package/dist/lib/long-task-authority.js +142 -0
  102. package/dist/lib/long-task-boundary-check.d.ts +15 -0
  103. package/dist/lib/long-task-boundary-check.js +9 -0
  104. package/dist/lib/long-task-check-evidence-decoder.d.ts +3 -0
  105. package/dist/lib/long-task-check-evidence-decoder.js +74 -0
  106. package/dist/lib/long-task-check-execution-policy.d.ts +18 -0
  107. package/dist/lib/long-task-check-execution-policy.js +36 -0
  108. package/dist/lib/long-task-check-runner.d.ts +2 -0
  109. package/dist/lib/long-task-check-runner.js +181 -0
  110. package/dist/lib/long-task-check-shape.d.ts +2 -0
  111. package/dist/lib/long-task-check-shape.js +136 -0
  112. package/dist/lib/long-task-claim-definitions.d.ts +7 -0
  113. package/dist/lib/long-task-claim-definitions.js +78 -0
  114. package/dist/lib/long-task-claim-proof-policy.d.ts +4 -0
  115. package/dist/lib/long-task-claim-proof-policy.js +57 -0
  116. package/dist/lib/long-task-claims.d.ts +10 -0
  117. package/dist/lib/long-task-claims.js +187 -0
  118. package/dist/lib/long-task-context-authority-topology.d.ts +7 -0
  119. package/dist/lib/long-task-context-authority-topology.js +37 -0
  120. package/dist/lib/long-task-context-authority.d.ts +14 -0
  121. package/dist/lib/long-task-context-authority.js +66 -0
  122. package/dist/lib/long-task-contract-types.d.ts +203 -0
  123. package/dist/lib/long-task-contract-types.js +1 -0
  124. package/dist/lib/long-task-counterfactual-claim-policy.d.ts +10 -0
  125. package/dist/lib/long-task-counterfactual-claim-policy.js +57 -0
  126. package/dist/lib/long-task-counterfactual-sandbox.d.ts +6 -0
  127. package/dist/lib/long-task-counterfactual-sandbox.js +87 -0
  128. package/dist/lib/long-task-counterfactual-types.d.ts +24 -0
  129. package/dist/lib/long-task-counterfactual-types.js +1 -0
  130. package/dist/lib/long-task-delivery-compiler.d.ts +10 -0
  131. package/dist/lib/long-task-delivery-compiler.js +129 -0
  132. package/dist/lib/long-task-delivery-parser.d.ts +13 -0
  133. package/dist/lib/long-task-delivery-parser.js +90 -0
  134. package/dist/lib/long-task-delivery-preflight.d.ts +5 -0
  135. package/dist/lib/long-task-delivery-preflight.js +151 -0
  136. package/dist/lib/long-task-delivery-shape.d.ts +5 -0
  137. package/dist/lib/long-task-delivery-shape.js +5 -0
  138. package/dist/lib/long-task-delivery-types.d.ts +8 -0
  139. package/dist/lib/long-task-delivery-types.js +8 -0
  140. package/dist/lib/long-task-delivery-validation.d.ts +3 -0
  141. package/dist/lib/long-task-delivery-validation.js +175 -0
  142. package/dist/lib/long-task-evidence-adapter-policy.d.ts +4 -0
  143. package/dist/lib/long-task-evidence-adapter-policy.js +15 -0
  144. package/dist/lib/long-task-evidence-adapter-types.d.ts +1 -0
  145. package/dist/lib/long-task-evidence-adapter-types.js +1 -0
  146. package/dist/lib/long-task-evidence-findings.d.ts +5 -0
  147. package/dist/lib/long-task-evidence-findings.js +113 -0
  148. package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +4 -0
  149. package/dist/lib/long-task-evidence-sensitivity-policy.js +98 -0
  150. package/dist/lib/long-task-evidence-v2.d.ts +5 -0
  151. package/dist/lib/long-task-evidence-v2.js +226 -0
  152. package/dist/lib/long-task-explain-acceptance-link.d.ts +46 -0
  153. package/dist/lib/long-task-explain-acceptance-link.js +96 -0
  154. package/dist/lib/long-task-explain-claim-links.d.ts +45 -0
  155. package/dist/lib/long-task-explain-claim-links.js +88 -0
  156. package/dist/lib/long-task-explain-source-links.d.ts +93 -0
  157. package/dist/lib/long-task-explain-source-links.js +51 -0
  158. package/dist/lib/long-task-final-v2.d.ts +2 -0
  159. package/dist/lib/long-task-final-v2.js +124 -0
  160. package/dist/lib/long-task-finding-context.d.ts +3 -0
  161. package/dist/lib/long-task-finding-context.js +63 -0
  162. package/dist/lib/long-task-freshness.d.ts +3 -0
  163. package/dist/lib/long-task-freshness.js +80 -0
  164. package/dist/lib/long-task-hook-install.d.ts +9 -0
  165. package/dist/lib/long-task-hook-install.js +184 -0
  166. package/dist/lib/long-task-hook-preflight.d.ts +7 -0
  167. package/dist/lib/long-task-hook-preflight.js +58 -0
  168. package/dist/lib/long-task-observation-ownership.d.ts +2 -0
  169. package/dist/lib/long-task-observation-ownership.js +22 -0
  170. package/dist/lib/long-task-outcome-parser.d.ts +4 -0
  171. package/dist/lib/long-task-outcome-parser.js +100 -0
  172. package/dist/lib/long-task-paths.d.ts +49 -0
  173. package/dist/lib/long-task-paths.js +418 -0
  174. package/dist/lib/long-task-playwright-counterfactual-policy.d.ts +7 -0
  175. package/dist/lib/long-task-playwright-counterfactual-policy.js +125 -0
  176. package/dist/lib/long-task-playwright-evidence.d.ts +6 -0
  177. package/dist/lib/long-task-playwright-evidence.js +244 -0
  178. package/dist/lib/long-task-product-shape.d.ts +6 -0
  179. package/dist/lib/long-task-product-shape.js +73 -0
  180. package/dist/lib/long-task-progress.d.ts +4 -0
  181. package/dist/lib/long-task-progress.js +114 -0
  182. package/dist/lib/long-task-protected-files.d.ts +1 -0
  183. package/dist/lib/long-task-protected-files.js +30 -0
  184. package/dist/lib/long-task-required-proof-surfaces.d.ts +2 -0
  185. package/dist/lib/long-task-required-proof-surfaces.js +13 -0
  186. package/dist/lib/long-task-requirement-shape.d.ts +2 -0
  187. package/dist/lib/long-task-requirement-shape.js +18 -0
  188. package/dist/lib/long-task-risk-surfaces.d.ts +2 -0
  189. package/dist/lib/long-task-risk-surfaces.js +60 -0
  190. package/dist/lib/long-task-risk-types.d.ts +5 -0
  191. package/dist/lib/long-task-risk-types.js +12 -0
  192. package/dist/lib/long-task-risk.d.ts +9 -0
  193. package/dist/lib/long-task-risk.js +132 -0
  194. package/dist/lib/long-task-root-shape.d.ts +4 -0
  195. package/dist/lib/long-task-root-shape.js +86 -0
  196. package/dist/lib/long-task-runner-environment.d.ts +7 -0
  197. package/dist/lib/long-task-runner-environment.js +57 -0
  198. package/dist/lib/long-task-runner-files.d.ts +3 -0
  199. package/dist/lib/long-task-runner-files.js +39 -0
  200. package/dist/lib/long-task-runner-freeze.d.ts +2 -0
  201. package/dist/lib/long-task-runner-freeze.js +168 -0
  202. package/dist/lib/long-task-runtime-types.d.ts +214 -0
  203. package/dist/lib/long-task-runtime-types.js +1 -0
  204. package/dist/lib/long-task-shape-primitives.d.ts +17 -0
  205. package/dist/lib/long-task-shape-primitives.js +81 -0
  206. package/dist/lib/long-task-source-authority-types.d.ts +13 -0
  207. package/dist/lib/long-task-source-authority-types.js +1 -0
  208. package/dist/lib/long-task-source-claim-validation.d.ts +5 -0
  209. package/dist/lib/long-task-source-claim-validation.js +96 -0
  210. package/dist/lib/long-task-source-continuity.d.ts +4 -0
  211. package/dist/lib/long-task-source-continuity.js +57 -0
  212. package/dist/lib/long-task-source-inventory.d.ts +2 -0
  213. package/dist/lib/long-task-source-inventory.js +21 -0
  214. package/dist/lib/long-task-source-item-parser.d.ts +3 -0
  215. package/dist/lib/long-task-source-item-parser.js +112 -0
  216. package/dist/lib/long-task-source-shape.d.ts +2 -0
  217. package/dist/lib/long-task-source-shape.js +56 -0
  218. package/dist/lib/long-task-source-target-continuity.d.ts +4 -0
  219. package/dist/lib/long-task-source-target-continuity.js +80 -0
  220. package/dist/lib/long-task-source-target-index.d.ts +12 -0
  221. package/dist/lib/long-task-source-target-index.js +76 -0
  222. package/dist/lib/long-task-source-validation.d.ts +3 -0
  223. package/dist/lib/long-task-source-validation.js +46 -0
  224. package/dist/lib/long-task-state.d.ts +91 -0
  225. package/dist/lib/long-task-state.js +611 -0
  226. package/dist/lib/long-task-status-projection.d.ts +21 -0
  227. package/dist/lib/long-task-status-projection.js +116 -0
  228. package/dist/lib/long-task-status-v2.d.ts +37 -0
  229. package/dist/lib/long-task-status-v2.js +306 -0
  230. package/dist/lib/long-task-technical-shape.d.ts +3 -0
  231. package/dist/lib/long-task-technical-shape.js +44 -0
  232. package/dist/lib/long-task-verifier-authority.d.ts +12 -0
  233. package/dist/lib/long-task-verifier-authority.js +47 -0
  234. package/dist/lib/long-task-verifier-identity.d.ts +2 -0
  235. package/dist/lib/long-task-verifier-identity.js +55 -0
  236. package/dist/lib/long-task-verifier-v2.d.ts +13 -0
  237. package/dist/lib/long-task-verifier-v2.js +266 -0
  238. package/dist/lib/long-task-workspace-runtime-types.d.ts +23 -0
  239. package/dist/lib/long-task-workspace-runtime-types.js +1 -0
  240. package/dist/lib/long-task-workspace.d.ts +25 -0
  241. package/dist/lib/long-task-workspace.js +366 -0
  242. package/dist/lib/managed-file.js +20 -5
  243. package/dist/lib/migrations.js +156 -32
  244. package/dist/lib/modularity.d.ts +27 -1
  245. package/dist/lib/modularity.js +499 -23
  246. package/dist/lib/package-json-config.js +14 -5
  247. package/dist/lib/package-source.js +4 -2
  248. package/dist/lib/profiles.d.ts +13 -0
  249. package/dist/lib/profiles.js +66 -0
  250. package/dist/lib/schema-guard.js +4 -2
  251. package/dist/lib/source-files.js +14 -7
  252. package/dist/lib/source-pack-classify.js +91 -19
  253. package/dist/lib/source-pack-config.js +25 -8
  254. package/dist/lib/source-pack-export.js +84 -25
  255. package/dist/lib/source-pack-manifest.js +18 -6
  256. package/dist/lib/source-pack-records.js +35 -11
  257. package/dist/lib/source-pack-render.js +47 -18
  258. package/dist/lib/stable-json.d.ts +2 -0
  259. package/dist/lib/stable-json.js +21 -0
  260. package/dist/lib/strict-codec.d.ts +4 -0
  261. package/dist/lib/strict-codec.js +65 -0
  262. package/dist/lib/sync-engine.js +76 -24
  263. package/dist/lib/types.d.ts +8 -1
  264. package/dist/lib/upgrade.js +4 -3
  265. package/dist/lib/validators.js +218 -191
  266. package/dist/long-task-hook.d.ts +2 -0
  267. package/dist/long-task-hook.js +55 -0
  268. package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +340 -0
  269. package/dist/schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json +18 -0
  270. package/migrations/README.md +8 -3
  271. package/package.json +17 -6
  272. package/source-mappings.yaml +0 -3
  273. package/assets/protected-harness-baseline.json +0 -20
  274. package/assets/skills/composite-long-task-workflow/SKILL.md +0 -245
  275. package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -62
  276. package/assets/skills/composite-long-task-workflow/assets/goal-objective.template.md +0 -17
  277. package/assets/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md +0 -682
  278. package/dist/commands/superpowers.d.ts +0 -1
  279. package/dist/commands/superpowers.js +0 -8
  280. package/dist/lib/composite-long-task-renderer.d.ts +0 -12
  281. package/dist/lib/composite-long-task-renderer.js +0 -109
  282. package/dist/lib/plan-acceptance-artifacts.d.ts +0 -1
  283. package/dist/lib/plan-acceptance-artifacts.js +0 -220
  284. package/dist/lib/plan-acceptance-evidence.d.ts +0 -2
  285. package/dist/lib/plan-acceptance-evidence.js +0 -108
  286. package/dist/lib/plan-acceptance-json.d.ts +0 -15
  287. package/dist/lib/plan-acceptance-json.js +0 -133
  288. package/dist/lib/plan-acceptance-validator.d.ts +0 -2
  289. package/dist/lib/plan-acceptance-validator.js +0 -209
  290. package/dist/lib/plan-contract-validator.d.ts +0 -2
  291. package/dist/lib/plan-contract-validator.js +0 -127
  292. package/dist/lib/plan-validator-common.d.ts +0 -24
  293. package/dist/lib/plan-validator-common.js +0 -196
  294. package/dist/lib/superpowers-task-ac010.d.ts +0 -6
  295. package/dist/lib/superpowers-task-ac010.js +0 -26
  296. package/dist/lib/superpowers-task-assertion-normalizers.d.ts +0 -3
  297. package/dist/lib/superpowers-task-assertion-normalizers.js +0 -74
  298. package/dist/lib/superpowers-task-assertions.d.ts +0 -20
  299. package/dist/lib/superpowers-task-assertions.js +0 -257
  300. package/dist/lib/superpowers-task-attempt.d.ts +0 -4
  301. package/dist/lib/superpowers-task-attempt.js +0 -102
  302. package/dist/lib/superpowers-task-command-run-correlation.d.ts +0 -8
  303. package/dist/lib/superpowers-task-command-run-correlation.js +0 -103
  304. package/dist/lib/superpowers-task-command-specs.d.ts +0 -3
  305. package/dist/lib/superpowers-task-command-specs.js +0 -52
  306. package/dist/lib/superpowers-task-compile-diagnostics.d.ts +0 -5
  307. package/dist/lib/superpowers-task-compile-diagnostics.js +0 -20
  308. package/dist/lib/superpowers-task-compile-guards.d.ts +0 -2
  309. package/dist/lib/superpowers-task-compile-guards.js +0 -66
  310. package/dist/lib/superpowers-task-compile.d.ts +0 -6
  311. package/dist/lib/superpowers-task-compile.js +0 -133
  312. package/dist/lib/superpowers-task-completion-output.d.ts +0 -91
  313. package/dist/lib/superpowers-task-completion-output.js +0 -374
  314. package/dist/lib/superpowers-task-conformance.d.ts +0 -2
  315. package/dist/lib/superpowers-task-conformance.js +0 -24
  316. package/dist/lib/superpowers-task-contradictions.d.ts +0 -6
  317. package/dist/lib/superpowers-task-contradictions.js +0 -126
  318. package/dist/lib/superpowers-task-current-evidence.d.ts +0 -3
  319. package/dist/lib/superpowers-task-current-evidence.js +0 -176
  320. package/dist/lib/superpowers-task-delivery.d.ts +0 -4
  321. package/dist/lib/superpowers-task-delivery.js +0 -96
  322. package/dist/lib/superpowers-task-derive.d.ts +0 -14
  323. package/dist/lib/superpowers-task-derive.js +0 -393
  324. package/dist/lib/superpowers-task-events.d.ts +0 -1
  325. package/dist/lib/superpowers-task-events.js +0 -13
  326. package/dist/lib/superpowers-task-evidence-kernel.d.ts +0 -19
  327. package/dist/lib/superpowers-task-evidence-kernel.js +0 -347
  328. package/dist/lib/superpowers-task-evidence-records.d.ts +0 -2
  329. package/dist/lib/superpowers-task-evidence-records.js +0 -55
  330. package/dist/lib/superpowers-task-evidence.d.ts +0 -10
  331. package/dist/lib/superpowers-task-evidence.js +0 -147
  332. package/dist/lib/superpowers-task-fields.d.ts +0 -22
  333. package/dist/lib/superpowers-task-fields.js +0 -276
  334. package/dist/lib/superpowers-task-final-card.d.ts +0 -3
  335. package/dist/lib/superpowers-task-final-card.js +0 -35
  336. package/dist/lib/superpowers-task-gates.d.ts +0 -12
  337. package/dist/lib/superpowers-task-gates.js +0 -267
  338. package/dist/lib/superpowers-task-harness-drift.d.ts +0 -11
  339. package/dist/lib/superpowers-task-harness-drift.js +0 -90
  340. package/dist/lib/superpowers-task-next-slices.d.ts +0 -1
  341. package/dist/lib/superpowers-task-next-slices.js +0 -12
  342. package/dist/lib/superpowers-task-protected-baseline.d.ts +0 -10
  343. package/dist/lib/superpowers-task-protected-baseline.js +0 -66
  344. package/dist/lib/superpowers-task-source-compile.d.ts +0 -5
  345. package/dist/lib/superpowers-task-source-compile.js +0 -226
  346. package/dist/lib/superpowers-task-source-parser.d.ts +0 -23
  347. package/dist/lib/superpowers-task-source-parser.js +0 -218
  348. package/dist/lib/superpowers-task-state-schema.d.ts +0 -460
  349. package/dist/lib/superpowers-task-state-schema.js +0 -66
  350. package/dist/lib/superpowers-task-state-shape.d.ts +0 -3
  351. package/dist/lib/superpowers-task-state-shape.js +0 -50
  352. package/dist/lib/superpowers-task-state.d.ts +0 -16
  353. package/dist/lib/superpowers-task-state.js +0 -246
  354. package/dist/lib/superpowers-task-status.d.ts +0 -2
  355. package/dist/lib/superpowers-task-status.js +0 -24
  356. package/dist/lib/superpowers-task-under-specified.d.ts +0 -7
  357. package/dist/lib/superpowers-task-under-specified.js +0 -61
  358. package/dist/lib/superpowers-task-unregistered-evidence.d.ts +0 -11
  359. package/dist/lib/superpowers-task-unregistered-evidence.js +0 -72
  360. package/dist/lib/superpowers-task-validator.d.ts +0 -5
  361. package/dist/lib/superpowers-task-validator.js +0 -293
@@ -1,347 +0,0 @@
1
- import { deriveRequiredCommandSpecs } from "./superpowers-task-command-specs.js";
2
- import { validateCommandRunsForSpec, validateRequiredCommandCorrelation } from "./superpowers-task-command-run-correlation.js";
3
- import { evaluateAc010Bootstrap } from "./superpowers-task-ac010.js";
4
- import { evaluateCurrentAttemptArtifact } from "./superpowers-task-current-evidence.js";
5
- import { scanSuperpowersContradictions } from "./superpowers-task-contradictions.js";
6
- import { detectHarnessDrift } from "./superpowers-task-harness-drift.js";
7
- import { evaluateProtectedBaseline } from "./superpowers-task-protected-baseline.js";
8
- import { validateScopeConflicts } from "./superpowers-task-delivery.js";
9
- import { evaluateProofLayerAssertions, isMachineVerifiableLayer } from "./superpowers-task-assertions.js";
10
- import { scanUnregisteredAssertionEvidence } from "./superpowers-task-unregistered-evidence.js";
11
- import { findUnderSpecifiedAcs } from "./superpowers-task-under-specified.js";
12
- import { loadSuperpowersState, sourceRecords } from "./superpowers-task-state.js";
13
- export const TRUSTED_EVIDENCE_KERNEL_ORDER = [
14
- "load_three_inputs",
15
- "recompute_source_hashes",
16
- "load_task_state",
17
- "resolve_current_attempt",
18
- "load_required_command_specs",
19
- "load_command_run_records",
20
- "load_registered_evidence_records",
21
- "discard_stale_evidence",
22
- "scan_unregistered_assertion_json",
23
- "scan_contradictions",
24
- "run_ac010_bootstrap_prevention",
25
- "run_under_specified_ac_checks",
26
- "run_harness_drift_lock",
27
- "run_protected_baseline_guard",
28
- "validate_scope_conflicts",
29
- "recompute_every_ac",
30
- "recompute_every_pi",
31
- "recompute_acceptance_target_status",
32
- "recompute_product_goal_complete",
33
- "regenerate_derived",
34
- "append_final_gate_event"
35
- ];
36
- export async function evaluateTrustedEvidenceKernel(workdir, providedState) {
37
- const state = providedState ?? (await loadSuperpowersState(workdir));
38
- const errors = [];
39
- const acStatuses = {};
40
- const acFindings = {};
41
- const staleEvidenceIds = new Set();
42
- const invalidatedEvidenceIds = new Set();
43
- const attempt = currentAttempt(state);
44
- const currentSources = await sourceRecords(workdir);
45
- if (!attempt) {
46
- errors.push("missing current attempt: final-gate requires current_attempt_id with ExecutionAttempt");
47
- }
48
- else {
49
- validateAttemptAgainstSources(state, attempt, currentSources, errors);
50
- }
51
- const expectedSpecs = deriveRequiredCommandSpecs(state);
52
- const commandCorrelation = validateRequiredCommandCorrelation(state, attempt, expectedSpecs);
53
- errors.push(...commandCorrelation.errors);
54
- commandCorrelation.invalidated_evidence_ids.forEach((id) => invalidatedEvidenceIds.add(id));
55
- const underSpecified = new Map(findUnderSpecifiedAcs(state).map((item) => [item.ac_id, item.reasons]));
56
- for (const reasons of underSpecified.values()) {
57
- errors.push(...reasons);
58
- }
59
- const contradictionScan = await scanSuperpowersContradictions(workdir, state);
60
- errors.push(...contradictionScan.errors);
61
- const drift = detectHarnessDrift(state);
62
- errors.push(...drift.errors);
63
- const baseline = evaluateProtectedBaseline(state);
64
- errors.push(...baseline.errors);
65
- validateScopeConflicts(state, errors);
66
- const unregistered = await scanUnregisteredAssertionEvidence(workdir, state);
67
- errors.push(...unregistered.errors);
68
- const evidenceById = new Map((state.evidence ?? []).map((evidence) => [evidence.evidence_id, evidence]));
69
- for (const [acId, ac] of Object.entries(state.graph?.acceptance_criteria ?? {})) {
70
- const acErrors = [];
71
- if (underSpecified.has(acId)) {
72
- acStatuses[acId] = "under_specified";
73
- acFindings[acId] = underSpecified.get(acId) ?? [];
74
- continue;
75
- }
76
- const requiredLayers = ac.required_proof_layers ?? [];
77
- const spec = specForAc(state, expectedSpecs, acId);
78
- if ((ac.machine_blocking === true || ac.assertion_result_required === true) && !spec) {
79
- acErrors.push(`${acId} missing required_command_spec`);
80
- }
81
- if (spec) {
82
- acErrors.push(...validateCommandRunsForSpec(state, attempt, spec));
83
- }
84
- for (const layerName of requiredLayers) {
85
- const layerId = `${acId}.${layerName}`;
86
- const layer = state.graph.proof_layers?.[layerId];
87
- if (!layer || layer.status !== "satisfied") {
88
- acErrors.push(`${layerId} missing current satisfied proof layer`);
89
- continue;
90
- }
91
- if (isMachineVerifiableLayer(layerId)) {
92
- const evaluation = evaluateProofLayerAssertions(state, layerId);
93
- acErrors.push(...evaluation.blocking_assertion_failures, ...evaluation.negative_evidence_findings);
94
- for (const evidenceId of layer.evidence_ids ?? []) {
95
- const evidence = evidenceById.get(evidenceId);
96
- if (!evidence) {
97
- acErrors.push(`${layerId} references unregistered evidence ${evidenceId}`);
98
- continue;
99
- }
100
- acErrors.push(...validateEvidenceAgainstSpec(state, evidence, spec, layerId));
101
- acErrors.push(...(await evaluateCurrentAttemptArtifact(workdir, evidence, layerId)));
102
- if (invalidatedEvidenceIds.has(evidence.evidence_id)) {
103
- acErrors.push(`${layerId} evidence ${evidence.evidence_id} invalidated by newer failed command`);
104
- }
105
- if (isStaleEvidenceError(acErrors)) {
106
- staleEvidenceIds.add(evidence.evidence_id);
107
- }
108
- }
109
- }
110
- }
111
- errors.push(...acErrors);
112
- acStatuses[acId] = statusForAcErrors(acErrors, requiredLayers.length);
113
- acFindings[acId] = acErrors;
114
- }
115
- const ac010 = evaluateAc010Bootstrap(state, acStatuses);
116
- for (const acId of ac010.invalidated_ac_ids) {
117
- acStatuses[acId] = "invalidated";
118
- }
119
- errors.push(...ac010.errors);
120
- const piStatuses = recomputePlanStatuses(state, acStatuses);
121
- const piFindings = planFindings(state, acStatuses, piStatuses);
122
- const allAcsComplete = Object.keys(state.graph?.acceptance_criteria ?? {}).length > 0 &&
123
- Object.values(acStatuses).every((status) => status === "complete" || status === "out_of_scope_NA");
124
- const allPisComplete = Object.keys(state.graph?.plan_items ?? {}).length > 0 &&
125
- Object.values(piStatuses).every((status) => status === "complete" || status === "out_of_scope_NA");
126
- const uniqueErrors = unique(errors);
127
- const productComplete = uniqueErrors.length === 0 && allAcsComplete && allPisComplete && drift.product_goal_complete !== false && baseline.product_goal_complete !== false;
128
- return {
129
- product_goal_complete: productComplete,
130
- acceptance_target_status: productComplete ? "complete" : statusForGlobalErrors(uniqueErrors, acStatuses),
131
- errors: uniqueErrors,
132
- ac_statuses: acStatuses,
133
- pi_statuses: piStatuses,
134
- stale_evidence_ids: [...staleEvidenceIds],
135
- ignored_unregistered_evidence: unregistered.ignored,
136
- invalidated_evidence_ids: [...invalidatedEvidenceIds],
137
- kernel_order: [...TRUSTED_EVIDENCE_KERNEL_ORDER],
138
- ac_findings: acFindings,
139
- pi_findings: piFindings,
140
- harness_task_final_verdict: drift.harness_task_final_verdict
141
- };
142
- }
143
- export function applyTrustedEvidenceKernelResult(state, result) {
144
- for (const [acId, status] of Object.entries(result.ac_statuses)) {
145
- const ac = state.graph.acceptance_criteria[acId];
146
- if (ac) {
147
- ac.status = status;
148
- }
149
- }
150
- for (const [piId, status] of Object.entries(result.pi_statuses)) {
151
- const pi = state.graph.plan_items[piId];
152
- if (pi) {
153
- pi.status = status;
154
- }
155
- }
156
- state.final.product_goal_complete = result.product_goal_complete;
157
- state.meta.product_goal_complete = result.product_goal_complete;
158
- state.final.acceptance_target_status = result.acceptance_target_status;
159
- state.meta.acceptance_target_status = result.acceptance_target_status;
160
- state.final.audit_task_complete = true;
161
- state.meta.audit_task_complete = true;
162
- state.final.completion_basis = result.product_goal_complete
163
- ? ["trusted_evidence_kernel", "current_attempt_evidence", "negative_evidence_scan_passed", "harness_drift_lock_passed"]
164
- : [];
165
- state.final.next_required_actions = result.product_goal_complete ? [] : result.errors.slice(0, 12);
166
- state.gates.final_gate = {
167
- status: result.product_goal_complete ? "pass" : result.acceptance_target_status,
168
- kernel: "trusted_evidence_kernel",
169
- order: result.kernel_order,
170
- errors: result.errors,
171
- stale_evidence_ids: result.stale_evidence_ids,
172
- ignored_unregistered_evidence: result.ignored_unregistered_evidence,
173
- invalidated_evidence_ids: result.invalidated_evidence_ids,
174
- ac_findings: result.ac_findings,
175
- pi_findings: result.pi_findings,
176
- harness_task_final_verdict: result.harness_task_final_verdict,
177
- next_required_actions: state.final.next_required_actions
178
- };
179
- }
180
- function validateAttemptAgainstSources(state, attempt, currentSources, errors) {
181
- const productHash = currentSources.product_architecture_source?.sha256 ?? "";
182
- const planHash = currentSources.technical_realization_plan?.sha256 ?? "";
183
- const checklistHash = currentSources.acceptance_checklist?.sha256 ?? "";
184
- for (const [key, source] of Object.entries(currentSources)) {
185
- const expected = state.sources[key]?.sha256;
186
- if (expected && source.sha256 !== expected) {
187
- errors.push(`source hash mismatch for ${key}: expected ${expected}, actual ${source.sha256}; recompile graph before final-gate`);
188
- }
189
- }
190
- if (attempt.product_source_hash !== productHash) {
191
- errors.push("source hash mismatch: current attempt product_source_hash does not match product-architecture-source.md");
192
- }
193
- if (attempt.technical_plan_hash !== planHash) {
194
- errors.push("source hash mismatch: current attempt technical_plan_hash does not match technical-realization-plan.md");
195
- }
196
- if (attempt.acceptance_checklist_hash !== checklistHash) {
197
- errors.push("source hash mismatch: current attempt acceptance_checklist_hash does not match acceptance-checklist.md");
198
- }
199
- for (const field of [
200
- "task_attempt_id",
201
- "source_bundle_hash",
202
- "product_source_hash",
203
- "technical_plan_hash",
204
- "acceptance_checklist_hash",
205
- "git_head",
206
- "git_status_short",
207
- "tracked_diff_hash",
208
- "relevant_untracked_hash",
209
- "worktree_fingerprint",
210
- "started_at",
211
- "required_command_specs_hash",
212
- "mode"
213
- ]) {
214
- if (!attempt[field]) {
215
- errors.push(`current attempt missing required field ${field}`);
216
- }
217
- }
218
- }
219
- function validateEvidenceAgainstSpec(state, evidence, spec, layerId) {
220
- if (!spec) {
221
- return [];
222
- }
223
- const errors = [];
224
- const assertion = evidence.assertion_result;
225
- const label = `proof layer ${layerId} evidence ${evidence.evidence_id}`;
226
- const expectedPiIds = state.graph.acceptance_criteria[spec.ac_id]?.related_plan_items ?? [];
227
- const targetPiIds = evidence.target_pi_ids ?? assertion?.target_pi_ids ?? [];
228
- for (const piId of expectedPiIds) {
229
- if (!targetPiIds.includes(piId)) {
230
- errors.push(`${label} target_pi_ids ${targetPiIds.join(", ") || "(none)"} do not include ${piId}`);
231
- }
232
- }
233
- if (assertion) {
234
- const assertionIds = new Set(assertion.positive_assertions.map((item) => item.id));
235
- for (const id of spec.positive_assertions ?? []) {
236
- if (!assertionIds.has(id)) {
237
- errors.push(`${label} missing positive assertion ${id}`);
238
- }
239
- }
240
- const negativeIds = new Set(assertion.negative_assertions.map((item) => item.id));
241
- for (const id of spec.negative_assertions ?? []) {
242
- if (!negativeIds.has(id)) {
243
- errors.push(`${label} missing negative assertion ${id}`);
244
- }
245
- }
246
- const requiredTests = new Set(assertion.required_test_ids ?? []);
247
- for (const testId of spec.required_test_ids ?? []) {
248
- if (!requiredTests.has(testId)) {
249
- errors.push(`${label} assertion_result.required_test_ids missing ${testId}`);
250
- }
251
- }
252
- const invalidChecks = [
253
- ...((assertion.invalid_completion_signals ?? []).map((item) => `${item.id} ${item.forbidden_text ?? ""}`)),
254
- ...((assertion.negative_evidence_scan?.invalid_completion_signals_checked ?? []).map((item) => String(item)))
255
- ].join("\n");
256
- for (const signal of spec.invalid_completion_signals ?? []) {
257
- if (!invalidChecks.includes(signal)) {
258
- errors.push(`${label} invalid_completion_signals did not check ${signal}`);
259
- }
260
- }
261
- }
262
- return errors;
263
- }
264
- function specForAc(state, expectedSpecs, acId) {
265
- const actual = (state.required_command_specs ?? []).find((spec) => spec.ac_id === acId);
266
- if (actual) {
267
- return actual;
268
- }
269
- return expectedSpecs.find((spec) => spec.ac_id === acId);
270
- }
271
- function statusForAcErrors(errors, requiredLayerCount) {
272
- if (requiredLayerCount === 0) {
273
- return "not_run";
274
- }
275
- const text = errors.join("\n");
276
- if (!text) {
277
- return "complete";
278
- }
279
- if (/under_specified/i.test(text)) {
280
- return "under_specified";
281
- }
282
- if (/stale|failed|invalid|contradiction|negative evidence|forbidden|bootstrap/i.test(text)) {
283
- return "invalidated";
284
- }
285
- if (/blocked|harness_drift|protected_baseline|source hash mismatch/i.test(text)) {
286
- return "blocked";
287
- }
288
- return "partial";
289
- }
290
- function recomputePlanStatuses(state, acStatuses) {
291
- const statuses = {};
292
- for (const [planId, item] of Object.entries(state.graph?.plan_items ?? {})) {
293
- const relatedStatuses = (item.related_acs ?? []).map((acId) => acStatuses[acId] ?? state.graph.acceptance_criteria[acId]?.status ?? "not_run");
294
- if (relatedStatuses.length > 0 && relatedStatuses.every((status) => status === "complete" || status === "out_of_scope_NA")) {
295
- statuses[planId] = "complete";
296
- }
297
- else if (relatedStatuses.some((status) => status === "under_specified" || status === "blocked")) {
298
- statuses[planId] = "blocked";
299
- }
300
- else if (relatedStatuses.some((status) => status === "invalidated")) {
301
- statuses[planId] = "invalidated";
302
- }
303
- else if (relatedStatuses.some((status) => status === "partial")) {
304
- statuses[planId] = "partial";
305
- }
306
- else {
307
- statuses[planId] = "not_started";
308
- }
309
- }
310
- return statuses;
311
- }
312
- function planFindings(state, acStatuses, piStatuses) {
313
- const findings = {};
314
- for (const [planId, item] of Object.entries(state.graph?.plan_items ?? {})) {
315
- const related = item.related_acs ?? [];
316
- findings[planId] = related
317
- .filter((acId) => acStatuses[acId] && acStatuses[acId] !== "complete" && acStatuses[acId] !== "out_of_scope_NA")
318
- .map((acId) => `${acId} status=${acStatuses[acId]}`)
319
- .concat(piStatuses[planId] ? [`${planId} status=${piStatuses[planId]}`] : []);
320
- }
321
- return findings;
322
- }
323
- function statusForGlobalErrors(errors, acStatuses) {
324
- const text = errors.join("\n");
325
- if (Object.values(acStatuses).includes("under_specified") || /under_specified/i.test(text)) {
326
- return "under_specified";
327
- }
328
- if (/harness_drift|protected_baseline|source hash mismatch|missing current attempt|required_command_specs_hash|harness_task_missing|scope_conflict_requires_decision/i.test(text)) {
329
- return "blocked";
330
- }
331
- if (/stale|failed|invalid|contradiction|negative evidence|forbidden|bootstrap/i.test(text)) {
332
- return "invalidated";
333
- }
334
- return "partial";
335
- }
336
- function currentAttempt(state) {
337
- if (!state.current_attempt_id) {
338
- return undefined;
339
- }
340
- return (state.attempts ?? []).find((item) => item.task_attempt_id === state.current_attempt_id);
341
- }
342
- function isStaleEvidenceError(errors) {
343
- return errors.some((error) => /stale evidence|source_bundle_hash mismatch|artifact_sha256 mismatch|artifact_mtime/i.test(error));
344
- }
345
- function unique(values) {
346
- return [...new Set(values.filter(Boolean))];
347
- }
@@ -1,2 +0,0 @@
1
- import { type SuperpowersEvidenceRecord } from "./superpowers-task-state-schema.js";
2
- export declare function readEvidenceRecords(value: unknown): SuperpowersEvidenceRecord[];
@@ -1,55 +0,0 @@
1
- import { normalizeAssertionResult, normalizeNegativeEvidenceScan } from "./superpowers-task-assertion-normalizers.js";
2
- import { normalizeProofLayerId } from "./superpowers-task-fields.js";
3
- import { asStringArray, isRecord } from "./superpowers-task-state-schema.js";
4
- export function readEvidenceRecords(value) {
5
- if (!Array.isArray(value)) {
6
- return [];
7
- }
8
- return value.filter(isRecord).map((item) => ({
9
- evidence_id: String(item.evidence_id ?? item.evidenceId ?? ""),
10
- schema_version: item.schema_version === undefined ? undefined : String(item.schema_version),
11
- task_attempt_id: item.task_attempt_id === undefined ? undefined : String(item.task_attempt_id),
12
- source_bundle_hash: item.source_bundle_hash === undefined ? undefined : String(item.source_bundle_hash),
13
- product_source_hash: item.product_source_hash === undefined ? undefined : String(item.product_source_hash),
14
- technical_plan_hash: item.technical_plan_hash === undefined ? undefined : String(item.technical_plan_hash),
15
- acceptance_checklist_hash: item.acceptance_checklist_hash === undefined ? undefined : String(item.acceptance_checklist_hash),
16
- git_head: item.git_head === undefined ? undefined : String(item.git_head),
17
- worktree_fingerprint: item.worktree_fingerprint === undefined ? undefined : String(item.worktree_fingerprint),
18
- command_spec_id: item.command_spec_id === undefined ? undefined : String(item.command_spec_id),
19
- command_run_id: item.command_run_id === undefined ? undefined : String(item.command_run_id),
20
- command_line: item.command_line === undefined ? undefined : String(item.command_line),
21
- artifact_path: item.artifact_path === undefined ? undefined : String(item.artifact_path),
22
- artifact_sha256: item.artifact_sha256 === undefined ? undefined : String(item.artifact_sha256),
23
- artifact_mtime: item.artifact_mtime === undefined ? undefined : String(item.artifact_mtime),
24
- target_ac_ids: asStringArray(item.target_ac_ids),
25
- target_pi_ids: asStringArray(item.target_pi_ids),
26
- target_proof_layers: asStringArray(item.target_proof_layers).map(normalizeProofLayerId),
27
- slice_id: String(item.slice_id ?? item.sliceId ?? ""),
28
- type: String(item.type ?? ""),
29
- freshness: isRecord(item.freshness)
30
- ? {
31
- created_at: String(item.freshness.created_at ?? ""),
32
- valid_for: String(item.freshness.valid_for ?? ""),
33
- stale_after: item.freshness.stale_after === null ? null : item.freshness.stale_after === undefined ? null : String(item.freshness.stale_after)
34
- }
35
- : { created_at: "", valid_for: "", stale_after: null },
36
- command: item.command === undefined ? undefined : String(item.command),
37
- command_exit_code: item.command_exit_code === undefined ? undefined : Number(item.command_exit_code),
38
- artifact_paths: asStringArray(item.artifact_paths),
39
- proves: asStringArray(item.proves).map(normalizeProofLayerId),
40
- does_not_prove: asStringArray(item.does_not_prove).map((claim) => (claim.includes(".") ? normalizeProofLayerId(claim) : claim)),
41
- redaction: isRecord(item.redaction)
42
- ? { checked: item.redaction.checked === true, contains_secret: item.redaction.contains_secret === true }
43
- : { checked: false, contains_secret: false },
44
- reviewability: isRecord(item.reviewability)
45
- ? {
46
- external_reviewer_can_reproduce: item.reviewability.external_reviewer_can_reproduce === true,
47
- reproduction_steps: String(item.reviewability.reproduction_steps ?? "")
48
- }
49
- : { external_reviewer_can_reproduce: false, reproduction_steps: "" },
50
- assertion_result: normalizeAssertionResult(item.assertion_result),
51
- negative_evidence_scan: normalizeNegativeEvidenceScan(item.negative_evidence_scan),
52
- sibling_substitution_used: item.sibling_substitution_used === true,
53
- sibling_substitution_approval_source: item.sibling_substitution_approval_source === undefined ? undefined : String(item.sibling_substitution_approval_source)
54
- }));
55
- }
@@ -1,10 +0,0 @@
1
- import { type CommandRunRecord, type SuperpowersEvidenceRecord } from "./superpowers-task-state-schema.js";
2
- export declare function runSuperpowersAssertion(workdir: string, options: {
3
- acId: string;
4
- proofLayer: string;
5
- commandArgs: string[];
6
- }): Promise<CommandRunRecord>;
7
- export declare function recordSuperpowersEvidence(workdir: string, options: {
8
- artifactPath: string;
9
- commandRunId: string;
10
- }): Promise<SuperpowersEvidenceRecord>;
@@ -1,147 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { spawn } from "node:child_process";
3
- import { promises as fs } from "node:fs";
4
- import path from "node:path";
5
- import { pathExists, readText } from "./fs.js";
6
- import { appendSuperpowersEvent } from "./superpowers-task-events.js";
7
- import { computeSourceBundleHash } from "./superpowers-task-attempt.js";
8
- import { normalizeAssertionResult, normalizeNegativeEvidenceScan } from "./superpowers-task-assertions.js";
9
- import { normalizeProofLayerId, normalizeProofLayerName } from "./superpowers-task-fields.js";
10
- import { loadSuperpowersState, saveSuperpowersState, sha256 } from "./superpowers-task-state.js";
11
- import { asStringArray, isRecord } from "./superpowers-task-state-schema.js";
12
- export async function runSuperpowersAssertion(workdir, options) {
13
- if (!options.acId || !options.proofLayer) {
14
- throw new Error("run-assertion requires --ac <AC-ID> and --proof-layer <layer>");
15
- }
16
- if (options.commandArgs.length === 0) {
17
- throw new Error("run-assertion requires a command after --");
18
- }
19
- const state = await loadSuperpowersState(workdir);
20
- const proofLayer = normalizeProofLayerName(options.proofLayer);
21
- const spec = (state.required_command_specs ?? []).find((item) => item.ac_id === options.acId && item.proof_layers.map(normalizeProofLayerName).includes(proofLayer));
22
- if (!spec) {
23
- throw new Error(`no required command spec for ${options.acId}.${proofLayer}`);
24
- }
25
- const startedAt = new Date().toISOString();
26
- const exitCode = await runCommand(options.commandArgs);
27
- const endedAt = new Date().toISOString();
28
- const commandLine = options.commandArgs.join(" ");
29
- const commandRun = {
30
- command_run_id: `CR-${compactDate(startedAt)}-${sha256(commandLine).slice(0, 8)}`,
31
- task_attempt_id: state.current_attempt_id,
32
- command_spec_id: spec.command_spec_id,
33
- ac_id: options.acId,
34
- proof_layer: proofLayer,
35
- command_line: commandLine,
36
- exit_code: exitCode,
37
- started_at: startedAt,
38
- completed_at: endedAt,
39
- ended_at: endedAt,
40
- artifact_paths: []
41
- };
42
- state.command_runs = [...(state.command_runs ?? []), commandRun];
43
- await saveSuperpowersState(workdir, state);
44
- await appendSuperpowersEvent(workdir, "assertion_command_run", {
45
- command_run_id: commandRun.command_run_id,
46
- command_spec_id: commandRun.command_spec_id,
47
- exit_code: commandRun.exit_code
48
- });
49
- return commandRun;
50
- }
51
- export async function recordSuperpowersEvidence(workdir, options) {
52
- const state = await loadSuperpowersState(workdir);
53
- const commandRun = (state.command_runs ?? []).find((item) => item.command_run_id === options.commandRunId);
54
- if (!commandRun) {
55
- throw new Error(`command run not found: ${options.commandRunId}`);
56
- }
57
- const artifactPath = path.resolve(options.artifactPath);
58
- if (!(await pathExists(artifactPath))) {
59
- throw new Error(`evidence artifact not found: ${options.artifactPath}`);
60
- }
61
- const artifactText = await readText(artifactPath);
62
- const artifact = JSON.parse(artifactText);
63
- const artifactRecord = isRecord(artifact) ? artifact : {};
64
- const assertion = normalizeAssertionResult(artifactRecord.assertion_result ?? artifactRecord);
65
- if (!assertion) {
66
- throw new Error(`evidence artifact is missing assertion_result: ${options.artifactPath}`);
67
- }
68
- const stats = await fs.stat(artifactPath);
69
- const attempt = (state.attempts ?? []).find((item) => item.task_attempt_id === commandRun.task_attempt_id);
70
- const commandSpec = (state.required_command_specs ?? []).find((item) => item.command_spec_id === commandRun.command_spec_id);
71
- const layerId = normalizeProofLayerId(`${commandRun.ac_id}.${commandRun.proof_layer}`);
72
- const relativeArtifactPath = slash(path.relative(workdir, artifactPath));
73
- const targetPiIds = commandSpec ? (state.graph.acceptance_criteria[commandSpec.ac_id]?.related_plan_items ?? []) : [];
74
- const negativeScan = normalizeNegativeEvidenceScan(artifactRecord.negative_evidence_scan);
75
- if (assertion.schema_version === "assertion-result-v2") {
76
- assertion.target_pi_ids = assertion.target_pi_ids ?? targetPiIds;
77
- assertion.invalid_completion_signals = assertion.invalid_completion_signals ?? [];
78
- assertion.required_test_ids = assertion.required_test_ids ?? commandSpec?.required_test_ids ?? [];
79
- assertion.negative_evidence_scan = assertion.negative_evidence_scan ?? negativeScan;
80
- }
81
- const evidence = {
82
- schema_version: "evidence-record-v2",
83
- evidence_id: `EV2-${compactDate(new Date().toISOString())}-${sha256(options.commandRunId + artifactText).slice(0, 8)}`,
84
- task_attempt_id: commandRun.task_attempt_id,
85
- generated_at: new Date().toISOString(),
86
- source_bundle_hash: attempt?.source_bundle_hash ?? computeSourceBundleHash(state),
87
- product_source_hash: attempt?.product_source_hash ?? state.sources.product_architecture_source?.sha256 ?? "",
88
- technical_plan_hash: attempt?.technical_plan_hash ?? state.sources.technical_realization_plan?.sha256 ?? "",
89
- acceptance_checklist_hash: attempt?.acceptance_checklist_hash ?? state.sources.acceptance_checklist?.sha256 ?? "",
90
- git_head: attempt?.git_head ?? "",
91
- git_status_short: attempt?.git_status_short ?? "",
92
- tracked_diff_hash: attempt?.tracked_diff_hash ?? "",
93
- relevant_untracked_hash: attempt?.relevant_untracked_hash ?? "",
94
- covers_dirty_worktree: Boolean(attempt?.git_status_short?.trim()),
95
- worktree_fingerprint: attempt?.worktree_fingerprint ?? "",
96
- command_spec_id: commandRun.command_spec_id,
97
- command_run_id: commandRun.command_run_id,
98
- command_line: commandRun.command_line,
99
- command_exit_code: commandRun.exit_code,
100
- artifact_path: relativeArtifactPath,
101
- artifact_sha256: createHash("sha256").update(artifactText).digest("hex"),
102
- artifact_mtime: stats.mtime.toISOString(),
103
- target_ac_ids: [commandRun.ac_id],
104
- target_pi_ids: targetPiIds,
105
- target_proof_layers: [layerId],
106
- slice_id: String(artifactRecord.slice_id ?? "attempt-evidence"),
107
- type: String(artifactRecord.type ?? `${commandRun.proof_layer}_assertion`),
108
- freshness: { created_at: commandRun.completed_at ?? commandRun.ended_at, valid_for: "current_attempt", stale_after: null },
109
- command: commandRun.command_line,
110
- artifact_paths: [relativeArtifactPath],
111
- proves: [layerId],
112
- does_not_prove: asStringArray(artifactRecord.does_not_prove).length > 0 ? asStringArray(artifactRecord.does_not_prove) : ["unrelated proof layer"],
113
- redaction: isRecord(artifactRecord.redaction)
114
- ? { checked: artifactRecord.redaction.checked === true, contains_secret: artifactRecord.redaction.contains_secret === true }
115
- : { checked: true, contains_secret: false },
116
- reviewability: isRecord(artifactRecord.reviewability)
117
- ? {
118
- external_reviewer_can_reproduce: artifactRecord.reviewability.external_reviewer_can_reproduce === true,
119
- reproduction_steps: String(artifactRecord.reviewability.reproduction_steps ?? commandRun.command_line)
120
- }
121
- : { external_reviewer_can_reproduce: true, reproduction_steps: commandRun.command_line },
122
- assertion_result: assertion,
123
- negative_evidence_scan: negativeScan
124
- };
125
- state.evidence = [...(state.evidence ?? []), evidence];
126
- const proofLayer = state.graph.proof_layers[layerId];
127
- if (proofLayer && commandRun.exit_code === 0 && assertion.status === "passed") {
128
- proofLayer.status = "satisfied";
129
- proofLayer.evidence_ids = [...new Set([...(proofLayer.evidence_ids ?? []), evidence.evidence_id])];
130
- }
131
- await saveSuperpowersState(workdir, state);
132
- await appendSuperpowersEvent(workdir, "evidence_recorded", { evidence_id: evidence.evidence_id, command_run_id: commandRun.command_run_id });
133
- return evidence;
134
- }
135
- function runCommand(args) {
136
- return new Promise((resolve) => {
137
- const child = spawn(args[0], args.slice(1), { cwd: process.cwd(), stdio: "ignore", windowsHide: true });
138
- child.on("error", () => resolve(1));
139
- child.on("exit", (code) => resolve(code ?? 1));
140
- });
141
- }
142
- function compactDate(value) {
143
- return value.replace(/[-:.TZ]/g, "").slice(0, 17);
144
- }
145
- function slash(value) {
146
- return value.split(path.sep).join("/");
147
- }
@@ -1,22 +0,0 @@
1
- export declare const PRODUCT_FIELDS: readonly ["delivery_scope", "full_population_required", "representative_samples_validate", "representative_samples_do_not_validate", "out_of_scope_backlog", "scope_fit_decision", "selected_scope_fit_slice", "owner_boundary", "primary_capability_path", "non_completing_outcomes", "assertion_policy", "source_authority", "product_goal", "surface_ia_lock", "decision_lock", "context_delta", "source_to_context_coverage", "acceptance_semantics", "impact"];
2
- export declare const PLAN_FIELDS: readonly ["delivery_scope", "capability_target", "representative_samples", "full_population_boundary", "non_required_population", "owner_surfaces", "forbidden_surfaces", "owner_boundary", "primary_capability_path", "trigger_contract", "state_transition_contract", "observable_result_contract", "assertion_support", "required_assertion_commands", "invalid_implementation_shortcuts", "implementation_paths", "required_tests", "related_acs", "requirement_ref", "decision_id", "proof_layer_ids", "api_schema_changes", "state_machine", "data_flow", "worker_runtime_behavior", "ui_ia_changes", "migration_plan", "evidence_artifacts", "explicit_no_test_scope", "non_completing_shortcuts", "substitution_policy", "drift_severity", "partial_conditions", "blockers", "context_fact_refs"];
3
- export declare const ACCEPTANCE_FIELDS: readonly ["acceptance_scope", "ac_validates", "ac_does_not_validate", "sample_boundary", "full_population_required", "related_plan_items", "required_proof_layers", "assertion_command", "assertion_artifacts", "positive_assertions", "negative_assertions", "machine_blocking", "invalid_completion_signals", "assertion_result_required", "ac_type", "proof_chain", "verification_method", "fail_conditions", "invalid_evidence", "substitution_policy", "missing_layer_downgrade", "auditor_expectation", "out_of_scope_na_approval_source", "required_test_ids", "explicit_no_test_scope", "hard_blockers", "validates_explanation", "does_not_validate_explanation", "final_evidence_expected", "test_cases"];
4
- export declare const PRODUCT_REQUIRED_FIELDS: readonly ["delivery_scope", "full_population_required", "representative_samples_validate", "representative_samples_do_not_validate", "out_of_scope_backlog", "scope_fit_decision", "selected_scope_fit_slice", "owner_boundary", "primary_capability_path", "non_completing_outcomes", "assertion_policy", "source_authority", "product_goal"];
5
- export declare const PLAN_REQUIRED_FIELDS: readonly ["delivery_scope", "capability_target", "representative_samples", "full_population_boundary", "non_required_population", "owner_boundary", "primary_capability_path", "trigger_contract", "state_transition_contract", "observable_result_contract", "assertion_support", "required_assertion_commands", "invalid_implementation_shortcuts", "implementation_paths"];
6
- export declare const ACCEPTANCE_REQUIRED_FIELDS: readonly ["acceptance_scope", "ac_validates", "ac_does_not_validate", "sample_boundary", "full_population_required", "related_plan_items", "required_proof_layers", "assertion_command", "assertion_artifacts", "positive_assertions", "negative_assertions", "machine_blocking", "invalid_completion_signals", "assertion_result_required"];
7
- type FieldType = "array" | "boolean" | "enum" | "text";
8
- export declare const PRODUCT_FIELD_TYPES: Record<(typeof PRODUCT_FIELDS)[number], FieldType>;
9
- export declare const PLAN_FIELD_TYPES: Record<(typeof PLAN_FIELDS)[number], FieldType>;
10
- export declare const ACCEPTANCE_FIELD_TYPES: Record<(typeof ACCEPTANCE_FIELDS)[number], FieldType>;
11
- export declare const PRODUCT_DELIVERY_SCOPES: Set<string>;
12
- export declare const PLAN_DELIVERY_SCOPES: Set<string>;
13
- export declare const ACCEPTANCE_SCOPES: Set<string>;
14
- export declare const SCOPE_FIT_DECISIONS: Set<string>;
15
- export declare const CANONICAL_PROOF_LAYERS: readonly ["code", "api_schema", "worker_runtime", "data_artifact", "integration", "ui_browser", "security_redaction", "all_provider_all_runner", "cleanup_stale_scan", "test"];
16
- export declare const LEGACY_PROOF_LAYER_ALIASES: Record<string, string>;
17
- export declare const MACHINE_VERIFIABLE_LAYER_NAMES: Set<string>;
18
- export declare function fieldSet(fields: readonly string[]): Set<string>;
19
- export declare function normalizeProofLayerName(layer: string): string;
20
- export declare function normalizeProofLayerId(layerId: string): string;
21
- export declare function isSelectedScopeFitSlice(value: string): boolean;
22
- export {};