audit-tools 0.28.7 → 0.28.9
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-install-hosts.mjs +133 -27
- package/dist/audit/cli/confirmIntentStep.d.ts +1 -0
- package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
- package/dist/audit/cli/confirmIntentStep.js +14 -10
- package/dist/audit/cli/confirmIntentStep.js.map +1 -1
- package/dist/audit/cli/dispatch/quotaPool.d.ts.map +1 -1
- package/dist/audit/cli/dispatch/quotaPool.js +4 -3
- package/dist/audit/cli/dispatch/quotaPool.js.map +1 -1
- package/dist/audit/cli/dispatch.d.ts +15 -1
- package/dist/audit/cli/dispatch.d.ts.map +1 -1
- package/dist/audit/cli/dispatch.js +54 -19
- package/dist/audit/cli/dispatch.js.map +1 -1
- package/dist/audit/cli/hybridDispatch.d.ts +46 -0
- package/dist/audit/cli/hybridDispatch.d.ts.map +1 -0
- package/dist/audit/cli/hybridDispatch.js +77 -0
- package/dist/audit/cli/hybridDispatch.js.map +1 -0
- package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
- package/dist/audit/cli/nextStepHelpers.js +111 -2
- package/dist/audit/cli/nextStepHelpers.js.map +1 -1
- package/dist/audit/cli/quotaCommand.d.ts.map +1 -1
- package/dist/audit/cli/quotaCommand.js +20 -10
- package/dist/audit/cli/quotaCommand.js.map +1 -1
- package/dist/audit/cli/reviewRun.d.ts +8 -0
- package/dist/audit/cli/reviewRun.d.ts.map +1 -1
- package/dist/audit/cli/reviewRun.js +1 -1
- package/dist/audit/cli/reviewRun.js.map +1 -1
- package/dist/audit/cli/rollingAuditDispatch.d.ts +57 -4
- package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
- package/dist/audit/cli/rollingAuditDispatch.js +137 -10
- package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
- package/dist/audit/cli/scoreAuditCommand.d.ts +16 -0
- package/dist/audit/cli/scoreAuditCommand.d.ts.map +1 -0
- package/dist/audit/cli/scoreAuditCommand.js +82 -0
- package/dist/audit/cli/scoreAuditCommand.js.map +1 -0
- package/dist/audit/cli/submitPacketCommand.d.ts.map +1 -1
- package/dist/audit/cli/submitPacketCommand.js +8 -1
- package/dist/audit/cli/submitPacketCommand.js.map +1 -1
- package/dist/audit/cli.d.ts.map +1 -1
- package/dist/audit/cli.js +5 -1
- package/dist/audit/cli.js.map +1 -1
- package/dist/audit/orchestrator/designReviewProjection.d.ts +9 -1
- package/dist/audit/orchestrator/designReviewProjection.d.ts.map +1 -1
- package/dist/audit/orchestrator/designReviewProjection.js +19 -1
- package/dist/audit/orchestrator/designReviewProjection.js.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.d.ts +2 -0
- package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.js +11 -1
- package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
- package/dist/audit/orchestrator/executorRunners.js +1 -1
- package/dist/audit/orchestrator/executorRunners.js.map +1 -1
- package/dist/audit/orchestrator/intakeExecutors.d.ts +9 -1
- package/dist/audit/orchestrator/intakeExecutors.d.ts.map +1 -1
- package/dist/audit/orchestrator/intakeExecutors.js +16 -3
- package/dist/audit/orchestrator/intakeExecutors.js.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.js +3 -0
- package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
- package/dist/audit/orchestrator/intentInterpreter.d.ts +21 -7
- package/dist/audit/orchestrator/intentInterpreter.d.ts.map +1 -1
- package/dist/audit/orchestrator/intentInterpreter.js +30 -11
- package/dist/audit/orchestrator/intentInterpreter.js.map +1 -1
- package/dist/audit/orchestrator/intentScopeDisposition.d.ts +49 -0
- package/dist/audit/orchestrator/intentScopeDisposition.d.ts.map +1 -0
- package/dist/audit/orchestrator/intentScopeDisposition.js +57 -0
- package/dist/audit/orchestrator/intentScopeDisposition.js.map +1 -0
- package/dist/audit/orchestrator/rollingDispatch.d.ts +9 -0
- package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
- package/dist/audit/orchestrator/rollingDispatch.js +10 -0
- package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
- package/dist/audit/orchestrator/scope.d.ts +1 -0
- package/dist/audit/orchestrator/scope.d.ts.map +1 -1
- package/dist/audit/orchestrator/scope.js +2 -7
- package/dist/audit/orchestrator/scope.js.map +1 -1
- package/dist/audit/quota/index.d.ts +5 -0
- package/dist/audit/quota/index.d.ts.map +1 -1
- package/dist/audit/reporting/scoreAudit.d.ts +161 -0
- package/dist/audit/reporting/scoreAudit.d.ts.map +1 -0
- package/dist/audit/reporting/scoreAudit.js +224 -0
- package/dist/audit/reporting/scoreAudit.js.map +1 -0
- package/dist/audit/types/activeDispatch.d.ts +29 -1
- package/dist/audit/types/activeDispatch.d.ts.map +1 -1
- package/dist/audit/types/activeDispatch.js.map +1 -1
- package/dist/audit/types/analyzerCapability.d.ts +6 -6
- package/dist/audit/validation/auditResults.d.ts +13 -0
- package/dist/audit/validation/auditResults.d.ts.map +1 -1
- package/dist/audit/validation/auditResults.js +35 -12
- package/dist/audit/validation/auditResults.js.map +1 -1
- package/dist/remediate/contractPipeline/changeClassification.d.ts +146 -0
- package/dist/remediate/contractPipeline/changeClassification.d.ts.map +1 -0
- package/dist/remediate/contractPipeline/changeClassification.js +398 -0
- package/dist/remediate/contractPipeline/changeClassification.js.map +1 -0
- package/dist/remediate/contractPipeline/derive.d.ts.map +1 -1
- package/dist/remediate/contractPipeline/derive.js +9 -0
- package/dist/remediate/contractPipeline/derive.js.map +1 -1
- package/dist/remediate/intent/intentOrdering.d.ts +51 -0
- package/dist/remediate/intent/intentOrdering.d.ts.map +1 -0
- package/dist/remediate/intent/intentOrdering.js +150 -0
- package/dist/remediate/intent/intentOrdering.js.map +1 -0
- package/dist/remediate/phases/plan.d.ts.map +1 -1
- package/dist/remediate/phases/plan.js +14 -1
- package/dist/remediate/phases/plan.js.map +1 -1
- package/dist/remediate/providers/index.d.ts +32 -0
- package/dist/remediate/providers/index.d.ts.map +1 -1
- package/dist/remediate/providers/index.js +28 -1
- package/dist/remediate/providers/index.js.map +1 -1
- package/dist/remediate/steps/contractPipeline.d.ts +15 -1
- package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
- package/dist/remediate/steps/contractPipeline.js +282 -14
- package/dist/remediate/steps/contractPipeline.js.map +1 -1
- package/dist/remediate/steps/dispatch.d.ts +56 -1
- package/dist/remediate/steps/dispatch.d.ts.map +1 -1
- package/dist/remediate/steps/dispatch.js +120 -29
- package/dist/remediate/steps/dispatch.js.map +1 -1
- package/dist/remediate/steps/nextStep.d.ts +53 -2
- package/dist/remediate/steps/nextStep.d.ts.map +1 -1
- package/dist/remediate/steps/nextStep.js +253 -81
- package/dist/remediate/steps/nextStep.js.map +1 -1
- package/dist/remediate/steps/providerNodeDispatch.d.ts +8 -1
- package/dist/remediate/steps/providerNodeDispatch.d.ts.map +1 -1
- package/dist/remediate/steps/providerNodeDispatch.js +7 -2
- package/dist/remediate/steps/providerNodeDispatch.js.map +1 -1
- package/dist/remediate/steps/rollingSession.d.ts +55 -1
- package/dist/remediate/steps/rollingSession.d.ts.map +1 -1
- package/dist/remediate/steps/rollingSession.js +128 -19
- package/dist/remediate/steps/rollingSession.js.map +1 -1
- package/dist/remediate/validation/contractPipelineGates.d.ts +23 -8
- package/dist/remediate/validation/contractPipelineGates.d.ts.map +1 -1
- package/dist/remediate/validation/contractPipelineGates.js +43 -38
- package/dist/remediate/validation/contractPipelineGates.js.map +1 -1
- package/dist/shared/dispatch/coordinator.d.ts +170 -0
- package/dist/shared/dispatch/coordinator.d.ts.map +1 -0
- package/dist/shared/dispatch/coordinator.js +177 -0
- package/dist/shared/dispatch/coordinator.js.map +1 -0
- package/dist/shared/dispatch/hybridDispatch.d.ts +74 -0
- package/dist/shared/dispatch/hybridDispatch.d.ts.map +1 -0
- package/dist/shared/dispatch/hybridDispatch.js +54 -0
- package/dist/shared/dispatch/hybridDispatch.js.map +1 -0
- package/dist/shared/dispatch/settledPools.d.ts +21 -0
- package/dist/shared/dispatch/settledPools.d.ts.map +1 -0
- package/dist/shared/dispatch/settledPools.js +34 -0
- package/dist/shared/dispatch/settledPools.js.map +1 -0
- package/dist/shared/index.d.ts +16 -6
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +15 -3
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/intent/clauseInterpreter.d.ts +19 -0
- package/dist/shared/intent/clauseInterpreter.d.ts.map +1 -1
- package/dist/shared/intent/clauseInterpreter.js +19 -0
- package/dist/shared/intent/clauseInterpreter.js.map +1 -1
- package/dist/shared/io/json.d.ts +25 -0
- package/dist/shared/io/json.d.ts.map +1 -1
- package/dist/shared/io/json.js +67 -0
- package/dist/shared/io/json.js.map +1 -1
- package/dist/shared/providers/opencodeProvider.d.ts.map +1 -1
- package/dist/shared/providers/opencodeProvider.js +12 -0
- package/dist/shared/providers/opencodeProvider.js.map +1 -1
- package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
- package/dist/shared/providers/providerConfirmation.js +9 -1
- package/dist/shared/providers/providerConfirmation.js.map +1 -1
- package/dist/shared/providers/providerFactory.d.ts +1 -0
- package/dist/shared/providers/providerFactory.d.ts.map +1 -1
- package/dist/shared/providers/providerFactory.js +10 -8
- package/dist/shared/providers/providerFactory.js.map +1 -1
- package/dist/shared/providers/sharedProviderConfirmation.d.ts +134 -0
- package/dist/shared/providers/sharedProviderConfirmation.d.ts.map +1 -0
- package/dist/shared/providers/sharedProviderConfirmation.js +244 -0
- package/dist/shared/providers/sharedProviderConfirmation.js.map +1 -0
- package/dist/shared/quota/apiPool.d.ts +67 -0
- package/dist/shared/quota/apiPool.d.ts.map +1 -0
- package/dist/shared/quota/apiPool.js +139 -0
- package/dist/shared/quota/apiPool.js.map +1 -0
- package/dist/shared/quota/capacity.d.ts +29 -1
- package/dist/shared/quota/capacity.d.ts.map +1 -1
- package/dist/shared/quota/capacity.js +5 -0
- package/dist/shared/quota/capacity.js.map +1 -1
- package/dist/shared/quota/claimRegistry.d.ts +64 -0
- package/dist/shared/quota/claimRegistry.d.ts.map +1 -0
- package/dist/shared/quota/claimRegistry.js +157 -0
- package/dist/shared/quota/claimRegistry.js.map +1 -0
- package/dist/shared/quota/compositeQuotaSource.d.ts +10 -1
- package/dist/shared/quota/compositeQuotaSource.d.ts.map +1 -1
- package/dist/shared/quota/compositeQuotaSource.js +34 -6
- package/dist/shared/quota/compositeQuotaSource.js.map +1 -1
- package/dist/shared/quota/httpQuotaSource.d.ts +9 -1
- package/dist/shared/quota/httpQuotaSource.d.ts.map +1 -1
- package/dist/shared/quota/httpQuotaSource.js +33 -8
- package/dist/shared/quota/httpQuotaSource.js.map +1 -1
- package/dist/shared/quota/learnedQuotaSource.d.ts +7 -1
- package/dist/shared/quota/learnedQuotaSource.d.ts.map +1 -1
- package/dist/shared/quota/learnedQuotaSource.js +18 -7
- package/dist/shared/quota/learnedQuotaSource.js.map +1 -1
- package/dist/shared/quota/quotaSource.d.ts +41 -0
- package/dist/shared/quota/quotaSource.d.ts.map +1 -1
- package/dist/shared/quota/quotaSource.js +19 -0
- package/dist/shared/quota/quotaSource.js.map +1 -1
- package/dist/shared/types/contractPipeline/obligations.d.ts +42 -0
- package/dist/shared/types/contractPipeline/obligations.d.ts.map +1 -1
- package/dist/shared/types/contractPipeline.d.ts +1 -1
- package/dist/shared/types/contractPipeline.d.ts.map +1 -1
- package/dist/shared/types/contractPipeline.js.map +1 -1
- package/dist/shared/types/intentCheckpoint.d.ts +14 -0
- package/dist/shared/types/intentCheckpoint.d.ts.map +1 -1
- package/dist/shared/types/intentCheckpoint.js +10 -0
- package/dist/shared/types/intentCheckpoint.js.map +1 -1
- package/dist/shared/types/sessionConfig.d.ts +60 -0
- package/dist/shared/types/sessionConfig.d.ts.map +1 -1
- package/dist/shared/types/sessionConfig.js +13 -0
- package/dist/shared/types/sessionConfig.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FreshSessionProvider } from "./types.js";
|
|
2
2
|
import type { ResolvedProviderName, SessionConfig, ClaudeCodeConfig, OpenCodeConfig } from "../types/sessionConfig.js";
|
|
3
3
|
import { RunLogger } from "../observability/runLog.js";
|
|
4
|
+
export declare function hasConfiguredOpenCode(sessionConfig: SessionConfig): boolean;
|
|
4
5
|
/**
|
|
5
6
|
* openai-compatible is configured when both an endpoint and a model are set. The
|
|
6
7
|
* API key is resolved (and degrades) at launch — env presence is intentionally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerFactory.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/providerFactory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAEhB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"providerFactory.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/providerFactory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAEhB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAcvD,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAK3E;AAMD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,GACzC,OAAO,CAET;AAQD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,E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audeCode(sessionConfig) {
|
|
|
11
11
|
hasEntries(sessionConfig.claude_code?.extra_args) ||
|
|
12
12
|
sessionConfig.claude_code?.dangerously_skip_permissions === true);
|
|
13
13
|
}
|
|
14
|
-
function hasConfiguredOpenCode(sessionConfig) {
|
|
14
|
+
export function hasConfiguredOpenCode(sessionConfig) {
|
|
15
15
|
return (Boolean(sessionConfig.opencode?.command?.trim()) ||
|
|
16
16
|
hasEntries(sessionConfig.opencode?.extra_args));
|
|
17
17
|
}
|
|
@@ -127,14 +127,16 @@ const PROVIDER_PRIORITY_RULES = [
|
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
name: "claude-code",
|
|
130
|
-
comment: "Tie-break: claude is available
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
name: "opencode",
|
|
135
|
-
comment: "Tie-break: opencode is available but claude is not — prefer opencode.",
|
|
136
|
-
predicate: (ctx) => ctx.opencodeAvailable && !ctx.claudeAvailable,
|
|
130
|
+
comment: "Tie-break: claude is available — prefer claude-code. (No `!opencodeAvailable` " +
|
|
131
|
+
"guard: opencode no longer competes at the bare-availability rung, so claude " +
|
|
132
|
+
"wins whenever present rather than yielding to an unconfigured opencode.)",
|
|
133
|
+
predicate: (ctx) => ctx.claudeAvailable,
|
|
137
134
|
},
|
|
135
|
+
// NOTE: there is deliberately NO bare-availability opencode tie-break. A
|
|
136
|
+
// PATH-detected `opencode` is OPT-IN only — it is auto-selected solely via the
|
|
137
|
+
// config-gated rung above (hasOpenCodeConfig && opencodeAvailable). Without
|
|
138
|
+
// claude and without configured-opencode, resolution falls through to
|
|
139
|
+
// local-subprocess rather than launching opencode unprompted (PB-1).
|
|
138
140
|
{
|
|
139
141
|
name: "openai-compatible",
|
|
140
142
|
comment: "Configured background pool: an OpenAI-compatible endpoint (base_url + model) is an API, " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerFactory.js","sourceRoot":"","sources":["../../../src/shared/providers/providerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,SAAS,UAAU,CAAC,MAA4B;IAC9C,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,uBAAuB,CAAC,aAA4B;IAC3D,OAAO,CACL,OAAO,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACnD,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,CAAC;QACjD,aAAa,CAAC,WAAW,EAAE,4BAA4B,KAAK,IAAI,CACjE,CAAC;AACJ,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"providerFactory.js","sourceRoot":"","sources":["../../../src/shared/providers/providerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,SAAS,UAAU,CAAC,MAA4B;IAC9C,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,uBAAuB,CAAC,aAA4B;IAC3D,OAAO,CACL,OAAO,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC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}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DC-2 — shared, session-scoped provider confirmation (Gate-0).
|
|
3
|
+
*
|
|
4
|
+
* The design wants ONE provider confirmation spanning an audit→remediate run:
|
|
5
|
+
* the first tool to run writes the confirmed provider pool to a SHARED artifact
|
|
6
|
+
* at `<root>/.audit-tools/provider-confirmation.json` (NOT the per-tool audit
|
|
7
|
+
* artifacts dir); the second tool reads and honors it unless the roster has
|
|
8
|
+
* since changed. "Session" = the shared `.audit-tools` dir for that repo+run, so
|
|
9
|
+
* no new identity scheme is needed.
|
|
10
|
+
*
|
|
11
|
+
* Two invariants are in tension and are reconciled here by the CE-012 third
|
|
12
|
+
* state:
|
|
13
|
+
* - INV-DC1-6 (never-block): remediate run standalone with no prior audit must
|
|
14
|
+
* resolve its provider independently, exactly as today — absence of the
|
|
15
|
+
* artifact is NOT an error.
|
|
16
|
+
* - INV-DC2-3 (roster-stale-re-confirm): a confirmation whose discovered roster
|
|
17
|
+
* no longer matches the current one must NOT be silently honored (it could
|
|
18
|
+
* pin a provider that has since disappeared) — it must re-confirm.
|
|
19
|
+
* A single `null` return cannot carry both meanings (CE-012). So the accessor
|
|
20
|
+
* returns a THREE-valued result: `null` for absent/malformed (never-block),
|
|
21
|
+
* `{ status: 'confirmed' }` for a fresh honor, and the DISTINCT
|
|
22
|
+
* `{ status: 'reconfirm' }` for roster-stale — so honoring INV-DC2-3 no longer
|
|
23
|
+
* contradicts INV-DC1-6.
|
|
24
|
+
*
|
|
25
|
+
* CE-003 (lockless read races the writer rename): writes go through the shared
|
|
26
|
+
* atomic writer (temp + atomic rename) under `withFileLock`, so a lockless
|
|
27
|
+
* reader always observes either the complete old file or the complete new file —
|
|
28
|
+
* never a torn intermediate.
|
|
29
|
+
*
|
|
30
|
+
* PB-1 (opencode opt-in): the roster is derived from `discoverProviders`, which
|
|
31
|
+
* already withholds a bare-PATH opencode unless it is explicitly configured, so
|
|
32
|
+
* the shared confirmation inherits that opt-in for free.
|
|
33
|
+
*/
|
|
34
|
+
import type { ResolvedProviderName, SessionConfig } from "../types/sessionConfig.js";
|
|
35
|
+
import type { RunLogger } from "../observability/runLog.js";
|
|
36
|
+
import type { ConfirmedPoolEntry } from "../types/providerConfirmation.js";
|
|
37
|
+
/**
|
|
38
|
+
* Schema version for the shared confirmation artifact. Bumped independently of
|
|
39
|
+
* the per-tool seam contract (PROVIDER_CONFIRMATION_RESULT_VERSION) — this is
|
|
40
|
+
* the cross-tool session artifact, a distinct shape that also carries the
|
|
41
|
+
* roster snapshot used for staleness.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SHARED_PROVIDER_CONFIRMATION_VERSION: "1.0.0";
|
|
44
|
+
/** File name of the shared session-level confirmation under `.audit-tools/`. */
|
|
45
|
+
export declare const SHARED_PROVIDER_CONFIRMATION_FILENAME = "provider-confirmation.json";
|
|
46
|
+
/** `<root>/.audit-tools/provider-confirmation.json` (absolute). */
|
|
47
|
+
export declare function sharedProviderConfirmationPath(root: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The shared session-level provider confirmation. Single-sourced so both
|
|
50
|
+
* orchestrators read/write exactly the same shape.
|
|
51
|
+
*
|
|
52
|
+
* `roster` is the sorted snapshot of the provider names discovered at write
|
|
53
|
+
* time. Staleness is "the current discovered roster differs from this snapshot"
|
|
54
|
+
* — a provider appearing or disappearing forces a re-confirm.
|
|
55
|
+
*/
|
|
56
|
+
export interface SharedProviderConfirmation {
|
|
57
|
+
/** Must equal SHARED_PROVIDER_CONFIRMATION_VERSION. */
|
|
58
|
+
schema_version: typeof SHARED_PROVIDER_CONFIRMATION_VERSION;
|
|
59
|
+
/** Always true: the pool applies to the whole audit→remediate session. */
|
|
60
|
+
session_level: true;
|
|
61
|
+
/** ISO-8601 timestamp of when the pool was confirmed. */
|
|
62
|
+
confirmed_at: string;
|
|
63
|
+
/** Confirmed provider pool, with exclusion flags. */
|
|
64
|
+
provider_pool: ConfirmedPoolEntry[];
|
|
65
|
+
/**
|
|
66
|
+
* Sorted snapshot of the provider NAMES discovered when this was written.
|
|
67
|
+
* Compared against the current discovered roster to detect staleness.
|
|
68
|
+
*/
|
|
69
|
+
roster: ResolvedProviderName[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Outcome of reading the shared confirmation. THREE-valued (CE-012):
|
|
73
|
+
* - `null` absent or malformed → never-block (INV-DC1-6)
|
|
74
|
+
* - `{ status: 'confirmed' }` present + roster matches → honor it
|
|
75
|
+
* - `{ status: 'reconfirm' }` present + roster changed → re-confirm (INV-DC2-3)
|
|
76
|
+
*/
|
|
77
|
+
export type SharedProviderConfirmationRead = {
|
|
78
|
+
status: "confirmed";
|
|
79
|
+
confirmation: SharedProviderConfirmation;
|
|
80
|
+
} | {
|
|
81
|
+
status: "reconfirm";
|
|
82
|
+
confirmation: SharedProviderConfirmation;
|
|
83
|
+
reason: string;
|
|
84
|
+
} | null;
|
|
85
|
+
/**
|
|
86
|
+
* The current discovered provider roster: the sorted set of provider names
|
|
87
|
+
* `discoverProviders` surfaces for this session config + environment. PB-1's
|
|
88
|
+
* opencode opt-in is inherited from `discoverProviders` (a bare-PATH opencode is
|
|
89
|
+
* not surfaced unless explicitly configured), so it never spuriously perturbs
|
|
90
|
+
* the roster.
|
|
91
|
+
*/
|
|
92
|
+
export declare function currentProviderRoster(sessionConfig: SessionConfig, env?: NodeJS.ProcessEnv): ResolvedProviderName[];
|
|
93
|
+
/**
|
|
94
|
+
* Build a fresh shared confirmation from auto-discovery. Guarantees the
|
|
95
|
+
* always-available `local-subprocess` fallback is present in the pool (it blocks
|
|
96
|
+
* auto-dispatch and so is never PATH-detected, but the pool must always be able
|
|
97
|
+
* to fall back to it) and stamps the schema version, session-level flag, and
|
|
98
|
+
* confirmation timestamp.
|
|
99
|
+
*
|
|
100
|
+
* @param sessionConfig - Current session config; may be an empty `{}`.
|
|
101
|
+
* @param env - Process env snapshot; defaults to `process.env`.
|
|
102
|
+
* @param exclude - Provider names to pre-exclude (from a prior gate).
|
|
103
|
+
*/
|
|
104
|
+
export declare function buildSharedProviderConfirmation(sessionConfig?: SessionConfig, env?: NodeJS.ProcessEnv, exclude?: ResolvedProviderName[]): SharedProviderConfirmation;
|
|
105
|
+
/**
|
|
106
|
+
* Atomically write the shared confirmation to
|
|
107
|
+
* `<root>/.audit-tools/provider-confirmation.json`. The durable write goes
|
|
108
|
+
* through the shared atomic writer (temp + atomic rename) and the whole
|
|
109
|
+
* operation is guarded by `withFileLock` so a concurrent writer can never
|
|
110
|
+
* interleave — and a lockless reader (see `readSharedProviderConfirmation`)
|
|
111
|
+
* never observes a torn file (CE-003).
|
|
112
|
+
*/
|
|
113
|
+
export declare function writeSharedProviderConfirmation(root: string, confirmation: SharedProviderConfirmation, logger?: RunLogger): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Read + interpret the shared confirmation for `root`. THREE-valued (CE-012):
|
|
116
|
+
*
|
|
117
|
+
* - returns `null` when the artifact is ABSENT or MALFORMED — the caller then
|
|
118
|
+
* resolves its provider independently, exactly as today (INV-DC1-6
|
|
119
|
+
* never-block). Absence is the standalone-remediate case and is not an error.
|
|
120
|
+
* - returns `{ status: 'confirmed', confirmation }` when the artifact is valid
|
|
121
|
+
* AND the stamped roster still matches the currently-discovered roster — the
|
|
122
|
+
* caller honors the recorded pool.
|
|
123
|
+
* - returns `{ status: 'reconfirm', confirmation, reason }` when the artifact
|
|
124
|
+
* is valid but the roster has CHANGED since it was written (a provider
|
|
125
|
+
* appeared or disappeared) — a DISTINCT signal so the caller re-confirms
|
|
126
|
+
* rather than pinning a stale pool (INV-DC2-3). This is the CE-012 third
|
|
127
|
+
* state that keeps INV-DC2-3 from collapsing into the never-block `null`.
|
|
128
|
+
*
|
|
129
|
+
* Never throws: a read/parse failure is treated as absent/malformed → `null`.
|
|
130
|
+
* The read is lockless (no lock needed: the writer's atomic rename guarantees a
|
|
131
|
+
* complete file either way — CE-003) and so cannot deadlock against a writer.
|
|
132
|
+
*/
|
|
133
|
+
export declare function readSharedProviderConfirmation(root: string, sessionConfig?: SessionConfig, env?: NodeJS.ProcessEnv): Promise<SharedProviderConfirmationRead>;
|
|
134
|
+
//# sourceMappingURL=sharedProviderConfirmation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedProviderConfirmation.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/sharedProviderConfirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAIrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAK5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAM3E;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,EAAG,OAAgB,CAAC;AAErE,gFAAgF;AAChF,eAAO,MAAM,qCAAqC,+BACpB,CAAC;AAE/B,mEAAmE;AACnE,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnE;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,uDAAuD;IACvD,cAAc,EAAE,OAAO,oCAAoC,CAAC;IAC5D,0EAA0E;IAC1E,aAAa,EAAE,IAAI,CAAC;IACpB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,aAAa,EAAE,kBAAkB,EAAE,CAAC;IACpC;;;OAGG;IACH,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,GACtC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,YAAY,EAAE,0BAA0B,CAAA;CAAE,GACjE;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,0BAA0B,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB,GACD,IAAI,CAAC;AAMT;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,EAC5B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,oBAAoB,EAAE,CAGxB;AAuBD;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,aAAa,GAAE,aAAkB,EACjC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,OAAO,GAAE,oBAAoB,EAAO,GACnC,0BAA0B,CAiC5B;AAMD;;;;;;;GAOG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,0BAA0B,EACxC,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,IAAI,CAAC,CAef;AA2DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,MAAM,EACZ,aAAa,GAAE,aAAkB,EACjC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,8BAA8B,CAAC,CA8BzC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DC-2 — shared, session-scoped provider confirmation (Gate-0).
|
|
3
|
+
*
|
|
4
|
+
* The design wants ONE provider confirmation spanning an audit→remediate run:
|
|
5
|
+
* the first tool to run writes the confirmed provider pool to a SHARED artifact
|
|
6
|
+
* at `<root>/.audit-tools/provider-confirmation.json` (NOT the per-tool audit
|
|
7
|
+
* artifacts dir); the second tool reads and honors it unless the roster has
|
|
8
|
+
* since changed. "Session" = the shared `.audit-tools` dir for that repo+run, so
|
|
9
|
+
* no new identity scheme is needed.
|
|
10
|
+
*
|
|
11
|
+
* Two invariants are in tension and are reconciled here by the CE-012 third
|
|
12
|
+
* state:
|
|
13
|
+
* - INV-DC1-6 (never-block): remediate run standalone with no prior audit must
|
|
14
|
+
* resolve its provider independently, exactly as today — absence of the
|
|
15
|
+
* artifact is NOT an error.
|
|
16
|
+
* - INV-DC2-3 (roster-stale-re-confirm): a confirmation whose discovered roster
|
|
17
|
+
* no longer matches the current one must NOT be silently honored (it could
|
|
18
|
+
* pin a provider that has since disappeared) — it must re-confirm.
|
|
19
|
+
* A single `null` return cannot carry both meanings (CE-012). So the accessor
|
|
20
|
+
* returns a THREE-valued result: `null` for absent/malformed (never-block),
|
|
21
|
+
* `{ status: 'confirmed' }` for a fresh honor, and the DISTINCT
|
|
22
|
+
* `{ status: 'reconfirm' }` for roster-stale — so honoring INV-DC2-3 no longer
|
|
23
|
+
* contradicts INV-DC1-6.
|
|
24
|
+
*
|
|
25
|
+
* CE-003 (lockless read races the writer rename): writes go through the shared
|
|
26
|
+
* atomic writer (temp + atomic rename) under `withFileLock`, so a lockless
|
|
27
|
+
* reader always observes either the complete old file or the complete new file —
|
|
28
|
+
* never a torn intermediate.
|
|
29
|
+
*
|
|
30
|
+
* PB-1 (opencode opt-in): the roster is derived from `discoverProviders`, which
|
|
31
|
+
* already withholds a bare-PATH opencode unless it is explicitly configured, so
|
|
32
|
+
* the shared confirmation inherits that opt-in for free.
|
|
33
|
+
*/
|
|
34
|
+
import { mkdir } from "node:fs/promises";
|
|
35
|
+
import { join } from "node:path";
|
|
36
|
+
import { auditToolsDir } from "../io/auditToolsPaths.js";
|
|
37
|
+
import { readJsonFile, writeJsonFile } from "../io/json.js";
|
|
38
|
+
import { withFileLock } from "../quota/fileLock.js";
|
|
39
|
+
import { discoverProviders, } from "./providerConfirmation.js";
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Version + on-disk location
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
/**
|
|
44
|
+
* Schema version for the shared confirmation artifact. Bumped independently of
|
|
45
|
+
* the per-tool seam contract (PROVIDER_CONFIRMATION_RESULT_VERSION) — this is
|
|
46
|
+
* the cross-tool session artifact, a distinct shape that also carries the
|
|
47
|
+
* roster snapshot used for staleness.
|
|
48
|
+
*/
|
|
49
|
+
export const SHARED_PROVIDER_CONFIRMATION_VERSION = "1.0.0";
|
|
50
|
+
/** File name of the shared session-level confirmation under `.audit-tools/`. */
|
|
51
|
+
export const SHARED_PROVIDER_CONFIRMATION_FILENAME = "provider-confirmation.json";
|
|
52
|
+
/** `<root>/.audit-tools/provider-confirmation.json` (absolute). */
|
|
53
|
+
export function sharedProviderConfirmationPath(root) {
|
|
54
|
+
return join(auditToolsDir(root), SHARED_PROVIDER_CONFIRMATION_FILENAME);
|
|
55
|
+
}
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// Roster derivation
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* The current discovered provider roster: the sorted set of provider names
|
|
61
|
+
* `discoverProviders` surfaces for this session config + environment. PB-1's
|
|
62
|
+
* opencode opt-in is inherited from `discoverProviders` (a bare-PATH opencode is
|
|
63
|
+
* not surfaced unless explicitly configured), so it never spuriously perturbs
|
|
64
|
+
* the roster.
|
|
65
|
+
*/
|
|
66
|
+
export function currentProviderRoster(sessionConfig, env = process.env) {
|
|
67
|
+
const names = discoverProviders(sessionConfig, env).map((p) => p.name);
|
|
68
|
+
return sortRoster(names);
|
|
69
|
+
}
|
|
70
|
+
function sortRoster(names) {
|
|
71
|
+
// Deduplicate + sort so the snapshot is order-insensitive and comparison is a
|
|
72
|
+
// plain stringified equality.
|
|
73
|
+
return [...new Set(names)].sort();
|
|
74
|
+
}
|
|
75
|
+
function rostersEqual(a, b) {
|
|
76
|
+
if (a.length !== b.length)
|
|
77
|
+
return false;
|
|
78
|
+
for (let i = 0; i < a.length; i++) {
|
|
79
|
+
if (a[i] !== b[i])
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Build
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/**
|
|
88
|
+
* Build a fresh shared confirmation from auto-discovery. Guarantees the
|
|
89
|
+
* always-available `local-subprocess` fallback is present in the pool (it blocks
|
|
90
|
+
* auto-dispatch and so is never PATH-detected, but the pool must always be able
|
|
91
|
+
* to fall back to it) and stamps the schema version, session-level flag, and
|
|
92
|
+
* confirmation timestamp.
|
|
93
|
+
*
|
|
94
|
+
* @param sessionConfig - Current session config; may be an empty `{}`.
|
|
95
|
+
* @param env - Process env snapshot; defaults to `process.env`.
|
|
96
|
+
* @param exclude - Provider names to pre-exclude (from a prior gate).
|
|
97
|
+
*/
|
|
98
|
+
export function buildSharedProviderConfirmation(sessionConfig = {}, env = process.env, exclude = []) {
|
|
99
|
+
const discovered = discoverProviders(sessionConfig, env);
|
|
100
|
+
const excludeSet = new Set(exclude);
|
|
101
|
+
const pool = [];
|
|
102
|
+
// Always include local-subprocess as a fallback — it's always available and is
|
|
103
|
+
// never surfaced by PATH discovery (it blocks auto-dispatch by design).
|
|
104
|
+
if (!discovered.some((p) => p.name === "local-subprocess")) {
|
|
105
|
+
pool.push({
|
|
106
|
+
name: "local-subprocess",
|
|
107
|
+
capability_tier: "unknown",
|
|
108
|
+
excluded: excludeSet.has("local-subprocess"),
|
|
109
|
+
reason: "always-available fallback; no PATH detection required",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const provider of discovered) {
|
|
113
|
+
pool.push({
|
|
114
|
+
name: provider.name,
|
|
115
|
+
capability_tier: provider.capabilityTier,
|
|
116
|
+
excluded: excludeSet.has(provider.name),
|
|
117
|
+
reason: provider.reason,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
schema_version: SHARED_PROVIDER_CONFIRMATION_VERSION,
|
|
122
|
+
session_level: true,
|
|
123
|
+
confirmed_at: new Date().toISOString(),
|
|
124
|
+
provider_pool: pool,
|
|
125
|
+
roster: sortRoster(discovered.map((p) => p.name)),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
// Write (audit writes it)
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
/**
|
|
132
|
+
* Atomically write the shared confirmation to
|
|
133
|
+
* `<root>/.audit-tools/provider-confirmation.json`. The durable write goes
|
|
134
|
+
* through the shared atomic writer (temp + atomic rename) and the whole
|
|
135
|
+
* operation is guarded by `withFileLock` so a concurrent writer can never
|
|
136
|
+
* interleave — and a lockless reader (see `readSharedProviderConfirmation`)
|
|
137
|
+
* never observes a torn file (CE-003).
|
|
138
|
+
*/
|
|
139
|
+
export async function writeSharedProviderConfirmation(root, confirmation, logger) {
|
|
140
|
+
const path = sharedProviderConfirmationPath(root);
|
|
141
|
+
const lockPath = `${path}.lock`;
|
|
142
|
+
// Ensure the `.audit-tools` dir exists BEFORE acquiring the lock — the lock is
|
|
143
|
+
// a sibling file, so its atomic `wx` create would otherwise ENOENT on a fresh
|
|
144
|
+
// root (mirrors StateStore.saveState mkdir-then-lock).
|
|
145
|
+
await mkdir(auditToolsDir(root), { recursive: true });
|
|
146
|
+
await withFileLock(lockPath, async () => {
|
|
147
|
+
await writeJsonFile(path, confirmation);
|
|
148
|
+
}, undefined, logger);
|
|
149
|
+
}
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
// Validation
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
function isResolvedProviderNameArray(value) {
|
|
154
|
+
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
155
|
+
}
|
|
156
|
+
function isConfirmedPoolEntry(value) {
|
|
157
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const obj = value;
|
|
161
|
+
return (typeof obj.name === "string" &&
|
|
162
|
+
typeof obj.capability_tier === "string" &&
|
|
163
|
+
typeof obj.excluded === "boolean");
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Validate a parsed value as a SharedProviderConfirmation. Returns the typed
|
|
167
|
+
* value or `null` when any required field is missing or malformed — a corrupt
|
|
168
|
+
* artifact must degrade to the never-block path, never throw.
|
|
169
|
+
*/
|
|
170
|
+
function parseSharedProviderConfirmation(value) {
|
|
171
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const obj = value;
|
|
175
|
+
if (obj.schema_version !== SHARED_PROVIDER_CONFIRMATION_VERSION)
|
|
176
|
+
return null;
|
|
177
|
+
if (obj.session_level !== true)
|
|
178
|
+
return null;
|
|
179
|
+
if (typeof obj.confirmed_at !== "string")
|
|
180
|
+
return null;
|
|
181
|
+
if (!Array.isArray(obj.provider_pool) ||
|
|
182
|
+
!obj.provider_pool.every(isConfirmedPoolEntry)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (!isResolvedProviderNameArray(obj.roster))
|
|
186
|
+
return null;
|
|
187
|
+
return {
|
|
188
|
+
schema_version: SHARED_PROVIDER_CONFIRMATION_VERSION,
|
|
189
|
+
session_level: true,
|
|
190
|
+
confirmed_at: obj.confirmed_at,
|
|
191
|
+
provider_pool: obj.provider_pool,
|
|
192
|
+
roster: obj.roster,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// Read (remediate gains this)
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
/**
|
|
199
|
+
* Read + interpret the shared confirmation for `root`. THREE-valued (CE-012):
|
|
200
|
+
*
|
|
201
|
+
* - returns `null` when the artifact is ABSENT or MALFORMED — the caller then
|
|
202
|
+
* resolves its provider independently, exactly as today (INV-DC1-6
|
|
203
|
+
* never-block). Absence is the standalone-remediate case and is not an error.
|
|
204
|
+
* - returns `{ status: 'confirmed', confirmation }` when the artifact is valid
|
|
205
|
+
* AND the stamped roster still matches the currently-discovered roster — the
|
|
206
|
+
* caller honors the recorded pool.
|
|
207
|
+
* - returns `{ status: 'reconfirm', confirmation, reason }` when the artifact
|
|
208
|
+
* is valid but the roster has CHANGED since it was written (a provider
|
|
209
|
+
* appeared or disappeared) — a DISTINCT signal so the caller re-confirms
|
|
210
|
+
* rather than pinning a stale pool (INV-DC2-3). This is the CE-012 third
|
|
211
|
+
* state that keeps INV-DC2-3 from collapsing into the never-block `null`.
|
|
212
|
+
*
|
|
213
|
+
* Never throws: a read/parse failure is treated as absent/malformed → `null`.
|
|
214
|
+
* The read is lockless (no lock needed: the writer's atomic rename guarantees a
|
|
215
|
+
* complete file either way — CE-003) and so cannot deadlock against a writer.
|
|
216
|
+
*/
|
|
217
|
+
export async function readSharedProviderConfirmation(root, sessionConfig = {}, env = process.env) {
|
|
218
|
+
const path = sharedProviderConfirmationPath(root);
|
|
219
|
+
let raw;
|
|
220
|
+
try {
|
|
221
|
+
raw = await readJsonFile(path);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Absent (ENOENT) OR unreadable / invalid-JSON both degrade to the
|
|
225
|
+
// never-block path — a missing or corrupt artifact is never an error here.
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
const confirmation = parseSharedProviderConfirmation(raw);
|
|
229
|
+
if (confirmation === null) {
|
|
230
|
+
// Malformed (wrong shape / version drift) → never-block.
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const current = currentProviderRoster(sessionConfig, env);
|
|
234
|
+
if (!rostersEqual(confirmation.roster, current)) {
|
|
235
|
+
return {
|
|
236
|
+
status: "reconfirm",
|
|
237
|
+
confirmation,
|
|
238
|
+
reason: `discovered provider roster changed since confirmation ` +
|
|
239
|
+
`(was [${confirmation.roster.join(", ")}], now [${current.join(", ")}])`,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return { status: "confirmed", confirmation };
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=sharedProviderConfirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedProviderConfirmation.js","sourceRoot":"","sources":["../../../src/shared/providers/sharedProviderConfirmation.ts"],"names":[],"mappings":"AAAA;;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ACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,IAAY,EACZ,gBAA+B,EAAE,EACjC,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,IAAI,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAC;IAElD,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,YAAY,CAAU,IAAI,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;QACnE,2EAA2E;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,+BAA+B,CAAC,GAAG,CAAC,CAAC;IAC1D,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,yDAAyD;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAChD,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,YAAY;YACZ,MAAM,EACJ,wDAAwD;gBACxD,SAAS,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;SAC3E,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CapacityPool } from "./capacity.js";
|
|
2
|
+
import type { DispatchableSource, SessionConfig } from "../types/sessionConfig.js";
|
|
3
|
+
import type { QuotaStateEntry } from "./types.js";
|
|
4
|
+
import type { QuotaSource } from "./quotaSource.js";
|
|
5
|
+
/**
|
|
6
|
+
* The stable id of a dispatchable source — its explicit `id`, or a
|
|
7
|
+
* `${provider}:${model ?? endpoint}` key so two sources of the same provider stay
|
|
8
|
+
* distinct as long as their model/endpoint differ. This is the CapacityPool id and
|
|
9
|
+
* the key learned quota is recorded under.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchableSourceId(source: DispatchableSource): string;
|
|
12
|
+
/**
|
|
13
|
+
* Bridge a generic {@link DispatchableSource} to the concrete per-provider config
|
|
14
|
+
* block its provider constructor expects, so `createFreshSessionProvider` can build
|
|
15
|
+
* the right backend FROM the source (not the global block). `endpoint` + `parameters`
|
|
16
|
+
* are interpreted per provider: the API base_url + sampling params for
|
|
17
|
+
* `openai-compatible`; the launcher command + CLI args for the headless CLIs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sourceProviderConfig(source: DispatchableSource): Partial<SessionConfig>;
|
|
20
|
+
/**
|
|
21
|
+
* Overlay a dispatchable source's per-provider config block onto the session config,
|
|
22
|
+
* so `createFreshSessionProvider` builds the backend FROM that source — the launch
|
|
23
|
+
* reads THIS source's `{endpoint, model, parameters}`, not the global block. This is
|
|
24
|
+
* what lets two sources of the same provider (e.g. two NIM endpoints) launch
|
|
25
|
+
* distinctly. A node on the host's own pool (no source) passes the config through.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withSourceConfig(sessionConfig: SessionConfig, source: DispatchableSource | undefined): SessionConfig;
|
|
28
|
+
/** Index the source-backed pools by their pool id, for per-node provider resolution. */
|
|
29
|
+
export declare function sourceByPoolId(pools: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
source?: DispatchableSource;
|
|
32
|
+
}>): Map<string, DispatchableSource>;
|
|
33
|
+
/**
|
|
34
|
+
* Build one CapacityPool for a configured dispatchable backend source — generic over
|
|
35
|
+
* the source's provider. An independent backend pool: it does not draw on the host
|
|
36
|
+
* subagent budget (`hostConcurrencyLimit: null`); its rate limits come from the
|
|
37
|
+
* source's own `quota` (RPM/TPM/context/output) plus learned 429 state; it carries
|
|
38
|
+
* its real-time quota probe (degraded → the raw `quotaSignalDegraded` marker). The
|
|
39
|
+
* pool is TAGGED with its `source` so the dispatch worker rebuilds the provider from
|
|
40
|
+
* the source's `{endpoint, model, parameters}`, not the global per-provider block.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildSourcePool(params: {
|
|
43
|
+
source: DispatchableSource;
|
|
44
|
+
quotaSource: QuotaSource;
|
|
45
|
+
quotaEntries: Record<string, QuotaStateEntry>;
|
|
46
|
+
}): Promise<CapacityPool>;
|
|
47
|
+
/**
|
|
48
|
+
* Every dispatchable backend source configured for a run, in pool order: the explicit
|
|
49
|
+
* `sessionConfig.sources`, plus — for back-compat — a single implicit source folded in
|
|
50
|
+
* from a legacy `openai_compatible` block when it isn't the primary provider and isn't
|
|
51
|
+
* already covered by an explicit source of the same id.
|
|
52
|
+
*/
|
|
53
|
+
export declare function collectDispatchableSources(sessionConfig: SessionConfig, primaryProviderName: string): DispatchableSource[];
|
|
54
|
+
/**
|
|
55
|
+
* Build the CapacityPool for every configured dispatchable backend source (the
|
|
56
|
+
* generalization of the former openai-compatible-only `buildConfiguredApiPool`): one
|
|
57
|
+
* pool per source, the IDENTICAL shape across audit + remediate, so the spill topology
|
|
58
|
+
* can't drift and the operator can configure ANY non-IDE source — multiple NIM/vLLM
|
|
59
|
+
* endpoints, a CLI pool, … — each with its own rate limit.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildSourcePools(params: {
|
|
62
|
+
sessionConfig: SessionConfig;
|
|
63
|
+
primaryProviderName: string;
|
|
64
|
+
quotaSource: QuotaSource;
|
|
65
|
+
quotaEntries: Record<string, QuotaStateEntry>;
|
|
66
|
+
}): Promise<CapacityPool[]>;
|
|
67
|
+
//# sourceMappingURL=apiPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiPool.d.ts","sourceRoot":"","sources":["../../../src/shared/quota/apiPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACd,MAAM,2BAA2B,C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