@claudexor/orchestrator 3.3.7-rc.0 → 3.3.8
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/README.md +3 -1
- package/dist/attemptUsageCost.d.ts.map +1 -1
- package/dist/attemptUsageCost.js +15 -1
- package/dist/attemptUsageCost.js.map +1 -1
- package/dist/credential-profile-rotation.d.ts +5 -2
- package/dist/credential-profile-rotation.d.ts.map +1 -1
- package/dist/credential-profile-rotation.js +18 -11
- package/dist/credential-profile-rotation.js.map +1 -1
- package/dist/credential-profiles.d.ts +3 -0
- package/dist/credential-profiles.d.ts.map +1 -1
- package/dist/credential-profiles.js +10 -7
- package/dist/credential-profiles.js.map +1 -1
- package/dist/delegatedHome.d.ts +12 -4
- package/dist/delegatedHome.d.ts.map +1 -1
- package/dist/delegatedHome.js +5 -4
- package/dist/delegatedHome.js.map +1 -1
- package/dist/diffReview.d.ts +7 -0
- package/dist/diffReview.d.ts.map +1 -1
- package/dist/diffReview.js +1 -0
- package/dist/diffReview.js.map +1 -1
- package/dist/orchestrator.d.ts +13 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +121 -122
- package/dist/orchestrator.js.map +1 -1
- package/dist/routing-failure.d.ts +35 -1
- package/dist/routing-failure.d.ts.map +1 -1
- package/dist/routing-failure.js +70 -3
- package/dist/routing-failure.js.map +1 -1
- package/dist/runFacts.d.ts.map +1 -1
- package/dist/runFacts.js +4 -13
- package/dist/runFacts.js.map +1 -1
- package/package.json +17 -17
package/dist/orchestrator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccessProfile, Attachment, ControlReviewerPanelEntry, EffortHint, HarnessCapabilities, KnownModelEntry, ExternalContextPolicy, HarnessEvent, InteractionHandlerResult, InteractionRequest, ModeKind, PaidBudget, QuotaAbsence, QuotaSnapshot, RoutingGoal, ProtectedPathApproval, RequestRequirementResolution, RunEvent, RunLifecycle, RunOutcomeFacts, TestCommandInvocation, ProviderFamily, ImplementationTransport, WebPolicySupport } from "@claudexor/schema";
|
|
1
|
+
import type { AccessProfile, Attachment, ControlReviewerPanelEntry, EffortHint, HarnessCapabilities, KnownModelEntry, ExternalContextPolicy, HarnessEvent, InteractionHandlerResult, InteractionRequest, ModeKind, PaidBudget, QuotaAbsence, QuotaSnapshot, RoutingGoal, ProtectedPathApproval, RequestRequirementResolution, RunEvent, RunLifecycle, RunOutcomeFacts, TestCommandInvocation, ProviderFamily, CredentialProfile, ImplementationTransport, WebPolicySupport } from "@claudexor/schema";
|
|
2
2
|
import { type PlannerAttemptArgs, type PlannerAttemptOutcome } from "./plannerAttempt.js";
|
|
3
3
|
export type { PlannerAttemptArgs, PlannerAttemptOutcome } from "./plannerAttempt.js";
|
|
4
4
|
import { type ExtraMcpServer } from "@claudexor/schema";
|
|
@@ -329,6 +329,14 @@ export interface RoutedAdapter {
|
|
|
329
329
|
/** Pre-spawn credential-route estimate (INV-061 projection of preference x
|
|
330
330
|
* doctor source readiness); null = undecidable, model gates stay fail-closed. */
|
|
331
331
|
authRouteEstimate: "local_session" | "api_key" | null;
|
|
332
|
+
/** Quota identity resolved before pool ranking. The model is frozen for the
|
|
333
|
+
* initial route; a fallback/downgrade model forces a fresh profile preflight
|
|
334
|
+
* before spawn instead of reusing this admission. */
|
|
335
|
+
quotaAdmission: {
|
|
336
|
+
model: string | null;
|
|
337
|
+
profile: CredentialProfile | null;
|
|
338
|
+
route: "vendor_native" | "managed_api_key" | null;
|
|
339
|
+
};
|
|
332
340
|
/** Manifest `synthesize` capability (#27 / D-6): only such routes are eligible
|
|
333
341
|
* to run the deep-scan bounded synthesis reducer over the scout reports. */
|
|
334
342
|
supportsSynthesize: boolean;
|
|
@@ -456,6 +464,10 @@ export declare class Orchestrator {
|
|
|
456
464
|
* always pinned first. Cross-family diversity is encouraged for later slots.
|
|
457
465
|
*/
|
|
458
466
|
private orderPool;
|
|
467
|
+
/** Harness-only convergence helpers still need the exact quota identity
|
|
468
|
+
* selected before ranking. This facade keeps their small interface while
|
|
469
|
+
* preventing a scoped limit on one model/account from cooling another. */
|
|
470
|
+
private quotaLedgerView;
|
|
459
471
|
/**
|
|
460
472
|
* Typed auth-route evidence for one candidate (QA-034): the concrete
|
|
461
473
|
* credential route the resolved auth mode maps to, plus the doctor's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EACV,aAAa,EAKb,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,YAAY,EAEZ,wBAAwB,EACxB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,qBAAqB,EAErB,4BAA4B,EAE5B,QAAQ,EACR,YAAY,EACZ,eAAe,EAEf,qBAAqB,EACrB,cAAc,
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EACV,aAAa,EAKb,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,YAAY,EAEZ,wBAAwB,EACxB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,qBAAqB,EAErB,4BAA4B,EAE5B,QAAQ,EACR,YAAY,EACZ,eAAe,EAEf,qBAAqB,EACrB,cAAc,EAEd,iBAAiB,EACjB,uBAAuB,EAEvB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAEL,KAAK,cA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AO,CAAC,iBAAiB;IAezB,OAAO,CAAC,cAAc;IAuEtB;;;;;;;;OAQG;YACW,iBAAiB;IA4G/B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;YAgBR,sBAAsB;IAmkBpC,OAAO,CAAC,qBAAqB;IAwB7B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,wBAAwB;YAiBlB,OAAO;IA07CrB,oGAAoG;IACpG,OAAO,CAAC,iBAAiB;IA+BzB,uGAAuG;IAEvG;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;YAaN,UAAU;IAsKxB,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,2BAA2B;YAoBrB,cAAc;IA+gC5B,2EAA2E;IAC3E,OAAO,CAAC,kBAAkB;IA2E1B,sFAAsF;IAChF,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAEhF;YACa,OAAO;IA+UrB;;6EAEyE;IACzE,OAAO,CAAC,WAAW;IAmBnB,sFAAsF;YACxE,MAAM;IAkBpB;gDAC4C;YAC9B,WAAW;IAmBzB,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,qBAAqB;IAW7B;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;YAiEb,iBAAiB;CA4xChC"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -18,7 +18,7 @@ import { assertRouteModelsAllowed } from "./modelGovernance.js";
|
|
|
18
18
|
import { governRouteEffort } from "./effortGovernance.js";
|
|
19
19
|
import { isFullAccess, RequestRequirementsResolver } from "./requestRequirements.js";
|
|
20
20
|
import { activateDelegationParent } from "./delegation-parent-activation.js";
|
|
21
|
-
import {
|
|
21
|
+
import { writeRoutingFailureTerminal } from "./routing-failure.js";
|
|
22
22
|
export { routingFailureClassification } from "./routing-failure.js";
|
|
23
23
|
import { runBounded } from "./run-bounded.js";
|
|
24
24
|
import { planPrompt } from "./plan-prompt.js";
|
|
@@ -327,9 +327,11 @@ export class Orchestrator {
|
|
|
327
327
|
execRootOf(input) {
|
|
328
328
|
return input.executionRoot ?? input.repoRoot;
|
|
329
329
|
}
|
|
330
|
-
async sessionSpecFields(input, harnessId, log, defaultRoute = null) {
|
|
330
|
+
async sessionSpecFields(input, harnessId, model, log, defaultRoute = null, quotaAdmission) {
|
|
331
331
|
const cfg = this.config(input.repoRoot)?.global;
|
|
332
|
-
const profile =
|
|
332
|
+
const profile = quotaAdmission?.model === model
|
|
333
|
+
? quotaAdmission.profile
|
|
334
|
+
: await this.preflightProfile(input, harnessId, model, log, defaultRoute);
|
|
333
335
|
return {
|
|
334
336
|
// "auto" at ANY level falls through (thread turns send the thread default
|
|
335
337
|
// "auto" as a per-run value; it must not shadow a configured preference).
|
|
@@ -441,13 +443,13 @@ export class Orchestrator {
|
|
|
441
443
|
.filter(({ profile, status }) => profileStatusAdmits(profile, status))
|
|
442
444
|
.map(({ profile }) => profile.profile_id));
|
|
443
445
|
}
|
|
444
|
-
async preflightProfile(input, harnessId, log, defaultRoute) {
|
|
446
|
+
async preflightProfile(input, harnessId, model, log, defaultRoute) {
|
|
445
447
|
const profile = this.resolveCredentialProfile(input, harnessId);
|
|
446
448
|
const policy = this.profilePolicy(input.repoRoot, harnessId);
|
|
447
449
|
const registry = this.config(input.repoRoot)?.global.credential_profiles ?? [];
|
|
448
450
|
const snapshots = this.deps.quotaSnapshots?.() ?? [];
|
|
449
451
|
const emit = (type, payload) => log?.emit(type, payload);
|
|
450
|
-
const breach = profileHeadroomBreach(snapshots, harnessId, profile?.profile_id ?? null, policy.headroom_threshold);
|
|
452
|
+
const breach = profileHeadroomBreach(snapshots, harnessId, profile?.profile_id ?? null, policy.headroom_threshold, model);
|
|
451
453
|
const readyProfileIds = policy.limit_action === "rotate" &&
|
|
452
454
|
breach !== null &&
|
|
453
455
|
(profile !== null || defaultRoute === "local_session")
|
|
@@ -464,6 +466,7 @@ export class Orchestrator {
|
|
|
464
466
|
snapshots,
|
|
465
467
|
readyProfileIds,
|
|
466
468
|
defaultRoute,
|
|
469
|
+
model,
|
|
467
470
|
emit,
|
|
468
471
|
});
|
|
469
472
|
}
|
|
@@ -474,6 +477,7 @@ export class Orchestrator {
|
|
|
474
477
|
registry,
|
|
475
478
|
snapshots,
|
|
476
479
|
readyProfileIds,
|
|
480
|
+
model,
|
|
477
481
|
emit,
|
|
478
482
|
});
|
|
479
483
|
}
|
|
@@ -751,6 +755,7 @@ export class Orchestrator {
|
|
|
751
755
|
// the default store's sources apply only to profile-less runs.
|
|
752
756
|
authRouteEstimate: this.profileAuthRoute(input, id) ??
|
|
753
757
|
estimateEffectiveAuthRoute(this.authPreferenceForHarness(input.repoRoot, id, input.authPreference), status.authSources),
|
|
758
|
+
quotaAdmission: { model: null, profile: null, route: null },
|
|
754
759
|
supportsSynthesize: manifest.capabilities.synthesize,
|
|
755
760
|
supportsInteractive: manifest.capabilities.interactive,
|
|
756
761
|
supportsJsonSchemaOutput: manifest.capabilities.json_schema_output,
|
|
@@ -785,11 +790,29 @@ export class Orchestrator {
|
|
|
785
790
|
if (pool.length === 0) {
|
|
786
791
|
throw new HarnessUnavailableError(`no harness can perform '${intent}' for this mode${dropped.length ? ` (skipped: ${dropped.join(", ")})` : ""}`);
|
|
787
792
|
}
|
|
788
|
-
|
|
793
|
+
// Quota admission must use the account that will actually spawn. In
|
|
794
|
+
// particular, an opt-in default-subject rotation has to select its ready
|
|
795
|
+
// profile before the budget router filters the exhausted default away.
|
|
796
|
+
// The same resolved profile is reused by the first spec build below.
|
|
797
|
+
const quotaPreparedPool = await Promise.all(pool.map(async (routed) => {
|
|
798
|
+
const model = input.models?.[routed.adapter.id] ?? routed.settings?.defaultModel ?? null;
|
|
799
|
+
const profile = await this.preflightProfile(input, routed.adapter.id, model, log, routed.authRouteEstimate);
|
|
800
|
+
const route = profile
|
|
801
|
+
? profile.credential_kind === "api_key"
|
|
802
|
+
? "managed_api_key"
|
|
803
|
+
: "vendor_native"
|
|
804
|
+
: routed.authRouteEstimate === "api_key"
|
|
805
|
+
? "managed_api_key"
|
|
806
|
+
: routed.authRouteEstimate === "local_session"
|
|
807
|
+
? "vendor_native"
|
|
808
|
+
: null;
|
|
809
|
+
return { ...routed, quotaAdmission: { model, profile, route } };
|
|
810
|
+
}));
|
|
811
|
+
const ordered = this.orderPool(quotaPreparedPool, input, intent, statusById, ledger, runId);
|
|
789
812
|
if (ordered.length === 0) {
|
|
790
813
|
throw new HarnessUnavailableError(`no harness remains eligible for '${intent}' after budget and quota routing`);
|
|
791
814
|
}
|
|
792
|
-
emitPrimaryDivergence(log, input.primaryHarness, ordered,
|
|
815
|
+
emitPrimaryDivergence(log, input.primaryHarness, ordered, quotaPreparedPool, dropped);
|
|
793
816
|
const n = input.n ?? ordered.length;
|
|
794
817
|
const selectionOrder = ordered;
|
|
795
818
|
const out = [];
|
|
@@ -896,28 +919,25 @@ export class Orchestrator {
|
|
|
896
919
|
: authModes.includes("api_key")
|
|
897
920
|
? "api_key"
|
|
898
921
|
: "unknown";
|
|
899
|
-
//
|
|
900
|
-
// (round-18 #2)
|
|
922
|
+
// The quota-preflight profile's credential_kind decides the route
|
|
923
|
+
// outright (round-18 #2). This includes an unpinned default subject
|
|
924
|
+
// that rotated before ranking; an api_key profile must never inherit a
|
|
901
925
|
// subscription classification from the default store's metric.
|
|
902
|
-
const
|
|
926
|
+
const admittedProfileRoute = r.quotaAdmission.profile
|
|
927
|
+
? r.quotaAdmission.profile.credential_kind === "api_key"
|
|
928
|
+
? "api_key"
|
|
929
|
+
: "local_session"
|
|
930
|
+
: null;
|
|
931
|
+
const authMode = admittedProfileRoute ??
|
|
903
932
|
(input.authPreference === "api_key"
|
|
904
933
|
? "api_key"
|
|
905
934
|
: input.authPreference === "subscription"
|
|
906
935
|
? "local_session"
|
|
907
936
|
: (metric?.last_auth_mode ?? guessedAuthMode));
|
|
908
|
-
// The quota subject
|
|
909
|
-
//
|
|
910
|
-
// default
|
|
911
|
-
|
|
912
|
-
// as unknown (undefined) and stays conservatively any-subject.
|
|
913
|
-
let credentialSubjectId;
|
|
914
|
-
try {
|
|
915
|
-
credentialSubjectId =
|
|
916
|
-
this.resolveCredentialProfile(input, r.adapter.id)?.profile_id ?? null;
|
|
917
|
-
}
|
|
918
|
-
catch {
|
|
919
|
-
credentialSubjectId = undefined;
|
|
920
|
-
}
|
|
937
|
+
// The exact quota subject selected before ranking: profile id or the
|
|
938
|
+
// engine default. Profile A's cooldown never excludes profile B or the
|
|
939
|
+
// default on the same harness and route.
|
|
940
|
+
const credentialSubjectId = r.quotaAdmission.profile?.profile_id ?? null;
|
|
921
941
|
// QA-034: the typed auth-route evidence (doctor source verification x the
|
|
922
942
|
// resolved route) is AUTHORITATIVE for billing knowledge in the router —
|
|
923
943
|
// a VERIFIED native route proves subscription_entitlement, so it survives
|
|
@@ -928,20 +948,19 @@ export class Orchestrator {
|
|
|
928
948
|
return {
|
|
929
949
|
harnessId: r.adapter.id,
|
|
930
950
|
available: true,
|
|
931
|
-
model:
|
|
932
|
-
config.harnesses[r.adapter.id]?.default_model ??
|
|
933
|
-
undefined,
|
|
951
|
+
model: r.quotaAdmission.model,
|
|
934
952
|
effort: input.efforts?.[r.adapter.id] ??
|
|
935
953
|
input.effort ??
|
|
936
954
|
config.harnesses[r.adapter.id]?.effort ??
|
|
937
955
|
undefined,
|
|
938
956
|
billingKnowledge: authMode === "api_key" ? "metered" : "unknown",
|
|
939
957
|
incrementalCostUsd: authMode === "api_key" ? (metric?.avg_cost_usd ?? null) : null,
|
|
940
|
-
credentialRoute:
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
958
|
+
credentialRoute: r.quotaAdmission.route ??
|
|
959
|
+
(authMode === "api_key"
|
|
960
|
+
? "managed_api_key"
|
|
961
|
+
: authMode === "local_session"
|
|
962
|
+
? "vendor_native"
|
|
963
|
+
: undefined),
|
|
945
964
|
...(authRoute ? { authRoute } : {}),
|
|
946
965
|
credentialSubjectId,
|
|
947
966
|
};
|
|
@@ -989,6 +1008,36 @@ export class Orchestrator {
|
|
|
989
1008
|
}
|
|
990
1009
|
return ordered;
|
|
991
1010
|
}
|
|
1011
|
+
/** Harness-only convergence helpers still need the exact quota identity
|
|
1012
|
+
* selected before ranking. This facade keeps their small interface while
|
|
1013
|
+
* preventing a scoped limit on one model/account from cooling another. */
|
|
1014
|
+
quotaLedgerView(ledger, routes) {
|
|
1015
|
+
const byId = new Map(routes.map((route) => [route.adapter.id, route]));
|
|
1016
|
+
const identity = (id) => {
|
|
1017
|
+
const route = byId.get(id);
|
|
1018
|
+
return route
|
|
1019
|
+
? {
|
|
1020
|
+
credentialRoute: route.quotaAdmission.route ?? undefined,
|
|
1021
|
+
credentialSubjectId: route.quotaAdmission.profile?.profile_id ?? null,
|
|
1022
|
+
model: route.quotaAdmission.model,
|
|
1023
|
+
}
|
|
1024
|
+
: null;
|
|
1025
|
+
};
|
|
1026
|
+
return {
|
|
1027
|
+
bindingPaceSlack: (id) => {
|
|
1028
|
+
const selected = identity(id);
|
|
1029
|
+
return selected
|
|
1030
|
+
? ledger.bindingPaceSlack(id, selected.credentialRoute, selected.credentialSubjectId, Date.now(), selected.model)
|
|
1031
|
+
: ledger.bindingPaceSlack(id);
|
|
1032
|
+
},
|
|
1033
|
+
cooldownActive: (id) => {
|
|
1034
|
+
const selected = identity(id);
|
|
1035
|
+
return selected
|
|
1036
|
+
? ledger.cooldownActive(id, selected.credentialRoute, selected.credentialSubjectId, Date.now(), selected.model)
|
|
1037
|
+
: ledger.cooldownActive(id);
|
|
1038
|
+
},
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
992
1041
|
/**
|
|
993
1042
|
* Typed auth-route evidence for one candidate (QA-034): the concrete
|
|
994
1043
|
* credential route the resolved auth mode maps to, plus the doctor's
|
|
@@ -1383,7 +1432,7 @@ export class Orchestrator {
|
|
|
1383
1432
|
const inPlaceEnvelope = envelope.worktree_path === envelope.repo_root;
|
|
1384
1433
|
const rawContextPacket = await rawContextForEnvelope(routed.implementationTransport, envelope);
|
|
1385
1434
|
const sessionFields = runInput
|
|
1386
|
-
? await this.sessionSpecFields(runInput, adapter.id, log, routed.authRouteEstimate)
|
|
1435
|
+
? await this.sessionSpecFields(runInput, adapter.id, knobs.model, log, routed.authRouteEstimate, routed.quotaAdmission)
|
|
1387
1436
|
: undefined;
|
|
1388
1437
|
// Continuity (INV-137): once the lane (harness + resolved profile) is known,
|
|
1389
1438
|
// build the continuation packet, materialize context/THREAD.md, and point
|
|
@@ -1440,8 +1489,12 @@ export class Orchestrator {
|
|
|
1440
1489
|
const workReportMode = this.applyWorkEnvelope(spec, workEnvelope);
|
|
1441
1490
|
const inactivityMs = harnessInactivityTimeoutMs(this.config(contract.repo.root));
|
|
1442
1491
|
// Named once: the attempt record, the CandidateRun and the terminal gate all
|
|
1443
|
-
// read the SAME applied facts rather than three re-derivations.
|
|
1444
|
-
|
|
1492
|
+
// read the SAME applied facts rather than three re-derivations. Derived
|
|
1493
|
+
// from the LIVE spec, so a W5.4 failover that rotates the credential
|
|
1494
|
+
// mid-attempt is re-recorded at the point it becomes true — the receipt
|
|
1495
|
+
// must name the profile that ran, never the one the request asked for.
|
|
1496
|
+
const appliedNow = () => appliedAttemptFacts(harnessHome, spec.access, spec.credential_profile?.profile_id ?? runInput?.credentialProfileId ?? null);
|
|
1497
|
+
let applied = appliedNow();
|
|
1445
1498
|
const attemptStartedMs = Date.now();
|
|
1446
1499
|
const budgetSignalState = { quotaPressureDisclosed: false };
|
|
1447
1500
|
const triedProfiles = new Set(); // W5.4 failover: each profile at most once
|
|
@@ -1664,6 +1717,7 @@ export class Orchestrator {
|
|
|
1664
1717
|
});
|
|
1665
1718
|
if (rotated) {
|
|
1666
1719
|
spec = rotated;
|
|
1720
|
+
applied = appliedNow();
|
|
1667
1721
|
errors.length = 0;
|
|
1668
1722
|
harnessErrored = false;
|
|
1669
1723
|
continue;
|
|
@@ -1969,26 +2023,11 @@ export class Orchestrator {
|
|
|
1969
2023
|
}
|
|
1970
2024
|
catch (err) {
|
|
1971
2025
|
const message = safeErrorMessage(err);
|
|
1972
|
-
store
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
phase: "routing",
|
|
1978
|
-
category: routingFailure.category,
|
|
1979
|
-
safeMessage: message,
|
|
1980
|
-
runDir: paths.root,
|
|
1981
|
-
...(routingFailure.nextActions ? { nextActions: routingFailure.nextActions } : {}),
|
|
1982
|
-
});
|
|
1983
|
-
store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (${mode})\n\n- Lifecycle: failed\n- Phase: routing\n\n${message}\n`);
|
|
1984
|
-
log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
|
|
1985
|
-
log.emit("run.failed", {
|
|
1986
|
-
lifecycle: "failed",
|
|
1987
|
-
facts: makeOutcomeFacts("failed", { reason: "harness_failed" }),
|
|
1988
|
-
reason: "harness_failed",
|
|
1989
|
-
phase: "routing",
|
|
1990
|
-
error: message,
|
|
1991
|
-
failure_ref: "final/failure.yaml",
|
|
2026
|
+
writeRoutingFailureTerminal(store, paths, log, {
|
|
2027
|
+
runId,
|
|
2028
|
+
modeLabel: mode,
|
|
2029
|
+
message,
|
|
2030
|
+
err,
|
|
1992
2031
|
});
|
|
1993
2032
|
return {
|
|
1994
2033
|
runId,
|
|
@@ -2314,6 +2353,10 @@ export class Orchestrator {
|
|
|
2314
2353
|
harnessId: r.harnessId,
|
|
2315
2354
|
status: gatesPassed(r.gates) && !r.errored ? "green" : "red",
|
|
2316
2355
|
}));
|
|
2356
|
+
/** The one cancellation terminal this race can reach, from any of its three
|
|
2357
|
+
* abort checks. Every argument is re-read at call time, exactly as it was
|
|
2358
|
+
* when each check spelled the whole call out for itself. */
|
|
2359
|
+
const cancelledRaceResult = () => cancelledResult(log, runId, taskId, mode, paths.root, cancelledCandidates(), () => this.writeRunTelemetry(store, paths, contract, runId, taskId, mode, candidateRoster(runs), null), ledger.spend(), input.signal, store);
|
|
2317
2360
|
// Revert divergence fence for the single-candidate in-place path: the
|
|
2318
2361
|
// candidate mutated the LIVE tree during execution above, so the post-turn
|
|
2319
2362
|
// snapshot must be taken NOW — before review/synthesis/arbitration, which can
|
|
@@ -2331,7 +2374,7 @@ export class Orchestrator {
|
|
|
2331
2374
|
}
|
|
2332
2375
|
if (input.signal?.aborted) {
|
|
2333
2376
|
await disposeReviewEnvelopes();
|
|
2334
|
-
return
|
|
2377
|
+
return cancelledRaceResult();
|
|
2335
2378
|
}
|
|
2336
2379
|
const failedDelegation = delegateFailure.dominantRaceCandidateFailure(runs);
|
|
2337
2380
|
if (failedDelegation) {
|
|
@@ -2522,7 +2565,7 @@ export class Orchestrator {
|
|
|
2522
2565
|
await disposeReviewEnvelopes();
|
|
2523
2566
|
}
|
|
2524
2567
|
if (input.signal?.aborted) {
|
|
2525
|
-
return
|
|
2568
|
+
return cancelledRaceResult();
|
|
2526
2569
|
}
|
|
2527
2570
|
// Synthesis: if worthwhile, run a synthesizer as a NEW, re-checked candidate.
|
|
2528
2571
|
const synth = decideSynthesis(evidences, input.synthesis ?? "auto");
|
|
@@ -2599,7 +2642,7 @@ export class Orchestrator {
|
|
|
2599
2642
|
}
|
|
2600
2643
|
}
|
|
2601
2644
|
if (input.signal?.aborted) {
|
|
2602
|
-
return
|
|
2645
|
+
return cancelledRaceResult();
|
|
2603
2646
|
}
|
|
2604
2647
|
let result;
|
|
2605
2648
|
try {
|
|
@@ -3236,26 +3279,11 @@ export class Orchestrator {
|
|
|
3236
3279
|
}
|
|
3237
3280
|
catch (err) {
|
|
3238
3281
|
const message = safeErrorMessage(err);
|
|
3239
|
-
store
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
phase: "routing",
|
|
3245
|
-
category: routingFailure.category,
|
|
3246
|
-
safeMessage: message,
|
|
3247
|
-
runDir: paths.root,
|
|
3248
|
-
...(routingFailure.nextActions ? { nextActions: routingFailure.nextActions } : {}),
|
|
3249
|
-
});
|
|
3250
|
-
store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (${mode})\n\n- Lifecycle: failed\n- Phase: routing\n\n${message}\n`);
|
|
3251
|
-
log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
|
|
3252
|
-
log.emit("run.failed", {
|
|
3253
|
-
lifecycle: "failed",
|
|
3254
|
-
facts: makeOutcomeFacts("failed", { reason: "harness_failed" }),
|
|
3255
|
-
reason: "harness_failed",
|
|
3256
|
-
phase: "routing",
|
|
3257
|
-
error: message,
|
|
3258
|
-
failure_ref: "final/failure.yaml",
|
|
3282
|
+
writeRoutingFailureTerminal(store, paths, log, {
|
|
3283
|
+
runId,
|
|
3284
|
+
modeLabel: mode,
|
|
3285
|
+
message,
|
|
3286
|
+
err,
|
|
3259
3287
|
});
|
|
3260
3288
|
return {
|
|
3261
3289
|
spendUsd: ledger.spend(),
|
|
@@ -3339,7 +3367,8 @@ export class Orchestrator {
|
|
|
3339
3367
|
// observed quota cooldown across all harnesses, or genuine no-progress (a stall on the same
|
|
3340
3368
|
// failure signature after every available harness has tried it).
|
|
3341
3369
|
const stallThreshold = input.untilClean === true ? 4 : 2;
|
|
3342
|
-
const
|
|
3370
|
+
const convergenceQuotaLedger = this.quotaLedgerView(ledger, adapterPool);
|
|
3371
|
+
const allCooledDown = () => adapterPool.every((a) => convergenceQuotaLedger.cooldownActive(a.adapter.id));
|
|
3343
3372
|
const attemptTelemetries = [];
|
|
3344
3373
|
let lastDiffStable = true;
|
|
3345
3374
|
try {
|
|
@@ -3697,7 +3726,7 @@ export class Orchestrator {
|
|
|
3697
3726
|
if (adapterPool.length > 1 && triedSinceProgress.size < adapterPool.length) {
|
|
3698
3727
|
// Quota-headroom consumer (mid-run, where quota observations EXIST);
|
|
3699
3728
|
// pick + honest route event owned by runSupport.rotateOnStall.
|
|
3700
|
-
adapterIdx = rotateOnStall(adapterPool.map((a) => a.adapter.id), adapterIdx,
|
|
3729
|
+
adapterIdx = rotateOnStall(adapterPool.map((a) => a.adapter.id), adapterIdx, convergenceQuotaLedger, triedSinceProgress, log, lastRun?.harnessId ?? null);
|
|
3701
3730
|
routed = adapterPool[adapterIdx];
|
|
3702
3731
|
adapter = routed.adapter;
|
|
3703
3732
|
}
|
|
@@ -3986,7 +4015,7 @@ export class Orchestrator {
|
|
|
3986
4015
|
const adapter = routed.adapter;
|
|
3987
4016
|
const knobs = this.routeSpecKnobs(routed, contract, undefined, input.effort);
|
|
3988
4017
|
const effectiveWeb = this.discloseWebUpgrade(log, routed, knobs.webPolicy, attemptId);
|
|
3989
|
-
const sessionFields = await this.sessionSpecFields(input, adapter.id, log, routed.authRouteEstimate);
|
|
4018
|
+
const sessionFields = await this.sessionSpecFields(input, adapter.id, knobs.model, log, routed.authRouteEstimate, routed.quotaAdmission);
|
|
3990
4019
|
const laneContinuity = args.laneRun
|
|
3991
4020
|
? await this.resolveContinuity(input, adapter.id, sessionFields.credential_profile?.profile_id ?? input.credentialProfileId ?? null, sessionFields.resume_session_id !== null, sessionFields, store, paths, this.execRootOf(input), log)
|
|
3992
4021
|
: null;
|
|
@@ -4065,26 +4094,11 @@ export class Orchestrator {
|
|
|
4065
4094
|
catch (err) {
|
|
4066
4095
|
roHome.dispose();
|
|
4067
4096
|
const message = safeErrorMessage(err);
|
|
4068
|
-
store
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
phase: "routing",
|
|
4074
|
-
category: routingFailure.category,
|
|
4075
|
-
safeMessage: message,
|
|
4076
|
-
runDir: paths.root,
|
|
4077
|
-
...(routingFailure.nextActions ? { nextActions: routingFailure.nextActions } : {}),
|
|
4078
|
-
});
|
|
4079
|
-
store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (plan)\n\n- Lifecycle: failed\n- Phase: routing\n\n${message}\n`);
|
|
4080
|
-
log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
|
|
4081
|
-
log.emit("run.failed", {
|
|
4082
|
-
lifecycle: "failed",
|
|
4083
|
-
facts: makeOutcomeFacts("failed", { reason: "harness_failed" }),
|
|
4084
|
-
reason: "harness_failed",
|
|
4085
|
-
phase: "routing",
|
|
4086
|
-
error: message,
|
|
4087
|
-
failure_ref: "final/failure.yaml",
|
|
4097
|
+
writeRoutingFailureTerminal(store, paths, log, {
|
|
4098
|
+
runId,
|
|
4099
|
+
modeLabel: "plan",
|
|
4100
|
+
message,
|
|
4101
|
+
err,
|
|
4088
4102
|
});
|
|
4089
4103
|
return {
|
|
4090
4104
|
spendUsd: ledger.spend(),
|
|
@@ -4364,7 +4378,7 @@ export class Orchestrator {
|
|
|
4364
4378
|
buildSpec: async (routed, homeEnv, prompt, attemptId) => {
|
|
4365
4379
|
const knobs = this.routeSpecKnobs(routed, contract, undefined, input.effort);
|
|
4366
4380
|
const effectiveWeb = this.discloseWebUpgrade(log, routed, knobs.webPolicy, attemptId);
|
|
4367
|
-
const sessionFields = await this.sessionSpecFields(input, routed.adapter.id, log, routed.authRouteEstimate);
|
|
4381
|
+
const sessionFields = await this.sessionSpecFields(input, routed.adapter.id, knobs.model, log, routed.authRouteEstimate, routed.quotaAdmission);
|
|
4368
4382
|
const spec = HarnessRunSpec.parse({
|
|
4369
4383
|
session_id: newId("ses"),
|
|
4370
4384
|
intent: "synthesize",
|
|
@@ -4461,26 +4475,11 @@ export class Orchestrator {
|
|
|
4461
4475
|
catch (err) {
|
|
4462
4476
|
roHome.dispose();
|
|
4463
4477
|
const message = safeErrorMessage(err);
|
|
4464
|
-
store
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
phase: "routing",
|
|
4470
|
-
category: routingFailure.category,
|
|
4471
|
-
safeMessage: message,
|
|
4472
|
-
runDir: paths.root,
|
|
4473
|
-
...(routingFailure.nextActions ? { nextActions: routingFailure.nextActions } : {}),
|
|
4474
|
-
});
|
|
4475
|
-
store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (${opts.mode})\n\n- Lifecycle: failed\n- Phase: routing\n\n${message}\n`);
|
|
4476
|
-
log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
|
|
4477
|
-
log.emit("run.failed", {
|
|
4478
|
-
lifecycle: "failed",
|
|
4479
|
-
facts: makeOutcomeFacts("failed", { reason: "harness_failed" }),
|
|
4480
|
-
reason: "harness_failed",
|
|
4481
|
-
phase: "routing",
|
|
4482
|
-
error: message,
|
|
4483
|
-
failure_ref: "final/failure.yaml",
|
|
4478
|
+
writeRoutingFailureTerminal(store, paths, log, {
|
|
4479
|
+
runId,
|
|
4480
|
+
modeLabel: opts.mode,
|
|
4481
|
+
message,
|
|
4482
|
+
err,
|
|
4484
4483
|
});
|
|
4485
4484
|
return {
|
|
4486
4485
|
runId,
|
|
@@ -4602,7 +4601,7 @@ export class Orchestrator {
|
|
|
4602
4601
|
const explorerPrompt = (opts.deepScan
|
|
4603
4602
|
? `${prompt}\n\nExplorer ${idx + 1}/${adapters.length}: focus on a distinct slice. Emit evidence-cited findings, explicit unknowns/omissions, and follow-up questions. Do not edit files.`
|
|
4604
4603
|
: prompt) + contextSection;
|
|
4605
|
-
const sessionFields = await this.sessionSpecFields(input, adapter.id, log, routed.authRouteEstimate);
|
|
4604
|
+
const sessionFields = await this.sessionSpecFields(input, adapter.id, knobs.model, log, routed.authRouteEstimate, routed.quotaAdmission);
|
|
4606
4605
|
const grantResume = sessionFields.resume_session_id !== null && !resumeGranted.has(adapter.id);
|
|
4607
4606
|
if (grantResume)
|
|
4608
4607
|
resumeGranted.add(adapter.id);
|