audit-tools 0.52.5 → 0.54.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 (384) hide show
  1. package/dist/audit/cli/auditStep.d.ts +1 -1
  2. package/dist/audit/cli/conceptualDispatch.d.ts +2 -2
  3. package/dist/audit/cli/conceptualDispatch.d.ts.map +1 -1
  4. package/dist/audit/cli/conceptualDispatch.js +6 -5
  5. package/dist/audit/cli/conceptualDispatch.js.map +1 -1
  6. package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
  7. package/dist/audit/cli/confirmIntentStep.js +3 -16
  8. package/dist/audit/cli/confirmIntentStep.js.map +1 -1
  9. package/dist/audit/cli/dispatch/hostHandoff.d.ts +2 -0
  10. package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
  11. package/dist/audit/cli/dispatch/hostHandoff.js +22 -1
  12. package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
  13. package/dist/audit/cli/dispatch/packetFilter.d.ts +1 -1
  14. package/dist/audit/cli/dispatch/packetFilter.d.ts.map +1 -1
  15. package/dist/audit/cli/dispatch/packetFilter.js +1 -1
  16. package/dist/audit/cli/dispatch/packetFilter.js.map +1 -1
  17. package/dist/audit/cli/functionalPreflight.d.ts.map +1 -1
  18. package/dist/audit/cli/functionalPreflight.js +6 -3
  19. package/dist/audit/cli/functionalPreflight.js.map +1 -1
  20. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  21. package/dist/audit/cli/nextStepCommand.js +57 -34
  22. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  23. package/dist/audit/cli/nextStepHelpers.d.ts +3 -3
  24. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  25. package/dist/audit/cli/nextStepHelpers.js +52 -77
  26. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  27. package/dist/audit/cli/prompts.d.ts +1 -2
  28. package/dist/audit/cli/prompts.d.ts.map +1 -1
  29. package/dist/audit/cli/prompts.js +2 -12
  30. package/dist/audit/cli/prompts.js.map +1 -1
  31. package/dist/audit/cli/sampleRunCommand.d.ts +2 -2
  32. package/dist/audit/cli/semanticReviewStep.d.ts +11 -2
  33. package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
  34. package/dist/audit/cli/semanticReviewStep.js +14 -10
  35. package/dist/audit/cli/semanticReviewStep.js.map +1 -1
  36. package/dist/audit/contracts/workerSchemas.d.ts +14 -14
  37. package/dist/audit/contracts/wrapperResponse.d.ts +6 -6
  38. package/dist/audit/extractors/graphRoutes.d.ts.map +1 -1
  39. package/dist/audit/extractors/graphRoutes.js +1 -3
  40. package/dist/audit/extractors/graphRoutes.js.map +1 -1
  41. package/dist/audit/io/artifacts.d.ts.map +1 -1
  42. package/dist/audit/io/artifacts.js +2 -3
  43. package/dist/audit/io/artifacts.js.map +1 -1
  44. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  45. package/dist/audit/orchestrator/advance.js +21 -1
  46. package/dist/audit/orchestrator/advance.js.map +1 -1
  47. package/dist/audit/orchestrator/architectureDiscovery.d.ts +25 -0
  48. package/dist/audit/orchestrator/architectureDiscovery.d.ts.map +1 -0
  49. package/dist/audit/orchestrator/architectureDiscovery.js +193 -0
  50. package/dist/audit/orchestrator/architectureDiscovery.js.map +1 -0
  51. package/dist/audit/orchestrator/dependencyMap.d.ts +20 -0
  52. package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
  53. package/dist/audit/orchestrator/dependencyMap.js +47 -0
  54. package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
  55. package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -1
  56. package/dist/audit/orchestrator/dependencySlices.js +37 -3
  57. package/dist/audit/orchestrator/dependencySlices.js.map +1 -1
  58. package/dist/audit/orchestrator/designReviewProjection.d.ts +2 -6
  59. package/dist/audit/orchestrator/designReviewProjection.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/designReviewProjection.js +2 -6
  61. package/dist/audit/orchestrator/designReviewProjection.js.map +1 -1
  62. package/dist/audit/orchestrator/designReviewPrompt.d.ts +2 -2
  63. package/dist/audit/orchestrator/designReviewPrompt.js +2 -2
  64. package/dist/audit/orchestrator/designReviewSnapshot.d.ts +2 -3
  65. package/dist/audit/orchestrator/designReviewSnapshot.d.ts.map +1 -1
  66. package/dist/audit/orchestrator/designReviewSnapshot.js +2 -3
  67. package/dist/audit/orchestrator/designReviewSnapshot.js.map +1 -1
  68. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  69. package/dist/audit/orchestrator/executorRunners.js +1 -22
  70. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  71. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  72. package/dist/audit/orchestrator/executors.js +0 -12
  73. package/dist/audit/orchestrator/executors.js.map +1 -1
  74. package/dist/audit/orchestrator/ingestionExecutors.d.ts.map +1 -1
  75. package/dist/audit/orchestrator/ingestionExecutors.js +38 -37
  76. package/dist/audit/orchestrator/ingestionExecutors.js.map +1 -1
  77. package/dist/audit/orchestrator/nextStep.d.ts +2 -28
  78. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  79. package/dist/audit/orchestrator/nextStep.js +4 -37
  80. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  81. package/dist/audit/orchestrator/obligationDerive.d.ts +2 -3
  82. package/dist/audit/orchestrator/obligationDerive.d.ts.map +1 -1
  83. package/dist/audit/orchestrator/obligationDerive.js +2 -3
  84. package/dist/audit/orchestrator/obligationDerive.js.map +1 -1
  85. package/dist/audit/orchestrator/pendingTasks.d.ts +2 -0
  86. package/dist/audit/orchestrator/pendingTasks.d.ts.map +1 -1
  87. package/dist/audit/orchestrator/pendingTasks.js +5 -1
  88. package/dist/audit/orchestrator/pendingTasks.js.map +1 -1
  89. package/dist/audit/orchestrator/planningExecutors.d.ts.map +1 -1
  90. package/dist/audit/orchestrator/planningExecutors.js +9 -0
  91. package/dist/audit/orchestrator/planningExecutors.js.map +1 -1
  92. package/dist/audit/orchestrator/requeueCommand.d.ts +1 -1
  93. package/dist/audit/orchestrator/resultBaseline.d.ts +5 -5
  94. package/dist/audit/orchestrator/resultBaseline.d.ts.map +1 -1
  95. package/dist/audit/orchestrator/resultBaseline.js +24 -47
  96. package/dist/audit/orchestrator/resultBaseline.js.map +1 -1
  97. package/dist/audit/orchestrator/selectiveDeepening/findingFollowup.d.ts.map +1 -1
  98. package/dist/audit/orchestrator/selectiveDeepening/findingFollowup.js +2 -0
  99. package/dist/audit/orchestrator/selectiveDeepening/findingFollowup.js.map +1 -1
  100. package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
  101. package/dist/audit/orchestrator/staleness.js +14 -10
  102. package/dist/audit/orchestrator/staleness.js.map +1 -1
  103. package/dist/audit/orchestrator/state.js +1 -1
  104. package/dist/audit/orchestrator/state.js.map +1 -1
  105. package/dist/audit/orchestrator/synthesisExecutors.d.ts.map +1 -1
  106. package/dist/audit/orchestrator/synthesisExecutors.js +3 -0
  107. package/dist/audit/orchestrator/synthesisExecutors.js.map +1 -1
  108. package/dist/audit/types/auditState.d.ts +6 -6
  109. package/dist/audit/types/flowCoverage.d.ts +6 -6
  110. package/dist/audit/types.d.ts +24 -13
  111. package/dist/audit/types.d.ts.map +1 -1
  112. package/dist/audit/types.js +92 -11
  113. package/dist/audit/types.js.map +1 -1
  114. package/dist/remediate/contractPipeline/executionPlan.d.ts +1908 -0
  115. package/dist/remediate/contractPipeline/executionPlan.d.ts.map +1 -0
  116. package/dist/remediate/contractPipeline/executionPlan.js +467 -0
  117. package/dist/remediate/contractPipeline/executionPlan.js.map +1 -0
  118. package/dist/remediate/contractPipeline/runtimePlanAuthority.d.ts +12 -0
  119. package/dist/remediate/contractPipeline/runtimePlanAuthority.d.ts.map +1 -0
  120. package/dist/remediate/contractPipeline/runtimePlanAuthority.js +41 -0
  121. package/dist/remediate/contractPipeline/runtimePlanAuthority.js.map +1 -0
  122. package/dist/remediate/dedup/crossLensDedup.d.ts +3 -16
  123. package/dist/remediate/dedup/crossLensDedup.d.ts.map +1 -1
  124. package/dist/remediate/dedup/crossLensDedup.js +2 -32
  125. package/dist/remediate/dedup/crossLensDedup.js.map +1 -1
  126. package/dist/remediate/index.d.ts +2 -19
  127. package/dist/remediate/index.d.ts.map +1 -1
  128. package/dist/remediate/index.js +22 -138
  129. package/dist/remediate/index.js.map +1 -1
  130. package/dist/remediate/intake.d.ts +10 -10
  131. package/dist/remediate/intent/intentOrdering.d.ts +6 -8
  132. package/dist/remediate/intent/intentOrdering.d.ts.map +1 -1
  133. package/dist/remediate/intent/intentOrdering.js +24 -47
  134. package/dist/remediate/intent/intentOrdering.js.map +1 -1
  135. package/dist/remediate/phases/close.d.ts +25 -17
  136. package/dist/remediate/phases/close.d.ts.map +1 -1
  137. package/dist/remediate/phases/close.js +278 -218
  138. package/dist/remediate/phases/close.js.map +1 -1
  139. package/dist/remediate/phases/closeAcceptance.d.ts +42 -0
  140. package/dist/remediate/phases/closeAcceptance.d.ts.map +1 -0
  141. package/dist/remediate/phases/closeAcceptance.js +66 -0
  142. package/dist/remediate/phases/closeAcceptance.js.map +1 -0
  143. package/dist/remediate/phases/closeReviewProvenance.d.ts +1 -1
  144. package/dist/remediate/phases/closeReviewProvenance.d.ts.map +1 -1
  145. package/dist/remediate/phases/closeReviewProvenance.js +9 -8
  146. package/dist/remediate/phases/closeReviewProvenance.js.map +1 -1
  147. package/dist/remediate/phases/closeVerifyAnalyzerLeads.d.ts.map +1 -1
  148. package/dist/remediate/phases/closeVerifyAnalyzerLeads.js +11 -9
  149. package/dist/remediate/phases/closeVerifyAnalyzerLeads.js.map +1 -1
  150. package/dist/remediate/phases/closeVerifyHeadEvidence.d.ts +21 -86
  151. package/dist/remediate/phases/closeVerifyHeadEvidence.d.ts.map +1 -1
  152. package/dist/remediate/phases/closeVerifyHeadEvidence.js +30 -19
  153. package/dist/remediate/phases/closeVerifyHeadEvidence.js.map +1 -1
  154. package/dist/remediate/phases/plan.d.ts +3 -60
  155. package/dist/remediate/phases/plan.d.ts.map +1 -1
  156. package/dist/remediate/phases/plan.js +3 -227
  157. package/dist/remediate/phases/plan.js.map +1 -1
  158. package/dist/remediate/phases/triage.d.ts.map +1 -1
  159. package/dist/remediate/phases/triage.js +19 -30
  160. package/dist/remediate/phases/triage.js.map +1 -1
  161. package/dist/remediate/riskSignal.d.ts +9 -43
  162. package/dist/remediate/riskSignal.d.ts.map +1 -1
  163. package/dist/remediate/riskSignal.js +7 -28
  164. package/dist/remediate/riskSignal.js.map +1 -1
  165. package/dist/remediate/state/disposition.d.ts +2 -1
  166. package/dist/remediate/state/disposition.d.ts.map +1 -1
  167. package/dist/remediate/state/disposition.js +37 -1
  168. package/dist/remediate/state/disposition.js.map +1 -1
  169. package/dist/remediate/state/runIdentity.d.ts +2 -13
  170. package/dist/remediate/state/runIdentity.d.ts.map +1 -1
  171. package/dist/remediate/state/runIdentity.js +3 -13
  172. package/dist/remediate/state/runIdentity.js.map +1 -1
  173. package/dist/remediate/state/store.d.ts +12 -36
  174. package/dist/remediate/state/store.d.ts.map +1 -1
  175. package/dist/remediate/state/store.js +58 -150
  176. package/dist/remediate/state/store.js.map +1 -1
  177. package/dist/remediate/state/types.d.ts +406 -504
  178. package/dist/remediate/state/types.d.ts.map +1 -1
  179. package/dist/remediate/state/types.js +24 -104
  180. package/dist/remediate/state/types.js.map +1 -1
  181. package/dist/remediate/steps/contractPipeline.d.ts +7 -661
  182. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  183. package/dist/remediate/steps/contractPipeline.js +264 -3851
  184. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  185. package/dist/remediate/steps/contractPipelinePrompts.d.ts +20 -142
  186. package/dist/remediate/steps/contractPipelinePrompts.d.ts.map +1 -1
  187. package/dist/remediate/steps/contractPipelinePrompts.js +48 -581
  188. package/dist/remediate/steps/contractPipelinePrompts.js.map +1 -1
  189. package/dist/remediate/steps/dispatch/contractConformanceReview.d.ts +4 -1
  190. package/dist/remediate/steps/dispatch/contractConformanceReview.d.ts.map +1 -1
  191. package/dist/remediate/steps/dispatch/contractConformanceReview.js +6 -3
  192. package/dist/remediate/steps/dispatch/contractConformanceReview.js.map +1 -1
  193. package/dist/remediate/steps/dispatch/hostContracts.d.ts +1 -1
  194. package/dist/remediate/steps/dispatch/hostContracts.d.ts.map +1 -1
  195. package/dist/remediate/steps/dispatch/hostHandoff.d.ts +4 -21
  196. package/dist/remediate/steps/dispatch/hostHandoff.d.ts.map +1 -1
  197. package/dist/remediate/steps/dispatch/hostHandoff.js +161 -383
  198. package/dist/remediate/steps/dispatch/hostHandoff.js.map +1 -1
  199. package/dist/remediate/steps/finalGate.d.ts +34 -0
  200. package/dist/remediate/steps/finalGate.d.ts.map +1 -1
  201. package/dist/remediate/steps/finalGate.js +44 -4
  202. package/dist/remediate/steps/finalGate.js.map +1 -1
  203. package/dist/remediate/steps/frictionCloseout.d.ts +1 -30
  204. package/dist/remediate/steps/frictionCloseout.d.ts.map +1 -1
  205. package/dist/remediate/steps/frictionCloseout.js +6 -99
  206. package/dist/remediate/steps/frictionCloseout.js.map +1 -1
  207. package/dist/remediate/steps/nextStep.d.ts +2 -15
  208. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  209. package/dist/remediate/steps/nextStep.js +254 -1042
  210. package/dist/remediate/steps/nextStep.js.map +1 -1
  211. package/dist/remediate/steps/prompts.js +16 -16
  212. package/dist/remediate/steps/prompts.js.map +1 -1
  213. package/dist/remediate/steps/stepUtils.d.ts +1 -1
  214. package/dist/remediate/steps/stepUtils.d.ts.map +1 -1
  215. package/dist/remediate/steps/types.d.ts +1 -1
  216. package/dist/remediate/steps/types.d.ts.map +1 -1
  217. package/dist/remediate/steps/types.js +1 -1
  218. package/dist/remediate/steps/types.js.map +1 -1
  219. package/dist/remediate/types/options.d.ts +9 -0
  220. package/dist/remediate/types/options.d.ts.map +1 -1
  221. package/dist/remediate/validation/artifacts.d.ts.map +1 -1
  222. package/dist/remediate/validation/artifacts.js +10 -56
  223. package/dist/remediate/validation/artifacts.js.map +1 -1
  224. package/dist/remediate/validation/remediationState.d.ts +2 -2
  225. package/dist/remediate/validation/remediationState.d.ts.map +1 -1
  226. package/dist/remediate/validation/remediationState.js +17 -77
  227. package/dist/remediate/validation/remediationState.js.map +1 -1
  228. package/dist/remediate/validation/verificationReport.d.ts +3 -0
  229. package/dist/remediate/validation/verificationReport.d.ts.map +1 -0
  230. package/dist/remediate/validation/verificationReport.js +28 -0
  231. package/dist/remediate/validation/verificationReport.js.map +1 -0
  232. package/dist/shared/analyzers/types.d.ts +10 -10
  233. package/dist/shared/engine/obligationEngine.d.ts +2 -2
  234. package/dist/shared/friction/triage.d.ts +7 -28
  235. package/dist/shared/friction/triage.d.ts.map +1 -1
  236. package/dist/shared/friction/triage.js +7 -28
  237. package/dist/shared/friction/triage.js.map +1 -1
  238. package/dist/shared/graph/orderedReachability.js +1 -1
  239. package/dist/shared/graph/orderedReachability.js.map +1 -1
  240. package/dist/shared/index.d.ts +5 -6
  241. package/dist/shared/index.d.ts.map +1 -1
  242. package/dist/shared/index.js +3 -4
  243. package/dist/shared/index.js.map +1 -1
  244. package/dist/shared/loopCorePaths.d.ts.map +1 -1
  245. package/dist/shared/loopCorePaths.js +37 -5
  246. package/dist/shared/loopCorePaths.js.map +1 -1
  247. package/dist/shared/prompts.d.ts +24 -10
  248. package/dist/shared/prompts.d.ts.map +1 -1
  249. package/dist/shared/prompts.js +27 -13
  250. package/dist/shared/prompts.js.map +1 -1
  251. package/dist/shared/reReview/projectionDiff.d.ts.map +1 -1
  252. package/dist/shared/reReview/projectionDiff.js +6 -14
  253. package/dist/shared/reReview/projectionDiff.js.map +1 -1
  254. package/dist/shared/types/executionPlan.d.ts +416 -0
  255. package/dist/shared/types/executionPlan.d.ts.map +1 -0
  256. package/dist/shared/types/executionPlan.js +132 -0
  257. package/dist/shared/types/executionPlan.js.map +1 -0
  258. package/dist/shared/types/remediationOutcome.d.ts +1378 -12
  259. package/dist/shared/types/remediationOutcome.d.ts.map +1 -1
  260. package/dist/shared/types/remediationOutcome.js +29 -1
  261. package/dist/shared/types/remediationOutcome.js.map +1 -1
  262. package/dist/shared/types/{contractPipeline/verification.d.ts → verificationReport.d.ts} +9 -37
  263. package/dist/shared/types/verificationReport.d.ts.map +1 -0
  264. package/dist/shared/types/verificationReport.js +4 -0
  265. package/dist/shared/types/verificationReport.js.map +1 -0
  266. package/dist/shared/validation/findingGrounding.d.ts +3 -5
  267. package/dist/shared/validation/findingGrounding.d.ts.map +1 -1
  268. package/dist/shared/validation/findingGrounding.js +4 -7
  269. package/dist/shared/validation/findingGrounding.js.map +1 -1
  270. package/package.json +2 -1
  271. package/scripts/shared/primitives.mjs +20 -0
  272. package/skills/audit-code/SKILL.md +5 -12
  273. package/skills/audit-code/audit-code.prompt.md +5 -8
  274. package/skills/audit-code/opencode-command-template.txt +2 -2
  275. package/skills/remediate-code/SKILL.md +5 -7
  276. package/skills/remediate-code/remediate-code.prompt.md +5 -5
  277. package/dispatch/lens-definitions.json +0 -46
  278. package/dist/remediate/contractPipeline/artifactNames.d.ts +0 -8
  279. package/dist/remediate/contractPipeline/artifactNames.d.ts.map +0 -1
  280. package/dist/remediate/contractPipeline/artifactNames.js +0 -28
  281. package/dist/remediate/contractPipeline/artifactNames.js.map +0 -1
  282. package/dist/remediate/contractPipeline/artifactStore.d.ts +0 -219
  283. package/dist/remediate/contractPipeline/artifactStore.d.ts.map +0 -1
  284. package/dist/remediate/contractPipeline/artifactStore.js +0 -436
  285. package/dist/remediate/contractPipeline/artifactStore.js.map +0 -1
  286. package/dist/remediate/contractPipeline/changeClassification.d.ts +0 -130
  287. package/dist/remediate/contractPipeline/changeClassification.d.ts.map +0 -1
  288. package/dist/remediate/contractPipeline/changeClassification.js +0 -446
  289. package/dist/remediate/contractPipeline/changeClassification.js.map +0 -1
  290. package/dist/remediate/contractPipeline/contractReviewBinding.d.ts +0 -28
  291. package/dist/remediate/contractPipeline/contractReviewBinding.d.ts.map +0 -1
  292. package/dist/remediate/contractPipeline/contractReviewBinding.js +0 -75
  293. package/dist/remediate/contractPipeline/contractReviewBinding.js.map +0 -1
  294. package/dist/remediate/contractPipeline/counterexampleFingerprint.d.ts +0 -27
  295. package/dist/remediate/contractPipeline/counterexampleFingerprint.d.ts.map +0 -1
  296. package/dist/remediate/contractPipeline/counterexampleFingerprint.js +0 -37
  297. package/dist/remediate/contractPipeline/counterexampleFingerprint.js.map +0 -1
  298. package/dist/remediate/contractPipeline/cyclicSeamResolution.d.ts +0 -131
  299. package/dist/remediate/contractPipeline/cyclicSeamResolution.d.ts.map +0 -1
  300. package/dist/remediate/contractPipeline/cyclicSeamResolution.js +0 -257
  301. package/dist/remediate/contractPipeline/cyclicSeamResolution.js.map +0 -1
  302. package/dist/remediate/contractPipeline/derive.d.ts +0 -173
  303. package/dist/remediate/contractPipeline/derive.d.ts.map +0 -1
  304. package/dist/remediate/contractPipeline/derive.js +0 -477
  305. package/dist/remediate/contractPipeline/derive.js.map +0 -1
  306. package/dist/remediate/contractPipeline/finalizedContractFields.d.ts +0 -50
  307. package/dist/remediate/contractPipeline/finalizedContractFields.d.ts.map +0 -1
  308. package/dist/remediate/contractPipeline/finalizedContractFields.js +0 -77
  309. package/dist/remediate/contractPipeline/finalizedContractFields.js.map +0 -1
  310. package/dist/remediate/contractPipeline/idRegistry.d.ts +0 -144
  311. package/dist/remediate/contractPipeline/idRegistry.d.ts.map +0 -1
  312. package/dist/remediate/contractPipeline/idRegistry.js +0 -214
  313. package/dist/remediate/contractPipeline/idRegistry.js.map +0 -1
  314. package/dist/remediate/contractPipeline/obligationKinds.d.ts +0 -27
  315. package/dist/remediate/contractPipeline/obligationKinds.d.ts.map +0 -1
  316. package/dist/remediate/contractPipeline/obligationKinds.js +0 -18
  317. package/dist/remediate/contractPipeline/obligationKinds.js.map +0 -1
  318. package/dist/remediate/contractPipeline/phaseCut.d.ts +0 -125
  319. package/dist/remediate/contractPipeline/phaseCut.d.ts.map +0 -1
  320. package/dist/remediate/contractPipeline/phaseCut.js +0 -339
  321. package/dist/remediate/contractPipeline/phaseCut.js.map +0 -1
  322. package/dist/remediate/contractPipeline/phaseCutArtifact.d.ts +0 -31
  323. package/dist/remediate/contractPipeline/phaseCutArtifact.d.ts.map +0 -1
  324. package/dist/remediate/contractPipeline/phaseCutArtifact.js +0 -48
  325. package/dist/remediate/contractPipeline/phaseCutArtifact.js.map +0 -1
  326. package/dist/remediate/contractPipeline/repairState.d.ts +0 -110
  327. package/dist/remediate/contractPipeline/repairState.d.ts.map +0 -1
  328. package/dist/remediate/contractPipeline/repairState.js +0 -185
  329. package/dist/remediate/contractPipeline/repairState.js.map +0 -1
  330. package/dist/remediate/contractPipeline/reviewSnapshot.d.ts +0 -79
  331. package/dist/remediate/contractPipeline/reviewSnapshot.d.ts.map +0 -1
  332. package/dist/remediate/contractPipeline/reviewSnapshot.js +0 -140
  333. package/dist/remediate/contractPipeline/reviewSnapshot.js.map +0 -1
  334. package/dist/remediate/contractPipeline/semanticProjection.d.ts +0 -64
  335. package/dist/remediate/contractPipeline/semanticProjection.d.ts.map +0 -1
  336. package/dist/remediate/contractPipeline/semanticProjection.js +0 -136
  337. package/dist/remediate/contractPipeline/semanticProjection.js.map +0 -1
  338. package/dist/remediate/contractPipeline/sketchSource.d.ts +0 -194
  339. package/dist/remediate/contractPipeline/sketchSource.d.ts.map +0 -1
  340. package/dist/remediate/contractPipeline/sketchSource.js +0 -262
  341. package/dist/remediate/contractPipeline/sketchSource.js.map +0 -1
  342. package/dist/remediate/contractPipeline/testPlanCarry.d.ts +0 -17
  343. package/dist/remediate/contractPipeline/testPlanCarry.d.ts.map +0 -1
  344. package/dist/remediate/contractPipeline/testPlanCarry.js +0 -72
  345. package/dist/remediate/contractPipeline/testPlanCarry.js.map +0 -1
  346. package/dist/remediate/steps/dispatch/marshal.d.ts +0 -7
  347. package/dist/remediate/steps/dispatch/marshal.d.ts.map +0 -1
  348. package/dist/remediate/steps/dispatch/marshal.js +0 -11
  349. package/dist/remediate/steps/dispatch/marshal.js.map +0 -1
  350. package/dist/remediate/validation/contractPipeline.d.ts +0 -35
  351. package/dist/remediate/validation/contractPipeline.d.ts.map +0 -1
  352. package/dist/remediate/validation/contractPipeline.js +0 -613
  353. package/dist/remediate/validation/contractPipeline.js.map +0 -1
  354. package/dist/remediate/validation/contractPipelineGates.d.ts +0 -272
  355. package/dist/remediate/validation/contractPipelineGates.d.ts.map +0 -1
  356. package/dist/remediate/validation/contractPipelineGates.js +0 -1397
  357. package/dist/remediate/validation/contractPipelineGates.js.map +0 -1
  358. package/dist/shared/types/contractPipeline/design.d.ts +0 -79
  359. package/dist/shared/types/contractPipeline/design.d.ts.map +0 -1
  360. package/dist/shared/types/contractPipeline/design.js +0 -16
  361. package/dist/shared/types/contractPipeline/design.js.map +0 -1
  362. package/dist/shared/types/contractPipeline/goal.d.ts +0 -41
  363. package/dist/shared/types/contractPipeline/goal.d.ts.map +0 -1
  364. package/dist/shared/types/contractPipeline/goal.js +0 -10
  365. package/dist/shared/types/contractPipeline/goal.js.map +0 -1
  366. package/dist/shared/types/contractPipeline/implementation.d.ts +0 -118
  367. package/dist/shared/types/contractPipeline/implementation.d.ts.map +0 -1
  368. package/dist/shared/types/contractPipeline/implementation.js +0 -13
  369. package/dist/shared/types/contractPipeline/implementation.js.map +0 -1
  370. package/dist/shared/types/contractPipeline/obligations.d.ts +0 -283
  371. package/dist/shared/types/contractPipeline/obligations.d.ts.map +0 -1
  372. package/dist/shared/types/contractPipeline/obligations.js +0 -84
  373. package/dist/shared/types/contractPipeline/obligations.js.map +0 -1
  374. package/dist/shared/types/contractPipeline/verification.d.ts.map +0 -1
  375. package/dist/shared/types/contractPipeline/verification.js +0 -10
  376. package/dist/shared/types/contractPipeline/verification.js.map +0 -1
  377. package/dist/shared/types/contractPipeline.d.ts +0 -48
  378. package/dist/shared/types/contractPipeline.d.ts.map +0 -1
  379. package/dist/shared/types/contractPipeline.js +0 -32
  380. package/dist/shared/types/contractPipeline.js.map +0 -1
  381. package/dist/shared/types/obligationLedger.d.ts +0 -39
  382. package/dist/shared/types/obligationLedger.d.ts.map +0 -1
  383. package/dist/shared/types/obligationLedger.js +0 -49
  384. package/dist/shared/types/obligationLedger.js.map +0 -1
@@ -1,173 +0,0 @@
1
- /**
2
- * Deterministic derivers for contract-pipeline artifacts.
3
- *
4
- * S1 of the contract-authoring determinism design
5
- * (`spec/contract-authoring-determinism-design.md`): the contract pipeline
6
- * historically had the LLM author every structured artifact and the backend
7
- * only validate it afterward. For the artifacts whose *structure* is a pure
8
- * function of an upstream artifact, that is wasted generation and a weak-model
9
- * failure surface ("emit a large, schema-conforming, internally-consistent JSON
10
- * artifact from scratch with correct ids and cross-refs"). This module owns
11
- * those derivations so the tool produces the structure and the model is left
12
- * only the irreducible judgment.
13
- *
14
- * `deriveObligationLedger` is the flagship: the obligation ledger is a 1:1
15
- * restructuring of the finalized module contracts — every module invariant and
16
- * failure mode becomes an obligation, and every module gets a
17
- * contract-conformance obligation — so no judgment is lost by generating it in
18
- * code. Construction goes through the shared `buildObligationLedger` so the
19
- * cycle check, version stamp, and envelope stay single-sourced with the rest of
20
- * the codebase (the non-negotiable "derivers and validators share one source —
21
- * no parallel logic").
22
- */
23
- import { type ObligationLedger } from "audit-tools/shared";
24
- import { isTestablePhaseObligation } from "../validation/contractPipelineGates.js";
25
- /** Options accepted by the derivers (created_at injected for deterministic tests). */
26
- export interface DeriveOptions {
27
- /** Overrides the generated ISO-8601 timestamp (for deterministic snapshots). */
28
- created_at?: string;
29
- }
30
- /**
31
- * Derive the obligation ledger deterministically from the finalized module
32
- * contracts. Pure function of its input (modulo the `created_at` stamp): the
33
- * same contracts always yield the same obligations in the same order, so the
34
- * artifact hash / staleness DAG stays well-behaved.
35
- *
36
- * Mapping (the inverse of the obligation-ledger consumers' expectations):
37
- * - one **structural** obligation per module ("implement this module per its
38
- * finalized contract") — guarantees the ledger is never empty and every
39
- * module has something the implementation DAG must cover, without inventing
40
- * a paired-test burden (structural is not a testable kind);
41
- * - one **invariant** obligation per declared module invariant (testable);
42
- * - one **behavioral** obligation per declared module failure mode (testable).
43
- *
44
- * `depends_on` is left empty: the validated module-contract shape declares no
45
- * inter-obligation ordering, so an honest derivation asserts none (and the
46
- * ledger is acyclic by construction — `buildObligationLedger` cannot throw).
47
- */
48
- export declare function deriveObligationLedger(finalizedModuleContracts: unknown, options?: DeriveOptions): ObligationLedger;
49
- export declare function deriveFinalizedModuleContracts(draftedModuleContracts: unknown, seamReconciliationReport: unknown, options?: DeriveOptions): {
50
- contract_version: string;
51
- goal_id: string;
52
- module_contracts: unknown[];
53
- created_at: string;
54
- };
55
- /**
56
- * Shared obligation-membership predicates — the single source for which
57
- * obligations each downstream scaffold covers.
58
- *
59
- * `isTestablePhaseObligation` (imported above) is now single-sourced in
60
- * `../validation/contractPipelineGates.ts` (MNT-e10b9d9b: this file's former
61
- * local TESTABLE_KINDS set and that file's TESTABLE_OBLIGATION_KINDS were
62
- * "kept in parity by hand" and had already diverged — fail-open here,
63
- * fail-closed there, on an identical unrecognized-kind input). Re-exported
64
- * here so every existing importer of derive.js keeps working unchanged.
65
- *
66
- * `isDagPhaseObligation`: every obligation is covered by the implementation DAG,
67
- * so this is always true. It exists so both scaffolds derive their membership
68
- * from a named predicate rather than an inline ad-hoc filter.
69
- */
70
- export { isTestablePhaseObligation };
71
- export declare function isDagPhaseObligation(_kind: string): boolean;
72
- export interface TestValidatorPlanScaffold {
73
- test_specs: Array<{
74
- obligation_id: string;
75
- name: string;
76
- kind: string;
77
- /**
78
- * The change's scope anchors (touched symbols / file) the negative assertion
79
- * must name to pass the CE-006 negative-scoping gate. Derived here so the
80
- * host sees them IN the skeleton instead of discovering them only after a
81
- * write is rejected (D1). Advisory context — the host reads them, the gate
82
- * enforces them; an empty array means no change-scope constraint applies.
83
- */
84
- scope_anchors: string[];
85
- assertions: string[];
86
- }>;
87
- }
88
- /**
89
- * A prior round's authored test spec, keyed by obligation_id, used to diff-carry
90
- * unchanged assertions across a re-emit (C3). Carries the identity signals
91
- * (`name` + `scope_anchors`) the carry decision is gated on plus the assertions.
92
- */
93
- export interface PriorTestSpec {
94
- name: string;
95
- scope_anchors: string[];
96
- assertions: string[];
97
- }
98
- /**
99
- * Build the test-plan skeleton: one spec per *testable* (invariant/behavioral)
100
- * obligation, with `obligation_id`/`name`/`kind`/`scope_anchors` filled and
101
- * `assertions` left blank for the model. The model fills only the assertions
102
- * (each spec needs a paired positive + negative assertion per the OBL-CO-01
103
- * gate, and the negative must name one of `scope_anchors` per CE-006).
104
- *
105
- * C3 diff-carry: when `priorByObligation` carries a prior round's authored spec
106
- * for an obligation whose premise is UNCHANGED (same `name` + same
107
- * `scope_anchors`), its assertions are pre-filled instead of left blank, so an
108
- * unchanged obligation is not re-authored from scratch every repair round. A
109
- * changed premise (renamed/re-scoped obligation) carries nothing — the host
110
- * re-authors it (fail-safe toward re-author, never toward stale carry).
111
- */
112
- export declare function buildTestValidatorPlanScaffold(ledger: ObligationLedger | undefined, priorByObligation?: Record<string, PriorTestSpec>): TestValidatorPlanScaffold;
113
- export interface ImplementationDagScaffoldNode {
114
- id: string;
115
- title: string;
116
- description: string;
117
- satisfies_obligations: string[];
118
- addresses_counterexamples: string[];
119
- /**
120
- * Advisory conceptual-critique item ids this node addresses (B3). The
121
- * conceptual-design critique's `advisory`-severity items have no obligation or
122
- * counterexample to attach to, so without a structural slot the host smuggles
123
- * them into prose or test assertions. This carrier gives each one a first-class
124
- * home: the host records which advisory items a node's implementation honours.
125
- * Blank in the skeleton (the host fills it); advisory, so it is not gated.
126
- */
127
- addressed_critique_items: string[];
128
- depends_on: string[];
129
- verification_obligation_ids: string[];
130
- targeted_commands: string[];
131
- status: string;
132
- }
133
- /** An advisory conceptual-critique item the host should account for in the DAG. */
134
- export interface AdvisoryCritiqueItem {
135
- id: string;
136
- description: string;
137
- }
138
- /**
139
- * Advisory-severity items from a conceptual_design_critique payload (defensive
140
- * read). Blocking items drive the design-repair loop and are consumed there;
141
- * advisory items survive past the critique gate and need a structural home in
142
- * the implementation DAG — this surfaces them so the skeleton can list them (B3).
143
- */
144
- export declare function advisoryCritiqueItems(critique: unknown): AdvisoryCritiqueItem[];
145
- export interface ImplementationDagScaffold {
146
- nodes: ImplementationDagScaffoldNode[];
147
- edges: never[];
148
- }
149
- /** Accepted counterexample ids from a judge_report payload (defensive read). */
150
- export declare function acceptedCounterexampleIds(judgeReport: unknown): string[];
151
- /**
152
- * Build the implementation-DAG skeleton: ONE node per finalized *module*
153
- * (grouping all that module's obligations), blank title/description/
154
- * targeted_commands for the model, and accepted counterexamples attached so
155
- * coverage holds by construction. Grouping by module means a 1-module change
156
- * derives 1 node instead of N obligation-nodes the host then has to merge (B2);
157
- * obligations with no module home (counterexample/critique-sourced) fall back
158
- * to one node each. Advisory: the model fills the blanks and may further
159
- * merge/split nodes as long as coverage is preserved.
160
- *
161
- * `depends_on` is DERIVED, not left for the host: when `finalizedContracts` is
162
- * supplied, each module node depends on the nodes of the modules it needs first
163
- * (producer/consumer `artifact:<name>` matching over `inputs`/`outputs` — the
164
- * same module-dependency DAG `phase_cut` uses). This
165
- * makes cross-node ordering tool-enforced instead of a thing the host must
166
- * remember to hand-add. Edges are oriented by phase ordinal so the result is
167
- * acyclic by construction: only an edge to a strictly-earlier-phase module is
168
- * kept, which drops the back-edge of any dependency cycle (fail-toward-later,
169
- * mirroring `derivePhaseCut`). The `edges` array stays empty — node `depends_on`
170
- * is the ordering the block promotion reads.
171
- */
172
- export declare function buildImplementationDagScaffold(ledger: ObligationLedger | undefined, acceptedCeIds: string[], finalizedContracts?: unknown): ImplementationDagScaffold;
173
- //# sourceMappingURL=derive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../../src/remediate/contractPipeline/derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAe5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAOnF,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,wBAAwB,EAAE,OAAO,EACjC,OAAO,GAAE,aAAkB,GAC1B,gBAAgB,CA6DlB;AAiFD,wBAAgB,8BAA8B,CAC5C,sBAAsB,EAAE,OAAO,EAC/B,wBAAwB,EAAE,OAAO,EACjC,OAAO,GAAE,aAAkB,GAC1B;IACD,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAsCA;AAaD;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3D;AASD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,KAAK,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb;;;;;;WAMG;QACH,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,iBAAiB,GAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,GACpD,yBAAyB,CA6B3B;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC;;;;;;;OAOG;IACH,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,2BAA2B,EAAE,MAAM,EAAE,CAAC;IACtC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,oBAAoB,EAAE,CAW/E;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,6BAA6B,EAAE,CAAC;IACvC,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,CAgBxE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,aAAa,EAAE,MAAM,EAAE,EACvB,kBAAkB,CAAC,EAAE,OAAO,GAC3B,yBAAyB,CAwD3B"}
@@ -1,477 +0,0 @@
1
- /**
2
- * Deterministic derivers for contract-pipeline artifacts.
3
- *
4
- * S1 of the contract-authoring determinism design
5
- * (`spec/contract-authoring-determinism-design.md`): the contract pipeline
6
- * historically had the LLM author every structured artifact and the backend
7
- * only validate it afterward. For the artifacts whose *structure* is a pure
8
- * function of an upstream artifact, that is wasted generation and a weak-model
9
- * failure surface ("emit a large, schema-conforming, internally-consistent JSON
10
- * artifact from scratch with correct ids and cross-refs"). This module owns
11
- * those derivations so the tool produces the structure and the model is left
12
- * only the irreducible judgment.
13
- *
14
- * `deriveObligationLedger` is the flagship: the obligation ledger is a 1:1
15
- * restructuring of the finalized module contracts — every module invariant and
16
- * failure mode becomes an obligation, and every module gets a
17
- * contract-conformance obligation — so no judgment is lost by generating it in
18
- * code. Construction goes through the shared `buildObligationLedger` so the
19
- * cycle check, version stamp, and envelope stay single-sourced with the rest of
20
- * the codebase (the non-negotiable "derivers and validators share one source —
21
- * no parallel logic").
22
- */
23
- import { buildObligationLedger, isRecord, mintUniqueId, } from "audit-tools/shared";
24
- import { buildBaselineSymbolCorpus, classifyObligationChange, obligationScopeAnchors, readObligationChangeClassification, } from "./changeClassification.js";
25
- import { derivePhaseCut, phaseCutModulesFromContracts } from "./phaseCut.js";
26
- import { coerceGoalId, obligationId } from "./idRegistry.js";
27
- import { COPIED_MODULE_CONTRACT_FIELDS, DERIVED_MODULE_CONTRACT_FIELDS, } from "./finalizedContractFields.js";
28
- import { CP_FINALIZED_MODULE_CONTRACTS_VERSION } from "../validation/contractPipeline.js";
29
- import { isTestablePhaseObligation } from "../validation/contractPipelineGates.js";
30
- /**
31
- * Derive the obligation ledger deterministically from the finalized module
32
- * contracts. Pure function of its input (modulo the `created_at` stamp): the
33
- * same contracts always yield the same obligations in the same order, so the
34
- * artifact hash / staleness DAG stays well-behaved.
35
- *
36
- * Mapping (the inverse of the obligation-ledger consumers' expectations):
37
- * - one **structural** obligation per module ("implement this module per its
38
- * finalized contract") — guarantees the ledger is never empty and every
39
- * module has something the implementation DAG must cover, without inventing
40
- * a paired-test burden (structural is not a testable kind);
41
- * - one **invariant** obligation per declared module invariant (testable);
42
- * - one **behavioral** obligation per declared module failure mode (testable).
43
- *
44
- * `depends_on` is left empty: the validated module-contract shape declares no
45
- * inter-obligation ordering, so an honest derivation asserts none (and the
46
- * ledger is acyclic by construction — `buildObligationLedger` cannot throw).
47
- */
48
- export function deriveObligationLedger(finalizedModuleContracts, options = {}) {
49
- const finalized = readFinalizedContracts(finalizedModuleContracts);
50
- const usedIds = new Set();
51
- const obligations = [];
52
- // DC-5: baseline corpus of pre-existing symbols, built once from the declared
53
- // interface surface. A testable obligation that references a symbol in here is
54
- // classified a behavior CHANGE (deterministic FIRST pass); otherwise an
55
- // ADDITION. The verdict is recorded on each obligation so the paired-test gate
56
- // is driven by data, not by render-only prose (CE-013).
57
- const baselineSymbols = buildBaselineSymbolCorpus(finalizedModuleContracts);
58
- for (const mod of finalized.module_contracts) {
59
- // Contract-conformance obligation — represents the module even when it
60
- // declares no invariants/failure modes (structural kind → not testable).
61
- obligations.push({
62
- id: mintUniqueId(usedIds, obligationId(mod.name, "contract")),
63
- description: `Implement module "${mod.name}" per its finalized contract ` +
64
- `(inputs: ${fmtList(mod.inputs)} → outputs: ${fmtList(mod.outputs)}; ` +
65
- `validation boundary: ${mod.validation_boundary || "n/a"}).`,
66
- kind: "structural",
67
- depends_on: [],
68
- status: "pending",
69
- source: "design_spec",
70
- module: mod.name,
71
- });
72
- mod.invariants.forEach((invariant, i) => {
73
- obligations.push({
74
- id: mintUniqueId(usedIds, obligationId(mod.name, `inv-${i + 1}`)),
75
- description: invariant,
76
- kind: "invariant",
77
- depends_on: [],
78
- status: "pending",
79
- source: "design_spec",
80
- module: mod.name,
81
- change_classification: classifyObligationChange(invariant, baselineSymbols),
82
- });
83
- });
84
- mod.failure_modes.forEach((failureMode, j) => {
85
- obligations.push({
86
- id: mintUniqueId(usedIds, obligationId(mod.name, `fail-${j + 1}`)),
87
- description: `Handle failure mode: ${failureMode}`,
88
- kind: "behavioral",
89
- depends_on: [],
90
- status: "pending",
91
- source: "design_spec",
92
- module: mod.name,
93
- change_classification: classifyObligationChange(failureMode, baselineSymbols),
94
- });
95
- });
96
- }
97
- return buildObligationLedger({
98
- goal_id: finalized.goal_id,
99
- obligations,
100
- created_at: options.created_at,
101
- });
102
- }
103
- // ── Finalized module contracts (deterministic attach) ─────────────────────────
104
- //
105
- // `contract_finalization` is a mechanical merge, not fresh authoring: it takes
106
- // the drafted module contracts and the seam-reconciliation decisions and, per
107
- // module, carries the draft interface verbatim while attaching the
108
- // `agreed_interface` of every seam that touches the module as a `seam_adjustment`.
109
- // No source is re-read and no judgment is spent — the judgment already happened
110
- // upstream (the seam_reconciliation phase decided each mismatch's resolution).
111
- // Attaching each agreed interface verbatim guarantees the reconciliation-derivation
112
- // gate (INV-CO-12) passes, since its corpus is the union of every module's
113
- // inputs/outputs/invariants/side_effects/seam_adjustments/validation_boundary.
114
- //
115
- // `neighbor_needs` is DROPPED at finalization (open-bugs.md:106). It is the
116
- // drafting phase's seam-negotiation vocabulary — symmetric coordination prose
117
- // whose directions per-module agents routinely invert — and when it was
118
- // preserved and unioned into the dependency graph, prose overrode every
119
- // declared `artifact:<name>` token edge and manufactured cycles the
120
- // fail-toward-later tiering then mis-phased. Implementation ordering derives
121
- // from the producer/consumer token graph ALONE. A weaker draft that leaves
122
- // inputs/outputs token-free simply declares no ordering constraint; a seam
123
- // report referencing a module not in scope still surfaces at the downstream
124
- // design/reconciliation gate and routes to an LLM re-author of
125
- // `contract_finalization` — the only path that still needs judgment.
126
- /** The seam-reconciliation `agreed_interface`s that touch a given module name. */
127
- function seamAdjustmentsForModule(moduleName, seamReconciliationReport) {
128
- const mismatches = isRecord(seamReconciliationReport) && Array.isArray(seamReconciliationReport.mismatches)
129
- ? seamReconciliationReport.mismatches
130
- : [];
131
- const adjustments = [];
132
- for (const mismatch of mismatches) {
133
- if (!isRecord(mismatch))
134
- continue;
135
- if (mismatch.module_a !== moduleName && mismatch.module_b !== moduleName)
136
- continue;
137
- const resolution = isRecord(mismatch.resolution) ? mismatch.resolution : undefined;
138
- const agreed = resolution && typeof resolution.agreed_interface === "string"
139
- ? resolution.agreed_interface
140
- : "";
141
- if (agreed.length === 0)
142
- continue;
143
- const seamId = typeof mismatch.seam_id === "string" ? mismatch.seam_id : "";
144
- adjustments.push(seamId ? `${seamId}: ${agreed}` : agreed);
145
- }
146
- return adjustments;
147
- }
148
- /**
149
- * Derive `finalized_module_contracts` deterministically from the drafted
150
- * `module_contracts` and the `seam_reconciliation_report`. Pure function of its
151
- * inputs (modulo the `created_at` stamp): the same drafts + seam report always
152
- * yield the same finalized contracts in draft order, so the artifact hash /
153
- * staleness DAG stays well-behaved.
154
- *
155
- * Each finalized entry copies the draft's interface fields verbatim (already
156
- * validated `string[]` / string shapes, so no coercion is needed) and DROPS
157
- * `neighbor_needs` (ordering derives from the artifact-token graph alone), then
158
- * sets `seam_adjustments` to the `agreed_interface`(s) of the seams that touch
159
- * the module. A draft entry that is not an object is passed through unchanged
160
- * (the downstream validator reports it).
161
- */
162
- /**
163
- * The producer for each DERIVED module-contract field, keyed by the SAME union
164
- * the field list is drawn from — so adding a derived field to the vocabulary
165
- * without a producer here is a compile error rather than a field that silently
166
- * finalizes as `undefined` and then fails validation on every module.
167
- */
168
- const DERIVED_MODULE_CONTRACT_VALUES = {
169
- seam_adjustments: (moduleName, seamReconciliationReport) => seamAdjustmentsForModule(moduleName, seamReconciliationReport),
170
- };
171
- export function deriveFinalizedModuleContracts(draftedModuleContracts, seamReconciliationReport, options = {}) {
172
- // Validated on the way IN, never read verbatim. `goal_id` is the identity
173
- // joining every contract-pipeline artifact and the key the consistency gate
174
- // compares, and the LLM is its only producer — so the previous
175
- // `typeof === "string"` read admitted `""`, an unsubstituted
176
- // `<stable-identifier>` placeholder, and a free-text sentence alike, and the
177
- // join silently degraded to "no identity" instead of failing. The grammar
178
- // lives in the id registry beside the other mints; see `GOAL_ID_PATTERN`.
179
- const goalId = isRecord(draftedModuleContracts)
180
- ? coerceGoalId(draftedModuleContracts.goal_id)
181
- : "";
182
- const drafts = isRecord(draftedModuleContracts) && Array.isArray(draftedModuleContracts.module_contracts)
183
- ? draftedModuleContracts.module_contracts
184
- : [];
185
- const module_contracts = drafts.map((mod) => {
186
- if (!isRecord(mod) || typeof mod.name !== "string")
187
- return mod;
188
- // COPIED first, DERIVED second, both drawn from the ONE field vocabulary
189
- // (`finalizedContractFields.ts`). The literal this replaced was the third
190
- // hand-written copy of the shape; a field added here and missed in the
191
- // reader narrowed every downstream silently.
192
- const finalized = Object.fromEntries(COPIED_MODULE_CONTRACT_FIELDS.map((field) => [field, mod[field]]));
193
- for (const field of DERIVED_MODULE_CONTRACT_FIELDS) {
194
- finalized[field] = DERIVED_MODULE_CONTRACT_VALUES[field](mod.name, seamReconciliationReport);
195
- }
196
- return finalized;
197
- });
198
- return {
199
- contract_version: CP_FINALIZED_MODULE_CONTRACTS_VERSION,
200
- goal_id: goalId,
201
- module_contracts,
202
- created_at: options.created_at ?? new Date().toISOString(),
203
- };
204
- }
205
- // ── Scaffolds (S3): skeletons for the partially-derivable artifacts ────────────
206
- //
207
- // The test plan and implementation DAG have an irreducible judgment slot
208
- // (assertion text; node title/description/commands) so they cannot be derived
209
- // in full. Instead the tool derives their SKELETON — structure, ids, and
210
- // cross-references populated, only the judgment fields blank — and shows it to
211
- // the model so it fills just those slots and cannot drop, misname, or
212
- // mis-reference an obligation. These are NOT writable artifacts: the blank
213
- // fields fail validation by design (that is the point — the model must fill
214
- // them). They are rendered into the dispatch prompt as a pre-filled skeleton.
215
- /**
216
- * Shared obligation-membership predicates — the single source for which
217
- * obligations each downstream scaffold covers.
218
- *
219
- * `isTestablePhaseObligation` (imported above) is now single-sourced in
220
- * `../validation/contractPipelineGates.ts` (MNT-e10b9d9b: this file's former
221
- * local TESTABLE_KINDS set and that file's TESTABLE_OBLIGATION_KINDS were
222
- * "kept in parity by hand" and had already diverged — fail-open here,
223
- * fail-closed there, on an identical unrecognized-kind input). Re-exported
224
- * here so every existing importer of derive.js keeps working unchanged.
225
- *
226
- * `isDagPhaseObligation`: every obligation is covered by the implementation DAG,
227
- * so this is always true. It exists so both scaffolds derive their membership
228
- * from a named predicate rather than an inline ad-hoc filter.
229
- */
230
- export { isTestablePhaseObligation };
231
- export function isDagPhaseObligation(_kind) {
232
- return true;
233
- }
234
- /** A short, stable test name from an obligation description. */
235
- function scaffoldName(obligation) {
236
- const text = obligation.description.replace(/\s+/g, " ").trim();
237
- if (!text)
238
- return obligation.id;
239
- return text.length > 64 ? `${text.slice(0, 61)}...` : text;
240
- }
241
- function sameStringSet(a, b) {
242
- if (a.length !== b.length)
243
- return false;
244
- const setB = new Set(b);
245
- return a.every((x) => setB.has(x));
246
- }
247
- /**
248
- * Build the test-plan skeleton: one spec per *testable* (invariant/behavioral)
249
- * obligation, with `obligation_id`/`name`/`kind`/`scope_anchors` filled and
250
- * `assertions` left blank for the model. The model fills only the assertions
251
- * (each spec needs a paired positive + negative assertion per the OBL-CO-01
252
- * gate, and the negative must name one of `scope_anchors` per CE-006).
253
- *
254
- * C3 diff-carry: when `priorByObligation` carries a prior round's authored spec
255
- * for an obligation whose premise is UNCHANGED (same `name` + same
256
- * `scope_anchors`), its assertions are pre-filled instead of left blank, so an
257
- * unchanged obligation is not re-authored from scratch every repair round. A
258
- * changed premise (renamed/re-scoped obligation) carries nothing — the host
259
- * re-authors it (fail-safe toward re-author, never toward stale carry).
260
- */
261
- export function buildTestValidatorPlanScaffold(ledger, priorByObligation = {}) {
262
- const obligations = ledger?.obligations ?? [];
263
- return {
264
- test_specs: obligations
265
- .filter((o) => isTestablePhaseObligation(o.kind))
266
- .map((o) => {
267
- const name = scaffoldName(o);
268
- const scope_anchors = obligationScopeAnchors(o.id, o.description, readObligationChangeClassification(o));
269
- const prior = priorByObligation[o.id];
270
- const carried = prior &&
271
- prior.name === name &&
272
- sameStringSet(prior.scope_anchors, scope_anchors) &&
273
- prior.assertions.length > 0
274
- ? [...prior.assertions]
275
- : [];
276
- return {
277
- obligation_id: o.id,
278
- name,
279
- kind: o.kind === "invariant" ? "invariant" : "unit",
280
- scope_anchors,
281
- assertions: carried,
282
- };
283
- }),
284
- };
285
- }
286
- /**
287
- * Advisory-severity items from a conceptual_design_critique payload (defensive
288
- * read). Blocking items drive the design-repair loop and are consumed there;
289
- * advisory items survive past the critique gate and need a structural home in
290
- * the implementation DAG — this surfaces them so the skeleton can list them (B3).
291
- */
292
- export function advisoryCritiqueItems(critique) {
293
- const items = isRecord(critique) && Array.isArray(critique.items) ? critique.items : [];
294
- return items
295
- .filter((item) => isRecord(item))
296
- .filter((item) => item.severity === "advisory")
297
- .map((item) => ({
298
- id: typeof item.id === "string" ? item.id : "",
299
- description: typeof item.description === "string" ? item.description : "",
300
- }))
301
- .filter((item) => item.id.length > 0);
302
- }
303
- /** Accepted counterexample ids from a judge_report payload (defensive read). */
304
- export function acceptedCounterexampleIds(judgeReport) {
305
- const record = isRecord(judgeReport) ? judgeReport : {};
306
- const classifications = Array.isArray(record.classifications)
307
- ? record.classifications
308
- : [];
309
- const ids = [];
310
- for (const cls of classifications) {
311
- if (isRecord(cls) &&
312
- cls.classification === "accepted" &&
313
- typeof cls.counterexample_id === "string") {
314
- ids.push(cls.counterexample_id);
315
- }
316
- }
317
- return ids;
318
- }
319
- /**
320
- * Build the implementation-DAG skeleton: ONE node per finalized *module*
321
- * (grouping all that module's obligations), blank title/description/
322
- * targeted_commands for the model, and accepted counterexamples attached so
323
- * coverage holds by construction. Grouping by module means a 1-module change
324
- * derives 1 node instead of N obligation-nodes the host then has to merge (B2);
325
- * obligations with no module home (counterexample/critique-sourced) fall back
326
- * to one node each. Advisory: the model fills the blanks and may further
327
- * merge/split nodes as long as coverage is preserved.
328
- *
329
- * `depends_on` is DERIVED, not left for the host: when `finalizedContracts` is
330
- * supplied, each module node depends on the nodes of the modules it needs first
331
- * (producer/consumer `artifact:<name>` matching over `inputs`/`outputs` — the
332
- * same module-dependency DAG `phase_cut` uses). This
333
- * makes cross-node ordering tool-enforced instead of a thing the host must
334
- * remember to hand-add. Edges are oriented by phase ordinal so the result is
335
- * acyclic by construction: only an edge to a strictly-earlier-phase module is
336
- * kept, which drops the back-edge of any dependency cycle (fail-toward-later,
337
- * mirroring `derivePhaseCut`). The `edges` array stays empty — node `depends_on`
338
- * is the ordering the block promotion reads.
339
- */
340
- export function buildImplementationDagScaffold(ledger, acceptedCeIds, finalizedContracts) {
341
- const obligations = (ledger?.obligations ?? []).filter((o) => isDagPhaseObligation(o.kind));
342
- // Group by module in first-appearance order; obligations with no module key
343
- // on their own id (one node each, preserving coverage).
344
- const groups = [];
345
- const groupIndex = new Map();
346
- for (const o of obligations) {
347
- const key = o.module ? `module:${o.module}` : `obligation:${o.id}`;
348
- let idx = groupIndex.get(key);
349
- if (idx === undefined) {
350
- idx = groups.length;
351
- groupIndex.set(key, idx);
352
- groups.push({ key, obligations: [] });
353
- }
354
- groups[idx].obligations.push(o);
355
- }
356
- const nodes = groups.map((g, i) => {
357
- const ids = g.obligations.map((o) => o.id);
358
- return {
359
- id: `CP-NODE-${i + 1}`,
360
- title: "",
361
- description: "",
362
- satisfies_obligations: [...ids],
363
- addresses_counterexamples: [],
364
- addressed_critique_items: [],
365
- depends_on: [],
366
- verification_obligation_ids: [...ids],
367
- targeted_commands: [],
368
- status: "pending",
369
- };
370
- });
371
- applyModuleDependencyEdges(nodes, groups, finalizedContracts);
372
- if (acceptedCeIds.length > 0) {
373
- if (nodes.length === 0) {
374
- nodes.push({
375
- id: "CP-NODE-1",
376
- title: "",
377
- description: "",
378
- satisfies_obligations: [],
379
- addresses_counterexamples: [...acceptedCeIds],
380
- addressed_critique_items: [],
381
- depends_on: [],
382
- verification_obligation_ids: [],
383
- targeted_commands: [],
384
- status: "pending",
385
- });
386
- }
387
- else {
388
- nodes[0].addresses_counterexamples = [...acceptedCeIds];
389
- }
390
- }
391
- return { nodes, edges: [] };
392
- }
393
- /**
394
- * Fill each module node's `depends_on` from the finalized contracts'
395
- * module-dependency DAG (producer/consumer artifact tokens alone), the
396
- * SAME source `phase_cut` uses so the node ordering and the phase barrier agree.
397
- * Only a group keyed on a real module can be a dependency target (obligation- and
398
- * counterexample-only nodes have no module home). Edges are oriented by phase
399
- * ordinal — kept only when the dependency module sits in a strictly-earlier phase
400
- * — so a dependency cycle contributes no back-edge and the result is acyclic by
401
- * construction. No-op when contracts are absent (existing behaviour: no edges).
402
- */
403
- function applyModuleDependencyEdges(nodes, groups, finalizedContracts) {
404
- if (finalizedContracts === undefined || finalizedContracts === null)
405
- return;
406
- // module name → node id (1 node per module by construction).
407
- const moduleToNodeId = new Map();
408
- groups.forEach((g, i) => {
409
- if (g.key.startsWith("module:")) {
410
- moduleToNodeId.set(g.key.slice("module:".length), nodes[i].id);
411
- }
412
- });
413
- if (moduleToNodeId.size === 0)
414
- return;
415
- const phaseModules = phaseCutModulesFromContracts(finalizedContracts);
416
- const depsByModule = new Map(phaseModules.map((m) => [m.name, m.depends_on]));
417
- const phaseOf = derivePhaseCut(phaseModules).module_phase;
418
- const nodeById = new Map(nodes.map((n) => [n.id, n]));
419
- for (const [moduleName, nodeId] of moduleToNodeId) {
420
- const node = nodeById.get(nodeId);
421
- if (!node)
422
- continue;
423
- const deps = new Set();
424
- for (const depModule of depsByModule.get(moduleName) ?? []) {
425
- const depNodeId = moduleToNodeId.get(depModule);
426
- if (!depNodeId || depNodeId === nodeId)
427
- continue;
428
- if ((phaseOf[depModule] ?? 0) < (phaseOf[moduleName] ?? 0))
429
- deps.add(depNodeId);
430
- }
431
- node.depends_on = [...deps].sort();
432
- }
433
- }
434
- // ── Helpers ───────────────────────────────────────────────────────────────────
435
- function fmtList(items) {
436
- return items.length > 0 ? items.join(", ") : "none";
437
- }
438
- function strArray(value) {
439
- return Array.isArray(value)
440
- ? value.filter((v) => typeof v === "string")
441
- : [];
442
- }
443
- /**
444
- * The defensive coercion per COPIED field, keyed by the SAME union the field
445
- * list is drawn from — a field added to the vocabulary without a coercion here
446
- * is a compile error, not a field silently read as `undefined` at runtime.
447
- * `name` is the only non-array string; every other copied field is an array of
448
- * strings, with `validation_boundary` the one scalar outside `name`.
449
- */
450
- const COPIED_MODULE_CONTRACT_COERCIONS = {
451
- name: (raw) => (typeof raw.name === "string" ? raw.name : "module"),
452
- inputs: (raw) => strArray(raw.inputs),
453
- outputs: (raw) => strArray(raw.outputs),
454
- invariants: (raw) => strArray(raw.invariants),
455
- side_effects: (raw) => strArray(raw.side_effects),
456
- validation_boundary: (raw) => typeof raw.validation_boundary === "string" ? raw.validation_boundary : "",
457
- failure_modes: (raw) => strArray(raw.failure_modes),
458
- };
459
- /** Defensive read of the validated finalized-module-contracts payload. */
460
- function readFinalizedContracts(payload) {
461
- const record = isRecord(payload) ? payload : {};
462
- // Same validation as the mint above: this reader is the OTHER half of the
463
- // same join, so a value that could not be minted must not be read back as one.
464
- const goalId = coerceGoalId(record.goal_id);
465
- const rawModules = Array.isArray(record.module_contracts)
466
- ? record.module_contracts
467
- : [];
468
- const module_contracts = rawModules.map((m) => {
469
- const raw = isRecord(m) ? m : {};
470
- return Object.fromEntries(COPIED_MODULE_CONTRACT_FIELDS.map((field) => [
471
- field,
472
- COPIED_MODULE_CONTRACT_COERCIONS[field](raw),
473
- ]));
474
- });
475
- return { goal_id: goalId, module_contracts };
476
- }
477
- //# sourceMappingURL=derive.js.map