auditor-lambda 0.3.39 → 0.3.41

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 (148) hide show
  1. package/audit-code-wrapper-lib.mjs +20 -2
  2. package/dist/cli/args.d.ts +59 -0
  3. package/dist/cli/args.js +244 -0
  4. package/dist/cli/dispatch.d.ts +80 -0
  5. package/dist/cli/dispatch.js +528 -0
  6. package/dist/cli/prompts.d.ts +18 -0
  7. package/dist/cli/prompts.js +130 -0
  8. package/dist/cli/steps.d.ts +29 -0
  9. package/dist/cli/steps.js +30 -0
  10. package/dist/cli/waveManifest.d.ts +40 -0
  11. package/dist/cli/waveManifest.js +41 -0
  12. package/dist/cli/workerResult.d.ts +18 -0
  13. package/dist/cli/workerResult.js +42 -0
  14. package/dist/cli.d.ts +2 -22
  15. package/dist/cli.js +373 -990
  16. package/dist/extractors/browserExtension.d.ts +1 -3
  17. package/dist/extractors/browserExtension.js +2 -2
  18. package/dist/extractors/designAssessment.d.ts +1 -3
  19. package/dist/extractors/disposition.d.ts +2 -1
  20. package/dist/extractors/disposition.js +3 -0
  21. package/dist/extractors/flows.d.ts +1 -3
  22. package/dist/extractors/flows.js +2 -2
  23. package/dist/extractors/graph.d.ts +1 -2
  24. package/dist/extractors/graph.js +4 -326
  25. package/dist/extractors/graphManifestEdges.d.ts +1 -1
  26. package/dist/extractors/graphPathUtils.d.ts +1 -1
  27. package/dist/extractors/graphPythonImports.d.ts +3 -0
  28. package/dist/extractors/graphPythonImports.js +326 -0
  29. package/dist/extractors/risk.d.ts +1 -2
  30. package/dist/extractors/surfaces.d.ts +1 -3
  31. package/dist/extractors/surfaces.js +2 -2
  32. package/dist/io/artifacts.d.ts +1 -5
  33. package/dist/io/artifacts.js +1 -1
  34. package/dist/io/runArtifacts.js +1 -1
  35. package/dist/mcp/server.js +1 -1
  36. package/dist/orchestrator/advance.d.ts +1 -0
  37. package/dist/orchestrator/advance.js +8 -5
  38. package/dist/orchestrator/auditTaskUtils.d.ts +4 -0
  39. package/dist/orchestrator/auditTaskUtils.js +27 -0
  40. package/dist/orchestrator/fileAnchors.d.ts +1 -1
  41. package/dist/orchestrator/fileIntegrity.d.ts +7 -0
  42. package/dist/orchestrator/fileIntegrity.js +41 -0
  43. package/dist/orchestrator/flowCoverage.d.ts +1 -1
  44. package/dist/orchestrator/flowPlanning.d.ts +1 -1
  45. package/dist/orchestrator/flowRequeue.d.ts +1 -1
  46. package/dist/orchestrator/internalExecutors.d.ts +3 -1
  47. package/dist/orchestrator/internalExecutors.js +23 -5
  48. package/dist/orchestrator/nextStep.d.ts +2 -1
  49. package/dist/orchestrator/nextStep.js +1 -1
  50. package/dist/orchestrator/planning.d.ts +1 -1
  51. package/dist/orchestrator/requeueCommand.d.ts +1 -1
  52. package/dist/orchestrator/reviewPackets.d.ts +1 -1
  53. package/dist/orchestrator/reviewPackets.js +21 -113
  54. package/dist/orchestrator/runtimeValidation.d.ts +1 -1
  55. package/dist/orchestrator/taskBuilder.d.ts +1 -1
  56. package/dist/orchestrator/taskBuilder.js +1 -12
  57. package/dist/orchestrator/unionFind.d.ts +7 -0
  58. package/dist/orchestrator/unionFind.js +32 -0
  59. package/dist/orchestrator/unitBuilder.d.ts +2 -2
  60. package/dist/orchestrator/unitBuilder.js +4 -18
  61. package/dist/prompts/renderWorkerPrompt.js +18 -1
  62. package/dist/providers/claudeCodeProvider.d.ts +4 -4
  63. package/dist/providers/claudeCodeProvider.js +9 -3
  64. package/dist/providers/constants.d.ts +1 -1
  65. package/dist/providers/constants.js +1 -1
  66. package/dist/providers/index.d.ts +1 -2
  67. package/dist/providers/index.js +5 -4
  68. package/dist/providers/localSubprocessProvider.d.ts +2 -2
  69. package/dist/providers/localSubprocessProvider.js +1 -1
  70. package/dist/providers/opencodeProvider.d.ts +4 -4
  71. package/dist/providers/opencodeProvider.js +7 -2
  72. package/dist/providers/spawnLoggedCommand.d.ts +3 -1
  73. package/dist/providers/spawnLoggedCommand.js +21 -0
  74. package/dist/providers/subprocessTemplateProvider.d.ts +4 -4
  75. package/dist/providers/subprocessTemplateProvider.js +8 -3
  76. package/dist/providers/vscodeTaskProvider.d.ts +3 -4
  77. package/dist/providers/vscodeTaskProvider.js +2 -2
  78. package/dist/quota/discoveredLimits.js +1 -1
  79. package/dist/quota/hostLimits.d.ts +1 -2
  80. package/dist/quota/hostLimits.js +4 -46
  81. package/dist/quota/index.d.ts +18 -15
  82. package/dist/quota/index.js +4 -9
  83. package/dist/quota/scheduler.d.ts +1 -3
  84. package/dist/quota/scheduler.js +1 -2
  85. package/dist/reporting/synthesis.d.ts +1 -2
  86. package/dist/reporting/synthesis.js +2 -0
  87. package/dist/reporting/workBlocks.d.ts +1 -2
  88. package/dist/supervisor/operatorHandoff.js +1 -1
  89. package/dist/supervisor/runLedger.d.ts +1 -1
  90. package/dist/supervisor/runLedger.js +2 -2
  91. package/dist/supervisor/sessionConfig.d.ts +1 -1
  92. package/dist/supervisor/sessionConfig.js +1 -3
  93. package/dist/types/reviewPlanning.d.ts +1 -1
  94. package/dist/types/workerSession.d.ts +6 -0
  95. package/dist/validation/artifacts.d.ts +1 -1
  96. package/dist/validation/artifacts.js +1 -1
  97. package/dist/validation/auditResults.d.ts +2 -1
  98. package/dist/validation/auditResults.js +31 -13
  99. package/dist/validation/sessionConfig.d.ts +2 -3
  100. package/dist/validation/sessionConfig.js +2 -3
  101. package/package.json +4 -2
  102. package/scripts/postinstall.mjs +0 -1
  103. package/dist/io/json.d.ts +0 -10
  104. package/dist/io/json.js +0 -142
  105. package/dist/providers/types.d.ts +0 -33
  106. package/dist/providers/types.js +0 -1
  107. package/dist/quota/compositeQuotaSource.d.ts +0 -7
  108. package/dist/quota/compositeQuotaSource.js +0 -20
  109. package/dist/quota/errorParsers/claudeCodeErrorParser.d.ts +0 -6
  110. package/dist/quota/errorParsers/claudeCodeErrorParser.js +0 -39
  111. package/dist/quota/errorParsers/genericErrorParser.d.ts +0 -9
  112. package/dist/quota/errorParsers/genericErrorParser.js +0 -7
  113. package/dist/quota/errorParsers/index.d.ts +0 -5
  114. package/dist/quota/errorParsers/index.js +0 -12
  115. package/dist/quota/errorParsing.d.ts +0 -7
  116. package/dist/quota/errorParsing.js +0 -69
  117. package/dist/quota/fileLock.d.ts +0 -6
  118. package/dist/quota/fileLock.js +0 -64
  119. package/dist/quota/learnedQuotaSource.d.ts +0 -7
  120. package/dist/quota/learnedQuotaSource.js +0 -25
  121. package/dist/quota/limits.d.ts +0 -16
  122. package/dist/quota/limits.js +0 -77
  123. package/dist/quota/quotaSource.d.ts +0 -12
  124. package/dist/quota/quotaSource.js +0 -1
  125. package/dist/quota/slidingWindow.d.ts +0 -4
  126. package/dist/quota/slidingWindow.js +0 -28
  127. package/dist/quota/state.d.ts +0 -15
  128. package/dist/quota/state.js +0 -148
  129. package/dist/quota/types.d.ts +0 -67
  130. package/dist/quota/types.js +0 -1
  131. package/dist/reporting/rootCause.d.ts +0 -10
  132. package/dist/reporting/rootCause.js +0 -146
  133. package/dist/types/disposition.d.ts +0 -9
  134. package/dist/types/disposition.js +0 -1
  135. package/dist/types/flows.d.ts +0 -17
  136. package/dist/types/flows.js +0 -1
  137. package/dist/types/graph.d.ts +0 -22
  138. package/dist/types/graph.js +0 -1
  139. package/dist/types/risk.d.ts +0 -9
  140. package/dist/types/risk.js +0 -1
  141. package/dist/types/runLedger.d.ts +0 -17
  142. package/dist/types/runLedger.js +0 -6
  143. package/dist/types/sessionConfig.d.ts +0 -79
  144. package/dist/types/sessionConfig.js +0 -15
  145. package/dist/types/surfaces.d.ts +0 -15
  146. package/dist/types/surfaces.js +0 -1
  147. package/dist/validation/basic.d.ts +0 -13
  148. package/dist/validation/basic.js +0 -46
@@ -1,4 +1,4 @@
1
- import { readJsonFile } from "../io/json.js";
1
+ import { readJsonFile } from "@audit-tools/shared";
2
2
  import { spawnLoggedCommand } from "./spawnLoggedCommand.js";
3
3
  function shellQuote(arg) {
4
4
  return JSON.stringify(arg);
@@ -25,9 +25,11 @@ function applyTemplate(template, input, task) {
25
25
  export class SubprocessTemplateProvider {
26
26
  name;
27
27
  config;
28
- constructor(config, name = "subprocess-template") {
28
+ opentoken;
29
+ constructor(config, name = "subprocess-template", opentoken = {}) {
29
30
  this.config = config;
30
31
  this.name = name;
32
+ this.opentoken = opentoken;
31
33
  }
32
34
  async launch(input) {
33
35
  const task = await readJsonFile(input.taskPath);
@@ -36,6 +38,9 @@ export class SubprocessTemplateProvider {
36
38
  }
37
39
  const rendered = this.config.command_template.map((entry) => applyTemplate(entry, input, task));
38
40
  const [command, ...args] = rendered;
39
- return await spawnLoggedCommand(command, args, input, this.config.env);
41
+ return await spawnLoggedCommand(command, args, input, this.config.env, {
42
+ opentoken: this.opentoken.enabled,
43
+ opentokenCommand: this.opentoken.command,
44
+ });
40
45
  }
41
46
  }
@@ -1,8 +1,7 @@
1
- import type { FreshSessionProvider, LaunchFreshSessionInput } from "./types.js";
2
- import type { VSCodeTaskConfig } from "../types/sessionConfig.js";
1
+ import type { FreshSessionProvider, LaunchFreshSessionInput, VSCodeTaskConfig, OpenTokenConfig } from "@audit-tools/shared";
3
2
  export declare class VSCodeTaskProvider implements FreshSessionProvider {
4
3
  name: string;
5
4
  private readonly delegate;
6
- constructor(config: VSCodeTaskConfig);
7
- launch(input: LaunchFreshSessionInput): Promise<import("./types.js").LaunchFreshSessionResult>;
5
+ constructor(config: VSCodeTaskConfig, opentoken?: OpenTokenConfig);
6
+ launch(input: LaunchFreshSessionInput): Promise<import("@audit-tools/shared").LaunchFreshSessionResult>;
8
7
  }
@@ -2,11 +2,11 @@ import { SubprocessTemplateProvider } from "./subprocessTemplateProvider.js";
2
2
  export class VSCodeTaskProvider {
3
3
  name = "vscode-task";
4
4
  delegate;
5
- constructor(config) {
5
+ constructor(config, opentoken = {}) {
6
6
  this.delegate = new SubprocessTemplateProvider({
7
7
  command_template: config.command_template,
8
8
  env: config.env,
9
- }, "vscode-task");
9
+ }, "vscode-task", opentoken);
10
10
  }
11
11
  async launch(input) {
12
12
  return await this.delegate.launch(input);
@@ -1,6 +1,6 @@
1
1
  import { mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import { dirname } from "node:path";
3
- import { getQuotaStatePath } from "./state.js";
3
+ import { getQuotaStatePath } from "@audit-tools/shared";
4
4
  function getCachePath() {
5
5
  return getQuotaStatePath().replace(/quota-state\.json$/, "discovered-limits.json");
6
6
  }
@@ -1,5 +1,4 @@
1
- import type { SessionConfig } from "../types/sessionConfig.js";
2
- import type { HostConcurrencyLimit } from "./types.js";
1
+ import type { SessionConfig, HostConcurrencyLimit } from "@audit-tools/shared";
3
2
  export declare function detectHostActiveSubagentLimit(env?: NodeJS.ProcessEnv): HostConcurrencyLimit | null;
4
3
  export declare function resolveHostActiveSubagentLimit(options: {
5
4
  explicitLimit?: number | null;
@@ -1,50 +1,8 @@
1
- const CODEX_DESKTOP_ACTIVE_SUBAGENT_LIMIT = 6;
2
- function parsePositiveInteger(value) {
3
- if (typeof value === "number") {
4
- return Number.isInteger(value) && value > 0 ? value : null;
5
- }
6
- if (typeof value !== "string")
7
- return null;
8
- const trimmed = value.trim();
9
- if (!/^\d+$/.test(trimmed))
10
- return null;
11
- const parsed = Number(trimmed);
12
- return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
13
- }
1
+ import { detectHostActiveSubagentLimit as detectShared, resolveHostActiveSubagentLimit as resolveShared, } from "@audit-tools/shared";
2
+ const ENV_PREFIX = "AUDIT_CODE";
14
3
  export function detectHostActiveSubagentLimit(env = process.env) {
15
- const explicitEnvLimit = parsePositiveInteger(env.AUDIT_CODE_HOST_MAX_ACTIVE_SUBAGENTS ??
16
- env.CODEX_MAX_ACTIVE_SUBAGENTS);
17
- if (explicitEnvLimit !== null) {
18
- return {
19
- active_subagents: explicitEnvLimit,
20
- source: "environment",
21
- description: "Host active subagent limit from environment.",
22
- };
23
- }
24
- if (env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop") {
25
- return {
26
- active_subagents: CODEX_DESKTOP_ACTIVE_SUBAGENT_LIMIT,
27
- source: "environment",
28
- description: "Codex Desktop active subagent limit.",
29
- };
30
- }
31
- return null;
4
+ return detectShared(ENV_PREFIX, env);
32
5
  }
33
6
  export function resolveHostActiveSubagentLimit(options) {
34
- if (options.explicitLimit !== undefined && options.explicitLimit !== null) {
35
- return {
36
- active_subagents: options.explicitLimit,
37
- source: "cli_flags",
38
- description: "Host active subagent limit reported by the conversation host.",
39
- };
40
- }
41
- const configuredLimit = parsePositiveInteger(options.sessionConfig.quota?.host_active_subagent_limit);
42
- if (configuredLimit !== null) {
43
- return {
44
- active_subagents: configuredLimit,
45
- source: "session_config",
46
- description: "Host active subagent limit from session-config quota settings.",
47
- };
48
- }
49
- return detectHostActiveSubagentLimit(options.env);
7
+ return resolveShared({ envPrefix: ENV_PREFIX, ...options });
50
8
  }
@@ -1,25 +1,28 @@
1
- export { resolveLimits, lookupKnownModel, classifyProvider } from "./limits.js";
2
- export type { LimitResolutionResult, ResolveLimitsOptions, ProviderType } from "./limits.js";
3
- export { detectHostActiveSubagentLimit, resolveHostActiveSubagentLimit, } from "./hostLimits.js";
4
- export { readQuotaState, writeQuotaState, computeMaxSafeConcurrency, recordWaveOutcome, getQuotaStatePath, decayWeight, applyDecayToEntry, computeBackoffCooldownMs, computeBackoffFailureWeight, computeRampUpConcurrency, } from "./state.js";
1
+ import type { ResolvedLimits as _ResolvedLimits, LimitConfidence as _LimitConfidence, LimitSource as _LimitSource, HostConcurrencyLimit as _HostConcurrencyLimit, QuotaUsageSnapshot as _QuotaUsageSnapshot, BackoffState as _BackoffState } from "@audit-tools/shared";
2
+ export { resolveLimits, lookupKnownModel, classifyProvider, readQuotaState, writeQuotaState, computeMaxSafeConcurrency, recordWaveOutcome, getQuotaStatePath, decayWeight, applyDecayToEntry, computeBackoffCooldownMs, computeBackoffFailureWeight, computeRampUpConcurrency, setQuotaStateDir, detectRateLimitError, computeCooldownUntil, acquireLock, releaseLock, withFileLock, FileLockTimeoutError, runSlidingWindow, LearnedQuotaSource, CompositeQuotaSource, GenericErrorParser, ClaudeCodeErrorParser, getErrorParserForProvider, } from "@audit-tools/shared";
3
+ export type { LimitResolutionResult, ResolveLimitsOptions, ProviderType, ResolvedLimits, LimitSource, LimitConfidence, HostConcurrencyLimit, HostConcurrencyLimitSource, QuotaState, QuotaStateEntry, ConcurrencyBucket, WaveSchedule, BackoffState, ObservedWaveOutcome, RateLimitDetectionResult, SlidingWindowResult, QuotaSource, QuotaUsageSnapshot, ErrorParser, } from "@audit-tools/shared";
5
4
  export { scheduleWave, buildProviderModelKey } from "./scheduler.js";
6
5
  export type { ScheduleWaveOptions } from "./scheduler.js";
7
- export { detectRateLimitError, computeCooldownUntil } from "./errorParsing.js";
8
- export { acquireLock, releaseLock, withFileLock, FileLockTimeoutError } from "./fileLock.js";
9
- export { runSlidingWindow } from "./slidingWindow.js";
10
- export type { SlidingWindowResult } from "./slidingWindow.js";
11
- export type { RateLimitDetectionResult } from "./errorParsing.js";
6
+ export { detectHostActiveSubagentLimit, resolveHostActiveSubagentLimit, } from "./hostLimits.js";
12
7
  export { probeProvider } from "./probe.js";
13
8
  export type { ProbeResult } from "./probe.js";
14
- export type { QuotaSource, QuotaUsageSnapshot } from "./quotaSource.js";
15
- export type { ErrorParser } from "./errorParsers/index.js";
16
- export { GenericErrorParser, ClaudeCodeErrorParser, getErrorParserForProvider } from "./errorParsers/index.js";
17
- export { LearnedQuotaSource } from "./learnedQuotaSource.js";
18
- export { CompositeQuotaSource } from "./compositeQuotaSource.js";
19
9
  export { lookupDiscoveredLimits, updateDiscoveredLimits, mergeDiscoveredLimits, readDiscoveredLimitsCache, writeDiscoveredLimitsCache, } from "./discoveredLimits.js";
20
10
  export type { DiscoveredRateLimits, DiscoveredLimitsCache, DiscoveredLimitsCacheEntry } from "./discoveredLimits.js";
21
11
  export { extractRateLimitHeaders } from "./headerExtraction.js";
22
12
  export type { ExtractedRateLimits } from "./headerExtraction.js";
23
13
  export type { HeaderExtractor } from "./headerExtractors/index.js";
24
14
  export { GenericHeaderExtractor, ClaudeCodeHeaderExtractor, getHeaderExtractorForProvider } from "./headerExtractors/index.js";
25
- export type { ResolvedLimits, LimitSource, LimitConfidence, HostConcurrencyLimit, HostConcurrencyLimitSource, QuotaState, QuotaStateEntry, ConcurrencyBucket, WaveSchedule, DispatchQuota, ObservedWaveOutcome, } from "./types.js";
15
+ export interface DispatchQuota {
16
+ contract_version: "audit-code-dispatch-quota/v1alpha1" | "audit-code-dispatch-quota/v1alpha2";
17
+ run_id: string;
18
+ model: string | null;
19
+ resolved_limits: _ResolvedLimits;
20
+ confidence: _LimitConfidence;
21
+ source: _LimitSource;
22
+ host_concurrency_limit: _HostConcurrencyLimit | null;
23
+ wave_size: number;
24
+ estimated_wave_tokens: number;
25
+ cooldown_until: string | null;
26
+ quota_source_snapshot?: _QuotaUsageSnapshot | null;
27
+ backoff_state?: _BackoffState | null;
28
+ }
@@ -1,14 +1,9 @@
1
- export { resolveLimits, lookupKnownModel, classifyProvider } from "./limits.js";
2
- export { detectHostActiveSubagentLimit, resolveHostActiveSubagentLimit, } from "./hostLimits.js";
3
- export { readQuotaState, writeQuotaState, computeMaxSafeConcurrency, recordWaveOutcome, getQuotaStatePath, decayWeight, applyDecayToEntry, computeBackoffCooldownMs, computeBackoffFailureWeight, computeRampUpConcurrency, } from "./state.js";
1
+ // Re-exported from @audit-tools/shared
2
+ export { resolveLimits, lookupKnownModel, classifyProvider, readQuotaState, writeQuotaState, computeMaxSafeConcurrency, recordWaveOutcome, getQuotaStatePath, decayWeight, applyDecayToEntry, computeBackoffCooldownMs, computeBackoffFailureWeight, computeRampUpConcurrency, setQuotaStateDir, detectRateLimitError, computeCooldownUntil, acquireLock, releaseLock, withFileLock, FileLockTimeoutError, runSlidingWindow, LearnedQuotaSource, CompositeQuotaSource, GenericErrorParser, ClaudeCodeErrorParser, getErrorParserForProvider, } from "@audit-tools/shared";
3
+ // Auditor-specific: local scheduler, probe, discovered limits, header extraction
4
4
  export { scheduleWave, buildProviderModelKey } from "./scheduler.js";
5
- export { detectRateLimitError, computeCooldownUntil } from "./errorParsing.js";
6
- export { acquireLock, releaseLock, withFileLock, FileLockTimeoutError } from "./fileLock.js";
7
- export { runSlidingWindow } from "./slidingWindow.js";
5
+ export { detectHostActiveSubagentLimit, resolveHostActiveSubagentLimit, } from "./hostLimits.js";
8
6
  export { probeProvider } from "./probe.js";
9
- export { GenericErrorParser, ClaudeCodeErrorParser, getErrorParserForProvider } from "./errorParsers/index.js";
10
- export { LearnedQuotaSource } from "./learnedQuotaSource.js";
11
- export { CompositeQuotaSource } from "./compositeQuotaSource.js";
12
7
  export { lookupDiscoveredLimits, updateDiscoveredLimits, mergeDiscoveredLimits, readDiscoveredLimitsCache, writeDiscoveredLimitsCache, } from "./discoveredLimits.js";
13
8
  export { extractRateLimitHeaders } from "./headerExtraction.js";
14
9
  export { GenericHeaderExtractor, ClaudeCodeHeaderExtractor, getHeaderExtractorForProvider } from "./headerExtractors/index.js";
@@ -1,6 +1,4 @@
1
- import type { ResolvedProviderName, SessionConfig } from "../types/sessionConfig.js";
2
- import type { HostConcurrencyLimit, QuotaStateEntry, WaveSchedule } from "./types.js";
3
- import type { QuotaUsageSnapshot } from "./quotaSource.js";
1
+ import type { ResolvedProviderName, SessionConfig, HostConcurrencyLimit, QuotaStateEntry, WaveSchedule, QuotaUsageSnapshot } from "@audit-tools/shared";
4
2
  import type { DiscoveredRateLimits } from "./discoveredLimits.js";
5
3
  export interface ScheduleWaveOptions {
6
4
  providerName: ResolvedProviderName;
@@ -1,5 +1,4 @@
1
- import { classifyProvider, resolveLimits } from "./limits.js";
2
- import { computeMaxSafeConcurrency, computeRampUpConcurrency } from "./state.js";
1
+ import { classifyProvider, resolveLimits, computeMaxSafeConcurrency, computeRampUpConcurrency } from "@audit-tools/shared";
3
2
  function sumTopN(sorted, n) {
4
3
  let sum = 0;
5
4
  for (let i = 0; i < Math.min(n, sorted.length); i++)
@@ -1,8 +1,7 @@
1
1
  import type { AuditResult, CoverageMatrix, Finding, UnitManifest } from "../types.js";
2
2
  import type { DesignAssessment } from "../types/designAssessment.js";
3
3
  import type { ExternalAnalyzerResults } from "../types/externalAnalyzer.js";
4
- import type { CriticalFlowManifest } from "../types/flows.js";
5
- import type { GraphBundle } from "../types/graph.js";
4
+ import type { CriticalFlowManifest, GraphBundle } from "@audit-tools/shared";
6
5
  import type { RuntimeValidationReport } from "../types/runtimeValidation.js";
7
6
  import { type WorkBlock } from "./workBlocks.js";
8
7
  export interface AuditReportSummary {
@@ -1,3 +1,4 @@
1
+ import { AUDITOR_REPORT_MARKER } from "@audit-tools/shared";
1
2
  import { buildWorkBlocks } from "./workBlocks.js";
2
3
  import { mergeFindings } from "./mergeFindings.js";
3
4
  function countBy(items, selectKey) {
@@ -55,6 +56,7 @@ export function buildAuditReportModel(params) {
55
56
  }
56
57
  export function renderAuditReportMarkdown(model) {
57
58
  const lines = [
59
+ AUDITOR_REPORT_MARKER,
58
60
  "# Audit Report",
59
61
  "",
60
62
  "## Summary",
@@ -1,6 +1,5 @@
1
1
  import type { Finding, UnitManifest } from "../types.js";
2
- import type { CriticalFlowManifest } from "../types/flows.js";
3
- import type { GraphBundle } from "../types/graph.js";
2
+ import type { CriticalFlowManifest, GraphBundle } from "@audit-tools/shared";
4
3
  export interface WorkBlock {
5
4
  id: string;
6
5
  finding_ids: string[];
@@ -1,6 +1,6 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { writeJsonFile } from "../io/json.js";
3
+ import { writeJsonFile } from "@audit-tools/shared";
4
4
  import { LOCAL_SUBPROCESS_PROVIDER_NAME } from "../providers/constants.js";
5
5
  export const CONFIG_ERROR_BLOCKER_PREFIX = "config-error:";
6
6
  const INCOMING_DIRNAME = "incoming";
@@ -1,3 +1,3 @@
1
- import { type RunLedger, type RunLedgerEntry } from "../types/runLedger.js";
1
+ import { type RunLedger, type RunLedgerEntry } from "@audit-tools/shared";
2
2
  export declare function loadRunLedger(artifactsDir: string): Promise<RunLedger>;
3
3
  export declare function appendRunLedgerEntry(artifactsDir: string, entry: RunLedgerEntry): Promise<void>;
@@ -1,8 +1,8 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { mkdir, open, rename, rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { RUN_LEDGER_STATUSES, } from "../types/runLedger.js";
5
- import { isFileMissingError, readJsonFile, writeJsonFile } from "../io/json.js";
4
+ import { RUN_LEDGER_STATUSES, } from "@audit-tools/shared";
5
+ import { isFileMissingError, readJsonFile, writeJsonFile } from "@audit-tools/shared";
6
6
  const RUN_LEDGER_FILENAME = "run-ledger.json";
7
7
  const RUN_LEDGER_LOCK_FILENAME = "run-ledger.lock";
8
8
  const LOCK_RETRY_DELAY_MS = 20;
@@ -1,4 +1,4 @@
1
- import type { SessionConfig } from "../types/sessionConfig.js";
1
+ import { type SessionConfig } from "@audit-tools/shared";
2
2
  export declare function getSessionConfigPath(artifactsDir: string): string;
3
3
  export declare function readSessionConfigFile(artifactsDir: string): Promise<unknown | undefined>;
4
4
  export declare function loadSessionConfig(artifactsDir: string): Promise<SessionConfig>;
@@ -1,8 +1,6 @@
1
1
  import { join } from "node:path";
2
- import { readOptionalJsonFile } from "../io/json.js";
3
- import { formatValidationIssues, } from "../validation/basic.js";
2
+ import { readOptionalJsonFile, writeJsonFile, formatValidationIssues, } from "@audit-tools/shared";
4
3
  import { validateSessionConfig } from "../validation/sessionConfig.js";
5
- import { writeJsonFile } from "../io/json.js";
6
4
  const SESSION_CONFIG_FILENAME = "session-config.json";
7
5
  const DEFAULT_SESSION_CONFIG = { provider: "local-subprocess" };
8
6
  export function getSessionConfigPath(artifactsDir) {
@@ -1,5 +1,5 @@
1
1
  import type { AuditTask, Lens } from "../types.js";
2
- import type { GraphEdge } from "./graph.js";
2
+ import type { GraphEdge } from "@audit-tools/shared";
3
3
  export interface ReviewPacketGraphEdge extends Pick<GraphEdge, "from" | "to" | "kind" | "confidence" | "reason"> {
4
4
  }
5
5
  export interface ReviewPacketQuality {
@@ -1,5 +1,10 @@
1
1
  export declare const WORKER_COMMAND_MODES: readonly ["run", "deferred"];
2
2
  export type WorkerCommandMode = (typeof WORKER_COMMAND_MODES)[number];
3
+ export interface AccessDeclaration {
4
+ read_paths: string[];
5
+ write_paths: string[];
6
+ forbidden_patterns?: string[];
7
+ }
3
8
  /**
4
9
  * Worker tasks serialize directly to task.json, so their persisted field names
5
10
  * intentionally stay snake_case for consistency across providers and bridges.
@@ -22,5 +27,6 @@ export interface WorkerTask {
22
27
  skip_worker_command?: boolean;
23
28
  timeout_ms?: number;
24
29
  max_retries?: number;
30
+ access?: AccessDeclaration;
25
31
  }
26
32
  export declare function usesDeferredWorkerCommand(task: Pick<WorkerTask, "worker_command_mode" | "skip_worker_command">): boolean;
@@ -1,3 +1,3 @@
1
1
  import type { ArtifactBundle } from "../io/artifacts.js";
2
- import { type ValidationIssue } from "./basic.js";
2
+ import { type ValidationIssue } from "@audit-tools/shared";
3
3
  export declare function validateArtifactBundle(bundle: ArtifactBundle): ValidationIssue[];
@@ -1,4 +1,4 @@
1
- import { pushValidationIssue, requireKeys, } from "./basic.js";
1
+ import { pushValidationIssue, requireKeys, } from "@audit-tools/shared";
2
2
  function pushIssue(issues, path, message) {
3
3
  pushValidationIssue(issues, path, message);
4
4
  }
@@ -1,6 +1,7 @@
1
1
  import type { AuditTask } from "../types.js";
2
- import { type ValidationIssue } from "./basic.js";
2
+ import { type ValidationIssue } from "@audit-tools/shared";
3
3
  export type IssueSeverity = "error" | "warning";
4
+ export declare function normalizeCoveragePath(path: string): string;
4
5
  export interface AuditResultIssue extends ValidationIssue {
5
6
  result_index: number;
6
7
  task_id: string;
@@ -1,4 +1,7 @@
1
- import { describeValue, formatValidationIssues, isRecord, } from "./basic.js";
1
+ import { describeValue, formatValidationIssues, isRecord, } from "@audit-tools/shared";
2
+ export function normalizeCoveragePath(path) {
3
+ return path.replace(/\\/g, "/").replace(/^\.\//, "");
4
+ }
2
5
  const REQUIRED_FINDING_FIELDS = [
3
6
  "id",
4
7
  "title",
@@ -423,6 +426,18 @@ export function validateAuditResults(results, tasks, options = {}) {
423
426
  tasks.map((item) => item.task_id).join(", "),
424
427
  });
425
428
  }
429
+ const taskNormMap = new Map();
430
+ if (task) {
431
+ for (const fp of task.file_paths) {
432
+ taskNormMap.set(normalizeCoveragePath(fp), fp);
433
+ }
434
+ }
435
+ const normLineIndex = new Map();
436
+ if (options.lineIndex) {
437
+ for (const [k, v] of Object.entries(options.lineIndex)) {
438
+ normLineIndex.set(normalizeCoveragePath(k), v);
439
+ }
440
+ }
426
441
  const fileCoverage = result.file_coverage;
427
442
  const normalizedFileCoverage = [];
428
443
  const declaredAssignedCoveragePaths = new Set();
@@ -447,6 +462,10 @@ export function validateAuditResults(results, tasks, options = {}) {
447
462
  });
448
463
  continue;
449
464
  }
465
+ const entryNorm = isNonEmptyString(entry.path)
466
+ ? normalizeCoveragePath(entry.path)
467
+ : "";
468
+ const canonicalPath = taskNormMap.get(entryNorm);
450
469
  if (!isNonEmptyString(entry.path)) {
451
470
  pushIssue(issues, {
452
471
  result_index: i,
@@ -455,7 +474,7 @@ export function validateAuditResults(results, tasks, options = {}) {
455
474
  message: "file_coverage entry has an empty path.",
456
475
  });
457
476
  }
458
- else if (task && !task.file_paths.includes(entry.path)) {
477
+ else if (task && !canonicalPath) {
459
478
  pushIssue(issues, {
460
479
  result_index: i,
461
480
  task_id: taskId,
@@ -463,7 +482,7 @@ export function validateAuditResults(results, tasks, options = {}) {
463
482
  message: `file_coverage path '${entry.path}' is not listed in the task file_paths.`,
464
483
  });
465
484
  }
466
- else if (seenCoveragePaths.has(entry.path)) {
485
+ else if (seenCoveragePaths.has(entryNorm)) {
467
486
  pushIssue(issues, {
468
487
  result_index: i,
469
488
  task_id: taskId,
@@ -472,11 +491,10 @@ export function validateAuditResults(results, tasks, options = {}) {
472
491
  });
473
492
  }
474
493
  else {
475
- seenCoveragePaths.add(entry.path);
494
+ seenCoveragePaths.add(entryNorm);
476
495
  }
477
- if (isNonEmptyString(entry.path) &&
478
- (!task || task.file_paths.includes(entry.path))) {
479
- declaredAssignedCoveragePaths.add(entry.path);
496
+ if (entryNorm.length > 0 && (!task || canonicalPath)) {
497
+ declaredAssignedCoveragePaths.add(canonicalPath ?? entryNorm);
480
498
  }
481
499
  if (!Number.isInteger(entry.total_lines)) {
482
500
  pushIssue(issues, {
@@ -495,8 +513,8 @@ export function validateAuditResults(results, tasks, options = {}) {
495
513
  message: "file_coverage total_lines must be zero or greater.",
496
514
  });
497
515
  }
498
- const expectedLineCount = typeof entry.path === "string"
499
- ? options.lineIndex?.[entry.path]
516
+ const expectedLineCount = entryNorm.length > 0
517
+ ? normLineIndex.get(entryNorm)
500
518
  : undefined;
501
519
  if (Number.isInteger(entry.total_lines) &&
502
520
  typeof expectedLineCount === "number" &&
@@ -509,19 +527,19 @@ export function validateAuditResults(results, tasks, options = {}) {
509
527
  `(expected ${expectedLineCount}, got ${entry.total_lines}).`,
510
528
  });
511
529
  }
512
- if (isNonEmptyString(entry.path) &&
530
+ if (entryNorm.length > 0 &&
513
531
  Number.isInteger(entry.total_lines) &&
514
532
  Number(entry.total_lines) >= 0 &&
515
- (!task || task.file_paths.includes(entry.path))) {
533
+ (!task || canonicalPath)) {
516
534
  normalizedFileCoverage.push({
517
- path: entry.path,
535
+ path: canonicalPath ?? entryNorm,
518
536
  total_lines: Number(entry.total_lines),
519
537
  });
520
538
  }
521
539
  }
522
540
  if (task) {
523
541
  for (const path of task.file_paths) {
524
- if (!seenCoveragePaths.has(path)) {
542
+ if (!seenCoveragePaths.has(normalizeCoveragePath(path))) {
525
543
  pushIssue(issues, {
526
544
  result_index: i,
527
545
  task_id: taskId,
@@ -1,8 +1,7 @@
1
- import { type SessionConfig } from "../types/sessionConfig.js";
2
- import { type ValidationIssue } from "./basic.js";
1
+ import { type SessionConfig, type ValidationIssue } from "@audit-tools/shared";
3
2
  export declare function validateSessionConfig(value: unknown): ValidationIssue[];
4
3
  export declare function validateConfiguredProviderEnvironment(sessionConfig: SessionConfig, options?: {
5
4
  commandExists?: (command: string) => boolean;
6
5
  pathExists?: (commandPath: string) => boolean;
7
6
  }): ValidationIssue[];
8
- export { formatValidationIssues } from "./basic.js";
7
+ export { formatValidationIssues } from "@audit-tools/shared";
@@ -1,7 +1,6 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { accessSync, constants } from "node:fs";
3
- import { PROVIDER_NAMES, SESSION_UI_MODES, } from "../types/sessionConfig.js";
4
- import { isRecord, pushValidationIssue, } from "./basic.js";
3
+ import { PROVIDER_NAMES, SESSION_UI_MODES, isRecord, pushValidationIssue, } from "@audit-tools/shared";
5
4
  const VALID_PROVIDERS = new Set(PROVIDER_NAMES);
6
5
  const VALID_UI_MODES = new Set(SESSION_UI_MODES);
7
6
  function pushIssue(issues, path, message) {
@@ -192,4 +191,4 @@ export function validateConfiguredProviderEnvironment(sessionConfig, options = {
192
191
  }
193
192
  return issues;
194
193
  }
195
- export { formatValidationIssues } from "./basic.js";
194
+ export { formatValidationIssues } from "@audit-tools/shared";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auditor-lambda",
3
- "version": "0.3.39",
3
+ "version": "0.3.41",
4
4
  "private": false,
5
5
  "description": "Portable hybrid code-auditing framework for arbitrary repositories.",
6
6
  "type": "module",
@@ -34,7 +34,6 @@
34
34
  "smoke:linked-audit-code": "node scripts/smoke-linked-audit-code.mjs",
35
35
  "smoke:packaged-audit-code": "node scripts/smoke-packaged-audit-code.mjs",
36
36
  "prepack": "npm run build",
37
- "prepare": "npm run build",
38
37
  "prepublishOnly": "npm run verify:release",
39
38
  "start": "node dist/index.js",
40
39
  "audit-code": "node audit-code.mjs",
@@ -65,6 +64,9 @@
65
64
  "orchestration",
66
65
  "agents"
67
66
  ],
67
+ "dependencies": {
68
+ "@audit-tools/shared": "*"
69
+ },
68
70
  "devDependencies": {
69
71
  "@types/node": "^24.3.0",
70
72
  "ajv": "^8.17.1",
@@ -80,7 +80,6 @@ const OPENCODE_AUDIT_BASH_PERMISSION = {
80
80
  'git status*': 'allow',
81
81
  'git diff*': 'allow',
82
82
  'grep *': 'allow',
83
- 'Select-String *': 'allow',
84
83
  'rm *': 'deny',
85
84
  };
86
85
 
package/dist/io/json.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare function isFileMissingError(error: unknown): boolean;
2
- export declare function readJsonFile<T>(path: string): Promise<T>;
3
- export declare function writeJsonFile(path: string, value: unknown): Promise<void>;
4
- export declare function appendNdjsonFile(path: string, value: unknown): Promise<void>;
5
- export declare function readNdjsonFile<T>(path: string): Promise<T[]>;
6
- export declare function readOptionalJsonFile<T>(path: string): Promise<T | undefined>;
7
- export declare function readOptionalNdjsonFile<T>(path: string): Promise<T[] | undefined>;
8
- export declare function writeNdjsonFile(path: string, values: unknown[]): Promise<void>;
9
- export declare function readOptionalTextFile(path: string): Promise<string | undefined>;
10
- export declare function writeTextFile(path: string, value: string): Promise<void>;