audit-tools 0.35.0 → 0.35.3
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/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
- package/dist/audit/cli/nextStepCommand.js +4 -2
- package/dist/audit/cli/nextStepCommand.js.map +1 -1
- package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
- package/dist/audit/cli/nextStepHelpers.js +85 -10
- package/dist/audit/cli/nextStepHelpers.js.map +1 -1
- package/dist/audit/extractors/analyzers/candidates.d.ts.map +1 -1
- package/dist/audit/extractors/analyzers/candidates.js +45 -54
- package/dist/audit/extractors/analyzers/candidates.js.map +1 -1
- package/dist/audit/orchestrator/executors.d.ts +2 -0
- package/dist/audit/orchestrator/executors.d.ts.map +1 -1
- package/dist/audit/orchestrator/executors.js +8 -2
- package/dist/audit/orchestrator/executors.js.map +1 -1
- package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
- package/dist/audit/orchestrator/nextStep.js +2 -2
- package/dist/audit/orchestrator/nextStep.js.map +1 -1
- package/dist/audit/orchestrator/partitionTaskGraph.d.ts +11 -0
- package/dist/audit/orchestrator/partitionTaskGraph.d.ts.map +1 -1
- package/dist/audit/orchestrator/partitionTaskGraph.js +4 -1
- package/dist/audit/orchestrator/partitionTaskGraph.js.map +1 -1
- package/dist/audit/orchestrator/reviewPackets.d.ts +6 -0
- package/dist/audit/orchestrator/reviewPackets.d.ts.map +1 -1
- package/dist/audit/orchestrator/reviewPackets.js +1 -0
- package/dist/audit/orchestrator/reviewPackets.js.map +1 -1
- package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
- package/dist/audit/orchestrator/staleness.js +3 -3
- package/dist/audit/orchestrator/staleness.js.map +1 -1
- package/dist/audit/providers/index.d.ts +12 -6
- package/dist/audit/providers/index.d.ts.map +1 -1
- package/dist/audit/providers/index.js +24 -14
- package/dist/audit/providers/index.js.map +1 -1
- package/dist/audit/quota/hostLimits.d.ts +4 -6
- package/dist/audit/quota/hostLimits.d.ts.map +1 -1
- package/dist/audit/quota/hostLimits.js +5 -8
- package/dist/audit/quota/hostLimits.js.map +1 -1
- package/dist/audit/reporting/mergeFindings.d.ts.map +1 -1
- package/dist/audit/reporting/mergeFindings.js +3 -0
- package/dist/audit/reporting/mergeFindings.js.map +1 -1
- package/dist/audit/validation/sessionConfig.d.ts.map +1 -1
- package/dist/audit/validation/sessionConfig.js +27 -29
- package/dist/audit/validation/sessionConfig.js.map +1 -1
- package/dist/remediate/dedup/crossLensDedup.d.ts +12 -0
- package/dist/remediate/dedup/crossLensDedup.d.ts.map +1 -1
- package/dist/remediate/dedup/crossLensDedup.js +29 -4
- package/dist/remediate/dedup/crossLensDedup.js.map +1 -1
- package/dist/remediate/phases/plan.d.ts +8 -4
- package/dist/remediate/phases/plan.d.ts.map +1 -1
- package/dist/remediate/phases/plan.js +10 -6
- package/dist/remediate/phases/plan.js.map +1 -1
- package/dist/remediate/providers/index.d.ts +12 -7
- package/dist/remediate/providers/index.d.ts.map +1 -1
- package/dist/remediate/providers/index.js +24 -15
- package/dist/remediate/providers/index.js.map +1 -1
- package/dist/remediate/quota/hostLimits.d.ts +4 -6
- package/dist/remediate/quota/hostLimits.d.ts.map +1 -1
- package/dist/remediate/quota/hostLimits.js +5 -8
- package/dist/remediate/quota/hostLimits.js.map +1 -1
- package/dist/remediate/steps/nextStep.d.ts +1 -1
- package/dist/remediate/steps/nextStep.d.ts.map +1 -1
- package/dist/remediate/steps/nextStep.js +163 -138
- package/dist/remediate/steps/nextStep.js.map +1 -1
- package/dist/remediate/steps/sessionConfigLoad.d.ts.map +1 -1
- package/dist/remediate/steps/sessionConfigLoad.js +12 -3
- package/dist/remediate/steps/sessionConfigLoad.js.map +1 -1
- package/dist/remediate/validation/contractPipelineGates.d.ts.map +1 -1
- package/dist/remediate/validation/contractPipelineGates.js +3 -8
- package/dist/remediate/validation/contractPipelineGates.js.map +1 -1
- package/dist/shared/decompose/modularity.d.ts.map +1 -1
- package/dist/shared/decompose/modularity.js +101 -37
- package/dist/shared/decompose/modularity.js.map +1 -1
- package/dist/shared/dispatch/providerLaunchFinalize.d.ts.map +1 -1
- package/dist/shared/dispatch/providerLaunchFinalize.js +23 -3
- package/dist/shared/dispatch/providerLaunchFinalize.js.map +1 -1
- package/dist/shared/findings/dedupe.d.ts +29 -0
- package/dist/shared/findings/dedupe.d.ts.map +1 -1
- package/dist/shared/findings/dedupe.js +74 -3
- package/dist/shared/findings/dedupe.js.map +1 -1
- package/dist/shared/index.d.ts +4 -2
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +3 -2
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/providers/agyProvider.d.ts.map +1 -1
- package/dist/shared/providers/agyProvider.js +12 -26
- package/dist/shared/providers/agyProvider.js.map +1 -1
- package/dist/shared/providers/auditorSources.d.ts.map +1 -1
- package/dist/shared/providers/auditorSources.js +0 -6
- package/dist/shared/providers/auditorSources.js.map +1 -1
- package/dist/shared/providers/orchestratorBindings.d.ts +42 -0
- package/dist/shared/providers/orchestratorBindings.d.ts.map +1 -0
- package/dist/shared/providers/orchestratorBindings.js +30 -0
- package/dist/shared/providers/orchestratorBindings.js.map +1 -0
- package/dist/shared/providers/providerFactory.d.ts.map +1 -1
- package/dist/shared/providers/providerFactory.js +3 -5
- package/dist/shared/providers/providerFactory.js.map +1 -1
- package/dist/shared/providers/providerPathGuard.d.ts.map +1 -1
- package/dist/shared/providers/providerPathGuard.js +18 -21
- package/dist/shared/providers/providerPathGuard.js.map +1 -1
- package/dist/shared/quota/hostLimits.d.ts +18 -0
- package/dist/shared/quota/hostLimits.d.ts.map +1 -1
- package/dist/shared/quota/hostLimits.js +13 -0
- package/dist/shared/quota/hostLimits.js.map +1 -1
- package/dist/shared/quota/limits.d.ts +6 -9
- package/dist/shared/quota/limits.d.ts.map +1 -1
- package/dist/shared/quota/limits.js +37 -24
- package/dist/shared/quota/limits.js.map +1 -1
- package/dist/shared/quota/scheduler.d.ts.map +1 -1
- package/dist/shared/quota/scheduler.js +2 -11
- package/dist/shared/quota/scheduler.js.map +1 -1
- package/dist/shared/types/sessionConfig.d.ts +3 -3
- package/dist/shared/types/sessionConfig.d.ts.map +1 -1
- package/dist/shared/validation/findingsReport.d.ts +25 -33
- package/dist/shared/validation/findingsReport.d.ts.map +1 -1
- package/dist/shared/validation/findingsReport.js +237 -57
- package/dist/shared/validation/findingsReport.js.map +1 -1
- package/dist/shared/validation/sessionConfig.d.ts.map +1 -1
- package/dist/shared/validation/sessionConfig.js +4 -1
- package/dist/shared/validation/sessionConfig.js.map +1 -1
- package/package.json +1 -1
- package/dist/audit/providers/agyProvider.d.ts +0 -11
- package/dist/audit/providers/agyProvider.d.ts.map +0 -1
- package/dist/audit/providers/agyProvider.js +0 -18
- package/dist/audit/providers/agyProvider.js.map +0 -1
- package/dist/audit/providers/claudeCodeProvider.d.ts +0 -11
- package/dist/audit/providers/claudeCodeProvider.d.ts.map +0 -1
- package/dist/audit/providers/claudeCodeProvider.js +0 -23
- package/dist/audit/providers/claudeCodeProvider.js.map +0 -1
- package/dist/audit/providers/claudeWorkerProvider.d.ts +0 -10
- package/dist/audit/providers/claudeWorkerProvider.d.ts.map +0 -1
- package/dist/audit/providers/claudeWorkerProvider.js +0 -15
- package/dist/audit/providers/claudeWorkerProvider.js.map +0 -1
- package/dist/audit/providers/opencodeProvider.d.ts +0 -2
- package/dist/audit/providers/opencodeProvider.d.ts.map +0 -1
- package/dist/audit/providers/opencodeProvider.js +0 -7
- package/dist/audit/providers/opencodeProvider.js.map +0 -1
- package/dist/remediate/providers/agyProvider.d.ts +0 -12
- package/dist/remediate/providers/agyProvider.d.ts.map +0 -1
- package/dist/remediate/providers/agyProvider.js +0 -19
- package/dist/remediate/providers/agyProvider.js.map +0 -1
- package/dist/remediate/providers/claudeCodeProvider.d.ts +0 -12
- package/dist/remediate/providers/claudeCodeProvider.d.ts.map +0 -1
- package/dist/remediate/providers/claudeCodeProvider.js +0 -24
- package/dist/remediate/providers/claudeCodeProvider.js.map +0 -1
- package/dist/remediate/providers/claudeWorkerProvider.d.ts +0 -11
- package/dist/remediate/providers/claudeWorkerProvider.d.ts.map +0 -1
- package/dist/remediate/providers/claudeWorkerProvider.js +0 -16
- package/dist/remediate/providers/claudeWorkerProvider.js.map +0 -1
- package/dist/remediate/providers/opencodeProvider.d.ts +0 -2
- package/dist/remediate/providers/opencodeProvider.d.ts.map +0 -1
- package/dist/remediate/providers/opencodeProvider.js +0 -7
- package/dist/remediate/providers/opencodeProvider.js.map +0 -1
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
import { createFreshSessionProvider as createSharedFreshSessionProvider, resolveFreshSessionProviderName as resolveSharedFreshSessionProviderName, } from "audit-tools/shared";
|
|
2
|
-
import { createClaudeCodeProvider } from "./claudeCodeProvider.js";
|
|
3
|
-
import { createClaudeWorkerProvider } from "./claudeWorkerProvider.js";
|
|
4
|
-
import { createOpenCodeProvider } from "./opencodeProvider.js";
|
|
5
|
-
import { createAgyProvider } from "./agyProvider.js";
|
|
1
|
+
import { buildOrchestratorProviderBindings, createFreshSessionProvider as createSharedFreshSessionProvider, createOpenCodeProvider, resolveFreshSessionProviderName as resolveSharedFreshSessionProviderName, } from "audit-tools/shared";
|
|
6
2
|
/**
|
|
7
|
-
* Auto-resolution
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
3
|
+
* Auto-resolution, the provider classes, AND the per-orchestrator binding
|
|
4
|
+
* machinery are single-sourced in `audit-tools/shared`; this module declares
|
|
5
|
+
* remediate-code's descriptor — the ONE home for everything that legitimately
|
|
6
|
+
* differs from audit-code — and draws its bound factories from it. The
|
|
7
|
+
* autonomous remediator skips permission prompts by default (it applies changes
|
|
8
|
+
* unattended and cannot pause mid-run); an explicit
|
|
9
|
+
* `dangerously_skip_permissions: false` in the config still opts out.
|
|
13
10
|
*/
|
|
11
|
+
export const REMEDIATE_CODE_DESCRIPTOR = {
|
|
12
|
+
orchestratorName: "remediate-code",
|
|
13
|
+
sessionConfigPath: ".audit-tools/remediation/session-config.json",
|
|
14
|
+
slashCommand: "/remediate-code",
|
|
15
|
+
skipPermissionsDefault: true,
|
|
16
|
+
envPrefix: "REMEDIATE_CODE",
|
|
17
|
+
};
|
|
18
|
+
const bindings = buildOrchestratorProviderBindings(REMEDIATE_CODE_DESCRIPTOR);
|
|
19
|
+
export const createClaudeCodeProvider = bindings.createClaudeCodeProvider;
|
|
20
|
+
// opencode has no per-orchestrator delta; the shared factory is re-exported to
|
|
21
|
+
// keep one import surface for all provider factories.
|
|
22
|
+
export { createOpenCodeProvider };
|
|
14
23
|
export function resolveFreshSessionProviderName(name, sessionConfig = {}, options = {}) {
|
|
15
24
|
return resolveSharedFreshSessionProviderName(name, sessionConfig, options);
|
|
16
25
|
}
|
|
17
26
|
export function createFreshSessionProvider(name, sessionConfig = {}) {
|
|
18
27
|
return createSharedFreshSessionProvider(name, sessionConfig, {
|
|
19
|
-
orchestratorName:
|
|
20
|
-
createClaudeCodeProvider:
|
|
21
|
-
createClaudeWorkerProvider:
|
|
28
|
+
orchestratorName: REMEDIATE_CODE_DESCRIPTOR.orchestratorName,
|
|
29
|
+
createClaudeCodeProvider: bindings.createClaudeCodeProvider,
|
|
30
|
+
createClaudeWorkerProvider: bindings.createClaudeWorkerProvider,
|
|
22
31
|
createOpenCodeProvider: (config) => createOpenCodeProvider(config),
|
|
23
|
-
createAgyProvider:
|
|
32
|
+
createAgyProvider: bindings.createAgyProvider,
|
|
24
33
|
});
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remediate/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,IAAI,gCAAgC,EAC9D,+BAA+B,IAAI,qCAAqC,GACzE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remediate/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,0BAA0B,IAAI,gCAAgC,EAC9D,sBAAsB,EACtB,+BAA+B,IAAI,qCAAqC,GACzE,MAAM,oBAAoB,CAAC;AAQ5B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,gBAAgB,EAAE,gBAAgB;IAClC,iBAAiB,EAAE,8CAA8C;IACjE,YAAY,EAAE,iBAAiB;IAC/B,sBAAsB,EAAE,IAAI;IAC5B,SAAS,EAAE,gBAAgB;CAC5B,CAAC;AAEF,MAAM,QAAQ,GAAG,iCAAiC,CAAC,yBAAyB,CAAC,CAAC;AAE9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC,wBAAwB,CAAC;AAC1E,+EAA+E;AAC/E,sDAAsD;AACtD,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC,MAAM,UAAU,+BAA+B,CAC7C,IAAwB,EACxB,gBAA+B,EAAE,EACjC,UAGI,EAAE;IAEN,OAAO,qCAAqC,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,IAAwB,EACxB,gBAA+B,EAAE;IAEjC,OAAO,gCAAgC,CAAC,IAAI,EAAE,aAAa,EAAE;QAC3D,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;QAC5D,wBAAwB,EAAE,QAAQ,CAAC,wBAAwB;QAC3D,0BAA0B,EAAE,QAAQ,CAAC,0BAA0B;QAC/D,sBAAsB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC;QAClE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function detectHostActiveSubagentLimit(env?: NodeJS.ProcessEnv, readCodexMaxThreads?: ReadCodexMaxThreads): HostConcurrencyLimit | null;
|
|
3
|
-
export declare function resolveHostActiveSubagentLimit(options: {
|
|
1
|
+
export declare const detectHostActiveSubagentLimit: (env?: NodeJS.ProcessEnv, readCodexMaxThreads?: import("audit-tools/shared").ReadCodexMaxThreads) => import("audit-tools/shared").HostConcurrencyLimit | null, resolveHostActiveSubagentLimit: (options: {
|
|
4
2
|
explicitLimit?: number | null;
|
|
5
|
-
sessionConfig: SessionConfig;
|
|
3
|
+
sessionConfig: import("audit-tools/shared").SessionConfig;
|
|
6
4
|
env?: NodeJS.ProcessEnv;
|
|
7
|
-
readCodexMaxThreads?: ReadCodexMaxThreads;
|
|
8
|
-
})
|
|
5
|
+
readCodexMaxThreads?: import("audit-tools/shared").ReadCodexMaxThreads;
|
|
6
|
+
}) => import("audit-tools/shared").HostConcurrencyLimit | null;
|
|
9
7
|
//# sourceMappingURL=hostLimits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostLimits.d.ts","sourceRoot":"","sources":["../../../src/remediate/quota/hostLimits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hostLimits.d.ts","sourceRoot":"","sources":["../../../src/remediate/quota/hostLimits.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,6BAA6B,iKAAE,8BAA8B;iBAE0mG,CAAC;;OAA0D,CAAC;uBAA4C,CAAC;8DAD5uG,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export function resolveHostActiveSubagentLimit(options) {
|
|
7
|
-
return resolveShared({ envPrefix: ENV_PREFIX, ...options });
|
|
8
|
-
}
|
|
1
|
+
import { buildHostLimitBindings } from "audit-tools/shared";
|
|
2
|
+
import { REMEDIATE_CODE_DESCRIPTOR } from "../providers/index.js";
|
|
3
|
+
// The quota half of the per-orchestrator draw: the env prefix is declared once,
|
|
4
|
+
// on the descriptor, and the shared binding builder does the rest.
|
|
5
|
+
export const { detectHostActiveSubagentLimit, resolveHostActiveSubagentLimit } = buildHostLimitBindings(REMEDIATE_CODE_DESCRIPTOR);
|
|
9
6
|
//# sourceMappingURL=hostLimits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostLimits.js","sourceRoot":"","sources":["../../../src/remediate/quota/hostLimits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hostLimits.js","sourceRoot":"","sources":["../../../src/remediate/quota/hostLimits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,gFAAgF;AAChF,mEAAmE;AACnE,MAAM,CAAC,MAAM,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,GAC5E,sBAAsB,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RemediationState, type HostCapabilities } from "../state/store.js";
|
|
2
2
|
import type { RemediationBlock } from "../state/types.js";
|
|
3
|
-
import { type FrictionTriageDecision, type InterpretedIntent, type SessionConfig, type HostModelRosterEntry, type CapacityPool, type PartialCompletionTerminal, type RollingDispatchResult, type ProviderSlot,
|
|
3
|
+
import { HostSessionQuotaSource, type FrictionTriageDecision, type InterpretedIntent, type SessionConfig, type HostModelRosterEntry, type CapacityPool, type PartialCompletionTerminal, type RollingDispatchResult, type ProviderSlot, type EngineDecisionSink, type ProviderName, type DispatchModelTier } from "audit-tools/shared";
|
|
4
4
|
import type { RemediationStep, RemediationDispatchPlan } from "./types.js";
|
|
5
5
|
import { isTerminalStatus, isVerifiedCompleteStatus } from "../state/itemStatus.js";
|
|
6
6
|
import { type GateRunner } from "./finalGate.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextStep.d.ts","sourceRoot":"","sources":["../../../src/remediate/steps/nextStep.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAGV,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"nextStep.d.ts","sourceRoot":"","sources":["../../../src/remediate/steps/nextStep.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAGV,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EA4BL,sBAAsB,EAmCtB,KAAK,sBAAsB,EAG3B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EAGjB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAmC5B,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAK3E,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EAEzB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAuCxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoB3D,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM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{ dirname, join, resolve } from "node:path";
|
|
5
5
|
import { StateStore } from "../state/store.js";
|
|
6
|
-
|
|
6
|
+
// IO / validation / rendering helpers
|
|
7
|
+
import { discardOnSchemaVersionMismatch, buildSelfSpawnExclusion, readOptionalJsonFile, readValidatedRepoSessionIntent, stagedAndUntracked, writeJsonFile, writeTextFile, buildAuditDeliverablePair, formatValidationIssues, isRecord, withFsRetry, RunLogger, DISPATCH_PROMPT_HANDOFF_NOTE, renderHostScratchNote, hostScratchDir, renderQuotaCoverageNudge, renderTokenBudgetView, coerceJsonObjectArg,
|
|
8
|
+
// rolling engine + quota
|
|
9
|
+
driveRolling, resolveLedgerBudgets, setQuotaStateDir, detectHostDispatchWall, admissionBlockedOnBudget, classifyEmptyGrantCause, reconcileAdmissionLeasesFromQuotaFile, buildQuotaPausedTerminal, HostSessionQuotaSource, quotaPoolKey,
|
|
10
|
+
// obligation engine + intent
|
|
11
|
+
interpretFreeFormIntent, advance, decideFrictionTriage, buildFrictionTriageBlock,
|
|
12
|
+
// dispatch planning / provider classification
|
|
13
|
+
planHybridDispatch, readSettledPools, addSettledPool, isPoolSettlingOutcome, isInProcessWorkerProvider, sourceByPoolId, classifyProvider, selectDispatchDriver, renderDispatchDriverInstruction, resolveHostProviderName, resolveHostDispatchProviderName, resolveHostDispatchCapability as sharedResolveHostDispatchCapability, resolveAutonomousMode, resolveRollingEngineFlag,
|
|
14
|
+
// friction capture
|
|
15
|
+
captureStepBoundaryFriction, captureZeroCapacityFriction, captureCostDriftFriction, captureCreditExhaustionFriction, captureQuotaUnclassifiedFriction, captureModelUnavailableFriction, capturePacketTooLargeFriction, createDispatchDecisionLog,
|
|
16
|
+
// domain constants
|
|
17
|
+
LENSES, SEVERITIES, } from "audit-tools/shared";
|
|
7
18
|
import { readRemediationAccessMemory, computeBlockContinuityScores } from "../state/accessMemory.js";
|
|
8
19
|
import { applyPlanPipeline, buildCoverageLedger } from "../phases/plan.js";
|
|
9
20
|
import { groundExtractedFindings } from "../phases/grounding.js";
|
|
@@ -1019,12 +1030,12 @@ function normalizeExtractedPlan(value) {
|
|
|
1019
1030
|
}
|
|
1020
1031
|
async function saveStateForPlan(artifactsDir, existing, plan, planCoverage) {
|
|
1021
1032
|
const items = {};
|
|
1033
|
+
const blockIds = blockIdsByFinding(plan);
|
|
1022
1034
|
for (const finding of plan.findings) {
|
|
1023
|
-
const block = plan.blocks.find((candidate) => candidate.items.includes(finding.id));
|
|
1024
1035
|
items[finding.id] = {
|
|
1025
1036
|
finding_id: finding.id,
|
|
1026
1037
|
status: "pending",
|
|
1027
|
-
block_id:
|
|
1038
|
+
block_id: blockIds.get(finding.id) ?? "UNKNOWN",
|
|
1028
1039
|
};
|
|
1029
1040
|
}
|
|
1030
1041
|
const state = {
|
|
@@ -1063,11 +1074,18 @@ function stripPlanTimeBookkeeping(value) {
|
|
|
1063
1074
|
function findingCarryForwardKey(finding) {
|
|
1064
1075
|
return JSON.stringify(stripPlanTimeBookkeeping(finding));
|
|
1065
1076
|
}
|
|
1077
|
+
// Single-block membership is enforced by `fixupBlocksAfterDedup` (each finding
|
|
1078
|
+
// id appears in exactly one block's items after fixup), so this scan is a plain
|
|
1079
|
+
// projection. First-wins in block order is kept as the tie-break for defense in
|
|
1080
|
+
// depth — it is the same order fixup resolves ownership in, so the two can
|
|
1081
|
+
// never disagree even on a malformed plan.
|
|
1066
1082
|
function blockIdsByFinding(plan) {
|
|
1067
1083
|
const byFinding = new Map();
|
|
1068
1084
|
for (const block of plan.blocks) {
|
|
1069
1085
|
for (const id of block.items) {
|
|
1070
|
-
byFinding.
|
|
1086
|
+
if (!byFinding.has(id)) {
|
|
1087
|
+
byFinding.set(id, block.block_id);
|
|
1088
|
+
}
|
|
1071
1089
|
}
|
|
1072
1090
|
}
|
|
1073
1091
|
return byFinding;
|
|
@@ -1989,6 +2007,7 @@ async function handlePendingExtractedPlan(root, artifactsDir, existing, extracte
|
|
|
1989
2007
|
// way declined findings are recorded; their payloads recover at close from the
|
|
1990
2008
|
// unfiltered intake source.
|
|
1991
2009
|
const filterDisp = await readOptionalJsonFile(reviewFilterDispositionsPath(artifactsDir));
|
|
2010
|
+
const pipelinedBlockIds = blockIdsByFinding(pipelined);
|
|
1992
2011
|
const coverage = filterDisp
|
|
1993
2012
|
? buildCoverageLedger({
|
|
1994
2013
|
planId: pipelined.plan_id,
|
|
@@ -2015,8 +2034,7 @@ async function handlePendingExtractedPlan(root, artifactsDir, existing, extracte
|
|
|
2015
2034
|
{
|
|
2016
2035
|
finding_id: finding.id,
|
|
2017
2036
|
status: "pending",
|
|
2018
|
-
block_id:
|
|
2019
|
-
?.block_id ?? "UNKNOWN",
|
|
2037
|
+
block_id: pipelinedBlockIds.get(finding.id) ?? "UNKNOWN",
|
|
2020
2038
|
},
|
|
2021
2039
|
])),
|
|
2022
2040
|
});
|
|
@@ -2370,31 +2388,49 @@ async function handleReadyIntakeContractPipeline(root, artifactsDir, options) {
|
|
|
2370
2388
|
if (!intake.summary || !isIntakeReady(intake.summary)) {
|
|
2371
2389
|
return null;
|
|
2372
2390
|
}
|
|
2391
|
+
// Resolve the manifest sources ONCE for the whole step (risk signal, Path A,
|
|
2392
|
+
// and the pipeline source inputs all consume the same snapshot), and read the
|
|
2393
|
+
// structured-audit source file at most once via a memoized reader (an
|
|
2394
|
+
// unreadable source memoizes `undefined`; extractAuditFindings on undefined
|
|
2395
|
+
// yields the empty set, so consumers degrade exactly as before).
|
|
2396
|
+
const manifestSources = intake.manifest
|
|
2397
|
+
? resolveManifestSources(root, intake.manifest).resolved
|
|
2398
|
+
: [];
|
|
2399
|
+
const auditSource = intake.summary.source_type === "structured_audit"
|
|
2400
|
+
? manifestSources.find((s) => s.type === "structured_audit")
|
|
2401
|
+
: undefined;
|
|
2402
|
+
let auditFindingsCache;
|
|
2403
|
+
const readAuditFindingsOnce = async () => {
|
|
2404
|
+
if (!auditSource) {
|
|
2405
|
+
return undefined;
|
|
2406
|
+
}
|
|
2407
|
+
if (!auditFindingsCache) {
|
|
2408
|
+
let value;
|
|
2409
|
+
try {
|
|
2410
|
+
value = JSON.parse(await readFile(auditSource.path, "utf8"));
|
|
2411
|
+
}
|
|
2412
|
+
catch {
|
|
2413
|
+
value = undefined;
|
|
2414
|
+
}
|
|
2415
|
+
auditFindingsCache = { value };
|
|
2416
|
+
}
|
|
2417
|
+
return auditFindingsCache.value;
|
|
2418
|
+
};
|
|
2373
2419
|
// Slice 2 — compute & persist the shared intake risk/complexity signal the
|
|
2374
2420
|
// self-scaling dials (Slices 3/4) will read. Idempotent: recorded once from
|
|
2375
2421
|
// intake-available data only (affected_files + goals + path-risk patterns), so
|
|
2376
|
-
// a later escalate-on-evidence raise is never clobbered. The
|
|
2377
|
-
//
|
|
2378
|
-
// where the top-level summary.affected_files is
|
|
2379
|
-
// per-finding) — it unions the per-finding
|
|
2380
|
-
// patterns actually fire (fail-closed: a
|
|
2381
|
-
// `low`). No behavior keys on it yet —
|
|
2422
|
+
// a later escalate-on-evidence raise is never clobbered. The audit-source read
|
|
2423
|
+
// happens only on the run that actually computes (memoized above), and for
|
|
2424
|
+
// structured_audit — where the top-level summary.affected_files is
|
|
2425
|
+
// legitimately empty (paths live per-finding) — it unions the per-finding
|
|
2426
|
+
// affected files so the path-risk patterns actually fire (fail-closed: a
|
|
2427
|
+
// risky-subsystem audit must not land `low`). No behavior keys on it yet —
|
|
2428
|
+
// this establishes the source of truth.
|
|
2382
2429
|
await ensureIntakeRiskSignal(artifactsDir, async () => {
|
|
2383
2430
|
const summary = intake.summary;
|
|
2384
2431
|
const affectedFiles = summary.affected_files.map((f) => f.path);
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
if (auditSource) {
|
|
2388
|
-
try {
|
|
2389
|
-
const parsed = JSON.parse(await readFile(auditSource.path, "utf8"));
|
|
2390
|
-
affectedFiles.push(...distinctAffectedFiles(extractAuditFindings(parsed)));
|
|
2391
|
-
}
|
|
2392
|
-
catch {
|
|
2393
|
-
// Unreadable audit source — leave the summary-derived list; an empty
|
|
2394
|
-
// list with non-empty goals still rates conservatively via intent.
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2432
|
+
const parsed = await readAuditFindingsOnce();
|
|
2433
|
+
affectedFiles.push(...distinctAffectedFiles(extractAuditFindings(parsed)));
|
|
2398
2434
|
return { affectedFiles, goals: summary.goals };
|
|
2399
2435
|
});
|
|
2400
2436
|
const pipeline = shouldEnterContractPipeline(artifactsDir, intake.summary.source_type);
|
|
@@ -2419,118 +2455,109 @@ async function handleReadyIntakeContractPipeline(root, artifactsDir, options) {
|
|
|
2419
2455
|
// ledger is built over the originals (every audit finding → exactly one
|
|
2420
2456
|
// disposition). The gate may halt to collect the user's decision.
|
|
2421
2457
|
let reviewSourceSwap;
|
|
2422
|
-
if (
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2458
|
+
if (auditSource) {
|
|
2459
|
+
const auditFindings = await readAuditFindingsOnce();
|
|
2460
|
+
const originals = extractAuditFindings(auditFindings);
|
|
2461
|
+
if (originals.length > 0) {
|
|
2462
|
+
const checkpoint = await readOptionalJsonFile(join(artifactsDir, "intent_checkpoint.json"));
|
|
2463
|
+
const filter = await runFindingFilterPass(originals, {
|
|
2464
|
+
root,
|
|
2465
|
+
checkpoint: checkpoint ?? undefined,
|
|
2466
|
+
evidenceGrounding: true,
|
|
2467
|
+
});
|
|
2468
|
+
const gate = await runReviewApprovalGate(root, artifactsDir, filter.survivors,
|
|
2469
|
+
// Autonomy resolves from the PERSISTED session config (hoisted load
|
|
2470
|
+
// above) → env → attended default, never from the bare CLI options.
|
|
2471
|
+
resolveAutonomousMode({ sessionConfig: sessionConfigForDispatch }));
|
|
2472
|
+
if (gate.kind === "halt") {
|
|
2473
|
+
return gate.step;
|
|
2428
2474
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2475
|
+
// Persist the filter dispositions so coverage is built over the originals.
|
|
2476
|
+
await persistReviewFilterDispositions(artifactsDir, originals, filter);
|
|
2477
|
+
// Lean path = the `low` risk tier's realization (D-68 — the standalone lean
|
|
2478
|
+
// fast-path folded into the self-scaling dial; its two mechanisms now live in
|
|
2479
|
+
// `riskSignal.ts` (light-review) + `contractPipeline.ts` (lean plan builder)).
|
|
2480
|
+
// A run skips the heavy contract DESIGN loop and
|
|
2481
|
+
// synthesizes the extracted plan directly IFF its effective risk tier is `low`;
|
|
2482
|
+
// the plan→implement→close machinery (per-node verify-before-merge + the final
|
|
2483
|
+
// whole-repo gate) is the retained safety net. Runs only here — on Path A
|
|
2484
|
+
// (structured_audit), the only intake with a pre-existing finding set to judge.
|
|
2485
|
+
//
|
|
2486
|
+
// First fold the APPROVED set's finding-level risk (grounding / confidence /
|
|
2487
|
+
// coupling / systemic / architecture / count — the finding-QUALITY dimension the
|
|
2488
|
+
// intake path/breadth/intent signal doesn't see) INTO the shared risk signal as
|
|
2489
|
+
// escalate-on-evidence. This makes the tier the SINGLE classifier: there is no
|
|
2490
|
+
// separate fast-path boolean that can DISAGREE with it (a grounded handful
|
|
2491
|
+
// touching a risk subsystem stays `high` and takes the full pipeline, instead of
|
|
2492
|
+
// bypassing it as the old parallel `evaluateFastPath` allowed).
|
|
2493
|
+
const findingEvidence = findingRiskEvidence(gate.approved);
|
|
2494
|
+
let riskSignal = await readIntakeRiskSignal(artifactsDir);
|
|
2495
|
+
if (findingEvidence && riskSignal) {
|
|
2496
|
+
const raised = escalateRiskSignal(riskSignal, findingEvidence);
|
|
2497
|
+
// escalateRiskSignal returns the SAME reference when the evidence does not
|
|
2498
|
+
// raise the tier — only persist on an actual change (no byte-identical rewrite).
|
|
2499
|
+
if (raised !== riskSignal) {
|
|
2500
|
+
riskSignal = raised;
|
|
2501
|
+
await writeIntakeRiskSignal(artifactsDir, riskSignal);
|
|
2502
|
+
}
|
|
2431
2503
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
// Autonomy resolves from the PERSISTED session config (hoisted load
|
|
2442
|
-
// above) → env → attended default, never from the bare CLI options.
|
|
2443
|
-
resolveAutonomousMode({ sessionConfig: sessionConfigForDispatch }));
|
|
2444
|
-
if (gate.kind === "halt") {
|
|
2445
|
-
return gate.step;
|
|
2504
|
+
// T1 slice 3b — the lean tier is NOT zero-scrutiny: a `low`-tier run first runs
|
|
2505
|
+
// a bounded LIGHT adversarial review over the approved findings (the floor,
|
|
2506
|
+
// never off — `adversarialDepthForTier("low") === "light"`). A clear verdict
|
|
2507
|
+
// proceeds to the lean plan; a verdict that surfaces a real concern escalates
|
|
2508
|
+
// the risk signal and routes to the full pipeline below.
|
|
2509
|
+
if (gate.approved.length > 0 && riskSignal?.tier === "low") {
|
|
2510
|
+
const review = await runLeanLightReviewGate(root, artifactsDir, gate.approved);
|
|
2511
|
+
if (review.kind === "halt") {
|
|
2512
|
+
return review.step;
|
|
2446
2513
|
}
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
// (structured_audit), the only intake with a pre-existing finding set to judge.
|
|
2457
|
-
//
|
|
2458
|
-
// First fold the APPROVED set's finding-level risk (grounding / confidence /
|
|
2459
|
-
// coupling / systemic / architecture / count — the finding-QUALITY dimension the
|
|
2460
|
-
// intake path/breadth/intent signal doesn't see) INTO the shared risk signal as
|
|
2461
|
-
// escalate-on-evidence. This makes the tier the SINGLE classifier: there is no
|
|
2462
|
-
// separate fast-path boolean that can DISAGREE with it (a grounded handful
|
|
2463
|
-
// touching a risk subsystem stays `high` and takes the full pipeline, instead of
|
|
2464
|
-
// bypassing it as the old parallel `evaluateFastPath` allowed).
|
|
2465
|
-
const findingEvidence = findingRiskEvidence(gate.approved);
|
|
2466
|
-
let riskSignal = await readIntakeRiskSignal(artifactsDir);
|
|
2467
|
-
if (findingEvidence && riskSignal) {
|
|
2468
|
-
const raised = escalateRiskSignal(riskSignal, findingEvidence);
|
|
2469
|
-
// escalateRiskSignal returns the SAME reference when the evidence does not
|
|
2470
|
-
// raise the tier — only persist on an actual change (no byte-identical rewrite).
|
|
2471
|
-
if (raised !== riskSignal) {
|
|
2472
|
-
riskSignal = raised;
|
|
2473
|
-
await writeIntakeRiskSignal(artifactsDir, riskSignal);
|
|
2474
|
-
}
|
|
2514
|
+
if (review.kind === "escalate") {
|
|
2515
|
+
// Escalate-on-evidence: raise the signal to at least `medium` so the
|
|
2516
|
+
// full pipeline's adversarial depth is `full` (see slice 3a), then
|
|
2517
|
+
// fall through to the full pipeline.
|
|
2518
|
+
await writeIntakeRiskSignal(artifactsDir, escalateRiskSignal(riskSignal, {
|
|
2519
|
+
tier: "medium",
|
|
2520
|
+
reason: `lean light review surfaced a concern: ${review.concerns.join("; ")}`,
|
|
2521
|
+
}));
|
|
2522
|
+
process.stderr.write(`[remediate-code] Lean light review escalated (${review.concerns.join("; ")}); routing to the full contract pipeline.\n`);
|
|
2475
2523
|
}
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
return review.step;
|
|
2524
|
+
else {
|
|
2525
|
+
// Clear verdict → proceed with the lean plan.
|
|
2526
|
+
const leanPlan = buildLeanExtractedPlan(gate.approved, randomRunId("LEAN"));
|
|
2527
|
+
await writeJsonFile(intakePaths(artifactsDir).extractedPlan, leanPlan);
|
|
2528
|
+
process.stderr.write(`[remediate-code] Lean fast path (risk tier low): ${riskSignal.rationale.join("; ")}; light review clear. Routing to plan→implement.\n`);
|
|
2529
|
+
const planned = await handlePendingExtractedPlan(root, artifactsDir, { status: "pending" }, leanPlan);
|
|
2530
|
+
if (planned) {
|
|
2531
|
+
return planned;
|
|
2485
2532
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
tier: "medium",
|
|
2492
|
-
reason: `lean light review surfaced a concern: ${review.concerns.join("; ")}`,
|
|
2493
|
-
}));
|
|
2494
|
-
process.stderr.write(`[remediate-code] Lean light review escalated (${review.concerns.join("; ")}); routing to the full contract pipeline.\n`);
|
|
2495
|
-
}
|
|
2496
|
-
else {
|
|
2497
|
-
// Clear verdict → proceed with the lean plan.
|
|
2498
|
-
const leanPlan = buildLeanExtractedPlan(gate.approved, randomRunId("LEAN"));
|
|
2499
|
-
await writeJsonFile(intakePaths(artifactsDir).extractedPlan, leanPlan);
|
|
2500
|
-
process.stderr.write(`[remediate-code] Lean fast path (risk tier low): ${riskSignal.rationale.join("; ")}; light review clear. Routing to plan→implement.\n`);
|
|
2501
|
-
const planned = await handlePendingExtractedPlan(root, artifactsDir, { status: "pending" }, leanPlan);
|
|
2502
|
-
if (planned) {
|
|
2503
|
-
return planned;
|
|
2504
|
-
}
|
|
2505
|
-
// Defensive: a deterministically-built lean plan should always
|
|
2506
|
-
// normalize. If it somehow didn't, handlePendingExtractedPlan removed
|
|
2507
|
-
// the file; fall through to the full pipeline (the safety net) rather
|
|
2508
|
-
// than stalling the run.
|
|
2509
|
-
process.stderr.write("[remediate-code] Lean fast-path plan failed to materialize; falling back to the contract pipeline.\n");
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
// Seed the pipeline with the approved survivors only. When that set is
|
|
2513
|
-
// narrower than the originals (anything filtered or declined), route the
|
|
2514
|
-
// seed AND the pipeline's source inputs at a filtered file so a removed
|
|
2515
|
-
// finding can never re-enter via the raw audit-findings.json (tool-enforced).
|
|
2516
|
-
const approvedPayload = isRecord(auditFindings)
|
|
2517
|
-
? { ...auditFindings, findings: gate.approved }
|
|
2518
|
-
: { findings: gate.approved };
|
|
2519
|
-
let seedSourcePath = auditSource.path;
|
|
2520
|
-
if (gate.approved.length < originals.length) {
|
|
2521
|
-
await mkdir(contractPipelineDir(artifactsDir), { recursive: true });
|
|
2522
|
-
seedSourcePath = join(contractPipelineDir(artifactsDir), "approved-findings.json");
|
|
2523
|
-
await writeJsonFile(seedSourcePath, approvedPayload);
|
|
2524
|
-
reviewSourceSwap = { from: auditSource.path, to: seedSourcePath };
|
|
2525
|
-
}
|
|
2526
|
-
try {
|
|
2527
|
-
await writePathASeedFromFindings(artifactsDir, seedSourcePath, approvedPayload);
|
|
2528
|
-
}
|
|
2529
|
-
catch {
|
|
2530
|
-
// If the seed cannot be written, the pipeline still runs; the LLM
|
|
2531
|
-
// phases use the source files from sourcePaths.
|
|
2533
|
+
// Defensive: a deterministically-built lean plan should always
|
|
2534
|
+
// normalize. If it somehow didn't, handlePendingExtractedPlan removed
|
|
2535
|
+
// the file; fall through to the full pipeline (the safety net) rather
|
|
2536
|
+
// than stalling the run.
|
|
2537
|
+
process.stderr.write("[remediate-code] Lean fast-path plan failed to materialize; falling back to the contract pipeline.\n");
|
|
2532
2538
|
}
|
|
2533
2539
|
}
|
|
2540
|
+
// Seed the pipeline with the approved survivors only. When that set is
|
|
2541
|
+
// narrower than the originals (anything filtered or declined), route the
|
|
2542
|
+
// seed AND the pipeline's source inputs at a filtered file so a removed
|
|
2543
|
+
// finding can never re-enter via the raw audit-findings.json (tool-enforced).
|
|
2544
|
+
const approvedPayload = isRecord(auditFindings)
|
|
2545
|
+
? { ...auditFindings, findings: gate.approved }
|
|
2546
|
+
: { findings: gate.approved };
|
|
2547
|
+
let seedSourcePath = auditSource.path;
|
|
2548
|
+
if (gate.approved.length < originals.length) {
|
|
2549
|
+
await mkdir(contractPipelineDir(artifactsDir), { recursive: true });
|
|
2550
|
+
seedSourcePath = join(contractPipelineDir(artifactsDir), "approved-findings.json");
|
|
2551
|
+
await writeJsonFile(seedSourcePath, approvedPayload);
|
|
2552
|
+
reviewSourceSwap = { from: auditSource.path, to: seedSourcePath };
|
|
2553
|
+
}
|
|
2554
|
+
try {
|
|
2555
|
+
await writePathASeedFromFindings(artifactsDir, seedSourcePath, approvedPayload);
|
|
2556
|
+
}
|
|
2557
|
+
catch {
|
|
2558
|
+
// If the seed cannot be written, the pipeline still runs; the LLM
|
|
2559
|
+
// phases use the source files from sourcePaths.
|
|
2560
|
+
}
|
|
2534
2561
|
}
|
|
2535
2562
|
}
|
|
2536
2563
|
const paths = intakePaths(artifactsDir);
|
|
@@ -2538,14 +2565,12 @@ async function handleReadyIntakeContractPipeline(root, artifactsDir, options) {
|
|
|
2538
2565
|
if (existsSync(paths.brief)) {
|
|
2539
2566
|
sourcePaths.add(paths.brief);
|
|
2540
2567
|
}
|
|
2541
|
-
|
|
2542
|
-
for
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
: source.path);
|
|
2548
|
-
}
|
|
2568
|
+
for (const source of manifestSources) {
|
|
2569
|
+
// Swap the raw audit-findings.json for the approved-only filtered file so a
|
|
2570
|
+
// declined finding can never re-enter the pipeline as a source input.
|
|
2571
|
+
sourcePaths.add(reviewSourceSwap && source.path === reviewSourceSwap.from
|
|
2572
|
+
? reviewSourceSwap.to
|
|
2573
|
+
: source.path);
|
|
2549
2574
|
}
|
|
2550
2575
|
// Resolve the independent-critic dispatch capability from the SAME handshake
|
|
2551
2576
|
// (`resolveHostDispatchCapability`) implement dispatch uses — never a manual
|