auditor-lambda 0.1.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/README.md +173 -0
- package/audit-code-wrapper-lib.mjs +905 -0
- package/audit-code.mjs +13 -0
- package/dist/adapters/coverageSummary.d.ts +8 -0
- package/dist/adapters/coverageSummary.js +13 -0
- package/dist/adapters/eslint.d.ts +13 -0
- package/dist/adapters/eslint.js +21 -0
- package/dist/adapters/normalizeExternal.d.ts +12 -0
- package/dist/adapters/normalizeExternal.js +19 -0
- package/dist/adapters/npmAudit.d.ts +15 -0
- package/dist/adapters/npmAudit.js +12 -0
- package/dist/adapters/semgrep.d.ts +22 -0
- package/dist/adapters/semgrep.js +14 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +724 -0
- package/dist/coverage.d.ts +11 -0
- package/dist/coverage.js +102 -0
- package/dist/extractors/bucketing.d.ts +7 -0
- package/dist/extractors/bucketing.js +72 -0
- package/dist/extractors/disposition.d.ts +4 -0
- package/dist/extractors/disposition.js +41 -0
- package/dist/extractors/fileInventory.d.ts +7 -0
- package/dist/extractors/fileInventory.js +44 -0
- package/dist/extractors/flows.d.ts +5 -0
- package/dist/extractors/flows.js +125 -0
- package/dist/extractors/fsIntake.d.ts +8 -0
- package/dist/extractors/fsIntake.js +66 -0
- package/dist/extractors/graph.d.ts +4 -0
- package/dist/extractors/graph.js +46 -0
- package/dist/extractors/ignore.d.ts +1 -0
- package/dist/extractors/ignore.js +17 -0
- package/dist/extractors/risk.d.ts +5 -0
- package/dist/extractors/risk.js +45 -0
- package/dist/extractors/surfaces.d.ts +4 -0
- package/dist/extractors/surfaces.js +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/artifacts.d.ts +38 -0
- package/dist/io/artifacts.js +100 -0
- package/dist/io/json.d.ts +8 -0
- package/dist/io/json.js +96 -0
- package/dist/io/runArtifacts.d.ts +14 -0
- package/dist/io/runArtifacts.js +37 -0
- package/dist/orchestrator/advance.d.ts +24 -0
- package/dist/orchestrator/advance.js +104 -0
- package/dist/orchestrator/artifactMetadata.d.ts +4 -0
- package/dist/orchestrator/artifactMetadata.js +111 -0
- package/dist/orchestrator/autoFixExecutor.d.ts +3 -0
- package/dist/orchestrator/autoFixExecutor.js +63 -0
- package/dist/orchestrator/chunking.d.ts +5 -0
- package/dist/orchestrator/chunking.js +13 -0
- package/dist/orchestrator/dependencyMap.d.ts +1 -0
- package/dist/orchestrator/dependencyMap.js +82 -0
- package/dist/orchestrator/executors.d.ts +6 -0
- package/dist/orchestrator/executors.js +52 -0
- package/dist/orchestrator/flowCoverage.d.ts +4 -0
- package/dist/orchestrator/flowCoverage.js +44 -0
- package/dist/orchestrator/flowPlanning.d.ts +3 -0
- package/dist/orchestrator/flowPlanning.js +42 -0
- package/dist/orchestrator/flowRequeue.d.ts +5 -0
- package/dist/orchestrator/flowRequeue.js +58 -0
- package/dist/orchestrator/internalExecutors.d.ts +16 -0
- package/dist/orchestrator/internalExecutors.js +212 -0
- package/dist/orchestrator/nextStep.d.ts +9 -0
- package/dist/orchestrator/nextStep.js +44 -0
- package/dist/orchestrator/planning.d.ts +4 -0
- package/dist/orchestrator/planning.js +62 -0
- package/dist/orchestrator/requeue.d.ts +3 -0
- package/dist/orchestrator/requeue.js +25 -0
- package/dist/orchestrator/requeueCommand.d.ts +10 -0
- package/dist/orchestrator/requeueCommand.js +27 -0
- package/dist/orchestrator/resultIngestion.d.ts +2 -0
- package/dist/orchestrator/resultIngestion.js +13 -0
- package/dist/orchestrator/runtimeValidation.d.ts +7 -0
- package/dist/orchestrator/runtimeValidation.js +103 -0
- package/dist/orchestrator/runtimeValidationUpdate.d.ts +2 -0
- package/dist/orchestrator/runtimeValidationUpdate.js +52 -0
- package/dist/orchestrator/staleness.d.ts +2 -0
- package/dist/orchestrator/staleness.js +83 -0
- package/dist/orchestrator/state.d.ts +3 -0
- package/dist/orchestrator/state.js +85 -0
- package/dist/orchestrator/syntaxResolutionExecutor.d.ts +3 -0
- package/dist/orchestrator/syntaxResolutionExecutor.js +99 -0
- package/dist/orchestrator/taskBuilder.d.ts +12 -0
- package/dist/orchestrator/taskBuilder.js +154 -0
- package/dist/orchestrator/unitBuilder.d.ts +3 -0
- package/dist/orchestrator/unitBuilder.js +145 -0
- package/dist/orchestrator.d.ts +6 -0
- package/dist/orchestrator.js +33 -0
- package/dist/prompts/renderWorkerPrompt.d.ts +2 -0
- package/dist/prompts/renderWorkerPrompt.js +19 -0
- package/dist/providers/claudeCodeProvider.d.ts +8 -0
- package/dist/providers/claudeCodeProvider.js +20 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.js +77 -0
- package/dist/providers/localSubprocessProvider.d.ts +5 -0
- package/dist/providers/localSubprocessProvider.js +13 -0
- package/dist/providers/opencodeProvider.d.ts +8 -0
- package/dist/providers/opencodeProvider.js +15 -0
- package/dist/providers/spawnLoggedCommand.d.ts +2 -0
- package/dist/providers/spawnLoggedCommand.js +48 -0
- package/dist/providers/subprocessTemplateProvider.d.ts +8 -0
- package/dist/providers/subprocessTemplateProvider.js +41 -0
- package/dist/providers/types.d.ts +22 -0
- package/dist/providers/types.js +1 -0
- package/dist/providers/vscodeTaskProvider.d.ts +8 -0
- package/dist/providers/vscodeTaskProvider.js +14 -0
- package/dist/reporting/mergeFindings.d.ts +4 -0
- package/dist/reporting/mergeFindings.js +136 -0
- package/dist/reporting/rootCause.d.ts +11 -0
- package/dist/reporting/rootCause.js +69 -0
- package/dist/reporting/synthesis.d.ts +21 -0
- package/dist/reporting/synthesis.js +55 -0
- package/dist/supervisor/operatorHandoff.d.ts +37 -0
- package/dist/supervisor/operatorHandoff.js +144 -0
- package/dist/supervisor/runLedger.d.ts +3 -0
- package/dist/supervisor/runLedger.js +17 -0
- package/dist/supervisor/sessionConfig.d.ts +4 -0
- package/dist/supervisor/sessionConfig.js +26 -0
- package/dist/types/artifactMetadata.d.ts +8 -0
- package/dist/types/artifactMetadata.js +1 -0
- package/dist/types/auditState.d.ts +14 -0
- package/dist/types/auditState.js +1 -0
- package/dist/types/disposition.d.ts +9 -0
- package/dist/types/disposition.js +1 -0
- package/dist/types/externalAnalyzer.d.ts +16 -0
- package/dist/types/externalAnalyzer.js +1 -0
- package/dist/types/flowCoverage.d.ts +11 -0
- package/dist/types/flowCoverage.js +1 -0
- package/dist/types/flows.d.ts +11 -0
- package/dist/types/flows.js +1 -0
- package/dist/types/graph.d.ts +18 -0
- package/dist/types/graph.js +1 -0
- package/dist/types/risk.d.ts +9 -0
- package/dist/types/risk.js +1 -0
- package/dist/types/runLedger.d.ts +13 -0
- package/dist/types/runLedger.js +1 -0
- package/dist/types/runtimeValidation.d.ts +22 -0
- package/dist/types/runtimeValidation.js +1 -0
- package/dist/types/sessionConfig.d.ts +27 -0
- package/dist/types/sessionConfig.js +1 -0
- package/dist/types/surfaces.d.ts +11 -0
- package/dist/types/surfaces.js +1 -0
- package/dist/types/workerResult.d.ts +13 -0
- package/dist/types/workerResult.js +1 -0
- package/dist/types/workerSession.d.ts +13 -0
- package/dist/types/workerSession.js +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.js +1 -0
- package/dist/validation/artifacts.d.ts +3 -0
- package/dist/validation/artifacts.js +191 -0
- package/dist/validation/basic.d.ts +5 -0
- package/dist/validation/basic.js +9 -0
- package/dist/validation/sessionConfig.d.ts +6 -0
- package/dist/validation/sessionConfig.js +139 -0
- package/docs/agent-integrations.md +237 -0
- package/docs/agent-roles.md +69 -0
- package/docs/architecture.md +90 -0
- package/docs/artifacts.md +69 -0
- package/docs/bootstrap-install.md +79 -0
- package/docs/contract.md +140 -0
- package/docs/github-copilot.md +50 -0
- package/docs/model-selection.md +86 -0
- package/docs/next-steps.md +161 -0
- package/docs/packaging.md +88 -0
- package/docs/pipeline.md +152 -0
- package/docs/product-direction.md +111 -0
- package/docs/production-launch-bar.md +83 -0
- package/docs/production-readiness.md +52 -0
- package/docs/repo-layout.md +30 -0
- package/docs/run-flow.md +49 -0
- package/docs/session-config.md +232 -0
- package/docs/supervisor.md +83 -0
- package/docs/usage.md +172 -0
- package/docs/windows-setup.md +146 -0
- package/package.json +56 -0
- package/schemas/audit-code-v1alpha1.schema.json +191 -0
- package/schemas/audit_result.schema.json +48 -0
- package/schemas/audit_state.schema.json +36 -0
- package/schemas/audit_task.schema.json +49 -0
- package/schemas/blind_spot_register.schema.json +40 -0
- package/schemas/coverage_matrix.schema.json +50 -0
- package/schemas/critical_flows.schema.json +38 -0
- package/schemas/external_analyzer_results.schema.json +31 -0
- package/schemas/file_disposition.schema.json +33 -0
- package/schemas/finding.schema.json +62 -0
- package/schemas/flow_coverage.schema.json +44 -0
- package/schemas/graph_bundle.schema.json +55 -0
- package/schemas/merged_findings.schema.json +14 -0
- package/schemas/repo_manifest.schema.json +37 -0
- package/schemas/risk_register.schema.json +30 -0
- package/schemas/root_cause_clusters.schema.json +31 -0
- package/schemas/runtime_validation_report.schema.json +34 -0
- package/schemas/runtime_validation_tasks.schema.json +36 -0
- package/schemas/surface_manifest.schema.json +32 -0
- package/schemas/synthesis_report.schema.json +61 -0
- package/schemas/unit_manifest.schema.json +36 -0
- package/skills/audit-code/SKILL.md +54 -0
- package/skills/audit-code/audit-code.prompt.md +66 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function chunkLineCount(totalLines, chunkSize = 200) {
|
|
2
|
+
if (totalLines <= 0) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
const ranges = [];
|
|
6
|
+
let start = 1;
|
|
7
|
+
while (start <= totalLines) {
|
|
8
|
+
const end = Math.min(start + chunkSize - 1, totalLines);
|
|
9
|
+
ranges.push({ start, end });
|
|
10
|
+
start = end + 1;
|
|
11
|
+
}
|
|
12
|
+
return ranges;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ARTIFACT_DEPENDENCY_MAP: Record<string, string[]>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const ARTIFACT_DEPENDENCY_MAP = {
|
|
2
|
+
"repo_manifest.json": [
|
|
3
|
+
"file_disposition.json",
|
|
4
|
+
"unit_manifest.json",
|
|
5
|
+
"surface_manifest.json",
|
|
6
|
+
"graph_bundle.json",
|
|
7
|
+
"critical_flows.json",
|
|
8
|
+
"risk_register.json",
|
|
9
|
+
"coverage_matrix.json",
|
|
10
|
+
"flow_coverage.json",
|
|
11
|
+
"audit_tasks.json",
|
|
12
|
+
"requeue_tasks.json",
|
|
13
|
+
"runtime_validation_tasks.json",
|
|
14
|
+
"runtime_validation_report.json",
|
|
15
|
+
"synthesis_report.json",
|
|
16
|
+
],
|
|
17
|
+
"file_disposition.json": [
|
|
18
|
+
"unit_manifest.json",
|
|
19
|
+
"surface_manifest.json",
|
|
20
|
+
"graph_bundle.json",
|
|
21
|
+
"critical_flows.json",
|
|
22
|
+
"risk_register.json",
|
|
23
|
+
"coverage_matrix.json",
|
|
24
|
+
"flow_coverage.json",
|
|
25
|
+
"audit_tasks.json",
|
|
26
|
+
"requeue_tasks.json",
|
|
27
|
+
"runtime_validation_tasks.json",
|
|
28
|
+
"runtime_validation_report.json",
|
|
29
|
+
"synthesis_report.json",
|
|
30
|
+
],
|
|
31
|
+
"unit_manifest.json": [
|
|
32
|
+
"risk_register.json",
|
|
33
|
+
"coverage_matrix.json",
|
|
34
|
+
"audit_tasks.json",
|
|
35
|
+
"runtime_validation_tasks.json",
|
|
36
|
+
"requeue_tasks.json",
|
|
37
|
+
"synthesis_report.json",
|
|
38
|
+
],
|
|
39
|
+
"surface_manifest.json": [
|
|
40
|
+
"critical_flows.json",
|
|
41
|
+
"risk_register.json",
|
|
42
|
+
"runtime_validation_tasks.json",
|
|
43
|
+
"synthesis_report.json",
|
|
44
|
+
],
|
|
45
|
+
"critical_flows.json": [
|
|
46
|
+
"flow_coverage.json",
|
|
47
|
+
"risk_register.json",
|
|
48
|
+
"audit_tasks.json",
|
|
49
|
+
"requeue_tasks.json",
|
|
50
|
+
"runtime_validation_tasks.json",
|
|
51
|
+
"runtime_validation_report.json",
|
|
52
|
+
"synthesis_report.json",
|
|
53
|
+
],
|
|
54
|
+
"audit_results.jsonl": [
|
|
55
|
+
"coverage_matrix.json",
|
|
56
|
+
"flow_coverage.json",
|
|
57
|
+
"requeue_tasks.json",
|
|
58
|
+
"runtime_validation_tasks.json",
|
|
59
|
+
"runtime_validation_report.json",
|
|
60
|
+
"merged_findings.json",
|
|
61
|
+
"root_cause_clusters.json",
|
|
62
|
+
"synthesis_report.json",
|
|
63
|
+
],
|
|
64
|
+
"coverage_matrix.json": [
|
|
65
|
+
"flow_coverage.json",
|
|
66
|
+
"requeue_tasks.json",
|
|
67
|
+
"runtime_validation_tasks.json",
|
|
68
|
+
"runtime_validation_report.json",
|
|
69
|
+
"synthesis_report.json",
|
|
70
|
+
],
|
|
71
|
+
"flow_coverage.json": [
|
|
72
|
+
"requeue_tasks.json",
|
|
73
|
+
"runtime_validation_tasks.json",
|
|
74
|
+
"runtime_validation_report.json",
|
|
75
|
+
"synthesis_report.json",
|
|
76
|
+
],
|
|
77
|
+
"runtime_validation_report.json": [
|
|
78
|
+
"merged_findings.json",
|
|
79
|
+
"root_cause_clusters.json",
|
|
80
|
+
"synthesis_report.json",
|
|
81
|
+
],
|
|
82
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const EXECUTOR_REGISTRY = [
|
|
2
|
+
{
|
|
3
|
+
id: "intake_executor",
|
|
4
|
+
obligation_ids: ["repo_manifest", "file_disposition"],
|
|
5
|
+
description: "Create intake artifacts for repository discovery and disposition.",
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "structure_executor",
|
|
9
|
+
obligation_ids: ["structure_artifacts"],
|
|
10
|
+
description: "Build structure artifacts such as units, surfaces, graphs, flows, and risk.",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "planning_executor",
|
|
14
|
+
obligation_ids: ["planning_artifacts"],
|
|
15
|
+
description: "Build coverage, tasks, runtime validation planning artifacts, and related planning outputs.",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "result_ingestion_executor",
|
|
19
|
+
obligation_ids: ["audit_results_ingested"],
|
|
20
|
+
description: "Ingest available audit result artifacts and refresh dependent coverage artifacts.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "runtime_validation_update_executor",
|
|
24
|
+
obligation_ids: ["runtime_validation_current"],
|
|
25
|
+
description: "Merge runtime validation evidence updates when provided.",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "synthesis_executor",
|
|
29
|
+
obligation_ids: ["synthesis_current"],
|
|
30
|
+
description: "Refresh merged findings, clusters, and synthesis outputs.",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "external_analyzer_import_executor",
|
|
34
|
+
obligation_ids: [],
|
|
35
|
+
description: "Import normalized external analyzer results into the artifact set.",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "auto_fix_executor",
|
|
39
|
+
obligation_ids: ["auto_fixes_applied"],
|
|
40
|
+
description: "Run configured deterministic code formatters to apply surface-level fixes automatically.",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "syntax_resolution_executor",
|
|
44
|
+
obligation_ids: ["syntax_resolved"],
|
|
45
|
+
description: "Run deterministic static analysis/compilers and extract any remaining unfixable syntactical errors into external signals.",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "agent",
|
|
49
|
+
obligation_ids: ["audit_tasks_completed"],
|
|
50
|
+
description: "Pause the pipeline and delegate pending codebase review tasks or syntax resolutions to the active LLM agent.",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CoverageMatrix } from "../types.js";
|
|
2
|
+
import type { FlowCoverageManifest } from "../types/flowCoverage.js";
|
|
3
|
+
import type { CriticalFlowManifest } from "../types/flows.js";
|
|
4
|
+
export declare function buildFlowCoverage(criticalFlows: CriticalFlowManifest, coverageMatrix: CoverageMatrix): FlowCoverageManifest;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function lensSetForFlow(concerns) {
|
|
2
|
+
const allowed = [
|
|
3
|
+
"security",
|
|
4
|
+
"reliability",
|
|
5
|
+
"correctness",
|
|
6
|
+
"data_integrity",
|
|
7
|
+
"operability",
|
|
8
|
+
"performance",
|
|
9
|
+
];
|
|
10
|
+
return concerns.filter((concern) => allowed.includes(concern));
|
|
11
|
+
}
|
|
12
|
+
export function buildFlowCoverage(criticalFlows, coverageMatrix) {
|
|
13
|
+
const flows = criticalFlows.flows.map((flow) => {
|
|
14
|
+
const required = lensSetForFlow(flow.concerns);
|
|
15
|
+
const completed = new Set();
|
|
16
|
+
for (const path of flow.paths) {
|
|
17
|
+
const record = coverageMatrix.files.find((file) => file.path === path);
|
|
18
|
+
if (!record || record.audit_status === "excluded") {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
for (const lens of record.completed_lenses) {
|
|
22
|
+
if (required.includes(lens)) {
|
|
23
|
+
completed.add(lens);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const completed_lenses = [...completed];
|
|
28
|
+
const status = required.length > 0 &&
|
|
29
|
+
required.every((lens) => completed_lenses.includes(lens))
|
|
30
|
+
? "complete"
|
|
31
|
+
: completed_lenses.length > 0
|
|
32
|
+
? "partial"
|
|
33
|
+
: "pending";
|
|
34
|
+
return {
|
|
35
|
+
flow_id: flow.id,
|
|
36
|
+
paths: flow.paths,
|
|
37
|
+
required_lenses: required,
|
|
38
|
+
completed_lenses,
|
|
39
|
+
status,
|
|
40
|
+
notes: [`Derived from ${flow.paths.length} path(s).`],
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
return { flows };
|
|
44
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AuditTask } from "../types.js";
|
|
2
|
+
import type { CriticalFlowManifest } from "../types/flows.js";
|
|
3
|
+
export declare function buildFlowAwareTaskAugmentations(existingTasks: AuditTask[], criticalFlows: CriticalFlowManifest, lineIndex: Record<string, number>): AuditTask[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const DEFAULT_FLOW_LENS_PRIORITY = [
|
|
2
|
+
"security",
|
|
3
|
+
"reliability",
|
|
4
|
+
"correctness",
|
|
5
|
+
];
|
|
6
|
+
function normalizeTaskSignature(task) {
|
|
7
|
+
const path = task.file_paths.join(",");
|
|
8
|
+
const range = task.line_ranges?.map((r) => `${r.path}:${r.start}-${r.end}`).join(",") ??
|
|
9
|
+
"full";
|
|
10
|
+
return `${task.lens}|${path}|${range}`;
|
|
11
|
+
}
|
|
12
|
+
export function buildFlowAwareTaskAugmentations(existingTasks, criticalFlows, lineIndex) {
|
|
13
|
+
const seenTaskIds = new Set(existingTasks.map((task) => task.task_id));
|
|
14
|
+
const existingSignatures = new Set(existingTasks.map(normalizeTaskSignature));
|
|
15
|
+
const extraTasks = [];
|
|
16
|
+
for (const flow of criticalFlows.flows) {
|
|
17
|
+
const desiredLenses = flow.concerns.filter((concern) => DEFAULT_FLOW_LENS_PRIORITY.includes(concern));
|
|
18
|
+
for (const path of flow.paths) {
|
|
19
|
+
const totalLines = lineIndex[path] ?? 0;
|
|
20
|
+
for (const lens of desiredLenses) {
|
|
21
|
+
const candidate = {
|
|
22
|
+
task_id: `flow:${flow.id}:${lens}:${path}`,
|
|
23
|
+
unit_id: `flow:${flow.id}`,
|
|
24
|
+
pass_id: `flow-pass:${lens}`,
|
|
25
|
+
lens,
|
|
26
|
+
file_paths: [path],
|
|
27
|
+
line_ranges: totalLines > 0 ? [{ path, start: 1, end: totalLines }] : undefined,
|
|
28
|
+
rationale: `Flow-aware audit for ${path} because it participates in critical flow ${flow.id} under the ${lens} lens.`,
|
|
29
|
+
};
|
|
30
|
+
const signature = normalizeTaskSignature(candidate);
|
|
31
|
+
if (seenTaskIds.has(candidate.task_id) ||
|
|
32
|
+
existingSignatures.has(signature)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
extraTasks.push(candidate);
|
|
36
|
+
seenTaskIds.add(candidate.task_id);
|
|
37
|
+
existingSignatures.add(signature);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return extraTasks;
|
|
42
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExternalAnalyzerResults } from "../types/externalAnalyzer.js";
|
|
2
|
+
import type { AuditTask } from "../types.js";
|
|
3
|
+
import type { FlowCoverageManifest } from "../types/flowCoverage.js";
|
|
4
|
+
import type { CriticalFlowManifest } from "../types/flows.js";
|
|
5
|
+
export declare function buildFlowRequeueTasks(criticalFlows: CriticalFlowManifest, flowCoverage: FlowCoverageManifest, externalAnalyzerResults?: ExternalAnalyzerResults): AuditTask[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function isLens(value) {
|
|
2
|
+
return [
|
|
3
|
+
"correctness",
|
|
4
|
+
"architecture",
|
|
5
|
+
"maintainability",
|
|
6
|
+
"security",
|
|
7
|
+
"reliability",
|
|
8
|
+
"performance",
|
|
9
|
+
"data_integrity",
|
|
10
|
+
"tests",
|
|
11
|
+
"operability",
|
|
12
|
+
"config_deployment",
|
|
13
|
+
].includes(value);
|
|
14
|
+
}
|
|
15
|
+
function taskPriority(hasExternalSignal, lens) {
|
|
16
|
+
if (hasExternalSignal &&
|
|
17
|
+
(lens === "security" || lens === "data_integrity" || lens === "reliability")) {
|
|
18
|
+
return "high";
|
|
19
|
+
}
|
|
20
|
+
return hasExternalSignal ? "medium" : "low";
|
|
21
|
+
}
|
|
22
|
+
export function buildFlowRequeueTasks(criticalFlows, flowCoverage, externalAnalyzerResults) {
|
|
23
|
+
const flowMap = new Map(criticalFlows.flows.map((flow) => [flow.id, flow]));
|
|
24
|
+
const tasks = [];
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const externalPaths = new Set((externalAnalyzerResults?.results ?? []).map((item) => item.path));
|
|
27
|
+
for (const record of flowCoverage.flows) {
|
|
28
|
+
const flow = flowMap.get(record.flow_id);
|
|
29
|
+
if (!flow) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const missingLenses = record.required_lenses.filter((lens) => !record.completed_lenses.includes(lens));
|
|
33
|
+
for (const lensName of missingLenses) {
|
|
34
|
+
if (!isLens(lensName)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (const path of flow.paths) {
|
|
38
|
+
const signature = `${flow.id}|${lensName}|${path}`;
|
|
39
|
+
if (seen.has(signature)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
seen.add(signature);
|
|
43
|
+
const hasExternalSignal = externalPaths.has(path);
|
|
44
|
+
tasks.push({
|
|
45
|
+
task_id: `flow-requeue:${flow.id}:${lensName}:${path}`,
|
|
46
|
+
unit_id: flow.id,
|
|
47
|
+
pass_id: `flow-requeue:${lensName}`,
|
|
48
|
+
lens: lensName,
|
|
49
|
+
file_paths: [path],
|
|
50
|
+
rationale: `Requeue ${path} because critical flow ${flow.id} is still missing the ${lensName} lens.${hasExternalSignal ? " External analyzer signals make this follow-up higher priority." : ""}`,
|
|
51
|
+
priority: taskPriority(hasExternalSignal, lensName),
|
|
52
|
+
tags: hasExternalSignal ? ["external_analyzer_signal"] : [],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return tasks;
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArtifactBundle } from "../io/artifacts.js";
|
|
2
|
+
import type { AuditResult } from "../types.js";
|
|
3
|
+
import type { RuntimeValidationReport } from "../types/runtimeValidation.js";
|
|
4
|
+
import type { ExternalAnalyzerResults } from "../types/externalAnalyzer.js";
|
|
5
|
+
export interface ExecutorRunResult {
|
|
6
|
+
updated: ArtifactBundle;
|
|
7
|
+
artifacts_written: string[];
|
|
8
|
+
progress_summary: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runIntakeExecutor(bundle: ArtifactBundle, root: string): Promise<ExecutorRunResult>;
|
|
11
|
+
export declare function runStructureExecutor(bundle: ArtifactBundle): ExecutorRunResult;
|
|
12
|
+
export declare function runPlanningExecutor(bundle: ArtifactBundle, lineIndex?: Record<string, number>): ExecutorRunResult;
|
|
13
|
+
export declare function runResultIngestionExecutor(bundle: ArtifactBundle, results: AuditResult[]): ExecutorRunResult;
|
|
14
|
+
export declare function runRuntimeValidationUpdateExecutor(bundle: ArtifactBundle, updates: RuntimeValidationReport): ExecutorRunResult;
|
|
15
|
+
export declare function runSynthesisExecutor(bundle: ArtifactBundle, results?: AuditResult[]): ExecutorRunResult;
|
|
16
|
+
export declare function runExternalAnalyzerImportExecutor(bundle: ArtifactBundle, externalResults: ExternalAnalyzerResults): ExecutorRunResult;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { buildFileDisposition } from "../extractors/disposition.js";
|
|
2
|
+
import { buildGraphBundle } from "../extractors/graph.js";
|
|
3
|
+
import { buildCriticalFlowManifest } from "../extractors/flows.js";
|
|
4
|
+
import { buildRiskRegister } from "../extractors/risk.js";
|
|
5
|
+
import { buildSurfaceManifest } from "../extractors/surfaces.js";
|
|
6
|
+
import { initializeCoverageFromPlan } from "./planning.js";
|
|
7
|
+
import { buildFlowCoverage } from "./flowCoverage.js";
|
|
8
|
+
import { buildFlowAwareTaskAugmentations } from "./flowPlanning.js";
|
|
9
|
+
import { buildRequeuePayload } from "./requeueCommand.js";
|
|
10
|
+
import { buildRuntimeValidationTasks, buildPlaceholderRuntimeValidationReport, mergeRuntimeValidationReport, } from "./runtimeValidation.js";
|
|
11
|
+
import { buildSynthesisReport } from "../reporting/synthesis.js";
|
|
12
|
+
import { buildChunkedAuditTasks, buildExternalSignalTasks, } from "./taskBuilder.js";
|
|
13
|
+
import { buildUnitManifest } from "./unitBuilder.js";
|
|
14
|
+
import { buildRepoManifestFromFs } from "../extractors/fsIntake.js";
|
|
15
|
+
import { loadIgnoreFile } from "../extractors/ignore.js";
|
|
16
|
+
import { ingestAuditResults } from "./resultIngestion.js";
|
|
17
|
+
import { updateRuntimeValidationReport } from "./runtimeValidationUpdate.js";
|
|
18
|
+
function preserveOrPlaceholder(tasks, existing) {
|
|
19
|
+
return existing
|
|
20
|
+
? mergeRuntimeValidationReport(tasks, existing)
|
|
21
|
+
: buildPlaceholderRuntimeValidationReport(tasks);
|
|
22
|
+
}
|
|
23
|
+
export async function runIntakeExecutor(bundle, root) {
|
|
24
|
+
const ignore = await loadIgnoreFile(root);
|
|
25
|
+
const repoManifest = await buildRepoManifestFromFs({
|
|
26
|
+
root,
|
|
27
|
+
ignore,
|
|
28
|
+
hash_files: false,
|
|
29
|
+
});
|
|
30
|
+
const disposition = buildFileDisposition(repoManifest);
|
|
31
|
+
return {
|
|
32
|
+
updated: {
|
|
33
|
+
...bundle,
|
|
34
|
+
repo_manifest: repoManifest,
|
|
35
|
+
file_disposition: disposition,
|
|
36
|
+
},
|
|
37
|
+
artifacts_written: ["repo_manifest.json", "file_disposition.json"],
|
|
38
|
+
progress_summary: `Created intake artifacts for ${repoManifest.files.length} files.`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function runStructureExecutor(bundle) {
|
|
42
|
+
if (!bundle.repo_manifest) {
|
|
43
|
+
throw new Error("Cannot run structure executor without repo_manifest");
|
|
44
|
+
}
|
|
45
|
+
const externalAnalyzerResults = bundle.external_analyzer_results;
|
|
46
|
+
const disposition = bundle.file_disposition ?? buildFileDisposition(bundle.repo_manifest);
|
|
47
|
+
const unitManifest = buildUnitManifest(bundle.repo_manifest, disposition);
|
|
48
|
+
const surfaceManifest = buildSurfaceManifest(bundle.repo_manifest, disposition);
|
|
49
|
+
const criticalFlows = buildCriticalFlowManifest(bundle.repo_manifest, surfaceManifest, disposition);
|
|
50
|
+
const graphBundle = buildGraphBundle(bundle.repo_manifest, disposition);
|
|
51
|
+
const riskRegister = buildRiskRegister(unitManifest, criticalFlows, externalAnalyzerResults);
|
|
52
|
+
return {
|
|
53
|
+
updated: {
|
|
54
|
+
...bundle,
|
|
55
|
+
file_disposition: disposition,
|
|
56
|
+
unit_manifest: unitManifest,
|
|
57
|
+
surface_manifest: surfaceManifest,
|
|
58
|
+
graph_bundle: graphBundle,
|
|
59
|
+
critical_flows: criticalFlows,
|
|
60
|
+
risk_register: riskRegister,
|
|
61
|
+
},
|
|
62
|
+
artifacts_written: [
|
|
63
|
+
"file_disposition.json",
|
|
64
|
+
"unit_manifest.json",
|
|
65
|
+
"surface_manifest.json",
|
|
66
|
+
"graph_bundle.json",
|
|
67
|
+
"critical_flows.json",
|
|
68
|
+
"risk_register.json",
|
|
69
|
+
],
|
|
70
|
+
progress_summary: `Built structure artifacts for ${unitManifest.units.length} units and ${criticalFlows.flows.length} critical flows.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function runPlanningExecutor(bundle, lineIndex = {}) {
|
|
74
|
+
if (!bundle.repo_manifest) {
|
|
75
|
+
throw new Error("Cannot run planning executor without repo_manifest");
|
|
76
|
+
}
|
|
77
|
+
if (!bundle.file_disposition ||
|
|
78
|
+
!bundle.unit_manifest ||
|
|
79
|
+
!bundle.surface_manifest ||
|
|
80
|
+
!bundle.critical_flows ||
|
|
81
|
+
!bundle.risk_register) {
|
|
82
|
+
throw new Error("Cannot run planning executor without current structure artifacts");
|
|
83
|
+
}
|
|
84
|
+
const externalAnalyzerResults = bundle.external_analyzer_results;
|
|
85
|
+
const coverage = initializeCoverageFromPlan(bundle.repo_manifest, bundle.unit_manifest, bundle.file_disposition, externalAnalyzerResults);
|
|
86
|
+
const flowCoverage = buildFlowCoverage(bundle.critical_flows, coverage);
|
|
87
|
+
const runtimeValidationTasks = buildRuntimeValidationTasks(bundle.unit_manifest, bundle.critical_flows, flowCoverage);
|
|
88
|
+
const runtimeValidationReport = preserveOrPlaceholder(runtimeValidationTasks, bundle.runtime_validation_report);
|
|
89
|
+
const baseTasks = buildChunkedAuditTasks(bundle.unit_manifest, lineIndex, {
|
|
90
|
+
chunk_size: 200,
|
|
91
|
+
external_analyzer_results: externalAnalyzerResults,
|
|
92
|
+
});
|
|
93
|
+
const analyzerTasks = buildExternalSignalTasks(coverage, lineIndex, externalAnalyzerResults);
|
|
94
|
+
const flowTasks = buildFlowAwareTaskAugmentations([...baseTasks, ...analyzerTasks], bundle.critical_flows, lineIndex);
|
|
95
|
+
const auditTasks = [...baseTasks, ...analyzerTasks, ...flowTasks];
|
|
96
|
+
const requeuePayload = buildRequeuePayload(coverage, bundle.critical_flows, flowCoverage, externalAnalyzerResults);
|
|
97
|
+
return {
|
|
98
|
+
updated: {
|
|
99
|
+
...bundle,
|
|
100
|
+
coverage_matrix: coverage,
|
|
101
|
+
flow_coverage: flowCoverage,
|
|
102
|
+
runtime_validation_tasks: runtimeValidationTasks,
|
|
103
|
+
runtime_validation_report: runtimeValidationReport,
|
|
104
|
+
audit_tasks: auditTasks,
|
|
105
|
+
requeue_tasks: requeuePayload.tasks,
|
|
106
|
+
},
|
|
107
|
+
artifacts_written: [
|
|
108
|
+
"coverage_matrix.json",
|
|
109
|
+
"flow_coverage.json",
|
|
110
|
+
"runtime_validation_tasks.json",
|
|
111
|
+
"runtime_validation_report.json",
|
|
112
|
+
"audit_tasks.json",
|
|
113
|
+
"requeue_tasks.json",
|
|
114
|
+
],
|
|
115
|
+
progress_summary: `Built planning artifacts; generated ${auditTasks.length} tasks and ${requeuePayload.task_count} requeue tasks.${externalAnalyzerResults?.results.length ? ` External analyzer signals influenced lenses and produced ${analyzerTasks.length} dedicated follow-up task(s).` : ""}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function runResultIngestionExecutor(bundle, results) {
|
|
119
|
+
if (!bundle.coverage_matrix) {
|
|
120
|
+
throw new Error("Cannot ingest results without coverage_matrix");
|
|
121
|
+
}
|
|
122
|
+
ingestAuditResults(bundle.coverage_matrix, results);
|
|
123
|
+
const flowCoverage = bundle.critical_flows
|
|
124
|
+
? buildFlowCoverage(bundle.critical_flows, bundle.coverage_matrix)
|
|
125
|
+
: bundle.flow_coverage;
|
|
126
|
+
const runtimeValidationTasks = bundle.unit_manifest
|
|
127
|
+
? buildRuntimeValidationTasks(bundle.unit_manifest, bundle.critical_flows, flowCoverage)
|
|
128
|
+
: bundle.runtime_validation_tasks;
|
|
129
|
+
const runtimeValidationReport = runtimeValidationTasks
|
|
130
|
+
? preserveOrPlaceholder(runtimeValidationTasks, bundle.runtime_validation_report)
|
|
131
|
+
: bundle.runtime_validation_report;
|
|
132
|
+
const requeuePayload = bundle.coverage_matrix
|
|
133
|
+
? buildRequeuePayload(bundle.coverage_matrix, bundle.critical_flows, flowCoverage, bundle.external_analyzer_results)
|
|
134
|
+
: { tasks: [], task_count: 0 };
|
|
135
|
+
const mergedResults = [...(bundle.audit_results ?? []), ...results];
|
|
136
|
+
const synthesisReport = buildSynthesisReport(mergedResults, runtimeValidationReport, bundle.external_analyzer_results);
|
|
137
|
+
return {
|
|
138
|
+
updated: {
|
|
139
|
+
...bundle,
|
|
140
|
+
coverage_matrix: bundle.coverage_matrix,
|
|
141
|
+
flow_coverage: flowCoverage,
|
|
142
|
+
runtime_validation_tasks: runtimeValidationTasks,
|
|
143
|
+
runtime_validation_report: runtimeValidationReport,
|
|
144
|
+
audit_results: mergedResults,
|
|
145
|
+
requeue_tasks: requeuePayload.tasks,
|
|
146
|
+
synthesis_report: synthesisReport,
|
|
147
|
+
},
|
|
148
|
+
artifacts_written: [
|
|
149
|
+
"coverage_matrix.json",
|
|
150
|
+
"flow_coverage.json",
|
|
151
|
+
"runtime_validation_tasks.json",
|
|
152
|
+
"runtime_validation_report.json",
|
|
153
|
+
"audit_results.jsonl",
|
|
154
|
+
"requeue_tasks.json",
|
|
155
|
+
"synthesis_report.json",
|
|
156
|
+
],
|
|
157
|
+
progress_summary: `Ingested ${results.length} audit result entries and refreshed dependent artifacts.`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
export function runRuntimeValidationUpdateExecutor(bundle, updates) {
|
|
161
|
+
if (!bundle.runtime_validation_tasks) {
|
|
162
|
+
throw new Error("Cannot update runtime validation without runtime_validation_tasks");
|
|
163
|
+
}
|
|
164
|
+
const existingReport = bundle.runtime_validation_report ??
|
|
165
|
+
buildPlaceholderRuntimeValidationReport(bundle.runtime_validation_tasks);
|
|
166
|
+
const mergedReport = updateRuntimeValidationReport(bundle.runtime_validation_tasks, existingReport, updates);
|
|
167
|
+
const synthesisReport = buildSynthesisReport(bundle.audit_results ?? [], mergedReport, bundle.external_analyzer_results);
|
|
168
|
+
return {
|
|
169
|
+
updated: {
|
|
170
|
+
...bundle,
|
|
171
|
+
runtime_validation_report: mergedReport,
|
|
172
|
+
synthesis_report: synthesisReport,
|
|
173
|
+
},
|
|
174
|
+
artifacts_written: [
|
|
175
|
+
"runtime_validation_report.json",
|
|
176
|
+
"synthesis_report.json",
|
|
177
|
+
],
|
|
178
|
+
progress_summary: `Merged ${updates.results.length} runtime validation updates.`,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export function runSynthesisExecutor(bundle, results) {
|
|
182
|
+
const finalResults = results ?? bundle.audit_results ?? [];
|
|
183
|
+
const synthesisReport = buildSynthesisReport(finalResults, bundle.runtime_validation_report, bundle.external_analyzer_results);
|
|
184
|
+
const mergedFindings = { findings: synthesisReport.merged_findings };
|
|
185
|
+
const rootCauseClusters = { clusters: synthesisReport.root_cause_clusters };
|
|
186
|
+
return {
|
|
187
|
+
updated: {
|
|
188
|
+
...bundle,
|
|
189
|
+
audit_results: finalResults,
|
|
190
|
+
merged_findings: mergedFindings,
|
|
191
|
+
root_cause_clusters: rootCauseClusters,
|
|
192
|
+
synthesis_report: synthesisReport,
|
|
193
|
+
},
|
|
194
|
+
artifacts_written: [
|
|
195
|
+
"merged_findings.json",
|
|
196
|
+
"root_cause_clusters.json",
|
|
197
|
+
"synthesis_report.json",
|
|
198
|
+
],
|
|
199
|
+
progress_summary: `Refreshed synthesis for ${finalResults.length} audit result entries.`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function runExternalAnalyzerImportExecutor(bundle, externalResults) {
|
|
203
|
+
const summary = `Imported ${externalResults.results.length} normalized findings from ${externalResults.tool}.`;
|
|
204
|
+
return {
|
|
205
|
+
updated: {
|
|
206
|
+
...bundle,
|
|
207
|
+
external_analyzer_results: externalResults,
|
|
208
|
+
},
|
|
209
|
+
artifacts_written: ["external_analyzer_results.json"],
|
|
210
|
+
progress_summary: summary,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArtifactBundle } from "../io/artifacts.js";
|
|
2
|
+
import type { AuditState } from "../types/auditState.js";
|
|
3
|
+
export interface NextStepDecision {
|
|
4
|
+
state: AuditState;
|
|
5
|
+
selected_obligation: string | null;
|
|
6
|
+
selected_executor: string | null;
|
|
7
|
+
reason: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function decideNextStep(bundle: ArtifactBundle): NextStepDecision;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EXECUTOR_REGISTRY } from "./executors.js";
|
|
2
|
+
import { deriveAuditState } from "./state.js";
|
|
3
|
+
const PRIORITY = [
|
|
4
|
+
"repo_manifest",
|
|
5
|
+
"file_disposition",
|
|
6
|
+
"auto_fixes_applied",
|
|
7
|
+
"syntax_resolved",
|
|
8
|
+
"structure_artifacts",
|
|
9
|
+
"planning_artifacts",
|
|
10
|
+
"audit_tasks_completed",
|
|
11
|
+
"audit_results_ingested",
|
|
12
|
+
"runtime_validation_current",
|
|
13
|
+
"synthesis_current",
|
|
14
|
+
];
|
|
15
|
+
function findObligation(obligations) {
|
|
16
|
+
for (const id of PRIORITY) {
|
|
17
|
+
const item = obligations.find((o) => o.id === id);
|
|
18
|
+
if (item && (item.state === "missing" || item.state === "stale")) {
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
export function decideNextStep(bundle) {
|
|
25
|
+
const state = deriveAuditState(bundle);
|
|
26
|
+
const next = findObligation(state.obligations);
|
|
27
|
+
if (!next) {
|
|
28
|
+
return {
|
|
29
|
+
state,
|
|
30
|
+
selected_obligation: null,
|
|
31
|
+
selected_executor: null,
|
|
32
|
+
reason: state.status === "complete"
|
|
33
|
+
? "All known obligations are currently satisfied."
|
|
34
|
+
: "No actionable missing obligation was found.",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const executor = EXECUTOR_REGISTRY.find((item) => item.obligation_ids.includes(next.id));
|
|
38
|
+
return {
|
|
39
|
+
state,
|
|
40
|
+
selected_obligation: next.id,
|
|
41
|
+
selected_executor: executor?.id ?? null,
|
|
42
|
+
reason: `Selected highest-priority actionable obligation ${next.id}.`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CoverageMatrix, RepoManifest, UnitManifest } from "../types.js";
|
|
2
|
+
import type { FileDisposition } from "../types/disposition.js";
|
|
3
|
+
import type { ExternalAnalyzerResults } from "../types/externalAnalyzer.js";
|
|
4
|
+
export declare function initializeCoverageFromPlan(repoManifest: RepoManifest, unitManifest: UnitManifest, disposition: FileDisposition, externalAnalyzerResults?: ExternalAnalyzerResults): CoverageMatrix;
|