audit-tools 0.56.2 → 0.57.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 (374) hide show
  1. package/README.md +24 -22
  2. package/dist/audit/cli/args.d.ts +0 -1
  3. package/dist/audit/cli/args.d.ts.map +1 -1
  4. package/dist/audit/cli/args.js +0 -14
  5. package/dist/audit/cli/args.js.map +1 -1
  6. package/dist/audit/cli/auditStep.d.ts +0 -59
  7. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  8. package/dist/audit/cli/auditStep.js +7 -139
  9. package/dist/audit/cli/auditStep.js.map +1 -1
  10. package/dist/audit/cli/cleanup.d.ts.map +1 -1
  11. package/dist/audit/cli/cleanup.js +4 -1
  12. package/dist/audit/cli/cleanup.js.map +1 -1
  13. package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
  14. package/dist/audit/cli/confirmIntentStep.js +16 -31
  15. package/dist/audit/cli/confirmIntentStep.js.map +1 -1
  16. package/dist/audit/cli/dispatch/hostHandoff.d.ts +459 -1
  17. package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
  18. package/dist/audit/cli/dispatch/hostHandoff.js +312 -1
  19. package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
  20. package/dist/audit/cli/dispatch/packetFilter.d.ts +1 -1
  21. package/dist/audit/cli/dispatch/questionReviewAcceptance.d.ts +254 -0
  22. package/dist/audit/cli/dispatch/questionReviewAcceptance.d.ts.map +1 -0
  23. package/dist/audit/cli/dispatch/questionReviewAcceptance.js +183 -0
  24. package/dist/audit/cli/dispatch/questionReviewAcceptance.js.map +1 -0
  25. package/dist/audit/cli/foldTransaction.d.ts +1 -1
  26. package/dist/audit/cli/foldTransaction.d.ts.map +1 -1
  27. package/dist/audit/cli/foldTransaction.js +3 -2
  28. package/dist/audit/cli/foldTransaction.js.map +1 -1
  29. package/dist/audit/cli/functionalPreflight.d.ts +4 -4
  30. package/dist/audit/cli/laneSubmissions.d.ts +4 -4
  31. package/dist/audit/cli/nextStepCommand.d.ts +3 -20
  32. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  33. package/dist/audit/cli/nextStepCommand.js +64 -141
  34. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  35. package/dist/audit/cli/nextStepHelpers.d.ts +10 -72
  36. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  37. package/dist/audit/cli/nextStepHelpers.js +115 -375
  38. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  39. package/dist/audit/cli/prompts.d.ts +0 -2
  40. package/dist/audit/cli/prompts.d.ts.map +1 -1
  41. package/dist/audit/cli/prompts.js +3 -14
  42. package/dist/audit/cli/prompts.js.map +1 -1
  43. package/dist/audit/cli/questionReviewCycle.d.ts +281 -0
  44. package/dist/audit/cli/questionReviewCycle.d.ts.map +1 -0
  45. package/dist/audit/cli/questionReviewCycle.js +87 -0
  46. package/dist/audit/cli/questionReviewCycle.js.map +1 -0
  47. package/dist/audit/cli/questionReviewSession.d.ts +21 -0
  48. package/dist/audit/cli/questionReviewSession.d.ts.map +1 -0
  49. package/dist/audit/cli/questionReviewSession.js +111 -0
  50. package/dist/audit/cli/questionReviewSession.js.map +1 -0
  51. package/dist/audit/cli/questionWorkloadBindings.d.ts +7 -0
  52. package/dist/audit/cli/questionWorkloadBindings.d.ts.map +1 -0
  53. package/dist/audit/cli/questionWorkloadBindings.js +68 -0
  54. package/dist/audit/cli/questionWorkloadBindings.js.map +1 -0
  55. package/dist/audit/cli/resynthesizeCommand.d.ts +1 -0
  56. package/dist/audit/cli/resynthesizeCommand.d.ts.map +1 -1
  57. package/dist/audit/cli/resynthesizeCommand.js +52 -51
  58. package/dist/audit/cli/resynthesizeCommand.js.map +1 -1
  59. package/dist/audit/cli/sampleRunCommand.d.ts +600 -159
  60. package/dist/audit/cli/sampleRunCommand.d.ts.map +1 -1
  61. package/dist/audit/cli/sampleRunCommand.js +66 -152
  62. package/dist/audit/cli/sampleRunCommand.js.map +1 -1
  63. package/dist/audit/cli/statusCommand.d.ts.map +1 -1
  64. package/dist/audit/cli/statusCommand.js +20 -14
  65. package/dist/audit/cli/statusCommand.js.map +1 -1
  66. package/dist/audit/cli/steps.d.ts +10 -10
  67. package/dist/audit/cli/submitCommand.d.ts +13 -6
  68. package/dist/audit/cli/submitCommand.d.ts.map +1 -1
  69. package/dist/audit/cli/submitCommand.js +121 -24
  70. package/dist/audit/cli/submitCommand.js.map +1 -1
  71. package/dist/audit/cli.d.ts.map +1 -1
  72. package/dist/audit/cli.js +7 -17
  73. package/dist/audit/cli.js.map +1 -1
  74. package/dist/audit/contracts/findingContractPrompt.d.ts +4 -4
  75. package/dist/audit/contracts/workerSchemas.d.ts +83 -82
  76. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  77. package/dist/audit/contracts/workerSchemas.js +8 -1
  78. package/dist/audit/contracts/workerSchemas.js.map +1 -1
  79. package/dist/audit/contracts/wrapperResponse.d.ts +13 -13
  80. package/dist/audit/contracts/wrapperResponse.d.ts.map +1 -1
  81. package/dist/audit/contracts/wrapperResponse.js +0 -1
  82. package/dist/audit/contracts/wrapperResponse.js.map +1 -1
  83. package/dist/audit/extractors/designAssessment.js +2 -2
  84. package/dist/audit/extractors/designAssessment.js.map +1 -1
  85. package/dist/audit/io/artifacts.d.ts +37 -10
  86. package/dist/audit/io/artifacts.d.ts.map +1 -1
  87. package/dist/audit/io/artifacts.js +217 -33
  88. package/dist/audit/io/artifacts.js.map +1 -1
  89. package/dist/audit/io/rollover.d.ts.map +1 -1
  90. package/dist/audit/io/rollover.js +7 -16
  91. package/dist/audit/io/rollover.js.map +1 -1
  92. package/dist/audit/io/runSnapshot.d.ts +1 -1
  93. package/dist/audit/io/runSnapshot.js +1 -1
  94. package/dist/audit/orchestrator/architectureDiscovery.d.ts +9 -10
  95. package/dist/audit/orchestrator/architectureDiscovery.d.ts.map +1 -1
  96. package/dist/audit/orchestrator/architectureDiscovery.js +95 -13
  97. package/dist/audit/orchestrator/architectureDiscovery.js.map +1 -1
  98. package/dist/audit/orchestrator/charterPacketArchive.d.ts +3 -0
  99. package/dist/audit/orchestrator/charterPacketArchive.d.ts.map +1 -1
  100. package/dist/audit/orchestrator/charterPacketArchive.js +31 -2
  101. package/dist/audit/orchestrator/charterPacketArchive.js.map +1 -1
  102. package/dist/audit/orchestrator/dependencyMap.d.ts +2 -8
  103. package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
  104. package/dist/audit/orchestrator/dependencyMap.js +10 -105
  105. package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
  106. package/dist/audit/orchestrator/dependencySlices.d.ts +2 -3
  107. package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -1
  108. package/dist/audit/orchestrator/dependencySlices.js +2 -35
  109. package/dist/audit/orchestrator/dependencySlices.js.map +1 -1
  110. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  111. package/dist/audit/orchestrator/designReviewPrompt.js +24 -14
  112. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  113. package/dist/audit/orchestrator/executorRunners.d.ts +1 -1
  114. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  115. package/dist/audit/orchestrator/executorRunners.js +14 -21
  116. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  117. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  118. package/dist/audit/orchestrator/executors.js +1 -131
  119. package/dist/audit/orchestrator/executors.js.map +1 -1
  120. package/dist/audit/orchestrator/flowPlanning.d.ts +1 -1
  121. package/dist/audit/orchestrator/flowPlanning.js +1 -1
  122. package/dist/audit/orchestrator/ingestionExecutors.d.ts.map +1 -1
  123. package/dist/audit/orchestrator/ingestionExecutors.js +19 -12
  124. package/dist/audit/orchestrator/ingestionExecutors.js.map +1 -1
  125. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts +2 -2
  126. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
  127. package/dist/audit/orchestrator/intentCheckpointExecutor.js +37 -36
  128. package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
  129. package/dist/audit/orchestrator/lensSelection.d.ts +6 -37
  130. package/dist/audit/orchestrator/lensSelection.d.ts.map +1 -1
  131. package/dist/audit/orchestrator/lensSelection.js +42 -68
  132. package/dist/audit/orchestrator/lensSelection.js.map +1 -1
  133. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  134. package/dist/audit/orchestrator/nextStep.js +1 -4
  135. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  136. package/dist/audit/orchestrator/questionEvidence.d.ts +67 -0
  137. package/dist/audit/orchestrator/questionEvidence.d.ts.map +1 -0
  138. package/dist/audit/orchestrator/questionEvidence.js +177 -0
  139. package/dist/audit/orchestrator/questionEvidence.js.map +1 -0
  140. package/dist/audit/orchestrator/questionPlanExecutor.d.ts +10 -0
  141. package/dist/audit/orchestrator/questionPlanExecutor.d.ts.map +1 -0
  142. package/dist/audit/orchestrator/questionPlanExecutor.js +23 -0
  143. package/dist/audit/orchestrator/questionPlanExecutor.js.map +1 -0
  144. package/dist/audit/orchestrator/questionPlanning.d.ts +48 -0
  145. package/dist/audit/orchestrator/questionPlanning.d.ts.map +1 -0
  146. package/dist/audit/orchestrator/questionPlanning.js +326 -0
  147. package/dist/audit/orchestrator/questionPlanning.js.map +1 -0
  148. package/dist/audit/orchestrator/requeueCommand.d.ts +1 -1
  149. package/dist/audit/orchestrator/reviewLensPlaybooks.d.ts +11 -0
  150. package/dist/audit/orchestrator/reviewLensPlaybooks.d.ts.map +1 -0
  151. package/dist/audit/orchestrator/reviewLensPlaybooks.js +11 -0
  152. package/dist/audit/orchestrator/reviewLensPlaybooks.js.map +1 -0
  153. package/dist/audit/orchestrator/runtimeValidation.d.ts.map +1 -1
  154. package/dist/audit/orchestrator/runtimeValidation.js +14 -0
  155. package/dist/audit/orchestrator/runtimeValidation.js.map +1 -1
  156. package/dist/audit/orchestrator/runtimeValidationUpdate.d.ts +1 -1
  157. package/dist/audit/orchestrator/runtimeValidationUpdate.d.ts.map +1 -1
  158. package/dist/audit/orchestrator/runtimeValidationUpdate.js +13 -4
  159. package/dist/audit/orchestrator/runtimeValidationUpdate.js.map +1 -1
  160. package/dist/audit/orchestrator/selectiveDeepening/conflict.js +1 -1
  161. package/dist/audit/orchestrator/selectiveDeepening/conflict.js.map +1 -1
  162. package/dist/audit/orchestrator/selectiveDeepening/index.js +1 -1
  163. package/dist/audit/orchestrator/selectiveDeepening/index.js.map +1 -1
  164. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  165. package/dist/audit/orchestrator/state.js +8 -60
  166. package/dist/audit/orchestrator/state.js.map +1 -1
  167. package/dist/audit/orchestrator/synthesisExecutors.d.ts +15 -1
  168. package/dist/audit/orchestrator/synthesisExecutors.d.ts.map +1 -1
  169. package/dist/audit/orchestrator/synthesisExecutors.js +76 -25
  170. package/dist/audit/orchestrator/synthesisExecutors.js.map +1 -1
  171. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
  172. package/dist/audit/orchestrator/systemicChallengeExecutor.js +11 -6
  173. package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
  174. package/dist/audit/orchestrator/taskAffinityGraph.d.ts +4 -4
  175. package/dist/audit/reporting/questionReport.d.ts +28 -0
  176. package/dist/audit/reporting/questionReport.d.ts.map +1 -0
  177. package/dist/audit/reporting/questionReport.js +186 -0
  178. package/dist/audit/reporting/questionReport.js.map +1 -0
  179. package/dist/audit/reporting/synthesis.d.ts +10 -1
  180. package/dist/audit/reporting/synthesis.d.ts.map +1 -1
  181. package/dist/audit/reporting/synthesis.js +161 -24
  182. package/dist/audit/reporting/synthesis.js.map +1 -1
  183. package/dist/audit/reporting/synthesisNarrativePrompt.d.ts +4 -1
  184. package/dist/audit/reporting/synthesisNarrativePrompt.d.ts.map +1 -1
  185. package/dist/audit/reporting/synthesisNarrativePrompt.js +5 -1
  186. package/dist/audit/reporting/synthesisNarrativePrompt.js.map +1 -1
  187. package/dist/audit/supervisor/operatorHandoff.d.ts +2 -3
  188. package/dist/audit/supervisor/operatorHandoff.d.ts.map +1 -1
  189. package/dist/audit/supervisor/operatorHandoff.js +3 -18
  190. package/dist/audit/supervisor/operatorHandoff.js.map +1 -1
  191. package/dist/audit/systemic/aggregateMetricsDigest.d.ts.map +1 -1
  192. package/dist/audit/systemic/aggregateMetricsDigest.js +0 -2
  193. package/dist/audit/systemic/aggregateMetricsDigest.js.map +1 -1
  194. package/dist/audit/types/artifactMetadata.d.ts +1 -2
  195. package/dist/audit/types/artifactMetadata.d.ts.map +1 -1
  196. package/dist/audit/types/auditState.d.ts +6 -6
  197. package/dist/audit/types/conceptualAdjudication.d.ts +708 -50
  198. package/dist/audit/types/conceptualAdjudication.d.ts.map +1 -1
  199. package/dist/audit/types/conceptualAdjudication.js +2 -0
  200. package/dist/audit/types/conceptualAdjudication.js.map +1 -1
  201. package/dist/audit/types/runtimeValidation.d.ts +58 -6
  202. package/dist/audit/types/runtimeValidation.d.ts.map +1 -1
  203. package/dist/audit/types/runtimeValidation.js +8 -0
  204. package/dist/audit/types/runtimeValidation.js.map +1 -1
  205. package/dist/audit/types.d.ts +551 -34
  206. package/dist/audit/types.d.ts.map +1 -1
  207. package/dist/audit/validation/auditResults.d.ts +1 -1
  208. package/dist/audit/validation/auditResults.js +1 -1
  209. package/dist/audit/validation/ingestIssueCodes.d.ts.map +1 -1
  210. package/dist/audit/validation/ingestIssueCodes.js +0 -1
  211. package/dist/audit/validation/ingestIssueCodes.js.map +1 -1
  212. package/dist/remediate/contractPipeline/executionPlan.d.ts +679 -52
  213. package/dist/remediate/contractPipeline/executionPlan.d.ts.map +1 -1
  214. package/dist/remediate/contractPipeline/executionPlan.js +23 -0
  215. package/dist/remediate/contractPipeline/executionPlan.js.map +1 -1
  216. package/dist/remediate/findingFilter.d.ts.map +1 -1
  217. package/dist/remediate/findingFilter.js +6 -2
  218. package/dist/remediate/findingFilter.js.map +1 -1
  219. package/dist/remediate/intake.d.ts +4 -4
  220. package/dist/remediate/phases/close.d.ts.map +1 -1
  221. package/dist/remediate/phases/close.js +15 -5
  222. package/dist/remediate/phases/close.js.map +1 -1
  223. package/dist/remediate/phases/closeVerifyAnalyzerLeads.d.ts +5 -0
  224. package/dist/remediate/phases/closeVerifyAnalyzerLeads.d.ts.map +1 -1
  225. package/dist/remediate/phases/closeVerifyAnalyzerLeads.js +37 -8
  226. package/dist/remediate/phases/closeVerifyAnalyzerLeads.js.map +1 -1
  227. package/dist/remediate/state/types.d.ts +619 -26
  228. package/dist/remediate/state/types.d.ts.map +1 -1
  229. package/dist/remediate/state/types.js +2 -1
  230. package/dist/remediate/state/types.js.map +1 -1
  231. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  232. package/dist/remediate/steps/contractPipeline.js +2 -0
  233. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  234. package/dist/remediate/steps/contractPipelinePrompts.d.ts.map +1 -1
  235. package/dist/remediate/steps/contractPipelinePrompts.js +2 -0
  236. package/dist/remediate/steps/contractPipelinePrompts.js.map +1 -1
  237. package/dist/remediate/steps/dispatch/contractConformanceReview.d.ts +3 -3
  238. package/dist/remediate/steps/intakeResolver.d.ts.map +1 -1
  239. package/dist/remediate/steps/intakeResolver.js +31 -6
  240. package/dist/remediate/steps/intakeResolver.js.map +1 -1
  241. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  242. package/dist/remediate/steps/nextStep.js +47 -44
  243. package/dist/remediate/steps/nextStep.js.map +1 -1
  244. package/dist/remediate/steps/prompts.d.ts.map +1 -1
  245. package/dist/remediate/steps/prompts.js +3 -0
  246. package/dist/remediate/steps/prompts.js.map +1 -1
  247. package/dist/shared/analyzers/types.d.ts +18 -18
  248. package/dist/shared/contentKey.d.ts +1 -1
  249. package/dist/shared/contentKey.js +1 -1
  250. package/dist/shared/decompose/charterClarification.d.ts +4 -4
  251. package/dist/shared/decompose/charterExtraction.d.ts +31 -31
  252. package/dist/shared/decompose/contentCoherence.d.ts +1 -1
  253. package/dist/shared/decompose/contentCoherence.js +1 -1
  254. package/dist/shared/decompose/systemicChallenge.d.ts +629 -18
  255. package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -1
  256. package/dist/shared/engine/obligationEngine.d.ts +2 -2
  257. package/dist/shared/index.d.ts +2 -0
  258. package/dist/shared/index.d.ts.map +1 -1
  259. package/dist/shared/index.js +2 -0
  260. package/dist/shared/index.js.map +1 -1
  261. package/dist/shared/io/stepContractWriter.js +1 -1
  262. package/dist/shared/io/stepContractWriter.js.map +1 -1
  263. package/dist/shared/loopCorePaths.d.ts.map +1 -1
  264. package/dist/shared/loopCorePaths.js +5 -2
  265. package/dist/shared/loopCorePaths.js.map +1 -1
  266. package/dist/shared/mcp/submitServer.d.ts +1 -0
  267. package/dist/shared/mcp/submitServer.d.ts.map +1 -1
  268. package/dist/shared/mcp/submitServer.js +1 -1
  269. package/dist/shared/mcp/submitServer.js.map +1 -1
  270. package/dist/shared/submission/hostResultOutcomes.js +1 -1
  271. package/dist/shared/submission/hostResultOutcomes.js.map +1 -1
  272. package/dist/shared/tooling/exec.js +1 -1
  273. package/dist/shared/tooling/exec.js.map +1 -1
  274. package/dist/shared/types/charter.d.ts +38 -38
  275. package/dist/shared/types/contractPropertyShapes.d.ts.map +1 -1
  276. package/dist/shared/types/contractPropertyShapes.js +7 -0
  277. package/dist/shared/types/contractPropertyShapes.js.map +1 -1
  278. package/dist/shared/types/executionPlan.d.ts +88 -12
  279. package/dist/shared/types/executionPlan.d.ts.map +1 -1
  280. package/dist/shared/types/executionPlan.js +1 -0
  281. package/dist/shared/types/executionPlan.js.map +1 -1
  282. package/dist/shared/types/finding.d.ts +1721 -56
  283. package/dist/shared/types/finding.d.ts.map +1 -1
  284. package/dist/shared/types/finding.js +7 -10
  285. package/dist/shared/types/finding.js.map +1 -1
  286. package/dist/shared/types/findingVocabulary.d.ts +8 -0
  287. package/dist/shared/types/findingVocabulary.d.ts.map +1 -0
  288. package/dist/shared/types/findingVocabulary.js +13 -0
  289. package/dist/shared/types/findingVocabulary.js.map +1 -0
  290. package/dist/shared/types/intentCheckpoint.d.ts +8 -3
  291. package/dist/shared/types/intentCheckpoint.d.ts.map +1 -1
  292. package/dist/shared/types/intentCheckpoint.js +4 -3
  293. package/dist/shared/types/intentCheckpoint.js.map +1 -1
  294. package/dist/shared/types/questionReviewReport.d.ts +10574 -0
  295. package/dist/shared/types/questionReviewReport.d.ts.map +1 -0
  296. package/dist/shared/types/questionReviewReport.js +186 -0
  297. package/dist/shared/types/questionReviewReport.js.map +1 -0
  298. package/dist/shared/types/remediationOutcome.d.ts +1379 -148
  299. package/dist/shared/types/remediationOutcome.d.ts.map +1 -1
  300. package/dist/shared/types/remediationOutcome.js +5 -0
  301. package/dist/shared/types/remediationOutcome.js.map +1 -1
  302. package/dist/shared/types/reviewIndependence.d.ts +24 -24
  303. package/dist/shared/types/reviewQuestion.d.ts +4710 -0
  304. package/dist/shared/types/reviewQuestion.d.ts.map +1 -0
  305. package/dist/shared/types/reviewQuestion.js +216 -0
  306. package/dist/shared/types/reviewQuestion.js.map +1 -0
  307. package/dist/shared/types/stepContract.js +1 -1
  308. package/dist/shared/types/stepContract.js.map +1 -1
  309. package/dist/shared/validation/designFindingGrounding.js +1 -1
  310. package/dist/shared/validation/designFindingGrounding.js.map +1 -1
  311. package/dist/shared/validation/findingsReport.d.ts.map +1 -1
  312. package/dist/shared/validation/findingsReport.js +19 -4
  313. package/dist/shared/validation/findingsReport.js.map +1 -1
  314. package/docs/audit-pkg/contracts.md +27 -56
  315. package/docs/audit-pkg/operator-guide.md +31 -17
  316. package/docs/audit-pkg/product.md +17 -23
  317. package/package.json +1 -1
  318. package/schemas/audit-code-v1alpha1.schema.json +0 -1
  319. package/schemas/review_submission.schema.json +514 -0
  320. package/skills/audit-code/audit-code.prompt.md +7 -5
  321. package/wrapper/audit-code-wrapper-lib.mjs +1 -5
  322. package/wrapper/installer-verb-help.mjs +1 -1
  323. package/dist/audit/cli/explainTaskCommand.d.ts +0 -4
  324. package/dist/audit/cli/explainTaskCommand.d.ts.map +0 -1
  325. package/dist/audit/cli/explainTaskCommand.js +0 -45
  326. package/dist/audit/cli/explainTaskCommand.js.map +0 -1
  327. package/dist/audit/cli/ingestResultsCommand.d.ts +0 -2
  328. package/dist/audit/cli/ingestResultsCommand.d.ts.map +0 -1
  329. package/dist/audit/cli/ingestResultsCommand.js +0 -42
  330. package/dist/audit/cli/ingestResultsCommand.js.map +0 -1
  331. package/dist/audit/cli/requeueCommand.d.ts +0 -2
  332. package/dist/audit/cli/requeueCommand.d.ts.map +0 -1
  333. package/dist/audit/cli/requeueCommand.js +0 -12
  334. package/dist/audit/cli/requeueCommand.js.map +0 -1
  335. package/dist/audit/cli/semanticReviewStep.d.ts +0 -41
  336. package/dist/audit/cli/semanticReviewStep.d.ts.map +0 -1
  337. package/dist/audit/cli/semanticReviewStep.js +0 -185
  338. package/dist/audit/cli/semanticReviewStep.js.map +0 -1
  339. package/dist/audit/cli/unacceptResultsCommand.d.ts +0 -19
  340. package/dist/audit/cli/unacceptResultsCommand.d.ts.map +0 -1
  341. package/dist/audit/cli/unacceptResultsCommand.js +0 -52
  342. package/dist/audit/cli/unacceptResultsCommand.js.map +0 -1
  343. package/dist/audit/cli/updateRuntimeValidationCommand.d.ts +0 -2
  344. package/dist/audit/cli/updateRuntimeValidationCommand.d.ts.map +0 -1
  345. package/dist/audit/cli/updateRuntimeValidationCommand.js +0 -18
  346. package/dist/audit/cli/updateRuntimeValidationCommand.js.map +0 -1
  347. package/dist/audit/cli/validateResultsCommand.d.ts +0 -13
  348. package/dist/audit/cli/validateResultsCommand.d.ts.map +0 -1
  349. package/dist/audit/cli/validateResultsCommand.js +0 -87
  350. package/dist/audit/cli/validateResultsCommand.js.map +0 -1
  351. package/dist/audit/cli/workerResult.d.ts +0 -2
  352. package/dist/audit/cli/workerResult.d.ts.map +0 -1
  353. package/dist/audit/cli/workerResult.js +0 -6
  354. package/dist/audit/cli/workerResult.js.map +0 -1
  355. package/dist/audit/orchestrator/coverageElementBaseline.d.ts +0 -54
  356. package/dist/audit/orchestrator/coverageElementBaseline.d.ts.map +0 -1
  357. package/dist/audit/orchestrator/coverageElementBaseline.js +0 -136
  358. package/dist/audit/orchestrator/coverageElementBaseline.js.map +0 -1
  359. package/dist/audit/orchestrator/planning.d.ts +0 -5
  360. package/dist/audit/orchestrator/planning.d.ts.map +0 -1
  361. package/dist/audit/orchestrator/planning.js +0 -79
  362. package/dist/audit/orchestrator/planning.js.map +0 -1
  363. package/dist/audit/orchestrator/planningExecutors.d.ts +0 -21
  364. package/dist/audit/orchestrator/planningExecutors.d.ts.map +0 -1
  365. package/dist/audit/orchestrator/planningExecutors.js +0 -273
  366. package/dist/audit/orchestrator/planningExecutors.js.map +0 -1
  367. package/dist/audit/orchestrator/taskBuilder.d.ts +0 -62
  368. package/dist/audit/orchestrator/taskBuilder.d.ts.map +0 -1
  369. package/dist/audit/orchestrator/taskBuilder.js +0 -412
  370. package/dist/audit/orchestrator/taskBuilder.js.map +0 -1
  371. package/dist/audit/orchestrator/trivialAudit.d.ts +0 -21
  372. package/dist/audit/orchestrator/trivialAudit.d.ts.map +0 -1
  373. package/dist/audit/orchestrator/trivialAudit.js +0 -80
  374. package/dist/audit/orchestrator/trivialAudit.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ import { assertQualifiedReviewObligation, assertQualifiedReviewStillCurrent, deriveQuestionCycleUnlocked } from "./questionReviewCycle.js";
2
+ import { publishAuditQuestionWorkload } from "./dispatch/hostHandoff.js";
1
3
  import { preservesSourceIndexes } from "../orchestrator/executorRunners.js";
2
4
  import { designReviewInputRevision } from "../orchestrator/designReviewProjection.js";
3
5
  import { decodeAuditReviewSubmission, readAuditReviewSubmission, currentAuditReviewInputRevision, auditLaneReviewRequirement } from "./reviewSubmission.js";
@@ -13,9 +15,10 @@ import { AnalyzerRunConsentDecisionSchema, readRunConsentUnlocked, updateRunCons
13
15
  import { mkdir, readFile, unlink } from "node:fs/promises";
14
16
  import { join, relative } from "node:path";
15
17
  import { AUDIT_FINDINGS_FILENAME, auditFindingsPath, promotedAuditFindingsPath, advance, ANALYZER_SETTINGS, describeStoppedFold, RunLogger, hashContent, isFileMissingError, isJsonParseError, isRecord, readJsonFile, readSubmissionIngestHistory, readTrailingSubmissionRefusals, persistAnalyzerSettings, writeJsonFile, writeTextFile, } from "audit-tools/shared";
16
- import { loadArtifactBundle, promoteFinalAuditReport, } from "../io/artifacts.js";
17
- import { ensureRunSourceRoot, removeRunSnapshot, resolveRunSince } from "../io/runSnapshot.js";
18
+ import { loadArtifactBundle, promoteFinalAuditReport, hasCurrentQuestionReport, hasWorkingQuestionReportMarker, isWorkingDirFullyPromoted, } from "../io/artifacts.js";
19
+ import { ensureRunSourceRoot, readRunSourceRoot, removeRunSnapshot, resolveRunSince } from "../io/runSnapshot.js";
18
20
  import { markRunEnded } from "../io/rollover.js";
21
+ import { readQuestionReviewRunId } from "./questionReviewSession.js";
19
22
  import { auditReportPath, groundDesignFindings, laneAssetsDir, promotedAuditReportPath, } from "audit-tools/shared";
20
23
  import { charterExtractionKindsForCeiling } from "./charterExtractionPrompt.js";
21
24
  import { archiveCharterPackets } from "../orchestrator/charterPacketArchive.js";
@@ -28,8 +31,7 @@ import { commitFold, createFoldTransaction, markSubmissionApplied, describeQuara
28
31
  import { charterClarificationOmits, charterComparisonOmits, charterFidelityOmits, charterExtractionOmits, intentEquivalenceOmits, synthesisNarrativeOmits, systemicChallengeOmits, } from "../orchestrator/obligationPolicy.js";
29
32
  import { computeArtifactMetadata, computeArtifactStateSignature } from "../orchestrator/artifactMetadata.js";
30
33
  import { decideNextStep, PRIORITY, } from "../orchestrator/nextStep.js";
31
- import { isHostDelegationExecutor } from "../orchestrator/executors.js";
32
- import { resolveCharterCeiling } from "../orchestrator/charterExtractionExecutor.js";
34
+ import { ceilingRequestsCharters, resolveCharterCeiling } from "../orchestrator/charterExtractionExecutor.js";
33
35
  import { systemicChallengeSchemaForBundle } from "../orchestrator/systemicChallengeExecutor.js";
34
36
  import { deriveObligationState } from "../orchestrator/obligationDerive.js";
35
37
  import { deriveAuditState } from "../orchestrator/state.js";
@@ -37,16 +39,13 @@ import { checkFileIntegrity } from "../orchestrator/fileIntegrity.js";
37
39
  import { graphEnrichmentUnresolvedAnalyzers, graphEnrichmentLowConfidenceEdges, pendingAnalyzerConsent, } from "../orchestrator/hostInputPause.js";
38
40
  import { runAuditStepUnlocked } from "./auditStep.js";
39
41
  import { withArtifactTreeHold } from "../../shared/io/artifactTreeHold.js";
40
- import { writeHandoffOnly, ensureSemanticReviewRunUnlocked, loadCurrentActiveReviewRun, } from "./reviewRun.js";
42
+ import { writeHandoffOnly, } from "./reviewRun.js";
41
43
  import { sizeIndexFromManifest } from "../orchestrator/reviewPackets.js";
42
- import { buildPendingAuditTasks } from "./dispatch/packetFilter.js";
44
+ import { reviewSourceScope } from "../orchestrator/questionPlanning.js";
43
45
  import { buildLineIndex } from "./lineIndex.js";
44
46
  import { errorMessage } from "../../shared/io/json.js";
45
- import { ingestAuditHostResults, } from "./dispatch/hostHandoff.js";
46
- import { auditIngestRemedy, } from "../validation/ingestIssueCodes.js";
47
- import { buildCharterPacketManifest, carriedCharterLane, materializeCharterPacket, } from "../orchestrator/charterPackets.js";
47
+ import { buildCharterPacketManifest, carriedCharterLane, charterPacketReadSet, materializeCharterPacket, } from "../orchestrator/charterPackets.js";
48
48
  import { CHARTER_EXTRACTION_MERGED_FILENAME, AUDIT_GATE_SUBMISSION_SCOPE, GATE_LANES, charterExtractionCoverageFilename, charterExtractionLane, charterExtractionPacketFilename, closeDispatchedLaneOutcomes, laneSubmissionPath, laneSubmissionId, recordLaneOutcome, systemicChallengeLane, } from "./laneSubmissions.js";
49
- import { recordHostResultOutcomes, renderIngestReportLines } from "audit-tools/shared";
50
49
  /**
51
50
  * Read a lane's submission from the TOOL-COMPUTED path its emission bound —
52
51
  * never a name a host could type. `ok` when the file exists and parses;
@@ -120,7 +119,7 @@ export function requireSourceRoot(params) {
120
119
  * could disagree with the table it describes.
121
120
  */
122
121
  const NEXT_STEP_RETURN_KIND_TABLE = {
123
- semantic_review: true,
122
+ question_review: true,
124
123
  design_review_parallel: true,
125
124
  design_review_contract: true,
126
125
  design_review_conceptual: true,
@@ -165,6 +164,8 @@ async function promoteCompletedReport(root, artifactsDir) {
165
164
  // run's report and this run's render sat only under `.audit-tools/audit/`.
166
165
  // Identity, not existence: promoted content must equal the in-place render.
167
166
  const inPlacePath = auditReportPath(artifactsDir);
167
+ if (!(await hasCurrentQuestionReport(artifactsDir)))
168
+ return inPlacePath;
168
169
  const [promotedText, inPlaceText] = await Promise.all([
169
170
  readFile(promotedPath, "utf8").catch(() => null),
170
171
  readFile(inPlacePath, "utf8").catch(() => null),
@@ -185,12 +186,14 @@ async function promoteCompletedReport(root, artifactsDir) {
185
186
  ]);
186
187
  const findingsCurrent = inPlaceFindings === null || (promotedFindings !== null && inPlaceFindings.equals(promotedFindings));
187
188
  let findingsArchived = true;
188
- if (!alreadyPromoted || !findingsCurrent) {
189
+ if (!alreadyPromoted || !findingsCurrent || !(await isWorkingDirFullyPromoted(artifactsDir))) {
189
190
  const promoted = await promoteFinalAuditReport({ artifactsDir });
190
191
  if (!promoted.promoted)
191
192
  return inPlacePath;
192
193
  findingsArchived = !(promoted.unarchived ?? []).some((member) => member.startsWith(AUDIT_FINDINGS_FILENAME));
193
194
  }
195
+ if (!findingsArchived || !(await isWorkingDirFullyPromoted(artifactsDir)))
196
+ return inPlacePath;
194
197
  // A presented, promoted report ENDS the run, whatever its status (a rendered
195
198
  // report on a stopped fold included — re-reading the same frozen snapshot
196
199
  // would only stop it again): its snapshot goes, and the marker lets the next
@@ -226,7 +229,16 @@ export async function buildTerminalStep(params, bundle, state, blockedReason) {
226
229
  if (!reportRendered) {
227
230
  return { kind: "blocked", state, bundle, reason: blockedReason };
228
231
  }
229
- const finalReportPath = await promoteCompletedReport(params.root, params.artifactsDir);
232
+ const questionRun = bundle.review_plan !== undefined ||
233
+ Boolean(await readQuestionReviewRunId(params.artifactsDir, { includeEnded: true })) ||
234
+ await hasWorkingQuestionReportMarker(params.artifactsDir);
235
+ const finalReportPath = questionRun
236
+ ? await withArtifactTreeHold(params.artifactsDir, undefined, () => promoteCompletedReport(params.root, params.artifactsDir))
237
+ : await promoteCompletedReport(params.root, params.artifactsDir);
238
+ if (questionRun && finalReportPath === auditReportPath(params.artifactsDir)) {
239
+ return { kind: "blocked", state, bundle,
240
+ reason: "The current question report and its custody records could not be verified and promoted. Restore the matching question plan, accepted answers and report or resolve the reported archive issue, then run next-step again. The working audit was kept." };
241
+ }
230
242
  return {
231
243
  kind: "complete",
232
244
  state,
@@ -1602,117 +1614,20 @@ export async function checkFinalizationCycle(ctx) {
1602
1614
  "obligations are erroneously invalidating each other.",
1603
1615
  };
1604
1616
  }
1617
+ // ── advance engine binding ────────────────────────────────────────────────────
1605
1618
  /**
1606
- * A FRESH empty carry — a factory, never a shared constant. The carry is
1607
- * MUTATED in place (`mergeFoldAdvisoriesInto` appends to both arrays), so two
1608
- * holders that received the same object would alias: the persistent carry is
1609
- * read as `emptyFoldAdvisories()`, merged into, and persisted, and a shared
1610
- * constant would mean the "empty" sentinel itself grew the advisories — after
1611
- * which every `writePendingAdvisories(emptyFoldAdvisories())` call is no longer
1612
- * empty, stops deleting the file, and re-states the advisory on EVERY later
1613
- * emission. That is not hypothetical: it is what a shallow spread of the
1614
- * constant did, and it turned the once-only property into once-per-emission.
1619
+ * Per-call execution dependencies threaded to every audit obligation executor.
1620
+ * Mirrors remediate-code's `RemediateCtx`: the shared engine stays agnostic;
1621
+ * audit-code picks its own `Ctx`. The refs carry the fold-local mutable state the
1622
+ * hand-rolled `for` loop kept in closures — the analyzer settings a decisions
1623
+ * file can update mid-fold, the last progress summary surfaced in the terminal
1624
+ * block, and the cycle-guard bookkeeping (transition counter + the no-progress /
1625
+ * finalization-cycle sets the two guards mutate).
1615
1626
  */
1616
- function emptyFoldAdvisories() {
1617
- return { ingestIssues: [], validationWarnings: [] };
1618
- }
1619
- /** `<artifactsDir>/steps/pending-advisories.json` — the drainable prompt carry. */
1620
- function pendingAdvisoriesPath(artifactsDir) {
1621
- return join(artifactsDir, "steps", "pending-advisories.json");
1622
- }
1623
1627
  /** The progress marker a filesystem-watching host reads (see `executeAndRecord`). */
1624
1628
  function deterministicProgressPath(artifactsDir) {
1625
1629
  return join(artifactsDir, "steps", "deterministic-progress.json");
1626
1630
  }
1627
- /**
1628
- * Read the persisted carry. Lenient by design: an absent or unreadable file is
1629
- * an empty carry, because this is a PROMPT convenience over a ledger that
1630
- * remains authoritative — a bookkeeping file must never be able to fail the
1631
- * call it decorates. Shape-checked rather than schema-parsed for the same
1632
- * reason: unrecognized entries are dropped, never thrown on.
1633
- */
1634
- async function readPendingAdvisories(artifactsDir) {
1635
- let raw;
1636
- try {
1637
- raw = JSON.parse(await readFile(pendingAdvisoriesPath(artifactsDir), "utf8"));
1638
- }
1639
- catch {
1640
- return emptyFoldAdvisories();
1641
- }
1642
- if (!isRecord(raw))
1643
- return emptyFoldAdvisories();
1644
- const take = (value) => (Array.isArray(value) ? value : []);
1645
- return {
1646
- ingestIssues: take(raw.ingestIssues),
1647
- validationWarnings: take(raw.validationWarnings),
1648
- };
1649
- }
1650
- /**
1651
- * Persist the carry, or DELETE it when empty. Deleting rather than writing an
1652
- * empty object is what keeps presence a signal: a later fold reads "nothing
1653
- * pending" from absence, and no reader has to distinguish `[]` from "not yet
1654
- * written".
1655
- */
1656
- async function writePendingAdvisories(artifactsDir, advisories) {
1657
- const path = pendingAdvisoriesPath(artifactsDir);
1658
- if (advisoriesEmpty(advisories)) {
1659
- try {
1660
- await unlink(path);
1661
- }
1662
- catch (error) {
1663
- if (!isFileMissingError(error))
1664
- throw error;
1665
- }
1666
- return;
1667
- }
1668
- await writeJsonFile(path, advisories);
1669
- }
1670
- /**
1671
- * Append one fold iteration's advisories to the pending carry. Dedupe by
1672
- * identity signature keeps an issue the SAME ingest re-classifies on a later
1673
- * iteration (it will, while the submission stays broken) from rendering twice;
1674
- * the consuming drain ({@link takeFoldAdvisories}) is the once-per-emit half.
1675
- */
1676
- function mergeFoldAdvisoriesInto(carried, fresh) {
1677
- appendUnseen(carried.ingestIssues, fresh.issues);
1678
- appendUnseen(carried.validationWarnings, fresh.validationWarnings);
1679
- }
1680
- /** Append each advisory whose signature is not already in `target`, in order. */
1681
- function appendUnseen(target, incoming) {
1682
- const seen = new Set(target.map(advisorySignature));
1683
- for (const advisory of incoming) {
1684
- const signature = advisorySignature(advisory);
1685
- if (seen.has(signature))
1686
- continue;
1687
- seen.add(signature);
1688
- target.push(advisory);
1689
- }
1690
- }
1691
- function advisoriesEmpty(advisories) {
1692
- return advisories.ingestIssues.length === 0 && advisories.validationWarnings.length === 0;
1693
- }
1694
- /**
1695
- * Drain the carry: what the NEXT emission must state, now consumed. Clears the
1696
- * in-memory ref AND the persisted copy TOGETHER, so the once-only property holds
1697
- * across a call boundary exactly as it does within one call — a ref cleared
1698
- * without the file would re-state on the next call, and a file left behind after
1699
- * a render would do the same.
1700
- */
1701
- async function takeFoldAdvisories(artifactsDir, ref) {
1702
- const taken = {
1703
- ingestIssues: ref.value.ingestIssues,
1704
- validationWarnings: ref.value.validationWarnings,
1705
- };
1706
- ref.value = emptyFoldAdvisories();
1707
- await writePendingAdvisories(artifactsDir, emptyFoldAdvisories());
1708
- return taken;
1709
- }
1710
- /** Content identity of one advisory, across both channels. */
1711
- function advisorySignature(advisory) {
1712
- const workItemId = "work_item_id" in advisory ? (advisory.work_item_id ?? "") : "";
1713
- const code = "code" in advisory ? advisory.code : "warning";
1714
- return `${code}|${workItemId}|${advisory.message}`;
1715
- }
1716
1631
  /**
1717
1632
  * A deterministic-executor `emit` of a blocked step — the `!progress_made`
1718
1633
  * dead-end the hand loop returned directly from `executeAndRecord`.
@@ -1927,206 +1842,60 @@ async function runDesignReviewObligation(bundle, ctx) {
1927
1842
  }
1928
1843
  return { kind: "transition", state: branch.bundle };
1929
1844
  }
1930
- /** Consume available inspection results once at the full fold boundary, whatever inquiry is pending. */
1931
- async function ingestAvailableInspectionResults(bundle, ctx) {
1932
- // First fold every strictly-bound result that still belongs to the pending
1933
- // set. Filtering against bundle truth makes crash recovery idempotent: an
1934
- // accepted ledger written before core ingestion is retried, while results
1935
- // already reflected in coverage are not replayed.
1936
- const currentRun = await loadCurrentActiveReviewRun(ctx.params.artifactsDir);
1937
- let ingestIssues = [];
1938
- let rawIngestIssues = [];
1939
- let validationWarnings = [];
1940
- if (currentRun) {
1941
- let acceptedResults = [];
1942
- let completedIds = [];
1943
- // The line index is built HERE (once per fold) rather than inside the ingest
1944
- // so the accept decision sees the same disk truth `runAuditStep`'s batch gate
1945
- // validates against; the audit-task manifest comes from the same bundle.
1946
- const lineIndexForIngest = bundle.repo_manifest
1947
- ? await buildLineIndex(requireSourceRoot(ctx.params), bundle.repo_manifest)
1948
- : undefined;
1949
- // The set replayed below. The ingest validates those entries again against
1950
- // this same tree, so the batch gate cannot refuse what it is handed.
1951
- const pendingIds = new Set(buildPendingAuditTasks(bundle).map((task) => task.task_id));
1952
- try {
1953
- const ingested = await ingestAuditHostResults({
1954
- root: ctx.params.root,
1955
- sourceRoot: requireSourceRoot(ctx.params),
1956
- artifactsDir: ctx.params.artifactsDir,
1957
- runId: currentRun.run_id,
1958
- auditTasks: bundle.audit_tasks ?? [],
1959
- lineIndex: lineIndexForIngest,
1960
- pendingTaskIds: pendingIds,
1961
- });
1962
- acceptedResults = ingested.accepted_results;
1963
- ingestIssues = ingested.issues;
1964
- rawIngestIssues = ingested.raw_issues;
1965
- validationWarnings = ingested.validation_warnings;
1966
- completedIds = ingested.completed_work_item_ids;
1967
- }
1968
- catch (error) {
1969
- // No handoff exists on the first visit, or prepare was interrupted before
1970
- // all binding artifacts landed. Re-preparing below restores it exactly:
1971
- // the prepare writes the workload, result map and binding set together,
1972
- // so a partial trio is overwritten whole.
1973
- //
1974
- // A STALE binding set is deliberately NOT in this class and must not be
1975
- // added to it: the ingest already classifies it and returns an issue
1976
- // WITHOUT throwing (see `StaleAuditHostTaskBindingsError`), precisely so
1977
- // the fold reaches the re-prepare below instead of aborting here. An
1978
- // error that arrives at this line was not classified by the ingest, and
1979
- // swallowing it would turn an unreadable handoff into a silent one.
1980
- if (!isFileMissingError(error))
1981
- throw error;
1982
- }
1983
- // The ingest CLASSIFIES every failed read — a submission that never
1984
- // arrived, unreadable bytes (an EACCES or a directory at the bound path
1985
- // reads as malformed WITH the OS detail in its message), a body that fails
1986
- // the contract, a replayed result id. Those classifications used to die in
1987
- // the caller that computed them; they now land on the ledger and, below,
1988
- // in the re-emitted step the host actually reads. The completed set rides
1989
- // along so a repaired item closes its own record.
1990
- await recordHostResultOutcomes(ctx.params.artifactsDir, currentRun.run_id, {
1991
- issues: rawIngestIssues,
1992
- acceptedIds: completedIds,
1993
- });
1994
- // Even a refused-only arrival must be visible on the next host step.
1995
- mergeFoldAdvisoriesInto(ctx.foldAdvisoriesRef.value, { issues: ingestIssues, validationWarnings });
1996
- await writePendingAdvisories(ctx.params.artifactsDir, ctx.foldAdvisoriesRef.value);
1997
- const pendingAccepted = acceptedResults.filter((result) => pendingIds.has(result.task_id));
1998
- if (pendingAccepted.length > 0) {
1999
- // Forced, lock-free, against the CARRIED bundle: the fold owns the one
2000
- // hold and the one persist.
2001
- const ingested = await runAuditStepUnlocked({
2002
- root: ctx.params.root,
2003
- sourceRoot: requireSourceRoot(ctx.params),
2004
- artifactsDir: ctx.params.artifactsDir,
2005
- preferredExecutor: "result_ingestion_executor",
2006
- auditResultsData: [...pendingAccepted],
2007
- }, bundle);
2008
- return ingested.updated_bundle;
2009
- }
1845
+ /** Raw fallback errors may quote submitted text, paths, or schema values. */
1846
+ function questionResultCorrection(reason) {
1847
+ if (reason === "Result assignment differs from its destination" ||
1848
+ reason === "Review submission does not match the current issued assignment, question revision and snapshot") {
1849
+ return "Binding mismatch. Copy the assignment, question, revision, and snapshot IDs from the current workload.";
1850
+ }
1851
+ if (reason.startsWith("Source is outside this assignment:")) {
1852
+ return "Source is outside the assignment. Use only source admitted in the current binding.";
1853
+ }
1854
+ if (reason.startsWith("Source span is outside the issued file:")) {
1855
+ return "Source lines are outside the issued file. Check the span against the frozen source.";
1856
+ }
1857
+ if (reason.startsWith("Evidence was not issued for this assignment:") ||
1858
+ reason.startsWith("Observation links unavailable or unissued evidence:")) {
1859
+ return "Evidence is unavailable or unissued for this assignment. Check the current evidence and observation IDs.";
2010
1860
  }
2011
- return bundle;
1861
+ if (reason === "Conflicting reuse of an accepted review submission ID") {
1862
+ return "Submission ID already used for different content. Replay only the exact accepted answer under that ID.";
1863
+ }
1864
+ if (reason.startsWith("Unknown or duplicate requested part:") ||
1865
+ reason.startsWith("Review part has unsupported observation links:")) {
1866
+ return "Requested part or observation links are invalid. Check the parts and links against the current binding.";
1867
+ }
1868
+ return "Could not accept the result. Check that it is readable JSON and meets the current answer contract.";
2012
1869
  }
2013
1870
  async function runHostDelegationObligation(bundle, ctx) {
2014
- const decision = decideNextStep(bundle, { emitStaleness: false });
2015
- const state = decision.state;
2016
- if (!decision.selected_executor) {
2017
- return emitNoExecutorBlocked(bundle, ctx, decision);
2018
- }
2019
- if (!isHostDelegationExecutor(decision.selected_executor)) {
2020
- return runDeterministicExecutor(bundle, ctx);
2021
- }
2022
- // The UNLOCKED variant: the fold already holds the artifact-tree lock, and
2023
- // `withFileLock` is non-reentrant — taking the artifact-tree hold here would
2024
- // be a deterministic FileLockTimeoutError on the audit loop's most common
2025
- // exit path. Its blocked core state rides the emit's `state` below, so the
2026
- // fold's single commit persists it (the pause's own persist was the split's
2027
- // other half).
2028
- const review = await ensureSemanticReviewRunUnlocked({
2029
- root: ctx.params.root,
2030
- sourceRoot: requireSourceRoot(ctx.params),
2031
- artifactsDir: ctx.params.artifactsDir,
2032
- bundle,
2033
- state,
2034
- obligationId: decision.selected_obligation,
1871
+ const sourceRoot = requireSourceRoot(ctx.params);
1872
+ const cycle = await deriveQuestionCycleUnlocked({
1873
+ root: ctx.params.root, sourceRoot, artifactsDir: ctx.params.artifactsDir, bundle,
1874
+ });
1875
+ const carried = { ...bundle, question_cycle: cycle };
1876
+ if (bundle.audit_findings !== undefined && !(await hasCurrentQuestionReport(ctx.params.artifactsDir))) {
1877
+ // A new accepted answer may not change plan membership or source revision.
1878
+ // Re-synthesize rather than repeatedly presenting a no-longer-current pair.
1879
+ delete carried.audit_findings;
1880
+ delete carried.audit_report;
1881
+ delete carried.synthesis_narrative;
1882
+ }
1883
+ if (cycle.pending.length === 0)
1884
+ return { kind: "transition", state: carried };
1885
+ const pendingIds = new Set(cycle.pending.map(({ assignment }) => assignment.assignment_id));
1886
+ const rejections = cycle.issues.filter(issue => pendingIds.has(issue.assignment_id)).slice(0, 8)
1887
+ .map(issue => ({ assignmentId: issue.assignment_id, guidance: questionResultCorrection(issue.reason) }));
1888
+ const published = await publishAuditQuestionWorkload({
1889
+ root: ctx.params.root, sourceRoot, artifactsDir: ctx.params.artifactsDir, runId: cycle.runId, bindings: cycle.pending,
2035
1890
  });
2036
- // What THIS ingest saw. Deliberately NOT drained here: the carried advisories
2037
- // are taken at the fold's single emission boundary (`runDeterministicForNextStep`),
2038
- // which every emitted step kind passes through — draining at this obligation
2039
- // would state them only for a semantic-review emission and silently drop them
2040
- // the moment the run's next step happened to be a different kind
2041
- // (design_review_conceptual, charter_*, synthesis_narrative…).
2042
1891
  return {
2043
1892
  kind: "emit",
2044
- step: {
2045
- kind: "semantic_review",
2046
- selectedExecutor: decision.selected_executor,
2047
- ...review,
2048
- },
2049
- // The pause's blocked core state — the fold's single commit persists it
2050
- // (the locking variant's own write was the other half of the split).
2051
- state: review.bundle,
1893
+ step: { kind: "question_review", state: deriveAuditState(carried, { emitStaleness: false }), bundle: carried,
1894
+ runId: cycle.runId, workloadPath: published.workload_path, pendingCount: cycle.pending.length,
1895
+ rejectedCount: cycle.issues.length, rejections },
1896
+ state: carried,
2052
1897
  };
2053
1898
  }
2054
- /**
2055
- * State the fold's carried advisories on the step about to be emitted, and
2056
- * DRAIN them.
2057
- *
2058
- * THE single emission-boundary drain. It lives here, not at any one obligation,
2059
- * because the property is "stated on exactly one emitted step, whichever call
2060
- * and whichever step kind emits it": a carry produced by a call-ending
2061
- * transition must survive to a later fold, and that fold's step may be ANY
2062
- * kind. Hanging the drain off the semantic-review obligation made it correct
2063
- * only for as long as the next step happened to be a semantic review.
2064
- *
2065
- * Advisories are only ever RENDERED by the semantic-review step today (the
2066
- * other kinds carry no advisory channel), so a carry drained onto one of them
2067
- * still reaches the operator — as a stated line in this step's prompt — rather
2068
- * than being lost. A step with nothing carried is returned untouched.
2069
- */
2070
- async function withFoldAdvisories(step, ctx) {
2071
- const carried = await takeFoldAdvisories(ctx.params.artifactsDir, ctx.foldAdvisoriesRef);
2072
- if (advisoriesEmpty(carried))
2073
- return step;
2074
- if (step.kind !== "semantic_review") {
2075
- return {
2076
- ...step,
2077
- // An architecture step that carries a ready-inspection run names that
2078
- // run's workload in its own task, above the carried report (the
2079
- // `withReadyInspection` section); the pending items are in it.
2080
- advisoryNotice: renderCarriedAdvisoryLines(carried, step.inspectionRun !== undefined && step.kind !== "blocked"
2081
- ? "named_above"
2082
- : "next_call"),
2083
- };
2084
- }
2085
- return {
2086
- ...step,
2087
- ingestIssues: [...(step.ingestIssues ?? []), ...carried.ingestIssues],
2088
- validationWarnings: [
2089
- ...(step.validationWarnings ?? []),
2090
- ...carried.validationWarnings,
2091
- ],
2092
- };
2093
- }
2094
- /**
2095
- * The advisory lines a step that carries no advisory CHANNEL still states. A
2096
- * carried advisory is never dropped on the floor because the run happened to
2097
- * move on to a different step kind — it is rendered as text, in the same
2098
- * wording the semantic-review step's own sections use.
2099
- *
2100
- * "The same wording" is now MECHANICAL: both callers render through the one
2101
- * {@link renderIngestReportLines}. This function used to hand-copy the split,
2102
- * the bullet format and the headings, and the copy had already gone stale
2103
- * against the section it claimed to match.
2104
- *
2105
- * The report rides a step of another kind and follows its whole task, so the
2106
- * workload is `named_above` when that task names a ready-inspection workload,
2107
- * and `next_call` otherwise.
2108
- */
2109
- function renderCarriedAdvisoryLines(carried, workload) {
2110
- return renderIngestReportLines({
2111
- issues: carried.ingestIssues,
2112
- remedy: auditIngestRemedy,
2113
- workload,
2114
- advisories: carried.validationWarnings,
2115
- });
2116
- }
2117
- /** Emit the no-executor blocked step (the hand loop's `!selected_executor` arm). */
2118
- async function emitNoExecutorBlocked(bundle, ctx, decision) {
2119
- const state = decision.state;
2120
- const reason = ctx.lastSummaryRef.value || decision.reason;
2121
- await writeHandoffOnly({
2122
- root: ctx.params.root,
2123
- artifactsDir: ctx.params.artifactsDir,
2124
- bundle,
2125
- audit_state: state,
2126
- progress_summary: reason,
2127
- });
2128
- return { kind: "emit", step: { kind: "blocked", state, bundle, reason }, state: bundle };
2129
- }
2130
1899
  /**
2131
1900
  * Wrap each obligation so the fold's CURRENT carried bundle is always
2132
1901
  * observable on the ctx — the commit-on-throw path persists it, and a throw
@@ -2139,6 +1908,8 @@ function trackFoldBundle(obligations) {
2139
1908
  return obligations.map((obligation) => ({
2140
1909
  ...obligation,
2141
1910
  execute: async (bundle, ctx) => {
1911
+ if (bundle.review_tooling_qualification)
1912
+ assertQualifiedReviewObligation(obligation.id);
2142
1913
  // Liveness for the LONG deterministic drain (the >2min stale-artifact
2143
1914
  // re-extraction next-step that blew a caller timeout with no output). The
2144
1915
  // per-execution label is set HERE because this is the one place every fold
@@ -2223,11 +1994,6 @@ export async function runDeterministicForNextStep(params) {
2223
1994
  heartbeat.stop();
2224
1995
  }
2225
1996
  }
2226
- const ARCHITECTURE_WORK_STEPS = new Set([
2227
- "charter_extraction", "charter_comparison", "charter_fidelity",
2228
- "design_review_parallel", "design_review_contract", "design_review_conceptual",
2229
- "charter_clarification", "systemic_challenge",
2230
- ]);
2231
1997
  async function runDeterministicFold(params, heartbeat) {
2232
1998
  // THE fold's one git-index probe cache (`ScopeIndexMemo`). It is created here
2233
1999
  // and held on `params` — the object every dispatch path already shares, the
@@ -2242,7 +2008,6 @@ async function runDeterministicFold(params, heartbeat) {
2242
2008
  analyzersRef,
2243
2009
  lastSummaryRef: { value: "" },
2244
2010
  heartbeat,
2245
- foldAdvisoriesRef: { value: emptyFoldAdvisories() },
2246
2011
  dispatchOrdinalRef: { value: 0 },
2247
2012
  dispatchedSignatures: new Set(),
2248
2013
  seenStateSignatures: new Set(),
@@ -2269,16 +2034,22 @@ async function runDeterministicFold(params, heartbeat) {
2269
2034
  // `finally` below runs on the throw path too, still under the hold.
2270
2035
  const holdStartMs = Date.now();
2271
2036
  let chargedExecutions;
2272
- let ingestionExecutions = 0;
2273
2037
  let intakeExecutions = 0;
2274
- await recoverStagedSubmissions(params.artifactsDir);
2038
+ let startBundle = await loadArtifactBundle(params.artifactsDir, {});
2039
+ if (startBundle.review_tooling_qualification) {
2040
+ if (params.since !== undefined || params.autoFix?.enabled !== undefined || params.autoFix?.dryRun) {
2041
+ throw new Error("Qualified question review cannot change source scope or formatting consent.");
2042
+ }
2043
+ params.sourceRoot = await readRunSourceRoot(params.root, params.artifactsDir);
2044
+ await assertQualifiedReviewStillCurrent(startBundle, params.sourceRoot, params.scopeIndexMemo);
2045
+ // A verified review can resume its interrupted report synthesis only.
2046
+ await recoverStagedSubmissions(params.artifactsDir, lane => lane === GATE_LANES.synthesis_narrative);
2047
+ }
2048
+ else {
2049
+ await recoverStagedSubmissions(params.artifactsDir);
2050
+ params.sourceRoot = await ensureRunSourceRoot(params.root, params.artifactsDir);
2051
+ }
2275
2052
  const previousConsent = await readRunConsentUnlocked(params.root, params.artifactsDir);
2276
- // The run's frozen snapshot, under the same hold as the consent record it
2277
- // shares a lifetime with: created at run start, re-checked out on resume.
2278
- // Every content read of this fold uses it (`requireSourceRoot`); the
2279
- // complete-run rule lives in `ensureRunSourceRoot`, shared with every
2280
- // standalone step command.
2281
- params.sourceRoot = await ensureRunSourceRoot(params.root, params.artifactsDir);
2282
2053
  if (params.since !== undefined) {
2283
2054
  params.since = await resolveRunSince(params.root, params.artifactsDir, params.since);
2284
2055
  }
@@ -2288,26 +2059,25 @@ async function runDeterministicFold(params, heartbeat) {
2288
2059
  if (params.externalAcquisition?.enabled)
2289
2060
  applyRunConsent(params.externalAcquisition, consent);
2290
2061
  params.autoFix = { enabled: consent.auto_fix, dryRun: consent.dry_run };
2291
- // The PERSISTED carry, read back under the hold. A transition that ENDED
2292
- // an earlier call left its advisories on disk for the next emission to
2293
- // state, and that emission may be this call's — the ctx ref starts empty
2294
- // per call, so without this read the durable half would be write-only and
2295
- // the advisories would still die at the call boundary. Seeding the ref
2296
- // (rather than merging at the emit site) keeps ONE drain point, so the
2297
- // once-only property is the same one the in-call path already relies on.
2298
- ctx.foldAdvisoriesRef.value = await readPendingAdvisories(params.artifactsDir);
2299
- let startBundle = await loadArtifactBundle(params.artifactsDir);
2300
2062
  if (consent.auto_fix && !previousConsent.auto_fix && !consent.dry_run) {
2301
2063
  delete startBundle.auto_fixes_applied;
2302
2064
  }
2303
2065
  ctx.currentBundleRef.value = startBundle;
2304
2066
  try {
2305
- // Observe source integrity against the fresh carried authority, under
2306
- // the same hold and before any old host submission can be ingested.
2307
- if (startBundle.audit_state?.status !== "complete" && startBundle.repo_manifest) {
2308
- const taskFiles = [...new Set(buildPendingAuditTasks(startBundle).flatMap((task) => task.file_paths))];
2309
- if (taskFiles.length > 0) {
2310
- const integrity = await checkFileIntegrity(requireSourceRoot(params), startBundle.repo_manifest, taskFiles);
2067
+ // Check the same frozen read set that the active review stage uses.
2068
+ // Before question planning, deep charter lanes also bind admitted source.
2069
+ if (!startBundle.review_tooling_qualification && startBundle.audit_state?.status !== "complete" && startBundle.repo_manifest) {
2070
+ let admittedFiles = [];
2071
+ if (startBundle.review_plan) {
2072
+ const scope = reviewSourceScope(startBundle);
2073
+ admittedFiles = [...new Set([...scope.allowedSourcePaths, ...scope.allowedContractPaths])];
2074
+ }
2075
+ else if (ceilingRequestsCharters(resolveCharterCeiling(startBundle.intent_checkpoint))) {
2076
+ const { memberPaths, docPaths } = charterPacketReadSet(startBundle);
2077
+ admittedFiles = [...memberPaths, ...docPaths];
2078
+ }
2079
+ if (admittedFiles.length > 0) {
2080
+ const integrity = await checkFileIntegrity(requireSourceRoot(params), startBundle.repo_manifest, admittedFiles);
2311
2081
  if (!integrity.is_clean) {
2312
2082
  process.stderr.write(`[audit-code] nextStep: integrity check - ${integrity.changed_files.length} changed, ` +
2313
2083
  `${integrity.missing_files.length} missing, ${integrity.io_errors.length} io-error(s); re-running intake.\n`);
@@ -2322,32 +2092,14 @@ async function runDeterministicFold(params, heartbeat) {
2322
2092
  }
2323
2093
  }
2324
2094
  }
2325
- if (startBundle.audit_tasks && startBundle.audit_state?.status !== "complete" &&
2326
- deriveAuditState(startBundle, { emitStaleness: false }).obligations.find((obligation) => obligation.id === "planning_artifacts")?.state === "satisfied") {
2327
- const beforeIngest = startBundle;
2328
- startBundle = await ingestAvailableInspectionResults(startBundle, ctx);
2329
- ingestionExecutions = startBundle === beforeIngest ? 0 : 1;
2330
- ctx.currentBundleRef.value = startBundle;
2331
- }
2332
2095
  const engineOutcome = await advance({
2333
2096
  priority: PRIORITY,
2334
2097
  obligations: trackFoldBundle(buildAuditObligations()),
2335
2098
  }, startBundle, ctx, {
2336
2099
  maxTransitions: engineMaxTransitions(),
2337
- maxExecutions: MAX_DRAIN_STEPS - ingestionExecutions - intakeExecutions,
2100
+ maxExecutions: MAX_DRAIN_STEPS - intakeExecutions,
2338
2101
  });
2339
- chargedExecutions = engineOutcome.executions + ingestionExecutions + intakeExecutions;
2340
- if (engineOutcome.step && engineOutcome.step.kind !== "terminal_intent" && ARCHITECTURE_WORK_STEPS.has(engineOutcome.step.kind) &&
2341
- buildPendingAuditTasks(engineOutcome.state).length > 0) {
2342
- const inspection = await ensureSemanticReviewRunUnlocked({
2343
- root: params.root, sourceRoot: requireSourceRoot(params), artifactsDir: params.artifactsDir,
2344
- bundle: engineOutcome.state,
2345
- state: deriveAuditState(engineOutcome.state, { emitStaleness: false }),
2346
- obligationId: "audit_tasks_completed",
2347
- emittedStepKind: engineOutcome.step.kind,
2348
- });
2349
- engineOutcome.step = { ...engineOutcome.step, inspectionRun: inspection.activeReviewRun };
2350
- }
2102
+ chargedExecutions = engineOutcome.executions + intakeExecutions;
2351
2103
  await assertOwnership();
2352
2104
  await commitFold(params.artifactsDir, engineOutcome.state, ctx.tx);
2353
2105
  return engineOutcome;
@@ -2409,7 +2161,7 @@ async function runDeterministicFold(params, heartbeat) {
2409
2161
  // conversion below promotes — the carry has nowhere left to be stated, and
2410
2162
  // the run is over.
2411
2163
  if (outcome.step && outcome.step.kind !== "terminal_intent") {
2412
- return await withFoldAdvisories(outcome.step, ctx);
2164
+ return outcome.step;
2413
2165
  }
2414
2166
  if (outcome.step) {
2415
2167
  // Guard terminals convert POST-commit, POST-hold: buildTerminalStep can
@@ -2440,17 +2192,7 @@ async function runDeterministicFold(params, heartbeat) {
2440
2192
  // budget makes unreachable in practice — a backstop firing IS the anomaly).
2441
2193
  const stalled = describeStoppedFold(outcome);
2442
2194
  if (stalled) {
2443
- // The engine's bound is its runaway backstop, and audit deliberately
2444
- // supplies no stateSignature (cycle detection lives in ctx-level guards with
2445
- // tolerance windows). A cause those guards miss — observed 2026-07-30: an
2446
- // errored rolling packet left `audit_tasks_completed` actionable while its
2447
- // error-shaped result files made the pending frontier look answered — used
2448
- // to CRASH next-step with exit 1, where the same class of stall
2449
- // (no_capable_pool) gets a graceful resumable pause. The engine now REPORTS
2450
- // the non-convergence instead of throwing it, so the pause is built from the
2451
- // outcome's own fields — no error message is parsed to learn either that the
2452
- // bound fired or which obligation was spinning.
2453
- const bundle = await loadArtifactBundle(params.artifactsDir);
2195
+ const bundle = await loadArtifactBundle(params.artifactsDir, {});
2454
2196
  const decision = decideNextStep(bundle);
2455
2197
  return {
2456
2198
  kind: "blocked",
@@ -2458,16 +2200,14 @@ async function runDeterministicFold(params, heartbeat) {
2458
2200
  bundle,
2459
2201
  reason: `The deterministic fold ${stalled.cause} — an obligation is re-selecting without clearing its own ` +
2460
2202
  `actionable state (${stalled.spinning}). ` +
2461
- "The run is paused resumably, not crashed: inspect the run's task-results/ for error-shaped " +
2462
- "result files whose tasks never completed (delete them to re-dispatch those tasks), or hand " +
2463
- "results in with `audit-code ingest-results --results <file>`; then re-run next-step.",
2203
+ "The run is paused. Inspect its current question workload and recorded errors, then re-run next-step.",
2464
2204
  };
2465
2205
  }
2466
2206
  // No actionable obligation: the fold reached completion (e.g. synthesis flipped
2467
2207
  // the state to complete and every obligation is now satisfied). Build the
2468
2208
  // terminal: `complete` when the state is complete / a report is rendered,
2469
2209
  // else blocked. A complete state's summary is the decision's own reason.
2470
- const bundle = await loadArtifactBundle(params.artifactsDir);
2210
+ const bundle = await loadArtifactBundle(params.artifactsDir, {});
2471
2211
  const decision = decideNextStep(bundle);
2472
2212
  const state = decision.state;
2473
2213
  return buildTerminalStep(params, bundle, state, state.status === "complete"