auditor-lambda 0.3.3 → 0.3.5

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 (47) hide show
  1. package/README.md +6 -1
  2. package/audit-code-wrapper-lib.mjs +87 -7
  3. package/dist/cli.js +517 -91
  4. package/dist/extractors/graph.d.ts +5 -1
  5. package/dist/extractors/graph.js +223 -3
  6. package/dist/extractors/pathPatterns.d.ts +3 -2
  7. package/dist/extractors/pathPatterns.js +97 -24
  8. package/dist/io/artifacts.d.ts +5 -0
  9. package/dist/io/artifacts.js +2 -0
  10. package/dist/orchestrator/advance.js +1 -1
  11. package/dist/orchestrator/dependencyMap.js +18 -0
  12. package/dist/orchestrator/fileAnchors.d.ts +32 -0
  13. package/dist/orchestrator/fileAnchors.js +217 -0
  14. package/dist/orchestrator/internalExecutors.d.ts +1 -1
  15. package/dist/orchestrator/internalExecutors.js +120 -33
  16. package/dist/orchestrator/reviewPackets.d.ts +14 -0
  17. package/dist/orchestrator/reviewPackets.js +310 -0
  18. package/dist/orchestrator/selectiveDeepening.d.ts +14 -0
  19. package/dist/orchestrator/selectiveDeepening.js +392 -0
  20. package/dist/orchestrator/state.js +6 -1
  21. package/dist/orchestrator/taskBuilder.d.ts +16 -0
  22. package/dist/orchestrator/taskBuilder.js +68 -11
  23. package/dist/prompts/renderWorkerPrompt.js +2 -1
  24. package/dist/providers/claudeCodeProvider.js +3 -1
  25. package/dist/providers/index.js +2 -1
  26. package/dist/supervisor/operatorHandoff.js +22 -11
  27. package/dist/types/graph.d.ts +1 -0
  28. package/dist/types/reviewPlanning.d.ts +41 -0
  29. package/dist/types/reviewPlanning.js +1 -0
  30. package/dist/types/sessionConfig.d.ts +1 -0
  31. package/dist/validation/artifacts.js +13 -0
  32. package/dist/validation/auditResults.js +50 -2
  33. package/dist/validation/sessionConfig.js +5 -0
  34. package/docs/agent-integrations.md +4 -1
  35. package/docs/bootstrap-install.md +3 -0
  36. package/docs/contract.md +3 -0
  37. package/docs/dispatch-implementation-plan.md +220 -489
  38. package/docs/next-steps.md +13 -8
  39. package/docs/product-direction.md +5 -3
  40. package/docs/run-flow.md +25 -30
  41. package/docs/session-config.md +15 -4
  42. package/docs/supervisor.md +5 -3
  43. package/docs/workflow-refactor-brief.md +114 -176
  44. package/package.json +1 -1
  45. package/schemas/finding.schema.json +1 -15
  46. package/schemas/graph_bundle.schema.json +16 -0
  47. package/skills/audit-code/audit-code.prompt.md +11 -6
@@ -69,13 +69,7 @@ function buildSuggestedInputs(artifactsDir, status, isConfigError, activeReviewR
69
69
  return [];
70
70
  }
71
71
  if (activeReviewRun) {
72
- return [
73
- {
74
- flag: "--results",
75
- suggested_path: activeReviewRun.audit_results_path,
76
- description: "Write structured audit-review results for the currently dispatched run, then execute the exact worker command below to ingest them.",
77
- },
78
- ];
72
+ return [];
79
73
  }
80
74
  const incomingDir = join(artifactsDir, INCOMING_DIRNAME);
81
75
  return [
@@ -101,12 +95,21 @@ function buildSuggestedInputs(artifactsDir, status, isConfigError, activeReviewR
101
95
  },
102
96
  ];
103
97
  }
104
- function buildSuggestedCommands(suggestedInputs, status, activeReviewRun) {
98
+ function buildSuggestedCommands(artifactsDir, suggestedInputs, status, activeReviewRun) {
105
99
  if (status !== BLOCKED_STATUS) {
106
100
  return [];
107
101
  }
108
102
  if (activeReviewRun) {
109
- return [renderShellCommand(activeReviewRun.worker_command)];
103
+ return [
104
+ renderShellCommand([
105
+ "audit-code",
106
+ "prepare-dispatch",
107
+ "--run-id",
108
+ activeReviewRun.run_id,
109
+ "--artifacts-dir",
110
+ artifactsDir,
111
+ ]),
112
+ ];
110
113
  }
111
114
  return suggestedInputs.map((item) => `audit-code ${item.flag} ${quoteShellPath(item.suggested_path)}`);
112
115
  }
@@ -216,17 +219,25 @@ export function buildAuditCodeHandoff(params) {
216
219
  summary: buildSummary(params.state.status, params.providerName ?? null, params.progressSummary),
217
220
  pending_obligations: buildPendingObligations(params.state),
218
221
  suggested_inputs: suggestedInputs,
219
- suggested_commands: buildSuggestedCommands(suggestedInputs, params.state.status, params.activeReviewRun),
222
+ suggested_commands: buildSuggestedCommands(params.artifactsDir, suggestedInputs, params.state.status, params.activeReviewRun),
220
223
  interactive_provider_hint: buildInteractiveProviderHint(params.state.status, params.providerName ?? null, artifactPaths.session_config, isConfigError),
221
224
  artifact_paths: artifactPaths,
222
225
  active_review_run: params.activeReviewRun,
223
226
  };
224
227
  // Add quick_start command and file map when blocked for review
225
228
  if (params.state.status === BLOCKED_STATUS && params.activeReviewRun) {
226
- handoff.quick_start = `audit-code worker-run --task ${params.activeReviewRun.task_path}`;
229
+ handoff.quick_start = renderShellCommand([
230
+ "audit-code",
231
+ "prepare-dispatch",
232
+ "--run-id",
233
+ params.activeReviewRun.run_id,
234
+ "--artifacts-dir",
235
+ params.artifactsDir,
236
+ ]);
227
237
  handoff.file_map = {
228
238
  current_task: artifactPaths.current_task,
229
239
  current_prompt: artifactPaths.current_prompt,
240
+ dispatch_plan: join(params.artifactsDir, "runs", params.activeReviewRun.run_id, "dispatch-plan.json"),
230
241
  audit_results: params.activeReviewRun.audit_results_path,
231
242
  final_report: join(params.root, "audit-report.md"),
232
243
  };
@@ -12,6 +12,7 @@ export interface GraphBundle {
12
12
  graphs: {
13
13
  imports?: GraphEdge[];
14
14
  calls?: GraphEdge[];
15
+ references?: GraphEdge[];
15
16
  routes?: RouteEdge[];
16
17
  [key: string]: unknown;
17
18
  };
@@ -0,0 +1,41 @@
1
+ import type { AuditTask, Lens } from "../types.js";
2
+ export interface ReviewPacket {
3
+ packet_id: string;
4
+ task_ids: string[];
5
+ unit_ids: string[];
6
+ pass_ids: string[];
7
+ lenses: Lens[];
8
+ file_paths: string[];
9
+ file_line_counts: Record<string, number>;
10
+ total_lines: number;
11
+ priority: NonNullable<AuditTask["priority"]>;
12
+ tags?: string[];
13
+ rationale: string;
14
+ estimated_tokens: number;
15
+ }
16
+ export interface AuditPlanMetrics {
17
+ generated_at: string;
18
+ task_count: number;
19
+ packet_count: number;
20
+ estimated_agent_reduction: number;
21
+ estimated_agent_reduction_ratio: number;
22
+ unique_file_count: number;
23
+ task_file_reference_count: number;
24
+ repeated_file_reference_count: number;
25
+ total_task_lines: number;
26
+ total_packet_lines: number;
27
+ repeated_line_reference_count: number;
28
+ min_task_lines: number;
29
+ max_task_lines: number;
30
+ average_task_lines: number;
31
+ largest_task_id?: string;
32
+ largest_packet_id?: string;
33
+ lens_task_counts: Partial<Record<Lens, number>>;
34
+ priority_task_counts: Record<NonNullable<AuditTask["priority"]>, number>;
35
+ packet_size: {
36
+ single_task_packets: number;
37
+ multi_task_packets: number;
38
+ max_tasks_per_packet: number;
39
+ max_files_per_packet: number;
40
+ };
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -10,6 +10,7 @@ export interface SubprocessTemplateConfig {
10
10
  export interface ClaudeCodeConfig {
11
11
  command?: string;
12
12
  extra_args?: string[];
13
+ dangerously_skip_permissions?: boolean;
13
14
  }
14
15
  export interface OpenCodeConfig {
15
16
  command?: string;
@@ -40,6 +40,19 @@ export function validateArtifactBundle(bundle) {
40
40
  if (bundle.external_analyzer_results) {
41
41
  issues.push(...requireKeys(bundle.external_analyzer_results, "external_analyzer_results", ["tool", "results"]));
42
42
  }
43
+ if (bundle.audit_plan_metrics) {
44
+ issues.push(...requireKeys(bundle.audit_plan_metrics, "audit_plan_metrics", ["generated_at", "task_count", "packet_count"]));
45
+ }
46
+ if (bundle.review_packets) {
47
+ for (const [index, packet] of bundle.review_packets.entries()) {
48
+ issues.push(...requireKeys(packet, `review_packets:${index}`, [
49
+ "packet_id",
50
+ "task_ids",
51
+ "lenses",
52
+ "file_paths",
53
+ ]));
54
+ }
55
+ }
43
56
  if (bundle.tooling_manifest) {
44
57
  issues.push(...requireKeys(bundle.tooling_manifest, "tooling_manifest", ["generated_at", "package_root", "implementation_hash", "inputs"]));
45
58
  }
@@ -57,6 +57,20 @@ function validateRequiredStringField(value, label, taskId, resultIndex, issues)
57
57
  });
58
58
  }
59
59
  }
60
+ function validateExpectedStringField(value, label, expected, taskId, resultIndex, issues) {
61
+ if (typeof value !== "string" || value.trim().length === 0) {
62
+ return;
63
+ }
64
+ if (value !== expected) {
65
+ pushIssue(issues, {
66
+ result_index: resultIndex,
67
+ task_id: taskId,
68
+ field: label,
69
+ message: `${label} must match the assigned task metadata ` +
70
+ `(expected '${expected}', got '${value}').`,
71
+ });
72
+ }
73
+ }
60
74
  function validateFinding(finding, label, taskId, resultIndex) {
61
75
  const issues = [];
62
76
  if (!isRecord(finding)) {
@@ -237,6 +251,11 @@ export function validateAuditResults(results, tasks, options = {}) {
237
251
  message: `Invalid lens '${result.lens}'. Must be one of: ${[...VALID_LENSES].join(", ")}.`,
238
252
  });
239
253
  }
254
+ if (task) {
255
+ validateExpectedStringField(result.unit_id, "unit_id", task.unit_id, taskId, i, issues);
256
+ validateExpectedStringField(result.pass_id, "pass_id", task.pass_id, taskId, i, issues);
257
+ validateExpectedStringField(result.lens, "lens", task.lens, taskId, i, issues);
258
+ }
240
259
  if (tasks.length > 0 && !task) {
241
260
  pushIssue(issues, {
242
261
  result_index: i,
@@ -248,6 +267,7 @@ export function validateAuditResults(results, tasks, options = {}) {
248
267
  }
249
268
  const fileCoverage = result.file_coverage;
250
269
  const normalizedFileCoverage = [];
270
+ const declaredAssignedCoveragePaths = new Set();
251
271
  if (!Array.isArray(fileCoverage) || fileCoverage.length === 0) {
252
272
  pushIssue(issues, {
253
273
  result_index: i,
@@ -281,7 +301,6 @@ export function validateAuditResults(results, tasks, options = {}) {
281
301
  pushIssue(issues, {
282
302
  result_index: i,
283
303
  task_id: taskId,
284
- severity: "warning",
285
304
  field: `file_coverage[${j}].path`,
286
305
  message: `file_coverage path '${entry.path}' is not listed in the task file_paths.`,
287
306
  });
@@ -297,6 +316,10 @@ export function validateAuditResults(results, tasks, options = {}) {
297
316
  else {
298
317
  seenCoveragePaths.add(entry.path);
299
318
  }
319
+ if (isNonEmptyString(entry.path) &&
320
+ (!task || task.file_paths.includes(entry.path))) {
321
+ declaredAssignedCoveragePaths.add(entry.path);
322
+ }
300
323
  if (!Number.isInteger(entry.total_lines)) {
301
324
  pushIssue(issues, {
302
325
  result_index: i,
@@ -330,7 +353,8 @@ export function validateAuditResults(results, tasks, options = {}) {
330
353
  }
331
354
  if (isNonEmptyString(entry.path) &&
332
355
  Number.isInteger(entry.total_lines) &&
333
- Number(entry.total_lines) >= 0) {
356
+ Number(entry.total_lines) >= 0 &&
357
+ (!task || task.file_paths.includes(entry.path))) {
334
358
  normalizedFileCoverage.push({
335
359
  path: entry.path,
336
360
  total_lines: Number(entry.total_lines),
@@ -367,11 +391,35 @@ export function validateAuditResults(results, tasks, options = {}) {
367
391
  if (!isRecord(finding) || !Array.isArray(finding.affected_files)) {
368
392
  continue;
369
393
  }
394
+ const expectedFindingLens = task?.lens ??
395
+ (typeof result.lens === "string" && VALID_LENSES.has(result.lens)
396
+ ? result.lens
397
+ : undefined);
398
+ if (expectedFindingLens &&
399
+ typeof finding.lens === "string" &&
400
+ finding.lens !== expectedFindingLens) {
401
+ pushIssue(issues, {
402
+ result_index: i,
403
+ task_id: taskId,
404
+ field: `${label}.lens`,
405
+ message: `${label}.lens must match the assigned task lens ` +
406
+ `(expected '${expectedFindingLens}', got '${finding.lens}').`,
407
+ });
408
+ }
370
409
  for (let k = 0; k < finding.affected_files.length; k++) {
371
410
  const affected = finding.affected_files[k];
372
411
  if (!isRecord(affected) || !isNonEmptyString(affected.path)) {
373
412
  continue;
374
413
  }
414
+ if (!declaredAssignedCoveragePaths.has(affected.path)) {
415
+ pushIssue(issues, {
416
+ result_index: i,
417
+ task_id: taskId,
418
+ field: `${label}.affected_files[${k}].path`,
419
+ message: `affected_files path '${affected.path}' is not in the declared assigned file_coverage.`,
420
+ });
421
+ continue;
422
+ }
375
423
  if (!Number.isInteger(affected.line_start)) {
376
424
  continue;
377
425
  }
@@ -74,6 +74,11 @@ function validateAgentProviderSection(value, path, issues) {
74
74
  if (value.extra_args !== undefined) {
75
75
  validateStringArray(value.extra_args, `${path}.extra_args`, "extra_args", issues, { allowEmptyArray: true });
76
76
  }
77
+ if (path === "claude_code" &&
78
+ value.dangerously_skip_permissions !== undefined &&
79
+ typeof value.dangerously_skip_permissions !== "boolean") {
80
+ pushIssue(issues, `${path}.dangerously_skip_permissions`, "dangerously_skip_permissions must be a boolean when provided.");
81
+ }
77
82
  }
78
83
  function commandExists(command) {
79
84
  const lookupCommand = process.platform === "win32" ? "where" : "which";
@@ -277,4 +277,7 @@ For a polished operator experience today:
277
277
  4. prefer `local-subprocess` unless you explicitly want a backend provider bridge
278
278
  5. use `subprocess-template` only when integrating a non-native editor or launcher surface
279
279
 
280
- If you intentionally want the backend fallback to bridge semantic review into another process, re-run with an explicit `--provider` flag after configuring the matching section in `.audit-artifacts/session-config.json`.
280
+ If you intentionally want the backend fallback to bridge semantic review into
281
+ another process, set the matching provider in
282
+ `.audit-artifacts/session-config.json` or re-run with an explicit `--provider`
283
+ flag after configuring the matching provider section.
@@ -7,6 +7,9 @@ audit-code install
7
7
  ```
8
8
 
9
9
  That command installs the repo-local `/audit-code` surfaces we can automate today.
10
+ It is also the single refresh path: rerun `audit-code install` after prompt or
11
+ skill updates to rewrite the shared install assets and every generated
12
+ host-specific surface from the same source files.
10
13
 
11
14
  After bootstrap, run:
12
15
 
package/docs/contract.md CHANGED
@@ -25,7 +25,10 @@ Workers submit `AuditResult[]` shaped by `schemas/audit_result.schema.json`.
25
25
  Important rules:
26
26
 
27
27
  - `file_coverage` is required and must include every assigned file.
28
+ - `file_coverage` must not include files outside the assigned task.
28
29
  - `file_coverage[].total_lines` must match the current file line count.
30
+ - `task_id`, `unit_id`, `pass_id`, and `lens` must match the assigned task.
31
+ - each finding lens must match the assigned task lens.
29
32
  - `findings[].affected_files` must be objects, not strings.
30
33
  - `findings[].evidence` must be an array of plain strings.
31
34