audit-tools 0.32.20 → 0.32.22

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 (195) hide show
  1. package/dist/audit/clarification/blastRadius.d.ts +23 -0
  2. package/dist/audit/clarification/blastRadius.d.ts.map +1 -0
  3. package/dist/audit/clarification/blastRadius.js +65 -0
  4. package/dist/audit/clarification/blastRadius.js.map +1 -0
  5. package/dist/audit/clarification/dials.d.ts +28 -0
  6. package/dist/audit/clarification/dials.d.ts.map +1 -0
  7. package/dist/audit/clarification/dials.js +37 -0
  8. package/dist/audit/clarification/dials.js.map +1 -0
  9. package/dist/audit/clarification/partition.d.ts +25 -0
  10. package/dist/audit/clarification/partition.d.ts.map +1 -0
  11. package/dist/audit/clarification/partition.js +77 -0
  12. package/dist/audit/clarification/partition.js.map +1 -0
  13. package/dist/audit/clarification/riskGate.d.ts +24 -0
  14. package/dist/audit/clarification/riskGate.d.ts.map +1 -0
  15. package/dist/audit/clarification/riskGate.js +38 -0
  16. package/dist/audit/clarification/riskGate.js.map +1 -0
  17. package/dist/audit/clarification/voiQueue.d.ts +17 -0
  18. package/dist/audit/clarification/voiQueue.d.ts.map +1 -0
  19. package/dist/audit/clarification/voiQueue.js +37 -0
  20. package/dist/audit/clarification/voiQueue.js.map +1 -0
  21. package/dist/audit/cli/auditStep.d.ts +2 -0
  22. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  23. package/dist/audit/cli/auditStep.js +9 -1
  24. package/dist/audit/cli/auditStep.js.map +1 -1
  25. package/dist/audit/cli/charterClarificationPrompt.d.ts +19 -0
  26. package/dist/audit/cli/charterClarificationPrompt.d.ts.map +1 -0
  27. package/dist/audit/cli/charterClarificationPrompt.js +60 -0
  28. package/dist/audit/cli/charterClarificationPrompt.js.map +1 -0
  29. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  30. package/dist/audit/cli/nextStepCommand.js +74 -0
  31. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  32. package/dist/audit/cli/nextStepHelpers.d.ts +62 -0
  33. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  34. package/dist/audit/cli/nextStepHelpers.js +129 -0
  35. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  36. package/dist/audit/cli/steps.d.ts +4 -4
  37. package/dist/audit/cli/steps.d.ts.map +1 -1
  38. package/dist/audit/cli/steps.js +2 -0
  39. package/dist/audit/cli/steps.js.map +1 -1
  40. package/dist/audit/io/artifacts.d.ts +6 -0
  41. package/dist/audit/io/artifacts.d.ts.map +1 -1
  42. package/dist/audit/io/artifacts.js +2 -0
  43. package/dist/audit/io/artifacts.js.map +1 -1
  44. package/dist/audit/orchestrator/advance.d.ts +23 -0
  45. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  46. package/dist/audit/orchestrator/advance.js +122 -4
  47. package/dist/audit/orchestrator/advance.js.map +1 -1
  48. package/dist/audit/orchestrator/advanceTypes.d.ts +22 -1
  49. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  50. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts +28 -0
  51. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts.map +1 -0
  52. package/dist/audit/orchestrator/charterClarificationExecutor.js +130 -0
  53. package/dist/audit/orchestrator/charterClarificationExecutor.js.map +1 -0
  54. package/dist/audit/orchestrator/dependencyMap.d.ts +2 -0
  55. package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
  56. package/dist/audit/orchestrator/dependencyMap.js +24 -0
  57. package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
  58. package/dist/audit/orchestrator/designReviewPrompt.d.ts +17 -0
  59. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/designReviewPrompt.js +50 -0
  61. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  62. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  63. package/dist/audit/orchestrator/executorRunners.js +4 -0
  64. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  65. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  66. package/dist/audit/orchestrator/executors.js +20 -0
  67. package/dist/audit/orchestrator/executors.js.map +1 -1
  68. package/dist/audit/orchestrator/nextStep.d.ts +11 -1
  69. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  70. package/dist/audit/orchestrator/nextStep.js +6 -2
  71. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  72. package/dist/audit/orchestrator/staleness.d.ts +27 -1
  73. package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
  74. package/dist/audit/orchestrator/staleness.js +33 -16
  75. package/dist/audit/orchestrator/staleness.js.map +1 -1
  76. package/dist/audit/orchestrator/state.d.ts +12 -1
  77. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  78. package/dist/audit/orchestrator/state.js +41 -2
  79. package/dist/audit/orchestrator/state.js.map +1 -1
  80. package/dist/audit/orchestrator/synthesisExecutors.d.ts.map +1 -1
  81. package/dist/audit/orchestrator/synthesisExecutors.js +1 -0
  82. package/dist/audit/orchestrator/synthesisExecutors.js.map +1 -1
  83. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +25 -0
  84. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -0
  85. package/dist/audit/orchestrator/systemicChallengeExecutor.js +107 -0
  86. package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -0
  87. package/dist/audit/reporting/mergeFindings.d.ts +2 -1
  88. package/dist/audit/reporting/mergeFindings.d.ts.map +1 -1
  89. package/dist/audit/reporting/mergeFindings.js +6 -1
  90. package/dist/audit/reporting/mergeFindings.js.map +1 -1
  91. package/dist/audit/reporting/synthesis.d.ts +2 -0
  92. package/dist/audit/reporting/synthesis.d.ts.map +1 -1
  93. package/dist/audit/reporting/synthesis.js +1 -1
  94. package/dist/audit/reporting/synthesis.js.map +1 -1
  95. package/dist/audit/systemic/aggregateMetricsDigest.d.ts +11 -0
  96. package/dist/audit/systemic/aggregateMetricsDigest.d.ts.map +1 -0
  97. package/dist/audit/systemic/aggregateMetricsDigest.js +84 -0
  98. package/dist/audit/systemic/aggregateMetricsDigest.js.map +1 -0
  99. package/dist/audit/systemic/metricsDigestTypes.d.ts +35 -0
  100. package/dist/audit/systemic/metricsDigestTypes.d.ts.map +1 -0
  101. package/dist/audit/systemic/metricsDigestTypes.js +10 -0
  102. package/dist/audit/systemic/metricsDigestTypes.js.map +1 -0
  103. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +16 -0
  104. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -0
  105. package/dist/audit/systemic/secondOrderAdversaryPrompt.js +85 -0
  106. package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -0
  107. package/dist/audit/systemic/systemicChallengeLoop.d.ts +48 -0
  108. package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -0
  109. package/dist/audit/systemic/systemicChallengeLoop.js +107 -0
  110. package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -0
  111. package/dist/audit/types/charterClarification.d.ts +52 -0
  112. package/dist/audit/types/charterClarification.d.ts.map +1 -0
  113. package/dist/audit/types/charterClarification.js +2 -0
  114. package/dist/audit/types/charterClarification.js.map +1 -0
  115. package/dist/audit/types/systemicChallenge.d.ts +69 -0
  116. package/dist/audit/types/systemicChallenge.d.ts.map +1 -0
  117. package/dist/audit/types/systemicChallenge.js +2 -0
  118. package/dist/audit/types/systemicChallenge.js.map +1 -0
  119. package/dist/remediate/steps/dispatch/acceptNode.d.ts +178 -0
  120. package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -0
  121. package/dist/remediate/steps/dispatch/acceptNode.js +351 -0
  122. package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -0
  123. package/dist/remediate/steps/dispatch/common.d.ts +123 -0
  124. package/dist/remediate/steps/dispatch/common.d.ts.map +1 -0
  125. package/dist/remediate/steps/dispatch/common.js +236 -0
  126. package/dist/remediate/steps/dispatch/common.js.map +1 -0
  127. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts +37 -0
  128. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts.map +1 -0
  129. package/dist/remediate/steps/dispatch/dagNodeFields.js +19 -0
  130. package/dist/remediate/steps/dispatch/dagNodeFields.js.map +1 -0
  131. package/dist/remediate/steps/dispatch/implementPrompt.d.ts +70 -0
  132. package/dist/remediate/steps/dispatch/implementPrompt.d.ts.map +1 -0
  133. package/dist/remediate/steps/dispatch/implementPrompt.js +577 -0
  134. package/dist/remediate/steps/dispatch/implementPrompt.js.map +1 -0
  135. package/dist/remediate/steps/dispatch/marshal.d.ts +32 -0
  136. package/dist/remediate/steps/dispatch/marshal.d.ts.map +1 -0
  137. package/dist/remediate/steps/dispatch/marshal.js +935 -0
  138. package/dist/remediate/steps/dispatch/marshal.js.map +1 -0
  139. package/dist/remediate/steps/dispatch/verifyCommands.d.ts +97 -0
  140. package/dist/remediate/steps/dispatch/verifyCommands.d.ts.map +1 -0
  141. package/dist/remediate/steps/dispatch/verifyCommands.js +204 -0
  142. package/dist/remediate/steps/dispatch/verifyCommands.js.map +1 -0
  143. package/dist/remediate/steps/dispatch/waveScheduling.d.ts +90 -0
  144. package/dist/remediate/steps/dispatch/waveScheduling.d.ts.map +1 -0
  145. package/dist/remediate/steps/dispatch/waveScheduling.js +352 -0
  146. package/dist/remediate/steps/dispatch/waveScheduling.js.map +1 -0
  147. package/dist/remediate/steps/dispatch/worktreeLifecycle.d.ts +189 -0
  148. package/dist/remediate/steps/dispatch/worktreeLifecycle.d.ts.map +1 -0
  149. package/dist/remediate/steps/dispatch/worktreeLifecycle.js +643 -0
  150. package/dist/remediate/steps/dispatch/worktreeLifecycle.js.map +1 -0
  151. package/dist/remediate/steps/dispatch/writeScope.d.ts +151 -0
  152. package/dist/remediate/steps/dispatch/writeScope.d.ts.map +1 -0
  153. package/dist/remediate/steps/dispatch/writeScope.js +376 -0
  154. package/dist/remediate/steps/dispatch/writeScope.js.map +1 -0
  155. package/dist/remediate/steps/dispatch.d.ts +16 -871
  156. package/dist/remediate/steps/dispatch.d.ts.map +1 -1
  157. package/dist/remediate/steps/dispatch.js +18 -3623
  158. package/dist/remediate/steps/dispatch.js.map +1 -1
  159. package/dist/shared/decompose/charterClarification.d.ts +80 -0
  160. package/dist/shared/decompose/charterClarification.d.ts.map +1 -0
  161. package/dist/shared/decompose/charterClarification.js +105 -0
  162. package/dist/shared/decompose/charterClarification.js.map +1 -0
  163. package/dist/shared/decompose/systemicChallenge.d.ts +326 -0
  164. package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -0
  165. package/dist/shared/decompose/systemicChallenge.js +30 -0
  166. package/dist/shared/decompose/systemicChallenge.js.map +1 -0
  167. package/dist/shared/index.d.ts +10 -5
  168. package/dist/shared/index.d.ts.map +1 -1
  169. package/dist/shared/index.js +6 -4
  170. package/dist/shared/index.js.map +1 -1
  171. package/dist/shared/opencodePermissions.d.ts +73 -0
  172. package/dist/shared/opencodePermissions.d.ts.map +1 -1
  173. package/dist/shared/opencodePermissions.js +172 -0
  174. package/dist/shared/opencodePermissions.js.map +1 -1
  175. package/dist/shared/tooling/exec.d.ts +10 -1
  176. package/dist/shared/tooling/exec.d.ts.map +1 -1
  177. package/dist/shared/tooling/exec.js +13 -1
  178. package/dist/shared/tooling/exec.js.map +1 -1
  179. package/dist/shared/types/charter.d.ts +89 -0
  180. package/dist/shared/types/charter.d.ts.map +1 -1
  181. package/dist/shared/types/charter.js +68 -0
  182. package/dist/shared/types/charter.js.map +1 -1
  183. package/dist/shared/types/intentCheckpoint.d.ts +15 -0
  184. package/dist/shared/types/intentCheckpoint.d.ts.map +1 -1
  185. package/dist/shared/types/intentCheckpoint.js +11 -0
  186. package/dist/shared/types/intentCheckpoint.js.map +1 -1
  187. package/dist/shared/validation/charterGate.d.ts +20 -1
  188. package/dist/shared/validation/charterGate.d.ts.map +1 -1
  189. package/dist/shared/validation/charterGate.js +23 -0
  190. package/dist/shared/validation/charterGate.js.map +1 -1
  191. package/opencode.json +36 -20
  192. package/package.json +1 -1
  193. package/scripts/postinstall.mjs +2 -1
  194. package/wrapper/audit-code-wrapper-opencode.mjs +38 -12
  195. package/wrapper/remediate-code-wrapper-opencode.mjs +38 -12
@@ -0,0 +1,577 @@
1
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { join, relative, dirname } from "node:path";
3
+ import { toPromptPathToken, severityRank, mostCapableTier, findingLead, renderFindingBadgeBody, } from "audit-tools/shared";
4
+ import { findingNeedsVerificationBeforeFix } from "audit-tools/shared";
5
+ import { REMEDIATION_WORKER_RESULT_CONTRACT_VERSION, } from "../types.js";
6
+ import { classifyFindingRisk } from "../stepUtils.js";
7
+ import { isTerminalStatus } from "../../state/itemStatus.js";
8
+ import { runDir, uniquePaths } from "./common.js";
9
+ import { buildFreeVerifyCommands } from "./verifyCommands.js";
10
+ import { nodeFieldsOf, reconciliationExpectationsOf } from "./dagNodeFields.js";
11
+ const TEST_FILE_RE = /\.(test|spec)\.[cm]?[jt]sx?$/;
12
+ const WALK_SKIP_DIRS = new Set([
13
+ "node_modules", ".git", "dist", "build", "coverage", "out",
14
+ ".next", ".turbo", ".audit-tools",
15
+ ]);
16
+ /** Bounded recursive scan for test files under `root` (skips vendor/build dirs). */
17
+ function walkTestFiles(root, max = 400) {
18
+ const out = [];
19
+ const stack = [root];
20
+ let visited = 0;
21
+ while (stack.length > 0 && out.length < max) {
22
+ const dir = stack.pop();
23
+ let entries;
24
+ try {
25
+ entries = readdirSync(dir, { withFileTypes: true });
26
+ }
27
+ catch {
28
+ continue;
29
+ }
30
+ for (const entry of entries) {
31
+ if (++visited > 20000)
32
+ return out;
33
+ if (entry.isDirectory()) {
34
+ if (WALK_SKIP_DIRS.has(entry.name) || entry.name.startsWith(".test-"))
35
+ continue;
36
+ stack.push(join(dir, entry.name));
37
+ }
38
+ else if (TEST_FILE_RE.test(entry.name)) {
39
+ out.push(join(dir, entry.name));
40
+ if (out.length >= max)
41
+ break;
42
+ }
43
+ }
44
+ }
45
+ return out;
46
+ }
47
+ /**
48
+ * Walk the repo ONCE and read every test file's content (bounded). Built once per
49
+ * dispatch and shared across all blocks so the filesystem walk + reads are not
50
+ * repeated per block.
51
+ */
52
+ export function buildTestFileIndex(root) {
53
+ const index = [];
54
+ for (const testPath of walkTestFiles(root)) {
55
+ let content;
56
+ try {
57
+ content = readFileSync(testPath, "utf8");
58
+ }
59
+ catch {
60
+ continue;
61
+ }
62
+ index.push({ rel: relative(root, testPath).replace(/\\/g, "/"), content });
63
+ }
64
+ return index;
65
+ }
66
+ /**
67
+ * Collect test files from `index` that reference any of `sourceFiles` by
68
+ * module basename. When `packageRoot` is supplied (repo-relative prefix, e.g.
69
+ * `packages/foo`), only test files under that package are considered —
70
+ * otherwise all test files in the index are matched (existing behavior).
71
+ */
72
+ export function collectReferencingTests(index, sourceFiles, packageRoot) {
73
+ if (sourceFiles.length === 0 || index.length === 0)
74
+ return [];
75
+ const basenames = sourceFiles
76
+ .map((f) => (f.split(/[/\\]/).pop() ?? f).replace(/\.[cm]?[jt]sx?$/, ""))
77
+ .filter((b) => b.length > 1);
78
+ if (basenames.length === 0)
79
+ return [];
80
+ const needles = basenames.map((b) => new RegExp(`\\b${b.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`));
81
+ const sourceSet = new Set(sourceFiles.map((f) => f.replace(/\\/g, "/")));
82
+ // Normalize packageRoot to forward slashes and ensure it ends without trailing slash
83
+ const pkgPrefix = packageRoot
84
+ ? packageRoot.replace(/\\/g, "/").replace(/\/$/, "") + "/"
85
+ : null;
86
+ const result = [];
87
+ for (const { rel, content } of index) {
88
+ if (sourceSet.has(rel))
89
+ continue;
90
+ // If a package scope is set, skip files outside that package
91
+ if (pkgPrefix && !rel.startsWith(pkgPrefix))
92
+ continue;
93
+ if (needles.some((re) => re.test(content)))
94
+ result.push(rel);
95
+ }
96
+ return result;
97
+ }
98
+ /**
99
+ * Detect the nearest ancestor directory containing a `package.json` for the
100
+ * first source file in `sourceFiles` (walk up, stop at `root`). Returns the
101
+ * repo-relative path prefix (e.g. `packages/foo`) or undefined if none found.
102
+ */
103
+ function detectPackageRoot(sourceFiles, root) {
104
+ if (sourceFiles.length === 0)
105
+ return undefined;
106
+ const first = sourceFiles[0];
107
+ // Resolve to absolute path relative to root if not already absolute
108
+ const absFirst = first.startsWith("/") || /^[A-Za-z]:[/\\]/.test(first)
109
+ ? first
110
+ : join(root, first);
111
+ let dir = dirname(absFirst);
112
+ while (dir !== root && dir.length > root.length) {
113
+ if (existsSync(join(dir, "package.json"))) {
114
+ return relative(root, dir).replace(/\\/g, "/");
115
+ }
116
+ const parent = dirname(dir);
117
+ if (parent === dir)
118
+ break;
119
+ dir = parent;
120
+ }
121
+ return undefined;
122
+ }
123
+ export { detectPackageRoot };
124
+ /**
125
+ * The files an implement worker should receive as context for a finding:
126
+ * pre-document affected_files PLUS any files the document phase declared in the
127
+ * item_spec's `touched_files`.
128
+ */
129
+ function itemReadFiles(finding, spec) {
130
+ const files = finding.affected_files.map((f) => f.path);
131
+ if (spec?.touched_files)
132
+ files.push(...spec.touched_files);
133
+ return uniquePaths(files);
134
+ }
135
+ /**
136
+ * The files an implement worker is expected to write. The documented
137
+ * `touched_files` set is authoritative when present; affected_files are only a
138
+ * fallback for older or incomplete document results.
139
+ */
140
+ function itemWriteFiles(finding, spec) {
141
+ if (Array.isArray(spec?.touched_files)) {
142
+ return uniquePaths(spec.touched_files);
143
+ }
144
+ return uniquePaths(finding.affected_files.map((f) => f.path));
145
+ }
146
+ /**
147
+ * Repo-relative paths every finding in a block needs for context, deduped.
148
+ */
149
+ export function blockReadFiles(block, state) {
150
+ const files = block.items.flatMap((findingId) => {
151
+ const finding = state.plan?.findings.find((f) => f.id === findingId);
152
+ if (!finding)
153
+ return [];
154
+ return itemReadFiles(finding, state.items?.[findingId]?.item_spec);
155
+ });
156
+ return uniquePaths(files);
157
+ }
158
+ /**
159
+ * Repo-relative paths every finding in a block may write, deduped. This is kept
160
+ * narrower than read context so a broad affected hub file does not serialize
161
+ * blocks whose documented write sets are actually disjoint.
162
+ */
163
+ export function blockWriteFiles(block, state) {
164
+ const files = block.items.flatMap((findingId) => {
165
+ const finding = state.plan?.findings.find((f) => f.id === findingId);
166
+ if (!finding)
167
+ return [];
168
+ return itemWriteFiles(finding, state.items?.[findingId]?.item_spec);
169
+ });
170
+ return uniquePaths(files);
171
+ }
172
+ /**
173
+ * Construct the DispatchPlanItem for an implement task. Single source of truth
174
+ * so prepareImplementDispatch and mergeImplementResults stay in lockstep on item
175
+ * shape.
176
+ */
177
+ export function buildImplementDispatchItem(block, state, dir) {
178
+ const taskId = `implement-${block.block_id}`;
179
+ const readFiles = blockReadFiles(block, state);
180
+ const writeFiles = blockWriteFiles(block, state);
181
+ const resultPath = join(dir, `${taskId}.result.json`);
182
+ return {
183
+ task_id: taskId,
184
+ block_id: block.block_id,
185
+ prompt_path: join(dir, `${taskId}.md`),
186
+ result_path: resultPath,
187
+ model_hint: buildImplementModelHint(block, state),
188
+ access: {
189
+ read_paths: readFiles,
190
+ write_paths: [...writeFiles, resultPath],
191
+ },
192
+ };
193
+ }
194
+ /**
195
+ * Absolute path to a block's implement worker result file for a run. Single
196
+ * source (same convention as {@link buildImplementDispatchItem}'s `result_path`)
197
+ * shared with triage's already-satisfied reconciliation guard: a passing tree
198
+ * verify only proves a node's work was DONE if a worker actually ran and left a
199
+ * result — no result file ⇒ "no worker ran", not "verified satisfied".
200
+ */
201
+ export function implementResultPath(artifactsDir, runId, blockId) {
202
+ return join(runDir(artifactsDir, runId, "implement"), `implement-${blockId}.result.json`);
203
+ }
204
+ export function buildImplementModelHint(block, state) {
205
+ // Prefer the node's own promoted `model_tier` (derived from contract-pipeline
206
+ // complexity signals) over a re-derived block heuristic. In the contract
207
+ // pipeline a block maps 1:1 to a DAG node, so the block's single finding
208
+ // carries the authoritative relative rank. Never collapse to a flat
209
+ // "standard" when the node declared a tier.
210
+ const nodeTiers = block.items
211
+ .map((findingId) => {
212
+ const finding = state.plan?.findings.find((f) => f.id === findingId);
213
+ return finding ? nodeFieldsOf(finding).model_tier : undefined;
214
+ })
215
+ .filter((t) => t !== undefined);
216
+ if (nodeTiers.length > 0) {
217
+ // Take the most-capable declared rank across the block's nodes so a deep
218
+ // node is never under-provisioned by a sibling's smaller rank. Ordering is
219
+ // the single shared tier-rank authority (`mostCapableTier`).
220
+ const tier = mostCapableTier(nodeTiers) ?? "standard";
221
+ return { tier, reasons: ["node_model_tier"] };
222
+ }
223
+ const deepReasons = [];
224
+ let allSafe = true;
225
+ let maxSeverityRank = 0;
226
+ for (const findingId of block.items) {
227
+ const item = state.items?.[findingId];
228
+ const finding = state.plan?.findings.find((f) => f.id === findingId);
229
+ if (!finding)
230
+ continue;
231
+ const rank = severityRank(finding.severity);
232
+ if (rank > maxSeverityRank)
233
+ maxSeverityRank = rank;
234
+ if (item?.item_spec) {
235
+ const { tier } = classifyFindingRisk(finding, item.item_spec);
236
+ if (tier === "context_dependent") {
237
+ deepReasons.push(`context_dependent_${findingId}`);
238
+ }
239
+ if (tier !== "safe") {
240
+ allSafe = false;
241
+ }
242
+ }
243
+ else {
244
+ allSafe = false;
245
+ }
246
+ }
247
+ if (maxSeverityRank >= 5) {
248
+ deepReasons.push("critical_severity");
249
+ }
250
+ if (block.items.length >= 5) {
251
+ deepReasons.push("large_block");
252
+ }
253
+ if (deepReasons.length > 0) {
254
+ return { tier: "deep", reasons: deepReasons };
255
+ }
256
+ if (allSafe && block.items.length === 1 && maxSeverityRank <= 2) {
257
+ return { tier: "small", reasons: ["all_safe_single_finding"] };
258
+ }
259
+ return { tier: "standard", reasons: ["default_implement_block"] };
260
+ }
261
+ /**
262
+ * G1 + INV-GND-02: a finding that the auditor's grounding pass marked ungrounded
263
+ * — or that carries NO grounding verdict (undefined → treated as ungrounded) —
264
+ * has not been positively re-verified against the cited code. Instruct the
265
+ * worker to VERIFY the claim against the source first and only then fix it (or
266
+ * resolve_no_change if the claim does not hold), rather than blindly applying a
267
+ * fix to a possibly-stale/hallucinated finding. A positively-grounded finding
268
+ * adds no bullet (it was already re-verified at ingest).
269
+ */
270
+ function groundingVerificationBullet(finding) {
271
+ if (!findingNeedsVerificationBeforeFix(finding))
272
+ return "";
273
+ const reason = finding.grounding?.reason
274
+ ? ` (${finding.grounding.reason})`
275
+ : " (no grounding verdict was recorded for this finding)";
276
+ return `- VERIFY BEFORE FIX: this finding is not positively grounded${reason}. Confirm the claim against the cited code first; if it holds, fix it, otherwise mark the item \`resolved_no_change\` with evidence. Do not apply a fix to an unverified claim.`;
277
+ }
278
+ /**
279
+ * Opt-in meta-audit reflection invitation (parity with audit-code's worker
280
+ * prompt). Rendered after the file-access section because it carves out one
281
+ * extra append-only path. Shape: the shared `AgentReflectionSchema`;
282
+ * the close phase aggregates the file into the report's "Process Feedback"
283
+ * section. Best-effort by design — it must never compete with the obligation.
284
+ */
285
+ function reflectionInvitation(feedbackDisplay, taskId, lens) {
286
+ return `
287
+ ## Optional process feedback
288
+
289
+ Never let this delay or replace the required output above: if you hit task
290
+ ambiguity, tool friction, or unclear instructions, you MAY append one JSON
291
+ reflection line to \`${feedbackDisplay}\` with shape:
292
+ {"task_id": "${taskId}"${lens ? `, "lens": "${lens}"` : ""}, "instruction_clarity": "clear|mostly_clear|ambiguous|unclear",
293
+ "ambiguities": ["..."], "tool_friction": ["..."], "suggestions": ["..."],
294
+ "severity": "info|low|medium|high"}
295
+ One object per line; never overwrite existing lines. Appending to this file is
296
+ allowed in addition to the file access above.
297
+ `;
298
+ }
299
+ // ---------------------------------------------------------------------------
300
+ // Infra-modifying block detection
301
+ // ---------------------------------------------------------------------------
302
+ /**
303
+ * The live dispatch/orchestration modules whose modification can break the
304
+ * running engine mid-run. Derived from the REAL post-A12 source layout
305
+ * (`src/remediate/...`) — this module IS one of them (`steps/dispatch.ts`), so
306
+ * the list is anchored to the actual files on disk, not a hand-typed monorepo
307
+ * path that drifts when the tree is reorganised (the pre-A12
308
+ * `packages/remediate-code/...` list silently matched NOTHING after the
309
+ * collapse, so every infra block rendered as non-infra). Each entry is the
310
+ * module's path relative to the `src/remediate` area, forward-slash form.
311
+ */
312
+ const INFRA_MODULE_SUBPATHS = [
313
+ "steps/nextStep.ts",
314
+ "steps/dispatch.ts",
315
+ "state/store.ts",
316
+ "steps/contractPipeline.ts",
317
+ "steps/stepWriter.ts",
318
+ ];
319
+ /**
320
+ * The infra module sub-paths anchored under `src/remediate/` — the canonical
321
+ * repo-relative form for the current (post-A12) single-package layout. A write
322
+ * path matches when its normalised (forward-slash) form ends with one of these
323
+ * segments, so an absolute worktree path
324
+ * (`.../worktrees/foo/src/remediate/steps/dispatch.ts`), a repo-relative path
325
+ * (`src/remediate/steps/dispatch.ts`), or a Windows backslash path all match,
326
+ * while a same-basename file in another area (`src/audit/steps/dispatch.ts`)
327
+ * does not.
328
+ */
329
+ const INFRA_FILE_SEGMENTS = INFRA_MODULE_SUBPATHS.map((sub) => `src/remediate/${sub}`);
330
+ /**
331
+ * Returns true when any path in `writePaths` is one of the live infra modules.
332
+ * Paths are normalised to forward-slash form (win32 backslash → `/`) and matched
333
+ * by trailing repo-relative segment so absolute/worktree/relative spellings all
334
+ * resolve identically. Used to gate the live-surface verification section in the
335
+ * implement prompt.
336
+ */
337
+ export function isInfraModifyingBlock(writePaths) {
338
+ for (const p of writePaths) {
339
+ const normalized = p.replace(/\\/g, "/");
340
+ for (const segment of INFRA_FILE_SEGMENTS) {
341
+ if (normalized === segment || normalized.endsWith("/" + segment)) {
342
+ return true;
343
+ }
344
+ }
345
+ }
346
+ return false;
347
+ }
348
+ function infraModifyingSection(repoRoot) {
349
+ const rootDisplay = toPromptPathToken(repoRoot);
350
+ return `
351
+ ## Infra-modifying block
352
+
353
+ This block modifies the dispatch/orchestration engine that the current run
354
+ executes. **The host builds the package centrally — do NOT run \`npm run build\`
355
+ or \`npm test\` here** (a worker-side build races the central build's \`dist/\`).
356
+ Verify build-free only and let the host re-exercise the live surface after its
357
+ central build:
358
+
359
+ 1. **Type-check (no emit):** After completing all edits, run:
360
+ \`\`\`
361
+ npm run check
362
+ \`\`\`
363
+ from \`${rootDisplay}\`. If type-check fails, mark the item blocked and record
364
+ the failure in \`failure_reason\`.
365
+
366
+ 2. **Targeted build-free tests:** Run this package's build-free test runner
367
+ directly against the tests for your change — for remediate-code:
368
+ \`\`\`
369
+ npx vitest run <your-test-file>
370
+ \`\`\`
371
+ from \`${rootDisplay}\`. Never invoke \`npm test\`/\`npm run build\`: those
372
+ prepend a build. If a targeted test fails, mark the item blocked and record
373
+ the failure in \`failure_reason\`.
374
+
375
+ 3. **Rollback is the host's job.** Because you do not build or republish the
376
+ engine, you cannot brick the live dispatcher mid-run. The host owns the
377
+ central build and any dist rollback; record the files you changed in your
378
+ result evidence so the host can attribute a post-build failure.
379
+ `;
380
+ }
381
+ /**
382
+ * Per-item bullets threading what upstream/neighbor nodes agreed to provide
383
+ * (INV-DS-12): the node's reconciliation_expectations / preconditions and its
384
+ * expected_changes. Rendered inside each item so a dependent node implements
385
+ * against the realized upstream surface rather than guessing.
386
+ */
387
+ function upstreamExpectationsBullets(finding) {
388
+ const node = nodeFieldsOf(finding);
389
+ const expectations = reconciliationExpectationsOf(finding);
390
+ const lines = [];
391
+ if (expectations.length > 0) {
392
+ lines.push(`- Upstream/neighbor contract provides (implement against these, do not redefine them): ${expectations.join("; ")}`);
393
+ }
394
+ if (typeof node.expected_changes === "string" && node.expected_changes.trim().length > 0) {
395
+ lines.push(`- Expected changes: ${node.expected_changes.trim()}`);
396
+ }
397
+ if (Array.isArray(node.verification) && node.verification.length > 0) {
398
+ lines.push(`- Verification checks: ${node.verification.join("; ")}`);
399
+ }
400
+ return lines.join("\n");
401
+ }
402
+ /**
403
+ * The build-free per-node verification section. Emits the node's own build-free
404
+ * targeted commands (build/build-prepending commands filtered out — residual
405
+ * CE-001) plus the standard build-free baseline (`npm run check` + the package's
406
+ * build-free test runner). NON-EMITTING: it instructs the worker to run these to
407
+ * gate its own result, never to emit further dispatch.
408
+ */
409
+ function perNodeVerificationSection(block, state, rootDisplay) {
410
+ const nodeCommands = uniquePaths(block.items.flatMap((findingId) => {
411
+ const finding = state.plan?.findings.find((f) => f.id === findingId);
412
+ return finding ? buildFreeVerifyCommands(finding.targeted_commands) : [];
413
+ }));
414
+ const commandBlock = nodeCommands.length > 0
415
+ ? `Run these node-targeted, build-free commands and record each command + result in the affected item's evidence:
416
+ \`\`\`
417
+ ${nodeCommands.join("\n")}
418
+ \`\`\`
419
+ `
420
+ : "";
421
+ return `
422
+ ## Per-node verification (build-free)
423
+
424
+ The host builds the package centrally; do NOT run \`npm run build\` or \`npm test\`
425
+ (either races the central build's \`dist/\`). Verify build-free only, from
426
+ \`${rootDisplay}\`:
427
+
428
+ - Type-check with \`npm run check\` (no emit).
429
+ - Run the package's build-free test runner directly against your change
430
+ (remediate-code: \`npx vitest run <your-test-file>\`; node-test packages:
431
+ \`node --import tsx/esm --test <your-test-file>\`).
432
+
433
+ ${commandBlock}A node is verified-complete only when its declared outputs exist and these
434
+ build-free checks pass; otherwise mark the item blocked with the failure in
435
+ \`failure_reason\`.
436
+ `;
437
+ }
438
+ export function implementPrompt(block, state, resultPath, conventions, repoRoot, feedbackDisplay, worktreeRoot) {
439
+ const items = block.items.flatMap((findingId) => {
440
+ const item = state.items?.[findingId];
441
+ const finding = state.plan?.findings.find((entry) => entry.id === findingId);
442
+ if (!finding)
443
+ return [];
444
+ // Only render items that still need implementing — never a resolved item
445
+ // from a prior wave or one the user skipped (deemed_inappropriate/ignored).
446
+ if (!item || isTerminalStatus(item.status))
447
+ return [];
448
+ if (item.status !== "pending")
449
+ return [];
450
+ // item_spec may be pre-populated from the plan DAG node or absent;
451
+ // either way the implementer receives finding context directly.
452
+ // clarification_context carries the user's answer when this item was re-opened
453
+ // from a clarification round (up-front gate or mid-run) — thread it through so
454
+ // the retry acts on the decided scope, not the original ambiguity.
455
+ return [{ finding, spec: item.item_spec, clarification: item.clarification_context }];
456
+ });
457
+ // When a worktreeRoot is supplied, the worker operates in the worktree, not
458
+ // the main repo root. Source file paths are prefixed with the worktree root.
459
+ // The result path always lives in the artifacts dir (outside the worktree).
460
+ const effectiveRoot = worktreeRoot ?? repoRoot;
461
+ // Normalize to forward slashes for host-facing prompt text; bash-like shells
462
+ // on Windows treat backslashes as escape characters.
463
+ const rootDisplay = toPromptPathToken(effectiveRoot);
464
+ const resultDisplay = toPromptPathToken(resultPath);
465
+ // Prefix each source file path with the worktree root when applicable.
466
+ function resolveFilePath(rel) {
467
+ if (!worktreeRoot)
468
+ return rel;
469
+ if (rel.startsWith("/") || /^[A-Za-z]:[/\\]/.test(rel))
470
+ return rel;
471
+ return toPromptPathToken(join(worktreeRoot, rel));
472
+ }
473
+ const worktreeNote = worktreeRoot
474
+ ? `\nYou are working in a worktree at ${toPromptPathToken(worktreeRoot)}; all file edits go here. Do not edit files outside this worktree.\n`
475
+ : "";
476
+ return `
477
+ # Implement Remediation Block
478
+
479
+ You are implementing one bounded remediation block. Edit the files needed for the
480
+ findings in this prompt, and you MAY create new files (e.g. a test file or an
481
+ extracted module) within the SAME package as those files when a finding's change
482
+ calls for it. Do not edit unrelated files in other packages, and do not change
483
+ remediation state files directly.
484
+ Repository root: ${rootDisplay}
485
+ Set the shell/tool workdir to the repository root when running commands; do not rely on cwd state from prior shell calls.
486
+
487
+ ## Block
488
+
489
+ - Block ID: ${block.block_id}
490
+ - Findings: ${items.map(({ finding }) => finding.id).join(", ")}
491
+
492
+ ## Items
493
+
494
+ ${items
495
+ .map(({ finding, spec, clarification }) => `
496
+ ### ${finding.id} — ${finding.title}
497
+
498
+ ${findingLead(finding.summary)}
499
+
500
+ ${renderFindingBadgeBody(finding, { showGrounding: false, showAdvisoryMeta: false, showFiles: false, showDetails: false, showEvidence: false }).join("\n")}
501
+ - Files: ${itemReadFiles(finding, spec).map(resolveFilePath).join(", ")}
502
+ - Details: ${finding.summary}
503
+ ${clarification ? `- Clarified scope (decided with the user — act on THIS): ${clarification}\n` : ""}${groundingVerificationBullet(finding)}
504
+ ${spec ? `- Concrete change: ${spec.concrete_change}
505
+ - Tests to write: ${spec.tests_to_write
506
+ .map((test) => `${test.name}: ${test.assertions.join("; ")}`)
507
+ .join(" | ")}` : ""}
508
+ ${upstreamExpectationsBullets(finding)}
509
+ `)
510
+ .join("\n")}
511
+ ${conventions ? `\n${conventions}\n` : ""}${perNodeVerificationSection(block, state, rootDisplay)}${isInfraModifyingBlock(blockWriteFiles(block, state)) ? infraModifyingSection(repoRoot) : ""}
512
+ ## Verification
513
+ ${worktreeNote}
514
+ Run changed or newly created tests by name when possible, and record the focused
515
+ command and result in the affected item's evidence. If a broad or full-suite
516
+ command fails in a dirty worktree and appears unrelated or pre-existing, record
517
+ that broad failure separately instead of using it as the only verdict for this
518
+ block. If a focused test for this block fails, the affected item remains blocked.
519
+ If targeted commands are listed under an item, run them when applicable and
520
+ include each command and result in that item's evidence.
521
+
522
+ Windows PowerShell: do not pipe an inline foreach statement directly into ConvertTo-Json.
523
+ Assign the foreach output to a variable first, then pipe that variable to ConvertTo-Json.
524
+
525
+ ## Output
526
+
527
+ After editing and verifying the block, write JSON to exactly:
528
+
529
+ \`${resultDisplay}\`
530
+
531
+ Emit **exactly one \`item_results\` entry per node id below — no more, no fewer**.
532
+ Each entry's \`finding_id\` MUST be one of the exact ids: ${items
533
+ .map(({ finding }) => `\`${finding.id}\``)
534
+ .join(", ")}. Do not substitute a title, an obligation id, or a block id for
535
+ the node id, and do not emit duplicate entries for the same node.
536
+
537
+ \`\`\`json
538
+ {
539
+ "contract_version": "${REMEDIATION_WORKER_RESULT_CONTRACT_VERSION}",
540
+ "phase": "implement",
541
+ "item_results": [
542
+ ${items
543
+ .map(({ finding }) => ` {
544
+ "finding_id": "${finding.id}",
545
+ "status": "resolved",
546
+ "evidence": ["test or verification evidence"]
547
+ }`)
548
+ .join(",\n")}
549
+ ]
550
+ }
551
+ \`\`\`
552
+
553
+ For an item you cannot safely finish because of an EXECUTION failure (a test
554
+ won't pass, a build breaks, the change is infeasible), set \`status\` to
555
+ \`blocked\` and include \`failure_reason\`. If instead you are stuck on a SCOPING
556
+ or JUDGMENT question — how far the fix should reach, which of several valid
557
+ behaviors is intended, or whether the issue is real — do NOT guess and do NOT
558
+ block: set \`status\` to \`needs_clarification\` and put the question in
559
+ \`clarification_question\` (optionally \`clarification_category\`). It is routed to
560
+ the user as a real question, then re-dispatched with the answer. Stop after
561
+ writing the result JSON.
562
+
563
+ ## File access
564
+
565
+ Read: ${uniquePaths(items.flatMap(({ finding, spec }) => itemReadFiles(finding, spec))).join(", ")}
566
+ Write: ${uniquePaths(items.flatMap(({ finding, spec }) => itemWriteFiles(finding, spec))).join(", ")}
567
+ You may also create new files within the same package as those files (e.g. tests
568
+ or extracted modules) when a finding requires it.
569
+ If your change renames, moves, or removes a symbol, also update the existing test
570
+ files that reference it — fixing tests for a changed surface is part of this
571
+ block, not a later cleanup. Test files that reference these files are included in
572
+ your write access.
573
+ Write result: ${resultDisplay}
574
+ Do not modify unrelated files outside these paths or files in other packages.
575
+ ${reflectionInvitation(feedbackDisplay, block.block_id)}`;
576
+ }
577
+ //# sourceMappingURL=implementPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementPrompt.js","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/implementPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EACL,0CAA0C,GAG3C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,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OAAO,CAAC,EAAE;;;MAG3B,CACD;SACA,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;QAiBR,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SACzF,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;gBAOpF,aAAa;;EAE3B,oBAAoB,CAAC,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type RemediationState } from "../../state/store.js";
2
+ import type { SessionConfig, HostModelRosterEntry } from "audit-tools/shared";
3
+ import { type RemediationDispatchPlan } from "../types.js";
4
+ import { DispatchOptions } from "./common.js";
5
+ export type { DispatchOptions } from "./common.js";
6
+ export declare function prepareImplementDispatch(options: DispatchOptions, runId: string, onlyBlockId?: string, waveOptions?: {
7
+ hostMaxConcurrent?: number;
8
+ sessionConfig?: SessionConfig | null;
9
+ hostContextTokens?: number | null;
10
+ hostOutputTokens?: number | null;
11
+ hostModels?: HostModelRosterEntry[] | null;
12
+ hostModelId?: string | null;
13
+ /**
14
+ * Root each node's prompt at its isolated worktree (the deterministic
15
+ * `worktreePath(root, block_id, runId)`) rather than the main checkout. Set by
16
+ * the rolling engine (`driveRollingImplementDispatch`) so a worker told its
17
+ * repository root is the worktree edits there, not the shared main tree.
18
+ */
19
+ worktreeRootedPrompts?: boolean;
20
+ /**
21
+ * Lease the granted admitted set against the shared reservation ledger. The
22
+ * host-subagent rolling path leaves this unset (defaults true — it dispatches the
23
+ * grant across processes and reconciles at accept-node); the in-process rolling
24
+ * engine passes `false` (it admits + leases per-packet itself, so a host grant
25
+ * here would double-count). Threaded into `buildDispatchQuota`.
26
+ */
27
+ grantLeases?: boolean;
28
+ }): Promise<RemediationDispatchPlan>;
29
+ export declare function mergeImplementResults(options: DispatchOptions, runId: string): Promise<RemediationState>;
30
+ export declare function readExtractedPlanIfPresent(artifactsDir: string): Promise<unknown | undefined>;
31
+ export declare function readDispatchPlan(artifactsDir: string, runId: string, phase: "implement"): Promise<RemediationDispatchPlan>;
32
+ //# sourceMappingURL=marshal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/marshal.ts"],"names":[],"mappings":"AAQA,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMzE,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc9E,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,aAAa,CAAC;AAYrB,OAAO,EACL,eAAe,EAUhB,MAAM,aAAa,CAAC;AAyBrB,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkInD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;OAMG;IAC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