audit-tools 0.51.7 → 0.51.9

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 (665) hide show
  1. package/dist/audit/clarification/blastRadius.d.ts +17 -16
  2. package/dist/audit/clarification/blastRadius.d.ts.map +1 -1
  3. package/dist/audit/clarification/blastRadius.js +48 -44
  4. package/dist/audit/clarification/blastRadius.js.map +1 -1
  5. package/dist/audit/clarification/dials.d.ts +4 -4
  6. package/dist/audit/clarification/dials.d.ts.map +1 -1
  7. package/dist/audit/clarification/dials.js +1 -0
  8. package/dist/audit/clarification/dials.js.map +1 -1
  9. package/dist/audit/clarification/partition.d.ts +12 -21
  10. package/dist/audit/clarification/partition.d.ts.map +1 -1
  11. package/dist/audit/clarification/partition.js +52 -59
  12. package/dist/audit/clarification/partition.js.map +1 -1
  13. package/dist/audit/clarification/riskGate.d.ts +2 -2
  14. package/dist/audit/clarification/riskGate.d.ts.map +1 -1
  15. package/dist/audit/clarification/riskGate.js +1 -0
  16. package/dist/audit/clarification/riskGate.js.map +1 -1
  17. package/dist/audit/clarification/voiQueue.d.ts +3 -3
  18. package/dist/audit/clarification/voiQueue.d.ts.map +1 -1
  19. package/dist/audit/clarification/voiQueue.js +1 -0
  20. package/dist/audit/clarification/voiQueue.js.map +1 -1
  21. package/dist/audit/cli/auditStep.d.ts +14 -2
  22. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  23. package/dist/audit/cli/auditStep.js +13 -5
  24. package/dist/audit/cli/auditStep.js.map +1 -1
  25. package/dist/audit/cli/charterClarificationPrompt.d.ts +6 -9
  26. package/dist/audit/cli/charterClarificationPrompt.d.ts.map +1 -1
  27. package/dist/audit/cli/charterClarificationPrompt.js +35 -47
  28. package/dist/audit/cli/charterClarificationPrompt.js.map +1 -1
  29. package/dist/audit/cli/charterComparisonPrompt.d.ts +14 -0
  30. package/dist/audit/cli/charterComparisonPrompt.d.ts.map +1 -0
  31. package/dist/audit/cli/charterComparisonPrompt.js +111 -0
  32. package/dist/audit/cli/charterComparisonPrompt.js.map +1 -0
  33. package/dist/audit/cli/charterExtractionPrompt.d.ts +14 -17
  34. package/dist/audit/cli/charterExtractionPrompt.d.ts.map +1 -1
  35. package/dist/audit/cli/charterExtractionPrompt.js +81 -104
  36. package/dist/audit/cli/charterExtractionPrompt.js.map +1 -1
  37. package/dist/audit/cli/charterFidelityPrompt.d.ts +14 -0
  38. package/dist/audit/cli/charterFidelityPrompt.d.ts.map +1 -0
  39. package/dist/audit/cli/charterFidelityPrompt.js +58 -0
  40. package/dist/audit/cli/charterFidelityPrompt.js.map +1 -0
  41. package/dist/audit/cli/conceptualDispatch.d.ts +39 -6
  42. package/dist/audit/cli/conceptualDispatch.d.ts.map +1 -1
  43. package/dist/audit/cli/conceptualDispatch.js +59 -12
  44. package/dist/audit/cli/conceptualDispatch.js.map +1 -1
  45. package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
  46. package/dist/audit/cli/confirmIntentStep.js +46 -2
  47. package/dist/audit/cli/confirmIntentStep.js.map +1 -1
  48. package/dist/audit/cli/dispatch/hostHandoff.d.ts +18 -6
  49. package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
  50. package/dist/audit/cli/dispatch/hostHandoff.js +525 -67
  51. package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
  52. package/dist/audit/cli/fanoutLanes.d.ts +24 -0
  53. package/dist/audit/cli/fanoutLanes.d.ts.map +1 -1
  54. package/dist/audit/cli/fanoutLanes.js +9 -1
  55. package/dist/audit/cli/fanoutLanes.js.map +1 -1
  56. package/dist/audit/cli/foldTransaction.d.ts.map +1 -1
  57. package/dist/audit/cli/foldTransaction.js +14 -3
  58. package/dist/audit/cli/foldTransaction.js.map +1 -1
  59. package/dist/audit/cli/forceSynthesisCommand.d.ts.map +1 -1
  60. package/dist/audit/cli/forceSynthesisCommand.js +4 -1
  61. package/dist/audit/cli/forceSynthesisCommand.js.map +1 -1
  62. package/dist/audit/cli/intakeCommand.d.ts.map +1 -1
  63. package/dist/audit/cli/intakeCommand.js +1 -0
  64. package/dist/audit/cli/intakeCommand.js.map +1 -1
  65. package/dist/audit/cli/laneSubmissions.d.ts +18 -12
  66. package/dist/audit/cli/laneSubmissions.d.ts.map +1 -1
  67. package/dist/audit/cli/laneSubmissions.js +40 -4
  68. package/dist/audit/cli/laneSubmissions.js.map +1 -1
  69. package/dist/audit/cli/laneValidators.d.ts.map +1 -1
  70. package/dist/audit/cli/laneValidators.js +14 -14
  71. package/dist/audit/cli/laneValidators.js.map +1 -1
  72. package/dist/audit/cli/nextStepCommand.d.ts +7 -0
  73. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  74. package/dist/audit/cli/nextStepCommand.js +206 -31
  75. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  76. package/dist/audit/cli/nextStepHelpers.d.ts +92 -28
  77. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  78. package/dist/audit/cli/nextStepHelpers.js +363 -126
  79. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  80. package/dist/audit/cli/prompts.d.ts +10 -0
  81. package/dist/audit/cli/prompts.d.ts.map +1 -1
  82. package/dist/audit/cli/prompts.js +3 -1
  83. package/dist/audit/cli/prompts.js.map +1 -1
  84. package/dist/audit/cli/reviewRun.d.ts +12 -0
  85. package/dist/audit/cli/reviewRun.d.ts.map +1 -1
  86. package/dist/audit/cli/reviewRun.js +242 -29
  87. package/dist/audit/cli/reviewRun.js.map +1 -1
  88. package/dist/audit/cli/sampleRunCommand.d.ts +12 -4
  89. package/dist/audit/cli/sampleRunCommand.d.ts.map +1 -1
  90. package/dist/audit/cli/semanticReviewStep.d.ts +9 -0
  91. package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
  92. package/dist/audit/cli/semanticReviewStep.js +71 -30
  93. package/dist/audit/cli/semanticReviewStep.js.map +1 -1
  94. package/dist/audit/cli/statusCommand.d.ts.map +1 -1
  95. package/dist/audit/cli/statusCommand.js +29 -66
  96. package/dist/audit/cli/statusCommand.js.map +1 -1
  97. package/dist/audit/cli/stepScaffold.d.ts +43 -2
  98. package/dist/audit/cli/stepScaffold.d.ts.map +1 -1
  99. package/dist/audit/cli/stepScaffold.js +24 -10
  100. package/dist/audit/cli/stepScaffold.js.map +1 -1
  101. package/dist/audit/cli/steps.d.ts +52 -29
  102. package/dist/audit/cli/steps.d.ts.map +1 -1
  103. package/dist/audit/cli/steps.js +44 -14
  104. package/dist/audit/cli/steps.js.map +1 -1
  105. package/dist/audit/cli/synthesizeCommand.d.ts.map +1 -1
  106. package/dist/audit/cli/synthesizeCommand.js +4 -1
  107. package/dist/audit/cli/synthesizeCommand.js.map +1 -1
  108. package/dist/audit/contracts/workerSchemas.d.ts +65 -16
  109. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  110. package/dist/audit/contracts/workerSchemas.js +89 -8
  111. package/dist/audit/contracts/workerSchemas.js.map +1 -1
  112. package/dist/audit/contracts/wrapperResponse.d.ts +14 -21
  113. package/dist/audit/contracts/wrapperResponse.d.ts.map +1 -1
  114. package/dist/audit/contracts/wrapperResponse.js +0 -1
  115. package/dist/audit/contracts/wrapperResponse.js.map +1 -1
  116. package/dist/audit/decompose/findings.d.ts.map +1 -1
  117. package/dist/audit/decompose/findings.js +10 -2
  118. package/dist/audit/decompose/findings.js.map +1 -1
  119. package/dist/audit/extractors/designAssessment.d.ts.map +1 -1
  120. package/dist/audit/extractors/designAssessment.js +13 -4
  121. package/dist/audit/extractors/designAssessment.js.map +1 -1
  122. package/dist/audit/extractors/disposition.d.ts.map +1 -1
  123. package/dist/audit/extractors/disposition.js +17 -5
  124. package/dist/audit/extractors/disposition.js.map +1 -1
  125. package/dist/audit/extractors/graph.d.ts +1 -1
  126. package/dist/audit/extractors/graph.js +1 -1
  127. package/dist/audit/extractors/graphRoutes.d.ts.map +1 -1
  128. package/dist/audit/extractors/graphRoutes.js +224 -17
  129. package/dist/audit/extractors/graphRoutes.js.map +1 -1
  130. package/dist/audit/extractors/leadLineage.d.ts +10 -0
  131. package/dist/audit/extractors/leadLineage.d.ts.map +1 -0
  132. package/dist/audit/extractors/leadLineage.js +44 -0
  133. package/dist/audit/extractors/leadLineage.js.map +1 -0
  134. package/dist/audit/io/artifacts.d.ts.map +1 -1
  135. package/dist/audit/io/artifacts.js +25 -8
  136. package/dist/audit/io/artifacts.js.map +1 -1
  137. package/dist/audit/io/runArtifacts.d.ts +76 -1
  138. package/dist/audit/io/runArtifacts.d.ts.map +1 -1
  139. package/dist/audit/io/runArtifacts.js +113 -20
  140. package/dist/audit/io/runArtifacts.js.map +1 -1
  141. package/dist/audit/io/toolingManifest.d.ts +15 -0
  142. package/dist/audit/io/toolingManifest.d.ts.map +1 -1
  143. package/dist/audit/io/toolingManifest.js +158 -11
  144. package/dist/audit/io/toolingManifest.js.map +1 -1
  145. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  146. package/dist/audit/orchestrator/advance.js +30 -4
  147. package/dist/audit/orchestrator/advance.js.map +1 -1
  148. package/dist/audit/orchestrator/advanceTypes.d.ts +28 -5
  149. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  150. package/dist/audit/orchestrator/artifactMetadata.d.ts.map +1 -1
  151. package/dist/audit/orchestrator/artifactMetadata.js +39 -1
  152. package/dist/audit/orchestrator/artifactMetadata.js.map +1 -1
  153. package/dist/audit/orchestrator/auditTaskUtils.d.ts.map +1 -1
  154. package/dist/audit/orchestrator/auditTaskUtils.js +4 -1
  155. package/dist/audit/orchestrator/auditTaskUtils.js.map +1 -1
  156. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts +11 -17
  157. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts.map +1 -1
  158. package/dist/audit/orchestrator/charterClarificationExecutor.js +61 -93
  159. package/dist/audit/orchestrator/charterClarificationExecutor.js.map +1 -1
  160. package/dist/audit/orchestrator/charterComparisonExecutor.d.ts +24 -0
  161. package/dist/audit/orchestrator/charterComparisonExecutor.d.ts.map +1 -0
  162. package/dist/audit/orchestrator/charterComparisonExecutor.js +110 -0
  163. package/dist/audit/orchestrator/charterComparisonExecutor.js.map +1 -0
  164. package/dist/audit/orchestrator/charterExtractionExecutor.d.ts +34 -20
  165. package/dist/audit/orchestrator/charterExtractionExecutor.d.ts.map +1 -1
  166. package/dist/audit/orchestrator/charterExtractionExecutor.js +80 -106
  167. package/dist/audit/orchestrator/charterExtractionExecutor.js.map +1 -1
  168. package/dist/audit/orchestrator/charterFidelityExecutor.d.ts +20 -0
  169. package/dist/audit/orchestrator/charterFidelityExecutor.d.ts.map +1 -0
  170. package/dist/audit/orchestrator/charterFidelityExecutor.js +76 -0
  171. package/dist/audit/orchestrator/charterFidelityExecutor.js.map +1 -0
  172. package/dist/audit/orchestrator/charterFidelityPacket.d.ts +7 -0
  173. package/dist/audit/orchestrator/charterFidelityPacket.d.ts.map +1 -0
  174. package/dist/audit/orchestrator/charterFidelityPacket.js +68 -0
  175. package/dist/audit/orchestrator/charterFidelityPacket.js.map +1 -0
  176. package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
  177. package/dist/audit/orchestrator/dependencyMap.js +9 -8
  178. package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
  179. package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -1
  180. package/dist/audit/orchestrator/dependencySlices.js +7 -6
  181. package/dist/audit/orchestrator/dependencySlices.js.map +1 -1
  182. package/dist/audit/orchestrator/designReviewProjection.d.ts.map +1 -1
  183. package/dist/audit/orchestrator/designReviewProjection.js +7 -0
  184. package/dist/audit/orchestrator/designReviewProjection.js.map +1 -1
  185. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  186. package/dist/audit/orchestrator/designReviewPrompt.js +58 -19
  187. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  188. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  189. package/dist/audit/orchestrator/executorRunners.js +6 -2
  190. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  191. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  192. package/dist/audit/orchestrator/executors.js +22 -8
  193. package/dist/audit/orchestrator/executors.js.map +1 -1
  194. package/dist/audit/orchestrator/hostInputPause.js +1 -0
  195. package/dist/audit/orchestrator/hostInputPause.js.map +1 -1
  196. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts +40 -0
  197. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
  198. package/dist/audit/orchestrator/intentCheckpointExecutor.js +32 -2
  199. package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
  200. package/dist/audit/orchestrator/intentCheckpointGate.d.ts +5 -3
  201. package/dist/audit/orchestrator/intentCheckpointGate.d.ts.map +1 -1
  202. package/dist/audit/orchestrator/intentCheckpointGate.js +34 -5
  203. package/dist/audit/orchestrator/intentCheckpointGate.js.map +1 -1
  204. package/dist/audit/orchestrator/intentEquivalenceExecutor.d.ts +2 -2
  205. package/dist/audit/orchestrator/intentInterpreter.d.ts +1 -1
  206. package/dist/audit/orchestrator/intentInterpreter.js +1 -1
  207. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  208. package/dist/audit/orchestrator/nextStep.js +3 -1
  209. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  210. package/dist/audit/orchestrator/obligationPolicy.d.ts +2 -1
  211. package/dist/audit/orchestrator/obligationPolicy.d.ts.map +1 -1
  212. package/dist/audit/orchestrator/obligationPolicy.js +19 -7
  213. package/dist/audit/orchestrator/obligationPolicy.js.map +1 -1
  214. package/dist/audit/orchestrator/partitionTaskGraph.d.ts.map +1 -1
  215. package/dist/audit/orchestrator/partitionTaskGraph.js +1 -0
  216. package/dist/audit/orchestrator/partitionTaskGraph.js.map +1 -1
  217. package/dist/audit/orchestrator/resultIngestion.d.ts.map +1 -1
  218. package/dist/audit/orchestrator/resultIngestion.js +3 -1
  219. package/dist/audit/orchestrator/resultIngestion.js.map +1 -1
  220. package/dist/audit/orchestrator/runtimeCommand.d.ts +72 -0
  221. package/dist/audit/orchestrator/runtimeCommand.d.ts.map +1 -1
  222. package/dist/audit/orchestrator/runtimeCommand.js +177 -20
  223. package/dist/audit/orchestrator/runtimeCommand.js.map +1 -1
  224. package/dist/audit/orchestrator/scopeIndexBaseline.d.ts +56 -0
  225. package/dist/audit/orchestrator/scopeIndexBaseline.d.ts.map +1 -0
  226. package/dist/audit/orchestrator/scopeIndexBaseline.js +114 -0
  227. package/dist/audit/orchestrator/scopeIndexBaseline.js.map +1 -0
  228. package/dist/audit/orchestrator/staleness.d.ts +70 -1
  229. package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
  230. package/dist/audit/orchestrator/staleness.js +171 -21
  231. package/dist/audit/orchestrator/staleness.js.map +1 -1
  232. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  233. package/dist/audit/orchestrator/state.js +49 -25
  234. package/dist/audit/orchestrator/state.js.map +1 -1
  235. package/dist/audit/orchestrator/structureExecutors.d.ts.map +1 -1
  236. package/dist/audit/orchestrator/structureExecutors.js +7 -5
  237. package/dist/audit/orchestrator/structureExecutors.js.map +1 -1
  238. package/dist/audit/orchestrator/syntaxResolutionExecutor.d.ts.map +1 -1
  239. package/dist/audit/orchestrator/syntaxResolutionExecutor.js +1 -0
  240. package/dist/audit/orchestrator/syntaxResolutionExecutor.js.map +1 -1
  241. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +13 -2
  242. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
  243. package/dist/audit/orchestrator/systemicChallengeExecutor.js +166 -12
  244. package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
  245. package/dist/audit/reporting/mergeFindings.d.ts.map +1 -1
  246. package/dist/audit/reporting/mergeFindings.js +6 -5
  247. package/dist/audit/reporting/mergeFindings.js.map +1 -1
  248. package/dist/audit/reporting/synthesis.d.ts +117 -0
  249. package/dist/audit/reporting/synthesis.d.ts.map +1 -1
  250. package/dist/audit/reporting/synthesis.js +277 -10
  251. package/dist/audit/reporting/synthesis.js.map +1 -1
  252. package/dist/audit/supervisor/operatorHandoff.d.ts +0 -2
  253. package/dist/audit/supervisor/operatorHandoff.d.ts.map +1 -1
  254. package/dist/audit/supervisor/operatorHandoff.js +0 -3
  255. package/dist/audit/supervisor/operatorHandoff.js.map +1 -1
  256. package/dist/audit/systemic/coveredThemes.d.ts +28 -0
  257. package/dist/audit/systemic/coveredThemes.d.ts.map +1 -0
  258. package/dist/audit/systemic/coveredThemes.js +52 -0
  259. package/dist/audit/systemic/coveredThemes.js.map +1 -0
  260. package/dist/audit/systemic/reviewFileMap.d.ts +81 -0
  261. package/dist/audit/systemic/reviewFileMap.d.ts.map +1 -0
  262. package/dist/audit/systemic/reviewFileMap.js +169 -0
  263. package/dist/audit/systemic/reviewFileMap.js.map +1 -0
  264. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -1
  265. package/dist/audit/systemic/secondOrderAdversaryPrompt.js +149 -26
  266. package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -1
  267. package/dist/audit/systemic/systemicChallengeLoop.d.ts +44 -4
  268. package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -1
  269. package/dist/audit/systemic/systemicChallengeLoop.js +114 -10
  270. package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -1
  271. package/dist/audit/types/auditState.d.ts +6 -6
  272. package/dist/audit/types/charterClarification.d.ts +9 -4
  273. package/dist/audit/types/charterClarification.d.ts.map +1 -1
  274. package/dist/audit/types/charterRegister.d.ts +48 -93
  275. package/dist/audit/types/charterRegister.d.ts.map +1 -1
  276. package/dist/audit/types/charterRegister.js +15 -26
  277. package/dist/audit/types/charterRegister.js.map +1 -1
  278. package/dist/audit/types/conceptualAdjudication.d.ts +88 -18
  279. package/dist/audit/types/conceptualAdjudication.d.ts.map +1 -1
  280. package/dist/audit/types/conceptualAdjudication.js +77 -16
  281. package/dist/audit/types/conceptualAdjudication.js.map +1 -1
  282. package/dist/audit/types/designAssessment.d.ts +8 -6
  283. package/dist/audit/types/designAssessment.d.ts.map +1 -1
  284. package/dist/audit/types/reviewPlanning.d.ts +2 -2
  285. package/dist/audit/types/systemicChallenge.d.ts +43 -7
  286. package/dist/audit/types/systemicChallenge.d.ts.map +1 -1
  287. package/dist/audit/types.d.ts +71 -10
  288. package/dist/audit/types.d.ts.map +1 -1
  289. package/dist/audit/types.js +23 -2
  290. package/dist/audit/types.js.map +1 -1
  291. package/dist/audit/validation/auditResults.d.ts +30 -0
  292. package/dist/audit/validation/auditResults.d.ts.map +1 -1
  293. package/dist/audit/validation/auditResults.js +50 -8
  294. package/dist/audit/validation/auditResults.js.map +1 -1
  295. package/dist/audit/validation/ingestIssueCodes.d.ts +1 -1
  296. package/dist/audit/validation/ingestIssueCodes.d.ts.map +1 -1
  297. package/dist/audit/validation/ingestIssueCodes.js +14 -0
  298. package/dist/audit/validation/ingestIssueCodes.js.map +1 -1
  299. package/dist/remediate/contractPipeline/artifactStore.d.ts +97 -2
  300. package/dist/remediate/contractPipeline/artifactStore.d.ts.map +1 -1
  301. package/dist/remediate/contractPipeline/artifactStore.js +163 -9
  302. package/dist/remediate/contractPipeline/artifactStore.js.map +1 -1
  303. package/dist/remediate/contractPipeline/changeClassification.d.ts.map +1 -1
  304. package/dist/remediate/contractPipeline/changeClassification.js +93 -3
  305. package/dist/remediate/contractPipeline/changeClassification.js.map +1 -1
  306. package/dist/remediate/contractPipeline/cyclicSeamResolution.d.ts.map +1 -1
  307. package/dist/remediate/contractPipeline/cyclicSeamResolution.js +31 -0
  308. package/dist/remediate/contractPipeline/cyclicSeamResolution.js.map +1 -1
  309. package/dist/remediate/contractPipeline/derive.d.ts +0 -14
  310. package/dist/remediate/contractPipeline/derive.d.ts.map +1 -1
  311. package/dist/remediate/contractPipeline/derive.js +52 -24
  312. package/dist/remediate/contractPipeline/derive.js.map +1 -1
  313. package/dist/remediate/contractPipeline/finalizedContractFields.d.ts +50 -0
  314. package/dist/remediate/contractPipeline/finalizedContractFields.d.ts.map +1 -0
  315. package/dist/remediate/contractPipeline/finalizedContractFields.js +77 -0
  316. package/dist/remediate/contractPipeline/finalizedContractFields.js.map +1 -0
  317. package/dist/remediate/contractPipeline/idRegistry.d.ts +85 -0
  318. package/dist/remediate/contractPipeline/idRegistry.d.ts.map +1 -1
  319. package/dist/remediate/contractPipeline/idRegistry.js +147 -0
  320. package/dist/remediate/contractPipeline/idRegistry.js.map +1 -1
  321. package/dist/remediate/contractPipeline/phaseCut.d.ts +13 -16
  322. package/dist/remediate/contractPipeline/phaseCut.d.ts.map +1 -1
  323. package/dist/remediate/contractPipeline/phaseCut.js +15 -30
  324. package/dist/remediate/contractPipeline/phaseCut.js.map +1 -1
  325. package/dist/remediate/contractPipeline/reviewSnapshot.d.ts +20 -1
  326. package/dist/remediate/contractPipeline/reviewSnapshot.d.ts.map +1 -1
  327. package/dist/remediate/contractPipeline/reviewSnapshot.js +23 -7
  328. package/dist/remediate/contractPipeline/reviewSnapshot.js.map +1 -1
  329. package/dist/remediate/contractPipeline/semanticProjection.d.ts +17 -0
  330. package/dist/remediate/contractPipeline/semanticProjection.d.ts.map +1 -1
  331. package/dist/remediate/contractPipeline/semanticProjection.js +6 -9
  332. package/dist/remediate/contractPipeline/semanticProjection.js.map +1 -1
  333. package/dist/remediate/contractPipeline/sketchSource.d.ts +183 -0
  334. package/dist/remediate/contractPipeline/sketchSource.d.ts.map +1 -0
  335. package/dist/remediate/contractPipeline/sketchSource.js +255 -0
  336. package/dist/remediate/contractPipeline/sketchSource.js.map +1 -0
  337. package/dist/remediate/findingFilter.d.ts.map +1 -1
  338. package/dist/remediate/findingFilter.js +1 -0
  339. package/dist/remediate/findingFilter.js.map +1 -1
  340. package/dist/remediate/index.d.ts +81 -0
  341. package/dist/remediate/index.d.ts.map +1 -1
  342. package/dist/remediate/index.js +162 -53
  343. package/dist/remediate/index.js.map +1 -1
  344. package/dist/remediate/intake.d.ts +43 -0
  345. package/dist/remediate/intake.d.ts.map +1 -1
  346. package/dist/remediate/intake.js +82 -13
  347. package/dist/remediate/intake.js.map +1 -1
  348. package/dist/remediate/phases/close.d.ts +33 -2
  349. package/dist/remediate/phases/close.d.ts.map +1 -1
  350. package/dist/remediate/phases/close.js +227 -13
  351. package/dist/remediate/phases/close.js.map +1 -1
  352. package/dist/remediate/phases/closeVerifyHeadEvidence.d.ts +154 -0
  353. package/dist/remediate/phases/closeVerifyHeadEvidence.d.ts.map +1 -0
  354. package/dist/remediate/phases/closeVerifyHeadEvidence.js +242 -0
  355. package/dist/remediate/phases/closeVerifyHeadEvidence.js.map +1 -0
  356. package/dist/remediate/state/runStatus.d.ts +35 -0
  357. package/dist/remediate/state/runStatus.d.ts.map +1 -0
  358. package/dist/remediate/state/runStatus.js +46 -0
  359. package/dist/remediate/state/runStatus.js.map +1 -0
  360. package/dist/remediate/state/store.d.ts +52 -2
  361. package/dist/remediate/state/store.d.ts.map +1 -1
  362. package/dist/remediate/state/store.js +124 -21
  363. package/dist/remediate/state/store.js.map +1 -1
  364. package/dist/remediate/state/types.d.ts +83 -13
  365. package/dist/remediate/state/types.d.ts.map +1 -1
  366. package/dist/remediate/steps/contractPipeline.d.ts +65 -1
  367. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  368. package/dist/remediate/steps/contractPipeline.js +302 -85
  369. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  370. package/dist/remediate/steps/contractPipelinePrompts.d.ts.map +1 -1
  371. package/dist/remediate/steps/contractPipelinePrompts.js +58 -21
  372. package/dist/remediate/steps/contractPipelinePrompts.js.map +1 -1
  373. package/dist/remediate/steps/dispatch/hostHandoff.d.ts +87 -2
  374. package/dist/remediate/steps/dispatch/hostHandoff.d.ts.map +1 -1
  375. package/dist/remediate/steps/dispatch/hostHandoff.js +344 -44
  376. package/dist/remediate/steps/dispatch/hostHandoff.js.map +1 -1
  377. package/dist/remediate/steps/finalGate.d.ts +109 -5
  378. package/dist/remediate/steps/finalGate.d.ts.map +1 -1
  379. package/dist/remediate/steps/finalGate.js +135 -27
  380. package/dist/remediate/steps/finalGate.js.map +1 -1
  381. package/dist/remediate/steps/gateCommands.d.ts +167 -0
  382. package/dist/remediate/steps/gateCommands.d.ts.map +1 -1
  383. package/dist/remediate/steps/gateCommands.js +428 -1
  384. package/dist/remediate/steps/gateCommands.js.map +1 -1
  385. package/dist/remediate/steps/intakeResolver.d.ts +2 -13
  386. package/dist/remediate/steps/intakeResolver.d.ts.map +1 -1
  387. package/dist/remediate/steps/intakeResolver.js +22 -4
  388. package/dist/remediate/steps/intakeResolver.js.map +1 -1
  389. package/dist/remediate/steps/nextStep.d.ts +44 -40
  390. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  391. package/dist/remediate/steps/nextStep.js +501 -106
  392. package/dist/remediate/steps/nextStep.js.map +1 -1
  393. package/dist/remediate/steps/stepWriter.d.ts +1 -1
  394. package/dist/remediate/steps/stepWriter.d.ts.map +1 -1
  395. package/dist/remediate/steps/stepWriter.js +1 -0
  396. package/dist/remediate/steps/stepWriter.js.map +1 -1
  397. package/dist/remediate/steps/types.d.ts +32 -1
  398. package/dist/remediate/steps/types.d.ts.map +1 -1
  399. package/dist/remediate/steps/types.js +1 -0
  400. package/dist/remediate/steps/types.js.map +1 -1
  401. package/dist/remediate/types/options.d.ts +8 -0
  402. package/dist/remediate/types/options.d.ts.map +1 -1
  403. package/dist/remediate/utils/fileIntegrity.d.ts +8 -0
  404. package/dist/remediate/utils/fileIntegrity.d.ts.map +1 -1
  405. package/dist/remediate/utils/fileIntegrity.js +12 -1
  406. package/dist/remediate/utils/fileIntegrity.js.map +1 -1
  407. package/dist/remediate/validation/artifacts.d.ts +1 -1
  408. package/dist/remediate/validation/artifacts.d.ts.map +1 -1
  409. package/dist/remediate/validation/artifacts.js +19 -2
  410. package/dist/remediate/validation/artifacts.js.map +1 -1
  411. package/dist/remediate/validation/contractPipeline.d.ts.map +1 -1
  412. package/dist/remediate/validation/contractPipeline.js +26 -39
  413. package/dist/remediate/validation/contractPipeline.js.map +1 -1
  414. package/dist/remediate/validation/contractPipelineGates.d.ts +18 -1
  415. package/dist/remediate/validation/contractPipelineGates.d.ts.map +1 -1
  416. package/dist/remediate/validation/contractPipelineGates.js +33 -5
  417. package/dist/remediate/validation/contractPipelineGates.js.map +1 -1
  418. package/dist/shared/analyzers/acquisitionEngine.d.ts +83 -5
  419. package/dist/shared/analyzers/acquisitionEngine.d.ts.map +1 -1
  420. package/dist/shared/analyzers/acquisitionEngine.js +46 -14
  421. package/dist/shared/analyzers/acquisitionEngine.js.map +1 -1
  422. package/dist/shared/analyzers/binaryAcquisition.d.ts +35 -2
  423. package/dist/shared/analyzers/binaryAcquisition.d.ts.map +1 -1
  424. package/dist/shared/analyzers/binaryAcquisition.js +5 -5
  425. package/dist/shared/analyzers/binaryAcquisition.js.map +1 -1
  426. package/dist/shared/analyzers/candidates.d.ts.map +1 -1
  427. package/dist/shared/analyzers/candidates.js +1 -0
  428. package/dist/shared/analyzers/candidates.js.map +1 -1
  429. package/dist/shared/analyzers/clippy.d.ts +9 -1
  430. package/dist/shared/analyzers/clippy.d.ts.map +1 -1
  431. package/dist/shared/analyzers/clippy.js +10 -2
  432. package/dist/shared/analyzers/clippy.js.map +1 -1
  433. package/dist/shared/analyzers/normalizeExternal.d.ts.map +1 -1
  434. package/dist/shared/analyzers/normalizeExternal.js +1 -0
  435. package/dist/shared/analyzers/normalizeExternal.js.map +1 -1
  436. package/dist/shared/analyzers/rubocop.d.ts +7 -1
  437. package/dist/shared/analyzers/rubocop.d.ts.map +1 -1
  438. package/dist/shared/analyzers/rubocop.js +8 -2
  439. package/dist/shared/analyzers/rubocop.js.map +1 -1
  440. package/dist/shared/analyzers/types.d.ts +24 -24
  441. package/dist/shared/analyzers/types.d.ts.map +1 -1
  442. package/dist/shared/analyzers/types.js +15 -0
  443. package/dist/shared/analyzers/types.js.map +1 -1
  444. package/dist/shared/artifactFreshness.d.ts.map +1 -1
  445. package/dist/shared/artifactFreshness.js +42 -7
  446. package/dist/shared/artifactFreshness.js.map +1 -1
  447. package/dist/shared/chunkByBudget.d.ts.map +1 -1
  448. package/dist/shared/chunkByBudget.js.map +1 -1
  449. package/dist/shared/continuityScore.d.ts.map +1 -1
  450. package/dist/shared/continuityScore.js +12 -4
  451. package/dist/shared/continuityScore.js.map +1 -1
  452. package/dist/shared/decompose/charterClarification.d.ts +49 -45
  453. package/dist/shared/decompose/charterClarification.d.ts.map +1 -1
  454. package/dist/shared/decompose/charterClarification.js +50 -57
  455. package/dist/shared/decompose/charterClarification.js.map +1 -1
  456. package/dist/shared/decompose/charterExtraction.d.ts +616 -342
  457. package/dist/shared/decompose/charterExtraction.d.ts.map +1 -1
  458. package/dist/shared/decompose/charterExtraction.js +590 -488
  459. package/dist/shared/decompose/charterExtraction.js.map +1 -1
  460. package/dist/shared/decompose/contentCoherence.d.ts +36 -2
  461. package/dist/shared/decompose/contentCoherence.d.ts.map +1 -1
  462. package/dist/shared/decompose/contentCoherence.js +45 -5
  463. package/dist/shared/decompose/contentCoherence.js.map +1 -1
  464. package/dist/shared/decompose/modularity.d.ts +98 -1
  465. package/dist/shared/decompose/modularity.d.ts.map +1 -1
  466. package/dist/shared/decompose/modularity.js +89 -8
  467. package/dist/shared/decompose/modularity.js.map +1 -1
  468. package/dist/shared/decompose/systemicChallenge.d.ts +111 -0
  469. package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -1
  470. package/dist/shared/decompose/systemicChallenge.js +28 -0
  471. package/dist/shared/decompose/systemicChallenge.js.map +1 -1
  472. package/dist/shared/engine/obligationEngine.d.ts +2 -2
  473. package/dist/shared/engine/obligationEngine.d.ts.map +1 -1
  474. package/dist/shared/engine/obligationEngine.js +8 -2
  475. package/dist/shared/engine/obligationEngine.js.map +1 -1
  476. package/dist/shared/findingSimilarity.d.ts +8 -0
  477. package/dist/shared/findingSimilarity.d.ts.map +1 -1
  478. package/dist/shared/findingSimilarity.js +10 -3
  479. package/dist/shared/findingSimilarity.js.map +1 -1
  480. package/dist/shared/findings/dedupe.d.ts +15 -0
  481. package/dist/shared/findings/dedupe.d.ts.map +1 -1
  482. package/dist/shared/findings/dedupe.js +137 -1
  483. package/dist/shared/findings/dedupe.js.map +1 -1
  484. package/dist/shared/friction/frictionRecord.d.ts.map +1 -1
  485. package/dist/shared/friction/frictionRecord.js +14 -1
  486. package/dist/shared/friction/frictionRecord.js.map +1 -1
  487. package/dist/shared/friction/triage.d.ts +4 -0
  488. package/dist/shared/friction/triage.d.ts.map +1 -1
  489. package/dist/shared/friction/triage.js +41 -29
  490. package/dist/shared/friction/triage.js.map +1 -1
  491. package/dist/shared/git.d.ts +14 -0
  492. package/dist/shared/git.d.ts.map +1 -1
  493. package/dist/shared/git.js +22 -0
  494. package/dist/shared/git.js.map +1 -1
  495. package/dist/shared/index.d.ts +42 -38
  496. package/dist/shared/index.d.ts.map +1 -1
  497. package/dist/shared/index.js +35 -23
  498. package/dist/shared/index.js.map +1 -1
  499. package/dist/shared/intent/clauseBoundaries.d.ts +75 -0
  500. package/dist/shared/intent/clauseBoundaries.d.ts.map +1 -0
  501. package/dist/shared/intent/clauseBoundaries.js +134 -0
  502. package/dist/shared/intent/clauseBoundaries.js.map +1 -0
  503. package/dist/shared/intent/clauseInterpreter.d.ts +11 -5
  504. package/dist/shared/intent/clauseInterpreter.d.ts.map +1 -1
  505. package/dist/shared/intent/clauseInterpreter.js +16 -41
  506. package/dist/shared/intent/clauseInterpreter.js.map +1 -1
  507. package/dist/shared/intent/freeFormIntentInterpreter.d.ts +11 -0
  508. package/dist/shared/intent/freeFormIntentInterpreter.d.ts.map +1 -1
  509. package/dist/shared/intent/freeFormIntentInterpreter.js +31 -17
  510. package/dist/shared/intent/freeFormIntentInterpreter.js.map +1 -1
  511. package/dist/shared/io/fileLock.d.ts.map +1 -1
  512. package/dist/shared/io/fileLock.js +18 -6
  513. package/dist/shared/io/fileLock.js.map +1 -1
  514. package/dist/shared/io/frictionCapture.d.ts +25 -5
  515. package/dist/shared/io/frictionCapture.d.ts.map +1 -1
  516. package/dist/shared/io/frictionCapture.js +30 -9
  517. package/dist/shared/io/frictionCapture.js.map +1 -1
  518. package/dist/shared/io/schemaVersion.d.ts +4 -3
  519. package/dist/shared/io/schemaVersion.d.ts.map +1 -1
  520. package/dist/shared/io/schemaVersion.js +27 -4
  521. package/dist/shared/io/schemaVersion.js.map +1 -1
  522. package/dist/shared/io/stepContractWriter.d.ts +38 -4
  523. package/dist/shared/io/stepContractWriter.d.ts.map +1 -1
  524. package/dist/shared/io/stepContractWriter.js +59 -1
  525. package/dist/shared/io/stepContractWriter.js.map +1 -1
  526. package/dist/shared/loopCorePaths.d.ts.map +1 -1
  527. package/dist/shared/loopCorePaths.js +8 -0
  528. package/dist/shared/loopCorePaths.js.map +1 -1
  529. package/dist/shared/opencodePermissions.d.ts +27 -3
  530. package/dist/shared/opencodePermissions.d.ts.map +1 -1
  531. package/dist/shared/opencodePermissions.js +77 -26
  532. package/dist/shared/opencodePermissions.js.map +1 -1
  533. package/dist/shared/prompts.d.ts +12 -1
  534. package/dist/shared/prompts.d.ts.map +1 -1
  535. package/dist/shared/prompts.js +11 -1
  536. package/dist/shared/prompts.js.map +1 -1
  537. package/dist/shared/reReview/projectionDiff.d.ts +13 -0
  538. package/dist/shared/reReview/projectionDiff.d.ts.map +1 -1
  539. package/dist/shared/reReview/projectionDiff.js +1 -1
  540. package/dist/shared/reReview/projectionDiff.js.map +1 -1
  541. package/dist/shared/reporting/findingDisplay.d.ts +7 -0
  542. package/dist/shared/reporting/findingDisplay.d.ts.map +1 -1
  543. package/dist/shared/reporting/findingDisplay.js +8 -1
  544. package/dist/shared/reporting/findingDisplay.js.map +1 -1
  545. package/dist/shared/steps/stepEmissionScaffold.d.ts +15 -3
  546. package/dist/shared/steps/stepEmissionScaffold.d.ts.map +1 -1
  547. package/dist/shared/steps/stepEmissionScaffold.js +8 -6
  548. package/dist/shared/steps/stepEmissionScaffold.js.map +1 -1
  549. package/dist/shared/submission/hostHandoffCore.d.ts +37 -12
  550. package/dist/shared/submission/hostHandoffCore.d.ts.map +1 -1
  551. package/dist/shared/submission/hostHandoffCore.js +81 -18
  552. package/dist/shared/submission/hostHandoffCore.js.map +1 -1
  553. package/dist/shared/submission/hostResultOutcomes.d.ts +70 -1
  554. package/dist/shared/submission/hostResultOutcomes.d.ts.map +1 -1
  555. package/dist/shared/submission/hostResultOutcomes.js +66 -1
  556. package/dist/shared/submission/hostResultOutcomes.js.map +1 -1
  557. package/dist/shared/submission/submissionLedger.d.ts +86 -1
  558. package/dist/shared/submission/submissionLedger.d.ts.map +1 -1
  559. package/dist/shared/submission/submissionLedger.js +108 -0
  560. package/dist/shared/submission/submissionLedger.js.map +1 -1
  561. package/dist/shared/submission/submissionScan.d.ts.map +1 -1
  562. package/dist/shared/submission/submissionScan.js +1 -0
  563. package/dist/shared/submission/submissionScan.js.map +1 -1
  564. package/dist/shared/tooling/analyzerDeps.d.ts +14 -0
  565. package/dist/shared/tooling/analyzerDeps.d.ts.map +1 -1
  566. package/dist/shared/tooling/analyzerDeps.js +23 -0
  567. package/dist/shared/tooling/analyzerDeps.js.map +1 -1
  568. package/dist/shared/tooling/commandShape.d.ts +35 -1
  569. package/dist/shared/tooling/commandShape.d.ts.map +1 -1
  570. package/dist/shared/tooling/commandShape.js +66 -4
  571. package/dist/shared/tooling/commandShape.js.map +1 -1
  572. package/dist/shared/tooling/exec.d.ts +62 -4
  573. package/dist/shared/tooling/exec.d.ts.map +1 -1
  574. package/dist/shared/tooling/exec.js +127 -8
  575. package/dist/shared/tooling/exec.js.map +1 -1
  576. package/dist/shared/types/charter.d.ts +674 -156
  577. package/dist/shared/types/charter.d.ts.map +1 -1
  578. package/dist/shared/types/charter.js +172 -118
  579. package/dist/shared/types/charter.js.map +1 -1
  580. package/dist/shared/types/closingActions.d.ts +25 -0
  581. package/dist/shared/types/closingActions.d.ts.map +1 -1
  582. package/dist/shared/types/closingActions.js +26 -0
  583. package/dist/shared/types/closingActions.js.map +1 -1
  584. package/dist/shared/types/contractPipeline/obligations.d.ts +63 -2
  585. package/dist/shared/types/contractPipeline/obligations.d.ts.map +1 -1
  586. package/dist/shared/types/contractPipeline/obligations.js +51 -0
  587. package/dist/shared/types/contractPipeline/obligations.js.map +1 -1
  588. package/dist/shared/types/contractPipeline.d.ts +1 -0
  589. package/dist/shared/types/contractPipeline.d.ts.map +1 -1
  590. package/dist/shared/types/contractPipeline.js +1 -0
  591. package/dist/shared/types/contractPipeline.js.map +1 -1
  592. package/dist/shared/types/contractPropertyShapes.d.ts +34 -0
  593. package/dist/shared/types/contractPropertyShapes.d.ts.map +1 -0
  594. package/dist/shared/types/contractPropertyShapes.js +255 -0
  595. package/dist/shared/types/contractPropertyShapes.js.map +1 -0
  596. package/dist/shared/types/finding.d.ts +376 -18
  597. package/dist/shared/types/finding.d.ts.map +1 -1
  598. package/dist/shared/types/finding.js +111 -0
  599. package/dist/shared/types/finding.js.map +1 -1
  600. package/dist/shared/types/intentCheckpoint.d.ts +214 -2
  601. package/dist/shared/types/intentCheckpoint.d.ts.map +1 -1
  602. package/dist/shared/types/intentCheckpoint.js +273 -0
  603. package/dist/shared/types/intentCheckpoint.js.map +1 -1
  604. package/dist/shared/types/intentInterpretation.d.ts +1 -1
  605. package/dist/shared/types/intentInterpretation.js +1 -1
  606. package/dist/shared/types/remediationOutcome.d.ts +294 -30
  607. package/dist/shared/types/remediationOutcome.d.ts.map +1 -1
  608. package/dist/shared/types/remediationOutcome.js +96 -7
  609. package/dist/shared/types/remediationOutcome.js.map +1 -1
  610. package/dist/shared/types/stepContract.d.ts +47 -0
  611. package/dist/shared/types/stepContract.d.ts.map +1 -1
  612. package/dist/shared/types/stepContract.js +113 -0
  613. package/dist/shared/types/stepContract.js.map +1 -1
  614. package/dist/shared/validation/charterGate.d.ts +13 -28
  615. package/dist/shared/validation/charterGate.d.ts.map +1 -1
  616. package/dist/shared/validation/charterGate.js +13 -35
  617. package/dist/shared/validation/charterGate.js.map +1 -1
  618. package/dist/shared/validation/contractConstructionSites.d.ts +116 -0
  619. package/dist/shared/validation/contractConstructionSites.d.ts.map +1 -0
  620. package/dist/shared/validation/contractConstructionSites.js +277 -0
  621. package/dist/shared/validation/contractConstructionSites.js.map +1 -0
  622. package/dist/shared/validation/designFindingGrounding.d.ts +33 -4
  623. package/dist/shared/validation/designFindingGrounding.d.ts.map +1 -1
  624. package/dist/shared/validation/designFindingGrounding.js +40 -6
  625. package/dist/shared/validation/designFindingGrounding.js.map +1 -1
  626. package/dist/shared/validation/findingGrounding.d.ts.map +1 -1
  627. package/dist/shared/validation/findingGrounding.js +11 -1
  628. package/dist/shared/validation/findingGrounding.js.map +1 -1
  629. package/dist/shared/validation/findingsReport.d.ts.map +1 -1
  630. package/dist/shared/validation/findingsReport.js +5 -0
  631. package/dist/shared/validation/findingsReport.js.map +1 -1
  632. package/docs/audit-pkg/contracts.md +8 -2
  633. package/opencode.json +29 -29
  634. package/package.json +16 -3
  635. package/schemas/audit-code-v1alpha1.schema.json +0 -4
  636. package/scripts/audit/postinstall.mjs +81 -96
  637. package/scripts/remediate/postinstall.mjs +43 -83
  638. package/scripts/shared/host-asset-plan.mjs +176 -0
  639. package/scripts/shared/install-host-assets.mjs +44 -1
  640. package/scripts/shared/primitives.mjs +89 -0
  641. package/skills/audit-code/SKILL.md +4 -4
  642. package/skills/audit-code/audit-code.prompt.md +14 -10
  643. package/skills/remediate-code/SKILL.md +9 -5
  644. package/skills/remediate-code/remediate-code.prompt.md +11 -4
  645. package/wrapper/audit-code-wrapper-build.mjs +6 -3
  646. package/dist/audit/cli/charterDeltaPrompt.d.ts +0 -18
  647. package/dist/audit/cli/charterDeltaPrompt.d.ts.map +0 -1
  648. package/dist/audit/cli/charterDeltaPrompt.js +0 -150
  649. package/dist/audit/cli/charterDeltaPrompt.js.map +0 -1
  650. package/dist/audit/orchestrator/charterDeltaExecutor.d.ts +0 -24
  651. package/dist/audit/orchestrator/charterDeltaExecutor.d.ts.map +0 -1
  652. package/dist/audit/orchestrator/charterDeltaExecutor.js +0 -128
  653. package/dist/audit/orchestrator/charterDeltaExecutor.js.map +0 -1
  654. package/dist/audit/supervisor/runLedger.d.ts +0 -3
  655. package/dist/audit/supervisor/runLedger.d.ts.map +0 -1
  656. package/dist/audit/supervisor/runLedger.js +0 -69
  657. package/dist/audit/supervisor/runLedger.js.map +0 -1
  658. package/dist/shared/types/executionRecord.d.ts +0 -58
  659. package/dist/shared/types/executionRecord.d.ts.map +0 -1
  660. package/dist/shared/types/executionRecord.js +0 -26
  661. package/dist/shared/types/executionRecord.js.map +0 -1
  662. package/dist/shared/types/runLedger.d.ts +0 -17
  663. package/dist/shared/types/runLedger.d.ts.map +0 -1
  664. package/dist/shared/types/runLedger.js +0 -7
  665. package/dist/shared/types/runLedger.js.map +0 -1
@@ -1,556 +1,658 @@
1
- // The charter layer of the conceptual design-review — assemble a gated charter
2
- // register from host LLM submissions (Phase C; design of record
3
- // spec/conceptual-design-review-design.md §"The estimator charters" + §"The True
4
- // charter needs hard gates").
1
+ // sites-pinned: tests/shared/charter-layer.test.ts, tests/shared/charter-lane-dag.test.ts
2
+ // The five-step charter layer — deterministic ENFORCEMENT half (design of record:
3
+ // spec/conceptual-design-review-design.md §"The estimator charters", steps 1–5;
4
+ // decision record docs/reviews/charter-redesign-feedback-2026-09-15.md).
5
5
  //
6
- // Division of labour ([[contract-authoring-determinism-direction]]): each blind
7
- // LANE emits JUDGMENT — a self-organized leveled teleology whose nodes carry FILE
8
- // SCOPES (purpose in telos terms + premise height + the files it claims to
9
- // describe); the independent delta miner emits the channel-pair gaps it sees plus
10
- // a triangulated telos per subsystem. This module is the deterministic
11
- // ENFORCEMENT half — it grounds every file scope against the repo universe,
12
- // JOINS the per-kind teleologies to each other and to the decomposition HINT by
13
- // file-set overlap (the decomposition is a scaffold suggestion, never a forced
14
- // node list), selects each unit's per-kind charter mechanically, derives each
15
- // delta's kind + routing from its channel pair (the design's routing table, never
16
- // host discretion), runs the Phase-A hard gates (applyTrueCharterGate drops
17
- // un-falsifiable True; gateCharterDelta forces a low-confidence side to the human
18
- // channel), computes the per-channel-pair disagreement density, and surfaces the
19
- // surviving deltas as Finding leads for synthesis. PURE + deterministic +
20
- // language-neutral (operates on abstract file-path scopes + telos strings, no
21
- // IO): provenance-on-disk grounding is the ingest's concern, not this module's.
6
+ // Division of labour: the host lanes emit JUDGMENT (three goal DAGs, the confirmed
7
+ // correspondences and typed differences, the fidelity verdicts); this module is the
8
+ // tool-owned half that grounds, validates, derives and routes:
9
+ // 1. `assembleLaneGraph` — one lane submission → a persisted lane DAG (ids
10
+ // unique, edges resolve, NO cycles, levels derived,
11
+ // file scopes grounded against the repo universe).
12
+ // 2. `proposeCorrespondences` — tool candidates from file overlap + provenance
13
+ // cross-refs (deterministic, content-keyed ids).
14
+ // 3. `assembleComparison` — the comparison submission → confirmed
15
+ // correspondences + difference records, each routed
16
+ // by the FIXED `(dimension, relation, split)` table.
17
+ // 4. `applyFidelity` — tool pre-check verdicts + lane verdicts stamped on.
18
+ // 5. `differenceFindings` — `supported` finding candidates → Finding leads.
19
+ // PURE + deterministic + language-neutral: no IO, no LLM. Provenance-on-disk
20
+ // grounding is the ingest's concern (it hands the pre-check its read results).
22
21
  import { z } from "zod";
23
22
  import { hashContent } from "../hash.js";
24
- import { CharterSchema, CharterKindSchema, CharterConfidenceSchema, CharterProvenanceSchema, GoalGraphSchema, TeleologyNodeSchema, TriangulatedTelosSchema, } from "../types/charter.js";
25
- import { applyTrueCharterGate, gateCharterDelta, } from "../validation/charterGate.js";
26
23
  import { compareCodeUnits } from "../compareCodeUnits.js";
27
- // ── Submission contracts (what the host LLM writes to its bound path) ───────
28
- /**
29
- * One teleology node as a lane emits it: a charter statement WITH its file scope
30
- * and emergent level (the `TeleologyNodeSchema` fields, single-sourced — minus
31
- * `purpose`, which the charter half already carries). The tool assigns unit
32
- * membership and `charter_id` — the host never picks a join key beyond the
33
- * content-derived file scope itself.
34
- */
35
- const CharterNodeInputSchema = CharterSchema.omit({ charter_id: true })
36
- .extend(TeleologyNodeSchema.omit({ purpose: true }).shape)
24
+ import { CharterLaneGraphSchema, CharterLaneKindSchema, CharterProvenanceSchema, CharterConfidenceSchema, CorrespondenceMemberSchema, DifferenceDimensionSchema, DifferenceRelationSchema, DifferenceSplitSchema, DifferenceAccountSchema, } from "../types/charter.js";
25
+ // ── Step 1: lane submission → lane DAG ─────────────────────────────────────────
26
+ /** A node as a LANE submits it: local id, telos, optional scope, evidence, confidence. */
27
+ const LaneNodeInputSchema = z
28
+ .object({
29
+ node_id: z.string().min(1),
30
+ purpose: z.string().min(1),
31
+ files: z.array(z.string()).optional(),
32
+ provenance: z.array(CharterProvenanceSchema),
33
+ confidence: CharterConfidenceSchema,
34
+ })
37
35
  .strict();
38
- /**
39
- * The charter-EXTRACTION submission (Phase C.1): ONE blind lane's self-organized
40
- * teleology. Deltas are NOT authored here — the independent delta miner mines
41
- * them in a second pass over the joined charters, so no author marks its own
42
- * homework. Lanes from every kind are merged (concatenated) before assembly;
43
- * the join is by file-set overlap, so lanes never need to agree on node ids.
44
- */
45
- export const CharterSubmissionSchema = z
36
+ const LaneEdgeInputSchema = z
46
37
  .object({
47
- nodes: z.array(CharterNodeInputSchema).default([]),
38
+ from: z.string().min(1),
39
+ to: z.string().min(1),
40
+ provenance: z.array(CharterProvenanceSchema),
48
41
  })
49
42
  .strict();
50
43
  /**
51
- * A delta as the miner emits it: the symmetric channel `pair` it sees a gap
52
- * across + the interpreted `summary` of that gap. The tool derives `kind`,
53
- * `routed_to`, and `delta_id` — the miner never picks the routing (that is the
54
- * design's fixed table, enforced here).
44
+ * The charter-EXTRACTION submission (step 1): ONE blind lane's goal DAG. The lane
45
+ * mints local ids; `premise_height` is not asked for (the tool derives it);
46
+ * `files` is optional (the Stated lane cites provenance only).
55
47
  */
56
- const CharterDeltaInputSchema = z
48
+ export const CharterSubmissionSchema = z
57
49
  .object({
58
- pair: z.tuple([CharterKindSchema, CharterKindSchema]),
59
- summary: z.string(),
50
+ kind: CharterLaneKindSchema,
51
+ nodes: z.array(LaneNodeInputSchema).default([]),
52
+ edges: z.array(LaneEdgeInputSchema).default([]),
60
53
  })
61
54
  .strict();
62
- /** One subsystem's mined deltas (delta phase). */
63
- const CharterDeltaSubsystemInputSchema = z
64
- .object({
65
- node_id: z.string(),
66
- deltas: z.array(CharterDeltaInputSchema).default([]),
67
- })
55
+ /** The TOOL-merged extraction submission: every lane's DAG, handed to the executor by path. */
56
+ export const CharterExtractionMergedSchema = z
57
+ .object({ lanes: z.array(CharterSubmissionSchema) })
68
58
  .strict();
69
59
  /**
70
- * A True nomination as the miner emits it — downstream of triangulation, at the
71
- * `deepest` ceiling only (the assembly refuses them otherwise; the consent gate
72
- * moved here when `true` stopped being an extraction lane). Falsifiable-or-drop:
73
- * `applyTrueCharterGate` enforces the concrete alternative + concrete cost.
60
+ * Validate one lane's submission into its persisted DAG. Deterministic: same
61
+ * submission + same universe → same graph. Refusals, per node/edge, are recorded
62
+ * as validation issues (surfaced, never silent):
63
+ * - a duplicate `node_id` keeps the first and drops the rest;
64
+ * - an edge naming an unknown node, or a self-edge, is dropped;
65
+ * - a file outside the universe is dropped from the node's scope (a node left with
66
+ * an EMPTY declared scope keeps `files` absent, i.e. becomes provenance-only);
67
+ * - a CYCLE refuses the whole edge set: every edge on a cycle is dropped and the
68
+ * issue names the cycle, because a level cannot be derived from a cyclic graph
69
+ * and a silently broken cycle would hide which edge the lane drafted backwards
70
+ * ([[inverted-neighbor-edges-manufacture-a-cycle]]).
71
+ * `premise_height` = longest path from a ROOT (a node that serves nothing) down to
72
+ * the node, so 0 is a top-level purpose and a leaf mechanism sits deepest.
73
+ */
74
+ export function assembleLaneGraph(submission, params) {
75
+ const validation_issues = [];
76
+ const kind = submission.kind;
77
+ // Nodes: unique ids, grounded scopes.
78
+ const byId = new Map();
79
+ for (const node of submission.nodes) {
80
+ if (byId.has(node.node_id)) {
81
+ validation_issues.push(`${kind}: duplicate node_id "${node.node_id}" — kept the first, dropped the rest`);
82
+ continue;
83
+ }
84
+ let files;
85
+ if (node.files !== undefined) {
86
+ const known = [...new Set(node.files)].filter((f) => params.universe.has(f));
87
+ const unknown = node.files.filter((f) => !params.universe.has(f));
88
+ if (unknown.length > 0) {
89
+ validation_issues.push(`${kind}: node "${node.node_id}" cites file(s) outside the repo universe — dropped from its scope (${[...new Set(unknown)]
90
+ .sort(compareCodeUnits)
91
+ .join(", ")})`);
92
+ }
93
+ files = known.length > 0 ? known.sort(compareCodeUnits) : undefined;
94
+ }
95
+ byId.set(node.node_id, {
96
+ node_id: node.node_id,
97
+ purpose: node.purpose,
98
+ premise_height: 0,
99
+ ...(files !== undefined ? { files } : {}),
100
+ provenance: node.provenance,
101
+ confidence: node.confidence,
102
+ });
103
+ }
104
+ // Edges: resolve, no self-edges, no duplicates.
105
+ const edgeKeys = new Set();
106
+ const edges = [];
107
+ for (const edge of submission.edges) {
108
+ if (edge.from === edge.to) {
109
+ validation_issues.push(`${kind}: edge "${edge.from}" serves itself — dropped`);
110
+ continue;
111
+ }
112
+ if (!byId.has(edge.from) || !byId.has(edge.to)) {
113
+ validation_issues.push(`${kind}: edge ${edge.from} → ${edge.to} names an unknown node — dropped`);
114
+ continue;
115
+ }
116
+ const key = `${edge.from} -> ${edge.to}`;
117
+ if (edgeKeys.has(key))
118
+ continue;
119
+ edgeKeys.add(key);
120
+ edges.push({ from: edge.from, to: edge.to, provenance: edge.provenance });
121
+ }
122
+ // Cycle check (Kahn over the SERVES direction). Nodes left unprocessed lie on or
123
+ // downstream of a cycle; every edge among them is refused and the issue names them.
124
+ const acyclicEdges = refuseCycles(kind, [...byId.keys()], edges, validation_issues);
125
+ // Levels: longest path from a root. `from` serves `to`, so `to` is the parent;
126
+ // height(child) = max(height(parent)) + 1; roots (serve nothing) are 0.
127
+ const parentsOf = new Map();
128
+ for (const e of acyclicEdges) {
129
+ const list = parentsOf.get(e.from) ?? [];
130
+ list.push(e.to);
131
+ parentsOf.set(e.from, list);
132
+ }
133
+ const height = new Map();
134
+ const heightOf = (id) => {
135
+ const cached = height.get(id);
136
+ if (cached !== undefined)
137
+ return cached;
138
+ const parents = parentsOf.get(id) ?? [];
139
+ const h = parents.length === 0 ? 0 : Math.max(...parents.map(heightOf)) + 1;
140
+ height.set(id, h);
141
+ return h;
142
+ };
143
+ const nodes = [...byId.values()]
144
+ .map((n) => ({ ...n, premise_height: heightOf(n.node_id) }))
145
+ .sort((a, b) => compareCodeUnits(a.node_id, b.node_id));
146
+ const sortedEdges = [...acyclicEdges].sort((a, b) => compareCodeUnits(a.from, b.from) || compareCodeUnits(a.to, b.to));
147
+ return {
148
+ graph: CharterLaneGraphSchema.parse({ kind, nodes, edges: sortedEdges }),
149
+ validation_issues,
150
+ };
151
+ }
152
+ function refuseCycles(kind, ids, edges, issues) {
153
+ const indegree = new Map(ids.map((id) => [id, 0]));
154
+ const out = new Map();
155
+ for (const e of edges) {
156
+ indegree.set(e.to, (indegree.get(e.to) ?? 0) + 1);
157
+ const list = out.get(e.from) ?? [];
158
+ list.push(e.to);
159
+ out.set(e.from, list);
160
+ }
161
+ const queue = ids.filter((id) => (indegree.get(id) ?? 0) === 0).sort(compareCodeUnits);
162
+ const done = new Set();
163
+ while (queue.length > 0) {
164
+ const id = queue.shift();
165
+ done.add(id);
166
+ for (const next of out.get(id) ?? []) {
167
+ const d = (indegree.get(next) ?? 1) - 1;
168
+ indegree.set(next, d);
169
+ if (d === 0)
170
+ queue.push(next);
171
+ }
172
+ }
173
+ if (done.size === ids.length)
174
+ return edges;
175
+ const cyclic = ids.filter((id) => !done.has(id)).sort(compareCodeUnits);
176
+ const cyclicSet = new Set(cyclic);
177
+ const refused = edges.filter((e) => cyclicSet.has(e.from) && cyclicSet.has(e.to));
178
+ issues.push(`${kind}: the goal graph has a cycle through ${cyclic.map((c) => `"${c}"`).join(", ")} — ${refused.length} edge(s) among those nodes refused; a level cannot be derived from a cycle (an edge drafted as "what the parent needs from me" instead of "what I serve" is the usual cause)`);
179
+ return edges.filter((e) => !(cyclicSet.has(e.from) && cyclicSet.has(e.to)));
180
+ }
181
+ // ── Step 2: tool-proposed correspondence candidates ────────────────────────────
182
+ /** The path part of a provenance ref: `<path>#<symbol>` or `<path>:<line>` → `<path>`. */
183
+ export function provenancePath(ref) {
184
+ const hash = ref.indexOf("#");
185
+ const cut = hash >= 0 ? ref.slice(0, hash) : ref;
186
+ const colon = cut.lastIndexOf(":");
187
+ return colon > 0 && /^\d+$/.test(cut.slice(colon + 1)) ? cut.slice(0, colon) : cut;
188
+ }
189
+ function memberKey(members) {
190
+ return [...members]
191
+ .map((m) => `${m.kind}:${[...m.node_ids].sort(compareCodeUnits).join(",")}`)
192
+ .sort(compareCodeUnits)
193
+ .join("|");
194
+ }
195
+ /**
196
+ * Propose correspondence candidates between every pair of lanes. Two signals, both
197
+ * deterministic and content-derived:
198
+ * - `file_overlap`: the nodes' file scopes share ≥1 path;
199
+ * - `cross_ref`: a node's provenance cites a path (`<path>#<symbol>` / `<path>:<line>`)
200
+ * that lies in the other node's file scope (the Stated lane's usual key).
201
+ * A pair related by both is reported once, as `file_overlap` (the stronger signal),
202
+ * with the union of evidence paths. Candidate ids are content-keyed on the member
203
+ * set, so re-proposal never churns the artifact.
74
204
  */
75
- const TrueNominationInputSchema = z
205
+ export function proposeCorrespondences(graphs) {
206
+ const byKey = new Map();
207
+ const sorted = [...graphs].sort((a, b) => compareCodeUnits(a.kind, b.kind));
208
+ for (let i = 0; i < sorted.length; i += 1) {
209
+ for (let j = i + 1; j < sorted.length; j += 1) {
210
+ const a = sorted[i];
211
+ const b = sorted[j];
212
+ if (a.kind === b.kind)
213
+ continue;
214
+ for (const na of a.nodes) {
215
+ for (const nb of b.nodes) {
216
+ const overlap = fileOverlap(na, nb);
217
+ const crossRefs = overlap.length > 0 ? [] : crossRefPaths(na, nb);
218
+ if (overlap.length === 0 && crossRefs.length === 0)
219
+ continue;
220
+ const members = [
221
+ { kind: a.kind, node_ids: [na.node_id] },
222
+ { kind: b.kind, node_ids: [nb.node_id] },
223
+ ];
224
+ const key = memberKey(members);
225
+ if (byKey.has(key))
226
+ continue;
227
+ byKey.set(key, {
228
+ candidate_id: `cand-${hashContent(key, { length: 10 })}`,
229
+ members,
230
+ basis: overlap.length > 0 ? "file_overlap" : "cross_ref",
231
+ evidence_paths: (overlap.length > 0 ? overlap : crossRefs).sort(compareCodeUnits),
232
+ });
233
+ }
234
+ }
235
+ }
236
+ }
237
+ return [...byKey.values()].sort((a, b) => compareCodeUnits(a.candidate_id, b.candidate_id));
238
+ }
239
+ function fileOverlap(a, b) {
240
+ if (!a.files || !b.files)
241
+ return [];
242
+ const setB = new Set(b.files);
243
+ return [...new Set(a.files.filter((f) => setB.has(f)))];
244
+ }
245
+ function crossRefPaths(a, b) {
246
+ const hits = new Set();
247
+ const collect = (from, into) => {
248
+ if (!into.files)
249
+ return;
250
+ const scope = new Set(into.files);
251
+ for (const p of from.provenance) {
252
+ const path = provenancePath(p.ref);
253
+ if (scope.has(path))
254
+ hits.add(path);
255
+ }
256
+ };
257
+ collect(a, b);
258
+ collect(b, a);
259
+ return [...hits];
260
+ }
261
+ // ── Step 3: the comparison submission → correspondences + differences ──────────
262
+ const CorrespondenceInputSchema = z
76
263
  .object({
77
- node_id: z.string(),
78
- /** The nominated ideal, in telos terms. */
79
- purpose: z.string(),
80
- nominated_alternative: z.string(),
81
- nominated_cost: z.string(),
82
- confidence: CharterConfidenceSchema,
83
- /** May be empty — the ideal cites no source. */
84
- provenance: z.array(CharterProvenanceSchema).default([]),
264
+ candidate_id: z.string().min(1).optional(),
265
+ verdict: z.enum(["confirm", "reject", "widen"]),
266
+ members: z.array(CorrespondenceMemberSchema).min(2),
267
+ evidence: z.array(CharterProvenanceSchema).default([]),
268
+ })
269
+ .strict();
270
+ const DifferenceInputSchema = z
271
+ .object({
272
+ /** The candidate_id, or the 0-based index into `correspondences`, this rests on. */
273
+ correspondence: z.union([z.string().min(1), z.number().int().min(0)]),
274
+ dimension: DifferenceDimensionSchema,
275
+ relation: DifferenceRelationSchema,
276
+ split: DifferenceSplitSchema.optional(),
277
+ accounts: z.array(DifferenceAccountSchema).min(2),
278
+ gap: z.string().min(1),
279
+ covered_channel_gap: z.boolean().optional(),
85
280
  })
86
281
  .strict();
87
282
  /**
88
- * The charter-DELTA submission (Phase C.2): the independent miner's channel-pair
89
- * gaps across the already-joined charters, its TRIANGULATED TELOS per subsystem
90
- * (a unified opinion the owner reacts to — a lead, never a reconciliation), any
91
- * True nominations (deepest only), plus the goal DAG it reads off all subsystems
92
- * (it is the only pass that sees every joined unit, so it owns `goal_graph`).
283
+ * The charter-COMPARISON submission (steps 2–3): the comparison reader's verdicts
284
+ * on the tool candidates (plus any it adds), and the typed differences. An empty
285
+ * result must affirm `no_correspondences: true` (a silent empty is indistinguishable
286
+ * from a reader that never ran).
93
287
  */
94
- export const CharterDeltaSubmissionSchema = z
288
+ export const CharterComparisonSubmissionSchema = z
95
289
  .object({
96
- subsystems: z.array(CharterDeltaSubsystemInputSchema).default([]),
97
- triangulated: z.array(TriangulatedTelosSchema).default([]),
98
- true_nominations: z.array(TrueNominationInputSchema).default([]),
99
- goal_graph: GoalGraphSchema.optional(),
100
- /**
101
- * Explicit clean affirmation — "I mined every subsystem and found no deltas."
102
- * REQUIRED when the submission carries zero deltas, and REFUSED alongside any
103
- * delta, so a dead miner (which submits nothing) can never be mistaken for a
104
- * clean one (same contract as `reviewed_clean` on a zero-finding AuditResult).
105
- * Keyed to DELTAS only: a clean mine may still carry triangulated teloses.
106
- */
107
- no_deltas: z.boolean().optional(),
290
+ correspondences: z.array(CorrespondenceInputSchema).default([]),
291
+ differences: z.array(DifferenceInputSchema).default([]),
292
+ no_correspondences: z.boolean().optional(),
108
293
  })
109
294
  .strict()
110
295
  .superRefine((value, ctx) => {
111
- const deltaCount = value.subsystems.reduce((n, s) => n + s.deltas.length, 0);
112
- if (deltaCount === 0 && value.no_deltas !== true) {
296
+ const confirmed = value.correspondences.filter((c) => c.verdict !== "reject").length;
297
+ if (confirmed === 0 && value.no_correspondences !== true) {
113
298
  ctx.addIssue({
114
299
  code: z.ZodIssueCode.custom,
115
- path: ["no_deltas"],
116
- message: "a submission with zero deltas must affirm `no_deltas: true` — an empty result " +
117
- "without the affirmation is indistinguishable from a miner that never ran.",
300
+ path: ["no_correspondences"],
301
+ message: "a submission that confirms or adds no correspondence must affirm `no_correspondences: true`",
118
302
  });
119
303
  }
120
- if (deltaCount > 0 && value.no_deltas === true) {
304
+ if (confirmed > 0 && value.no_correspondences === true) {
121
305
  ctx.addIssue({
122
306
  code: z.ZodIssueCode.custom,
123
- path: ["no_deltas"],
124
- message: "`no_deltas: true` alongside mined deltas is contradictory — drop the flag or the deltas.",
307
+ path: ["no_correspondences"],
308
+ message: "`no_correspondences: true` alongside confirmed correspondences is contradictory",
125
309
  });
126
310
  }
127
311
  });
128
- // ── Deterministic routing table (design §"The estimator charters") ─────────────
129
312
  /**
130
- * Canonical charter-kind order — pairs are sorted by this so `[stated, revealed]`
131
- * and `[revealed, stated]` map to one key (the deltas are symmetric).
313
+ * The design's routing table (step 5), keyed on `(dimension, relation, split)`.
314
+ * The host never picks a route. Non-incompatible records route nowhere except a
315
+ * covered-channel Presence gap, which routes by the silent channel (Stated silent →
316
+ * doc rot for the remediator; a code channel silent → a clarification).
132
317
  */
133
- const KIND_ORDER = ["stated", "structural", "revealed", "true"];
134
- function canonicalPair(pair) {
135
- return [...pair].sort((a, b) => KIND_ORDER.indexOf(a) - KIND_ORDER.indexOf(b));
136
- }
137
- /**
138
- * The design's routing table, keyed by canonical `pair` — who acts on each gap.
139
- * Every ESTIMATOR pair has one defined meaning; `true` pairs exist only for the
140
- * miner's deepest-rung nominations. A pair OUTSIDE this table has no defined
141
- * owner and is a validation issue (the tool never invents a route). `severity`
142
- * ranks the surfaced lead: a wrong-goal provocation is the highest-blast, doc
143
- * rot the lowest.
144
- */
145
- const DELTA_ROUTES = {
146
- "stated|structural": {
147
- kind: "doc_rot",
148
- routed_to: "remediator",
149
- severity: "low",
150
- },
151
- "stated|revealed": {
152
- kind: "says_does_drift",
153
- routed_to: "remediator",
154
- severity: "medium",
155
- },
156
- "structural|revealed": {
157
- kind: "architecture_betrayal",
158
- routed_to: "clarification",
159
- severity: "medium",
160
- },
161
- "stated|true": {
162
- kind: "wrong_goal",
163
- routed_to: "human",
164
- severity: "high",
165
- },
166
- "structural|true": {
167
- kind: "wrong_goal",
168
- routed_to: "human",
169
- severity: "high",
170
- },
171
- "revealed|true": {
172
- kind: "wrong_goal",
173
- routed_to: "human",
174
- severity: "high",
175
- },
176
- };
177
- /** Lower of two charter confidences — a delta is only as strong as its weaker side. */
178
- function weakerConfidence(a, b) {
179
- const rank = { high: 2, medium: 1, low: 0 };
180
- return rank[a.confidence] <= rank[b.confidence] ? a.confidence : b.confidence;
181
- }
182
- // ── Assembly: the file-set-overlap JOIN (Phase C.1) ────────────────────────────
183
- /** Stable content-derived node order so assembly never depends on input order. */
184
- function sortNodeInputs(nodes) {
185
- return [...nodes].sort((a, b) => KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) ||
186
- a.premise_height - b.premise_height ||
187
- compareCodeUnits(a.purpose, b.purpose) ||
188
- compareCodeUnits(a.files[0] ?? "", b.files[0] ?? ""));
189
- }
190
- /** Sorted intersection size of a node's files against a member set. */
191
- function overlapSize(files, members) {
192
- let n = 0;
193
- for (const f of files)
194
- if (members.has(f))
195
- n += 1;
196
- return n;
318
+ export function routeDifference(input) {
319
+ const { dimension, relation, split } = input;
320
+ if (relation !== "incompatible") {
321
+ if (dimension === "presence" && input.covered_channel_gap === true) {
322
+ return input.silent === "stated"
323
+ ? { routed_to: "remediator", severity: "low" }
324
+ : { routed_to: "clarification", severity: "medium" };
325
+ }
326
+ return { routed_to: "none", severity: "info" };
327
+ }
328
+ if (!split || split.kind === "three_way") {
329
+ return { routed_to: "clarification", severity: "high" };
330
+ }
331
+ const odd = split.odd;
332
+ switch (dimension) {
333
+ case "purpose":
334
+ case "scope":
335
+ return odd === "stated"
336
+ ? { routed_to: "remediator", severity: "low" }
337
+ : { routed_to: "clarification", severity: "medium" };
338
+ case "responsibility":
339
+ case "hierarchy":
340
+ return { routed_to: "clarification", severity: "medium" };
341
+ case "standing":
342
+ case "standard":
343
+ return { routed_to: "clarification", severity: "medium" };
344
+ case "presence":
345
+ return odd === "stated"
346
+ ? { routed_to: "remediator", severity: "low" }
347
+ : { routed_to: "clarification", severity: "medium" };
348
+ default:
349
+ return { routed_to: "clarification", severity: "medium" };
350
+ }
197
351
  }
198
352
  /**
199
- * Assemble the joined charter layer (Phase C.1) from the merged per-lane
200
- * submissions. Deterministic: same nodes + same hint + same universe always
201
- * yield the same units, ids, and charter selection.
202
- *
203
- * Join: each grounded node maps to the hint unit with the largest file overlap
204
- * (ties → lexicographically first hint id); nodes overlapping NO hint unit are
205
- * union-found into residual units on any shared file, across kinds. A unit's id
206
- * is its hint `node_id` when hinted, else the lexicographically first file of
207
- * its scope union (provably collision-free: a residual scope contains no hint
208
- * member, so its first file can never equal a hint id, which IS a hint member).
209
- * Per unit per kind, the best-overlap node becomes the kind's charter
210
- * (`charter_id = unit:kind`); every joined node persists in the unit's
211
- * teleology, levels intact.
353
+ * Assemble the confirmed correspondences and the difference records from the
354
+ * comparison submission. Refusals are validation issues, never silent:
355
+ * - a member naming a node absent from its lane's DAG;
356
+ * - a `confirm`/`widen` naming an unknown candidate;
357
+ * - a host-added correspondence (no candidate) with fewer than two evidence refs
358
+ * whose PATHS lie in the repo universe, or whose refs are all on one side;
359
+ * - a difference naming no confirmed correspondence, an account for a lane not in
360
+ * that correspondence, an `incompatible` relation without a `split`, or a split
361
+ * with a non-incompatible relation.
362
+ * Ids are content-keyed (member set / correspondence + dimension + gap).
212
363
  */
213
- export function assembleCharters(submission, params) {
364
+ export function assembleComparison(submission, params) {
214
365
  const validation_issues = [];
215
- // Ground every node against the universe; drop whole nodes on unknown paths
216
- // (a silently narrowed scope would corrupt the join key).
217
- const grounded = [];
218
- for (const node of sortNodeInputs(submission.nodes)) {
219
- const unknown = node.files.filter((f) => !params.universe.has(f));
220
- if (unknown.length > 0) {
221
- validation_issues.push(`${node.kind} teleology node "${node.purpose.slice(0, 80)}" cites file(s) outside the repo universe — dropped (${unknown
222
- .sort((a, b) => compareCodeUnits(a, b))
223
- .join(", ")})`);
224
- continue;
366
+ const nodeIdsByKind = new Map(params.graphs.map((g) => [g.kind, new Set(g.nodes.map((n) => n.node_id))]));
367
+ const candidateById = new Map(params.candidates.map((c) => [c.candidate_id, c]));
368
+ const correspondences = [];
369
+ const byInputIndex = new Map();
370
+ const byCandidate = new Map();
371
+ const seenKeys = new Set();
372
+ submission.correspondences.forEach((input, index) => {
373
+ if (input.verdict === "reject")
374
+ return;
375
+ const badMember = input.members.find((m) => m.node_ids.some((id) => !(nodeIdsByKind.get(m.kind)?.has(id) ?? false)));
376
+ if (badMember) {
377
+ validation_issues.push(`correspondence #${index}: names node(s) absent from the ${badMember.kind} DAG — dropped`);
378
+ return;
225
379
  }
226
- grounded.push({ ...node, files: [...new Set(node.files)].sort((a, b) => compareCodeUnits(a, b)) });
227
- }
228
- // Hint mapping: node → best-overlap consensus unit.
229
- const hintIds = [...params.hint.keys()].sort((a, b) => compareCodeUnits(a, b));
230
- const hintMembers = new Map(hintIds.map((id) => [id, new Set(params.hint.get(id))]));
231
- const hinted = new Map();
232
- const residual = [];
233
- for (const node of grounded) {
234
- let bestId;
235
- let bestOverlap = 0;
236
- for (const id of hintIds) {
237
- const overlap = overlapSize(node.files, hintMembers.get(id));
238
- if (overlap > bestOverlap) {
239
- bestOverlap = overlap;
240
- bestId = id;
241
- }
380
+ if (new Set(input.members.map((m) => m.kind)).size < 2) {
381
+ validation_issues.push(`correspondence #${index}: spans fewer than two lanes — dropped`);
382
+ return;
242
383
  }
243
- if (bestId !== undefined) {
244
- const list = hinted.get(bestId) ?? [];
245
- list.push(node);
246
- hinted.set(bestId, list);
384
+ let basis = "host";
385
+ if (input.candidate_id !== undefined) {
386
+ if (!candidateById.has(input.candidate_id)) {
387
+ validation_issues.push(`correspondence #${index}: candidate "${input.candidate_id}" is not a tool candidate — dropped`);
388
+ return;
389
+ }
390
+ basis = "tool";
247
391
  }
248
392
  else {
249
- residual.push(node);
250
- }
251
- }
252
- // Residual union-find: any shared file joins nodes into one unit, across kinds.
253
- const parent = residual.map((_, i) => i);
254
- const find = (i) => {
255
- while (parent[i] !== i) {
256
- parent[i] = parent[parent[i]];
257
- i = parent[i];
393
+ // A host-added correspondence needs two CHECKABLE refs (their paths lie in
394
+ // the repo universe) on at least two different sides — one per lane it joins.
395
+ // A ref is attributed to the member whose scope holds its path; a checkable
396
+ // ref no member scope holds counts, but only as one unattributed side.
397
+ const sides = new Set();
398
+ for (const p of input.evidence) {
399
+ const path = provenancePath(p.ref);
400
+ if (!params.universe.has(path))
401
+ continue;
402
+ sides.add(ownerOfPath(input.members, params.graphs, path) ?? `unattributed:${path}`);
403
+ }
404
+ if (sides.size < 2) {
405
+ validation_issues.push(`correspondence #${index}: host-added with fewer than two checkable evidence refs on different sides — dropped`);
406
+ return;
407
+ }
258
408
  }
259
- return i;
260
- };
261
- const union = (a, b) => {
262
- const ra = find(a);
263
- const rb = find(b);
264
- if (ra !== rb)
265
- parent[Math.max(ra, rb)] = Math.min(ra, rb);
266
- };
267
- const byFile = new Map();
268
- residual.forEach((node, i) => {
269
- for (const f of node.files) {
270
- const seen = byFile.get(f);
271
- if (seen === undefined)
272
- byFile.set(f, i);
273
- else
274
- union(seen, i);
409
+ const key = memberKey(input.members);
410
+ if (seenKeys.has(key)) {
411
+ validation_issues.push(`correspondence #${index}: duplicates an earlier member set — dropped`);
412
+ return;
275
413
  }
276
- });
277
- const residualUnits = new Map();
278
- residual.forEach((node, i) => {
279
- const root = find(i);
280
- const list = residualUnits.get(root) ?? [];
281
- list.push(node);
282
- residualUnits.set(root, list);
283
- });
284
- const drafts = [];
285
- for (const id of hintIds) {
286
- const nodes = hinted.get(id);
287
- if (!nodes || nodes.length === 0)
288
- continue; // partial coverage is designed
289
- const members = new Set(params.hint.get(id));
290
- for (const node of nodes)
291
- for (const f of node.files)
292
- members.add(f);
293
- drafts.push({
294
- node_id: id,
295
- members: [...members].sort((a, b) => compareCodeUnits(a, b)),
296
- nodes,
414
+ seenKeys.add(key);
415
+ const correspondence_id = `corr-${hashContent(key, { length: 10 })}`;
416
+ correspondences.push({
417
+ correspondence_id,
418
+ members: [...input.members]
419
+ .map((m) => ({ kind: m.kind, node_ids: [...m.node_ids].sort(compareCodeUnits) }))
420
+ .sort((a, b) => compareCodeUnits(a.kind, b.kind)),
421
+ basis,
422
+ ...(input.candidate_id !== undefined ? { candidate_id: input.candidate_id } : {}),
423
+ evidence: input.evidence,
297
424
  });
298
- }
299
- for (const nodes of residualUnits.values()) {
300
- const members = new Set();
301
- for (const node of nodes)
302
- for (const f of node.files)
303
- members.add(f);
304
- const sorted = [...members].sort((a, b) => compareCodeUnits(a, b));
305
- drafts.push({ node_id: sorted[0], members: sorted, nodes });
306
- }
307
- drafts.sort((a, b) => compareCodeUnits(a.node_id, b.node_id));
308
- // Per unit: teleologies per kind + tool-selected charter per kind + True gate.
309
- const subsystems = [];
310
- for (const draft of drafts) {
311
- const memberSet = new Set(draft.members);
312
- const byKind = new Map();
313
- for (const node of draft.nodes) {
314
- const list = byKind.get(node.kind) ?? [];
315
- list.push(node);
316
- byKind.set(node.kind, list);
425
+ byInputIndex.set(index, correspondence_id);
426
+ if (input.candidate_id !== undefined)
427
+ byCandidate.set(input.candidate_id, correspondence_id);
428
+ });
429
+ const corrById = new Map(correspondences.map((c) => [c.correspondence_id, c]));
430
+ const differences = [];
431
+ const seenDiff = new Set();
432
+ submission.differences.forEach((input, index) => {
433
+ const corrId = typeof input.correspondence === "number"
434
+ ? byInputIndex.get(input.correspondence)
435
+ : (byCandidate.get(input.correspondence) ?? (corrById.has(input.correspondence) ? input.correspondence : undefined));
436
+ const corr = corrId ? corrById.get(corrId) : undefined;
437
+ if (!corr) {
438
+ validation_issues.push(`difference #${index}: names no confirmed correspondence (${String(input.correspondence)}) — dropped`);
439
+ return;
317
440
  }
318
- const teleologies = {};
319
- const selected = [];
320
- for (const kind of KIND_ORDER) {
321
- const nodes = byKind.get(kind);
322
- if (!nodes || nodes.length === 0)
323
- continue;
324
- teleologies[kind] = nodes
325
- .map((n) => ({
326
- purpose: n.purpose,
327
- premise_height: n.premise_height,
328
- files: n.files,
329
- }))
330
- .sort((a, b) => a.premise_height - b.premise_height ||
331
- compareCodeUnits(a.purpose, b.purpose));
332
- const best = [...nodes].sort((a, b) => overlapSize(b.files, memberSet) - overlapSize(a.files, memberSet) ||
333
- a.premise_height - b.premise_height ||
334
- compareCodeUnits(a.purpose, b.purpose))[0];
335
- selected.push({
336
- charter_id: `${draft.node_id}:${kind}`,
337
- kind,
338
- purpose: best.purpose,
339
- provenance: best.provenance,
340
- confidence: best.confidence,
341
- ...(best.nominated_alternative !== undefined
342
- ? { nominated_alternative: best.nominated_alternative }
343
- : {}),
344
- ...(best.nominated_cost !== undefined
345
- ? { nominated_cost: best.nominated_cost }
346
- : {}),
347
- });
441
+ const lanes = new Set(corr.members.map((m) => m.kind));
442
+ const stray = input.accounts.find((a) => !lanes.has(a.kind));
443
+ if (stray) {
444
+ validation_issues.push(`difference #${index}: carries an account for "${stray.kind}", a lane outside its correspondence — dropped`);
445
+ return;
348
446
  }
349
- // Phase-A True gate: extraction lanes never author `true`, but the gate
350
- // stays as the mechanical backstop (falsifiable-or-drop).
351
- const { kept, dropped } = applyTrueCharterGate(selected);
352
- for (const drop of dropped) {
353
- validation_issues.push(`${drop.charter_id}: ${drop.reason}`);
447
+ if (input.relation === "incompatible" && !input.split) {
448
+ validation_issues.push(`difference #${index}: incompatible without a split — dropped`);
449
+ return;
354
450
  }
355
- if (kept.length === 0)
356
- continue;
357
- subsystems.push({
358
- node_id: draft.node_id,
359
- members: draft.members,
360
- charters: [...kept].sort((a, b) => compareCodeUnits(a.charter_id, b.charter_id)),
361
- teleologies,
451
+ if (input.relation !== "incompatible" && input.split) {
452
+ validation_issues.push(`difference #${index}: a split on a ${input.relation} relation — dropped`);
453
+ return;
454
+ }
455
+ if (input.split?.kind === "two_against_one" && !lanes.has(input.split.odd)) {
456
+ validation_issues.push(`difference #${index}: split names "${input.split.odd}" as the odd channel, which is not in its correspondence — dropped`);
457
+ return;
458
+ }
459
+ if (input.split?.kind === "three_way" && lanes.size < 3) {
460
+ validation_issues.push(`difference #${index}: three_way split on a two-lane correspondence — dropped`);
461
+ return;
462
+ }
463
+ const accounts = [...input.accounts].sort((a, b) => compareCodeUnits(a.kind, b.kind));
464
+ const silent = input.dimension === "presence"
465
+ ? [...lanes].find((k) => !accounts.some((a) => a.kind === k))
466
+ : undefined;
467
+ const route = routeDifference({
468
+ dimension: input.dimension,
469
+ relation: input.relation,
470
+ split: input.split,
471
+ covered_channel_gap: input.covered_channel_gap,
472
+ silent,
362
473
  });
363
- }
364
- return { subsystems, validation_issues };
474
+ const difference_id = `diff-${hashContent(`${corr.correspondence_id}|${input.dimension}|${input.gap}`, { length: 10 })}`;
475
+ if (seenDiff.has(difference_id)) {
476
+ validation_issues.push(`difference #${index}: duplicates an earlier record — dropped`);
477
+ return;
478
+ }
479
+ seenDiff.add(difference_id);
480
+ differences.push({
481
+ difference_id,
482
+ correspondence_id: corr.correspondence_id,
483
+ dimension: input.dimension,
484
+ relation: input.relation,
485
+ ...(input.split ? { split: input.split } : {}),
486
+ accounts,
487
+ gap: input.gap,
488
+ ...(input.covered_channel_gap !== undefined ? { covered_channel_gap: input.covered_channel_gap } : {}),
489
+ routed_to: route.routed_to,
490
+ finding_candidate: input.relation === "incompatible" ||
491
+ (input.dimension === "presence" && input.covered_channel_gap === true),
492
+ });
493
+ });
494
+ correspondences.sort((a, b) => compareCodeUnits(a.correspondence_id, b.correspondence_id));
495
+ differences.sort((a, b) => compareCodeUnits(a.difference_id, b.difference_id));
496
+ return { correspondences, differences, validation_issues };
365
497
  }
366
- export function assembleDeltas(submission, subsystems, params) {
367
- const deltas = [];
368
- const findings = [];
369
- const validation_issues = [];
370
- const augmented = subsystems.map((s) => ({
371
- ...s,
372
- charters: [...s.charters],
373
- }));
374
- const byNode = new Map(augmented.map((s) => [s.node_id, s]));
375
- // Every goal-graph node id the miner reported — a delta's subsystem is
376
- // "linked" exactly when its node_id appears here (mirrors the existing
377
- // out-of-scope consumer's own derivation, now computed once here instead).
378
- const goalNodeIds = new Set((submission.goal_graph?.nodes ?? []).map((n) => n.node_id));
379
- // True nominations first (deepest only): survivors join the unit's charters
380
- // and are pair-eligible for this same submission's deltas.
381
- const nominations = [...submission.true_nominations].sort((a, b) => compareCodeUnits(a.node_id, b.node_id) || compareCodeUnits(a.purpose, b.purpose));
382
- if (nominations.length > 0 && !params.allowTrueNominations) {
383
- validation_issues.push(`submission carries ${nominations.length} true nomination(s) but the ceiling does not authorize the deepest rung — all dropped (true provocations require explicit deepest opt-in)`);
384
- }
385
- else {
386
- for (const nomination of nominations) {
387
- const subsystem = byNode.get(nomination.node_id);
388
- if (!subsystem) {
389
- validation_issues.push(`true nomination for "${nomination.node_id}" names no joined subsystem — dropped`);
390
- continue;
391
- }
392
- if (subsystem.charters.some((c) => c.kind === "true")) {
393
- validation_issues.push(`subsystem "${nomination.node_id}" has more than one true nomination — kept the first, dropped the rest`);
394
- continue;
395
- }
396
- const candidate = {
397
- charter_id: `${nomination.node_id}:true`,
398
- kind: "true",
399
- purpose: nomination.purpose,
400
- provenance: nomination.provenance,
401
- confidence: nomination.confidence,
402
- nominated_alternative: nomination.nominated_alternative,
403
- nominated_cost: nomination.nominated_cost,
404
- };
405
- const { kept, dropped } = applyTrueCharterGate([candidate]);
406
- for (const drop of dropped) {
407
- validation_issues.push(`${drop.charter_id}: ${drop.reason}`);
408
- }
409
- if (kept.length > 0) {
410
- subsystem.charters.push(kept[0]);
411
- subsystem.charters.sort((a, b) => compareCodeUnits(a.charter_id, b.charter_id));
412
- }
498
+ function ownerOfPath(members, graphs, path) {
499
+ for (const m of members) {
500
+ const graph = graphs.find((g) => g.kind === m.kind);
501
+ if (!graph)
502
+ continue;
503
+ for (const id of m.node_ids) {
504
+ const node = graph.nodes.find((n) => n.node_id === id);
505
+ if (node?.files?.includes(path))
506
+ return m.kind;
413
507
  }
414
508
  }
415
- // Deltas: route by channel pair, gate by confidence, surface as leads.
416
- const sorted = [...submission.subsystems].sort((a, b) => compareCodeUnits(a.node_id, b.node_id));
417
- for (const sub of sorted) {
418
- const subsystem = byNode.get(sub.node_id);
419
- if (!subsystem) {
420
- validation_issues.push(`delta subsystem "${sub.node_id}" has no assembled charters — dropped (deltas may only span reviewed subsystems)`);
421
- continue;
509
+ return undefined;
510
+ }
511
+ // ── Step 4: fidelity ───────────────────────────────────────────────────────────
512
+ /** The fidelity lane's submission: one verdict per difference in its packet. */
513
+ export const CharterFidelitySubmissionSchema = z
514
+ .object({
515
+ verdicts: z
516
+ .array(z
517
+ .object({
518
+ difference_id: z.string().min(1),
519
+ verdict: z.enum(["supported", "interpretation", "unverifiable"]),
520
+ over_read_side: CharterLaneKindSchema.optional(),
521
+ rationale: z.string().min(1),
522
+ })
523
+ .strict()
524
+ .superRefine((v, ctx) => {
525
+ if (v.verdict === "interpretation" && !v.over_read_side) {
526
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["over_read_side"], message: "an interpretation verdict names the side that over-read" });
422
527
  }
423
- const kept = subsystem.charters;
424
- const keptByKind = new Map(kept.map((c) => [c.kind, c]));
425
- // Pass 1: validate + route every draft delta (identical checks/drop
426
- // reasons/order to before), grouping the SURVIVORS by canonical pair —
427
- // the grouping key delta_id minting (pass 2) discriminates on.
428
- const survivorsByPairKey = new Map();
429
- for (const draft of sub.deltas) {
430
- const [ka, kb] = canonicalPair(draft.pair);
431
- if (ka === kb) {
432
- validation_issues.push(`subsystem "${sub.node_id}" delta pairs "${ka}" with itself — dropped`);
433
- continue;
434
- }
435
- const route = DELTA_ROUTES[`${ka}|${kb}`];
436
- if (!route) {
437
- validation_issues.push(`subsystem "${sub.node_id}" delta [${ka}, ${kb}] has no routing in the design's table — dropped`);
438
- continue;
439
- }
440
- const charterA = keptByKind.get(ka);
441
- const charterB = keptByKind.get(kb);
442
- if (!charterA || !charterB) {
443
- const missing = [!charterA ? ka : null, !charterB ? kb : null]
444
- .filter((m) => m !== null)
445
- .join(" + ");
446
- validation_issues.push(`subsystem "${sub.node_id}" delta [${ka}, ${kb}] references a missing/dropped charter (${missing}) — dropped`);
447
- continue;
448
- }
449
- const pairKey = `${ka}|${kb}`;
450
- const list = survivorsByPairKey.get(pairKey) ?? [];
451
- list.push({ pair: [ka, kb], route, charterA, charterB, summary: draft.summary });
452
- survivorsByPairKey.set(pairKey, list);
528
+ if (v.verdict !== "interpretation" && v.over_read_side) {
529
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["over_read_side"], message: "over_read_side only with an interpretation verdict" });
453
530
  }
454
- // Pass 2: mint delta_id per group. A subsystem mining exactly ONE delta on
455
- // a channel pair — the common case — keeps the bare, pre-existing
456
- // `node_id:ka-kb` shape (identity was already unique; no discriminator
457
- // needed or added). A subsystem mining MORE THAN ONE delta on the SAME
458
- // canonical pair (COR-6b924995 / COR-d8089caf: `[stated,revealed]` and
459
- // `[revealed,stated]` collide into this same group via canonicalPair
460
- // above, so pair order can never dodge this) gets each member a
461
- // content-derived discriminator — a hash of its own summary, never a
462
- // submission-array index — so identity is stable and order-independent
463
- // regardless of which order the miner happened to list them in.
464
- for (const group of survivorsByPairKey.values()) {
465
- for (const surv of group) {
466
- const [ka, kb] = surv.pair;
467
- const delta_id = group.length === 1
468
- ? `${sub.node_id}:${ka}-${kb}`
469
- : `${sub.node_id}:${ka}-${kb}:${hashContent(surv.summary, { length: 8 })}`;
470
- const baseDelta = {
471
- delta_id,
472
- pair: surv.pair,
473
- kind: surv.route.kind,
474
- routed_to: surv.route.routed_to,
475
- summary: surv.summary,
476
- node_id: sub.node_id,
477
- ...(goalNodeIds.has(sub.node_id) ? { goal_node_id: sub.node_id } : {}),
478
- };
479
- // Phase-A low-confidence gate: a shaky side forces the human channel.
480
- // gateCharterDelta either returns `delta` unchanged or spreads it
481
- // (`{ ...delta, routed_to: "human" }`), so node_id/goal_node_id
482
- // survive the call; the cast reflects that read, not an assumption.
483
- const gated = gateCharterDelta(baseDelta, kept);
484
- deltas.push(gated);
485
- findings.push(deltaToFinding(gated, sub.node_id, subsystem.members, surv.route.severity, weakerConfidence(surv.charterA, surv.charterB)));
486
- }
531
+ }))
532
+ .default([]),
533
+ })
534
+ .strict();
535
+ /**
536
+ * The MECHANICAL pre-check (step 4, first half): given, per provenance ref, whether
537
+ * its quote was found at its ref on disk (`quoteFound(ref, quote)` — the ingest reads
538
+ * the files; this module never does), stamp `unverifiable` (decided_by `tool`) on
539
+ * every finding candidate that has a side whose cited quote is absent. Records with
540
+ * every quote present are left for the lane. Returns the differences with the tool
541
+ * verdicts stamped, plus the ids still owed a lane verdict.
542
+ */
543
+ export function precheckFidelity(differences, quoteFound) {
544
+ const pendingLane = [];
545
+ const stamped = differences.map((d) => {
546
+ if (!d.finding_candidate)
547
+ return d;
548
+ const missing = d.accounts.flatMap((a) => a.provenance
549
+ .filter((p) => p.quote !== undefined && quoteFound(p) === false)
550
+ .map((p) => `${a.kind}: ${p.ref}`));
551
+ if (missing.length > 0) {
552
+ const verdict = {
553
+ verdict: "unverifiable",
554
+ rationale: `cited quote not found at ${missing.sort(compareCodeUnits).join("; ")}`,
555
+ decided_by: "tool",
556
+ };
557
+ return { ...d, fidelity: verdict };
487
558
  }
488
- }
489
- // Triangulated teloses: one per known unit; a lead the owner reacts to.
490
- const triangulated = [];
491
- const seenTelos = new Set();
492
- for (const telos of [...submission.triangulated].sort((a, b) => compareCodeUnits(a.node_id, b.node_id))) {
493
- if (!byNode.has(telos.node_id)) {
494
- validation_issues.push(`triangulated telos for "${telos.node_id}" names no joined subsystem — dropped`);
559
+ pendingLane.push(d.difference_id);
560
+ return d;
561
+ });
562
+ return { differences: stamped, pendingLane: pendingLane.sort(compareCodeUnits) };
563
+ }
564
+ /**
565
+ * Stamp the lane's verdicts (step 4, second half). A verdict naming an unknown
566
+ * difference, or a difference the tool already settled, is a validation issue; a
567
+ * finding candidate left without any verdict stays pending (never assumed
568
+ * `supported`).
569
+ */
570
+ export function applyFidelity(differences, submission) {
571
+ const validation_issues = [];
572
+ const byId = new Map(differences.map((d) => [d.difference_id, d]));
573
+ const verdicts = new Map();
574
+ for (const v of submission.verdicts) {
575
+ const d = byId.get(v.difference_id);
576
+ if (!d) {
577
+ validation_issues.push(`fidelity verdict for unknown difference "${v.difference_id}" — dropped`);
495
578
  continue;
496
579
  }
497
- if (seenTelos.has(telos.node_id)) {
498
- validation_issues.push(`subsystem "${telos.node_id}" has more than one triangulated telos — kept the first, dropped the rest`);
580
+ if (d.fidelity?.decided_by === "tool") {
581
+ validation_issues.push(`fidelity verdict for "${v.difference_id}" ignored — the tool pre-check already settled it as unverifiable`);
499
582
  continue;
500
583
  }
501
- seenTelos.add(telos.node_id);
502
- triangulated.push(telos);
503
- }
504
- // Disagreement density: tool-computed, per unit per channel pair — the
505
- // quantitative surface for "which parts of the triangulation need
506
- // clarification."
507
- const densityByKey = new Map();
508
- for (const delta of deltas) {
509
- // Read the explicit field (INV-CDI-EXPLICIT-NODE-FIELDS) — never parse
510
- // delta_id, which is opaque and, since the fix above, may carry a
511
- // discriminator suffix a naive last-colon split would misread.
512
- const key = `${delta.node_id}|${delta.pair[0]}|${delta.pair[1]}`;
513
- const existing = densityByKey.get(key);
514
- if (existing) {
515
- densityByKey.set(key, { ...existing, count: existing.count + 1 });
516
- }
517
- else {
518
- densityByKey.set(key, { node_id: delta.node_id, pair: delta.pair, count: 1 });
584
+ if (verdicts.has(v.difference_id)) {
585
+ validation_issues.push(`duplicate fidelity verdict for "${v.difference_id}" — kept the first`);
586
+ continue;
519
587
  }
588
+ verdicts.set(v.difference_id, {
589
+ verdict: v.verdict,
590
+ ...(v.over_read_side ? { over_read_side: v.over_read_side } : {}),
591
+ rationale: v.rationale,
592
+ decided_by: "lane",
593
+ });
520
594
  }
521
- const disagreement = [...densityByKey.values()].sort((a, b) => compareCodeUnits(a.node_id, b.node_id) ||
522
- compareCodeUnits(a.pair[0], b.pair[0]) ||
523
- compareCodeUnits(a.pair[1], b.pair[1]));
524
- deltas.sort((a, b) => compareCodeUnits(a.delta_id, b.delta_id));
525
- findings.sort((a, b) => compareCodeUnits(a.id, b.id));
526
- return {
527
- subsystems: augmented,
528
- deltas,
529
- findings,
530
- triangulated,
531
- disagreement,
532
- goal_graph: submission.goal_graph ?? { nodes: [], edges: [] },
533
- validation_issues,
534
- };
595
+ const stamped = differences.map((d) => {
596
+ const v = verdicts.get(d.difference_id);
597
+ return v ? { ...d, fidelity: v } : d;
598
+ });
599
+ const still_pending = stamped
600
+ .filter((d) => d.finding_candidate && !d.fidelity)
601
+ .map((d) => d.difference_id)
602
+ .sort(compareCodeUnits);
603
+ return { differences: stamped, validation_issues, still_pending };
535
604
  }
605
+ // ── Step 5: findings (leads) ───────────────────────────────────────────────────
536
606
  /**
537
- * Surface a routed charter delta as a Finding LEAD ([[leads-not-verdicts]] — the
538
- * owner judges it; a charter delta is never a verdict). `lens` is `architecture`:
539
- * a charter-boundary gap is a design defect. Members of the subsystem are the
540
- * affected files (the charter layer operates over file ids).
607
+ * Surface every `supported` finding candidate as a Finding LEAD (leads-not-verdicts).
608
+ * `affected_files` = the union of the corresponding nodes' scopes (the report's
609
+ * grouping evidence); `confidence` = the weakest account's source confidence.
541
610
  */
542
- function deltaToFinding(delta, nodeId, members, severity, confidence) {
543
- const kindLabel = delta.kind.replace(/_/g, " ");
544
- return {
545
- id: delta.delta_id,
546
- title: `Charter delta (${kindLabel}) in subsystem ${nodeId}`,
547
- category: `charter_delta:${delta.kind}`,
548
- severity,
549
- confidence,
550
- lens: "architecture",
551
- summary: delta.summary,
552
- affected_files: members.map((path) => ({ path })),
553
- systemic: true,
554
- };
611
+ export function differenceFindings(differences, correspondences, graphs) {
612
+ const corrById = new Map(correspondences.map((c) => [c.correspondence_id, c]));
613
+ const findings = [];
614
+ for (const d of differences) {
615
+ if (!d.finding_candidate || d.fidelity?.verdict !== "supported")
616
+ continue;
617
+ const corr = corrById.get(d.correspondence_id);
618
+ const files = new Set();
619
+ let weakest = "high";
620
+ for (const m of corr?.members ?? []) {
621
+ const graph = graphs.find((g) => g.kind === m.kind);
622
+ for (const id of m.node_ids) {
623
+ const node = graph?.nodes.find((n) => n.node_id === id);
624
+ for (const f of node?.files ?? [])
625
+ files.add(f);
626
+ if (node && rank(node.confidence) < rank(weakest))
627
+ weakest = node.confidence;
628
+ }
629
+ }
630
+ const route = routeDifference({
631
+ dimension: d.dimension,
632
+ relation: d.relation,
633
+ split: d.split,
634
+ covered_channel_gap: d.covered_channel_gap,
635
+ });
636
+ findings.push({
637
+ id: d.difference_id,
638
+ title: `Charter ${d.dimension} difference (${describeSplit(d)})`,
639
+ category: `charter_difference:${d.dimension}`,
640
+ severity: route.severity,
641
+ confidence: weakest,
642
+ lens: "architecture",
643
+ summary: `${d.gap} ${d.accounts.map((a) => `[${a.kind}] ${a.claim}`).join(" ")}`,
644
+ affected_files: [...files].sort(compareCodeUnits).map((path) => ({ path })),
645
+ systemic: true,
646
+ });
647
+ }
648
+ return findings.sort((a, b) => compareCodeUnits(a.id, b.id));
649
+ }
650
+ function rank(c) {
651
+ return c === "high" ? 2 : c === "medium" ? 1 : 0;
652
+ }
653
+ function describeSplit(d) {
654
+ if (!d.split)
655
+ return d.relation;
656
+ return d.split.kind === "three_way" ? "three-way" : `${d.split.odd} against the rest`;
555
657
  }
556
658
  //# sourceMappingURL=charterExtraction.js.map