@claudexor/orchestrator 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attemptFinalize.d.ts +14 -11
- package/dist/attemptFinalize.d.ts.map +1 -1
- package/dist/attemptFinalize.js +41 -14
- package/dist/attemptFinalize.js.map +1 -1
- package/dist/attemptTelemetry.d.ts +16 -20
- package/dist/attemptTelemetry.d.ts.map +1 -1
- package/dist/attemptTelemetry.js +38 -70
- package/dist/attemptTelemetry.js.map +1 -1
- package/dist/attemptUsageCost.d.ts +47 -0
- package/dist/attemptUsageCost.d.ts.map +1 -0
- package/dist/attemptUsageCost.js +191 -0
- package/dist/attemptUsageCost.js.map +1 -0
- package/dist/budgetFailure.d.ts +3 -1
- package/dist/budgetFailure.d.ts.map +1 -1
- package/dist/budgetFailure.js.map +1 -1
- package/dist/candidateEvidence.d.ts +5 -0
- package/dist/candidateEvidence.d.ts.map +1 -1
- package/dist/candidateEvidence.js +3 -1
- package/dist/candidateEvidence.js.map +1 -1
- package/dist/candidateOutputs.d.ts +19 -0
- package/dist/candidateOutputs.d.ts.map +1 -1
- package/dist/candidateOutputs.js +201 -67
- package/dist/candidateOutputs.js.map +1 -1
- package/dist/credential-profile-rotation.d.ts +145 -0
- package/dist/credential-profile-rotation.d.ts.map +1 -0
- package/dist/credential-profile-rotation.js +315 -0
- package/dist/credential-profile-rotation.js.map +1 -0
- package/dist/credential-profiles.d.ts +35 -134
- package/dist/credential-profiles.d.ts.map +1 -1
- package/dist/credential-profiles.js +73 -295
- package/dist/credential-profiles.js.map +1 -1
- package/dist/decisionBudget.d.ts +43 -0
- package/dist/decisionBudget.d.ts.map +1 -0
- package/dist/decisionBudget.js +84 -0
- package/dist/decisionBudget.js.map +1 -0
- package/dist/decisionTerminalReconciliation.d.ts +18 -0
- package/dist/decisionTerminalReconciliation.d.ts.map +1 -0
- package/dist/decisionTerminalReconciliation.js +26 -0
- package/dist/decisionTerminalReconciliation.js.map +1 -0
- package/dist/deepScanReducer.d.ts +14 -44
- package/dist/deepScanReducer.d.ts.map +1 -1
- package/dist/deepScanReducer.js +240 -128
- package/dist/deepScanReducer.js.map +1 -1
- package/dist/delegation-parent-activation.d.ts +6 -0
- package/dist/delegation-parent-activation.d.ts.map +1 -0
- package/dist/delegation-parent-activation.js +13 -0
- package/dist/delegation-parent-activation.js.map +1 -0
- package/dist/delegationBudgetAuthority.d.ts +30 -0
- package/dist/delegationBudgetAuthority.d.ts.map +1 -0
- package/dist/delegationBudgetAuthority.js +157 -0
- package/dist/delegationBudgetAuthority.js.map +1 -0
- package/dist/delegationFailure.d.ts +58 -0
- package/dist/delegationFailure.d.ts.map +1 -0
- package/dist/delegationFailure.js +184 -0
- package/dist/delegationFailure.js.map +1 -0
- package/dist/delegationToolEvidence.d.ts +20 -0
- package/dist/delegationToolEvidence.d.ts.map +1 -0
- package/dist/delegationToolEvidence.js +46 -0
- package/dist/delegationToolEvidence.js.map +1 -0
- package/dist/git-precondition.d.ts +11 -0
- package/dist/git-precondition.d.ts.map +1 -0
- package/dist/git-precondition.js +69 -0
- package/dist/git-precondition.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +14 -6
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +106 -19
- package/dist/interaction.js.map +1 -1
- package/dist/orchestrator.d.ts +62 -115
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +671 -965
- package/dist/orchestrator.js.map +1 -1
- package/dist/plan-prompt.d.ts +3 -0
- package/dist/plan-prompt.d.ts.map +1 -0
- package/dist/plan-prompt.js +28 -0
- package/dist/plan-prompt.js.map +1 -0
- package/dist/planBrief.d.ts +27 -0
- package/dist/planBrief.d.ts.map +1 -0
- package/dist/planBrief.js +42 -0
- package/dist/planBrief.js.map +1 -0
- package/dist/planRun.d.ts +4 -3
- package/dist/planRun.d.ts.map +1 -1
- package/dist/planRun.js +33 -33
- package/dist/planRun.js.map +1 -1
- package/dist/plannerAttempt.d.ts +64 -0
- package/dist/plannerAttempt.d.ts.map +1 -0
- package/dist/plannerAttempt.js +235 -0
- package/dist/plannerAttempt.js.map +1 -0
- package/dist/policyFindings.js.map +1 -1
- package/dist/requestRequirements.d.ts +45 -1
- package/dist/requestRequirements.d.ts.map +1 -1
- package/dist/requestRequirements.js +158 -11
- package/dist/requestRequirements.js.map +1 -1
- package/dist/reviewerPanel.js.map +1 -1
- package/dist/root-ledger.d.ts +13 -0
- package/dist/root-ledger.d.ts.map +1 -0
- package/dist/root-ledger.js +21 -0
- package/dist/root-ledger.js.map +1 -0
- package/dist/routing-failure.d.ts +6 -0
- package/dist/routing-failure.d.ts.map +1 -0
- package/dist/routing-failure.js +12 -0
- package/dist/routing-failure.js.map +1 -0
- package/dist/run-bounded.d.ts +3 -0
- package/dist/run-bounded.d.ts.map +1 -0
- package/dist/run-bounded.js +23 -0
- package/dist/run-bounded.js.map +1 -0
- package/dist/run-input-resolution.d.ts +10 -0
- package/dist/run-input-resolution.d.ts.map +1 -0
- package/dist/run-input-resolution.js +88 -0
- package/dist/run-input-resolution.js.map +1 -0
- package/dist/runEventLog.d.ts +48 -0
- package/dist/runEventLog.d.ts.map +1 -0
- package/dist/runEventLog.js +63 -0
- package/dist/runEventLog.js.map +1 -0
- package/dist/runFacts.d.ts +23 -0
- package/dist/runFacts.d.ts.map +1 -0
- package/dist/runFacts.js +179 -0
- package/dist/runFacts.js.map +1 -0
- package/dist/runFactsBuilder.d.ts +5 -0
- package/dist/runFactsBuilder.d.ts.map +1 -0
- package/dist/runFactsBuilder.js +412 -0
- package/dist/runFactsBuilder.js.map +1 -0
- package/dist/runFactsDeliverable.d.ts +13 -0
- package/dist/runFactsDeliverable.d.ts.map +1 -0
- package/dist/runFactsDeliverable.js +94 -0
- package/dist/runFactsDeliverable.js.map +1 -0
- package/dist/runFactsPresentation.d.ts +7 -0
- package/dist/runFactsPresentation.d.ts.map +1 -0
- package/dist/runFactsPresentation.js +113 -0
- package/dist/runFactsPresentation.js.map +1 -0
- package/dist/runFactsReview.d.ts +7 -0
- package/dist/runFactsReview.d.ts.map +1 -0
- package/dist/runFactsReview.js +63 -0
- package/dist/runFactsReview.js.map +1 -0
- package/dist/runSupport.d.ts +17 -15
- package/dist/runSupport.d.ts.map +1 -1
- package/dist/runSupport.js +16 -0
- package/dist/runSupport.js.map +1 -1
- package/dist/runTelemetryWriter.d.ts +5 -2
- package/dist/runTelemetryWriter.d.ts.map +1 -1
- package/dist/runTelemetryWriter.js +72 -1
- package/dist/runTelemetryWriter.js.map +1 -1
- package/dist/runTerminalContext.d.ts +31 -0
- package/dist/runTerminalContext.d.ts.map +1 -0
- package/dist/runTerminalContext.js +12 -0
- package/dist/runTerminalContext.js.map +1 -0
- package/dist/runTerminalResults.d.ts +55 -0
- package/dist/runTerminalResults.d.ts.map +1 -0
- package/dist/runTerminalResults.js +134 -0
- package/dist/runTerminalResults.js.map +1 -0
- package/dist/runTerminals.d.ts +8 -57
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +423 -135
- package/dist/runTerminals.js.map +1 -1
- package/dist/secretDiff.d.ts +32 -0
- package/dist/secretDiff.d.ts.map +1 -0
- package/dist/secretDiff.js +140 -0
- package/dist/secretDiff.js.map +1 -0
- package/dist/structuredOutput.d.ts.map +1 -1
- package/dist/structuredOutput.js.map +1 -1
- package/dist/task-contract-builder.d.ts +35 -0
- package/dist/task-contract-builder.d.ts.map +1 -0
- package/dist/task-contract-builder.js +114 -0
- package/dist/task-contract-builder.js.map +1 -0
- package/dist/terminalOutcome.d.ts +22 -0
- package/dist/terminalOutcome.d.ts.map +1 -0
- package/dist/terminalOutcome.js +39 -0
- package/dist/terminalOutcome.js.map +1 -0
- package/dist/transientClassify.js.map +1 -1
- package/package.json +17 -17
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CredentialProfileStatus as CredentialProfileStatusSchema } from "@claudexor/schema";
|
|
2
|
+
import { redactSecrets } from "@claudexor/util";
|
|
3
|
+
import { estimateEffectiveAuthRoute } from "@claudexor/schema";
|
|
4
|
+
import { nextEligibleProfile, profileHeadroomBreach, } from "./credential-profile-rotation.js";
|
|
5
|
+
export { nextEligibleProfile, planReactiveRotation, preflightCredentialProfile, preflightDefaultSubject, profileHeadroomBreach, rotateSpecOnTypedLimit, rotationRetryEligible, staticRotationCandidates, } from "./credential-profile-rotation.js";
|
|
2
6
|
/**
|
|
3
7
|
* The ONE resolve owner for credential profiles (INV-135): explicit id →
|
|
4
8
|
* durable registry entry for exactly this harness. Unknown, disabled, or
|
|
@@ -27,295 +31,98 @@ export async function selectedProfileAvailability(input) {
|
|
|
27
31
|
}
|
|
28
32
|
if (!input.probe)
|
|
29
33
|
return `harness "${input.harnessId}" has no profile probe`;
|
|
30
|
-
const result = await input.probe
|
|
31
|
-
|
|
32
|
-
(profile.credential_kind === "api_key" && result.verification === "not_run");
|
|
33
|
-
return result.availability === "available" && verificationAdmits
|
|
34
|
+
const result = await probeCredentialProfileStatus(profile, input.probe);
|
|
35
|
+
return profileStatusAdmits(profile, result)
|
|
34
36
|
? "available"
|
|
35
37
|
: (result.detail ?? `${result.availability}/${result.verification}`);
|
|
36
38
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
39
|
+
/** One readiness predicate shared by run admission and accounts projection. */
|
|
40
|
+
export function profileStatusAdmits(profile, result) {
|
|
41
|
+
const verificationAdmits = result.verification === "passed" ||
|
|
42
|
+
(profile.credential_kind === "api_key" && result.verification === "not_run");
|
|
43
|
+
return result.availability === "available" && verificationAdmits;
|
|
44
|
+
}
|
|
45
|
+
/** One fail-closed profile doctor wrapper shared by Accounts and runtime
|
|
46
|
+
* selection. Probe failures are readiness facts, never selector exceptions. */
|
|
47
|
+
export async function probeCredentialProfileStatus(profile, probe) {
|
|
48
|
+
if (!probe) {
|
|
49
|
+
return {
|
|
50
|
+
profile_id: profile.profile_id,
|
|
51
|
+
harness_id: profile.harness_id,
|
|
52
|
+
availability: "unknown",
|
|
53
|
+
verification: "not_run",
|
|
54
|
+
detail: `harness "${profile.harness_id}" has no profile probe`,
|
|
55
|
+
last_verified_at: null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const result = CredentialProfileStatusSchema.parse(await probe(profile));
|
|
60
|
+
if (result.profile_id !== profile.profile_id || result.harness_id !== profile.harness_id) {
|
|
61
|
+
throw new Error("profile readiness probe returned status for a different profile");
|
|
61
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
...result,
|
|
65
|
+
...(result.detail === undefined ? {} : { detail: redactSecrets(result.detail) }),
|
|
66
|
+
};
|
|
62
67
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* (release wave round-16 BLOCK): a subscription→API-key swap silently changes
|
|
73
|
-
* the payment model mid-attempt, and the attempt's first-wins auth-route
|
|
74
|
-
* receipt (decided once before spawn) would misvalue metered usage as
|
|
75
|
-
* subscription entitlement, bypassing a finite cash cap.
|
|
76
|
-
*/
|
|
77
|
-
export function nextEligibleProfile(registry, harnessId, policy, current, snapshots, excluded = new Set()) {
|
|
78
|
-
const pool = registry.filter((p) => p.harness_id === harnessId && p.enabled);
|
|
79
|
-
const ordered = policy.rotation_eligible.length > 0
|
|
80
|
-
? policy.rotation_eligible
|
|
81
|
-
.map((id) => pool.find((p) => p.profile_id === id))
|
|
82
|
-
.filter((p) => p !== undefined)
|
|
83
|
-
: pool;
|
|
84
|
-
for (const candidate of ordered) {
|
|
85
|
-
if (candidate.profile_id === current?.profile_id)
|
|
86
|
-
continue;
|
|
87
|
-
if (excluded.has(candidate.profile_id))
|
|
88
|
-
continue;
|
|
89
|
-
// Fail-CLOSED kind guard (round-17 hardening of the round-16 BLOCK): the
|
|
90
|
-
// kind comes from the TYPED current profile in hand — never re-found in
|
|
91
|
-
// a freshly reloaded pool, where a mid-flight disable/remove of the
|
|
92
|
-
// current profile would have silently dropped the cross-kind prohibition.
|
|
93
|
-
if (current !== null && candidate.credential_kind !== current.credential_kind)
|
|
94
|
-
continue;
|
|
95
|
-
// `current === null` is the DEFAULT subject (the vendor-native store): the
|
|
96
|
-
// same round-16 BLOCK applies — rotating the subscription default INTO an
|
|
97
|
-
// api_key profile would silently change the payment model mid-attempt.
|
|
98
|
-
if (current === null && candidate.credential_kind === "api_key")
|
|
99
|
-
continue;
|
|
100
|
-
if (profileHeadroomBreach(snapshots, harnessId, candidate.profile_id, policy.headroom_threshold))
|
|
101
|
-
continue;
|
|
102
|
-
return candidate;
|
|
68
|
+
catch (error) {
|
|
69
|
+
return {
|
|
70
|
+
profile_id: profile.profile_id,
|
|
71
|
+
harness_id: profile.harness_id,
|
|
72
|
+
availability: "unknown",
|
|
73
|
+
verification: "not_run",
|
|
74
|
+
detail: `profile readiness probe failed: ${redactSecrets(error instanceof Error ? error.message : String(error))}`,
|
|
75
|
+
last_verified_at: null,
|
|
76
|
+
};
|
|
103
77
|
}
|
|
104
|
-
|
|
78
|
+
}
|
|
79
|
+
/** Same precedence used by run admission: the first explicit route wins;
|
|
80
|
+
* `auto` means fall through rather than shadow a more general setting. */
|
|
81
|
+
export function effectiveAuthPreference(...values) {
|
|
82
|
+
return (values.find((value) => value !== undefined && value !== null && value !== "auto") ?? "auto");
|
|
83
|
+
}
|
|
84
|
+
/** Fresh effective route for the unprofiled/default subject in Accounts. The
|
|
85
|
+
* gateway status proves aggregate intent readiness; the schema auth estimator
|
|
86
|
+
* then chooses the exact usable source under the same configured preference as
|
|
87
|
+
* run admission. Returning the route (not merely a bool) keeps next_up labels
|
|
88
|
+
* truthful when a native-capable harness falls back to an API key. */
|
|
89
|
+
export function defaultCredentialRoute(status, requested) {
|
|
90
|
+
if (status.status !== "ok" || status.routableIntents.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
return estimateEffectiveAuthRoute(requested, status.authSources);
|
|
105
93
|
}
|
|
106
94
|
export function nextUpIdentity(args) {
|
|
107
|
-
const { registry, harnessId, policy, snapshots,
|
|
108
|
-
if (!
|
|
95
|
+
const { registry, harnessId, policy, snapshots, defaultEnabled, defaultReady, defaultRoute, readyProfileIds, } = args;
|
|
96
|
+
if (!defaultEnabled) {
|
|
109
97
|
return {
|
|
110
98
|
kind: "none",
|
|
111
|
-
reason: "the
|
|
99
|
+
reason: "the default credential is disabled; enable it or pin an account per-run (--profile)",
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (!defaultReady) {
|
|
103
|
+
return {
|
|
104
|
+
kind: "none",
|
|
105
|
+
reason: "the default credential is not ready; refresh Accounts or run `claudexor doctor`",
|
|
112
106
|
};
|
|
113
107
|
}
|
|
114
108
|
// Under `rotate`, a native/default subject already over its headroom bound
|
|
115
109
|
// fails over to the next eligible enabled profile BEFORE spawn — that is who
|
|
116
110
|
// an unpinned run routes to next. `ask`/`fail` proceed on the native default.
|
|
117
|
-
if (policy.limit_action === "rotate") {
|
|
111
|
+
if (policy.limit_action === "rotate" && defaultRoute === "local_session") {
|
|
118
112
|
const breach = profileHeadroomBreach(snapshots, harnessId, null, policy.headroom_threshold);
|
|
119
113
|
if (breach) {
|
|
120
|
-
const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots);
|
|
114
|
+
const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots, readyProfileIds);
|
|
121
115
|
if (next)
|
|
122
116
|
return { kind: "profile", profileId: next.profile_id };
|
|
123
117
|
}
|
|
124
118
|
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* `rotation_retry_eligible` (sol #30): a failover retry is allowed ONLY when
|
|
129
|
-
* the attempt saw a TYPED vendor limit AND produced no deliverable and no
|
|
130
|
-
* workspace mutation — a partially-acted attempt never silently reruns.
|
|
131
|
-
*/
|
|
132
|
-
export function rotationRetryEligible(input) {
|
|
133
|
-
return input.sawTypedLimit && input.deliverableEmpty;
|
|
134
|
-
}
|
|
135
|
-
function emitRotationExhausted(args) {
|
|
136
|
-
const excluded = args.excluded ?? new Set();
|
|
137
|
-
const candidates = args.registry
|
|
138
|
-
.filter((profile) => profile.harness_id === args.harnessId && profile.enabled)
|
|
139
|
-
.map((profile) => {
|
|
140
|
-
const breach = profileHeadroomBreach(args.snapshots, args.harnessId, profile.profile_id, args.policy.headroom_threshold);
|
|
141
|
-
const rejected = profile.profile_id === args.current?.profile_id
|
|
142
|
-
? "current"
|
|
143
|
-
: args.policy.rotation_eligible.length > 0 &&
|
|
144
|
-
!args.policy.rotation_eligible.includes(profile.profile_id)
|
|
145
|
-
? "not_in_rotation_policy"
|
|
146
|
-
: excluded.has(profile.profile_id)
|
|
147
|
-
? "already_tried"
|
|
148
|
-
: args.current && profile.credential_kind !== args.current.credential_kind
|
|
149
|
-
? "credential_kind_mismatch"
|
|
150
|
-
: args.current === null && profile.credential_kind === "api_key"
|
|
151
|
-
? "credential_kind_mismatch"
|
|
152
|
-
: breach
|
|
153
|
-
? "headroom_exceeded"
|
|
154
|
-
: "not_selected";
|
|
119
|
+
if (!defaultRoute) {
|
|
155
120
|
return {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
rejected,
|
|
159
|
-
headroom: breach,
|
|
121
|
+
kind: "none",
|
|
122
|
+
reason: "the default credential route is unknown; refresh Accounts or run `claudexor doctor`",
|
|
160
123
|
};
|
|
161
|
-
});
|
|
162
|
-
args.emit("route.profile.rotation_exhausted", {
|
|
163
|
-
harness_id: args.harnessId,
|
|
164
|
-
attempt_id: args.attemptId,
|
|
165
|
-
from_profile_id: args.current?.profile_id ?? null,
|
|
166
|
-
reason: args.reason,
|
|
167
|
-
threshold: args.policy.headroom_threshold,
|
|
168
|
-
candidates,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* `profile_headroom_preflight` (W5.4): BEFORE spawn, the selected profile's
|
|
173
|
-
* freshest quota windows are checked against the policy threshold. A breach
|
|
174
|
-
* is always a typed event; `rotate` swaps to the next eligible profile with
|
|
175
|
-
* provenance, `ask`/`fail` proceed on the selected profile — the runtime
|
|
176
|
-
* `vendor_limit_rejected` evidence stays the terminating truth.
|
|
177
|
-
*/
|
|
178
|
-
export function preflightCredentialProfile(args) {
|
|
179
|
-
const { profile, harnessId, policy, registry, snapshots, emit } = args;
|
|
180
|
-
const breach = profileHeadroomBreach(snapshots, harnessId, profile.profile_id, policy.headroom_threshold);
|
|
181
|
-
if (!breach)
|
|
182
|
-
return profile;
|
|
183
|
-
emit("route.profile.headroom_exceeded", {
|
|
184
|
-
harness_id: harnessId,
|
|
185
|
-
profile_id: profile.profile_id,
|
|
186
|
-
action: policy.limit_action,
|
|
187
|
-
constraint_id: breach.constraint_id,
|
|
188
|
-
used_ratio: breach.used_ratio,
|
|
189
|
-
threshold: breach.threshold,
|
|
190
|
-
resets_at: breach.resets_at,
|
|
191
|
-
});
|
|
192
|
-
if (policy.limit_action === "fail") {
|
|
193
|
-
// The documented FAIL action fails (release wave tier1 #4): a FRESH breach
|
|
194
|
-
// under fail refuses before spawn with the evidence, instead of silently
|
|
195
|
-
// proceeding into a vendor rejection.
|
|
196
|
-
throw new Error(`credential profile "${profile.profile_id}" (${harnessId}) is over its headroom threshold ` +
|
|
197
|
-
`(${breach.constraint_id} at ${Math.round(breach.used_ratio * 100)}% >= ${Math.round(breach.threshold * 100)}%; ` +
|
|
198
|
-
`limit_action=fail${breach.resets_at ? `; resets ${breach.resets_at}` : ""})`);
|
|
199
|
-
}
|
|
200
|
-
if (policy.limit_action !== "rotate")
|
|
201
|
-
return profile;
|
|
202
|
-
const next = nextEligibleProfile(registry, harnessId, policy, profile, snapshots);
|
|
203
|
-
if (!next) {
|
|
204
|
-
emitRotationExhausted({
|
|
205
|
-
current: profile,
|
|
206
|
-
harnessId,
|
|
207
|
-
policy,
|
|
208
|
-
registry,
|
|
209
|
-
snapshots,
|
|
210
|
-
reason: "profile_headroom_preflight",
|
|
211
|
-
emit,
|
|
212
|
-
});
|
|
213
|
-
return profile;
|
|
214
|
-
}
|
|
215
|
-
emit("route.profile.rotated", {
|
|
216
|
-
harness_id: harnessId,
|
|
217
|
-
from_profile_id: profile.profile_id,
|
|
218
|
-
to_profile_id: next.profile_id,
|
|
219
|
-
reason: "profile_headroom_preflight",
|
|
220
|
-
constraint_id: breach.constraint_id,
|
|
221
|
-
used_ratio: breach.used_ratio,
|
|
222
|
-
resets_at: breach.resets_at,
|
|
223
|
-
});
|
|
224
|
-
return next;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Default-subject start selection (INV-135, owner scope "auto-balance"): when
|
|
228
|
-
* NO profile is pinned, the policy is `rotate`, and the DEFAULT store's own
|
|
229
|
-
* fresh quota window is at/over the headroom bound, pick the first eligible
|
|
230
|
-
* SUBSCRIPTION profile instead of spawning into a near-certain vendor limit.
|
|
231
|
-
* Strictly opt-in: `fail`/`ask` keep today's default-user behavior untouched
|
|
232
|
-
* (the profile engine's fail action governs PINNED profiles only — throwing
|
|
233
|
-
* here would brick every default user at 90% quota). Unknown or stale usage
|
|
234
|
-
* never rotates.
|
|
235
|
-
*/
|
|
236
|
-
export function preflightDefaultSubject(args) {
|
|
237
|
-
const { harnessId, policy, registry, snapshots, emit } = args;
|
|
238
|
-
if (policy.limit_action !== "rotate")
|
|
239
|
-
return null;
|
|
240
|
-
const breach = profileHeadroomBreach(snapshots, harnessId, null, policy.headroom_threshold);
|
|
241
|
-
if (!breach)
|
|
242
|
-
return null;
|
|
243
|
-
emit("route.profile.headroom_exceeded", {
|
|
244
|
-
harness_id: harnessId,
|
|
245
|
-
profile_id: null,
|
|
246
|
-
action: policy.limit_action,
|
|
247
|
-
constraint_id: breach.constraint_id,
|
|
248
|
-
used_ratio: breach.used_ratio,
|
|
249
|
-
threshold: breach.threshold,
|
|
250
|
-
resets_at: breach.resets_at,
|
|
251
|
-
});
|
|
252
|
-
const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots);
|
|
253
|
-
if (!next) {
|
|
254
|
-
emitRotationExhausted({
|
|
255
|
-
current: null,
|
|
256
|
-
harnessId,
|
|
257
|
-
policy,
|
|
258
|
-
registry,
|
|
259
|
-
snapshots,
|
|
260
|
-
reason: "profile_headroom_preflight",
|
|
261
|
-
emit,
|
|
262
|
-
});
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
emit("route.profile.rotated", {
|
|
266
|
-
harness_id: harnessId,
|
|
267
|
-
from_profile_id: null,
|
|
268
|
-
to_profile_id: next.profile_id,
|
|
269
|
-
reason: "profile_headroom_preflight",
|
|
270
|
-
constraint_id: breach.constraint_id,
|
|
271
|
-
used_ratio: breach.used_ratio,
|
|
272
|
-
resets_at: breach.resets_at,
|
|
273
|
-
});
|
|
274
|
-
return next;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Reactive failover plan (`vendor_limit_rejected`, W5.4): rotation fires ONLY
|
|
278
|
-
* on the typed predicate under a `rotate` policy, marks the current profile
|
|
279
|
-
* tried (at most once per attempt each), and returns the next target with
|
|
280
|
-
* provenance already emitted — or null when the attempt must fail as-is.
|
|
281
|
-
* `currentProfile: null` is the DEFAULT subject: allowed ONLY when the caller
|
|
282
|
-
* proves the attempt's pre-spawn route was vendor_native (a metered default
|
|
283
|
-
* hitting a limit is a budget fact, not a subscription to fail over from).
|
|
284
|
-
*/
|
|
285
|
-
export function planReactiveRotation(args) {
|
|
286
|
-
if (!rotationRetryEligible(args))
|
|
287
|
-
return null;
|
|
288
|
-
if (args.policy.limit_action !== "rotate")
|
|
289
|
-
return null;
|
|
290
|
-
if (args.currentProfile === null && args.defaultRouteWasVendorNative !== true)
|
|
291
|
-
return null;
|
|
292
|
-
if (args.currentProfile)
|
|
293
|
-
args.triedProfiles.add(args.currentProfile.profile_id);
|
|
294
|
-
const next = nextEligibleProfile(args.registry, args.harnessId, args.policy, args.currentProfile, args.snapshots, args.triedProfiles);
|
|
295
|
-
if (!next) {
|
|
296
|
-
emitRotationExhausted({
|
|
297
|
-
current: args.currentProfile,
|
|
298
|
-
harnessId: args.harnessId,
|
|
299
|
-
policy: args.policy,
|
|
300
|
-
registry: args.registry,
|
|
301
|
-
snapshots: args.snapshots,
|
|
302
|
-
excluded: args.triedProfiles,
|
|
303
|
-
attemptId: args.attemptId,
|
|
304
|
-
reason: "vendor_limit_rejected",
|
|
305
|
-
emit: args.emit,
|
|
306
|
-
});
|
|
307
|
-
return null;
|
|
308
124
|
}
|
|
309
|
-
|
|
310
|
-
harness_id: args.harnessId,
|
|
311
|
-
attempt_id: args.attemptId,
|
|
312
|
-
from_profile_id: args.currentProfile?.profile_id ?? null,
|
|
313
|
-
to_profile_id: next.profile_id,
|
|
314
|
-
reason: "vendor_limit_rejected",
|
|
315
|
-
retry_delay_ms: args.lastLimit?.retryDelayMs ?? null,
|
|
316
|
-
resets_at: args.lastLimit?.resetsAt ?? null,
|
|
317
|
-
});
|
|
318
|
-
return next;
|
|
125
|
+
return { kind: "native", route: defaultRoute };
|
|
319
126
|
}
|
|
320
127
|
/**
|
|
321
128
|
* INV-135 at the engine boundary: a cached vendor session resumes ONLY under
|
|
@@ -346,33 +153,4 @@ export function observeNativeSessionEvent(input, harnessId, ev) {
|
|
|
346
153
|
}
|
|
347
154
|
}
|
|
348
155
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Shared reactive-failover step for BOTH lanes: given the attempt's typed
|
|
351
|
-
* evidence, plan a rotation and rebuild the spec on a NEW vendor session
|
|
352
|
-
* under the next profile — or return null when the attempt must fail as-is.
|
|
353
|
-
*/
|
|
354
|
-
export function rotateSpecOnTypedLimit(args) {
|
|
355
|
-
const rotation = planReactiveRotation({
|
|
356
|
-
currentProfile: args.spec.credential_profile ?? null,
|
|
357
|
-
defaultRouteWasVendorNative: args.defaultRouteWasVendorNative,
|
|
358
|
-
harnessId: args.harnessId,
|
|
359
|
-
attemptId: args.attemptId,
|
|
360
|
-
policy: args.policy,
|
|
361
|
-
registry: args.registry,
|
|
362
|
-
snapshots: args.snapshots,
|
|
363
|
-
triedProfiles: args.triedProfiles,
|
|
364
|
-
sawTypedLimit: args.sawTypedLimit,
|
|
365
|
-
deliverableEmpty: args.deliverableEmpty,
|
|
366
|
-
lastLimit: args.lastLimit,
|
|
367
|
-
emit: args.emit,
|
|
368
|
-
});
|
|
369
|
-
if (!rotation)
|
|
370
|
-
return null;
|
|
371
|
-
return HarnessRunSpecSchema.parse({
|
|
372
|
-
...args.spec,
|
|
373
|
-
session_id: args.newSessionId(),
|
|
374
|
-
credential_profile: rotation,
|
|
375
|
-
resume_session_id: null,
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
156
|
//# sourceMappingURL=credential-profiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-profiles.js","sourceRoot":"","sources":["../src/credential-profiles.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAsC,EACtC,MAAc,EACd,SAAiB;IAEjB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC;IAC1F,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,o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AAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,KASa,EACb,SAAiB,EACjB,EAAgB;IAEhB,IAAI,CAAC,KAAK,EAAE,iBAAiB,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/D,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,mBAAmB,CAAC,CAAC;IAC9C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC;YACH,KAAK,CAAC,iBAAiB,CACrB,SAAS,EACT,GAAG,EACH,EAAE,CAAC,cAAc,IAAI,IAAI,EACzB,EAAE,CAAC,qBAAqB,IAAI,IAAI,CACjC,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,6CAA6C;QAC/C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ArtifactStore } from "@claudexor/artifact-store";
|
|
2
|
+
import type { BudgetLedger } from "@claudexor/budget";
|
|
3
|
+
import { type RunOutcomeFacts } from "@claudexor/schema";
|
|
4
|
+
export interface SettledBudgetSnapshot {
|
|
5
|
+
spendUsd: number | null;
|
|
6
|
+
valuationUsd: number | null;
|
|
7
|
+
estimated: boolean;
|
|
8
|
+
valuationKnowledge: "exact" | "estimated" | "unknown";
|
|
9
|
+
}
|
|
10
|
+
interface BudgetSnapshotSource {
|
|
11
|
+
spend?: () => number;
|
|
12
|
+
valuation?: () => number;
|
|
13
|
+
spendEstimated?: () => boolean;
|
|
14
|
+
valuationKnowledge?: () => "exact" | "estimated" | "unknown";
|
|
15
|
+
}
|
|
16
|
+
export declare function settledBudgetSnapshot(source: BudgetSnapshotSource): SettledBudgetSnapshot;
|
|
17
|
+
/** Reconcile a Delegate family's post-drain cash/valuation truth without
|
|
18
|
+
* stripping forward-compatible decision extensions. */
|
|
19
|
+
export declare function reconcileDecisionBudget(context: {
|
|
20
|
+
store: ArtifactStore;
|
|
21
|
+
paths: {
|
|
22
|
+
arbitrationDir: string;
|
|
23
|
+
};
|
|
24
|
+
}, budget: SettledBudgetSnapshot, terminal?: {
|
|
25
|
+
facts: RunOutcomeFacts;
|
|
26
|
+
why: string;
|
|
27
|
+
}): void;
|
|
28
|
+
export declare function decisionBudgetSummary(ledger: BudgetLedger): {
|
|
29
|
+
readonly spend_usd: number;
|
|
30
|
+
readonly estimated: boolean;
|
|
31
|
+
readonly cash_usd: number;
|
|
32
|
+
readonly valuation_usd: number;
|
|
33
|
+
readonly valuation_knowledge: "estimated" | "exact" | "unknown";
|
|
34
|
+
};
|
|
35
|
+
export declare function arbitrationBudgetOptions(ledger: BudgetLedger): {
|
|
36
|
+
readonly spendUsd: number;
|
|
37
|
+
readonly estimatedSpend: boolean;
|
|
38
|
+
readonly cashUsd: number;
|
|
39
|
+
readonly valuationUsd: number;
|
|
40
|
+
readonly valuationKnowledge: "estimated" | "exact" | "unknown";
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=decisionBudget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionBudget.d.ts","sourceRoot":"","sources":["../src/decisionBudget.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;CACvD;AAED,UAAU,oBAAoB;IAC5B,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;CAC9D;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,qBAAqB,CA2BzF;AAED;uDACuD;AACvD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACpE,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CA6BN;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY;aAEtD,SAAS;aACT,SAAS;aACT,QAAQ;aACR,aAAa;aACb,mBAAmB;EAEtB;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY;aAEzD,QAAQ;aACR,cAAc;aACd,OAAO;aACP,YAAY;aACZ,kBAAkB;EAErB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { DecisionRecord } from "@claudexor/schema";
|
|
3
|
+
export function settledBudgetSnapshot(source) {
|
|
4
|
+
const read = (value) => {
|
|
5
|
+
try {
|
|
6
|
+
const result = value?.();
|
|
7
|
+
return typeof result === "number" && Number.isFinite(result) ? result : null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
let estimated = false;
|
|
14
|
+
let valuationKnowledge = "unknown";
|
|
15
|
+
try {
|
|
16
|
+
estimated = source.spendEstimated?.() === true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
estimated = true;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
valuationKnowledge = source.valuationKnowledge?.() ?? "unknown";
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
valuationKnowledge = "unknown";
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
spendUsd: read(source.spend),
|
|
29
|
+
valuationUsd: read(source.valuation),
|
|
30
|
+
estimated,
|
|
31
|
+
valuationKnowledge,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Reconcile a Delegate family's post-drain cash/valuation truth without
|
|
35
|
+
* stripping forward-compatible decision extensions. */
|
|
36
|
+
export function reconcileDecisionBudget(context, budget, terminal) {
|
|
37
|
+
const path = join(context.paths.arbitrationDir, "decision.yaml");
|
|
38
|
+
const current = context.store.readYaml(path);
|
|
39
|
+
if (!current || typeof current !== "object" || Array.isArray(current))
|
|
40
|
+
return;
|
|
41
|
+
const record = current;
|
|
42
|
+
const priorBudget = record["budget_summary"] && typeof record["budget_summary"] === "object"
|
|
43
|
+
? record["budget_summary"]
|
|
44
|
+
: {};
|
|
45
|
+
const reconciled = {
|
|
46
|
+
...record,
|
|
47
|
+
...(terminal
|
|
48
|
+
? {
|
|
49
|
+
facts: terminal.facts,
|
|
50
|
+
why_winner: terminal.why,
|
|
51
|
+
apply_recommendation: "continue",
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
budget_summary: {
|
|
55
|
+
...priorBudget,
|
|
56
|
+
spend_usd: budget.spendUsd,
|
|
57
|
+
cash_usd: budget.spendUsd,
|
|
58
|
+
valuation_usd: budget.valuationUsd,
|
|
59
|
+
estimated: budget.estimated,
|
|
60
|
+
valuation_knowledge: budget.valuationKnowledge,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
DecisionRecord.parse(reconciled);
|
|
64
|
+
context.store.writeYaml(path, reconciled);
|
|
65
|
+
}
|
|
66
|
+
export function decisionBudgetSummary(ledger) {
|
|
67
|
+
return {
|
|
68
|
+
spend_usd: ledger.spend(),
|
|
69
|
+
estimated: ledger.estimated(),
|
|
70
|
+
cash_usd: ledger.spend(),
|
|
71
|
+
valuation_usd: ledger.valuation(),
|
|
72
|
+
valuation_knowledge: ledger.valuationKnowledge(),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function arbitrationBudgetOptions(ledger) {
|
|
76
|
+
return {
|
|
77
|
+
spendUsd: ledger.spend(),
|
|
78
|
+
estimatedSpend: ledger.estimated(),
|
|
79
|
+
cashUsd: ledger.spend(),
|
|
80
|
+
valuationUsd: ledger.valuation(),
|
|
81
|
+
valuationKnowledge: ledger.valuationKnowledge(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=decisionBudget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionBudget.js","sourceRoot":"","sources":["../src/decisionBudget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AAgBzE,MAAM,UAAU,qBAAqB,CAAC,MAA4B;IAChE,MAAM,IAAI,GAAG,CAAC,KAAiC,EAAiB,EAAE;QAChE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,CAAC;YACzB,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IACF,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,kBAAkB,GAAsC,SAAS,CAAC;IACtE,IAAI,CAAC;QACH,SAAS,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,KAAK,IAAI,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,SAAS,GAAG,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EAAE,MAAM,CAAC,QAAQ;YACzB,aAAa,EAAE,MAAM,CAAC,YAAY;YAClC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,mBAAmB,EAAE,MAAM,CAAC,kBAAkB;SAC/C;KACF,CAAC;IACF,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;QAC7B,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;QACxB,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE;QACjC,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE;KACxC,CAAC;AACb,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,MAAoB;IAC3D,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;QACxB,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE;QAClC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE;QACvB,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE;QAChC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE;KACvC,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ArtifactStore } from "@claudexor/artifact-store";
|
|
2
|
+
import { type RunOutcomeFacts } from "@claudexor/schema";
|
|
3
|
+
/** The terminal guard owns only the terminal truth of an already-valid
|
|
4
|
+
* decision. Ordinary strategies own their winner, review/check evidence,
|
|
5
|
+
* budget, and recommendation; an escaped failure/cancel must not rewrite
|
|
6
|
+
* those fields, but leaving a succeeded decision beside a failed lifecycle
|
|
7
|
+
* would make Control project contradictory outcome facts. */
|
|
8
|
+
export declare function reconcileDecisionTerminal(context: {
|
|
9
|
+
store: ArtifactStore;
|
|
10
|
+
paths: {
|
|
11
|
+
arbitrationDir: string;
|
|
12
|
+
};
|
|
13
|
+
}, terminal: {
|
|
14
|
+
facts: RunOutcomeFacts;
|
|
15
|
+
why: string;
|
|
16
|
+
preparedFacts?: RunOutcomeFacts;
|
|
17
|
+
}): RunOutcomeFacts;
|
|
18
|
+
//# sourceMappingURL=decisionTerminalReconciliation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionTerminalReconciliation.d.ts","sourceRoot":"","sources":["../src/decisionTerminalReconciliation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzE;;;;6DAI6D;AAC7D,wBAAgB,yBAAyB,CACvC,OAAO,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACpE,QAAQ,EAAE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,eAAe,CAAA;CAAE,GACjF,eAAe,CAoBjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { DecisionRecord } from "@claudexor/schema";
|
|
3
|
+
import { terminalOutcomeFacts } from "./terminalOutcome.js";
|
|
4
|
+
/** The terminal guard owns only the terminal truth of an already-valid
|
|
5
|
+
* decision. Ordinary strategies own their winner, review/check evidence,
|
|
6
|
+
* budget, and recommendation; an escaped failure/cancel must not rewrite
|
|
7
|
+
* those fields, but leaving a succeeded decision beside a failed lifecycle
|
|
8
|
+
* would make Control project contradictory outcome facts. */
|
|
9
|
+
export function reconcileDecisionTerminal(context, terminal) {
|
|
10
|
+
const path = join(context.paths.arbitrationDir, "decision.yaml");
|
|
11
|
+
const current = context.store.readYaml(path);
|
|
12
|
+
const parsed = DecisionRecord.safeParse(current);
|
|
13
|
+
if (!parsed.success || !current || typeof current !== "object" || Array.isArray(current)) {
|
|
14
|
+
return terminal.facts;
|
|
15
|
+
}
|
|
16
|
+
const facts = terminalOutcomeFacts(terminal.preparedFacts ?? parsed.data.facts, terminal.facts.lifecycle, terminal.facts.reason);
|
|
17
|
+
const reconciled = {
|
|
18
|
+
...current,
|
|
19
|
+
facts,
|
|
20
|
+
why_winner: terminal.why,
|
|
21
|
+
};
|
|
22
|
+
DecisionRecord.parse(reconciled);
|
|
23
|
+
context.store.writeYaml(path, reconciled);
|
|
24
|
+
return facts;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=decisionTerminalReconciliation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionTerminalReconciliation.js","sourceRoot":"","sources":["../src/decisionTerminalReconciliation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;;6DAI6D;AAC7D,MAAM,UAAU,yBAAyB,CACvC,OAAoE,EACpE,QAAkF;IAElF,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAU,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzF,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IACD,MAAM,KAAK,GAAG,oBAAoB,CAChC,QAAQ,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAC3C,QAAQ,CAAC,KAAK,CAAC,SAAS,EACxB,QAAQ,CAAC,KAAK,CAAC,MAAM,CACtB,CAAC;IACF,MAAM,UAAU,GAAG;QACjB,GAAI,OAAmC;QACvC,KAAK;QACL,UAAU,EAAE,QAAQ,CAAC,GAAG;KACzB,CAAC;IACF,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC"}
|