auditor-lambda 0.2.8 → 0.2.10

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 (104) hide show
  1. package/README.md +6 -0
  2. package/audit-code-wrapper-lib.mjs +1 -1
  3. package/dist/adapters/eslint.js +9 -5
  4. package/dist/cli.d.ts +42 -1
  5. package/dist/cli.js +234 -63
  6. package/dist/extractors/bucketing.d.ts +4 -0
  7. package/dist/extractors/bucketing.js +6 -2
  8. package/dist/extractors/disposition.d.ts +4 -0
  9. package/dist/extractors/disposition.js +6 -2
  10. package/dist/extractors/fileInventory.js +24 -28
  11. package/dist/extractors/flows.d.ts +5 -0
  12. package/dist/extractors/flows.js +18 -38
  13. package/dist/extractors/pathPatterns.d.ts +10 -3
  14. package/dist/extractors/pathPatterns.js +109 -61
  15. package/dist/extractors/surfaces.d.ts +4 -0
  16. package/dist/extractors/surfaces.js +11 -11
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/io/artifacts.d.ts +55 -40
  20. package/dist/io/artifacts.js +73 -110
  21. package/dist/io/json.js +52 -21
  22. package/dist/io/runArtifacts.d.ts +1 -1
  23. package/dist/io/runArtifacts.js +26 -3
  24. package/dist/orchestrator/advance.js +83 -62
  25. package/dist/orchestrator/autoFixExecutor.js +32 -15
  26. package/dist/orchestrator/flowCoverage.js +11 -5
  27. package/dist/orchestrator/flowPlanning.d.ts +7 -2
  28. package/dist/orchestrator/flowPlanning.js +46 -21
  29. package/dist/orchestrator/flowRequeue.js +28 -8
  30. package/dist/orchestrator/internalExecutors.js +12 -8
  31. package/dist/orchestrator/localCommands.d.ts +14 -0
  32. package/dist/orchestrator/localCommands.js +124 -0
  33. package/dist/orchestrator/planning.js +25 -3
  34. package/dist/orchestrator/requeue.js +11 -1
  35. package/dist/orchestrator/syntaxResolutionExecutor.js +60 -59
  36. package/dist/orchestrator/taskBuilder.d.ts +4 -2
  37. package/dist/orchestrator/taskBuilder.js +153 -52
  38. package/dist/orchestrator/unitBuilder.d.ts +3 -1
  39. package/dist/orchestrator/unitBuilder.js +24 -16
  40. package/dist/prompts/renderWorkerPrompt.d.ts +1 -1
  41. package/dist/prompts/renderWorkerPrompt.js +16 -8
  42. package/dist/providers/claudeCodeProvider.d.ts +4 -1
  43. package/dist/providers/claudeCodeProvider.js +8 -5
  44. package/dist/providers/localSubprocessProvider.d.ts +4 -0
  45. package/dist/providers/localSubprocessProvider.js +7 -2
  46. package/dist/providers/spawnLoggedCommand.d.ts +9 -1
  47. package/dist/providers/spawnLoggedCommand.js +77 -29
  48. package/dist/reporting/synthesis.d.ts +2 -0
  49. package/dist/reporting/synthesis.js +12 -9
  50. package/dist/supervisor/operatorHandoff.d.ts +1 -1
  51. package/dist/supervisor/operatorHandoff.js +56 -18
  52. package/dist/supervisor/runLedger.d.ts +1 -1
  53. package/dist/supervisor/runLedger.js +112 -5
  54. package/dist/supervisor/sessionConfig.js +10 -10
  55. package/dist/types/externalAnalyzer.d.ts +3 -0
  56. package/dist/types/flowCoverage.d.ts +5 -1
  57. package/dist/types/flowCoverage.js +5 -1
  58. package/dist/types/flows.d.ts +5 -1
  59. package/dist/types/flows.js +1 -1
  60. package/dist/types/runLedger.d.ts +5 -1
  61. package/dist/types/runLedger.js +6 -1
  62. package/dist/types/runtimeValidation.d.ts +12 -3
  63. package/dist/types/runtimeValidation.js +16 -1
  64. package/dist/types/sessionConfig.d.ts +15 -2
  65. package/dist/types/sessionConfig.js +15 -1
  66. package/dist/types/surfaces.d.ts +4 -1
  67. package/dist/types/surfaces.js +1 -1
  68. package/dist/types/workerSession.d.ts +9 -0
  69. package/dist/types/workerSession.js +5 -1
  70. package/dist/validation/artifacts.d.ts +1 -1
  71. package/dist/validation/artifacts.js +33 -20
  72. package/dist/validation/auditResults.d.ts +2 -2
  73. package/dist/validation/auditResults.js +7 -15
  74. package/dist/validation/basic.d.ts +9 -1
  75. package/dist/validation/basic.js +40 -3
  76. package/dist/validation/sessionConfig.d.ts +4 -2
  77. package/dist/validation/sessionConfig.js +62 -15
  78. package/docs/agent-integrations.md +31 -11
  79. package/docs/next-steps.md +21 -4
  80. package/docs/packaging.md +14 -0
  81. package/docs/product-direction.md +22 -0
  82. package/docs/production-launch-bar.md +2 -0
  83. package/docs/releasing.md +17 -0
  84. package/docs/remediation-baseline.md +75 -0
  85. package/docs/run-flow.md +23 -11
  86. package/docs/session-config.md +53 -6
  87. package/docs/supervisor.md +7 -0
  88. package/docs/workflow-refactor-brief.md +177 -0
  89. package/package.json +1 -1
  90. package/schemas/audit-code-v1alpha1.schema.json +1 -0
  91. package/schemas/audit_result.schema.json +4 -1
  92. package/schemas/audit_task.schema.json +3 -1
  93. package/schemas/coverage_matrix.schema.json +3 -3
  94. package/schemas/critical_flows.schema.json +6 -2
  95. package/schemas/file_disposition.schema.json +2 -2
  96. package/schemas/finding.schema.json +9 -4
  97. package/schemas/flow_coverage.schema.json +2 -2
  98. package/schemas/repo_manifest.schema.json +4 -4
  99. package/schemas/risk_register.schema.json +2 -2
  100. package/schemas/runtime_validation_report.schema.json +2 -2
  101. package/schemas/runtime_validation_tasks.schema.json +8 -2
  102. package/schemas/surface_manifest.schema.json +6 -3
  103. package/schemas/unit_manifest.schema.json +3 -2
  104. package/skills/audit-code/SKILL.md +5 -0
@@ -1,32 +1,28 @@
1
+ import { normalizeExtractorPath } from "./pathPatterns.js";
2
+ const LANGUAGE_BY_EXTENSION = {
3
+ ts: "typescript",
4
+ tsx: "typescript",
5
+ mts: "typescript",
6
+ cts: "typescript",
7
+ js: "javascript",
8
+ jsx: "javascript",
9
+ mjs: "javascript",
10
+ cjs: "javascript",
11
+ py: "python",
12
+ go: "go",
13
+ rs: "rust",
14
+ java: "java",
15
+ cs: "csharp",
16
+ json: "json",
17
+ yml: "yaml",
18
+ yaml: "yaml",
19
+ md: "markdown",
20
+ };
1
21
  function inferLanguage(path) {
2
- const ext = path.split(".").pop()?.toLowerCase();
3
- switch (ext) {
4
- case "ts":
5
- case "tsx":
6
- return "typescript";
7
- case "js":
8
- case "jsx":
9
- return "javascript";
10
- case "py":
11
- return "python";
12
- case "go":
13
- return "go";
14
- case "rs":
15
- return "rust";
16
- case "java":
17
- return "java";
18
- case "cs":
19
- return "csharp";
20
- case "json":
21
- return "json";
22
- case "yml":
23
- case "yaml":
24
- return "yaml";
25
- case "md":
26
- return "markdown";
27
- default:
28
- return "unknown";
29
- }
22
+ const normalized = normalizeExtractorPath(path);
23
+ const base = normalized.split("/").pop() ?? normalized;
24
+ const extension = base.includes(".") ? base.split(".").pop() ?? "" : "";
25
+ return LANGUAGE_BY_EXTENSION[extension] ?? "unknown";
30
26
  }
31
27
  export function buildRepoManifest(repositoryName, files) {
32
28
  return {
@@ -2,4 +2,9 @@ import type { RepoManifest } from "../types.js";
2
2
  import type { FileDisposition } from "../types/disposition.js";
3
3
  import type { CriticalFlowManifest } from "../types/flows.js";
4
4
  import type { SurfaceManifest } from "../types/surfaces.js";
5
+ /**
6
+ * Builds coarse critical-flow coverage from shared path heuristics. These
7
+ * bootstrap flows are intentionally conservative and should be reviewed when a
8
+ * repo uses unconventional naming or layout conventions.
9
+ */
5
10
  export declare function buildCriticalFlowManifest(repoManifest: RepoManifest, surfaceManifest: SurfaceManifest, disposition?: FileDisposition): CriticalFlowManifest;
@@ -1,14 +1,12 @@
1
1
  import { isAuditExcludedStatus } from "./disposition.js";
2
- import { isSecuritySensitivePath, isDataLayerPath, isConcurrencyPath, isInterfacePath, isDeploymentConfigPath, } from "./pathPatterns.js";
2
+ import { EXTRACTOR_HEURISTIC_NOTE, isAsyncTaskPath, isBillingPath, isIdentityPath, isSecuritySensitivePath, isDataLayerPath, isConcurrencyPath, isInterfacePath, isDeploymentConfigPath, normalizeExtractorPath, } from "./pathPatterns.js";
3
3
  function inferConcerns(paths) {
4
4
  const concerns = new Set();
5
5
  for (const path of paths) {
6
- const normalized = path.toLowerCase();
6
+ const normalized = normalizeExtractorPath(path);
7
7
  if (isSecuritySensitivePath(normalized))
8
8
  concerns.add("security");
9
- if (isDataLayerPath(normalized) ||
10
- normalized.includes("invoice") ||
11
- normalized.includes("payment"))
9
+ if (isDataLayerPath(normalized) || isBillingPath(normalized))
12
10
  concerns.add("data_integrity");
13
11
  if (isConcurrencyPath(normalized))
14
12
  concerns.add("reliability");
@@ -18,47 +16,26 @@ function inferConcerns(paths) {
18
16
  return concerns.size > 0 ? [...concerns] : ["correctness"];
19
17
  }
20
18
  function relatedPaths(entry, availablePaths) {
21
- const normalized = entry.toLowerCase();
19
+ const normalized = normalizeExtractorPath(entry);
22
20
  const linked = new Set([entry]);
23
21
  for (const path of availablePaths) {
24
- const lower = path.toLowerCase();
22
+ const lower = normalizeExtractorPath(path);
25
23
  if (path === entry)
26
24
  continue;
27
25
  // Auth / session flows: link sibling auth, session, token, user paths
28
- if (isSecuritySensitivePath(normalized) &&
29
- (lower.includes("auth") ||
30
- lower.includes("session") ||
31
- lower.includes("token") ||
32
- lower.includes("user"))) {
26
+ if (isSecuritySensitivePath(normalized) && isIdentityPath(lower)) {
33
27
  linked.add(path);
34
28
  }
35
29
  // Billing / payment flows: link ledger and subscription paths
36
- if ((normalized.includes("billing") ||
37
- normalized.includes("invoice") ||
38
- normalized.includes("payment")) &&
39
- (lower.includes("billing") ||
40
- lower.includes("invoice") ||
41
- lower.includes("payment") ||
42
- lower.includes("ledger") ||
43
- lower.includes("subscription"))) {
30
+ if (isBillingPath(normalized) && isBillingPath(lower)) {
44
31
  linked.add(path);
45
32
  }
46
33
  // Async / queue flows: link worker, job, retry, and task paths
47
- if (isConcurrencyPath(normalized) &&
48
- (lower.includes("queue") ||
49
- lower.includes("retry") ||
50
- lower.includes("worker") ||
51
- lower.includes("job") ||
52
- lower.includes("task"))) {
34
+ if (isConcurrencyPath(normalized) && isAsyncTaskPath(lower)) {
53
35
  linked.add(path);
54
36
  }
55
37
  // Deployment / infra flows: link docker, k8s, terraform, workflow paths
56
- if (isDeploymentConfigPath(normalized) &&
57
- (lower.includes("deploy") ||
58
- lower.includes("docker") ||
59
- lower.includes("workflow") ||
60
- lower.includes("k8s") ||
61
- lower.includes("terraform"))) {
38
+ if (isDeploymentConfigPath(normalized) && isDeploymentConfigPath(lower)) {
62
39
  linked.add(path);
63
40
  }
64
41
  }
@@ -76,6 +53,11 @@ function dedupeFlows(flows) {
76
53
  }
77
54
  return deduped;
78
55
  }
56
+ /**
57
+ * Builds coarse critical-flow coverage from shared path heuristics. These
58
+ * bootstrap flows are intentionally conservative and should be reviewed when a
59
+ * repo uses unconventional naming or layout conventions.
60
+ */
79
61
  export function buildCriticalFlowManifest(repoManifest, surfaceManifest, disposition) {
80
62
  const dispositionMap = new Map(disposition?.files.map((item) => [item.path, item.status]) ?? []);
81
63
  const availablePaths = repoManifest.files
@@ -95,14 +77,12 @@ export function buildCriticalFlowManifest(repoManifest, surfaceManifest, disposi
95
77
  paths,
96
78
  concerns: inferConcerns(paths),
97
79
  confidence: paths.length > 1 ? "high" : "low",
98
- notes: [
99
- "Heuristic critical-flow inference from detected surfaces and related paths.",
100
- ],
80
+ notes: [EXTRACTOR_HEURISTIC_NOTE],
101
81
  });
102
82
  }
103
83
  for (const path of availablePaths) {
104
- const lower = path.toLowerCase();
105
- if (isDataLayerPath(lower) || lower.includes("seed")) {
84
+ const normalized = normalizeExtractorPath(path);
85
+ if (isDataLayerPath(normalized)) {
106
86
  flows.push({
107
87
  id: `flow:data:${path.replace(/[^a-zA-Z0-9:_-]/g, "-")}`,
108
88
  name: `data evolution flow for ${path}`,
@@ -110,7 +90,7 @@ export function buildCriticalFlowManifest(repoManifest, surfaceManifest, disposi
110
90
  paths: relatedPaths(path, availablePaths),
111
91
  concerns: ["data_integrity", "reliability"],
112
92
  confidence: "high",
113
- notes: ["Heuristic data-evolution flow."],
93
+ notes: [EXTRACTOR_HEURISTIC_NOTE],
114
94
  });
115
95
  }
116
96
  }
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Centralised path-pattern predicates shared across disposition, bucketing,
3
- * surfaces, and flows extractors. Every function operates on the
4
- * already-lower-cased form of the path.
2
+ * Shared bootstrap heuristics for the extractor layer. These rules run before
3
+ * richer graph/unit analysis exists, so they intentionally favor recall over
4
+ * precision and always normalize case plus path separators first.
5
5
  */
6
+ export declare const EXTRACTOR_HEURISTIC_NOTE = "Heuristic path classification normalizes case and path separators, then matches conservative keyword groups; confirm unusual repo layouts manually.";
7
+ export declare function normalizeExtractorPath(path: string): string;
6
8
  export declare function isNodeModulesOrGit(normalized: string): boolean;
7
9
  export declare function isBuildOutput(normalized: string): boolean;
8
10
  export declare function isVendorPath(normalized: string): boolean;
@@ -20,3 +22,8 @@ export declare function isScriptPath(normalized: string): boolean;
20
22
  export declare function isDeploymentConfigPath(normalized: string): boolean;
21
23
  export declare function isGeneratedPath(normalized: string): boolean;
22
24
  export declare function isSurfacePath(normalized: string): boolean;
25
+ export declare function isBackgroundSurfacePath(normalized: string): boolean;
26
+ export declare function isNetworkSurfacePath(normalized: string): boolean;
27
+ export declare function isBillingPath(normalized: string): boolean;
28
+ export declare function isIdentityPath(normalized: string): boolean;
29
+ export declare function isAsyncTaskPath(normalized: string): boolean;
@@ -1,100 +1,148 @@
1
1
  /**
2
- * Centralised path-pattern predicates shared across disposition, bucketing,
3
- * surfaces, and flows extractors. Every function operates on the
4
- * already-lower-cased form of the path.
2
+ * Shared bootstrap heuristics for the extractor layer. These rules run before
3
+ * richer graph/unit analysis exists, so they intentionally favor recall over
4
+ * precision and always normalize case plus path separators first.
5
5
  */
6
+ export const EXTRACTOR_HEURISTIC_NOTE = "Heuristic path classification normalizes case and path separators, then matches conservative keyword groups; confirm unusual repo layouts manually.";
7
+ const BINARY_EXTENSIONS = [
8
+ ".png",
9
+ ".jpg",
10
+ ".jpeg",
11
+ ".gif",
12
+ ".pdf",
13
+ ".zip",
14
+ ];
15
+ const LOCKFILE_NAMES = [
16
+ "package-lock.json",
17
+ "pnpm-lock.yaml",
18
+ "yarn.lock",
19
+ "cargo.lock",
20
+ "composer.lock",
21
+ "go.sum",
22
+ ];
23
+ const TEST_KEYWORDS = ["test", "spec", "__tests__"];
24
+ const INTERFACE_KEYWORDS = ["route", "controller", "handler"];
25
+ const DATA_LAYER_KEYWORDS = ["model", "schema", "migration", "seed"];
26
+ const SECURITY_KEYWORDS = [
27
+ "auth",
28
+ "secret",
29
+ "token",
30
+ "permission",
31
+ "session",
32
+ ];
33
+ const CONCURRENCY_KEYWORDS = [
34
+ "queue",
35
+ "worker",
36
+ "job",
37
+ "cache",
38
+ "retry",
39
+ "lock",
40
+ ];
41
+ const SCRIPT_KEYWORDS = ["script"];
42
+ const DEPLOYMENT_KEYWORDS = [
43
+ "docker",
44
+ "terraform",
45
+ "deploy",
46
+ "workflow",
47
+ "k8s",
48
+ ];
49
+ const SURFACE_KEYWORDS = ["route", "controller", "worker", "job", "command"];
50
+ const BILLING_KEYWORDS = [
51
+ "billing",
52
+ "invoice",
53
+ "payment",
54
+ "ledger",
55
+ "subscription",
56
+ ];
57
+ const IDENTITY_KEYWORDS = ["user"];
58
+ const ASYNC_TASK_KEYWORDS = ["task"];
59
+ export function normalizeExtractorPath(path) {
60
+ return path.replace(/\\/g, "/").toLowerCase();
61
+ }
62
+ function splitSegments(normalized) {
63
+ return normalized.split("/").filter(Boolean);
64
+ }
65
+ function hasSegment(normalized, segment) {
66
+ return splitSegments(normalized).includes(segment);
67
+ }
68
+ function includesAny(normalized, values) {
69
+ return values.some((value) => normalized.includes(value));
70
+ }
71
+ function endsWithAny(normalized, suffixes) {
72
+ return suffixes.some((suffix) => normalized.endsWith(suffix));
73
+ }
74
+ function baseName(normalized) {
75
+ const segments = splitSegments(normalized);
76
+ return segments.at(-1) ?? normalized;
77
+ }
6
78
  export function isNodeModulesOrGit(normalized) {
7
- const segments = normalized.split(/[/\\]/);
8
- return segments.includes("node_modules") || segments.includes(".git");
79
+ return hasSegment(normalized, "node_modules") || hasSegment(normalized, ".git");
9
80
  }
10
81
  export function isBuildOutput(normalized) {
11
- return normalized.startsWith("dist/") || normalized.startsWith("build/");
82
+ return hasSegment(normalized, "dist") || hasSegment(normalized, "build");
12
83
  }
13
84
  export function isVendorPath(normalized) {
14
85
  return normalized.includes("vendor") || normalized.includes("third_party");
15
86
  }
16
87
  export function isBinaryArtifact(normalized) {
17
- return (normalized.endsWith(".png") ||
18
- normalized.endsWith(".jpg") ||
19
- normalized.endsWith(".jpeg") ||
20
- normalized.endsWith(".gif") ||
21
- normalized.endsWith(".pdf") ||
22
- normalized.endsWith(".zip"));
88
+ return endsWithAny(normalized, BINARY_EXTENSIONS);
23
89
  }
24
90
  export function isLogPath(normalized) {
25
- return normalized.endsWith(".log") || normalized.includes("stdout.log") || normalized.includes("stderr.log");
91
+ return normalized.endsWith(".log") || includesAny(normalized, ["stdout.log", "stderr.log"]);
26
92
  }
27
93
  export function isLicensePath(normalized) {
28
- const base = normalized.split(/[/\\]/).pop() ?? normalized;
94
+ const base = baseName(normalized);
29
95
  return base === "license" || base.startsWith("license.");
30
96
  }
31
97
  export function isLockfilePath(normalized) {
32
- return (normalized.endsWith("package-lock.json") ||
33
- normalized.endsWith("pnpm-lock.yaml") ||
34
- normalized.endsWith("yarn.lock") ||
35
- normalized.endsWith("cargo.lock") ||
36
- normalized.endsWith("composer.lock") ||
37
- normalized.endsWith("go.sum"));
98
+ return endsWithAny(normalized, LOCKFILE_NAMES);
38
99
  }
39
100
  export function isDocPath(normalized) {
40
- return normalized.endsWith(".md") || normalized.startsWith("docs/");
101
+ return normalized.endsWith(".md") || hasSegment(normalized, "docs");
41
102
  }
42
103
  export function isTestPath(normalized) {
43
- return (normalized.includes("test") ||
44
- normalized.includes("spec") ||
45
- normalized.includes("__tests__"));
104
+ return includesAny(normalized, TEST_KEYWORDS);
46
105
  }
47
106
  export function isInterfacePath(normalized) {
48
- return (normalized.includes("route") ||
49
- normalized.includes("controller") ||
50
- normalized.includes("handler") ||
51
- normalized.includes("api/"));
107
+ return includesAny(normalized, INTERFACE_KEYWORDS) || hasSegment(normalized, "api");
52
108
  }
53
109
  export function isDataLayerPath(normalized) {
54
- return (normalized.includes("model") ||
55
- normalized.includes("schema") ||
56
- normalized.includes("migration") ||
57
- normalized.includes("seed") ||
58
- normalized.includes("db/"));
110
+ return includesAny(normalized, DATA_LAYER_KEYWORDS) || hasSegment(normalized, "db");
59
111
  }
60
112
  export function isSecuritySensitivePath(normalized) {
61
- return (normalized.includes("auth") ||
62
- normalized.includes("secret") ||
63
- normalized.includes("token") ||
64
- normalized.includes("permission") ||
65
- normalized.includes("session"));
113
+ return includesAny(normalized, SECURITY_KEYWORDS);
66
114
  }
67
115
  export function isConcurrencyPath(normalized) {
68
- return (normalized.includes("queue") ||
69
- normalized.includes("worker") ||
70
- normalized.includes("job") ||
71
- normalized.includes("cache") ||
72
- normalized.includes("retry") ||
73
- normalized.includes("lock"));
116
+ return includesAny(normalized, CONCURRENCY_KEYWORDS);
74
117
  }
75
118
  export function isScriptPath(normalized) {
76
- return (normalized.includes("script") ||
77
- normalized.startsWith("scripts/") ||
78
- normalized.startsWith("bin/"));
119
+ return (includesAny(normalized, SCRIPT_KEYWORDS) ||
120
+ hasSegment(normalized, "scripts") ||
121
+ hasSegment(normalized, "bin"));
79
122
  }
80
123
  export function isDeploymentConfigPath(normalized) {
81
- return (normalized.includes("docker") ||
82
- normalized.includes("terraform") ||
83
- normalized.includes("deploy") ||
84
- normalized.includes("workflow") ||
85
- normalized.includes("k8s") ||
86
- normalized.endsWith(".yml") ||
87
- normalized.endsWith(".yaml"));
124
+ return includesAny(normalized, DEPLOYMENT_KEYWORDS) || endsWithAny(normalized, [".yml", ".yaml"]);
88
125
  }
89
126
  export function isGeneratedPath(normalized) {
90
127
  return normalized.includes("vendor") || normalized.includes("generated");
91
128
  }
92
129
  export function isSurfacePath(normalized) {
93
- return (normalized.includes("api/") ||
94
- normalized.includes("route") ||
95
- normalized.includes("controller") ||
96
- normalized.includes("worker") ||
97
- normalized.includes("job") ||
98
- normalized.includes("command") ||
99
- normalized.includes("cli"));
130
+ return (hasSegment(normalized, "api") ||
131
+ includesAny(normalized, SURFACE_KEYWORDS) ||
132
+ hasSegment(normalized, "cli"));
133
+ }
134
+ export function isBackgroundSurfacePath(normalized) {
135
+ return includesAny(normalized, ["worker", "job"]);
136
+ }
137
+ export function isNetworkSurfacePath(normalized) {
138
+ return hasSegment(normalized, "api") || includesAny(normalized, ["route", "controller"]);
139
+ }
140
+ export function isBillingPath(normalized) {
141
+ return includesAny(normalized, BILLING_KEYWORDS);
142
+ }
143
+ export function isIdentityPath(normalized) {
144
+ return isSecuritySensitivePath(normalized) || includesAny(normalized, IDENTITY_KEYWORDS);
145
+ }
146
+ export function isAsyncTaskPath(normalized) {
147
+ return isConcurrencyPath(normalized) || includesAny(normalized, ASYNC_TASK_KEYWORDS);
100
148
  }
@@ -1,4 +1,8 @@
1
1
  import type { RepoManifest } from "../types.js";
2
2
  import type { FileDisposition } from "../types/disposition.js";
3
3
  import type { SurfaceManifest } from "../types/surfaces.js";
4
+ /**
5
+ * Detects likely execution surfaces from file paths using the shared extractor
6
+ * heuristics, primarily to seed later audit planning.
7
+ */
4
8
  export declare function buildSurfaceManifest(repoManifest: RepoManifest, disposition?: FileDisposition): SurfaceManifest;
@@ -1,12 +1,16 @@
1
1
  import { isAuditExcludedStatus } from "./disposition.js";
2
- import { isSurfacePath } from "./pathPatterns.js";
2
+ import { EXTRACTOR_HEURISTIC_NOTE, isBackgroundSurfacePath, isNetworkSurfacePath, isSurfacePath, normalizeExtractorPath, } from "./pathPatterns.js";
3
3
  function methodsForPath(path) {
4
- const normalized = path.toLowerCase();
5
- if (normalized.includes("api") || normalized.includes("route")) {
4
+ const normalized = normalizeExtractorPath(path);
5
+ if (isNetworkSurfacePath(normalized)) {
6
6
  return ["GET", "POST"];
7
7
  }
8
8
  return undefined;
9
9
  }
10
+ /**
11
+ * Detects likely execution surfaces from file paths using the shared extractor
12
+ * heuristics, primarily to seed later audit planning.
13
+ */
10
14
  export function buildSurfaceManifest(repoManifest, disposition) {
11
15
  const surfaces = [];
12
16
  const dispositionMap = new Map(disposition?.files.map((item) => [item.path, item.status]) ?? []);
@@ -15,19 +19,15 @@ export function buildSurfaceManifest(repoManifest, disposition) {
15
19
  if (status && isAuditExcludedStatus(status)) {
16
20
  continue;
17
21
  }
18
- const normalized = file.path.toLowerCase();
22
+ const normalized = normalizeExtractorPath(file.path);
19
23
  if (isSurfacePath(normalized)) {
20
24
  surfaces.push({
21
25
  id: `surface:${file.path}`,
22
- kind: normalized.includes("worker") || normalized.includes("job")
23
- ? "background"
24
- : "interface",
26
+ kind: isBackgroundSurfacePath(normalized) ? "background" : "interface",
25
27
  entrypoint: file.path,
26
- exposure: normalized.includes("api") || normalized.includes("route")
27
- ? "network"
28
- : "local",
28
+ exposure: isNetworkSurfacePath(normalized) ? "network" : "local",
29
29
  methods: methodsForPath(file.path),
30
- notes: ["Heuristic surface detection."],
30
+ notes: [EXTRACTOR_HEURISTIC_NOTE],
31
31
  });
32
32
  }
33
33
  }
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- import "./cli.js";
1
+ export {};
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- import "./cli.js";
1
+ import { runCli } from "./cli.js";
2
+ await runCli(process.argv);
@@ -9,48 +9,62 @@ import type { GraphBundle } from "../types/graph.js";
9
9
  import type { RiskRegister } from "../types/risk.js";
10
10
  import type { RuntimeValidationReport, RuntimeValidationTaskManifest } from "../types/runtimeValidation.js";
11
11
  import type { SurfaceManifest } from "../types/surfaces.js";
12
- export interface ArtifactBundle {
13
- repo_manifest?: RepoManifest;
14
- file_disposition?: FileDisposition;
15
- auto_fixes_applied?: unknown;
16
- unit_manifest?: UnitManifest;
17
- graph_bundle?: GraphBundle;
18
- surface_manifest?: SurfaceManifest;
19
- critical_flows?: CriticalFlowManifest;
20
- flow_coverage?: FlowCoverageManifest;
21
- risk_register?: RiskRegister;
22
- coverage_matrix?: CoverageMatrix;
23
- runtime_validation_tasks?: RuntimeValidationTaskManifest;
24
- runtime_validation_report?: RuntimeValidationReport;
25
- external_analyzer_results?: ExternalAnalyzerResults;
26
- audit_results?: AuditResult[];
27
- audit_tasks?: AuditTask[];
28
- requeue_tasks?: AuditTask[];
29
- audit_report?: string;
30
- audit_state?: AuditState;
31
- artifact_metadata?: ArtifactMetadataManifest;
12
+ type ArtifactPayloadMap = {
13
+ repo_manifest: RepoManifest;
14
+ file_disposition: FileDisposition;
15
+ auto_fixes_applied: unknown;
16
+ unit_manifest: UnitManifest;
17
+ graph_bundle: GraphBundle;
18
+ surface_manifest: SurfaceManifest;
19
+ critical_flows: CriticalFlowManifest;
20
+ flow_coverage: FlowCoverageManifest;
21
+ risk_register: RiskRegister;
22
+ coverage_matrix: CoverageMatrix;
23
+ runtime_validation_tasks: RuntimeValidationTaskManifest;
24
+ runtime_validation_report: RuntimeValidationReport;
25
+ external_analyzer_results: ExternalAnalyzerResults;
26
+ audit_results: AuditResult[];
27
+ audit_tasks: AuditTask[];
28
+ requeue_tasks: AuditTask[];
29
+ audit_report: string;
30
+ audit_state: AuditState;
31
+ artifact_metadata: ArtifactMetadataManifest;
32
+ };
33
+ /**
34
+ * Audit artifacts accumulate phase-by-phase as the orchestrator advances.
35
+ * Missing keys mean the corresponding artifact has not been produced yet.
36
+ */
37
+ export type ArtifactBundle = Partial<ArtifactPayloadMap>;
38
+ export type ArtifactBundleKey = keyof ArtifactPayloadMap;
39
+ type ArtifactPhase = "intake" | "analysis" | "execution" | "reporting" | "supervisor";
40
+ interface ArtifactDefinition<K extends ArtifactBundleKey = ArtifactBundleKey> {
41
+ fileName: string;
42
+ phase: ArtifactPhase;
43
+ read: (path: string) => Promise<ArtifactPayloadMap[K] | undefined>;
44
+ write: (path: string, value: ArtifactPayloadMap[K]) => Promise<void>;
32
45
  }
33
- export declare const ARTIFACT_FILE_TO_BUNDLE_KEY: {
34
- readonly "repo_manifest.json": "repo_manifest";
35
- readonly "file_disposition.json": "file_disposition";
36
- readonly "auto_fixes_applied.json": "auto_fixes_applied";
37
- readonly "unit_manifest.json": "unit_manifest";
38
- readonly "graph_bundle.json": "graph_bundle";
39
- readonly "surface_manifest.json": "surface_manifest";
40
- readonly "critical_flows.json": "critical_flows";
41
- readonly "flow_coverage.json": "flow_coverage";
42
- readonly "risk_register.json": "risk_register";
43
- readonly "coverage_matrix.json": "coverage_matrix";
44
- readonly "runtime_validation_tasks.json": "runtime_validation_tasks";
45
- readonly "runtime_validation_report.json": "runtime_validation_report";
46
- readonly "external_analyzer_results.json": "external_analyzer_results";
47
- readonly "audit_results.jsonl": "audit_results";
48
- readonly "audit_tasks.json": "audit_tasks";
49
- readonly "requeue_tasks.json": "requeue_tasks";
50
- readonly "audit-report.md": "audit_report";
51
- readonly "audit_state.json": "audit_state";
52
- readonly "artifact_metadata.json": "artifact_metadata";
46
+ export declare const ARTIFACT_DEFINITIONS: {
47
+ readonly repo_manifest: ArtifactDefinition<"repo_manifest">;
48
+ readonly file_disposition: ArtifactDefinition<"file_disposition">;
49
+ readonly auto_fixes_applied: ArtifactDefinition<"auto_fixes_applied">;
50
+ readonly unit_manifest: ArtifactDefinition<"unit_manifest">;
51
+ readonly graph_bundle: ArtifactDefinition<"graph_bundle">;
52
+ readonly surface_manifest: ArtifactDefinition<"surface_manifest">;
53
+ readonly critical_flows: ArtifactDefinition<"critical_flows">;
54
+ readonly flow_coverage: ArtifactDefinition<"flow_coverage">;
55
+ readonly risk_register: ArtifactDefinition<"risk_register">;
56
+ readonly coverage_matrix: ArtifactDefinition<"coverage_matrix">;
57
+ readonly runtime_validation_tasks: ArtifactDefinition<"runtime_validation_tasks">;
58
+ readonly runtime_validation_report: ArtifactDefinition<"runtime_validation_report">;
59
+ readonly external_analyzer_results: ArtifactDefinition<"external_analyzer_results">;
60
+ readonly audit_results: ArtifactDefinition<"audit_results">;
61
+ readonly audit_tasks: ArtifactDefinition<"audit_tasks">;
62
+ readonly requeue_tasks: ArtifactDefinition<"requeue_tasks">;
63
+ readonly audit_report: ArtifactDefinition<"audit_report">;
64
+ readonly audit_state: ArtifactDefinition<"audit_state">;
65
+ readonly artifact_metadata: ArtifactDefinition<"artifact_metadata">;
53
66
  };
67
+ export declare const ARTIFACT_FILE_TO_BUNDLE_KEY: Record<string, ArtifactBundleKey>;
54
68
  export declare function getArtifactValue(bundle: ArtifactBundle, artifactName: string): unknown;
55
69
  export declare function loadArtifactBundle(root: string): Promise<ArtifactBundle>;
56
70
  export declare function writeCoreArtifacts(root: string, bundle: ArtifactBundle): Promise<void>;
@@ -59,3 +73,4 @@ export declare function promoteFinalAuditReport(params: {
59
73
  artifactsDir: string;
60
74
  repoRoot: string;
61
75
  }): Promise<void>;
76
+ export {};