auditor-lambda 0.3.40 → 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.
- package/audit-code-wrapper-lib.mjs +20 -2
- package/dist/cli/args.d.ts +59 -0
- package/dist/cli/args.js +244 -0
- package/dist/cli/dispatch.d.ts +80 -0
- package/dist/cli/dispatch.js +528 -0
- package/dist/cli/prompts.d.ts +18 -0
- package/dist/cli/prompts.js +130 -0
- package/dist/cli/steps.d.ts +29 -0
- package/dist/cli/steps.js +30 -0
- package/dist/cli/waveManifest.d.ts +40 -0
- package/dist/cli/waveManifest.js +41 -0
- package/dist/cli/workerResult.d.ts +18 -0
- package/dist/cli/workerResult.js +42 -0
- package/dist/cli.d.ts +2 -22
- package/dist/cli.js +160 -973
- package/dist/extractors/browserExtension.d.ts +1 -3
- package/dist/extractors/browserExtension.js +2 -2
- package/dist/extractors/designAssessment.d.ts +1 -3
- package/dist/extractors/disposition.d.ts +2 -1
- package/dist/extractors/disposition.js +3 -0
- package/dist/extractors/flows.d.ts +1 -3
- package/dist/extractors/flows.js +2 -2
- package/dist/extractors/graph.d.ts +1 -2
- package/dist/extractors/graph.js +4 -326
- package/dist/extractors/graphManifestEdges.d.ts +1 -1
- package/dist/extractors/graphPathUtils.d.ts +1 -1
- package/dist/extractors/graphPythonImports.d.ts +3 -0
- package/dist/extractors/graphPythonImports.js +326 -0
- package/dist/extractors/risk.d.ts +1 -2
- package/dist/extractors/surfaces.d.ts +1 -3
- package/dist/extractors/surfaces.js +2 -2
- package/dist/io/artifacts.d.ts +1 -5
- package/dist/io/artifacts.js +1 -1
- package/dist/io/runArtifacts.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/orchestrator/advance.d.ts +1 -0
- package/dist/orchestrator/advance.js +8 -5
- package/dist/orchestrator/auditTaskUtils.d.ts +4 -0
- package/dist/orchestrator/auditTaskUtils.js +27 -0
- package/dist/orchestrator/fileAnchors.d.ts +1 -1
- package/dist/orchestrator/fileIntegrity.d.ts +7 -0
- package/dist/orchestrator/fileIntegrity.js +41 -0
- package/dist/orchestrator/flowCoverage.d.ts +1 -1
- package/dist/orchestrator/flowPlanning.d.ts +1 -1
- package/dist/orchestrator/flowRequeue.d.ts +1 -1
- package/dist/orchestrator/internalExecutors.d.ts +3 -1
- package/dist/orchestrator/internalExecutors.js +23 -5
- package/dist/orchestrator/nextStep.d.ts +2 -1
- package/dist/orchestrator/nextStep.js +1 -1
- package/dist/orchestrator/planning.d.ts +1 -1
- package/dist/orchestrator/requeueCommand.d.ts +1 -1
- package/dist/orchestrator/reviewPackets.d.ts +1 -1
- package/dist/orchestrator/reviewPackets.js +21 -113
- package/dist/orchestrator/runtimeValidation.d.ts +1 -1
- package/dist/orchestrator/taskBuilder.d.ts +1 -1
- package/dist/orchestrator/taskBuilder.js +1 -12
- package/dist/orchestrator/unionFind.d.ts +7 -0
- package/dist/orchestrator/unionFind.js +32 -0
- package/dist/orchestrator/unitBuilder.d.ts +2 -2
- package/dist/orchestrator/unitBuilder.js +4 -18
- package/dist/prompts/renderWorkerPrompt.js +18 -1
- package/dist/providers/claudeCodeProvider.d.ts +4 -4
- package/dist/providers/claudeCodeProvider.js +9 -3
- package/dist/providers/constants.d.ts +1 -1
- package/dist/providers/constants.js +1 -1
- package/dist/providers/index.d.ts +1 -2
- package/dist/providers/index.js +5 -4
- package/dist/providers/localSubprocessProvider.d.ts +2 -2
- package/dist/providers/localSubprocessProvider.js +1 -1
- package/dist/providers/opencodeProvider.d.ts +4 -4
- package/dist/providers/opencodeProvider.js +7 -2
- package/dist/providers/spawnLoggedCommand.d.ts +3 -1
- package/dist/providers/spawnLoggedCommand.js +21 -0
- package/dist/providers/subprocessTemplateProvider.d.ts +4 -4
- package/dist/providers/subprocessTemplateProvider.js +8 -3
- package/dist/providers/vscodeTaskProvider.d.ts +3 -4
- package/dist/providers/vscodeTaskProvider.js +2 -2
- package/dist/quota/discoveredLimits.js +1 -1
- package/dist/quota/hostLimits.d.ts +1 -2
- package/dist/quota/hostLimits.js +4 -46
- package/dist/quota/index.d.ts +18 -15
- package/dist/quota/index.js +4 -9
- package/dist/quota/scheduler.d.ts +1 -3
- package/dist/quota/scheduler.js +1 -2
- package/dist/reporting/synthesis.d.ts +1 -2
- package/dist/reporting/synthesis.js +2 -0
- package/dist/reporting/workBlocks.d.ts +1 -2
- package/dist/supervisor/operatorHandoff.js +1 -1
- package/dist/supervisor/runLedger.d.ts +1 -1
- package/dist/supervisor/runLedger.js +2 -2
- package/dist/supervisor/sessionConfig.d.ts +1 -1
- package/dist/supervisor/sessionConfig.js +1 -3
- package/dist/types/reviewPlanning.d.ts +1 -1
- package/dist/types/workerSession.d.ts +6 -0
- package/dist/validation/artifacts.d.ts +1 -1
- package/dist/validation/artifacts.js +1 -1
- package/dist/validation/auditResults.d.ts +1 -1
- package/dist/validation/auditResults.js +1 -1
- package/dist/validation/sessionConfig.d.ts +2 -3
- package/dist/validation/sessionConfig.js +2 -3
- package/package.json +4 -2
- package/scripts/postinstall.mjs +0 -1
- package/dist/io/json.d.ts +0 -10
- package/dist/io/json.js +0 -142
- package/dist/providers/types.d.ts +0 -33
- package/dist/providers/types.js +0 -1
- package/dist/quota/compositeQuotaSource.d.ts +0 -7
- package/dist/quota/compositeQuotaSource.js +0 -20
- package/dist/quota/errorParsers/claudeCodeErrorParser.d.ts +0 -6
- package/dist/quota/errorParsers/claudeCodeErrorParser.js +0 -39
- package/dist/quota/errorParsers/genericErrorParser.d.ts +0 -9
- package/dist/quota/errorParsers/genericErrorParser.js +0 -7
- package/dist/quota/errorParsers/index.d.ts +0 -5
- package/dist/quota/errorParsers/index.js +0 -12
- package/dist/quota/errorParsing.d.ts +0 -7
- package/dist/quota/errorParsing.js +0 -69
- package/dist/quota/fileLock.d.ts +0 -6
- package/dist/quota/fileLock.js +0 -64
- package/dist/quota/learnedQuotaSource.d.ts +0 -7
- package/dist/quota/learnedQuotaSource.js +0 -25
- package/dist/quota/limits.d.ts +0 -16
- package/dist/quota/limits.js +0 -77
- package/dist/quota/quotaSource.d.ts +0 -12
- package/dist/quota/quotaSource.js +0 -1
- package/dist/quota/slidingWindow.d.ts +0 -4
- package/dist/quota/slidingWindow.js +0 -28
- package/dist/quota/state.d.ts +0 -15
- package/dist/quota/state.js +0 -148
- package/dist/quota/types.d.ts +0 -67
- package/dist/quota/types.js +0 -1
- package/dist/reporting/rootCause.d.ts +0 -10
- package/dist/reporting/rootCause.js +0 -146
- package/dist/types/disposition.d.ts +0 -9
- package/dist/types/disposition.js +0 -1
- package/dist/types/flows.d.ts +0 -17
- package/dist/types/flows.js +0 -1
- package/dist/types/graph.d.ts +0 -22
- package/dist/types/graph.js +0 -1
- package/dist/types/risk.d.ts +0 -9
- package/dist/types/risk.js +0 -1
- package/dist/types/runLedger.d.ts +0 -17
- package/dist/types/runLedger.js +0 -6
- package/dist/types/sessionConfig.d.ts +0 -79
- package/dist/types/sessionConfig.js +0 -15
- package/dist/types/surfaces.d.ts +0 -15
- package/dist/types/surfaces.js +0 -1
- package/dist/validation/basic.d.ts +0 -13
- package/dist/validation/basic.js +0 -46
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readJsonFile } from "
|
|
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
|
-
|
|
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 "
|
|
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("
|
|
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 "
|
|
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 "
|
|
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;
|
package/dist/quota/hostLimits.js
CHANGED
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/quota/index.d.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
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 {
|
|
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
|
|
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
|
+
}
|
package/dist/quota/index.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
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 {
|
|
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 "
|
|
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;
|
package/dist/quota/scheduler.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { classifyProvider, resolveLimits } from "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
5
|
-
import { isFileMissingError, readJsonFile, writeJsonFile } from "
|
|
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
|
|
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 "
|
|
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 "
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { AuditTask } from "../types.js";
|
|
2
|
-
import { type ValidationIssue } from "
|
|
2
|
+
import { type ValidationIssue } from "@audit-tools/shared";
|
|
3
3
|
export type IssueSeverity = "error" | "warning";
|
|
4
4
|
export declare function normalizeCoveragePath(path: string): string;
|
|
5
5
|
export interface AuditResultIssue extends ValidationIssue {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describeValue, formatValidationIssues, isRecord, } from "
|
|
1
|
+
import { describeValue, formatValidationIssues, isRecord, } from "@audit-tools/shared";
|
|
2
2
|
export function normalizeCoveragePath(path) {
|
|
3
3
|
return path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
4
4
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type SessionConfig } from "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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.
|
|
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",
|
package/scripts/postinstall.mjs
CHANGED
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>;
|
package/dist/io/json.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile, appendFile } from "node:fs/promises";
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
|
-
function errorMessage(error) {
|
|
4
|
-
return error instanceof Error ? error.message : String(error);
|
|
5
|
-
}
|
|
6
|
-
function ioError(action, path, error) {
|
|
7
|
-
return new Error(`Failed to ${action} ${path}: ${errorMessage(error)}`);
|
|
8
|
-
}
|
|
9
|
-
async function ensureParentDirectory(path) {
|
|
10
|
-
try {
|
|
11
|
-
await mkdir(dirname(path), { recursive: true });
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
throw ioError("prepare parent directory", path, error);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function isFileMissingError(error) {
|
|
18
|
-
return (typeof error === "object" &&
|
|
19
|
-
error !== null &&
|
|
20
|
-
"code" in error &&
|
|
21
|
-
error.code === "ENOENT");
|
|
22
|
-
}
|
|
23
|
-
export async function readJsonFile(path) {
|
|
24
|
-
let content;
|
|
25
|
-
try {
|
|
26
|
-
content = await readFile(path, "utf8");
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
if (isFileMissingError(error)) {
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
throw ioError("read", path, error);
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(content);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
throw new Error(`Invalid JSON in ${path}: ${errorMessage(error)}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export async function writeJsonFile(path, value) {
|
|
42
|
-
await ensureParentDirectory(path);
|
|
43
|
-
try {
|
|
44
|
-
await writeFile(path, JSON.stringify(value, null, 2) + "\n", "utf8");
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw ioError("write", path, error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export async function appendNdjsonFile(path, value) {
|
|
51
|
-
await ensureParentDirectory(path);
|
|
52
|
-
try {
|
|
53
|
-
await appendFile(path, JSON.stringify(value) + "\n", "utf8");
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
throw ioError("append", path, error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export async function readNdjsonFile(path) {
|
|
60
|
-
try {
|
|
61
|
-
const content = await readFile(path, "utf8");
|
|
62
|
-
const values = [];
|
|
63
|
-
let sawContent = false;
|
|
64
|
-
for (const [index, line] of content.split(/\r?\n/).entries()) {
|
|
65
|
-
if (line.trim().length === 0) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
sawContent = true;
|
|
69
|
-
try {
|
|
70
|
-
values.push(JSON.parse(line));
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new Error(`Invalid NDJSON in ${path} at line ${index + 1}: ${errorMessage(error)}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return sawContent ? values : [];
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
if (isFileMissingError(error)) {
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
if (error instanceof Error && error.message.includes(path)) {
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
throw ioError("read", path, error);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export async function readOptionalJsonFile(path) {
|
|
89
|
-
try {
|
|
90
|
-
return await readJsonFile(path);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
if (isFileMissingError(error)) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export async function readOptionalNdjsonFile(path) {
|
|
100
|
-
try {
|
|
101
|
-
return await readNdjsonFile(path);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (isFileMissingError(error)) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export async function writeNdjsonFile(path, values) {
|
|
111
|
-
await ensureParentDirectory(path);
|
|
112
|
-
try {
|
|
113
|
-
if (values.length === 0) {
|
|
114
|
-
await writeFile(path, "", "utf8");
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
await writeFile(path, values.map((v) => JSON.stringify(v)).join("\n") + "\n", "utf8");
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
throw ioError("write", path, error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export async function readOptionalTextFile(path) {
|
|
124
|
-
try {
|
|
125
|
-
return await readFile(path, "utf8");
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
if (isFileMissingError(error)) {
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
throw ioError("read", path, error);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export async function writeTextFile(path, value) {
|
|
135
|
-
await ensureParentDirectory(path);
|
|
136
|
-
try {
|
|
137
|
-
await writeFile(path, value, "utf8");
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
throw ioError("write", path, error);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export interface LaunchFreshSessionInput {
|
|
2
|
-
repoRoot: string;
|
|
3
|
-
runId: string;
|
|
4
|
-
obligationId: string | null;
|
|
5
|
-
promptPath: string;
|
|
6
|
-
taskPath: string;
|
|
7
|
-
resultPath: string;
|
|
8
|
-
stdoutPath: string;
|
|
9
|
-
stderrPath: string;
|
|
10
|
-
uiMode: "visible" | "headless";
|
|
11
|
-
timeoutMs: number;
|
|
12
|
-
}
|
|
13
|
-
export interface LaunchFreshSessionResult {
|
|
14
|
-
accepted: boolean;
|
|
15
|
-
processId?: number;
|
|
16
|
-
exitCode?: number | null;
|
|
17
|
-
signal?: string | null;
|
|
18
|
-
command?: string;
|
|
19
|
-
args?: string[];
|
|
20
|
-
stdoutPath?: string;
|
|
21
|
-
stderrPath?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ProviderRateLimits {
|
|
25
|
-
requests_per_minute?: number | null;
|
|
26
|
-
input_tokens_per_minute?: number | null;
|
|
27
|
-
output_tokens_per_minute?: number | null;
|
|
28
|
-
}
|
|
29
|
-
export interface FreshSessionProvider {
|
|
30
|
-
name: string;
|
|
31
|
-
launch(input: LaunchFreshSessionInput): Promise<LaunchFreshSessionResult>;
|
|
32
|
-
queryLimits?(model: string | null): Promise<ProviderRateLimits | null>;
|
|
33
|
-
}
|
package/dist/providers/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { QuotaSource, QuotaUsageSnapshot } from "./quotaSource.js";
|
|
2
|
-
export declare class CompositeQuotaSource implements QuotaSource {
|
|
3
|
-
readonly name = "composite";
|
|
4
|
-
private sources;
|
|
5
|
-
constructor(sources: QuotaSource[]);
|
|
6
|
-
queryCurrentUsage(providerModelKey: string): Promise<QuotaUsageSnapshot | null>;
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export class CompositeQuotaSource {
|
|
2
|
-
name = "composite";
|
|
3
|
-
sources;
|
|
4
|
-
constructor(sources) {
|
|
5
|
-
this.sources = sources;
|
|
6
|
-
}
|
|
7
|
-
async queryCurrentUsage(providerModelKey) {
|
|
8
|
-
for (const source of this.sources) {
|
|
9
|
-
try {
|
|
10
|
-
const snapshot = await source.queryCurrentUsage(providerModelKey);
|
|
11
|
-
if (snapshot)
|
|
12
|
-
return snapshot;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
// Skip failing sources, try next
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
}
|