auditor-lambda 0.8.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.
- package/audit-code-wrapper-lib.mjs +149 -129
- package/dist/adapters/normalizeExternal.js +6 -3
- package/dist/cli/args.d.ts +0 -1
- package/dist/cli/args.js +0 -6
- package/dist/cli/dispatch.js +3 -2
- package/dist/cli/lineIndex.js +4 -1
- package/dist/cli/mergeAndIngestCommand.d.ts +1 -0
- package/dist/cli/mergeAndIngestCommand.js +219 -0
- package/dist/cli/nextStepCommand.js +5 -1
- package/dist/cli/runToCompletion.d.ts +9 -0
- package/dist/cli/runToCompletion.js +655 -480
- package/dist/cli/statusCommand.d.ts +1 -0
- package/dist/cli/statusCommand.js +113 -0
- package/dist/cli/submitPacketCommand.d.ts +1 -0
- package/dist/cli/submitPacketCommand.js +155 -0
- package/dist/cli/workerResult.d.ts +1 -1
- package/dist/cli/workerRunCommand.d.ts +1 -0
- package/dist/cli/workerRunCommand.js +88 -0
- package/dist/cli.js +14 -563
- package/dist/extractors/analyzers/sql.js +4 -1
- package/dist/extractors/analyzers/treeSitter.js +29 -15
- package/dist/extractors/analyzers/typescript.js +10 -8
- package/dist/extractors/designAssessment.js +43 -24
- package/dist/extractors/graph.js +139 -73
- package/dist/extractors/pathPatterns.js +17 -5
- package/dist/io/runArtifactTypes.d.ts +18 -0
- package/dist/io/runArtifactTypes.js +1 -0
- package/dist/io/runArtifacts.d.ts +2 -18
- package/dist/io/runArtifacts.js +14 -3
- package/dist/mcp/server.js +9 -0
- package/dist/orchestrator/advance.js +37 -22
- package/dist/orchestrator/artifactFreshness.js +2 -2
- package/dist/orchestrator/autoFixExecutor.d.ts +1 -1
- package/dist/orchestrator/autoFixExecutor.js +16 -8
- package/dist/orchestrator/dependencyMap.d.ts +1 -1
- package/dist/orchestrator/dependencyMap.js +7 -1
- package/dist/orchestrator/fileAnchors.js +14 -3
- package/dist/orchestrator/flowCoverage.js +1 -0
- package/dist/orchestrator/flowRequeue.js +4 -1
- package/dist/orchestrator/{internalExecutors.d.ts → ingestionExecutors.d.ts} +0 -6
- package/dist/orchestrator/ingestionExecutors.js +237 -0
- package/dist/orchestrator/intakeExecutors.d.ts +3 -0
- package/dist/orchestrator/intakeExecutors.js +25 -0
- package/dist/orchestrator/planningExecutors.d.ts +4 -0
- package/dist/orchestrator/planningExecutors.js +95 -0
- package/dist/orchestrator/runtimeCommand.js +7 -15
- package/dist/orchestrator/selectiveDeepening/conflict.d.ts +8 -0
- package/dist/orchestrator/selectiveDeepening/conflict.js +71 -0
- package/dist/orchestrator/selectiveDeepening/findingFollowup.d.ts +10 -0
- package/dist/orchestrator/selectiveDeepening/findingFollowup.js +52 -0
- package/dist/orchestrator/selectiveDeepening/highRiskClean.d.ts +7 -0
- package/dist/orchestrator/selectiveDeepening/highRiskClean.js +44 -0
- package/dist/orchestrator/selectiveDeepening/index.d.ts +18 -0
- package/dist/orchestrator/selectiveDeepening/index.js +128 -0
- package/dist/orchestrator/selectiveDeepening/lensVerification.d.ts +12 -0
- package/dist/orchestrator/selectiveDeepening/lensVerification.js +242 -0
- package/dist/orchestrator/selectiveDeepening/runtimeValidation.d.ts +13 -0
- package/dist/orchestrator/selectiveDeepening/runtimeValidation.js +57 -0
- package/dist/orchestrator/selectiveDeepening/shared.d.ts +45 -0
- package/dist/orchestrator/selectiveDeepening/shared.js +128 -0
- package/dist/orchestrator/selectiveDeepening/stewardFollowup.d.ts +6 -0
- package/dist/orchestrator/selectiveDeepening/stewardFollowup.js +72 -0
- package/dist/orchestrator/selectiveDeepening.d.ts +2 -20
- package/dist/orchestrator/selectiveDeepening.js +6 -760
- package/dist/orchestrator/staleness.js +3 -3
- package/dist/orchestrator/structureExecutors.d.ts +5 -0
- package/dist/orchestrator/structureExecutors.js +94 -0
- package/dist/orchestrator/taskBuilder.d.ts +2 -2
- package/dist/orchestrator/taskBuilder.js +101 -82
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.js +14 -95
- package/dist/quota/discoveredLimits.d.ts +1 -0
- package/dist/quota/discoveredLimits.js +7 -1
- package/dist/quota/index.d.ts +0 -2
- package/dist/quota/index.js +1 -2
- package/dist/reporting/workBlocks.js +7 -4
- package/dist/types/reviewPlanning.d.ts +23 -16
- package/dist/validation/auditResults.js +97 -95
- package/dist/validation/sessionConfig.d.ts +2 -2
- package/dist/validation/sessionConfig.js +14 -7
- package/package.json +3 -2
- package/schemas/audit_findings.schema.json +3 -3
- package/schemas/critical_flows.schema.json +3 -2
- package/schemas/dispatch_quota.schema.json +1 -1
- package/schemas/graph_bundle.schema.json +1 -1
- package/schemas/review_packets.schema.json +1 -1
- package/schemas/step_contract.schema.json +80 -0
- package/scripts/postinstall.mjs +19 -2
- package/skills/audit-code/opencode-command-template.txt +3 -3
- package/dist/orchestrator/internalExecutors.js +0 -424
- package/dist/providers/localSubprocessProvider.d.ts +0 -9
- package/dist/providers/localSubprocessProvider.js +0 -18
- package/dist/providers/subprocessTemplateProvider.d.ts +0 -8
- package/dist/providers/subprocessTemplateProvider.js +0 -59
- package/dist/providers/vscodeTaskProvider.d.ts +0 -7
- package/dist/providers/vscodeTaskProvider.js +0 -14
- package/dist/quota/probe.d.ts +0 -10
- package/dist/quota/probe.js +0 -18
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import { runCommand } from "./runtimeCommand.js";
|
|
2
|
-
import { buildFileDisposition, isAuditExcludedStatus, } from "../extractors/disposition.js";
|
|
3
|
-
import { buildGraphBundle, buildGraphBundleFromFs, } from "../extractors/graph.js";
|
|
4
|
-
import { buildCriticalFlowManifest } from "../extractors/flows.js";
|
|
5
|
-
import { buildRiskRegister } from "../extractors/risk.js";
|
|
6
|
-
import { buildSurfaceManifest } from "../extractors/surfaces.js";
|
|
7
|
-
import { initializeCoverageFromPlan } from "./planning.js";
|
|
8
|
-
import { applyScopeToCoverage, fullAuditScope } from "./scope.js";
|
|
9
|
-
import { buildFlowCoverage } from "./flowCoverage.js";
|
|
10
|
-
import { buildRequeuePayload } from "./requeueCommand.js";
|
|
11
|
-
import { buildRuntimeValidationTasks, discoverRuntimeValidationCommand, mergeRuntimeValidationReport, } from "./runtimeValidation.js";
|
|
12
|
-
import { buildChunkedAuditTasks, } from "./taskBuilder.js";
|
|
13
|
-
import { buildAuditPlanMetrics, buildReviewPackets, sizeIndexFromManifest, } from "./reviewPackets.js";
|
|
14
|
-
import { buildUnitManifest } from "./unitBuilder.js";
|
|
15
|
-
import { buildRepoManifestFromFs } from "../extractors/fsIntake.js";
|
|
16
|
-
import { loadIgnoreFile } from "../extractors/ignore.js";
|
|
17
|
-
import { ingestAuditResults, updateAuditTaskStatuses, } from "./resultIngestion.js";
|
|
18
|
-
import { buildDesignAssessment } from "../extractors/designAssessment.js";
|
|
19
|
-
import { buildSelectiveDeepeningTasks } from "./selectiveDeepening.js";
|
|
20
|
-
import { updateRuntimeValidationReport } from "./runtimeValidationUpdate.js";
|
|
21
|
-
import { autoCompleteTrivialCoverage } from "./trivialAudit.js";
|
|
22
|
-
function lineIndexFromTasks(tasks) {
|
|
23
|
-
return Object.fromEntries((tasks ?? []).flatMap((task) => Object.entries(task.file_line_counts ?? {})));
|
|
24
|
-
}
|
|
25
|
-
function appendSelectiveDeepeningTasks(params) {
|
|
26
|
-
if (!params.bundle.audit_tasks) {
|
|
27
|
-
return { bundle: params.bundle, taskCount: 0, artifacts: [] };
|
|
28
|
-
}
|
|
29
|
-
const lineIndex = lineIndexFromTasks(params.bundle.audit_tasks);
|
|
30
|
-
const sizeIndex = sizeIndexFromManifest(params.bundle.repo_manifest);
|
|
31
|
-
const selectiveDeepeningTasks = buildSelectiveDeepeningTasks({
|
|
32
|
-
existingTasks: params.bundle.audit_tasks,
|
|
33
|
-
results: params.results,
|
|
34
|
-
lineIndex,
|
|
35
|
-
runtimeValidationTasks: params.bundle.runtime_validation_tasks,
|
|
36
|
-
runtimeValidationReport: params.runtimeValidationReport ?? params.bundle.runtime_validation_report,
|
|
37
|
-
externalAnalyzerResults: params.bundle.external_analyzer_results,
|
|
38
|
-
});
|
|
39
|
-
if (selectiveDeepeningTasks.length === 0) {
|
|
40
|
-
return { bundle: params.bundle, taskCount: 0, artifacts: [] };
|
|
41
|
-
}
|
|
42
|
-
const auditTasks = [...params.bundle.audit_tasks, ...selectiveDeepeningTasks];
|
|
43
|
-
return {
|
|
44
|
-
bundle: {
|
|
45
|
-
...params.bundle,
|
|
46
|
-
audit_tasks: auditTasks,
|
|
47
|
-
audit_plan_metrics: buildAuditPlanMetrics(auditTasks, {
|
|
48
|
-
graphBundle: params.bundle.graph_bundle,
|
|
49
|
-
lineIndex,
|
|
50
|
-
sizeIndex,
|
|
51
|
-
}),
|
|
52
|
-
review_packets: buildReviewPackets(auditTasks, {
|
|
53
|
-
graphBundle: params.bundle.graph_bundle,
|
|
54
|
-
lineIndex,
|
|
55
|
-
sizeIndex,
|
|
56
|
-
}),
|
|
57
|
-
},
|
|
58
|
-
taskCount: selectiveDeepeningTasks.length,
|
|
59
|
-
artifacts: ["audit_tasks.json", "audit_plan_metrics.json", "review_packets.json"],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export async function runIntakeExecutor(bundle, root) {
|
|
63
|
-
const ignore = await loadIgnoreFile(root);
|
|
64
|
-
const repoManifest = await buildRepoManifestFromFs({
|
|
65
|
-
root,
|
|
66
|
-
ignore,
|
|
67
|
-
hash_files: true,
|
|
68
|
-
});
|
|
69
|
-
const disposition = buildFileDisposition(repoManifest);
|
|
70
|
-
const auditableCount = disposition.files.filter((file) => !isAuditExcludedStatus(file.status)).length;
|
|
71
|
-
if (auditableCount === 0) {
|
|
72
|
-
throw new Error(`No auditable files found in ${root}. The repository may be empty, generated-only, documentation-only, or filtered by .auditorignore.`);
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
updated: {
|
|
76
|
-
...bundle,
|
|
77
|
-
repo_manifest: repoManifest,
|
|
78
|
-
file_disposition: disposition,
|
|
79
|
-
},
|
|
80
|
-
artifacts_written: ["repo_manifest.json", "file_disposition.json"],
|
|
81
|
-
progress_summary: `Created intake artifacts for ${repoManifest.files.length} files.`,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export async function runStructureExecutor(bundle, root) {
|
|
85
|
-
if (!bundle.repo_manifest) {
|
|
86
|
-
throw new Error("Cannot run structure executor without repo_manifest");
|
|
87
|
-
}
|
|
88
|
-
const externalAnalyzerResults = bundle.external_analyzer_results;
|
|
89
|
-
const disposition = bundle.file_disposition ?? buildFileDisposition(bundle.repo_manifest);
|
|
90
|
-
const unitManifest = buildUnitManifest(bundle.repo_manifest, disposition);
|
|
91
|
-
const graphBundle = root
|
|
92
|
-
? await buildGraphBundleFromFs(bundle.repo_manifest, root, disposition, {
|
|
93
|
-
externalAnalyzerResults,
|
|
94
|
-
})
|
|
95
|
-
: buildGraphBundle(bundle.repo_manifest, disposition, {
|
|
96
|
-
externalAnalyzerResults,
|
|
97
|
-
});
|
|
98
|
-
const surfaceManifest = buildSurfaceManifest(bundle.repo_manifest, disposition, { graphBundle });
|
|
99
|
-
const criticalFlows = buildCriticalFlowManifest(bundle.repo_manifest, surfaceManifest, disposition);
|
|
100
|
-
const riskRegister = buildRiskRegister(unitManifest, criticalFlows, externalAnalyzerResults);
|
|
101
|
-
return {
|
|
102
|
-
updated: {
|
|
103
|
-
...bundle,
|
|
104
|
-
file_disposition: disposition,
|
|
105
|
-
unit_manifest: unitManifest,
|
|
106
|
-
surface_manifest: surfaceManifest,
|
|
107
|
-
graph_bundle: graphBundle,
|
|
108
|
-
critical_flows: criticalFlows,
|
|
109
|
-
risk_register: riskRegister,
|
|
110
|
-
},
|
|
111
|
-
artifacts_written: [
|
|
112
|
-
"file_disposition.json",
|
|
113
|
-
"unit_manifest.json",
|
|
114
|
-
"surface_manifest.json",
|
|
115
|
-
"graph_bundle.json",
|
|
116
|
-
"critical_flows.json",
|
|
117
|
-
"risk_register.json",
|
|
118
|
-
],
|
|
119
|
-
progress_summary: `Built structure artifacts for ${unitManifest.units.length} units and ${criticalFlows.flows.length} critical flows.` +
|
|
120
|
-
(criticalFlows.fallback_required
|
|
121
|
-
? " Deterministic flow inference did not fully meet the confidence bar."
|
|
122
|
-
: ""),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
export function runDesignAssessmentExecutor(bundle) {
|
|
126
|
-
if (!bundle.unit_manifest ||
|
|
127
|
-
!bundle.graph_bundle ||
|
|
128
|
-
!bundle.critical_flows ||
|
|
129
|
-
!bundle.risk_register) {
|
|
130
|
-
throw new Error("Cannot run design assessment executor without structure artifacts");
|
|
131
|
-
}
|
|
132
|
-
const designAssessment = buildDesignAssessment({
|
|
133
|
-
unitManifest: bundle.unit_manifest,
|
|
134
|
-
graphBundle: bundle.graph_bundle,
|
|
135
|
-
criticalFlows: bundle.critical_flows,
|
|
136
|
-
riskRegister: bundle.risk_register,
|
|
137
|
-
});
|
|
138
|
-
const previous = bundle.design_assessment;
|
|
139
|
-
if (previous?.reviewed) {
|
|
140
|
-
designAssessment.reviewed = true;
|
|
141
|
-
designAssessment.review_findings = previous.review_findings ?? [];
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
updated: {
|
|
145
|
-
...bundle,
|
|
146
|
-
design_assessment: designAssessment,
|
|
147
|
-
},
|
|
148
|
-
artifacts_written: ["design_assessment.json"],
|
|
149
|
-
progress_summary: `Design assessment complete: ${designAssessment.findings.length} structural finding(s).`,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
export function runDesignReviewAutoComplete(bundle) {
|
|
153
|
-
const existing = bundle.design_assessment;
|
|
154
|
-
if (!existing) {
|
|
155
|
-
throw new Error("Cannot auto-complete design review without design_assessment artifact");
|
|
156
|
-
}
|
|
157
|
-
const updated = {
|
|
158
|
-
...existing,
|
|
159
|
-
reviewed: true,
|
|
160
|
-
review_findings: existing.review_findings ?? [],
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
updated: {
|
|
164
|
-
...bundle,
|
|
165
|
-
design_assessment: updated,
|
|
166
|
-
},
|
|
167
|
-
artifacts_written: ["design_assessment.json"],
|
|
168
|
-
progress_summary: "Design review auto-completed (host-agent review available via next-step).",
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
export async function runPlanningExecutor(bundle, root, lineIndex = {}, sizeIndex, scope) {
|
|
172
|
-
if (!bundle.repo_manifest) {
|
|
173
|
-
throw new Error("Cannot run planning executor without repo_manifest");
|
|
174
|
-
}
|
|
175
|
-
const resolvedSizeIndex = sizeIndex ?? sizeIndexFromManifest(bundle.repo_manifest);
|
|
176
|
-
if (!bundle.file_disposition ||
|
|
177
|
-
!bundle.unit_manifest ||
|
|
178
|
-
!bundle.surface_manifest ||
|
|
179
|
-
!bundle.critical_flows ||
|
|
180
|
-
!bundle.risk_register) {
|
|
181
|
-
throw new Error("Cannot run planning executor without current structure artifacts");
|
|
182
|
-
}
|
|
183
|
-
const resolvedScope = scope ?? fullAuditScope();
|
|
184
|
-
const externalAnalyzerResults = bundle.external_analyzer_results;
|
|
185
|
-
const coverage = initializeCoverageFromPlan(bundle.repo_manifest, bundle.unit_manifest, bundle.file_disposition, externalAnalyzerResults);
|
|
186
|
-
const skippedTrivialPaths = autoCompleteTrivialCoverage(coverage, lineIndex, externalAnalyzerResults);
|
|
187
|
-
// Delta scope: only seed + expanded files stay pending; the rest inherit prior
|
|
188
|
-
// completion or are excluded from this run. Full scope is a no-op.
|
|
189
|
-
applyScopeToCoverage(coverage, resolvedScope, bundle.coverage_matrix);
|
|
190
|
-
const flowCoverage = buildFlowCoverage(bundle.critical_flows, coverage);
|
|
191
|
-
const runtimeCommand = await discoverRuntimeValidationCommand(root);
|
|
192
|
-
const runtimeValidationTasks = buildRuntimeValidationTasks({
|
|
193
|
-
unitManifest: bundle.unit_manifest,
|
|
194
|
-
criticalFlows: bundle.critical_flows,
|
|
195
|
-
flowCoverage,
|
|
196
|
-
command: runtimeCommand,
|
|
197
|
-
});
|
|
198
|
-
const runtimeValidationReport = runtimeValidationTasks.tasks.length > 0
|
|
199
|
-
? mergeRuntimeValidationReport(runtimeValidationTasks, bundle.runtime_validation_report)
|
|
200
|
-
: undefined;
|
|
201
|
-
const auditTasks = buildChunkedAuditTasks(coverage, lineIndex, {
|
|
202
|
-
external_analyzer_results: externalAnalyzerResults,
|
|
203
|
-
critical_flows: bundle.critical_flows,
|
|
204
|
-
});
|
|
205
|
-
const taggedAuditTasks = auditTasks.map((task) => ({
|
|
206
|
-
...task,
|
|
207
|
-
status: task.status ?? "pending",
|
|
208
|
-
}));
|
|
209
|
-
const reviewPackets = buildReviewPackets(taggedAuditTasks, {
|
|
210
|
-
graphBundle: bundle.graph_bundle,
|
|
211
|
-
lineIndex,
|
|
212
|
-
sizeIndex: resolvedSizeIndex,
|
|
213
|
-
});
|
|
214
|
-
const auditPlanMetrics = buildAuditPlanMetrics(taggedAuditTasks, {
|
|
215
|
-
graphBundle: bundle.graph_bundle,
|
|
216
|
-
lineIndex,
|
|
217
|
-
sizeIndex: resolvedSizeIndex,
|
|
218
|
-
});
|
|
219
|
-
const requeuePayload = buildRequeuePayload(coverage, bundle.critical_flows, flowCoverage, externalAnalyzerResults);
|
|
220
|
-
const scopeSummary = resolvedScope.mode === "delta"
|
|
221
|
-
? ` 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.`
|
|
222
|
-
: "";
|
|
223
|
-
return {
|
|
224
|
-
updated: {
|
|
225
|
-
...bundle,
|
|
226
|
-
scope: resolvedScope,
|
|
227
|
-
coverage_matrix: coverage,
|
|
228
|
-
flow_coverage: flowCoverage,
|
|
229
|
-
runtime_validation_tasks: runtimeValidationTasks,
|
|
230
|
-
runtime_validation_report: runtimeValidationReport,
|
|
231
|
-
audit_tasks: taggedAuditTasks,
|
|
232
|
-
audit_plan_metrics: auditPlanMetrics,
|
|
233
|
-
review_packets: reviewPackets,
|
|
234
|
-
requeue_tasks: requeuePayload.tasks,
|
|
235
|
-
audit_report: undefined,
|
|
236
|
-
},
|
|
237
|
-
artifacts_written: [
|
|
238
|
-
"scope.json",
|
|
239
|
-
"coverage_matrix.json",
|
|
240
|
-
"flow_coverage.json",
|
|
241
|
-
"runtime_validation_tasks.json",
|
|
242
|
-
...(runtimeValidationReport ? ["runtime_validation_report.json"] : []),
|
|
243
|
-
"audit_tasks.json",
|
|
244
|
-
"audit_plan_metrics.json",
|
|
245
|
-
"review_packets.json",
|
|
246
|
-
"requeue_tasks.json",
|
|
247
|
-
],
|
|
248
|
-
progress_summary: `Built planning artifacts; generated ${taggedAuditTasks.length} review tasks in ${reviewPackets.length} packet(s) and ${requeuePayload.task_count} requeue tasks.` +
|
|
249
|
-
scopeSummary +
|
|
250
|
-
(skippedTrivialPaths.length > 0
|
|
251
|
-
? ` Skipped ${skippedTrivialPaths.length} trivial path${skippedTrivialPaths.length === 1 ? "" : "s"} from semantic review.`
|
|
252
|
-
: "") +
|
|
253
|
-
(runtimeCommand
|
|
254
|
-
? ` Runtime validation will use: ${runtimeCommand.join(" ")}.`
|
|
255
|
-
: " No deterministic runtime validation command was discovered."),
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
export function runResultIngestionExecutor(bundle, results) {
|
|
259
|
-
if (!bundle.coverage_matrix) {
|
|
260
|
-
throw new Error("Cannot ingest results without coverage_matrix");
|
|
261
|
-
}
|
|
262
|
-
const updatedCoverageMatrix = ingestAuditResults(bundle.coverage_matrix, results);
|
|
263
|
-
const flowCoverage = bundle.critical_flows
|
|
264
|
-
? buildFlowCoverage(bundle.critical_flows, updatedCoverageMatrix)
|
|
265
|
-
: bundle.flow_coverage;
|
|
266
|
-
const runtimeCommand = bundle.runtime_validation_tasks?.tasks.find((task) => task.command && task.command.length > 0)?.command;
|
|
267
|
-
const runtimeValidationTasks = bundle.unit_manifest && flowCoverage
|
|
268
|
-
? buildRuntimeValidationTasks({
|
|
269
|
-
unitManifest: bundle.unit_manifest,
|
|
270
|
-
criticalFlows: bundle.critical_flows,
|
|
271
|
-
flowCoverage,
|
|
272
|
-
command: runtimeCommand,
|
|
273
|
-
})
|
|
274
|
-
: bundle.runtime_validation_tasks;
|
|
275
|
-
const runtimeValidationReport = runtimeValidationTasks
|
|
276
|
-
? mergeRuntimeValidationReport(runtimeValidationTasks, bundle.runtime_validation_report)
|
|
277
|
-
: bundle.runtime_validation_report;
|
|
278
|
-
const mergedResults = [...(bundle.audit_results ?? []), ...results];
|
|
279
|
-
const completedAuditTasks = updateAuditTaskStatuses(bundle.audit_tasks, mergedResults);
|
|
280
|
-
const baseUpdatedBundle = {
|
|
281
|
-
...bundle,
|
|
282
|
-
coverage_matrix: updatedCoverageMatrix,
|
|
283
|
-
flow_coverage: flowCoverage,
|
|
284
|
-
runtime_validation_tasks: runtimeValidationTasks,
|
|
285
|
-
runtime_validation_report: runtimeValidationReport,
|
|
286
|
-
audit_results: mergedResults,
|
|
287
|
-
audit_tasks: completedAuditTasks,
|
|
288
|
-
audit_report: undefined,
|
|
289
|
-
};
|
|
290
|
-
const selectiveDeepening = appendSelectiveDeepeningTasks({
|
|
291
|
-
bundle: baseUpdatedBundle,
|
|
292
|
-
results: mergedResults,
|
|
293
|
-
runtimeValidationReport,
|
|
294
|
-
});
|
|
295
|
-
const requeuePayload = buildRequeuePayload(updatedCoverageMatrix, selectiveDeepening.bundle.critical_flows, selectiveDeepening.bundle.flow_coverage, selectiveDeepening.bundle.external_analyzer_results);
|
|
296
|
-
const finalBundle = {
|
|
297
|
-
...selectiveDeepening.bundle,
|
|
298
|
-
requeue_tasks: requeuePayload.tasks,
|
|
299
|
-
};
|
|
300
|
-
return {
|
|
301
|
-
updated: finalBundle,
|
|
302
|
-
artifacts_written: [
|
|
303
|
-
"coverage_matrix.json",
|
|
304
|
-
"flow_coverage.json",
|
|
305
|
-
...(runtimeValidationTasks ? ["runtime_validation_tasks.json"] : []),
|
|
306
|
-
...(runtimeValidationReport ? ["runtime_validation_report.json"] : []),
|
|
307
|
-
"audit_results.jsonl",
|
|
308
|
-
"audit_tasks.json",
|
|
309
|
-
...selectiveDeepening.artifacts.filter((artifact) => artifact !== "audit_tasks.json"),
|
|
310
|
-
"requeue_tasks.json",
|
|
311
|
-
],
|
|
312
|
-
progress_summary: `Ingested ${results.length} audit result entries and refreshed dependent artifacts.` +
|
|
313
|
-
(selectiveDeepening.taskCount > 0
|
|
314
|
-
? ` Added ${selectiveDeepening.taskCount} selective deepening task(s).`
|
|
315
|
-
: ""),
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
export async function runRuntimeValidationExecutor(bundle, root, options = {}) {
|
|
319
|
-
if (!bundle.runtime_validation_tasks) {
|
|
320
|
-
throw new Error("Cannot execute runtime validation without runtime_validation_tasks");
|
|
321
|
-
}
|
|
322
|
-
const existing = bundle.runtime_validation_report ?? { results: [] };
|
|
323
|
-
const byTaskId = new Map(existing.results.map((result) => [result.task_id, result]));
|
|
324
|
-
const byCommand = new Map();
|
|
325
|
-
for (const task of bundle.runtime_validation_tasks.tasks) {
|
|
326
|
-
const prior = byTaskId.get(task.id);
|
|
327
|
-
if (prior &&
|
|
328
|
-
["confirmed", "not_confirmed", "inconclusive", "not_required"].includes(prior.status)) {
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
if (!task.command || task.command.length === 0) {
|
|
332
|
-
byTaskId.set(task.id, {
|
|
333
|
-
task_id: task.id,
|
|
334
|
-
status: "not_required",
|
|
335
|
-
summary: `No deterministic runtime command was available for ${task.id}.`,
|
|
336
|
-
evidence: [],
|
|
337
|
-
notes: ["Runtime validation was not planned for this task."],
|
|
338
|
-
});
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
const signature = task.command.join("\0");
|
|
342
|
-
const outcome = byCommand.get(signature) ?? (await runCommand(task.command, root, { opentoken: options.opentoken }));
|
|
343
|
-
byCommand.set(signature, outcome);
|
|
344
|
-
byTaskId.set(task.id, {
|
|
345
|
-
task_id: task.id,
|
|
346
|
-
status: outcome.status,
|
|
347
|
-
summary: outcome.summary,
|
|
348
|
-
evidence: outcome.evidence,
|
|
349
|
-
notes: [`Target paths: ${task.target_paths.join(", ")}`],
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
const runtimeValidationReport = {
|
|
353
|
-
results: [...byTaskId.values()].sort((a, b) => a.task_id.localeCompare(b.task_id)),
|
|
354
|
-
};
|
|
355
|
-
const baseUpdatedBundle = {
|
|
356
|
-
...bundle,
|
|
357
|
-
runtime_validation_report: runtimeValidationReport,
|
|
358
|
-
audit_report: undefined,
|
|
359
|
-
};
|
|
360
|
-
const selectiveDeepening = appendSelectiveDeepeningTasks({
|
|
361
|
-
bundle: baseUpdatedBundle,
|
|
362
|
-
results: bundle.audit_results ?? [],
|
|
363
|
-
runtimeValidationReport,
|
|
364
|
-
});
|
|
365
|
-
return {
|
|
366
|
-
updated: selectiveDeepening.bundle,
|
|
367
|
-
artifacts_written: [
|
|
368
|
-
"runtime_validation_report.json",
|
|
369
|
-
...selectiveDeepening.artifacts,
|
|
370
|
-
],
|
|
371
|
-
progress_summary: `Executed deterministic runtime validation for ${bundle.runtime_validation_tasks.tasks.length} task(s).` +
|
|
372
|
-
(selectiveDeepening.taskCount > 0
|
|
373
|
-
? ` Added ${selectiveDeepening.taskCount} selective deepening task(s).`
|
|
374
|
-
: ""),
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
export function runRuntimeValidationUpdateExecutor(bundle, updates) {
|
|
378
|
-
if (!bundle.runtime_validation_tasks) {
|
|
379
|
-
throw new Error("Cannot update runtime validation without runtime_validation_tasks");
|
|
380
|
-
}
|
|
381
|
-
const existingReport = bundle.runtime_validation_report ?? { results: [] };
|
|
382
|
-
const mergedReport = updateRuntimeValidationReport(bundle.runtime_validation_tasks, existingReport, updates);
|
|
383
|
-
const baseUpdatedBundle = {
|
|
384
|
-
...bundle,
|
|
385
|
-
runtime_validation_report: mergedReport,
|
|
386
|
-
audit_report: undefined,
|
|
387
|
-
};
|
|
388
|
-
const selectiveDeepening = appendSelectiveDeepeningTasks({
|
|
389
|
-
bundle: baseUpdatedBundle,
|
|
390
|
-
results: bundle.audit_results ?? [],
|
|
391
|
-
runtimeValidationReport: mergedReport,
|
|
392
|
-
});
|
|
393
|
-
return {
|
|
394
|
-
updated: selectiveDeepening.bundle,
|
|
395
|
-
artifacts_written: [
|
|
396
|
-
"runtime_validation_report.json",
|
|
397
|
-
...selectiveDeepening.artifacts,
|
|
398
|
-
],
|
|
399
|
-
progress_summary: `Merged ${updates.results.length} runtime validation updates.` +
|
|
400
|
-
(selectiveDeepening.taskCount > 0
|
|
401
|
-
? ` Added ${selectiveDeepening.taskCount} selective deepening task(s).`
|
|
402
|
-
: ""),
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
export function runExternalAnalyzerImportExecutor(bundle, externalResults) {
|
|
406
|
-
const summary = `Imported ${externalResults.results.length} normalized findings from ${externalResults.tool}.`;
|
|
407
|
-
return {
|
|
408
|
-
updated: {
|
|
409
|
-
...bundle,
|
|
410
|
-
external_analyzer_results: externalResults,
|
|
411
|
-
coverage_matrix: undefined,
|
|
412
|
-
flow_coverage: undefined,
|
|
413
|
-
runtime_validation_tasks: undefined,
|
|
414
|
-
runtime_validation_report: undefined,
|
|
415
|
-
audit_tasks: undefined,
|
|
416
|
-
audit_plan_metrics: undefined,
|
|
417
|
-
review_packets: undefined,
|
|
418
|
-
requeue_tasks: undefined,
|
|
419
|
-
audit_report: undefined,
|
|
420
|
-
},
|
|
421
|
-
artifacts_written: ["external_analyzer_results.json"],
|
|
422
|
-
progress_summary: summary,
|
|
423
|
-
};
|
|
424
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FreshSessionProvider, LaunchFreshSessionInput } from "@audit-tools/shared";
|
|
2
|
-
import { spawnLoggedCommand } from "@audit-tools/shared";
|
|
3
|
-
export declare const MISSING_WORKER_COMMAND_MESSAGE = "local-subprocess provider requires task.worker_command.";
|
|
4
|
-
export declare class LocalSubprocessProvider implements FreshSessionProvider {
|
|
5
|
-
name: string;
|
|
6
|
-
private readonly launchCommand;
|
|
7
|
-
constructor(launchCommand?: typeof spawnLoggedCommand);
|
|
8
|
-
launch(input: LaunchFreshSessionInput): Promise<import("@audit-tools/shared").LaunchFreshSessionResult>;
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { readJsonFile } from "@audit-tools/shared";
|
|
2
|
-
import { spawnLoggedCommand, applyWorkerTaskLaunchSettings } from "@audit-tools/shared";
|
|
3
|
-
export const MISSING_WORKER_COMMAND_MESSAGE = "local-subprocess provider requires task.worker_command.";
|
|
4
|
-
export class LocalSubprocessProvider {
|
|
5
|
-
name = "local-subprocess";
|
|
6
|
-
launchCommand;
|
|
7
|
-
constructor(launchCommand = spawnLoggedCommand) {
|
|
8
|
-
this.launchCommand = launchCommand;
|
|
9
|
-
}
|
|
10
|
-
async launch(input) {
|
|
11
|
-
const task = await readJsonFile(input.taskPath);
|
|
12
|
-
if (!task.worker_command?.length) {
|
|
13
|
-
throw new Error(MISSING_WORKER_COMMAND_MESSAGE);
|
|
14
|
-
}
|
|
15
|
-
const [command, ...args] = task.worker_command;
|
|
16
|
-
return await this.launchCommand(command, args, applyWorkerTaskLaunchSettings(input, task));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FreshSessionProvider, LaunchFreshSessionInput, SubprocessTemplateConfig, OpenTokenConfig } from "@audit-tools/shared";
|
|
2
|
-
export declare class SubprocessTemplateProvider implements FreshSessionProvider {
|
|
3
|
-
name: string;
|
|
4
|
-
private readonly config;
|
|
5
|
-
private readonly opentoken;
|
|
6
|
-
constructor(config: SubprocessTemplateConfig, name?: string, opentoken?: OpenTokenConfig);
|
|
7
|
-
launch(input: LaunchFreshSessionInput): Promise<import("@audit-tools/shared").LaunchFreshSessionResult>;
|
|
8
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { readJsonFile } from "@audit-tools/shared";
|
|
2
|
-
import { spawnLoggedCommand, shellQuote, applyWorkerTaskLaunchSettings, } from "@audit-tools/shared";
|
|
3
|
-
function applyTemplate(template, input, task, context) {
|
|
4
|
-
const workerCommandShell = task.worker_command
|
|
5
|
-
.map((arg) => shellQuote(arg))
|
|
6
|
-
.join(" ");
|
|
7
|
-
const workerCommandJson = JSON.stringify(task.worker_command);
|
|
8
|
-
const values = {
|
|
9
|
-
repoRoot: input.repoRoot,
|
|
10
|
-
runId: input.runId,
|
|
11
|
-
obligationId: input.obligationId ?? "",
|
|
12
|
-
promptPath: input.promptPath,
|
|
13
|
-
taskPath: input.taskPath,
|
|
14
|
-
resultPath: input.resultPath,
|
|
15
|
-
stdoutPath: input.stdoutPath,
|
|
16
|
-
stderrPath: input.stderrPath,
|
|
17
|
-
workerCommandShell,
|
|
18
|
-
workerCommandJson,
|
|
19
|
-
uiMode: input.uiMode,
|
|
20
|
-
timeoutMs: String(input.timeoutMs),
|
|
21
|
-
};
|
|
22
|
-
const wholePlaceholder = template.match(/^\{([A-Za-z0-9_]+)\}$/);
|
|
23
|
-
return template.replace(/\{([A-Za-z0-9_]+)\}/g, (match, key) => {
|
|
24
|
-
if (!(key in values)) {
|
|
25
|
-
console.warn(`applyTemplate: unknown placeholder ${match} ` +
|
|
26
|
-
`provider=${context.providerName} runId=${input.runId} ` +
|
|
27
|
-
`obligationId=${input.obligationId ?? ""} taskPath=${input.taskPath} ` +
|
|
28
|
-
`entryIndex=${context.entryIndex}`);
|
|
29
|
-
}
|
|
30
|
-
const value = values[key] ?? "";
|
|
31
|
-
return wholePlaceholder || key.endsWith("Shell") ? value : shellQuote(value);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export class SubprocessTemplateProvider {
|
|
35
|
-
name;
|
|
36
|
-
config;
|
|
37
|
-
opentoken;
|
|
38
|
-
constructor(config, name = "subprocess-template", opentoken = {}) {
|
|
39
|
-
this.config = config;
|
|
40
|
-
this.name = name;
|
|
41
|
-
this.opentoken = opentoken;
|
|
42
|
-
}
|
|
43
|
-
async launch(input) {
|
|
44
|
-
const task = await readJsonFile(input.taskPath);
|
|
45
|
-
if (!this.config.command_template.length) {
|
|
46
|
-
throw new Error(`${this.name} provider requires a non-empty command_template.`);
|
|
47
|
-
}
|
|
48
|
-
const launchInput = applyWorkerTaskLaunchSettings(input, task);
|
|
49
|
-
const rendered = this.config.command_template.map((entry, entryIndex) => applyTemplate(entry, launchInput, task, {
|
|
50
|
-
providerName: this.name,
|
|
51
|
-
entryIndex,
|
|
52
|
-
}));
|
|
53
|
-
const [command, ...args] = rendered;
|
|
54
|
-
return await spawnLoggedCommand(command, args, launchInput, this.config.env, {
|
|
55
|
-
opentoken: this.opentoken.enabled,
|
|
56
|
-
opentokenCommand: this.opentoken.command,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { FreshSessionProvider, LaunchFreshSessionInput, VSCodeTaskConfig, OpenTokenConfig } from "@audit-tools/shared";
|
|
2
|
-
export declare class VSCodeTaskProvider implements FreshSessionProvider {
|
|
3
|
-
name: string;
|
|
4
|
-
private readonly delegate;
|
|
5
|
-
constructor(config: VSCodeTaskConfig, opentoken?: OpenTokenConfig);
|
|
6
|
-
launch(input: LaunchFreshSessionInput): Promise<import("@audit-tools/shared").LaunchFreshSessionResult>;
|
|
7
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SubprocessTemplateProvider } from "./subprocessTemplateProvider.js";
|
|
2
|
-
export class VSCodeTaskProvider {
|
|
3
|
-
name = "vscode-task";
|
|
4
|
-
delegate;
|
|
5
|
-
constructor(config, opentoken = {}) {
|
|
6
|
-
this.delegate = new SubprocessTemplateProvider({
|
|
7
|
-
command_template: config.command_template,
|
|
8
|
-
env: config.env,
|
|
9
|
-
}, "vscode-task", opentoken);
|
|
10
|
-
}
|
|
11
|
-
async launch(input) {
|
|
12
|
-
return await this.delegate.launch(input);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/dist/quota/probe.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface ProbeResult {
|
|
2
|
-
supported: boolean;
|
|
3
|
-
reason: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Probe a provider to discover its rate limits.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Phase 3A replaces this with the QuotaSource abstraction.
|
|
9
|
-
*/
|
|
10
|
-
export declare function probeProvider(providerName: string, probeMode?: "auto" | "never" | "force"): Promise<ProbeResult>;
|
package/dist/quota/probe.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Probe a provider to discover its rate limits.
|
|
3
|
-
*
|
|
4
|
-
* @deprecated Phase 3A replaces this with the QuotaSource abstraction.
|
|
5
|
-
*/
|
|
6
|
-
export async function probeProvider(providerName, probeMode = "auto") {
|
|
7
|
-
if (probeMode === "never") {
|
|
8
|
-
return { supported: false, reason: "probe disabled by config" };
|
|
9
|
-
}
|
|
10
|
-
if (providerName !== "subprocess-template") {
|
|
11
|
-
return {
|
|
12
|
-
supported: false,
|
|
13
|
-
reason: `probe not applicable for ${providerName} — limits come from known-model metadata or learned behavior`,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
// subprocess-template probe not yet implemented
|
|
17
|
-
return { supported: false, reason: "subprocess-template probe not yet implemented" };
|
|
18
|
-
}
|