auditor-lambda 0.6.12 → 0.8.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.
Files changed (56) hide show
  1. package/README.md +0 -21
  2. package/audit-code-wrapper-lib.mjs +44 -1
  3. package/dist/cli/args.d.ts +1 -0
  4. package/dist/cli/args.js +8 -0
  5. package/dist/cli/auditStep.js +7 -1
  6. package/dist/cli/dispatch.js +14 -3
  7. package/dist/cli/nextStepCommand.js +37 -0
  8. package/dist/cli/prompts.js +2 -0
  9. package/dist/cli.d.ts +0 -1
  10. package/dist/cli.js +22 -15
  11. package/dist/extractors/fileInventory.js +15 -2
  12. package/dist/extractors/graph.js +12 -2
  13. package/dist/io/artifacts.d.ts +3 -1
  14. package/dist/io/artifacts.js +18 -2
  15. package/dist/orchestrator/advance.js +2 -1
  16. package/dist/orchestrator/artifactFreshness.js +12 -2
  17. package/dist/orchestrator/artifactMetadata.d.ts +1 -0
  18. package/dist/orchestrator/artifactMetadata.js +15 -0
  19. package/dist/orchestrator/autoFixExecutor.d.ts +1 -1
  20. package/dist/orchestrator/autoFixExecutor.js +10 -0
  21. package/dist/orchestrator/executorResult.d.ts +12 -0
  22. package/dist/orchestrator/executorResult.js +1 -0
  23. package/dist/orchestrator/fileIntegrity.d.ts +1 -0
  24. package/dist/orchestrator/fileIntegrity.js +12 -3
  25. package/dist/orchestrator/flowRequeue.js +1 -14
  26. package/dist/orchestrator/graphEnrichmentExecutor.d.ts +1 -1
  27. package/dist/orchestrator/graphEnrichmentExecutor.js +3 -1
  28. package/dist/orchestrator/internalExecutors.d.ts +1 -18
  29. package/dist/orchestrator/internalExecutors.js +1 -158
  30. package/dist/orchestrator/reviewPacketGraph.d.ts +31 -0
  31. package/dist/orchestrator/reviewPacketGraph.js +691 -0
  32. package/dist/orchestrator/reviewPacketSizing.d.ts +25 -0
  33. package/dist/orchestrator/reviewPacketSizing.js +60 -0
  34. package/dist/orchestrator/reviewPackets.d.ts +3 -28
  35. package/dist/orchestrator/reviewPackets.js +6 -740
  36. package/dist/orchestrator/runtimeCommand.d.ts +11 -0
  37. package/dist/orchestrator/runtimeCommand.js +79 -0
  38. package/dist/orchestrator/scope.js +1 -1
  39. package/dist/orchestrator/syntaxResolutionExecutor.d.ts +1 -1
  40. package/dist/orchestrator/synthesisExecutors.d.ts +12 -0
  41. package/dist/orchestrator/synthesisExecutors.js +90 -0
  42. package/dist/orchestrator.js +1 -4
  43. package/dist/quota/index.d.ts +1 -1
  44. package/dist/quota/index.js +1 -1
  45. package/dist/types/workerSession.d.ts +1 -3
  46. package/dist/types.d.ts +6 -0
  47. package/dist/types.js +20 -1
  48. package/docs/development.md +35 -139
  49. package/docs/history.md +26 -0
  50. package/docs/product.md +41 -108
  51. package/package.json +1 -1
  52. package/schemas/audit_findings.schema.json +3 -2
  53. package/schemas/dispatch_quota.schema.json +2 -0
  54. package/schemas/external_analyzer_results.schema.json +2 -2
  55. package/schemas/repo_manifest.schema.json +1 -1
  56. package/docs/handoff.md +0 -204
@@ -0,0 +1,25 @@
1
+ import type { AuditTask } from "../types.js";
2
+ export declare const DEFAULT_MAX_TASKS_PER_PACKET = 0;
3
+ export declare const ESTIMATED_TOKENS_PER_LINE = 4;
4
+ export declare const ESTIMATED_PACKET_PROMPT_TOKENS = 900;
5
+ export declare const DEFAULT_TARGET_PACKET_TOKENS: number;
6
+ /**
7
+ * Build a path → size_bytes index from a repo manifest. Byte counts are
8
+ * recorded during intake, so this never reads files. Review packet token
9
+ * estimates are derived from these bytes (Phase 2) instead of counted lines.
10
+ */
11
+ export declare function sizeIndexFromManifest(repoManifest?: {
12
+ files: ReadonlyArray<{
13
+ path: string;
14
+ size_bytes: number;
15
+ }>;
16
+ }): Record<string, number>;
17
+ /** Estimated content tokens for one task across all of its files. */
18
+ export declare function taskContentTokens(task: AuditTask, sizeIndex?: Record<string, number>, lineIndex?: Record<string, number>): number;
19
+ /**
20
+ * Estimated content tokens across a set of file paths, resolving an owning task
21
+ * per path so the line fallback can read its `file_line_counts`. Shared files
22
+ * are counted once.
23
+ */
24
+ export declare function fileGroupContentTokens(filePaths: Iterable<string>, tasks: AuditTask[], sizeIndex?: Record<string, number>, lineIndex?: Record<string, number>): number;
25
+ export declare function estimateTaskGroupTokens(tasks: AuditTask[], sizeIndex?: Record<string, number>, lineIndex?: Record<string, number>): number;
@@ -0,0 +1,60 @@
1
+ import { estimateTokensFromBytes } from "@audit-tools/shared";
2
+ // Per-packet sizing / token-budget arithmetic for review packetization,
3
+ // extracted from reviewPackets.ts. Estimates derive from manifest byte counts
4
+ // (recorded at intake) with a line-count fallback for manually built tasks.
5
+ export const DEFAULT_MAX_TASKS_PER_PACKET = 0;
6
+ const DEFAULT_TARGET_PACKET_LINES = 8000;
7
+ export const ESTIMATED_TOKENS_PER_LINE = 4;
8
+ export const ESTIMATED_PACKET_PROMPT_TOKENS = 900;
9
+ // Default per-packet content-token budget. Kept equal to the legacy
10
+ // line-target × per-line estimate so byte-derived sizing lands on the same
11
+ // thresholds as the old line-based sizing when the line fallback is in effect.
12
+ export const DEFAULT_TARGET_PACKET_TOKENS = DEFAULT_TARGET_PACKET_LINES * ESTIMATED_TOKENS_PER_LINE;
13
+ /**
14
+ * Build a path → size_bytes index from a repo manifest. Byte counts are
15
+ * recorded during intake, so this never reads files. Review packet token
16
+ * estimates are derived from these bytes (Phase 2) instead of counted lines.
17
+ */
18
+ export function sizeIndexFromManifest(repoManifest) {
19
+ if (!repoManifest)
20
+ return {};
21
+ return Object.fromEntries(repoManifest.files.map((file) => [file.path, file.size_bytes]));
22
+ }
23
+ /**
24
+ * Estimated content tokens for a single file. Prefers a byte-based estimate
25
+ * from `sizeIndex` (sourced from the repo manifest); falls back to the legacy
26
+ * line-based estimate when no positive byte count is available (e.g. manually
27
+ * built tasks in tests, or paths absent from the manifest).
28
+ */
29
+ function pathContentTokens(owner, path, sizeIndex, lineIndex) {
30
+ const bytes = sizeIndex?.[path];
31
+ if (typeof bytes === "number" && bytes > 0) {
32
+ return estimateTokensFromBytes(bytes);
33
+ }
34
+ const lines = owner?.file_line_counts?.[path] ?? lineIndex?.[path] ?? 0;
35
+ return lines * ESTIMATED_TOKENS_PER_LINE;
36
+ }
37
+ /** Estimated content tokens for one task across all of its files. */
38
+ export function taskContentTokens(task, sizeIndex, lineIndex) {
39
+ return task.file_paths.reduce((sum, path) => sum + pathContentTokens(task, path, sizeIndex, lineIndex), 0);
40
+ }
41
+ /**
42
+ * Estimated content tokens across a set of file paths, resolving an owning task
43
+ * per path so the line fallback can read its `file_line_counts`. Shared files
44
+ * are counted once.
45
+ */
46
+ export function fileGroupContentTokens(filePaths, tasks, sizeIndex, lineIndex) {
47
+ let total = 0;
48
+ for (const path of filePaths) {
49
+ const owner = tasks.find((task) => task.file_paths.includes(path));
50
+ total += pathContentTokens(owner, path, sizeIndex, lineIndex);
51
+ }
52
+ return total;
53
+ }
54
+ export function estimateTaskGroupTokens(tasks, sizeIndex, lineIndex) {
55
+ let contentTokens = 0;
56
+ for (const task of tasks) {
57
+ contentTokens += taskContentTokens(task, sizeIndex, lineIndex);
58
+ }
59
+ return ESTIMATED_PACKET_PROMPT_TOKENS + contentTokens;
60
+ }
@@ -1,28 +1,10 @@
1
1
  import type { AuditTask } from "../types.js";
2
2
  import type { AuditPlanMetrics, ReviewPacket } from "../types/reviewPlanning.js";
3
- import type { GraphBundle, GraphEdge } from "@audit-tools/shared";
3
+ import type { GraphBundle } from "@audit-tools/shared";
4
4
  import { normalizeGraphPath } from "../extractors/graphPathUtils.js";
5
+ import { ESTIMATED_TOKENS_PER_LINE, ESTIMATED_PACKET_PROMPT_TOKENS, sizeIndexFromManifest, estimateTaskGroupTokens } from "./reviewPacketSizing.js";
5
6
  export { normalizeGraphPath };
6
- export declare const ESTIMATED_TOKENS_PER_LINE = 4;
7
- export declare const ESTIMATED_PACKET_PROMPT_TOKENS = 900;
8
- /**
9
- * Build a path → size_bytes index from a repo manifest. Byte counts are
10
- * recorded during intake, so this never reads files. Review packet token
11
- * estimates are derived from these bytes (Phase 2) instead of counted lines.
12
- */
13
- export declare function sizeIndexFromManifest(repoManifest?: {
14
- files: ReadonlyArray<{
15
- path: string;
16
- size_bytes: number;
17
- }>;
18
- }): Record<string, number>;
19
- export declare function estimateTaskGroupTokens(tasks: AuditTask[], sizeIndex?: Record<string, number>, lineIndex?: Record<string, number>): number;
20
- /**
21
- * Fan-in / fan-out degree above which a node is treated as a hub. Exported so
22
- * the Phase 3 delta-scope expansion skips the same hubs that packet planning
23
- * skips, preventing scope blow-up through highly-connected modules.
24
- */
25
- export declare const HIGH_FAN_DEGREE_THRESHOLD = 12;
7
+ export { ESTIMATED_TOKENS_PER_LINE, ESTIMATED_PACKET_PROMPT_TOKENS, sizeIndexFromManifest, estimateTaskGroupTokens, };
26
8
  export interface BuildReviewPacketOptions {
27
9
  graphBundle?: GraphBundle;
28
10
  lineIndex?: Record<string, number>;
@@ -42,13 +24,6 @@ export interface BuildReviewPacketOptions {
42
24
  */
43
25
  maxContextTokens?: number;
44
26
  }
45
- export declare function collectGraphEdges(graphBundle?: GraphBundle): GraphEdge[];
46
- export declare function graphEdgeConfidence(edge: GraphEdge): number;
47
- export interface GraphDegreeIndex {
48
- fanIn: Map<string, number>;
49
- fanOut: Map<string, number>;
50
- }
51
- export declare function buildGraphDegreeIndex(edges: GraphEdge[]): GraphDegreeIndex;
52
27
  export declare function buildReviewPackets(tasks: AuditTask[], options?: BuildReviewPacketOptions): ReviewPacket[];
53
28
  export declare function orderTasksForPacketReview(tasks: AuditTask[], options?: BuildReviewPacketOptions): AuditTask[];
54
29
  export declare function buildAuditPlanMetrics(tasks: AuditTask[], options?: BuildReviewPacketOptions & {