auditor-lambda 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +0 -21
  2. package/audit-code-wrapper-lib.mjs +149 -129
  3. package/dist/adapters/normalizeExternal.js +6 -3
  4. package/dist/cli/args.d.ts +0 -1
  5. package/dist/cli/args.js +0 -6
  6. package/dist/cli/auditStep.js +7 -1
  7. package/dist/cli/dispatch.js +3 -2
  8. package/dist/cli/lineIndex.js +4 -1
  9. package/dist/cli/mergeAndIngestCommand.d.ts +1 -0
  10. package/dist/cli/mergeAndIngestCommand.js +219 -0
  11. package/dist/cli/nextStepCommand.js +5 -1
  12. package/dist/cli/runToCompletion.d.ts +9 -0
  13. package/dist/cli/runToCompletion.js +655 -480
  14. package/dist/cli/statusCommand.d.ts +1 -0
  15. package/dist/cli/statusCommand.js +113 -0
  16. package/dist/cli/submitPacketCommand.d.ts +1 -0
  17. package/dist/cli/submitPacketCommand.js +155 -0
  18. package/dist/cli/workerResult.d.ts +1 -1
  19. package/dist/cli/workerRunCommand.d.ts +1 -0
  20. package/dist/cli/workerRunCommand.js +88 -0
  21. package/dist/cli.d.ts +0 -1
  22. package/dist/cli.js +14 -565
  23. package/dist/extractors/analyzers/sql.js +4 -1
  24. package/dist/extractors/analyzers/treeSitter.js +29 -15
  25. package/dist/extractors/analyzers/typescript.js +10 -8
  26. package/dist/extractors/designAssessment.js +43 -24
  27. package/dist/extractors/graph.js +151 -75
  28. package/dist/extractors/pathPatterns.js +17 -5
  29. package/dist/io/artifacts.d.ts +3 -1
  30. package/dist/io/artifacts.js +18 -2
  31. package/dist/io/runArtifactTypes.d.ts +18 -0
  32. package/dist/io/runArtifactTypes.js +1 -0
  33. package/dist/io/runArtifacts.d.ts +2 -18
  34. package/dist/io/runArtifacts.js +14 -3
  35. package/dist/mcp/server.js +9 -0
  36. package/dist/orchestrator/advance.js +38 -22
  37. package/dist/orchestrator/artifactFreshness.js +14 -4
  38. package/dist/orchestrator/autoFixExecutor.d.ts +2 -2
  39. package/dist/orchestrator/autoFixExecutor.js +26 -8
  40. package/dist/orchestrator/dependencyMap.d.ts +1 -1
  41. package/dist/orchestrator/dependencyMap.js +7 -1
  42. package/dist/orchestrator/executorResult.d.ts +12 -0
  43. package/dist/orchestrator/executorResult.js +1 -0
  44. package/dist/orchestrator/fileAnchors.js +14 -3
  45. package/dist/orchestrator/fileIntegrity.d.ts +1 -0
  46. package/dist/orchestrator/fileIntegrity.js +12 -3
  47. package/dist/orchestrator/flowCoverage.js +1 -0
  48. package/dist/orchestrator/flowRequeue.js +4 -1
  49. package/dist/orchestrator/graphEnrichmentExecutor.d.ts +1 -1
  50. package/dist/orchestrator/graphEnrichmentExecutor.js +3 -1
  51. package/dist/orchestrator/ingestionExecutors.d.ts +11 -0
  52. package/dist/orchestrator/ingestionExecutors.js +237 -0
  53. package/dist/orchestrator/intakeExecutors.d.ts +3 -0
  54. package/dist/orchestrator/intakeExecutors.js +25 -0
  55. package/dist/orchestrator/planningExecutors.d.ts +4 -0
  56. package/dist/orchestrator/planningExecutors.js +95 -0
  57. package/dist/orchestrator/reviewPacketGraph.d.ts +31 -0
  58. package/dist/orchestrator/reviewPacketGraph.js +691 -0
  59. package/dist/orchestrator/reviewPackets.d.ts +2 -15
  60. package/dist/orchestrator/reviewPackets.js +3 -685
  61. package/dist/orchestrator/runtimeCommand.d.ts +11 -0
  62. package/dist/orchestrator/runtimeCommand.js +71 -0
  63. package/dist/orchestrator/scope.js +1 -1
  64. package/dist/orchestrator/selectiveDeepening/conflict.d.ts +8 -0
  65. package/dist/orchestrator/selectiveDeepening/conflict.js +71 -0
  66. package/dist/orchestrator/selectiveDeepening/findingFollowup.d.ts +10 -0
  67. package/dist/orchestrator/selectiveDeepening/findingFollowup.js +52 -0
  68. package/dist/orchestrator/selectiveDeepening/highRiskClean.d.ts +7 -0
  69. package/dist/orchestrator/selectiveDeepening/highRiskClean.js +44 -0
  70. package/dist/orchestrator/selectiveDeepening/index.d.ts +18 -0
  71. package/dist/orchestrator/selectiveDeepening/index.js +128 -0
  72. package/dist/orchestrator/selectiveDeepening/lensVerification.d.ts +12 -0
  73. package/dist/orchestrator/selectiveDeepening/lensVerification.js +242 -0
  74. package/dist/orchestrator/selectiveDeepening/runtimeValidation.d.ts +13 -0
  75. package/dist/orchestrator/selectiveDeepening/runtimeValidation.js +57 -0
  76. package/dist/orchestrator/selectiveDeepening/shared.d.ts +45 -0
  77. package/dist/orchestrator/selectiveDeepening/shared.js +128 -0
  78. package/dist/orchestrator/selectiveDeepening/stewardFollowup.d.ts +6 -0
  79. package/dist/orchestrator/selectiveDeepening/stewardFollowup.js +72 -0
  80. package/dist/orchestrator/selectiveDeepening.d.ts +2 -20
  81. package/dist/orchestrator/selectiveDeepening.js +6 -760
  82. package/dist/orchestrator/staleness.js +3 -3
  83. package/dist/orchestrator/structureExecutors.d.ts +5 -0
  84. package/dist/orchestrator/structureExecutors.js +94 -0
  85. package/dist/orchestrator/syntaxResolutionExecutor.d.ts +1 -1
  86. package/dist/orchestrator/synthesisExecutors.d.ts +12 -0
  87. package/dist/orchestrator/synthesisExecutors.js +90 -0
  88. package/dist/orchestrator/taskBuilder.d.ts +2 -2
  89. package/dist/orchestrator/taskBuilder.js +101 -82
  90. package/dist/providers/index.d.ts +7 -0
  91. package/dist/providers/index.js +14 -95
  92. package/dist/quota/discoveredLimits.d.ts +1 -0
  93. package/dist/quota/discoveredLimits.js +7 -1
  94. package/dist/quota/index.d.ts +0 -2
  95. package/dist/quota/index.js +1 -2
  96. package/dist/reporting/workBlocks.js +7 -4
  97. package/dist/types/reviewPlanning.d.ts +23 -16
  98. package/dist/validation/auditResults.js +97 -95
  99. package/dist/validation/sessionConfig.d.ts +2 -2
  100. package/dist/validation/sessionConfig.js +14 -7
  101. package/docs/development.md +35 -139
  102. package/docs/history.md +26 -0
  103. package/docs/product.md +41 -108
  104. package/package.json +3 -2
  105. package/schemas/audit_findings.schema.json +6 -5
  106. package/schemas/critical_flows.schema.json +3 -2
  107. package/schemas/dispatch_quota.schema.json +3 -1
  108. package/schemas/external_analyzer_results.schema.json +2 -2
  109. package/schemas/graph_bundle.schema.json +1 -1
  110. package/schemas/repo_manifest.schema.json +1 -1
  111. package/schemas/review_packets.schema.json +1 -1
  112. package/schemas/step_contract.schema.json +80 -0
  113. package/scripts/postinstall.mjs +19 -2
  114. package/skills/audit-code/opencode-command-template.txt +3 -3
  115. package/dist/orchestrator/internalExecutors.d.ts +0 -34
  116. package/dist/orchestrator/internalExecutors.js +0 -581
  117. package/dist/providers/localSubprocessProvider.d.ts +0 -9
  118. package/dist/providers/localSubprocessProvider.js +0 -18
  119. package/dist/providers/subprocessTemplateProvider.d.ts +0 -8
  120. package/dist/providers/subprocessTemplateProvider.js +0 -59
  121. package/dist/providers/vscodeTaskProvider.d.ts +0 -7
  122. package/dist/providers/vscodeTaskProvider.js +0 -14
  123. package/dist/quota/probe.d.ts +0 -10
  124. package/dist/quota/probe.js +0 -18
  125. package/docs/handoff.md +0 -204
@@ -0,0 +1,237 @@
1
+ import { runCommand } from "./runtimeCommand.js";
2
+ import { buildFlowCoverage } from "./flowCoverage.js";
3
+ import { buildRequeuePayload } from "./requeueCommand.js";
4
+ import { buildRuntimeValidationTasks, mergeRuntimeValidationReport, } from "./runtimeValidation.js";
5
+ import { ingestAuditResults, updateAuditTaskStatuses, } from "./resultIngestion.js";
6
+ import { buildAuditPlanMetrics, buildReviewPackets, sizeIndexFromManifest, } from "./reviewPackets.js";
7
+ import { updateRuntimeValidationReport } from "./runtimeValidationUpdate.js";
8
+ import { buildSelectiveDeepeningTasks } from "./selectiveDeepening.js";
9
+ function lineIndexFromTasks(tasks) {
10
+ return Object.fromEntries((tasks ?? []).flatMap((task) => Object.entries(task.file_line_counts ?? {})));
11
+ }
12
+ function appendSelectiveDeepeningTasks(params) {
13
+ if (!params.bundle.audit_tasks) {
14
+ return { bundle: params.bundle, taskCount: 0, artifacts: [] };
15
+ }
16
+ const lineIndex = lineIndexFromTasks(params.bundle.audit_tasks);
17
+ const sizeIndex = sizeIndexFromManifest(params.bundle.repo_manifest);
18
+ const selectiveDeepeningTasks = buildSelectiveDeepeningTasks({
19
+ existingTasks: params.bundle.audit_tasks,
20
+ results: params.results,
21
+ lineIndex,
22
+ runtimeValidationTasks: params.bundle.runtime_validation_tasks,
23
+ runtimeValidationReport: params.runtimeValidationReport ?? params.bundle.runtime_validation_report,
24
+ externalAnalyzerResults: params.bundle.external_analyzer_results,
25
+ });
26
+ if (selectiveDeepeningTasks.length === 0) {
27
+ return { bundle: params.bundle, taskCount: 0, artifacts: [] };
28
+ }
29
+ const auditTasks = [...params.bundle.audit_tasks, ...selectiveDeepeningTasks];
30
+ return {
31
+ bundle: {
32
+ ...params.bundle,
33
+ audit_tasks: auditTasks,
34
+ audit_plan_metrics: buildAuditPlanMetrics(auditTasks, {
35
+ graphBundle: params.bundle.graph_bundle,
36
+ lineIndex,
37
+ sizeIndex,
38
+ }),
39
+ review_packets: buildReviewPackets(auditTasks, {
40
+ graphBundle: params.bundle.graph_bundle,
41
+ lineIndex,
42
+ sizeIndex,
43
+ }),
44
+ },
45
+ taskCount: selectiveDeepeningTasks.length,
46
+ artifacts: ["audit_tasks.json", "audit_plan_metrics.json", "review_packets.json"],
47
+ };
48
+ }
49
+ /**
50
+ * Apply selective deepening to an already-prepared base bundle and return the
51
+ * pieces every executor needs to assemble its `ExecutorRunResult`: the updated
52
+ * bundle, the deepening artifacts, and the progress-summary suffix.
53
+ *
54
+ * Centralizing this keeps the three executors that run deepening consistent —
55
+ * previously each site invoked `appendSelectiveDeepeningTasks` and then
56
+ * re-derived the same `Added N selective deepening task(s)` suffix by hand.
57
+ * `excludeArtifacts` lets a caller that already lists an artifact explicitly
58
+ * (the result-ingestion executor lists `audit_tasks.json`) drop it from the
59
+ * spread so it is never double-counted.
60
+ */
61
+ function applySelectiveDeepening(params) {
62
+ const selectiveDeepening = appendSelectiveDeepeningTasks({
63
+ bundle: params.baseBundle,
64
+ results: params.results,
65
+ runtimeValidationReport: params.runtimeValidationReport,
66
+ });
67
+ const exclude = new Set(params.excludeArtifacts ?? []);
68
+ return {
69
+ bundle: selectiveDeepening.bundle,
70
+ artifacts: selectiveDeepening.artifacts.filter((artifact) => !exclude.has(artifact)),
71
+ summarySuffix: selectiveDeepening.taskCount > 0
72
+ ? ` Added ${selectiveDeepening.taskCount} selective deepening task(s).`
73
+ : "",
74
+ };
75
+ }
76
+ export function runResultIngestionExecutor(bundle, results) {
77
+ if (!bundle.coverage_matrix) {
78
+ throw new Error("Cannot ingest results without coverage_matrix");
79
+ }
80
+ const updatedCoverageMatrix = ingestAuditResults(bundle.coverage_matrix, results);
81
+ const flowCoverage = bundle.critical_flows
82
+ ? buildFlowCoverage(bundle.critical_flows, updatedCoverageMatrix)
83
+ : bundle.flow_coverage;
84
+ const runtimeCommand = bundle.runtime_validation_tasks?.tasks.find((task) => task.command && task.command.length > 0)?.command;
85
+ const runtimeValidationTasks = bundle.unit_manifest && flowCoverage
86
+ ? buildRuntimeValidationTasks({
87
+ unitManifest: bundle.unit_manifest,
88
+ criticalFlows: bundle.critical_flows,
89
+ flowCoverage,
90
+ command: runtimeCommand,
91
+ })
92
+ : bundle.runtime_validation_tasks;
93
+ const runtimeValidationReport = runtimeValidationTasks
94
+ ? mergeRuntimeValidationReport(runtimeValidationTasks, bundle.runtime_validation_report)
95
+ : bundle.runtime_validation_report;
96
+ const mergedResults = [...(bundle.audit_results ?? []), ...results];
97
+ const completedAuditTasks = updateAuditTaskStatuses(bundle.audit_tasks, mergedResults);
98
+ const baseUpdatedBundle = {
99
+ ...bundle,
100
+ coverage_matrix: updatedCoverageMatrix,
101
+ flow_coverage: flowCoverage,
102
+ runtime_validation_tasks: runtimeValidationTasks,
103
+ runtime_validation_report: runtimeValidationReport,
104
+ audit_results: mergedResults,
105
+ audit_tasks: completedAuditTasks,
106
+ audit_report: undefined,
107
+ };
108
+ const selectiveDeepening = applySelectiveDeepening({
109
+ baseBundle: baseUpdatedBundle,
110
+ results: mergedResults,
111
+ runtimeValidationReport,
112
+ excludeArtifacts: ["audit_tasks.json"],
113
+ });
114
+ const requeuePayload = buildRequeuePayload(updatedCoverageMatrix, selectiveDeepening.bundle.critical_flows, selectiveDeepening.bundle.flow_coverage, selectiveDeepening.bundle.external_analyzer_results);
115
+ const finalBundle = {
116
+ ...selectiveDeepening.bundle,
117
+ requeue_tasks: requeuePayload.tasks,
118
+ };
119
+ return {
120
+ updated: finalBundle,
121
+ artifacts_written: [
122
+ "coverage_matrix.json",
123
+ "flow_coverage.json",
124
+ ...(runtimeValidationTasks ? ["runtime_validation_tasks.json"] : []),
125
+ ...(runtimeValidationReport ? ["runtime_validation_report.json"] : []),
126
+ "audit_results.jsonl",
127
+ "audit_tasks.json",
128
+ ...selectiveDeepening.artifacts,
129
+ "requeue_tasks.json",
130
+ ],
131
+ progress_summary: `Ingested ${results.length} audit result entries and refreshed dependent artifacts.` +
132
+ selectiveDeepening.summarySuffix,
133
+ };
134
+ }
135
+ export async function runRuntimeValidationExecutor(bundle, root, options = {}) {
136
+ if (!bundle.runtime_validation_tasks) {
137
+ throw new Error("Cannot execute runtime validation without runtime_validation_tasks");
138
+ }
139
+ const existing = bundle.runtime_validation_report ?? { results: [] };
140
+ const byTaskId = new Map(existing.results.map((result) => [result.task_id, result]));
141
+ const byCommand = new Map();
142
+ for (const task of bundle.runtime_validation_tasks.tasks) {
143
+ const prior = byTaskId.get(task.id);
144
+ if (prior &&
145
+ ["confirmed", "not_confirmed", "inconclusive", "not_required"].includes(prior.status)) {
146
+ continue;
147
+ }
148
+ if (!task.command || task.command.length === 0) {
149
+ byTaskId.set(task.id, {
150
+ task_id: task.id,
151
+ status: "not_required",
152
+ summary: `No deterministic runtime command was available for ${task.id}.`,
153
+ evidence: [],
154
+ notes: ["Runtime validation was not planned for this task."],
155
+ });
156
+ continue;
157
+ }
158
+ const signature = task.command.join("\0");
159
+ const outcome = byCommand.get(signature) ?? (await runCommand(task.command, root, { opentoken: options.opentoken }));
160
+ byCommand.set(signature, outcome);
161
+ byTaskId.set(task.id, {
162
+ task_id: task.id,
163
+ status: outcome.status,
164
+ summary: outcome.summary,
165
+ evidence: outcome.evidence,
166
+ notes: [`Target paths: ${task.target_paths.join(", ")}`],
167
+ });
168
+ }
169
+ const runtimeValidationReport = {
170
+ results: [...byTaskId.values()].sort((a, b) => a.task_id.localeCompare(b.task_id)),
171
+ };
172
+ const baseUpdatedBundle = {
173
+ ...bundle,
174
+ runtime_validation_report: runtimeValidationReport,
175
+ audit_report: undefined,
176
+ };
177
+ const selectiveDeepening = applySelectiveDeepening({
178
+ baseBundle: baseUpdatedBundle,
179
+ results: bundle.audit_results ?? [],
180
+ runtimeValidationReport,
181
+ });
182
+ return {
183
+ updated: selectiveDeepening.bundle,
184
+ artifacts_written: [
185
+ "runtime_validation_report.json",
186
+ ...selectiveDeepening.artifacts,
187
+ ],
188
+ progress_summary: `Executed deterministic runtime validation for ${bundle.runtime_validation_tasks.tasks.length} task(s).` +
189
+ selectiveDeepening.summarySuffix,
190
+ };
191
+ }
192
+ export function runRuntimeValidationUpdateExecutor(bundle, updates) {
193
+ if (!bundle.runtime_validation_tasks) {
194
+ throw new Error("Cannot update runtime validation without runtime_validation_tasks");
195
+ }
196
+ const existingReport = bundle.runtime_validation_report ?? { results: [] };
197
+ const mergedReport = updateRuntimeValidationReport(bundle.runtime_validation_tasks, existingReport, updates);
198
+ const baseUpdatedBundle = {
199
+ ...bundle,
200
+ runtime_validation_report: mergedReport,
201
+ audit_report: undefined,
202
+ };
203
+ const selectiveDeepening = applySelectiveDeepening({
204
+ baseBundle: baseUpdatedBundle,
205
+ results: bundle.audit_results ?? [],
206
+ runtimeValidationReport: mergedReport,
207
+ });
208
+ return {
209
+ updated: selectiveDeepening.bundle,
210
+ artifacts_written: [
211
+ "runtime_validation_report.json",
212
+ ...selectiveDeepening.artifacts,
213
+ ],
214
+ progress_summary: `Merged ${updates.results.length} runtime validation updates.` +
215
+ selectiveDeepening.summarySuffix,
216
+ };
217
+ }
218
+ export function runExternalAnalyzerImportExecutor(bundle, externalResults) {
219
+ const summary = `Imported ${externalResults.results.length} normalized findings from ${externalResults.tool}.`;
220
+ return {
221
+ updated: {
222
+ ...bundle,
223
+ external_analyzer_results: externalResults,
224
+ coverage_matrix: undefined,
225
+ flow_coverage: undefined,
226
+ runtime_validation_tasks: undefined,
227
+ runtime_validation_report: undefined,
228
+ audit_tasks: undefined,
229
+ audit_plan_metrics: undefined,
230
+ review_packets: undefined,
231
+ requeue_tasks: undefined,
232
+ audit_report: undefined,
233
+ },
234
+ artifacts_written: ["external_analyzer_results.json"],
235
+ progress_summary: summary,
236
+ };
237
+ }
@@ -0,0 +1,3 @@
1
+ import type { ArtifactBundle } from "../io/artifacts.js";
2
+ import type { ExecutorRunResult } from "./executorResult.js";
3
+ export declare function runIntakeExecutor(bundle: ArtifactBundle, root: string): Promise<ExecutorRunResult>;
@@ -0,0 +1,25 @@
1
+ import { buildFileDisposition, isAuditExcludedStatus, } from "../extractors/disposition.js";
2
+ import { buildRepoManifestFromFs } from "../extractors/fsIntake.js";
3
+ import { loadIgnoreFile } from "../extractors/ignore.js";
4
+ export async function runIntakeExecutor(bundle, root) {
5
+ const ignore = await loadIgnoreFile(root);
6
+ const repoManifest = await buildRepoManifestFromFs({
7
+ root,
8
+ ignore,
9
+ hash_files: true,
10
+ });
11
+ const disposition = buildFileDisposition(repoManifest);
12
+ const auditableCount = disposition.files.filter((file) => !isAuditExcludedStatus(file.status)).length;
13
+ if (auditableCount === 0) {
14
+ throw new Error(`No auditable files found in ${root}. The repository may be empty, generated-only, documentation-only, or filtered by .auditorignore.`);
15
+ }
16
+ return {
17
+ updated: {
18
+ ...bundle,
19
+ repo_manifest: repoManifest,
20
+ file_disposition: disposition,
21
+ },
22
+ artifacts_written: ["repo_manifest.json", "file_disposition.json"],
23
+ progress_summary: `Created intake artifacts for ${repoManifest.files.length} files.`,
24
+ };
25
+ }
@@ -0,0 +1,4 @@
1
+ import type { ArtifactBundle } from "../io/artifacts.js";
2
+ import type { AuditScopeManifest } from "../types/auditScope.js";
3
+ import type { ExecutorRunResult } from "./executorResult.js";
4
+ export declare function runPlanningExecutor(bundle: ArtifactBundle, root: string, lineIndex?: Record<string, number>, sizeIndex?: Record<string, number>, scope?: AuditScopeManifest): Promise<ExecutorRunResult>;
@@ -0,0 +1,95 @@
1
+ import { initializeCoverageFromPlan } from "./planning.js";
2
+ import { applyScopeToCoverage, fullAuditScope } from "./scope.js";
3
+ import { buildFlowCoverage } from "./flowCoverage.js";
4
+ import { buildRequeuePayload } from "./requeueCommand.js";
5
+ import { buildRuntimeValidationTasks, discoverRuntimeValidationCommand, mergeRuntimeValidationReport, } from "./runtimeValidation.js";
6
+ import { buildChunkedAuditTasks, } from "./taskBuilder.js";
7
+ import { buildAuditPlanMetrics, buildReviewPackets, sizeIndexFromManifest, } from "./reviewPackets.js";
8
+ import { autoCompleteTrivialCoverage } from "./trivialAudit.js";
9
+ export async function runPlanningExecutor(bundle, root, lineIndex = {}, sizeIndex, scope) {
10
+ if (!bundle.repo_manifest) {
11
+ throw new Error("Cannot run planning executor without repo_manifest");
12
+ }
13
+ const resolvedSizeIndex = sizeIndex ?? sizeIndexFromManifest(bundle.repo_manifest);
14
+ if (!bundle.file_disposition ||
15
+ !bundle.unit_manifest ||
16
+ !bundle.surface_manifest ||
17
+ !bundle.critical_flows ||
18
+ !bundle.risk_register) {
19
+ throw new Error("Cannot run planning executor without current structure artifacts");
20
+ }
21
+ const resolvedScope = scope ?? fullAuditScope();
22
+ const externalAnalyzerResults = bundle.external_analyzer_results;
23
+ const coverage = initializeCoverageFromPlan(bundle.repo_manifest, bundle.unit_manifest, bundle.file_disposition, externalAnalyzerResults);
24
+ const skippedTrivialPaths = autoCompleteTrivialCoverage(coverage, lineIndex, externalAnalyzerResults);
25
+ // Delta scope: only seed + expanded files stay pending; the rest inherit prior
26
+ // completion or are excluded from this run. Full scope is a no-op.
27
+ applyScopeToCoverage(coverage, resolvedScope, bundle.coverage_matrix);
28
+ const flowCoverage = buildFlowCoverage(bundle.critical_flows, coverage);
29
+ const runtimeCommand = await discoverRuntimeValidationCommand(root);
30
+ const runtimeValidationTasks = buildRuntimeValidationTasks({
31
+ unitManifest: bundle.unit_manifest,
32
+ criticalFlows: bundle.critical_flows,
33
+ flowCoverage,
34
+ command: runtimeCommand,
35
+ });
36
+ const runtimeValidationReport = runtimeValidationTasks.tasks.length > 0
37
+ ? mergeRuntimeValidationReport(runtimeValidationTasks, bundle.runtime_validation_report)
38
+ : undefined;
39
+ const auditTasks = buildChunkedAuditTasks(coverage, lineIndex, {
40
+ external_analyzer_results: externalAnalyzerResults,
41
+ critical_flows: bundle.critical_flows,
42
+ });
43
+ const taggedAuditTasks = auditTasks.map((task) => ({
44
+ ...task,
45
+ status: task.status ?? "pending",
46
+ }));
47
+ const reviewPackets = buildReviewPackets(taggedAuditTasks, {
48
+ graphBundle: bundle.graph_bundle,
49
+ lineIndex,
50
+ sizeIndex: resolvedSizeIndex,
51
+ });
52
+ const auditPlanMetrics = buildAuditPlanMetrics(taggedAuditTasks, {
53
+ graphBundle: bundle.graph_bundle,
54
+ lineIndex,
55
+ sizeIndex: resolvedSizeIndex,
56
+ });
57
+ const requeuePayload = buildRequeuePayload(coverage, bundle.critical_flows, flowCoverage, externalAnalyzerResults);
58
+ const scopeSummary = resolvedScope.mode === "delta"
59
+ ? ` Delta scope since ${resolvedScope.since}: ${resolvedScope.seed_files.length} changed file(s) + ${resolvedScope.expanded_files.length} graph neighbour(s) queued; a full audit is advised before release.`
60
+ : "";
61
+ return {
62
+ updated: {
63
+ ...bundle,
64
+ scope: resolvedScope,
65
+ coverage_matrix: coverage,
66
+ flow_coverage: flowCoverage,
67
+ runtime_validation_tasks: runtimeValidationTasks,
68
+ runtime_validation_report: runtimeValidationReport,
69
+ audit_tasks: taggedAuditTasks,
70
+ audit_plan_metrics: auditPlanMetrics,
71
+ review_packets: reviewPackets,
72
+ requeue_tasks: requeuePayload.tasks,
73
+ audit_report: undefined,
74
+ },
75
+ artifacts_written: [
76
+ "scope.json",
77
+ "coverage_matrix.json",
78
+ "flow_coverage.json",
79
+ "runtime_validation_tasks.json",
80
+ ...(runtimeValidationReport ? ["runtime_validation_report.json"] : []),
81
+ "audit_tasks.json",
82
+ "audit_plan_metrics.json",
83
+ "review_packets.json",
84
+ "requeue_tasks.json",
85
+ ],
86
+ progress_summary: `Built planning artifacts; generated ${taggedAuditTasks.length} review tasks in ${reviewPackets.length} packet(s) and ${requeuePayload.task_count} requeue tasks.` +
87
+ scopeSummary +
88
+ (skippedTrivialPaths.length > 0
89
+ ? ` Skipped ${skippedTrivialPaths.length} trivial path${skippedTrivialPaths.length === 1 ? "" : "s"} from semantic review.`
90
+ : "") +
91
+ (runtimeCommand
92
+ ? ` Runtime validation will use: ${runtimeCommand.join(" ")}.`
93
+ : " No deterministic runtime validation command was discovered."),
94
+ };
95
+ }
@@ -0,0 +1,31 @@
1
+ import type { AuditTask } from "../types.js";
2
+ import type { ReviewPacketGraphEdge, ReviewPacketQuality } from "../types/reviewPlanning.js";
3
+ import type { GraphBundle, GraphEdge } from "@audit-tools/shared";
4
+ import { UnionFind } from "./unionFind.js";
5
+ import { normalizeGraphPath } from "../extractors/graphPathUtils.js";
6
+ export { normalizeGraphPath };
7
+ /**
8
+ * Fan-in / fan-out degree above which a node is treated as a hub. Exported so
9
+ * the Phase 3 delta-scope expansion skips the same hubs that packet planning
10
+ * skips, preventing scope blow-up through highly-connected modules.
11
+ */
12
+ export declare const HIGH_FAN_DEGREE_THRESHOLD = 12;
13
+ export declare function collectGraphEdges(graphBundle?: GraphBundle): GraphEdge[];
14
+ export declare function graphEdgeConfidence(edge: GraphEdge): number;
15
+ export declare function isConcreteGraphEdge(edge: GraphEdge): boolean;
16
+ export interface GraphDegreeIndex {
17
+ fanIn: Map<string, number>;
18
+ fanOut: Map<string, number>;
19
+ }
20
+ export declare function buildGraphDegreeIndex(edges: GraphEdge[]): GraphDegreeIndex;
21
+ export declare function isPacketExpansionEdge(edge: GraphEdge, degreeIndex: GraphDegreeIndex): boolean;
22
+ export declare function buildFileToGroupKeys(groups: Map<string, AuditTask[]>): Map<string, Set<string>>;
23
+ export declare function unionFindFromGroups(groups: Map<string, AuditTask[]>, graphEdges: GraphEdge[]): UnionFind;
24
+ export declare function buildPlanningGraphEdges(groups: Map<string, AuditTask[]>, graphEdges: GraphEdge[], graphBundle?: GraphBundle, lineIndex?: Record<string, number>, sizeIndex?: Record<string, number>, targetPacketTokens?: number): GraphEdge[];
25
+ export declare function roundQuality(value: number): number;
26
+ export declare function buildPacketGraphContext(filePaths: string[], graphEdges: GraphEdge[], graphBundle?: GraphBundle): {
27
+ keyEdges: ReviewPacketGraphEdge[];
28
+ boundaryFiles: string[];
29
+ entrypoints: string[];
30
+ quality: ReviewPacketQuality;
31
+ };