@claudexor/orchestrator 1.0.1 → 2.1.2
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/attemptTelemetry.d.ts +38 -2
- package/dist/attemptTelemetry.d.ts.map +1 -1
- package/dist/attemptTelemetry.js +75 -2
- package/dist/attemptTelemetry.js.map +1 -1
- package/dist/contract-gates.d.ts +21 -0
- package/dist/contract-gates.d.ts.map +1 -0
- package/dist/contract-gates.js +93 -0
- package/dist/contract-gates.js.map +1 -0
- package/dist/credential-profiles.d.ts +152 -0
- package/dist/credential-profiles.d.ts.map +1 -0
- package/dist/credential-profiles.js +270 -0
- package/dist/credential-profiles.js.map +1 -0
- package/dist/diffReview.d.ts +9 -1
- package/dist/diffReview.d.ts.map +1 -1
- package/dist/diffReview.js +114 -18
- package/dist/diffReview.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modelGovernance.d.ts +6 -1
- package/dist/modelGovernance.d.ts.map +1 -1
- package/dist/modelGovernance.js +8 -2
- package/dist/modelGovernance.js.map +1 -1
- package/dist/orchestrateExecutor.d.ts +43 -0
- package/dist/orchestrateExecutor.d.ts.map +1 -0
- package/dist/orchestrateExecutor.js +207 -0
- package/dist/orchestrateExecutor.js.map +1 -0
- package/dist/orchestratePlanner.d.ts.map +1 -1
- package/dist/orchestratePlanner.js.map +1 -1
- package/dist/orchestrator.d.ts +100 -83
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +1008 -993
- package/dist/orchestrator.js.map +1 -1
- package/dist/outcomeReducer.d.ts +25 -0
- package/dist/outcomeReducer.d.ts.map +1 -0
- package/dist/outcomeReducer.js +121 -0
- package/dist/outcomeReducer.js.map +1 -0
- package/dist/policyFindings.d.ts +18 -0
- package/dist/policyFindings.d.ts.map +1 -0
- package/dist/policyFindings.js +166 -0
- package/dist/policyFindings.js.map +1 -0
- package/dist/requestRequirements.d.ts +38 -0
- package/dist/requestRequirements.d.ts.map +1 -0
- package/dist/requestRequirements.js +127 -0
- package/dist/requestRequirements.js.map +1 -0
- package/dist/reviewerPanel.d.ts +15 -1
- package/dist/reviewerPanel.d.ts.map +1 -1
- package/dist/reviewerPanel.js +85 -2
- package/dist/reviewerPanel.js.map +1 -1
- package/dist/routeContext.d.ts +37 -0
- package/dist/routeContext.d.ts.map +1 -0
- package/dist/routeContext.js +38 -0
- package/dist/routeContext.js.map +1 -0
- package/dist/runSupport.d.ts +37 -21
- package/dist/runSupport.d.ts.map +1 -1
- package/dist/runSupport.js +102 -78
- package/dist/runSupport.js.map +1 -1
- package/dist/runTelemetryWriter.d.ts +20 -0
- package/dist/runTelemetryWriter.d.ts.map +1 -0
- package/dist/runTelemetryWriter.js +68 -0
- package/dist/runTelemetryWriter.js.map +1 -0
- package/dist/runTerminals.d.ts +7 -1
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +42 -4
- package/dist/runTerminals.js.map +1 -1
- package/dist/structuredOutput.d.ts +33 -0
- package/dist/structuredOutput.d.ts.map +1 -0
- package/dist/structuredOutput.js +106 -0
- package/dist/structuredOutput.js.map +1 -0
- package/package.json +19 -18
- package/dist/finalVerifier.d.ts +0 -25
- package/dist/finalVerifier.d.ts.map +0 -1
- package/dist/finalVerifier.js +0 -110
- package/dist/finalVerifier.js.map +0 -1
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { HarnessRunSpec as HarnessRunSpecSchema } from "@claudexor/schema";
|
|
2
|
+
/**
|
|
3
|
+
* The ONE resolve owner for credential profiles (INV-135): explicit id →
|
|
4
|
+
* durable registry entry for exactly this harness. Unknown, disabled, or
|
|
5
|
+
* harness-mismatched ids throw a typed refusal — an explicit profile must
|
|
6
|
+
* never silently become the default credential ladder.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveCredentialProfile(registry, wanted, harnessId) {
|
|
9
|
+
const match = registry.find((p) => p.profile_id === wanted && p.harness_id === harnessId);
|
|
10
|
+
if (!match) {
|
|
11
|
+
throw new Error(`credential profile "${wanted}" is not registered for harness "${harnessId}"`);
|
|
12
|
+
}
|
|
13
|
+
if (!match.enabled) {
|
|
14
|
+
throw new Error(`credential profile "${wanted}" (${harnessId}) is disabled`);
|
|
15
|
+
}
|
|
16
|
+
return match;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Proactive headroom check (W5.4 `profile_headroom_preflight`): the SELECTED
|
|
20
|
+
* profile's freshest snapshot windows against the policy threshold. Unknown
|
|
21
|
+
* usage is NOT a breach — rotation never triggers on missing data.
|
|
22
|
+
*/
|
|
23
|
+
export function profileHeadroomBreach(snapshots, harnessId, profileId, threshold) {
|
|
24
|
+
for (const snapshot of snapshots) {
|
|
25
|
+
// FRESH evidence only (release wave tier1 #3): a stale or unknown reading
|
|
26
|
+
// must never breach headroom, rotate a profile away, or fail selection.
|
|
27
|
+
if (snapshot.freshness !== "fresh")
|
|
28
|
+
continue;
|
|
29
|
+
if (snapshot.subject.harness !== harnessId)
|
|
30
|
+
continue;
|
|
31
|
+
if ((snapshot.subject.subject_id ?? null) !== profileId)
|
|
32
|
+
continue;
|
|
33
|
+
for (const constraint of snapshot.constraints) {
|
|
34
|
+
if (constraint.used_ratio !== null && constraint.used_ratio >= threshold) {
|
|
35
|
+
return {
|
|
36
|
+
constraint_id: constraint.id,
|
|
37
|
+
used_ratio: constraint.used_ratio,
|
|
38
|
+
threshold,
|
|
39
|
+
resets_at: constraint.resets_at,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The next rotation target after `currentProfileId` (W5.4): policy order wins
|
|
48
|
+
* (`rotation_eligible`), else every enabled profile of the harness in registry
|
|
49
|
+
* order. The current profile and disabled/unknown ids never come back; a
|
|
50
|
+
* profile already over the headroom bound is skipped (rotating INTO a spent
|
|
51
|
+
* subscription is not a failover). Cross-subscription rotation of one vendor
|
|
52
|
+
* is allowed by owner decision — but rotation NEVER crosses credential kinds
|
|
53
|
+
* (release wave round-16 BLOCK): a subscription→API-key swap silently changes
|
|
54
|
+
* the payment model mid-attempt, and the attempt's first-wins auth-route
|
|
55
|
+
* receipt (decided once before spawn) would misvalue metered usage as
|
|
56
|
+
* subscription entitlement, bypassing a finite cash cap.
|
|
57
|
+
*/
|
|
58
|
+
export function nextEligibleProfile(registry, harnessId, policy, current, snapshots, excluded = new Set()) {
|
|
59
|
+
const pool = registry.filter((p) => p.harness_id === harnessId && p.enabled);
|
|
60
|
+
const ordered = policy.rotation_eligible.length > 0
|
|
61
|
+
? policy.rotation_eligible
|
|
62
|
+
.map((id) => pool.find((p) => p.profile_id === id))
|
|
63
|
+
.filter((p) => p !== undefined)
|
|
64
|
+
: pool;
|
|
65
|
+
for (const candidate of ordered) {
|
|
66
|
+
if (candidate.profile_id === current?.profile_id)
|
|
67
|
+
continue;
|
|
68
|
+
if (excluded.has(candidate.profile_id))
|
|
69
|
+
continue;
|
|
70
|
+
// Fail-CLOSED kind guard (round-17 hardening of the round-16 BLOCK): the
|
|
71
|
+
// kind comes from the TYPED current profile in hand — never re-found in
|
|
72
|
+
// a freshly reloaded pool, where a mid-flight disable/remove of the
|
|
73
|
+
// current profile would have silently dropped the cross-kind prohibition.
|
|
74
|
+
if (current !== null && candidate.credential_kind !== current.credential_kind)
|
|
75
|
+
continue;
|
|
76
|
+
// `current === null` is the DEFAULT subject (the vendor-native store): the
|
|
77
|
+
// same round-16 BLOCK applies — rotating the subscription default INTO an
|
|
78
|
+
// api_key profile would silently change the payment model mid-attempt.
|
|
79
|
+
if (current === null && candidate.credential_kind === "api_key")
|
|
80
|
+
continue;
|
|
81
|
+
if (profileHeadroomBreach(snapshots, harnessId, candidate.profile_id, policy.headroom_threshold))
|
|
82
|
+
continue;
|
|
83
|
+
return candidate;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `rotation_retry_eligible` (sol #30): a failover retry is allowed ONLY when
|
|
89
|
+
* the attempt saw a TYPED vendor limit AND produced no deliverable and no
|
|
90
|
+
* workspace mutation — a partially-acted attempt never silently reruns.
|
|
91
|
+
*/
|
|
92
|
+
export function rotationRetryEligible(input) {
|
|
93
|
+
return input.sawTypedLimit && input.deliverableEmpty;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `profile_headroom_preflight` (W5.4): BEFORE spawn, the selected profile's
|
|
97
|
+
* freshest quota windows are checked against the policy threshold. A breach
|
|
98
|
+
* is always a typed event; `rotate` swaps to the next eligible profile with
|
|
99
|
+
* provenance, `ask`/`fail` proceed on the selected profile — the runtime
|
|
100
|
+
* `vendor_limit_rejected` evidence stays the terminating truth.
|
|
101
|
+
*/
|
|
102
|
+
export function preflightCredentialProfile(args) {
|
|
103
|
+
const { profile, harnessId, policy, registry, snapshots, emit } = args;
|
|
104
|
+
const breach = profileHeadroomBreach(snapshots, harnessId, profile.profile_id, policy.headroom_threshold);
|
|
105
|
+
if (!breach)
|
|
106
|
+
return profile;
|
|
107
|
+
emit("route.profile.headroom_exceeded", {
|
|
108
|
+
harness_id: harnessId,
|
|
109
|
+
profile_id: profile.profile_id,
|
|
110
|
+
action: policy.limit_action,
|
|
111
|
+
constraint_id: breach.constraint_id,
|
|
112
|
+
used_ratio: breach.used_ratio,
|
|
113
|
+
threshold: breach.threshold,
|
|
114
|
+
resets_at: breach.resets_at,
|
|
115
|
+
});
|
|
116
|
+
if (policy.limit_action === "fail") {
|
|
117
|
+
// The documented FAIL action fails (release wave tier1 #4): a FRESH breach
|
|
118
|
+
// under fail refuses before spawn with the evidence, instead of silently
|
|
119
|
+
// proceeding into a vendor rejection.
|
|
120
|
+
throw new Error(`credential profile "${profile.profile_id}" (${harnessId}) is over its headroom threshold ` +
|
|
121
|
+
`(${breach.constraint_id} at ${Math.round(breach.used_ratio * 100)}% >= ${Math.round(breach.threshold * 100)}%; ` +
|
|
122
|
+
`limit_action=fail${breach.resets_at ? `; resets ${breach.resets_at}` : ""})`);
|
|
123
|
+
}
|
|
124
|
+
if (policy.limit_action !== "rotate")
|
|
125
|
+
return profile;
|
|
126
|
+
const next = nextEligibleProfile(registry, harnessId, policy, profile, snapshots);
|
|
127
|
+
if (!next)
|
|
128
|
+
return profile;
|
|
129
|
+
emit("route.profile.rotated", {
|
|
130
|
+
harness_id: harnessId,
|
|
131
|
+
from_profile_id: profile.profile_id,
|
|
132
|
+
to_profile_id: next.profile_id,
|
|
133
|
+
reason: "profile_headroom_preflight",
|
|
134
|
+
constraint_id: breach.constraint_id,
|
|
135
|
+
used_ratio: breach.used_ratio,
|
|
136
|
+
resets_at: breach.resets_at,
|
|
137
|
+
});
|
|
138
|
+
return next;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Default-subject start selection (INV-135, owner scope "auto-balance"): when
|
|
142
|
+
* NO profile is pinned, the policy is `rotate`, and the DEFAULT store's own
|
|
143
|
+
* fresh quota window is at/over the headroom bound, pick the first eligible
|
|
144
|
+
* SUBSCRIPTION profile instead of spawning into a near-certain vendor limit.
|
|
145
|
+
* Strictly opt-in: `fail`/`ask` keep today's default-user behavior untouched
|
|
146
|
+
* (the profile engine's fail action governs PINNED profiles only — throwing
|
|
147
|
+
* here would brick every default user at 90% quota). Unknown or stale usage
|
|
148
|
+
* never rotates.
|
|
149
|
+
*/
|
|
150
|
+
export function preflightDefaultSubject(args) {
|
|
151
|
+
const { harnessId, policy, registry, snapshots, emit } = args;
|
|
152
|
+
if (policy.limit_action !== "rotate")
|
|
153
|
+
return null;
|
|
154
|
+
const breach = profileHeadroomBreach(snapshots, harnessId, null, policy.headroom_threshold);
|
|
155
|
+
if (!breach)
|
|
156
|
+
return null;
|
|
157
|
+
emit("route.profile.headroom_exceeded", {
|
|
158
|
+
harness_id: harnessId,
|
|
159
|
+
profile_id: null,
|
|
160
|
+
action: policy.limit_action,
|
|
161
|
+
constraint_id: breach.constraint_id,
|
|
162
|
+
used_ratio: breach.used_ratio,
|
|
163
|
+
threshold: breach.threshold,
|
|
164
|
+
resets_at: breach.resets_at,
|
|
165
|
+
});
|
|
166
|
+
const next = nextEligibleProfile(registry, harnessId, policy, null, snapshots);
|
|
167
|
+
if (!next)
|
|
168
|
+
return null;
|
|
169
|
+
emit("route.profile.rotated", {
|
|
170
|
+
harness_id: harnessId,
|
|
171
|
+
from_profile_id: null,
|
|
172
|
+
to_profile_id: next.profile_id,
|
|
173
|
+
reason: "profile_headroom_preflight",
|
|
174
|
+
constraint_id: breach.constraint_id,
|
|
175
|
+
used_ratio: breach.used_ratio,
|
|
176
|
+
resets_at: breach.resets_at,
|
|
177
|
+
});
|
|
178
|
+
return next;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reactive failover plan (`vendor_limit_rejected`, W5.4): rotation fires ONLY
|
|
182
|
+
* on the typed predicate under a `rotate` policy, marks the current profile
|
|
183
|
+
* tried (at most once per attempt each), and returns the next target with
|
|
184
|
+
* provenance already emitted — or null when the attempt must fail as-is.
|
|
185
|
+
* `currentProfile: null` is the DEFAULT subject: allowed ONLY when the caller
|
|
186
|
+
* proves the attempt's pre-spawn route was vendor_native (a metered default
|
|
187
|
+
* hitting a limit is a budget fact, not a subscription to fail over from).
|
|
188
|
+
*/
|
|
189
|
+
export function planReactiveRotation(args) {
|
|
190
|
+
if (!rotationRetryEligible(args))
|
|
191
|
+
return null;
|
|
192
|
+
if (args.policy.limit_action !== "rotate")
|
|
193
|
+
return null;
|
|
194
|
+
if (args.currentProfile === null && args.defaultRouteWasVendorNative !== true)
|
|
195
|
+
return null;
|
|
196
|
+
if (args.currentProfile)
|
|
197
|
+
args.triedProfiles.add(args.currentProfile.profile_id);
|
|
198
|
+
const next = nextEligibleProfile(args.registry, args.harnessId, args.policy, args.currentProfile, args.snapshots, args.triedProfiles);
|
|
199
|
+
if (!next)
|
|
200
|
+
return null;
|
|
201
|
+
args.emit("route.profile.rotated", {
|
|
202
|
+
harness_id: args.harnessId,
|
|
203
|
+
attempt_id: args.attemptId,
|
|
204
|
+
from_profile_id: args.currentProfile?.profile_id ?? null,
|
|
205
|
+
to_profile_id: next.profile_id,
|
|
206
|
+
reason: "vendor_limit_rejected",
|
|
207
|
+
retry_delay_ms: args.lastLimit?.retryDelayMs ?? null,
|
|
208
|
+
resets_at: args.lastLimit?.resetsAt ?? null,
|
|
209
|
+
});
|
|
210
|
+
return next;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* INV-135 at the engine boundary: a cached vendor session resumes ONLY under
|
|
214
|
+
* exactly the profile it was recorded with (null-default equality included) —
|
|
215
|
+
* regardless of what the caller's map claims. Preflight rotation changing the
|
|
216
|
+
* profile therefore starts fresh.
|
|
217
|
+
*/
|
|
218
|
+
export function resumeSessionForProfile(cached, profile) {
|
|
219
|
+
if (!cached)
|
|
220
|
+
return null;
|
|
221
|
+
return (cached.profileId ?? null) === (profile?.profile_id ?? null) ? cached.sessionId : null;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Record a harness-emitted native session id for future thread resume; the
|
|
225
|
+
* observer never fails the run. profileId is the adapter's per-event stamp —
|
|
226
|
+
* the EFFECTIVE profile (rotation makes it differ from the requested id).
|
|
227
|
+
*/
|
|
228
|
+
export function observeNativeSessionEvent(input, harnessId, ev) {
|
|
229
|
+
if (!input?.onSessionObserved || ev.type !== "started")
|
|
230
|
+
return;
|
|
231
|
+
const nid = ev.payload?.["native_session_id"];
|
|
232
|
+
if (typeof nid === "string" && nid.length > 0) {
|
|
233
|
+
try {
|
|
234
|
+
input.onSessionObserved(harnessId, nid, ev.observed_model ?? null, ev.credential_profile_id ?? null);
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
/* observer errors must never fail the run */
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Shared reactive-failover step for BOTH lanes: given the attempt's typed
|
|
243
|
+
* evidence, plan a rotation and rebuild the spec on a NEW vendor session
|
|
244
|
+
* under the next profile — or return null when the attempt must fail as-is.
|
|
245
|
+
*/
|
|
246
|
+
export function rotateSpecOnTypedLimit(args) {
|
|
247
|
+
const rotation = planReactiveRotation({
|
|
248
|
+
currentProfile: args.spec.credential_profile ?? null,
|
|
249
|
+
defaultRouteWasVendorNative: args.defaultRouteWasVendorNative,
|
|
250
|
+
harnessId: args.harnessId,
|
|
251
|
+
attemptId: args.attemptId,
|
|
252
|
+
policy: args.policy,
|
|
253
|
+
registry: args.registry,
|
|
254
|
+
snapshots: args.snapshots,
|
|
255
|
+
triedProfiles: args.triedProfiles,
|
|
256
|
+
sawTypedLimit: args.sawTypedLimit,
|
|
257
|
+
deliverableEmpty: args.deliverableEmpty,
|
|
258
|
+
lastLimit: args.lastLimit,
|
|
259
|
+
emit: args.emit,
|
|
260
|
+
});
|
|
261
|
+
if (!rotation)
|
|
262
|
+
return null;
|
|
263
|
+
return HarnessRunSpecSchema.parse({
|
|
264
|
+
...args.spec,
|
|
265
|
+
session_id: args.newSessionId(),
|
|
266
|
+
credential_profile: rotation,
|
|
267
|
+
resume_session_id: null,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=credential-profiles.js.map
|
|
@@ -0,0 +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,CAA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;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,oBAAoB,CAAC,KAAK,CAAC;QAChC,GAAG,IAAI,CAAC,IAAI;QACZ,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE;QAC/B,kBAAkB,EAAE,QAAQ;QAC5B,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/diffReview.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import type { AuthPreference, ProviderFamily, ReviewFinding } from "@claudexor/schema";
|
|
2
2
|
import { type ReviewerSpec, type reviewCandidate } from "@claudexor/review";
|
|
3
|
+
export interface FrozenDiffReviewInput {
|
|
4
|
+
evidenceDir: string;
|
|
5
|
+
artifactsDir: string;
|
|
6
|
+
candidateSha: string;
|
|
7
|
+
candidateTree: string;
|
|
8
|
+
packetManifestSha256: string;
|
|
9
|
+
}
|
|
3
10
|
export interface DiffReviewInput {
|
|
4
11
|
repoRoot: string;
|
|
5
|
-
diff
|
|
12
|
+
diff?: string;
|
|
6
13
|
userIntent?: string;
|
|
7
14
|
tests?: string;
|
|
8
15
|
decidedTradeoffs?: string;
|
|
16
|
+
frozen?: FrozenDiffReviewInput;
|
|
9
17
|
authPreference?: AuthPreference;
|
|
10
18
|
signal?: AbortSignal;
|
|
11
19
|
onReviewerEvent?: (event: {
|
package/dist/diffReview.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffReview.d.ts","sourceRoot":"","sources":["../src/diffReview.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diffReview.d.ts","sourceRoot":"","sources":["../src/diffReview.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIhG,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,cAAc,EAAE,CAAC;IACpC,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACjG,YAAY,EAAE,CACZ,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,KACtD,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACxC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,eAAe,GAAG,OAAO,CAAC;CACjE;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAwF3B"}
|
package/dist/diffReview.js
CHANGED
|
@@ -5,21 +5,29 @@
|
|
|
5
5
|
* resolution, evidence packaging, revalidation, and typed results; the CLI
|
|
6
6
|
* verb stays a thin surface.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
9
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
10
|
+
import { HarnessUnavailableError, runCapture, runCaptureRaw } from "@claudexor/core";
|
|
10
11
|
import { revalidateFindings } from "@claudexor/review";
|
|
11
|
-
import { writeEvidencePacket } from "@claudexor/context";
|
|
12
|
+
import { verifySealedEvidencePacket, writeEvidencePacket } from "@claudexor/context";
|
|
12
13
|
import { containsSecretLikeToken, redactSecrets } from "@claudexor/util";
|
|
13
14
|
export async function runDiffReview(input, deps) {
|
|
14
|
-
if (
|
|
15
|
+
if (input.frozen && input.diff !== undefined) {
|
|
16
|
+
throw new Error("reviewDiff: frozen review consumes DIFF.patch from the sealed packet");
|
|
17
|
+
}
|
|
18
|
+
if (!input.frozen && !input.diff?.trim()) {
|
|
15
19
|
throw new Error("reviewDiff: the diff is empty — nothing to review");
|
|
16
20
|
}
|
|
21
|
+
const frozen = input.frozen
|
|
22
|
+
? await verifyFrozenReviewPacket(input.repoRoot, input.frozen, true)
|
|
23
|
+
: undefined;
|
|
24
|
+
const diff = frozen?.diff ?? input.diff ?? "";
|
|
17
25
|
// INV-062: raw secrets must never become review artifacts. The fence lives
|
|
18
26
|
// HERE so every caller (CLI verb, commit gate, future surfaces) is covered
|
|
19
27
|
// before any evidence write or reviewer call — and it covers EVERY
|
|
20
28
|
// artifact-bound string, not just the diff.
|
|
21
29
|
for (const [label, text] of [
|
|
22
|
-
["diff",
|
|
30
|
+
["diff", diff],
|
|
23
31
|
["userIntent", input.userIntent],
|
|
24
32
|
["tests", input.tests],
|
|
25
33
|
["decidedTradeoffs", input.decidedTradeoffs],
|
|
@@ -33,25 +41,45 @@ export async function runDiffReview(input, deps) {
|
|
|
33
41
|
throw new HarnessUnavailableError("no eligible reviewers (doctor-OK, review-capable) are available");
|
|
34
42
|
}
|
|
35
43
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
36
|
-
const baseDir =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const baseDir = input.frozen
|
|
45
|
+
? undefined
|
|
46
|
+
: join(deps.execRootOf(input.repoRoot), ".claudexor", "reviews", `diff-${stamp}`);
|
|
47
|
+
const evidenceDir = frozen?.evidenceDir ?? join(baseDir, "evidence");
|
|
48
|
+
const artifactsDir = input.frozen?.artifactsDir ?? join(baseDir, "reviewers");
|
|
49
|
+
if (!input.frozen) {
|
|
50
|
+
writeEvidencePacket(evidenceDir, {
|
|
51
|
+
userIntent: redactSecrets(input.userIntent ?? "Review this staged diff for defects before commit."),
|
|
52
|
+
diff,
|
|
53
|
+
tests: input.tests ?? "(no test evidence supplied)",
|
|
54
|
+
decidedTradeoffs: input.decidedTradeoffs,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
44
57
|
const result = await deps.reviewScoped({
|
|
45
|
-
candidateLabel: "Staged diff",
|
|
46
|
-
diff
|
|
58
|
+
candidateLabel: input.frozen ? "Frozen candidate" : "Staged diff",
|
|
59
|
+
diff,
|
|
47
60
|
evidenceDir,
|
|
48
|
-
artifactsDir
|
|
61
|
+
artifactsDir,
|
|
62
|
+
evidenceReadOnly: input.frozen !== undefined,
|
|
63
|
+
...(frozen
|
|
64
|
+
? {
|
|
65
|
+
frozenIdentity: {
|
|
66
|
+
candidateSha: input.frozen.candidateSha,
|
|
67
|
+
candidateTree: input.frozen.candidateTree,
|
|
68
|
+
packetManifestSha256: frozen.manifestSha256,
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
: {}),
|
|
49
72
|
cwd: input.repoRoot,
|
|
50
73
|
reviewers,
|
|
51
74
|
envInheritance: deps.envInheritance(input.repoRoot),
|
|
52
75
|
signal: input.signal,
|
|
53
|
-
onReviewerEvent: input.onReviewerEvent
|
|
76
|
+
onReviewerEvent: input.onReviewerEvent
|
|
77
|
+
? (event) => input.onReviewerEvent?.({ ...event })
|
|
78
|
+
: undefined,
|
|
54
79
|
});
|
|
80
|
+
if (input.frozen) {
|
|
81
|
+
await verifyFrozenReviewPacket(input.repoRoot, input.frozen, false);
|
|
82
|
+
}
|
|
55
83
|
const findings = await revalidateFindings(result.findings, {
|
|
56
84
|
candidateRoot: input.repoRoot,
|
|
57
85
|
evidenceDir,
|
|
@@ -63,7 +91,75 @@ export async function runDiffReview(input, deps) {
|
|
|
63
91
|
distinctProviders: result.distinctProviders,
|
|
64
92
|
routeProofs: result.routeProofs,
|
|
65
93
|
reviewSpendUsd: result.reviewSpendUsd,
|
|
66
|
-
artifactsDir
|
|
94
|
+
artifactsDir,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function verifyFrozenReviewPacket(repoRootInput, frozen, artifactsMustNotExist) {
|
|
98
|
+
const repoRoot = realpathSync(repoRootInput);
|
|
99
|
+
const evidenceDir = realpathSync(frozen.evidenceDir);
|
|
100
|
+
const artifactsDir = resolve(frozen.artifactsDir);
|
|
101
|
+
if (artifactsMustNotExist && existsSync(artifactsDir)) {
|
|
102
|
+
throw new Error("reviewDiff: reviewer artifacts directory already exists");
|
|
103
|
+
}
|
|
104
|
+
if (isWithin(repoRoot, evidenceDir)) {
|
|
105
|
+
throw new Error("reviewDiff: frozen evidence directory must be outside the candidate tree");
|
|
106
|
+
}
|
|
107
|
+
if (isWithin(repoRoot, artifactsDir)) {
|
|
108
|
+
throw new Error("reviewDiff: reviewer artifacts directory must be outside the candidate tree");
|
|
109
|
+
}
|
|
110
|
+
if (isWithin(evidenceDir, artifactsDir) || isWithin(artifactsDir, evidenceDir)) {
|
|
111
|
+
throw new Error("reviewDiff: sealed evidence and reviewer artifacts directories must not overlap");
|
|
112
|
+
}
|
|
113
|
+
const [actualSha, actualTree, status] = await Promise.all([
|
|
114
|
+
git(repoRoot, ["rev-parse", "HEAD"]),
|
|
115
|
+
git(repoRoot, ["rev-parse", "HEAD^{tree}"]),
|
|
116
|
+
git(repoRoot, ["status", "--porcelain=v1", "--untracked-files=all"]),
|
|
117
|
+
]);
|
|
118
|
+
if (actualSha !== frozen.candidateSha) {
|
|
119
|
+
throw new Error(`reviewDiff: candidate SHA mismatch (expected ${frozen.candidateSha}, got ${actualSha})`);
|
|
120
|
+
}
|
|
121
|
+
if (actualTree !== frozen.candidateTree) {
|
|
122
|
+
throw new Error(`reviewDiff: candidate tree mismatch (expected ${frozen.candidateTree}, got ${actualTree})`);
|
|
123
|
+
}
|
|
124
|
+
if (status !== "") {
|
|
125
|
+
throw new Error("reviewDiff: frozen candidate worktree is dirty or stale");
|
|
126
|
+
}
|
|
127
|
+
const packet = verifySealedEvidencePacket({
|
|
128
|
+
evidenceDir,
|
|
129
|
+
candidateSha: frozen.candidateSha,
|
|
130
|
+
candidateTree: frozen.candidateTree,
|
|
131
|
+
expectedManifestSha256: frozen.packetManifestSha256,
|
|
132
|
+
});
|
|
133
|
+
const actualDiff = await gitRaw(repoRoot, [
|
|
134
|
+
"diff",
|
|
135
|
+
"--binary",
|
|
136
|
+
`${packet.baseSha}..${frozen.candidateSha}`,
|
|
137
|
+
]);
|
|
138
|
+
if (packet.diff !== actualDiff) {
|
|
139
|
+
throw new Error("reviewDiff: sealed DIFF.patch does not match base..candidate");
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
evidenceDir: packet.evidenceDir,
|
|
143
|
+
diff: packet.diff,
|
|
144
|
+
manifestSha256: packet.manifestSha256,
|
|
67
145
|
};
|
|
68
146
|
}
|
|
147
|
+
async function git(cwd, args) {
|
|
148
|
+
const result = await runCapture("git", args, { cwd });
|
|
149
|
+
if (result.code !== 0) {
|
|
150
|
+
throw new Error(`reviewDiff: git ${args.join(" ")} failed: ${(result.stderr || result.stdout).trim()}`);
|
|
151
|
+
}
|
|
152
|
+
return result.stdout.trim();
|
|
153
|
+
}
|
|
154
|
+
async function gitRaw(cwd, args) {
|
|
155
|
+
const result = await runCaptureRaw("git", args, { cwd });
|
|
156
|
+
if (result.code !== 0) {
|
|
157
|
+
throw new Error(`reviewDiff: git ${args.join(" ")} failed: ${(result.stderr || result.stdout).trim()}`);
|
|
158
|
+
}
|
|
159
|
+
return result.stdout;
|
|
160
|
+
}
|
|
161
|
+
function isWithin(root, candidate) {
|
|
162
|
+
const path = relative(root, candidate);
|
|
163
|
+
return path === "" || (path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path));
|
|
164
|
+
}
|
|
69
165
|
//# sourceMappingURL=diffReview.js.map
|
package/dist/diffReview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffReview.js","sourceRoot":"","sources":["../src/diffReview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":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"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
* cannot run is a config bug better caught before the run than mid-run.
|
|
10
10
|
*/
|
|
11
11
|
import type { HarnessAdapter } from "@claudexor/core";
|
|
12
|
+
import { type KnownModelEntry } from "@claudexor/schema";
|
|
12
13
|
export interface ModelGovernedRoute {
|
|
13
14
|
adapter: HarnessAdapter;
|
|
14
15
|
/** Manifest model truth source (used when the adapter has no live models()). */
|
|
15
|
-
knownModels: readonly
|
|
16
|
+
knownModels: readonly KnownModelEntry[];
|
|
17
|
+
/** Pre-spawn credential-route estimate: route-annotated manifest models are
|
|
18
|
+
* filtered by it, and stay EXCLUDED when it is null (fail-closed — a
|
|
19
|
+
* route-scoped model never passes the gate on an undecidable route). */
|
|
20
|
+
authRouteEstimate: "local_session" | "api_key" | null;
|
|
16
21
|
settings: {
|
|
17
22
|
defaultModel: string | null;
|
|
18
23
|
fallbackModel: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelGovernance.d.ts","sourceRoot":"","sources":["../src/modelGovernance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"modelGovernance.d.ts","sourceRoot":"","sources":["../src/modelGovernance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,gFAAgF;IAChF,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;IACxC;;4EAEwE;IACxE,iBAAiB,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IACtD,QAAQ,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAChF;AAED,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,SAAS,kBAAkB,EAAE,EACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC1C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
package/dist/modelGovernance.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HarnessUnavailableError, validateModel } from "@claudexor/core";
|
|
2
|
+
import { knownModelIdsForRoute } from "@claudexor/schema";
|
|
2
3
|
export async function assertRouteModelsAllowed(routes, models, cwd) {
|
|
3
4
|
const checked = new Set();
|
|
4
5
|
for (const routed of routes) {
|
|
@@ -19,12 +20,17 @@ export async function assertRouteModelsAllowed(routes, models, cwd) {
|
|
|
19
20
|
truth = { list: inventory.map((m) => m.id), source: "api" };
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
|
-
|
|
23
|
+
// Route-aware manifest truth (INV-104 x INV-061): route-annotated models
|
|
24
|
+
// count only on their routes; an undecidable route excludes them.
|
|
25
|
+
truth = {
|
|
26
|
+
list: knownModelIdsForRoute(routed.knownModels, routed.authRouteEstimate),
|
|
27
|
+
source: "manifest",
|
|
28
|
+
};
|
|
23
29
|
}
|
|
24
30
|
for (const { role, model } of candidates) {
|
|
25
31
|
const check = validateModel(model, truth.list, truth.source);
|
|
26
32
|
if (check.status !== "ok") {
|
|
27
|
-
throw new HarnessUnavailableError(`harness '${id}' refused ${role} '${model}' (truth source: ${truth.source}): ${check.message}; ` +
|
|
33
|
+
throw new HarnessUnavailableError(`harness '${id}' refused ${role} '${model}' (truth source: ${truth.source}${truth.source === "manifest" ? `, route: ${routed.authRouteEstimate ?? "undecided"}` : ""}): ${check.message}; ` +
|
|
28
34
|
`run \`claudexor models --harness ${id}\``);
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelGovernance.js","sourceRoot":"","sources":["../src/modelGovernance.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"modelGovernance.js","sourceRoot":"","sources":["../src/modelGovernance.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAwB,MAAM,mBAAmB,CAAC;AAahF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAqC,EACrC,MAA0C,EAC1C,GAAW;IAEX,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAS;QAC9B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,YAAY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MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,iBAAiB,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,OAAO,IAAI;oBACzL,oCAAoC,EAAE,IAAI,CAC7C,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ArtifactStore } from "@claudexor/artifact-store";
|
|
2
|
+
import type { EventLog } from "@claudexor/event-log";
|
|
3
|
+
import type { BudgetLedger } from "@claudexor/budget";
|
|
4
|
+
import { type DeliveryReceipt, type OrchestrateAutonomy, type OrchestratePlan, type OrchestratePlanCall, type OrchestrateStepStatus, type RunStatus } from "@claudexor/schema";
|
|
5
|
+
export interface OrchestrateSafeStepResult {
|
|
6
|
+
status: OrchestrateStepStatus;
|
|
7
|
+
terminalStatus: RunStatus | null;
|
|
8
|
+
terminalSource: "subrun" | "review" | "executor";
|
|
9
|
+
evidenceRefs: string[];
|
|
10
|
+
runId: string | null;
|
|
11
|
+
detail: string | null;
|
|
12
|
+
spendUsd?: number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface OrchestrateApplyStepResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
runId: string;
|
|
17
|
+
detail: string;
|
|
18
|
+
receipt: DeliveryReceipt | null;
|
|
19
|
+
}
|
|
20
|
+
interface ExecuteOrchestratePlanInput {
|
|
21
|
+
plan: OrchestratePlan;
|
|
22
|
+
autonomy: OrchestrateAutonomy;
|
|
23
|
+
maxToolCalls: number | null;
|
|
24
|
+
ledger: BudgetLedger;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
store: ArtifactStore;
|
|
27
|
+
paths: ReturnType<ArtifactStore["runPaths"]>;
|
|
28
|
+
log: EventLog;
|
|
29
|
+
executeSafeStep(call: OrchestratePlanCall): Promise<OrchestrateSafeStepResult>;
|
|
30
|
+
executeApplyStep(call: Extract<OrchestratePlanCall, {
|
|
31
|
+
tool: "apply";
|
|
32
|
+
}>): Promise<OrchestrateApplyStepResult>;
|
|
33
|
+
}
|
|
34
|
+
export interface OrchestrateExecutionResult {
|
|
35
|
+
terminal: RunStatus;
|
|
36
|
+
note: string;
|
|
37
|
+
readOnly: boolean;
|
|
38
|
+
receiptRefs: string[];
|
|
39
|
+
}
|
|
40
|
+
/** Ordered executor; terminal truth is delegated to the exhaustive outcome reducer. */
|
|
41
|
+
export declare function executeOrchestratePlan(input: ExecuteOrchestratePlanInput): Promise<OrchestrateExecutionResult>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=orchestrateExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrateExecutor.d.ts","sourceRoot":"","sources":["../src/orchestrateExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAO3B,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,cAAc,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACjD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA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