@claudexor/orchestrator 4.1.0 → 4.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/account-pool.d.ts +11 -0
- package/dist/account-pool.d.ts.map +1 -1
- package/dist/account-pool.js +9 -0
- package/dist/account-pool.js.map +1 -1
- package/dist/account-resolution.d.ts +3 -0
- package/dist/account-resolution.d.ts.map +1 -1
- package/dist/account-resolution.js +1 -0
- package/dist/account-resolution.js.map +1 -1
- package/dist/attemptTelemetry.d.ts +4 -6
- package/dist/attemptTelemetry.d.ts.map +1 -1
- package/dist/attemptTelemetry.js +1 -1
- package/dist/attemptTelemetry.js.map +1 -1
- package/dist/budgetFailure.d.ts +4 -1
- package/dist/budgetFailure.d.ts.map +1 -1
- package/dist/budgetFailure.js +4 -2
- package/dist/budgetFailure.js.map +1 -1
- package/dist/candidateEvidence.d.ts.map +1 -1
- package/dist/candidateEvidence.js +7 -2
- package/dist/candidateEvidence.js.map +1 -1
- package/dist/candidateOutputs.d.ts.map +1 -1
- package/dist/candidateOutputs.js +6 -0
- package/dist/candidateOutputs.js.map +1 -1
- package/dist/candidateReview.d.ts +3 -1
- package/dist/candidateReview.d.ts.map +1 -1
- package/dist/candidateReview.js +6 -1
- package/dist/candidateReview.js.map +1 -1
- package/dist/candidateTerminals.d.ts +12 -1
- package/dist/candidateTerminals.d.ts.map +1 -1
- package/dist/candidateTerminals.js +51 -21
- package/dist/candidateTerminals.js.map +1 -1
- package/dist/captureRefusal.d.ts +28 -0
- package/dist/captureRefusal.d.ts.map +1 -0
- package/dist/captureRefusal.js +54 -0
- package/dist/captureRefusal.js.map +1 -0
- package/dist/continuity-terminal.d.ts +3 -1
- package/dist/continuity-terminal.d.ts.map +1 -1
- package/dist/continuity-terminal.js.map +1 -1
- package/dist/contract-gates.d.ts +10 -2
- package/dist/contract-gates.d.ts.map +1 -1
- package/dist/contract-gates.js +14 -1
- package/dist/contract-gates.js.map +1 -1
- package/dist/credential-profile-rotation.js +2 -3
- package/dist/credential-profile-rotation.js.map +1 -1
- package/dist/delegationFailure.d.ts +104 -7
- package/dist/delegationFailure.d.ts.map +1 -1
- package/dist/delegationFailure.js +47 -31
- package/dist/delegationFailure.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/inrun-continuity-types.d.ts +13 -1
- package/dist/inrun-continuity-types.d.ts.map +1 -1
- package/dist/inrun-continuity.d.ts +9 -2
- package/dist/inrun-continuity.d.ts.map +1 -1
- package/dist/inrun-continuity.js +43 -23
- package/dist/inrun-continuity.js.map +1 -1
- package/dist/inrun-continuity.test-support.d.ts +6 -2
- package/dist/inrun-continuity.test-support.d.ts.map +1 -1
- package/dist/inrun-continuity.test-support.js +4 -1
- package/dist/inrun-continuity.test-support.js.map +1 -1
- package/dist/orchestrator-credentials.d.ts +5 -4
- package/dist/orchestrator-credentials.d.ts.map +1 -1
- package/dist/orchestrator-credentials.js +7 -4
- package/dist/orchestrator-credentials.js.map +1 -1
- package/dist/orchestrator.d.ts +11 -3
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +341 -414
- package/dist/orchestrator.js.map +1 -1
- package/dist/persistedPatch.js +2 -2
- package/dist/persistedPatch.js.map +1 -1
- package/dist/pool-attempt-evidence.d.ts +62 -0
- package/dist/pool-attempt-evidence.d.ts.map +1 -0
- package/dist/pool-attempt-evidence.js +153 -0
- package/dist/pool-attempt-evidence.js.map +1 -0
- package/dist/pre-progress-refusal.d.ts +43 -6
- package/dist/pre-progress-refusal.d.ts.map +1 -1
- package/dist/pre-progress-refusal.js +53 -8
- package/dist/pre-progress-refusal.js.map +1 -1
- package/dist/readonlyTerminals.d.ts +55 -0
- package/dist/readonlyTerminals.d.ts.map +1 -0
- package/dist/readonlyTerminals.js +205 -0
- package/dist/readonlyTerminals.js.map +1 -0
- package/dist/reviewEvidence.d.ts +4 -0
- package/dist/reviewEvidence.d.ts.map +1 -0
- package/dist/reviewEvidence.js +46 -0
- package/dist/reviewEvidence.js.map +1 -0
- package/dist/rotation-predicate.d.ts +7 -23
- package/dist/rotation-predicate.d.ts.map +1 -1
- package/dist/rotation-predicate.js +45 -0
- package/dist/rotation-predicate.js.map +1 -1
- package/dist/runEventLog.d.ts +1 -0
- package/dist/runEventLog.d.ts.map +1 -1
- package/dist/runEventLog.js +3 -2
- package/dist/runEventLog.js.map +1 -1
- package/dist/runScope.d.ts +86 -0
- package/dist/runScope.d.ts.map +1 -0
- package/dist/runScope.js +181 -0
- package/dist/runScope.js.map +1 -0
- package/dist/runTerminalContext.d.ts +4 -0
- package/dist/runTerminalContext.d.ts.map +1 -1
- package/dist/runTerminalContext.js.map +1 -1
- package/dist/runTerminalHelpers.d.ts +50 -0
- package/dist/runTerminalHelpers.d.ts.map +1 -0
- package/dist/runTerminalHelpers.js +200 -0
- package/dist/runTerminalHelpers.js.map +1 -0
- package/dist/runTerminalResults.d.ts +25 -3
- package/dist/runTerminalResults.d.ts.map +1 -1
- package/dist/runTerminalResults.js +61 -29
- package/dist/runTerminalResults.js.map +1 -1
- package/dist/runTerminals.d.ts +1 -12
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +113 -140
- package/dist/runTerminals.js.map +1 -1
- package/dist/secretDiff.d.ts +14 -11
- package/dist/secretDiff.d.ts.map +1 -1
- package/dist/secretDiff.js +21 -28
- package/dist/secretDiff.js.map +1 -1
- package/dist/terminalOutcome.d.ts +24 -4
- package/dist/terminalOutcome.d.ts.map +1 -1
- package/dist/terminalOutcome.js +32 -5
- package/dist/terminalOutcome.js.map +1 -1
- package/package.json +17 -17
package/dist/persistedPatch.js
CHANGED
|
@@ -13,7 +13,7 @@ import { containsSecretLikeToken, redactSecrets, sensitiveResourcePolicy } from
|
|
|
13
13
|
export const PERSISTED_PATCH_NOTICE = "# Claudexor: secret-like strings are replaced with [redacted] in this saved copy. " +
|
|
14
14
|
"The real bytes stay in the candidate's changed files and in Claudexor's private exact patch object; " +
|
|
15
15
|
"a reviewer workspace copy omits files with secret-like content. Apply through Claudexor, never from this copy.";
|
|
16
|
-
const BINARY_PAYLOAD_WITHHELD = "# Claudexor: binary payload withheld from this saved copy (secret-like bytes)";
|
|
16
|
+
const BINARY_PAYLOAD_WITHHELD = "# Claudexor: binary payload withheld from this saved copy (secret-like or uninspectable bytes)";
|
|
17
17
|
const FILE_RECORD_START = /^(?:diff .+|Binary files .+ differ)$/gm;
|
|
18
18
|
/** Lines that carry diff structure, never file content. Inside a multi-line
|
|
19
19
|
* match they stay verbatim, so every file record and hunk of the copy survives. */
|
|
@@ -120,7 +120,7 @@ export function secretLikeSummaryLine(finding) {
|
|
|
120
120
|
parts.push(`${inPatch} in ${paths.length} changed file(s)${paths.length > 0 ? ` (${named(paths)})` : ""} — kept in the changed files, hidden in saved copies`);
|
|
121
121
|
}
|
|
122
122
|
if (finding.binary_paths.length > 0) {
|
|
123
|
-
parts.push(`${finding.binary_paths.length} binary payload(s) withheld from the saved patch (${named(finding.binary_paths)})`);
|
|
123
|
+
parts.push(`${finding.binary_paths.length} secret-like or uninspectable binary payload(s) withheld from the saved patch (${named(finding.binary_paths)})`);
|
|
124
124
|
}
|
|
125
125
|
if (finding.answer_matches > 0)
|
|
126
126
|
parts.push(`${finding.answer_matches} hidden in the answer`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistedPatch.js","sourceRoot":"","sources":["../src/persistedPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAElG;;;;;;GAMG;AAEH;;iFAEiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GACjC,oFAAoF;IACpF,sGAAsG;IACtG,gHAAgH,CAAC;AAEnH,MAAM,uBAAuB,GAC3B
|
|
1
|
+
{"version":3,"file":"persistedPatch.js","sourceRoot":"","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,CAAC,IAAI,CACR,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,wBAAwB,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CACzF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,0BAA0B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type HarnessEvent, type HarnessRunSpec, type PoolAttemptFailure, type RunOutcomeFacts, type VendorFailureEvidence } from "@claudexor/schema";
|
|
2
|
+
import type { TryFacts } from "./inrun-continuity-types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Per-try account attribution of one attempt (diagnostic evidence only): every
|
|
5
|
+
* ACTUAL try that ended in an error, with the row it ran on and its own error
|
|
6
|
+
* text in order, so a pool failure names each account's refusal instead of only
|
|
7
|
+
* the last one. The in-run controller opens a row at `beginTry`, observes the
|
|
8
|
+
* stream, and settles it once in `afterTry`. Only a PHYSICAL try counts: the
|
|
9
|
+
* gate's own dispatch callback marks it, so a selected successor whose account
|
|
10
|
+
* failed earlier (model inventory, processing or billing preparation) has no
|
|
11
|
+
* row, while an adapter that fails on entry, before its typed start, keeps one.
|
|
12
|
+
* Cancelled, budget-stopped and request-refused tries are not account evidence,
|
|
13
|
+
* and a try whose own events name another account is not attributed to this
|
|
14
|
+
* one. Building a row never throws: a malformed event time falls back to the
|
|
15
|
+
* settlement clock instead of replacing the original error.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PoolAttemptEvidence {
|
|
18
|
+
private readonly harnessId;
|
|
19
|
+
private readonly attemptId;
|
|
20
|
+
private readonly now;
|
|
21
|
+
private readonly rows;
|
|
22
|
+
private open;
|
|
23
|
+
constructor(harnessId: string, attemptId: string, now?: () => Date);
|
|
24
|
+
begin(spec: HarnessRunSpec, tryIndex: number): void;
|
|
25
|
+
observe(event: HarnessEvent): void;
|
|
26
|
+
settle(facts: Pick<TryFacts, "harnessErrored" | "aborted" | "budgetStopped" | "requestRefused" | "originalError" | "newTransients" | "markers">): void;
|
|
27
|
+
snapshot(): PoolAttemptFailure[];
|
|
28
|
+
}
|
|
29
|
+
/** Vendor text was redacted at event ingress; redact again like safeMessage (INV-062). */
|
|
30
|
+
export declare function redactVendorFailure(vendor: VendorFailureEvidence): VendorFailureEvidence;
|
|
31
|
+
/** Every failed try of these attempts, in attempt order. */
|
|
32
|
+
export declare function poolAttemptsOf(items: readonly {
|
|
33
|
+
poolAttempts?: readonly PoolAttemptFailure[];
|
|
34
|
+
}[]): PoolAttemptFailure[];
|
|
35
|
+
/**
|
|
36
|
+
* The list a strategy's own terminal names, decided by its actual outcome (the
|
|
37
|
+
* same axes that choose run.completed/run.blocked/run.failed): every failed try
|
|
38
|
+
* on a failure, a cancellation or a D8 decision/input block; none on a clean
|
|
39
|
+
* completion. The block or cancellation itself is never an account row.
|
|
40
|
+
*/
|
|
41
|
+
export declare function terminalPoolAttempts(facts: RunOutcomeFacts, items: readonly {
|
|
42
|
+
poolAttempts?: readonly PoolAttemptFailure[];
|
|
43
|
+
}[]): PoolAttemptFailure[];
|
|
44
|
+
/**
|
|
45
|
+
* The ONE human rendering of a pool failure, shared by every failure terminal
|
|
46
|
+
* (failure.yaml `safeMessage`, `run.failed` error, summary.md and the returned
|
|
47
|
+
* summary): the terminal's own message, then each failed try with its account
|
|
48
|
+
* and its own error text. The structured list rides beside it unchanged.
|
|
49
|
+
*/
|
|
50
|
+
export declare function withPoolAttempts(message: string, attempts: readonly PoolAttemptFailure[]): string;
|
|
51
|
+
/** A failure terminal's message and list from its attempts, in one step. */
|
|
52
|
+
export declare function poolFailure(message: string, items: readonly {
|
|
53
|
+
poolAttempts?: readonly PoolAttemptFailure[];
|
|
54
|
+
}[]): {
|
|
55
|
+
message: string;
|
|
56
|
+
poolAttempts: PoolAttemptFailure[];
|
|
57
|
+
};
|
|
58
|
+
/** An in-run `route.profile.rotation_exhausted`: each candidate keeps its
|
|
59
|
+
* rejection facts and gains its own failed tries; the ordered list rides
|
|
60
|
+
* beside, so a row deleted mid-run still names its failure exactly once. */
|
|
61
|
+
export declare function withRotationAttempts(payload: Record<string, unknown>, attempts: readonly PoolAttemptFailure[]): Record<string, unknown>;
|
|
62
|
+
//# sourceMappingURL=pool-attempt-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-attempt-evidence.d.ts","sourceRoot":"","sources":["../src/pool-attempt-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAiB5D;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IANtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,IAAI,CAAwB;IAEpC,YACmB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,GAAE,MAAM,IAAuB,EACjD;IAEJ,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQlD;IAED,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAUjC;IAED,MAAM,CACJ,KAAK,EAAE,IAAI,CACT,QAAQ,EACN,gBAAgB,GAChB,SAAS,GACT,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,SAAS,CACZ,GACA,IAAI,CA6BN;IAED,QAAQ,IAAI,kBAAkB,EAAE,CAE/B;CACF;AAOD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAMxF;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS;IAAE,YAAY,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,EAAE,GACjE,kBAAkB,EAAE,CAEtB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,SAAS;IAAE,YAAY,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,EAAE,GACjE,kBAAkB,EAAE,CAGtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,CAUjG;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS;IAAE,YAAY,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,EAAE,GACjE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAGzD;AAED;;4EAE4E;AAC5E,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GACtC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { needsOperatorAttention, } from "@claudexor/schema";
|
|
2
|
+
import { redactSecrets } from "@claudexor/util";
|
|
3
|
+
import { dominantHarnessFailureCategory } from "./harnessFailure.js";
|
|
4
|
+
/** The admission gate's callback, fired once a send is admitted, right before
|
|
5
|
+
* its adapter runs (`admitCurrentProfileDispatch`). */
|
|
6
|
+
const DISPATCH = "markPhysicalDispatchStarted";
|
|
7
|
+
/**
|
|
8
|
+
* Per-try account attribution of one attempt (diagnostic evidence only): every
|
|
9
|
+
* ACTUAL try that ended in an error, with the row it ran on and its own error
|
|
10
|
+
* text in order, so a pool failure names each account's refusal instead of only
|
|
11
|
+
* the last one. The in-run controller opens a row at `beginTry`, observes the
|
|
12
|
+
* stream, and settles it once in `afterTry`. Only a PHYSICAL try counts: the
|
|
13
|
+
* gate's own dispatch callback marks it, so a selected successor whose account
|
|
14
|
+
* failed earlier (model inventory, processing or billing preparation) has no
|
|
15
|
+
* row, while an adapter that fails on entry, before its typed start, keeps one.
|
|
16
|
+
* Cancelled, budget-stopped and request-refused tries are not account evidence,
|
|
17
|
+
* and a try whose own events name another account is not attributed to this
|
|
18
|
+
* one. Building a row never throws: a malformed event time falls back to the
|
|
19
|
+
* settlement clock instead of replacing the original error.
|
|
20
|
+
*/
|
|
21
|
+
export class PoolAttemptEvidence {
|
|
22
|
+
harnessId;
|
|
23
|
+
attemptId;
|
|
24
|
+
now;
|
|
25
|
+
rows = [];
|
|
26
|
+
open = null;
|
|
27
|
+
constructor(harnessId, attemptId, now = () => new Date()) {
|
|
28
|
+
this.harnessId = harnessId;
|
|
29
|
+
this.attemptId = attemptId;
|
|
30
|
+
this.now = now;
|
|
31
|
+
}
|
|
32
|
+
begin(spec, tryIndex) {
|
|
33
|
+
const gate = spec.extra[DISPATCH];
|
|
34
|
+
const open = { spec, tryIndex, error: null, at: null, foreign: false, gate };
|
|
35
|
+
this.open = open;
|
|
36
|
+
spec.extra[DISPATCH] = () => {
|
|
37
|
+
open.dispatched = true;
|
|
38
|
+
if (typeof gate === "function")
|
|
39
|
+
gate();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
observe(event) {
|
|
43
|
+
const open = this.open;
|
|
44
|
+
if (!open)
|
|
45
|
+
return;
|
|
46
|
+
const bound = open.spec.credential_profile?.profile_id ?? null;
|
|
47
|
+
if (event.credential_profile_id !== undefined && event.credential_profile_id !== bound)
|
|
48
|
+
open.foreign = true;
|
|
49
|
+
if (event.type === "error" && open.error === null) {
|
|
50
|
+
open.error = event.error ?? event.text ?? null;
|
|
51
|
+
open.at = event.ts;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
settle(facts) {
|
|
55
|
+
const open = this.open;
|
|
56
|
+
this.open = null; // one settlement per try, whatever the caller repeats
|
|
57
|
+
if (!open)
|
|
58
|
+
return;
|
|
59
|
+
// Successors copy this spec after settlement: they wrap the gate, never this try.
|
|
60
|
+
open.spec.extra[DISPATCH] = open.gate;
|
|
61
|
+
if (open.foreign || !open.dispatched || !facts.harnessErrored)
|
|
62
|
+
return;
|
|
63
|
+
if (facts.aborted || facts.budgetStopped || facts.requestRefused)
|
|
64
|
+
return;
|
|
65
|
+
const profile = open.spec.credential_profile ?? null;
|
|
66
|
+
const vendor = [...facts.newTransients].reverse().find((t) => t.vendorFailure)?.vendorFailure;
|
|
67
|
+
this.rows.push({
|
|
68
|
+
harnessId: this.harnessId,
|
|
69
|
+
profileId: profile?.profile_id ?? null,
|
|
70
|
+
profileDisplayName: profile ? redactSecrets(profile.display_name) : null,
|
|
71
|
+
requestedModel: open.spec.model_hint ?? null,
|
|
72
|
+
attemptId: this.attemptId,
|
|
73
|
+
tryIndex: open.tryIndex,
|
|
74
|
+
observedAt: isoOr(open.at, this.now),
|
|
75
|
+
phase: facts.markers.sawAgentProgress
|
|
76
|
+
? "after_progress"
|
|
77
|
+
: facts.markers.sawSessionStart
|
|
78
|
+
? "pre_progress"
|
|
79
|
+
: "pre_start",
|
|
80
|
+
category: dominantHarnessFailureCategory([...facts.newTransients]) ?? "unknown_harness_error",
|
|
81
|
+
error: redactSecrets(open.error ?? facts.originalError ?? "the try ended in an error without a message"),
|
|
82
|
+
vendorFailure: vendor ? redactVendorFailure(vendor) : null,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
snapshot() {
|
|
86
|
+
return this.rows.map((row) => ({ ...row }));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function isoOr(value, now) {
|
|
90
|
+
const at = value === null ? Number.NaN : Date.parse(value);
|
|
91
|
+
return new Date(Number.isFinite(at) ? at : now().getTime()).toISOString();
|
|
92
|
+
}
|
|
93
|
+
/** Vendor text was redacted at event ingress; redact again like safeMessage (INV-062). */
|
|
94
|
+
export function redactVendorFailure(vendor) {
|
|
95
|
+
return {
|
|
96
|
+
code: vendor.code === null ? null : redactSecrets(vendor.code),
|
|
97
|
+
message: vendor.message === null ? null : redactSecrets(vendor.message),
|
|
98
|
+
source: vendor.source,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Every failed try of these attempts, in attempt order. */
|
|
102
|
+
export function poolAttemptsOf(items) {
|
|
103
|
+
return items.flatMap((item) => item.poolAttempts ?? []);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The list a strategy's own terminal names, decided by its actual outcome (the
|
|
107
|
+
* same axes that choose run.completed/run.blocked/run.failed): every failed try
|
|
108
|
+
* on a failure, a cancellation or a D8 decision/input block; none on a clean
|
|
109
|
+
* completion. The block or cancellation itself is never an account row.
|
|
110
|
+
*/
|
|
111
|
+
export function terminalPoolAttempts(facts, items) {
|
|
112
|
+
const clean = facts.lifecycle === "succeeded" && !needsOperatorAttention(facts, false);
|
|
113
|
+
return clean ? [] : poolAttemptsOf(items);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The ONE human rendering of a pool failure, shared by every failure terminal
|
|
117
|
+
* (failure.yaml `safeMessage`, `run.failed` error, summary.md and the returned
|
|
118
|
+
* summary): the terminal's own message, then each failed try with its account
|
|
119
|
+
* and its own error text. The structured list rides beside it unchanged.
|
|
120
|
+
*/
|
|
121
|
+
export function withPoolAttempts(message, attempts) {
|
|
122
|
+
if (attempts.length === 0)
|
|
123
|
+
return message;
|
|
124
|
+
const lines = attempts.map((a) => {
|
|
125
|
+
const label = a.profileDisplayName && a.profileDisplayName !== a.profileId
|
|
126
|
+
? ` (${a.profileDisplayName})`
|
|
127
|
+
: "";
|
|
128
|
+
return `- ${a.harnessId}/${a.profileId ?? "default"}${label} · ${a.requestedModel ?? "default model"} · ${a.attemptId} try ${a.tryIndex + 1} · ${a.phase.replace("_", " ")} · ${a.category}: ${a.error}`;
|
|
129
|
+
});
|
|
130
|
+
return `${message}\n\nAccount attempts:\n${lines.join("\n")}`;
|
|
131
|
+
}
|
|
132
|
+
/** A failure terminal's message and list from its attempts, in one step. */
|
|
133
|
+
export function poolFailure(message, items) {
|
|
134
|
+
const poolAttempts = poolAttemptsOf(items);
|
|
135
|
+
return { message: withPoolAttempts(message, poolAttempts), poolAttempts };
|
|
136
|
+
}
|
|
137
|
+
/** An in-run `route.profile.rotation_exhausted`: each candidate keeps its
|
|
138
|
+
* rejection facts and gains its own failed tries; the ordered list rides
|
|
139
|
+
* beside, so a row deleted mid-run still names its failure exactly once. */
|
|
140
|
+
export function withRotationAttempts(payload, attempts) {
|
|
141
|
+
const candidates = Array.isArray(payload["candidates"])
|
|
142
|
+
? payload["candidates"]
|
|
143
|
+
: [];
|
|
144
|
+
return {
|
|
145
|
+
...payload,
|
|
146
|
+
candidates: candidates.map((candidate) => ({
|
|
147
|
+
...candidate,
|
|
148
|
+
attempt_failures: attempts.filter((a) => a.profileId === candidate["profile_id"]),
|
|
149
|
+
})),
|
|
150
|
+
pool_attempts: attempts,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=pool-attempt-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-attempt-evidence.js","sourceRoot":"","sources":["../src/pool-attempt-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAMvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAGrE;uDACuD;AACvD,MAAM,QAAQ,GAAG,6BAA6B,CAAC;AAa/C;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AAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;IAC3M,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,OAAO,0BAA0B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,KAAkE;IAElE,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;AAC5E,CAAC;AAED;;4EAE4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,OAAgC,EAChC,QAAuC;IAEvC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACrD,CAAC,CAAE,OAAO,CAAC,YAAY,CAA+B;QACtD,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;QACL,GAAG,OAAO;QACV,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YACzC,GAAG,SAAS;YACZ,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,YAAY,CAAC,CAAC;SAClF,CAAC,CAAC;QACH,aAAa,EAAE,QAAQ;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cross-run memory of a pool account's PRE-PROGRESS REFUSAL (#363)
|
|
2
|
+
* Cross-run memory of a pool account's PRE-PROGRESS REFUSAL (#363), and its
|
|
3
|
+
* positive twin: the LAST-SERVED fact (INV-135 tie-break).
|
|
3
4
|
*
|
|
4
5
|
* The structural rotation branch (`structural_pre_progress_failure`) already
|
|
5
6
|
* moves one run off an account whose vendor refused it before any work, without
|
|
@@ -13,10 +14,29 @@
|
|
|
13
14
|
* Only a session the adapter reported as STARTED counts: an adapter's own
|
|
14
15
|
* pre-spawn refusal — a readiness probe that could not confirm the login, a
|
|
15
16
|
* misconfigured route — is not the vendor refusing the account.
|
|
17
|
+
*
|
|
18
|
+
* The same served predicate (typed agent progress, or an error-free delivery)
|
|
19
|
+
* that clears a mark records that the account served this REQUEST under its
|
|
20
|
+
* requested-model key. The vendor's model label is never compared with the
|
|
21
|
+
* request: aliases and picker selectors are answered under resolved names, and
|
|
22
|
+
* a served request proves the account works, not which model answered it.
|
|
16
23
|
*/
|
|
17
|
-
import type { HarnessRunSpec, PreProgressRefusalObservation } from "@claudexor/schema";
|
|
24
|
+
import type { CredentialProfile, HarnessEvent, HarnessRunSpec, PreProgressRefusalObservation } from "@claudexor/schema";
|
|
18
25
|
import type { AttemptOutputMarkers } from "./attemptOutputMarkers.js";
|
|
19
|
-
import { type RotationEvidence } from "./rotation-predicate.js";
|
|
26
|
+
import { reactiveRotationEvidence, type RotationEvidence } from "./rotation-predicate.js";
|
|
27
|
+
/** The try that served: dedupe and producer-bound retraction key. */
|
|
28
|
+
export interface ServiceProducer {
|
|
29
|
+
runId: string;
|
|
30
|
+
attemptId: string;
|
|
31
|
+
tryIndex: number;
|
|
32
|
+
}
|
|
33
|
+
/** The orchestrator's view of the daemon's durable last-served facts. */
|
|
34
|
+
export interface AccountServiceMemory {
|
|
35
|
+
serve(profile: CredentialProfile, model: string | null, producer: ServiceProducer): void;
|
|
36
|
+
retract(profile: CredentialProfile, model: string | null, producer: ServiceProducer): void;
|
|
37
|
+
/** Service order per row for ONE ranking (higher = served more recently). */
|
|
38
|
+
orders(harnessId: string, model: string | null, profiles: readonly CredentialProfile[]): ReadonlyMap<string, number>;
|
|
39
|
+
}
|
|
20
40
|
/** The orchestrator's view of the daemon-owned bounded ledger. */
|
|
21
41
|
export interface PreProgressRefusalMemory {
|
|
22
42
|
live(): readonly PreProgressRefusalObservation[];
|
|
@@ -24,9 +44,14 @@ export interface PreProgressRefusalMemory {
|
|
|
24
44
|
generation(harnessId: string, profileId: string): number;
|
|
25
45
|
record(value: Omit<PreProgressRefusalObservation, "observed_at" | "expires_at">): void;
|
|
26
46
|
clear(harnessId: string, profileId: string, requestedModel: string | null): void;
|
|
47
|
+
/** Durable last-served facts; absent = nothing durable (library embedders). */
|
|
48
|
+
services?: AccountServiceMemory | null;
|
|
27
49
|
}
|
|
28
50
|
/** One try's outcome sink, bound before its session spawns. */
|
|
29
51
|
export interface PreProgressRefusalSubject {
|
|
52
|
+
/** One stream event of the try: typed agent progress serves the request; an
|
|
53
|
+
* event naming another account or a non-subscription route retracts. */
|
|
54
|
+
observe(event: HarnessEvent, markers: AttemptOutputMarkers): void;
|
|
30
55
|
note(): void;
|
|
31
56
|
noteServed(markers: AttemptOutputMarkers, delivered: boolean): void;
|
|
32
57
|
/** The account's credential is still the generation this try bound: no
|
|
@@ -40,6 +65,17 @@ export interface PreProgressRefusalSubject {
|
|
|
40
65
|
* registry already records it as a cooldown the pool ranks as exhausted.
|
|
41
66
|
*/
|
|
42
67
|
export declare function refusedBeforeProgress(evidence: RotationEvidence, markers: AttemptOutputMarkers): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Note THIS row's started-then-refused try, read from the try's own settled
|
|
70
|
+
* facts; a pin or a profile-less default never records one. The rotation step
|
|
71
|
+
* notes it, and so does a run stopped after the try settled, which then
|
|
72
|
+
* probes, rotates and retries nothing.
|
|
73
|
+
*/
|
|
74
|
+
export declare function noteRefusedBeforeProgress(args: Parameters<typeof reactiveRotationEvidence>[0] & {
|
|
75
|
+
spec: Pick<HarnessRunSpec, "credential_profile">;
|
|
76
|
+
pinned?: boolean;
|
|
77
|
+
notePreProgressRefusal?: () => void;
|
|
78
|
+
}): void;
|
|
43
79
|
/**
|
|
44
80
|
* Bind one try's subject — (harness, subscription account, requested model) —
|
|
45
81
|
* to the memory, BEFORE the try's session spawns. Null when there is nothing
|
|
@@ -49,10 +85,11 @@ export declare function refusedBeforeProgress(evidence: RotationEvidence, marker
|
|
|
49
85
|
* The binding also holds the account's credential generation: a profile
|
|
50
86
|
* mutation or login/logout does not wait for runs in flight, so an outcome
|
|
51
87
|
* arriving after one is about a credential that change already voided. It
|
|
52
|
-
* neither recreates the mark the change cleared nor clears a
|
|
53
|
-
* recorded about the changed credential.
|
|
88
|
+
* neither recreates the mark or service fact the change cleared nor clears a
|
|
89
|
+
* mark a later try recorded about the changed credential. The store write
|
|
90
|
+
* follows the generation check synchronously, so no clear can land between.
|
|
54
91
|
*/
|
|
55
|
-
export declare function preProgressRefusalSubject(memory: PreProgressRefusalMemory | undefined, harnessId: string, spec: Pick<HarnessRunSpec, "credential_profile" | "model_hint"
|
|
92
|
+
export declare function preProgressRefusalSubject(memory: PreProgressRefusalMemory | undefined, harnessId: string, spec: Pick<HarnessRunSpec, "credential_profile" | "model_hint">, producer?: ServiceProducer): PreProgressRefusalSubject | null;
|
|
56
93
|
/**
|
|
57
94
|
* The latest live mark per account for this harness and requested model — the
|
|
58
95
|
* instant the pool orders a demoted row by (oldest mark first).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-progress-refusal.d.ts","sourceRoot":"","sources":["../src/pre-progress-refusal.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pre-progress-refusal.d.ts","sourceRoot":"","sources":["../src/pre-progress-refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,6BAA6B,EAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACL,wBAAwB,EAExB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,qEAAqE;AACrE,MAAM,WA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AAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACpE;gEAC4D;IAC5D,OAAO,IAAI,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,GAAG;IACrD,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC,GACA,IAAI,CAIN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,wBAAwB,GAAG,SAAS,EAC5C,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,oBAAoB,GAAG,YAAY,CAAC,EAC/D,QAAQ,CAAC,EAAE,eAAe,GACzB,yBAAyB,GAAG,IAAI,CAmDlC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,6BAA6B,EAAE,EAClD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,GACV,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rotationRetryEligible } from "./rotation-predicate.js";
|
|
1
|
+
import { reactiveRotationEvidence, rotationRetryEligible, } from "./rotation-predicate.js";
|
|
2
2
|
/**
|
|
3
3
|
* The try's vendor session started and then ended in the structural branch's
|
|
4
4
|
* own evidence: a terminal non-transient death with no agent progress, no
|
|
@@ -8,6 +8,18 @@ import { rotationRetryEligible } from "./rotation-predicate.js";
|
|
|
8
8
|
export function refusedBeforeProgress(evidence, markers) {
|
|
9
9
|
return (!evidence.sawTypedLimit && markers.sawSessionStart === true && rotationRetryEligible(evidence));
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Note THIS row's started-then-refused try, read from the try's own settled
|
|
13
|
+
* facts; a pin or a profile-less default never records one. The rotation step
|
|
14
|
+
* notes it, and so does a run stopped after the try settled, which then
|
|
15
|
+
* probes, rotates and retries nothing.
|
|
16
|
+
*/
|
|
17
|
+
export function noteRefusedBeforeProgress(args) {
|
|
18
|
+
if (args.pinned || !args.spec.credential_profile)
|
|
19
|
+
return;
|
|
20
|
+
if (refusedBeforeProgress(reactiveRotationEvidence(args), args.markers))
|
|
21
|
+
args.notePreProgressRefusal?.();
|
|
22
|
+
}
|
|
11
23
|
/**
|
|
12
24
|
* Bind one try's subject — (harness, subscription account, requested model) —
|
|
13
25
|
* to the memory, BEFORE the try's session spawns. Null when there is nothing
|
|
@@ -17,17 +29,49 @@ export function refusedBeforeProgress(evidence, markers) {
|
|
|
17
29
|
* The binding also holds the account's credential generation: a profile
|
|
18
30
|
* mutation or login/logout does not wait for runs in flight, so an outcome
|
|
19
31
|
* arriving after one is about a credential that change already voided. It
|
|
20
|
-
* neither recreates the mark the change cleared nor clears a
|
|
21
|
-
* recorded about the changed credential.
|
|
32
|
+
* neither recreates the mark or service fact the change cleared nor clears a
|
|
33
|
+
* mark a later try recorded about the changed credential. The store write
|
|
34
|
+
* follows the generation check synchronously, so no clear can land between.
|
|
22
35
|
*/
|
|
23
|
-
export function preProgressRefusalSubject(memory, harnessId, spec) {
|
|
36
|
+
export function preProgressRefusalSubject(memory, harnessId, spec, producer) {
|
|
24
37
|
const profile = spec.credential_profile ?? null;
|
|
25
38
|
if (!memory || !profile || profile.credential_kind === "api_key")
|
|
26
39
|
return null;
|
|
27
40
|
const requestedModel = spec.model_hint ?? null;
|
|
28
41
|
const generation = memory.generation(harnessId, profile.profile_id);
|
|
29
42
|
const unchanged = () => memory.generation(harnessId, profile.profile_id) === generation;
|
|
43
|
+
const services = producer ? (memory.services ?? null) : null;
|
|
44
|
+
let served = false;
|
|
45
|
+
let foreign = false;
|
|
46
|
+
// Ordering evidence must never fail the try that produced it.
|
|
47
|
+
const write = (action) => {
|
|
48
|
+
try {
|
|
49
|
+
if (services)
|
|
50
|
+
action(services);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
/* the daemon logs its own write failures */
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const serve = () => {
|
|
57
|
+
if (served || foreign || !services || !unchanged())
|
|
58
|
+
return;
|
|
59
|
+
served = true;
|
|
60
|
+
write((store) => store.serve(profile, requestedModel, producer));
|
|
61
|
+
};
|
|
30
62
|
return {
|
|
63
|
+
observe: (event, markers) => {
|
|
64
|
+
if ((event.credential_profile_id !== undefined &&
|
|
65
|
+
event.credential_profile_id !== profile.profile_id) ||
|
|
66
|
+
(event.credential_route !== undefined && event.credential_route !== "vendor_native")) {
|
|
67
|
+
// The try itself says it is not this account's subscription session.
|
|
68
|
+
if (served && !foreign)
|
|
69
|
+
write((store) => store.retract(profile, requestedModel, producer));
|
|
70
|
+
foreign = true;
|
|
71
|
+
}
|
|
72
|
+
else if (markers.sawAgentProgress)
|
|
73
|
+
serve();
|
|
74
|
+
},
|
|
31
75
|
note: () => {
|
|
32
76
|
if (!unchanged())
|
|
33
77
|
return;
|
|
@@ -38,11 +82,12 @@ export function preProgressRefusalSubject(memory, harnessId, spec) {
|
|
|
38
82
|
});
|
|
39
83
|
},
|
|
40
84
|
// Agent progress, or an error-free try that delivered, proves the account
|
|
41
|
-
// served this
|
|
85
|
+
// served this request; a cancelled or empty try proves nothing.
|
|
42
86
|
noteServed: (markers, delivered) => {
|
|
43
|
-
if (unchanged()
|
|
44
|
-
|
|
45
|
-
|
|
87
|
+
if (foreign || !unchanged() || !(markers.sawAgentProgress || delivered))
|
|
88
|
+
return;
|
|
89
|
+
memory.clear(harnessId, profile.profile_id, requestedModel);
|
|
90
|
+
serve();
|
|
46
91
|
},
|
|
47
92
|
current: unchanged,
|
|
48
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-progress-refusal.js","sourceRoot":"","sources":["../src/pre-progress-refusal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pre-progress-refusal.js","sourceRoot":"","sources":["../src/pre-progress-refusal.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AA4CjC;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA0B,EAC1B,OAA6B;IAE7B,OAAO,CACL,CAAC,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,eAAe,KAAK,IAAI,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAC/F,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAIC;IAED,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB;QAAE,OAAO;IACzD,IAAI,qBAAqB,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC;QACrE,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA4C,EAC5C,SAAiB,EACjB,IAA+D,EAC/D,QAA0B;IAE1B,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC;IAChD,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC9E,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAA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CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,GAAG;YAAE,SAAS;QACxF,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ArtifactStore, RunPaths } from "@claudexor/artifact-store";
|
|
2
|
+
import type { BudgetLedger } from "@claudexor/budget";
|
|
3
|
+
import type { EventLog } from "@claudexor/event-log";
|
|
4
|
+
import { type ModeKind } from "@claudexor/schema";
|
|
5
|
+
import type { OrchestratorResult } from "./orchestrator.js";
|
|
6
|
+
import type { AttemptTelemetry } from "./attemptTelemetry.js";
|
|
7
|
+
import { type BudgetDenial } from "./budgetFailure.js";
|
|
8
|
+
import { type ContinuityTerminalFacts } from "./continuity-terminal.js";
|
|
9
|
+
import { type declaredFailure } from "./runTerminalResults.js";
|
|
10
|
+
/** One read-only (Ask/Plan chain or deep-scan scout) attempt as its terminals see it. */
|
|
11
|
+
export interface ReadonlyAttempt extends ContinuityTerminalFacts {
|
|
12
|
+
attemptId: string;
|
|
13
|
+
harnessId: string;
|
|
14
|
+
status: "success" | "failed" | "blocked";
|
|
15
|
+
report: string;
|
|
16
|
+
answerMatches?: number;
|
|
17
|
+
error: string | null;
|
|
18
|
+
telemetry: AttemptTelemetry;
|
|
19
|
+
/** QA-019: this scout was refused BEFORE spawn by the budget gate — it
|
|
20
|
+
* belongs in the denominator/omissions but never ran the harness, so the
|
|
21
|
+
* all-denied terminal still routes through the QA-050 budget classifier. */
|
|
22
|
+
budgetDenied?: boolean;
|
|
23
|
+
/** D-16 r8: scout ran out of context — a failed omission, never reducer
|
|
24
|
+
* input; ALL-interrupted terminalizes interrupted. */
|
|
25
|
+
interrupted?: boolean;
|
|
26
|
+
/** A5: the typed refusal (exhausted credential pool / spent window) this
|
|
27
|
+
* attempt died on, so the chain terminal can speak it machine-readably. */
|
|
28
|
+
declaredFailure?: ReturnType<typeof declaredFailure>;
|
|
29
|
+
}
|
|
30
|
+
interface ReadonlyTerminalContext {
|
|
31
|
+
store: ArtifactStore;
|
|
32
|
+
paths: RunPaths;
|
|
33
|
+
log: EventLog;
|
|
34
|
+
runId: string;
|
|
35
|
+
taskId: string;
|
|
36
|
+
mode: ModeKind;
|
|
37
|
+
ledger: BudgetLedger;
|
|
38
|
+
attempts: ReadonlyAttempt[];
|
|
39
|
+
attemptTelemetries: {
|
|
40
|
+
attemptId: string;
|
|
41
|
+
harnessId: string;
|
|
42
|
+
telemetry: AttemptTelemetry;
|
|
43
|
+
}[];
|
|
44
|
+
budgetStopped: boolean;
|
|
45
|
+
budgetDenial: BudgetDenial | null;
|
|
46
|
+
writeTelemetry(): void;
|
|
47
|
+
}
|
|
48
|
+
/** A read-only chain with no successful attempt (QA-036/QA-050/A5). */
|
|
49
|
+
export declare function readOnlyChainFailureResult(input: ReadonlyTerminalContext & {
|
|
50
|
+
fallbackOpen: boolean;
|
|
51
|
+
}): OrchestratorResult;
|
|
52
|
+
/** A deep scan whose every explorer failed: no synthesizable deliverable (QA-036). */
|
|
53
|
+
export declare function deepScanFailureResult(input: ReadonlyTerminalContext): OrchestratorResult;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=readonlyTerminals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonlyTerminals.d.ts","sourceRoot":"","sources":["../src/readonlyTerminals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD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