auditor-lambda 0.3.12 → 0.3.14

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 (61) hide show
  1. package/README.md +20 -24
  2. package/audit-code-wrapper-lib.mjs +52 -53
  3. package/dist/cli.js +43 -6
  4. package/dist/coverage.js +3 -1
  5. package/dist/extractors/disposition.js +8 -1
  6. package/dist/extractors/graph.d.ts +3 -1
  7. package/dist/extractors/graph.js +1147 -67
  8. package/dist/extractors/graphManifestEdges.d.ts +14 -0
  9. package/dist/extractors/graphManifestEdges.js +1158 -0
  10. package/dist/extractors/graphPathUtils.d.ts +5 -0
  11. package/dist/extractors/graphPathUtils.js +75 -0
  12. package/dist/extractors/pathPatterns.d.ts +1 -0
  13. package/dist/extractors/pathPatterns.js +3 -0
  14. package/dist/io/artifacts.d.ts +10 -1
  15. package/dist/io/artifacts.js +23 -3
  16. package/dist/orchestrator/internalExecutors.d.ts +4 -0
  17. package/dist/orchestrator/internalExecutors.js +35 -6
  18. package/dist/orchestrator/reviewPackets.js +1003 -31
  19. package/dist/orchestrator/syntaxResolutionExecutor.js +34 -0
  20. package/dist/types/externalAnalyzer.d.ts +9 -0
  21. package/dist/types/graph.d.ts +3 -0
  22. package/dist/types/reviewPlanning.d.ts +39 -0
  23. package/docs/contracts.md +215 -0
  24. package/docs/development.md +210 -0
  25. package/docs/handoff.md +204 -0
  26. package/docs/history.md +40 -0
  27. package/docs/operator-guide.md +189 -0
  28. package/docs/product.md +185 -0
  29. package/docs/release.md +131 -0
  30. package/package.json +1 -1
  31. package/schemas/audit_plan_metrics.schema.json +347 -0
  32. package/schemas/external_analyzer_results.schema.json +35 -0
  33. package/schemas/graph_bundle.schema.json +47 -2
  34. package/schemas/review_packets.schema.json +160 -0
  35. package/skills/audit-code/SKILL.md +7 -3
  36. package/skills/audit-code/audit-code.prompt.md +4 -1
  37. package/docs/agent-integrations.md +0 -317
  38. package/docs/agent-roles.md +0 -69
  39. package/docs/architecture.md +0 -90
  40. package/docs/artifacts.md +0 -36
  41. package/docs/bootstrap-install.md +0 -139
  42. package/docs/contract.md +0 -54
  43. package/docs/dispatch-implementation-plan.md +0 -302
  44. package/docs/field-trial-bug-report.md +0 -237
  45. package/docs/github-copilot.md +0 -66
  46. package/docs/model-selection.md +0 -97
  47. package/docs/next-steps.md +0 -202
  48. package/docs/packaging.md +0 -120
  49. package/docs/pipeline.md +0 -152
  50. package/docs/product-direction.md +0 -154
  51. package/docs/production-launch-bar.md +0 -92
  52. package/docs/production-readiness.md +0 -58
  53. package/docs/releasing.md +0 -145
  54. package/docs/remediation-baseline.md +0 -75
  55. package/docs/repo-layout.md +0 -30
  56. package/docs/run-flow.md +0 -56
  57. package/docs/session-config.md +0 -319
  58. package/docs/supervisor.md +0 -100
  59. package/docs/usage.md +0 -215
  60. package/docs/windows-setup.md +0 -146
  61. package/docs/workflow-refactor-brief.md +0 -124
@@ -0,0 +1,5 @@
1
+ import type { GraphEdge } from "../types/graph.js";
2
+ export declare function normalizeGraphPath(path: string): string;
3
+ export declare function graphLookupKey(path: string): string;
4
+ export declare function resolveCandidate(candidate: string, pathLookup: Map<string, string>): string | undefined;
5
+ export declare function graphEdge(params: GraphEdge): GraphEdge;
@@ -0,0 +1,75 @@
1
+ import { posix } from "node:path";
2
+ const RESOLVABLE_EXTENSIONS = [
3
+ "",
4
+ ".ts",
5
+ ".tsx",
6
+ ".mts",
7
+ ".cts",
8
+ ".js",
9
+ ".jsx",
10
+ ".mjs",
11
+ ".cjs",
12
+ ".json",
13
+ ".py",
14
+ ".pyi",
15
+ ];
16
+ const INDEX_EXTENSIONS = [
17
+ "index.ts",
18
+ "index.tsx",
19
+ "index.mts",
20
+ "index.cts",
21
+ "index.js",
22
+ "index.jsx",
23
+ "index.mjs",
24
+ "index.cjs",
25
+ "index.json",
26
+ "__init__.py",
27
+ "__init__.pyi",
28
+ ];
29
+ const RUNTIME_SOURCE_EXTENSION_ALIASES = {
30
+ ".js": [".ts", ".tsx", ".jsx"],
31
+ ".mjs": [".mts"],
32
+ ".cjs": [".cts"],
33
+ };
34
+ export function normalizeGraphPath(path) {
35
+ return posix
36
+ .normalize(path.replace(/\\/g, "/"))
37
+ .replace(/^\.\//, "");
38
+ }
39
+ export function graphLookupKey(path) {
40
+ return normalizeGraphPath(path).toLowerCase();
41
+ }
42
+ export function resolveCandidate(candidate, pathLookup) {
43
+ const normalized = normalizeGraphPath(candidate);
44
+ const direct = pathLookup.get(normalized.toLowerCase());
45
+ if (direct)
46
+ return direct;
47
+ const runtimeExtension = posix.extname(normalized).toLowerCase();
48
+ const sourceExtensionAliases = RUNTIME_SOURCE_EXTENSION_ALIASES[runtimeExtension];
49
+ if (sourceExtensionAliases) {
50
+ const withoutRuntimeExtension = normalized.slice(0, -runtimeExtension.length);
51
+ for (const sourceExtension of sourceExtensionAliases) {
52
+ const match = pathLookup.get(`${withoutRuntimeExtension}${sourceExtension}`.toLowerCase());
53
+ if (match)
54
+ return match;
55
+ }
56
+ }
57
+ for (const extension of RESOLVABLE_EXTENSIONS) {
58
+ const withExtension = `${normalized}${extension}`;
59
+ const match = pathLookup.get(withExtension.toLowerCase());
60
+ if (match)
61
+ return match;
62
+ }
63
+ for (const indexFile of INDEX_EXTENSIONS) {
64
+ const match = pathLookup.get(posix.join(normalized, indexFile).toLowerCase());
65
+ if (match)
66
+ return match;
67
+ }
68
+ return undefined;
69
+ }
70
+ export function graphEdge(params) {
71
+ return {
72
+ ...params,
73
+ direction: params.direction ?? "directed",
74
+ };
75
+ }
@@ -16,6 +16,7 @@ export declare function isLicensePath(normalized: string): boolean;
16
16
  export declare function isLockfilePath(normalized: string): boolean;
17
17
  export declare function isDocPath(normalized: string): boolean;
18
18
  export declare function isGeneratedInstallArtifactPath(normalized: string): boolean;
19
+ export declare function isGeneratedTestArtifactPath(normalized: string): boolean;
19
20
  export declare function isAuditArtifactPath(normalized: string): boolean;
20
21
  export declare function isTestPath(normalized: string): boolean;
21
22
  export declare function isInterfacePath(normalized: string): boolean;
@@ -173,6 +173,9 @@ export function isDocPath(normalized) {
173
173
  export function isGeneratedInstallArtifactPath(normalized) {
174
174
  return normalized.startsWith(".audit-code/install/");
175
175
  }
176
+ export function isGeneratedTestArtifactPath(normalized) {
177
+ return splitSegments(normalized).some((segment) => segment.startsWith(".test-") && segment.endsWith("-artifacts"));
178
+ }
176
179
  export function isAuditArtifactPath(normalized) {
177
180
  return splitSegments(normalized).some((segment) => segment.startsWith(".audit-artifacts"));
178
181
  }
@@ -1,3 +1,4 @@
1
+ import { cp, rm } from "node:fs/promises";
1
2
  import type { AuditResult, AuditTask, CoverageMatrix, RepoManifest, UnitManifest } from "../types.js";
2
3
  import type { AuditState } from "../types/auditState.js";
3
4
  import type { ArtifactMetadataManifest } from "../types/artifactMetadata.js";
@@ -80,5 +81,13 @@ export declare function cleanupIntermediateArtifacts(root: string): Promise<stri
80
81
  export declare function promoteFinalAuditReport(params: {
81
82
  artifactsDir: string;
82
83
  repoRoot: string;
83
- }): Promise<void>;
84
+ }, options?: {
85
+ copy?: typeof cp;
86
+ remove?: typeof rm;
87
+ warn?: (message: string) => void;
88
+ }): Promise<{
89
+ promoted: boolean;
90
+ cleaned: boolean;
91
+ warning?: string;
92
+ }>;
84
93
  export {};
@@ -96,9 +96,29 @@ export async function cleanupIntermediateArtifacts(root) {
96
96
  }
97
97
  return deleted;
98
98
  }
99
- export async function promoteFinalAuditReport(params) {
99
+ export async function promoteFinalAuditReport(params, options = {}) {
100
100
  const source = join(params.artifactsDir, "audit-report.md");
101
101
  const destination = join(params.repoRoot, "audit-report.md");
102
- await cp(source, destination, { force: true });
103
- await rm(params.artifactsDir, { recursive: true, force: true });
102
+ const copy = options.copy ?? cp;
103
+ const remove = options.remove ?? rm;
104
+ const warn = options.warn ?? ((message) => process.stderr.write(`${message}\n`));
105
+ try {
106
+ await copy(source, destination, { force: true });
107
+ }
108
+ catch (error) {
109
+ const warning = `audit-code: completed audit but could not promote final report to ${destination}: ` +
110
+ (error instanceof Error ? error.message : String(error));
111
+ warn(warning);
112
+ return { promoted: false, cleaned: false, warning };
113
+ }
114
+ try {
115
+ await remove(params.artifactsDir, { recursive: true, force: true });
116
+ return { promoted: true, cleaned: true };
117
+ }
118
+ catch (error) {
119
+ const warning = `audit-code: promoted final report to ${destination}, but could not remove ${params.artifactsDir}: ` +
120
+ (error instanceof Error ? error.message : String(error));
121
+ warn(warning);
122
+ return { promoted: true, cleaned: false, warning };
123
+ }
104
124
  }
@@ -7,6 +7,10 @@ export interface ExecutorRunResult {
7
7
  artifacts_written: string[];
8
8
  progress_summary: string;
9
9
  }
10
+ export declare function resolveRuntimeValidationSpawnCommand(command: string[], platform?: NodeJS.Platform, shellCommand?: string): {
11
+ command: string;
12
+ args: string[];
13
+ };
10
14
  export declare function runIntakeExecutor(bundle: ArtifactBundle, root: string): Promise<ExecutorRunResult>;
11
15
  export declare function runStructureExecutor(bundle: ArtifactBundle, root?: string): Promise<ExecutorRunResult>;
12
16
  export declare function runPlanningExecutor(bundle: ArtifactBundle, root: string, lineIndex?: Record<string, number>): Promise<ExecutorRunResult>;
@@ -56,8 +56,10 @@ function appendSelectiveDeepeningTasks(params) {
56
56
  };
57
57
  }
58
58
  async function runCommand(command, cwd) {
59
+ const spawnCommand = resolveRuntimeValidationSpawnCommand(command);
60
+ const displayCommand = command.join(" ");
59
61
  return await new Promise((resolve) => {
60
- const child = spawn(command[0], command.slice(1), {
62
+ const child = spawn(spawnCommand.command, spawnCommand.args, {
61
63
  cwd,
62
64
  env: process.env,
63
65
  stdio: ["ignore", "pipe", "pipe"],
@@ -73,7 +75,7 @@ async function runCommand(command, cwd) {
73
75
  child.on("error", (error) => {
74
76
  resolve({
75
77
  status: "inconclusive",
76
- summary: `Failed to execute ${command.join(" ")}: ${error.message}`,
78
+ summary: `Failed to execute ${displayCommand}: ${error.message}`,
77
79
  evidence: [],
78
80
  });
79
81
  });
@@ -83,13 +85,36 @@ async function runCommand(command, cwd) {
83
85
  resolve({
84
86
  status: code === 0 ? "confirmed" : "not_confirmed",
85
87
  summary: code === 0
86
- ? `Deterministic runtime command succeeded: ${command.join(" ")}`
87
- : `Deterministic runtime command failed with exit code ${code}: ${command.join(" ")}`,
88
+ ? `Deterministic runtime command succeeded: ${displayCommand}`
89
+ : `Deterministic runtime command failed with exit code ${code}: ${displayCommand}`,
88
90
  evidence,
89
91
  });
90
92
  });
91
93
  });
92
94
  }
95
+ export function resolveRuntimeValidationSpawnCommand(command, platform = process.platform, shellCommand = process.env.ComSpec ?? "cmd.exe") {
96
+ const [executable, ...args] = command;
97
+ if (!executable) {
98
+ return { command: "", args: [] };
99
+ }
100
+ if (platform !== "win32") {
101
+ return { command: executable, args };
102
+ }
103
+ const packageManager = executable.replace(/\.(cmd|bat)$/i, "").toLowerCase();
104
+ if (["npm", "npx", "pnpm", "yarn"].includes(packageManager)) {
105
+ return {
106
+ command: shellCommand,
107
+ args: ["/d", "/s", "/c", command.map(quoteCmdArg).join(" ")],
108
+ };
109
+ }
110
+ return { command: executable, args };
111
+ }
112
+ function quoteCmdArg(value) {
113
+ if (/^[A-Za-z0-9_./:=+-]+$/.test(value)) {
114
+ return value;
115
+ }
116
+ return `"${value.replace(/(["^&|<>%])/g, "^$1")}"`;
117
+ }
93
118
  export async function runIntakeExecutor(bundle, root) {
94
119
  const ignore = await loadIgnoreFile(root);
95
120
  const repoManifest = await buildRepoManifestFromFs({
@@ -117,8 +142,12 @@ export async function runStructureExecutor(bundle, root) {
117
142
  const unitManifest = buildUnitManifest(bundle.repo_manifest, disposition);
118
143
  const surfaceManifest = buildSurfaceManifest(bundle.repo_manifest, disposition);
119
144
  const graphBundle = root
120
- ? await buildGraphBundleFromFs(bundle.repo_manifest, root, disposition)
121
- : buildGraphBundle(bundle.repo_manifest, disposition);
145
+ ? await buildGraphBundleFromFs(bundle.repo_manifest, root, disposition, {
146
+ externalAnalyzerResults,
147
+ })
148
+ : buildGraphBundle(bundle.repo_manifest, disposition, {
149
+ externalAnalyzerResults,
150
+ });
122
151
  const criticalFlows = buildCriticalFlowManifest(bundle.repo_manifest, surfaceManifest, disposition);
123
152
  const riskRegister = buildRiskRegister(unitManifest, criticalFlows, externalAnalyzerResults);
124
153
  return {