@rulvar/core 1.230.0 → 1.231.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/index.d.ts +94 -4
- package/dist/index.js +840 -745
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8794,11 +8794,25 @@ function readRejectedFinishCandidates(raw) {
|
|
|
8794
8794
|
*
|
|
8795
8795
|
* The twenty-fifth comparison run was killed and resumed, and its two
|
|
8796
8796
|
* terminals mixed both kinds with nothing marking which was which: the
|
|
8797
|
-
* money was cumulative, the
|
|
8797
|
+
* money was cumulative, the live-only counters were not,
|
|
8798
8798
|
* and reconciling them into one honest account of the logical run was
|
|
8799
8799
|
* hand work over a joined journal. Keys are field paths as a consumer
|
|
8800
|
-
* reads them off `RunOutcome` (`cost.orchestrator.wakes`)
|
|
8801
|
-
*
|
|
8800
|
+
* reads them off `RunOutcome` (`cost.orchestrator.wakes`): the type
|
|
8801
|
+
* requires every field of the outcome, and the `satisfies` below
|
|
8802
|
+
* requires every counted leaf under `cost` (RV2801), because an index
|
|
8803
|
+
* signature admits nested paths and demands none, so the five that were
|
|
8804
|
+
* declared were declared by hand and by luck while four
|
|
8805
|
+
* (`cost.usageApprox`, `cost.abandoned.usd`, `cost.abandoned.usageApprox`,
|
|
8806
|
+
* `cost.orchestrator.share`) were simply missing. That is the RV2701
|
|
8807
|
+
* blindness one level down: a gate whose subject is nested figures
|
|
8808
|
+
* cannot stop at the top level.
|
|
8809
|
+
*
|
|
8810
|
+
* What neither can decide is whether a declared scope is TRUE, and a
|
|
8811
|
+
* wrong scope is worse than a missing one: a missing one is noticed, a
|
|
8812
|
+
* wrong one is believed. The doctrine test suspends a real run, resumes
|
|
8813
|
+
* it, and holds every declared figure against its own claim (RV2801),
|
|
8814
|
+
* which is how three `cost.orchestrator.*` paths were found calling
|
|
8815
|
+
* themselves `'segment'` while the terminal folded them cumulatively.
|
|
8802
8816
|
*/
|
|
8803
8817
|
const TERMINAL_TELEMETRY_SCOPE = Object.freeze({
|
|
8804
8818
|
status: "terminal",
|
|
@@ -8827,10 +8841,14 @@ const TERMINAL_TELEMETRY_SCOPE = Object.freeze({
|
|
|
8827
8841
|
"cost.totalUsd": "cumulative",
|
|
8828
8842
|
"cost.grossUsd": "cumulative",
|
|
8829
8843
|
"cost.wireRequests": "cumulative",
|
|
8844
|
+
"cost.usageApprox": "cumulative",
|
|
8845
|
+
"cost.abandoned.usd": "cumulative",
|
|
8846
|
+
"cost.abandoned.usageApprox": "cumulative",
|
|
8830
8847
|
"cost.orchestrator.spentUsd": "cumulative",
|
|
8831
|
-
"cost.orchestrator.
|
|
8832
|
-
"cost.orchestrator.
|
|
8833
|
-
"cost.orchestrator.
|
|
8848
|
+
"cost.orchestrator.share": "cumulative",
|
|
8849
|
+
"cost.orchestrator.wakes": "cumulative",
|
|
8850
|
+
"cost.orchestrator.forcedFinish": "cumulative",
|
|
8851
|
+
"cost.orchestrator.reserveUsedUsd": "cumulative",
|
|
8834
8852
|
transportRetries: "segment",
|
|
8835
8853
|
schemaRejectedFinishExchanges: "segment",
|
|
8836
8854
|
schemaRecoveredFinishExchanges: "segment"
|
|
@@ -8905,6 +8923,7 @@ function logicalRunTelemetry(entries) {
|
|
|
8905
8923
|
function childRostersFromJournal(entries) {
|
|
8906
8924
|
const rosters = /* @__PURE__ */ new Map();
|
|
8907
8925
|
const ordered = [...entries].sort((a, b) => a.seq - b.seq);
|
|
8926
|
+
const abandoned = buildAbandonFold(ordered);
|
|
8908
8927
|
const dispatchesByScope = /* @__PURE__ */ new Map();
|
|
8909
8928
|
const terminalsByScopeKey = /* @__PURE__ */ new Map();
|
|
8910
8929
|
for (const entry of ordered) {
|
|
@@ -8950,6 +8969,7 @@ function childRostersFromJournal(entries) {
|
|
|
8950
8969
|
const terminal = terminalsByScopeKey.get(JSON.stringify([childScope, dispatch.key]))?.find((candidate) => candidate.seq > dispatch.seq);
|
|
8951
8970
|
roster.children.push({
|
|
8952
8971
|
handle: dispatch.seq,
|
|
8972
|
+
...abandoned.isAbandoned(dispatch.seq) ? { abandoned: true } : {},
|
|
8953
8973
|
...terminal?.costAttribution?.agentType === void 0 ? {} : { agentType: terminal.costAttribution.agentType },
|
|
8954
8974
|
...terminal === void 0 ? {} : { status: terminal.status },
|
|
8955
8975
|
...terminal?.evidence === void 0 ? {} : { evidence: { ...terminal.evidence } }
|
|
@@ -9071,306 +9091,668 @@ async function reconcileRunMeta(store, runId, opts) {
|
|
|
9071
9091
|
};
|
|
9072
9092
|
}
|
|
9073
9093
|
//#endregion
|
|
9074
|
-
//#region src/
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
* Contract (DEF-4 tightening):
|
|
9082
|
-
* - A1 atomicity: a torn trailing line (crash mid-append) is never
|
|
9083
|
-
* visible in load; the incomplete fragment is dropped and overwritten
|
|
9084
|
-
* by the next append. Whole records on that line are data, never
|
|
9085
|
-
* fragment (RV701): a crash that persisted every JSON byte but not
|
|
9086
|
-
* the '\n' leaves a parseable tail that load serves and append
|
|
9087
|
-
* terminates before writing, and repair salvages complete records a
|
|
9088
|
-
* glued line carries instead of discarding the line, so an entry a
|
|
9089
|
-
* load has served can never be un-served by a later repair.
|
|
9090
|
-
* - A2 total per-run order: load returns append order, stable across
|
|
9091
|
-
* calls (the kernel's per-run queue serializes appends).
|
|
9092
|
-
* - A3 read-your-writes: append resolves after the line is written.
|
|
9093
|
-
* - A4 opaque payload: entries round-trip byte-for-byte as JSON; unknown
|
|
9094
|
-
* kinds and fields pass through untouched.
|
|
9095
|
-
*
|
|
9096
|
-
* Leasing is NOT implemented here: LeasableStore ships with
|
|
9097
|
-
* @rulvar/store-sqlite (M5); JsonlFileStore is single-writer by
|
|
9098
|
-
* convention.
|
|
9099
|
-
*/
|
|
9100
|
-
const JOURNAL_SUFFIX = ".jsonl";
|
|
9101
|
-
const META_SUFFIX = ".meta.json";
|
|
9102
|
-
function safeName(runId) {
|
|
9103
|
-
if (!/^[A-Za-z0-9._-]+$/.test(runId)) throw new JournalOrderViolation(`JsonlFileStore: runId '${runId}' is not filesystem-safe ([A-Za-z0-9._-] only)`);
|
|
9104
|
-
return runId;
|
|
9105
|
-
}
|
|
9094
|
+
//#region src/l0/telemetry-reduce.ts
|
|
9095
|
+
const ZERO = {
|
|
9096
|
+
inputTokens: 0,
|
|
9097
|
+
outputTokens: 0,
|
|
9098
|
+
cacheReadTokens: 0,
|
|
9099
|
+
cacheWriteTokens: 0
|
|
9100
|
+
};
|
|
9106
9101
|
/**
|
|
9107
|
-
*
|
|
9108
|
-
*
|
|
9109
|
-
*
|
|
9110
|
-
* clean concatenation from its first byte salvages its whole prefix
|
|
9111
|
-
* values and returns everything after them as the torn fragment, so the
|
|
9112
|
-
* caller keeps accepted records and drops exactly the unacknowledged
|
|
9113
|
-
* tail a crash tore.
|
|
9102
|
+
* Reduces one run's event stream (or any slice of it) to the invocation
|
|
9103
|
+
* table. Feed it the events in emission order; both a live stream and a
|
|
9104
|
+
* replayed one produce the same usage and cost columns.
|
|
9114
9105
|
*/
|
|
9115
|
-
function
|
|
9116
|
-
const
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
let
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
if (
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9106
|
+
function reduceInvocationTable(events) {
|
|
9107
|
+
const rows = /* @__PURE__ */ new Map();
|
|
9108
|
+
const order = [];
|
|
9109
|
+
const openPhases = /* @__PURE__ */ new Map();
|
|
9110
|
+
const byRole = {};
|
|
9111
|
+
let totalCostUsd = 0;
|
|
9112
|
+
const rowFor = (event) => {
|
|
9113
|
+
let row = rows.get(event.spanId);
|
|
9114
|
+
if (row === void 0) {
|
|
9115
|
+
row = {
|
|
9116
|
+
spanId: event.spanId,
|
|
9117
|
+
agentType: event.agentType,
|
|
9118
|
+
...event.label === void 0 ? {} : { label: event.label },
|
|
9119
|
+
usage: ZERO,
|
|
9120
|
+
costUsd: 0,
|
|
9121
|
+
costBasis: "aggregate-estimate",
|
|
9122
|
+
usageApprox: false,
|
|
9123
|
+
retryCount: 0,
|
|
9124
|
+
replayed: event.replayed === true,
|
|
9125
|
+
open: true,
|
|
9126
|
+
phases: []
|
|
9127
|
+
};
|
|
9128
|
+
rows.set(event.spanId, row);
|
|
9129
|
+
order.push(row);
|
|
9132
9130
|
}
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9131
|
+
return row;
|
|
9132
|
+
};
|
|
9133
|
+
for (const event of events) switch (event.type) {
|
|
9134
|
+
case "agent:start": {
|
|
9135
|
+
const row = rowFor(event);
|
|
9136
|
+
row.role = event.role;
|
|
9137
|
+
break;
|
|
9136
9138
|
}
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9139
|
+
case "agent:phase:start": {
|
|
9140
|
+
const row = rowFor(event);
|
|
9141
|
+
const phase = {
|
|
9142
|
+
invocation: event.invocation,
|
|
9143
|
+
role: event.role,
|
|
9144
|
+
model: event.model,
|
|
9145
|
+
durationMs: 0,
|
|
9146
|
+
usage: ZERO,
|
|
9147
|
+
costUsd: 0,
|
|
9148
|
+
costBasis: "aggregate-estimate",
|
|
9149
|
+
retries: 0,
|
|
9150
|
+
replayed: event.replayed === true,
|
|
9151
|
+
open: true
|
|
9142
9152
|
};
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9153
|
+
row.phases.push(phase);
|
|
9154
|
+
openPhases.set(`${event.spanId}#${event.invocation}`, phase);
|
|
9155
|
+
break;
|
|
9156
|
+
}
|
|
9157
|
+
case "agent:phase:end": {
|
|
9158
|
+
const key = `${event.spanId}#${event.invocation}`;
|
|
9159
|
+
let phase = openPhases.get(key);
|
|
9160
|
+
if (phase === void 0) {
|
|
9161
|
+
phase = {
|
|
9162
|
+
invocation: event.invocation,
|
|
9163
|
+
role: event.role,
|
|
9164
|
+
model: event.model,
|
|
9165
|
+
durationMs: 0,
|
|
9166
|
+
usage: ZERO,
|
|
9167
|
+
costUsd: 0,
|
|
9168
|
+
costBasis: "aggregate-estimate",
|
|
9169
|
+
retries: 0,
|
|
9170
|
+
replayed: event.replayed === true,
|
|
9171
|
+
open: true
|
|
9172
|
+
};
|
|
9173
|
+
rowFor(event).phases.push(phase);
|
|
9154
9174
|
}
|
|
9175
|
+
openPhases.delete(key);
|
|
9176
|
+
phase.open = false;
|
|
9177
|
+
phase.role = event.role;
|
|
9178
|
+
phase.model = event.model;
|
|
9179
|
+
phase.durationMs = event.durationMs;
|
|
9180
|
+
phase.usage = event.usage;
|
|
9181
|
+
phase.costUsd = event.costUsd;
|
|
9182
|
+
phase.costBasis = event.costBasis ?? "aggregate-estimate";
|
|
9183
|
+
phase.outcome = event.outcome;
|
|
9184
|
+
phase.retries = event.retries ?? 0;
|
|
9185
|
+
const bucket = byRole[event.role] ??= {
|
|
9186
|
+
usage: ZERO,
|
|
9187
|
+
costUsd: 0,
|
|
9188
|
+
costBasis: "per-call"
|
|
9189
|
+
};
|
|
9190
|
+
bucket.usage = sumUsage(bucket.usage, event.usage);
|
|
9191
|
+
bucket.costUsd += event.costUsd;
|
|
9192
|
+
if (phase.costBasis === "aggregate-estimate") bucket.costBasis = "aggregate-estimate";
|
|
9193
|
+
break;
|
|
9194
|
+
}
|
|
9195
|
+
case "agent:end": {
|
|
9196
|
+
const row = rowFor(event);
|
|
9197
|
+
row.open = false;
|
|
9198
|
+
row.status = event.status;
|
|
9199
|
+
row.usage = event.usage;
|
|
9200
|
+
row.costUsd = event.costUsd;
|
|
9201
|
+
row.costBasis = event.costBasis ?? "aggregate-estimate";
|
|
9202
|
+
row.usageApprox = event.usageApprox === true;
|
|
9203
|
+
row.retryCount = event.retryCount ?? 0;
|
|
9204
|
+
if (event.toolBudget !== void 0) row.toolBudget = event.toolBudget;
|
|
9205
|
+
totalCostUsd += event.costUsd;
|
|
9206
|
+
break;
|
|
9155
9207
|
}
|
|
9208
|
+
default: break;
|
|
9156
9209
|
}
|
|
9157
9210
|
return {
|
|
9158
|
-
|
|
9159
|
-
|
|
9211
|
+
agents: order,
|
|
9212
|
+
byRole,
|
|
9213
|
+
totalCostUsd
|
|
9160
9214
|
};
|
|
9161
9215
|
}
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
const size = fstatSync(fd).size;
|
|
9249
|
-
if (size > 0) {
|
|
9250
|
-
const lastByte = /* @__PURE__ */ new Uint8Array(1);
|
|
9251
|
-
readSync(fd, lastByte, 0, 1, size - 1);
|
|
9252
|
-
needsNewline = lastByte[0] !== 10;
|
|
9216
|
+
/**
|
|
9217
|
+
* The label the claim-consistency judge invocation dispatches under
|
|
9218
|
+
* (RV1502; named here since RV1604 so the critical-path reducer and the
|
|
9219
|
+
* orchestrator share one constant): the judge rides role 'synthesize',
|
|
9220
|
+
* and this label is what tells its wall apart from a real final
|
|
9221
|
+
* composition in {@link reduceCriticalPath}.
|
|
9222
|
+
*/
|
|
9223
|
+
const CLAIM_JUDGE_LABEL = "claim-consistency-judge";
|
|
9224
|
+
/** Total length of the union of possibly overlapping intervals. */
|
|
9225
|
+
function unionLength(intervals) {
|
|
9226
|
+
const positive = intervals.filter((interval) => interval.to > interval.from);
|
|
9227
|
+
if (positive.length === 0) return 0;
|
|
9228
|
+
const sorted = [...positive].sort((a, b) => a.from - b.from);
|
|
9229
|
+
let total = 0;
|
|
9230
|
+
let from = sorted[0]?.from ?? 0;
|
|
9231
|
+
let to = sorted[0]?.to ?? 0;
|
|
9232
|
+
for (const interval of sorted.slice(1)) if (interval.from > to) {
|
|
9233
|
+
total += to - from;
|
|
9234
|
+
from = interval.from;
|
|
9235
|
+
to = interval.to;
|
|
9236
|
+
} else if (interval.to > to) to = interval.to;
|
|
9237
|
+
return total + (to - from);
|
|
9238
|
+
}
|
|
9239
|
+
function reduceCriticalPath(events) {
|
|
9240
|
+
let runStart;
|
|
9241
|
+
let runEnd;
|
|
9242
|
+
const startBySpan = /* @__PURE__ */ new Map();
|
|
9243
|
+
let lastWorkerEnd;
|
|
9244
|
+
let workerSpans = 0;
|
|
9245
|
+
let synthesisMs = 0;
|
|
9246
|
+
let finalCompositionMs = 0;
|
|
9247
|
+
let semanticJudgeMs = 0;
|
|
9248
|
+
const coordinationModel = [];
|
|
9249
|
+
const coordinationTools = [];
|
|
9250
|
+
const synthesisSpans = [];
|
|
9251
|
+
const spanOf = (durationMs) => Number.isFinite(durationMs) && durationMs > 0 ? durationMs : 0;
|
|
9252
|
+
for (const event of events) {
|
|
9253
|
+
const at = Date.parse(event.ts);
|
|
9254
|
+
if (!Number.isFinite(at)) continue;
|
|
9255
|
+
switch (event.type) {
|
|
9256
|
+
case "run:start":
|
|
9257
|
+
runStart ??= at;
|
|
9258
|
+
break;
|
|
9259
|
+
case "run:end":
|
|
9260
|
+
runEnd = at;
|
|
9261
|
+
break;
|
|
9262
|
+
case "agent:start":
|
|
9263
|
+
startBySpan.set(event.spanId, {
|
|
9264
|
+
role: event.role,
|
|
9265
|
+
at,
|
|
9266
|
+
...event.label === void 0 ? {} : { label: event.label }
|
|
9267
|
+
});
|
|
9268
|
+
break;
|
|
9269
|
+
case "agent:phase:end":
|
|
9270
|
+
if (startBySpan.get(event.spanId)?.role === "orchestrate") coordinationModel.push({
|
|
9271
|
+
phase: event.role,
|
|
9272
|
+
from: at - spanOf(event.durationMs),
|
|
9273
|
+
to: at
|
|
9274
|
+
});
|
|
9275
|
+
break;
|
|
9276
|
+
case "tool:end":
|
|
9277
|
+
if (startBySpan.get(event.spanId)?.role === "orchestrate") coordinationTools.push({
|
|
9278
|
+
name: event.toolName,
|
|
9279
|
+
from: at - spanOf(event.durationMs),
|
|
9280
|
+
to: at
|
|
9281
|
+
});
|
|
9282
|
+
break;
|
|
9283
|
+
case "agent:end": {
|
|
9284
|
+
const started = startBySpan.get(event.spanId);
|
|
9285
|
+
if (started === void 0) break;
|
|
9286
|
+
if (started.role === "synthesize") {
|
|
9287
|
+
const wall = Math.max(0, at - started.at);
|
|
9288
|
+
const judge = started.label === CLAIM_JUDGE_LABEL;
|
|
9289
|
+
synthesisMs += wall;
|
|
9290
|
+
if (judge) semanticJudgeMs += wall;
|
|
9291
|
+
else finalCompositionMs += wall;
|
|
9292
|
+
synthesisSpans.push({
|
|
9293
|
+
from: started.at,
|
|
9294
|
+
to: at,
|
|
9295
|
+
judge
|
|
9296
|
+
});
|
|
9297
|
+
} else if (started.role !== "orchestrate") {
|
|
9298
|
+
workerSpans += 1;
|
|
9299
|
+
lastWorkerEnd = lastWorkerEnd === void 0 ? at : Math.max(lastWorkerEnd, at);
|
|
9300
|
+
}
|
|
9301
|
+
break;
|
|
9253
9302
|
}
|
|
9254
|
-
|
|
9255
|
-
closeSync(fd);
|
|
9303
|
+
default: break;
|
|
9256
9304
|
}
|
|
9257
|
-
if (needsNewline) appendFileSync(path, "\n", "utf8");
|
|
9258
|
-
}
|
|
9259
|
-
repairTornTail(runId, whole) {
|
|
9260
|
-
const path = this.journalPath(runId);
|
|
9261
|
-
const temp = `${path}.tmp`;
|
|
9262
|
-
writeFileSync(temp, whole.map((entry) => JSON.stringify(entry)).join("\n") + (whole.length > 0 ? "\n" : ""), "utf8");
|
|
9263
|
-
renameSync(temp, path);
|
|
9264
9305
|
}
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
}
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9306
|
+
const path = {
|
|
9307
|
+
synthesisMs,
|
|
9308
|
+
finalCompositionMs,
|
|
9309
|
+
semanticJudgeMs,
|
|
9310
|
+
workerSpans
|
|
9311
|
+
};
|
|
9312
|
+
if (runStart !== void 0 && runEnd !== void 0) path.runWallMs = Math.max(0, runEnd - runStart);
|
|
9313
|
+
if (runEnd !== void 0 && lastWorkerEnd !== void 0) {
|
|
9314
|
+
path.postFanInMs = Math.max(0, runEnd - lastWorkerEnd);
|
|
9315
|
+
const windowFrom = Math.min(lastWorkerEnd, runEnd);
|
|
9316
|
+
const windowTo = runEnd;
|
|
9317
|
+
const clip = (interval) => {
|
|
9318
|
+
if (interval.to < windowFrom || interval.from > windowTo) return;
|
|
9319
|
+
return {
|
|
9320
|
+
from: Math.max(interval.from, windowFrom),
|
|
9321
|
+
to: Math.min(interval.to, windowTo)
|
|
9322
|
+
};
|
|
9323
|
+
};
|
|
9324
|
+
const byPhase = {};
|
|
9325
|
+
const modelClipped = [];
|
|
9326
|
+
for (const interval of coordinationModel) {
|
|
9327
|
+
const clipped = clip(interval);
|
|
9328
|
+
if (clipped === void 0) continue;
|
|
9329
|
+
byPhase[interval.phase] = (byPhase[interval.phase] ?? 0) + (clipped.to - clipped.from);
|
|
9330
|
+
modelClipped.push(clipped);
|
|
9276
9331
|
}
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
for (const
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9332
|
+
const synthesisClipped = [];
|
|
9333
|
+
let judgeClippedMs = 0;
|
|
9334
|
+
let compositionClippedMs = 0;
|
|
9335
|
+
for (const span of synthesisSpans) {
|
|
9336
|
+
const clipped = clip(span);
|
|
9337
|
+
if (clipped === void 0) continue;
|
|
9338
|
+
synthesisClipped.push(clipped);
|
|
9339
|
+
if (span.judge) judgeClippedMs += clipped.to - clipped.from;
|
|
9340
|
+
else compositionClippedMs += clipped.to - clipped.from;
|
|
9285
9341
|
}
|
|
9286
|
-
|
|
9342
|
+
const byName = {};
|
|
9343
|
+
const callsByName = {};
|
|
9344
|
+
const toolsClipped = [];
|
|
9345
|
+
for (const interval of coordinationTools) {
|
|
9346
|
+
const clipped = clip(interval);
|
|
9347
|
+
if (clipped === void 0) continue;
|
|
9348
|
+
byName[interval.name] = (byName[interval.name] ?? 0) + (clipped.to - clipped.from);
|
|
9349
|
+
callsByName[interval.name] = (callsByName[interval.name] ?? 0) + 1;
|
|
9350
|
+
toolsClipped.push(clipped);
|
|
9351
|
+
}
|
|
9352
|
+
const lengthOf = (intervals) => intervals.reduce((sum, interval) => sum + (interval.to - interval.from), 0);
|
|
9353
|
+
const coveredMs = unionLength([
|
|
9354
|
+
...modelClipped,
|
|
9355
|
+
...toolsClipped,
|
|
9356
|
+
...synthesisClipped
|
|
9357
|
+
]);
|
|
9358
|
+
const modelOnlyMs = unionLength([...modelClipped, ...toolsClipped]) - unionLength(toolsClipped);
|
|
9359
|
+
const breakdown = {
|
|
9360
|
+
coordinationModelMs: lengthOf(modelClipped),
|
|
9361
|
+
coordinationModelMsByPhase: byPhase,
|
|
9362
|
+
coordinationModelOnlyMs: modelOnlyMs,
|
|
9363
|
+
coordinationToolMs: lengthOf(toolsClipped),
|
|
9364
|
+
coordinationToolMsByName: byName,
|
|
9365
|
+
coordinationToolCallsByName: callsByName,
|
|
9366
|
+
synthesisMs: lengthOf(synthesisClipped),
|
|
9367
|
+
finalCompositionMs: compositionClippedMs,
|
|
9368
|
+
semanticJudgeMs: judgeClippedMs,
|
|
9369
|
+
coveredMs,
|
|
9370
|
+
residueMs: Math.max(0, path.postFanInMs - coveredMs)
|
|
9371
|
+
};
|
|
9372
|
+
if (path.postFanInMs > 0) breakdown.residueShare = breakdown.residueMs / path.postFanInMs;
|
|
9373
|
+
path.postFanIn = breakdown;
|
|
9287
9374
|
}
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
this.lastSeq.delete(runId);
|
|
9375
|
+
if (path.runWallMs !== void 0 && path.runWallMs > 0) {
|
|
9376
|
+
if (path.postFanInMs !== void 0) path.postFanInShare = path.postFanInMs / path.runWallMs;
|
|
9377
|
+
path.synthesisShare = synthesisMs / path.runWallMs;
|
|
9292
9378
|
}
|
|
9379
|
+
return path;
|
|
9380
|
+
}
|
|
9381
|
+
//#endregion
|
|
9382
|
+
//#region src/stores/critical-path.ts
|
|
9383
|
+
const parse = (at) => {
|
|
9384
|
+
if (at === void 0) return;
|
|
9385
|
+
const ms = Date.parse(at);
|
|
9386
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
9293
9387
|
};
|
|
9294
|
-
const TRANSCRIPT_SUFFIX = ".bin";
|
|
9295
9388
|
/**
|
|
9296
|
-
*
|
|
9297
|
-
* persisted CompiledWorkflow sources) as one file per ref under `dir`,
|
|
9298
|
-
* so compiled runs resume across processes. Refs follow the
|
|
9299
|
-
* `<runId>/<name>` convention; nested segments become directories.
|
|
9389
|
+
* Fold a run's critical path out of its journal.
|
|
9300
9390
|
*
|
|
9301
|
-
*
|
|
9302
|
-
* segment must match `[A-Za-z0-9._-]` and be neither empty, '.', nor
|
|
9303
|
-
* '..', and the resolved path must stay under the resolved root. A '..'
|
|
9304
|
-
* segment used to pass the per-segment alphabet (dots are in it) and, via
|
|
9305
|
-
* `join`, escape the root; a caller passing an untrusted ref (or an
|
|
9306
|
-
* untrusted runId, which prefixes checkpoint and workflow-source refs)
|
|
9307
|
-
* could read, write, or delete `.bin` files outside `dir`.
|
|
9391
|
+
* @param entries the journal of one run, in any order
|
|
9308
9392
|
*/
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9393
|
+
function criticalPathFromJournal(entries) {
|
|
9394
|
+
const ordered = [...entries].sort((a, b) => a.seq - b.seq);
|
|
9395
|
+
let runStart;
|
|
9396
|
+
let runEnd;
|
|
9397
|
+
let lastWorkerEnd;
|
|
9398
|
+
let workerSpans = 0;
|
|
9399
|
+
let unclassifiedSpans = 0;
|
|
9400
|
+
let synthesisMs = 0;
|
|
9401
|
+
let finalCompositionMs = 0;
|
|
9402
|
+
let semanticJudgeMs = 0;
|
|
9403
|
+
let labelledSynthesis = false;
|
|
9404
|
+
let unlabelledSynthesis = false;
|
|
9405
|
+
for (const entry of ordered) {
|
|
9406
|
+
const startedAt = parse(entry.startedAt);
|
|
9407
|
+
const endedAt = parse(entry.endedAt);
|
|
9408
|
+
if (startedAt !== void 0) runStart = runStart === void 0 ? startedAt : Math.min(runStart, startedAt);
|
|
9409
|
+
const last = endedAt ?? startedAt;
|
|
9410
|
+
if (last !== void 0) runEnd = runEnd === void 0 ? last : Math.max(runEnd, last);
|
|
9411
|
+
if (entry.kind !== "agent" || entry.status === "running" || entry.status === "suspended") continue;
|
|
9412
|
+
const role = entry.costAttribution?.role;
|
|
9413
|
+
if (role === void 0) {
|
|
9414
|
+
unclassifiedSpans += 1;
|
|
9415
|
+
continue;
|
|
9416
|
+
}
|
|
9417
|
+
if (role === "orchestrate") continue;
|
|
9418
|
+
if (role !== "synthesize") {
|
|
9419
|
+
workerSpans += 1;
|
|
9420
|
+
if (endedAt !== void 0) lastWorkerEnd = lastWorkerEnd === void 0 ? endedAt : Math.max(lastWorkerEnd, endedAt);
|
|
9421
|
+
continue;
|
|
9422
|
+
}
|
|
9423
|
+
if (startedAt === void 0 || endedAt === void 0) continue;
|
|
9424
|
+
const wall = Math.max(0, endedAt - startedAt);
|
|
9425
|
+
synthesisMs += wall;
|
|
9426
|
+
const label = entry.costAttribution?.label;
|
|
9427
|
+
if (label === void 0) {
|
|
9428
|
+
unlabelledSynthesis = true;
|
|
9429
|
+
continue;
|
|
9430
|
+
}
|
|
9431
|
+
labelledSynthesis = true;
|
|
9432
|
+
if (label === "claim-consistency-judge" || label.startsWith(`claim-consistency-judge-`)) semanticJudgeMs += wall;
|
|
9433
|
+
else finalCompositionMs += wall;
|
|
9314
9434
|
}
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9435
|
+
const segments = logicalRunTelemetry(ordered).segments;
|
|
9436
|
+
const path = {
|
|
9437
|
+
workerSpans,
|
|
9438
|
+
synthesisMs,
|
|
9439
|
+
unclassifiedSpans,
|
|
9440
|
+
segments
|
|
9441
|
+
};
|
|
9442
|
+
if (labelledSynthesis && !unlabelledSynthesis) {
|
|
9443
|
+
path.finalCompositionMs = finalCompositionMs;
|
|
9444
|
+
path.semanticJudgeMs = semanticJudgeMs;
|
|
9445
|
+
}
|
|
9446
|
+
if (segments > 1 || runStart === void 0 || runEnd === void 0) return path;
|
|
9447
|
+
path.runWallMs = Math.max(0, runEnd - runStart);
|
|
9448
|
+
if (lastWorkerEnd !== void 0) path.postFanInMs = Math.max(0, runEnd - lastWorkerEnd);
|
|
9449
|
+
if (path.runWallMs > 0) {
|
|
9450
|
+
if (path.postFanInMs !== void 0) path.postFanInShare = path.postFanInMs / path.runWallMs;
|
|
9451
|
+
path.synthesisShare = synthesisMs / path.runWallMs;
|
|
9324
9452
|
}
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9453
|
+
return path;
|
|
9454
|
+
}
|
|
9455
|
+
//#endregion
|
|
9456
|
+
//#region src/stores/jsonl.ts
|
|
9457
|
+
/**
|
|
9458
|
+
* JsonlFileStore (M2-T01): the durable file store. One JSON entry per
|
|
9459
|
+
* line per run; the journal doubles as an event log. Meta records live
|
|
9460
|
+
* beside the journal and are replaced atomically, so listRuns never
|
|
9461
|
+
* parses payloads.
|
|
9462
|
+
*
|
|
9463
|
+
* Contract (DEF-4 tightening):
|
|
9464
|
+
* - A1 atomicity: a torn trailing line (crash mid-append) is never
|
|
9465
|
+
* visible in load; the incomplete fragment is dropped and overwritten
|
|
9466
|
+
* by the next append. Whole records on that line are data, never
|
|
9467
|
+
* fragment (RV701): a crash that persisted every JSON byte but not
|
|
9468
|
+
* the '\n' leaves a parseable tail that load serves and append
|
|
9469
|
+
* terminates before writing, and repair salvages complete records a
|
|
9470
|
+
* glued line carries instead of discarding the line, so an entry a
|
|
9471
|
+
* load has served can never be un-served by a later repair.
|
|
9472
|
+
* - A2 total per-run order: load returns append order, stable across
|
|
9473
|
+
* calls (the kernel's per-run queue serializes appends).
|
|
9474
|
+
* - A3 read-your-writes: append resolves after the line is written.
|
|
9475
|
+
* - A4 opaque payload: entries round-trip byte-for-byte as JSON; unknown
|
|
9476
|
+
* kinds and fields pass through untouched.
|
|
9477
|
+
*
|
|
9478
|
+
* Leasing is NOT implemented here: LeasableStore ships with
|
|
9479
|
+
* @rulvar/store-sqlite (M5); JsonlFileStore is single-writer by
|
|
9480
|
+
* convention.
|
|
9481
|
+
*/
|
|
9482
|
+
const JOURNAL_SUFFIX = ".jsonl";
|
|
9483
|
+
const META_SUFFIX = ".meta.json";
|
|
9484
|
+
function safeName(runId) {
|
|
9485
|
+
if (!/^[A-Za-z0-9._-]+$/.test(runId)) throw new JournalOrderViolation(`JsonlFileStore: runId '${runId}' is not filesystem-safe ([A-Za-z0-9._-] only)`);
|
|
9486
|
+
return runId;
|
|
9487
|
+
}
|
|
9488
|
+
/**
|
|
9489
|
+
* Whole JSON values glued on one line, split apart without parser
|
|
9490
|
+
* ambiguity (RV701): depth is tracked outside string literals only, and
|
|
9491
|
+
* every candidate must still round-trip JSON.parse. A line that is not a
|
|
9492
|
+
* clean concatenation from its first byte salvages its whole prefix
|
|
9493
|
+
* values and returns everything after them as the torn fragment, so the
|
|
9494
|
+
* caller keeps accepted records and drops exactly the unacknowledged
|
|
9495
|
+
* tail a crash tore.
|
|
9496
|
+
*/
|
|
9497
|
+
function splitConcatenatedJson(line) {
|
|
9498
|
+
const whole = [];
|
|
9499
|
+
let start = 0;
|
|
9500
|
+
let depth = 0;
|
|
9501
|
+
let inString = false;
|
|
9502
|
+
let escaped = false;
|
|
9503
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
9504
|
+
const ch = line[i];
|
|
9505
|
+
if (inString) {
|
|
9506
|
+
if (escaped) escaped = false;
|
|
9507
|
+
else if (ch === "\\") escaped = true;
|
|
9508
|
+
else if (ch === "\"") inString = false;
|
|
9509
|
+
continue;
|
|
9510
|
+
}
|
|
9511
|
+
if (ch === "\"") {
|
|
9512
|
+
inString = true;
|
|
9513
|
+
continue;
|
|
9514
|
+
}
|
|
9515
|
+
if (ch === "{" || ch === "[") {
|
|
9516
|
+
depth += 1;
|
|
9517
|
+
continue;
|
|
9518
|
+
}
|
|
9519
|
+
if (ch === "}" || ch === "]") {
|
|
9520
|
+
depth -= 1;
|
|
9521
|
+
if (depth < 0) return {
|
|
9522
|
+
whole,
|
|
9523
|
+
fragment: line.slice(start)
|
|
9524
|
+
};
|
|
9525
|
+
if (depth === 0) {
|
|
9526
|
+
const candidate = line.slice(start, i + 1);
|
|
9527
|
+
try {
|
|
9528
|
+
whole.push(JSON.parse(candidate));
|
|
9529
|
+
} catch {
|
|
9530
|
+
return {
|
|
9531
|
+
whole,
|
|
9532
|
+
fragment: line.slice(start)
|
|
9533
|
+
};
|
|
9534
|
+
}
|
|
9535
|
+
start = i + 1;
|
|
9536
|
+
}
|
|
9537
|
+
}
|
|
9331
9538
|
}
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9539
|
+
return {
|
|
9540
|
+
whole,
|
|
9541
|
+
fragment: line.slice(start)
|
|
9542
|
+
};
|
|
9543
|
+
}
|
|
9544
|
+
var JsonlFileStore = class {
|
|
9545
|
+
dir;
|
|
9546
|
+
/**
|
|
9547
|
+
* The stored tail seq per run, lazily initialized from the file on the
|
|
9548
|
+
* first append this instance performs (obligation A5). Per instance by
|
|
9549
|
+
* design: cross-process writers are the lease seam's job.
|
|
9550
|
+
*/
|
|
9551
|
+
lastSeq = /* @__PURE__ */ new Map();
|
|
9552
|
+
/**
|
|
9553
|
+
* The verify-only load switch (RV1512): with `repairOnLoad: false`,
|
|
9554
|
+
* `load` serves the salvageable records WITHOUT rewriting the file,
|
|
9555
|
+
* so an auditor's "verification" read never destroys the evidence
|
|
9556
|
+
* of a tear it found. The default keeps the owner semantics byte
|
|
9557
|
+
* for byte: a torn tail repairs on load exactly as documented in
|
|
9558
|
+
* the A1 model above. Mutations (`append`, `putMeta`, `delete`)
|
|
9559
|
+
* are unaffected by the flag; an auditor that must not write simply
|
|
9560
|
+
* does not call them.
|
|
9561
|
+
*/
|
|
9562
|
+
repairOnLoad;
|
|
9563
|
+
constructor(options) {
|
|
9564
|
+
this.dir = options.dir;
|
|
9565
|
+
this.repairOnLoad = options.repairOnLoad !== false;
|
|
9566
|
+
mkdirSync(this.dir, { recursive: true });
|
|
9567
|
+
}
|
|
9568
|
+
journalPath(runId) {
|
|
9569
|
+
return join(this.dir, `${safeName(runId)}${JOURNAL_SUFFIX}`);
|
|
9570
|
+
}
|
|
9571
|
+
metaPath(runId) {
|
|
9572
|
+
return join(this.dir, `${safeName(runId)}${META_SUFFIX}`);
|
|
9573
|
+
}
|
|
9574
|
+
async append(runId, e) {
|
|
9575
|
+
let tail = this.lastSeq.get(runId);
|
|
9576
|
+
if (tail === void 0) {
|
|
9577
|
+
const existing = await this.load(runId);
|
|
9578
|
+
this.terminateUnterminatedTail(runId);
|
|
9579
|
+
const last = existing[existing.length - 1];
|
|
9580
|
+
tail = last !== void 0 && Number.isFinite(last.seq) ? last.seq : Number.NEGATIVE_INFINITY;
|
|
9581
|
+
this.lastSeq.set(runId, tail);
|
|
9338
9582
|
}
|
|
9583
|
+
if (Number.isFinite(e.seq) && e.seq <= tail) throw new JournalOrderViolation(`JsonlFileStore: append of seq ${e.seq} to run '${runId}' is not after the stored tail seq ${tail}; a concurrent writer raced this journal from a stale tail`);
|
|
9584
|
+
appendFileSync(this.journalPath(runId), `${JSON.stringify(e)}\n`, "utf8");
|
|
9585
|
+
if (Number.isFinite(e.seq)) this.lastSeq.set(runId, e.seq);
|
|
9339
9586
|
}
|
|
9340
|
-
async
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9587
|
+
async load(runId) {
|
|
9588
|
+
let raw;
|
|
9589
|
+
try {
|
|
9590
|
+
raw = readFileSync(this.journalPath(runId), "utf8");
|
|
9591
|
+
} catch (thrown) {
|
|
9592
|
+
if (thrown.code === "ENOENT") return [];
|
|
9593
|
+
throw thrown;
|
|
9594
|
+
}
|
|
9595
|
+
const lines = raw.split("\n");
|
|
9596
|
+
const entries = [];
|
|
9597
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
9598
|
+
const line = lines[i] ?? "";
|
|
9599
|
+
if (line === "") continue;
|
|
9346
9600
|
try {
|
|
9347
|
-
|
|
9348
|
-
} catch {
|
|
9349
|
-
|
|
9601
|
+
entries.push(JSON.parse(line));
|
|
9602
|
+
} catch (thrown) {
|
|
9603
|
+
if (lines.slice(i + 1).every((rest) => rest === "")) {
|
|
9604
|
+
for (const value of splitConcatenatedJson(line).whole) entries.push(value);
|
|
9605
|
+
if (this.repairOnLoad) this.repairTornTail(runId, entries);
|
|
9606
|
+
break;
|
|
9607
|
+
}
|
|
9608
|
+
throw new JournalOrderViolation(`JsonlFileStore: corrupt journal line ${i + 1} of run '${runId}' (not the trailing line, so this is not a torn append)`, { cause: thrown });
|
|
9350
9609
|
}
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9610
|
+
}
|
|
9611
|
+
return entries;
|
|
9612
|
+
}
|
|
9613
|
+
/**
|
|
9614
|
+
* Restores the trailing '\n' of a parseable-but-unterminated tail
|
|
9615
|
+
* (RV701). One byte appended in place terminates the record exactly
|
|
9616
|
+
* where the crash left it; the file's bytes before it stay untouched.
|
|
9617
|
+
* No-op on a missing, empty, or already-terminated journal.
|
|
9618
|
+
*/
|
|
9619
|
+
terminateUnterminatedTail(runId) {
|
|
9620
|
+
const path = this.journalPath(runId);
|
|
9621
|
+
let fd;
|
|
9622
|
+
try {
|
|
9623
|
+
fd = openSync(path, "r");
|
|
9624
|
+
} catch (thrown) {
|
|
9625
|
+
if (thrown.code === "ENOENT") return;
|
|
9626
|
+
throw thrown;
|
|
9627
|
+
}
|
|
9628
|
+
let needsNewline = false;
|
|
9629
|
+
try {
|
|
9630
|
+
const size = fstatSync(fd).size;
|
|
9631
|
+
if (size > 0) {
|
|
9632
|
+
const lastByte = /* @__PURE__ */ new Uint8Array(1);
|
|
9633
|
+
readSync(fd, lastByte, 0, 1, size - 1);
|
|
9634
|
+
needsNewline = lastByte[0] !== 10;
|
|
9355
9635
|
}
|
|
9356
|
-
}
|
|
9357
|
-
|
|
9358
|
-
|
|
9636
|
+
} finally {
|
|
9637
|
+
closeSync(fd);
|
|
9638
|
+
}
|
|
9639
|
+
if (needsNewline) appendFileSync(path, "\n", "utf8");
|
|
9359
9640
|
}
|
|
9360
|
-
|
|
9641
|
+
repairTornTail(runId, whole) {
|
|
9642
|
+
const path = this.journalPath(runId);
|
|
9643
|
+
const temp = `${path}.tmp`;
|
|
9644
|
+
writeFileSync(temp, whole.map((entry) => JSON.stringify(entry)).join("\n") + (whole.length > 0 ? "\n" : ""), "utf8");
|
|
9645
|
+
renameSync(temp, path);
|
|
9646
|
+
}
|
|
9647
|
+
async putMeta(m) {
|
|
9648
|
+
const path = this.metaPath(m.runId);
|
|
9649
|
+
const temp = `${path}.tmp`;
|
|
9650
|
+
writeFileSync(temp, JSON.stringify(m, null, 2), "utf8");
|
|
9651
|
+
renameSync(temp, path);
|
|
9652
|
+
}
|
|
9653
|
+
async getMeta(runId) {
|
|
9361
9654
|
try {
|
|
9362
|
-
|
|
9363
|
-
} catch
|
|
9364
|
-
|
|
9655
|
+
return JSON.parse(readFileSync(this.metaPath(runId), "utf8"));
|
|
9656
|
+
} catch {
|
|
9657
|
+
return;
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
async listRuns(f) {
|
|
9661
|
+
const metas = [];
|
|
9662
|
+
for (const file of readdirSync(this.dir)) {
|
|
9663
|
+
if (!file.endsWith(META_SUFFIX)) continue;
|
|
9664
|
+
try {
|
|
9665
|
+
metas.push(JSON.parse(readFileSync(join(this.dir, file), "utf8")));
|
|
9666
|
+
} catch {}
|
|
9365
9667
|
}
|
|
9668
|
+
return metas.filter((meta) => metaMatchesFilter(meta, f));
|
|
9669
|
+
}
|
|
9670
|
+
async delete(runId) {
|
|
9671
|
+
rmSync(this.journalPath(runId), { force: true });
|
|
9672
|
+
rmSync(this.metaPath(runId), { force: true });
|
|
9673
|
+
this.lastSeq.delete(runId);
|
|
9366
9674
|
}
|
|
9367
9675
|
};
|
|
9368
|
-
|
|
9369
|
-
//#region src/model/pricing.ts
|
|
9676
|
+
const TRANSCRIPT_SUFFIX = ".bin";
|
|
9370
9677
|
/**
|
|
9371
|
-
*
|
|
9372
|
-
*
|
|
9373
|
-
*
|
|
9678
|
+
* File-backed TranscriptStore (M6-T02): blobs (transcripts, checkpoints,
|
|
9679
|
+
* persisted CompiledWorkflow sources) as one file per ref under `dir`,
|
|
9680
|
+
* so compiled runs resume across processes. Refs follow the
|
|
9681
|
+
* `<runId>/<name>` convention; nested segments become directories.
|
|
9682
|
+
*
|
|
9683
|
+
* Every ref is contained under `dir` (v1.36.0 review SEC-P1): each
|
|
9684
|
+
* segment must match `[A-Za-z0-9._-]` and be neither empty, '.', nor
|
|
9685
|
+
* '..', and the resolved path must stay under the resolved root. A '..'
|
|
9686
|
+
* segment used to pass the per-segment alphabet (dots are in it) and, via
|
|
9687
|
+
* `join`, escape the root; a caller passing an untrusted ref (or an
|
|
9688
|
+
* untrusted runId, which prefixes checkpoint and workflow-source refs)
|
|
9689
|
+
* could read, write, or delete `.bin` files outside `dir`.
|
|
9690
|
+
*/
|
|
9691
|
+
var FileTranscriptStore = class {
|
|
9692
|
+
dir;
|
|
9693
|
+
constructor(options) {
|
|
9694
|
+
this.dir = options.dir;
|
|
9695
|
+
mkdirSync(this.dir, { recursive: true });
|
|
9696
|
+
}
|
|
9697
|
+
blobPath(ref) {
|
|
9698
|
+
const segments = ref.split("/");
|
|
9699
|
+
for (const segment of segments) if (segment === "" || segment === "." || segment === ".." || !/^[A-Za-z0-9._-]+$/.test(segment)) throw new JournalOrderViolation(`FileTranscriptStore: ref segment '${segment}' is not filesystem-safe`);
|
|
9700
|
+
const name = segments.pop() ?? "";
|
|
9701
|
+
const path = join(this.dir, ...segments, `${name}${TRANSCRIPT_SUFFIX}`);
|
|
9702
|
+
const root = resolve(this.dir);
|
|
9703
|
+
const resolved = resolve(path);
|
|
9704
|
+
if (resolved !== root && !resolved.startsWith(`${root}${sep}`)) throw new JournalOrderViolation(`FileTranscriptStore: ref '${ref}' resolves outside the configured root`);
|
|
9705
|
+
return path;
|
|
9706
|
+
}
|
|
9707
|
+
async put(ref, blob) {
|
|
9708
|
+
const path = this.blobPath(ref);
|
|
9709
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
9710
|
+
const temp = `${path}.tmp`;
|
|
9711
|
+
writeFileSync(temp, blob);
|
|
9712
|
+
renameSync(temp, path);
|
|
9713
|
+
}
|
|
9714
|
+
async get(ref) {
|
|
9715
|
+
try {
|
|
9716
|
+
return new Uint8Array(readFileSync(this.blobPath(ref)));
|
|
9717
|
+
} catch (error) {
|
|
9718
|
+
if (error.code === "ENOENT") return null;
|
|
9719
|
+
throw error;
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
async list(runId) {
|
|
9723
|
+
if (runId === "." || runId === "..") throw new JournalOrderViolation(`FileTranscriptStore: runId '${runId}' is not filesystem-safe`);
|
|
9724
|
+
const root = join(this.dir, safeName(runId));
|
|
9725
|
+
const refs = [];
|
|
9726
|
+
const walk = (dir, prefix) => {
|
|
9727
|
+
let names;
|
|
9728
|
+
try {
|
|
9729
|
+
names = readdirSync(dir);
|
|
9730
|
+
} catch {
|
|
9731
|
+
return;
|
|
9732
|
+
}
|
|
9733
|
+
for (const name of names) {
|
|
9734
|
+
const path = join(dir, name);
|
|
9735
|
+
if (statSync(path).isDirectory()) walk(path, `${prefix}${name}/`);
|
|
9736
|
+
else if (name.endsWith(TRANSCRIPT_SUFFIX)) refs.push(`${prefix}${name.slice(0, -4)}`);
|
|
9737
|
+
}
|
|
9738
|
+
};
|
|
9739
|
+
walk(root, `${runId}/`);
|
|
9740
|
+
return refs.sort();
|
|
9741
|
+
}
|
|
9742
|
+
async delete(ref) {
|
|
9743
|
+
try {
|
|
9744
|
+
rmSync(this.blobPath(ref));
|
|
9745
|
+
} catch (error) {
|
|
9746
|
+
if (error.code !== "ENOENT") throw error;
|
|
9747
|
+
}
|
|
9748
|
+
}
|
|
9749
|
+
};
|
|
9750
|
+
//#endregion
|
|
9751
|
+
//#region src/model/pricing.ts
|
|
9752
|
+
/**
|
|
9753
|
+
* Resolves the pricing for a model: the versioned table wins; the
|
|
9754
|
+
* adapter-reported caps.pricing is the fallback; undefined means
|
|
9755
|
+
* unpriced (the CostReport surfaces it, never a silent zero).
|
|
9374
9756
|
*/
|
|
9375
9757
|
function resolvePricing(ref, table, capsPricing) {
|
|
9376
9758
|
return table?.models[ref] ?? capsPricing;
|
|
@@ -16482,490 +16864,202 @@ var AdmissionController = class {
|
|
|
16482
16864
|
const depth = spawnDepthOf(spec.childScope);
|
|
16483
16865
|
const childrenBefore = this.childrenOf.get(nodeKey) ?? 0;
|
|
16484
16866
|
const evaluated = this.evaluateLineage(spec);
|
|
16485
|
-
const statsBefore = {
|
|
16486
|
-
spawnsBefore: this.budget.spent().agentsSpawned,
|
|
16487
|
-
childrenOfParentBefore: childrenBefore,
|
|
16488
|
-
depth,
|
|
16489
|
-
...evaluated.statsBefore === void 0 ? {} : { lineage: evaluated.statsBefore }
|
|
16490
|
-
};
|
|
16491
|
-
if (evaluated.decision.kind === "reject") return {
|
|
16492
|
-
verdict: {
|
|
16493
|
-
kind: "reject",
|
|
16494
|
-
reason: evaluated.decision.reason
|
|
16495
|
-
},
|
|
16496
|
-
statsBefore
|
|
16497
|
-
};
|
|
16498
|
-
if (this.terminationAccount !== void 0) {
|
|
16499
|
-
if ((spec.ladderLength ?? 1) > this.terminationAccount.limits.kMax) return {
|
|
16500
|
-
verdict: {
|
|
16501
|
-
kind: "reject",
|
|
16502
|
-
reason: { code: "ladder_exceeds_frozen" }
|
|
16503
|
-
},
|
|
16504
|
-
statsBefore
|
|
16505
|
-
};
|
|
16506
|
-
if (this.terminationAccount.spawnUnitsExhausted) return {
|
|
16507
|
-
verdict: {
|
|
16508
|
-
kind: "reject",
|
|
16509
|
-
reason: { code: "termination_exhausted" }
|
|
16510
|
-
},
|
|
16511
|
-
statsBefore
|
|
16512
|
-
};
|
|
16513
|
-
}
|
|
16514
|
-
if (depth > this.maxDepth) return {
|
|
16515
|
-
verdict: {
|
|
16516
|
-
kind: "reject",
|
|
16517
|
-
reason: { code: "depth" }
|
|
16518
|
-
},
|
|
16519
|
-
statsBefore
|
|
16520
|
-
};
|
|
16521
|
-
if (childrenBefore >= this.maxChildrenPerNode) return {
|
|
16522
|
-
verdict: {
|
|
16523
|
-
kind: "reject",
|
|
16524
|
-
reason: { code: "quota" }
|
|
16525
|
-
},
|
|
16526
|
-
statsBefore
|
|
16527
|
-
};
|
|
16528
|
-
if (this.maxTotalSpawns !== void 0 && this.admittedTotal >= this.maxTotalSpawns) return {
|
|
16529
|
-
verdict: {
|
|
16530
|
-
kind: "reject",
|
|
16531
|
-
reason: { code: "lifetime" }
|
|
16532
|
-
},
|
|
16533
|
-
statsBefore
|
|
16534
|
-
};
|
|
16535
|
-
if (spec.roster !== void 0) {
|
|
16536
|
-
const seatsRemaining = spec.roster.floor - spec.roster.admittedChildren;
|
|
16537
|
-
if (seatsRemaining > 0) {
|
|
16538
|
-
const perSeatProjectionUsd = this.projectedDispatchReserveUsd(spec);
|
|
16539
|
-
const remainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16540
|
-
if (remainder !== void 0 && remainder < seatsRemaining * perSeatProjectionUsd + spec.roster.liveExposureUsd) return {
|
|
16541
|
-
verdict: {
|
|
16542
|
-
kind: "reject",
|
|
16543
|
-
reason: {
|
|
16544
|
-
code: "roster_floor",
|
|
16545
|
-
floor: spec.roster.floor,
|
|
16546
|
-
admittedChildren: spec.roster.admittedChildren,
|
|
16547
|
-
seatsRemaining,
|
|
16548
|
-
perSeatProjectionUsd,
|
|
16549
|
-
liveExposureUsd: spec.roster.liveExposureUsd,
|
|
16550
|
-
remainderUsd: remainder
|
|
16551
|
-
}
|
|
16552
|
-
},
|
|
16553
|
-
statsBefore
|
|
16554
|
-
};
|
|
16555
|
-
}
|
|
16556
|
-
}
|
|
16557
|
-
const spawnToolOrigin = spec.origin === "spawn_agent" || spec.origin === "parallel_agents";
|
|
16558
|
-
let childCeilingUsd;
|
|
16559
|
-
const parentRemainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16560
|
-
if (spawnToolOrigin) {
|
|
16561
|
-
if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
|
|
16562
|
-
} else if (parentRemainder !== void 0) {
|
|
16563
|
-
const fractionCap = this.childBudgetFraction * parentRemainder;
|
|
16564
|
-
childCeilingUsd = spec.budgetUsd === void 0 ? fractionCap : Math.min(spec.budgetUsd, fractionCap);
|
|
16565
|
-
} else if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
|
|
16566
|
-
let reserveUsd = spec.estCostUsd ?? this.flatReserveUsd;
|
|
16567
|
-
const source = spec.estCostUsd === void 0 ? "default" : "estCost";
|
|
16568
|
-
let clampedBy;
|
|
16569
|
-
if (childCeilingUsd !== void 0 && reserveUsd > childCeilingUsd) {
|
|
16570
|
-
clampedBy = spec.budgetUsd !== void 0 && childCeilingUsd === spec.budgetUsd ? "explicit-budget" : "fraction-ceiling";
|
|
16571
|
-
reserveUsd = childCeilingUsd;
|
|
16572
|
-
}
|
|
16573
|
-
const reserve = {
|
|
16574
|
-
reserveUsd,
|
|
16575
|
-
source
|
|
16576
|
-
};
|
|
16577
|
-
if (clampedBy !== void 0) reserve.clampedBy = clampedBy;
|
|
16578
|
-
if (childCeilingUsd !== void 0) reserve.childCeilingUsd = childCeilingUsd;
|
|
16579
|
-
if (this.budget.spawnHeadroom <= 0) return {
|
|
16580
|
-
verdict: {
|
|
16581
|
-
kind: "reject",
|
|
16582
|
-
reason: { code: "lifetime" }
|
|
16583
|
-
},
|
|
16584
|
-
statsBefore
|
|
16585
|
-
};
|
|
16586
|
-
if (commitReserve) try {
|
|
16587
|
-
this.budget.admitSpawn(reserveUsd, spec.parentAccountScope);
|
|
16588
|
-
} catch {
|
|
16589
|
-
return {
|
|
16590
|
-
verdict: {
|
|
16591
|
-
kind: "reject",
|
|
16592
|
-
reason: { code: "budget" }
|
|
16593
|
-
},
|
|
16594
|
-
statsBefore
|
|
16595
|
-
};
|
|
16596
|
-
}
|
|
16597
|
-
else {
|
|
16598
|
-
const remainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16599
|
-
const projection = this.projectedDispatchReserveUsd(spec);
|
|
16600
|
-
if (remainder !== void 0 && (remainder <= 0 || remainder < projection + (spec.pendingReserveUsd ?? 0))) return {
|
|
16601
|
-
verdict: {
|
|
16602
|
-
kind: "reject",
|
|
16603
|
-
reason: { code: "budget" }
|
|
16604
|
-
},
|
|
16605
|
-
statsBefore
|
|
16606
|
-
};
|
|
16607
|
-
}
|
|
16608
|
-
this.childrenOf.set(nodeKey, childrenBefore + 1);
|
|
16609
|
-
this.admittedTotal += 1;
|
|
16610
|
-
const lineage = evaluated.decision.lineage;
|
|
16611
|
-
this.registerLineageAdmit(lineage.logicalTaskId);
|
|
16612
|
-
let spawnUnitsAfter = this.budget.spawnHeadroom;
|
|
16613
|
-
if (this.terminationAccount !== void 0) {
|
|
16614
|
-
const debited = this.terminationAccount.debitSpawn({
|
|
16615
|
-
logicalTaskId: lineage.logicalTaskId,
|
|
16616
|
-
isNew: spec.lineage === void 0,
|
|
16617
|
-
ladderLength: spec.ladderLength ?? 1
|
|
16618
|
-
});
|
|
16619
|
-
if (!debited.ok) return {
|
|
16620
|
-
verdict: {
|
|
16621
|
-
kind: "reject",
|
|
16622
|
-
reason: { code: "termination_exhausted" }
|
|
16623
|
-
},
|
|
16624
|
-
statsBefore
|
|
16625
|
-
};
|
|
16626
|
-
spawnUnitsAfter = debited.spawnUnitsAfter;
|
|
16627
|
-
}
|
|
16628
|
-
return {
|
|
16629
|
-
verdict: {
|
|
16630
|
-
kind: "admit",
|
|
16631
|
-
reserve,
|
|
16632
|
-
spawnUnitsAfter,
|
|
16633
|
-
lineage: {
|
|
16634
|
-
logicalTaskId: lineage.logicalTaskId,
|
|
16635
|
-
isNew: spec.lineage === void 0,
|
|
16636
|
-
depth
|
|
16637
|
-
}
|
|
16638
|
-
},
|
|
16639
|
-
statsBefore,
|
|
16640
|
-
nodeId: this.mintId(),
|
|
16641
|
-
lineage,
|
|
16642
|
-
...this.terminationAccount === void 0 ? {} : { ladderLength: spec.ladderLength ?? 1 }
|
|
16643
|
-
};
|
|
16644
|
-
}
|
|
16645
|
-
/**
|
|
16646
|
-
* Resume roll-forward for an orchestrator child (M6-T07): restores the
|
|
16647
|
-
* children-quota counter only. The budget seed already counts settled
|
|
16648
|
-
* agent dispatches, and an in-flight child re-commits its reserve
|
|
16649
|
-
* through the ctx.agent dispatch path.
|
|
16650
|
-
*/
|
|
16651
|
-
recoverChild(nodeKey) {
|
|
16652
|
-
this.childrenOf.set(nodeKey, (this.childrenOf.get(nodeKey) ?? 0) + 1);
|
|
16653
|
-
this.admittedTotal += 1;
|
|
16654
|
-
}
|
|
16655
|
-
/**
|
|
16656
|
-
* Resume roll-forward for a child that already SETTLED before the
|
|
16657
|
-
* resume: re-registers the counters (maxChildrenPerNode, the lifetime
|
|
16658
|
-
* cap, statsBefore fidelity) without committing any reserve; the spend
|
|
16659
|
-
* itself sits in the root ledger seed.
|
|
16660
|
-
*/
|
|
16661
|
-
recoverSettled(parentAccountScope) {
|
|
16662
|
-
this.budget.admitRecovered(0, parentAccountScope);
|
|
16663
|
-
this.childrenOf.set(parentAccountScope, (this.childrenOf.get(parentAccountScope) ?? 0) + 1);
|
|
16664
|
-
this.admittedTotal += 1;
|
|
16665
|
-
}
|
|
16666
|
-
/**
|
|
16667
|
-
* Resume roll-forward for an admission whose decision entry exists but
|
|
16668
|
-
* whose child has NOT settled: re-applies the recorded reserve and
|
|
16669
|
-
* counters without re-evaluating any limit (replay never
|
|
16670
|
-
* re-evaluates admission; reserves are recovered, never
|
|
16671
|
-
* re-estimated).
|
|
16672
|
-
*/
|
|
16673
|
-
recoverInFlight(parentAccountScope, verdict) {
|
|
16674
|
-
if (verdict.kind === "reject") return;
|
|
16675
|
-
const reserveUsd = verdict.kind === "reuse_full" ? 0 : verdict.reserve.reserveUsd;
|
|
16676
|
-
this.budget.admitRecovered(reserveUsd, parentAccountScope);
|
|
16677
|
-
this.childrenOf.set(parentAccountScope, (this.childrenOf.get(parentAccountScope) ?? 0) + 1);
|
|
16678
|
-
this.admittedTotal += 1;
|
|
16679
|
-
}
|
|
16680
|
-
};
|
|
16681
|
-
//#endregion
|
|
16682
|
-
//#region src/l0/telemetry-reduce.ts
|
|
16683
|
-
const ZERO = {
|
|
16684
|
-
inputTokens: 0,
|
|
16685
|
-
outputTokens: 0,
|
|
16686
|
-
cacheReadTokens: 0,
|
|
16687
|
-
cacheWriteTokens: 0
|
|
16688
|
-
};
|
|
16689
|
-
/**
|
|
16690
|
-
* Reduces one run's event stream (or any slice of it) to the invocation
|
|
16691
|
-
* table. Feed it the events in emission order; both a live stream and a
|
|
16692
|
-
* replayed one produce the same usage and cost columns.
|
|
16693
|
-
*/
|
|
16694
|
-
function reduceInvocationTable(events) {
|
|
16695
|
-
const rows = /* @__PURE__ */ new Map();
|
|
16696
|
-
const order = [];
|
|
16697
|
-
const openPhases = /* @__PURE__ */ new Map();
|
|
16698
|
-
const byRole = {};
|
|
16699
|
-
let totalCostUsd = 0;
|
|
16700
|
-
const rowFor = (event) => {
|
|
16701
|
-
let row = rows.get(event.spanId);
|
|
16702
|
-
if (row === void 0) {
|
|
16703
|
-
row = {
|
|
16704
|
-
spanId: event.spanId,
|
|
16705
|
-
agentType: event.agentType,
|
|
16706
|
-
...event.label === void 0 ? {} : { label: event.label },
|
|
16707
|
-
usage: ZERO,
|
|
16708
|
-
costUsd: 0,
|
|
16709
|
-
costBasis: "aggregate-estimate",
|
|
16710
|
-
usageApprox: false,
|
|
16711
|
-
retryCount: 0,
|
|
16712
|
-
replayed: event.replayed === true,
|
|
16713
|
-
open: true,
|
|
16714
|
-
phases: []
|
|
16715
|
-
};
|
|
16716
|
-
rows.set(event.spanId, row);
|
|
16717
|
-
order.push(row);
|
|
16718
|
-
}
|
|
16719
|
-
return row;
|
|
16720
|
-
};
|
|
16721
|
-
for (const event of events) switch (event.type) {
|
|
16722
|
-
case "agent:start": {
|
|
16723
|
-
const row = rowFor(event);
|
|
16724
|
-
row.role = event.role;
|
|
16725
|
-
break;
|
|
16726
|
-
}
|
|
16727
|
-
case "agent:phase:start": {
|
|
16728
|
-
const row = rowFor(event);
|
|
16729
|
-
const phase = {
|
|
16730
|
-
invocation: event.invocation,
|
|
16731
|
-
role: event.role,
|
|
16732
|
-
model: event.model,
|
|
16733
|
-
durationMs: 0,
|
|
16734
|
-
usage: ZERO,
|
|
16735
|
-
costUsd: 0,
|
|
16736
|
-
costBasis: "aggregate-estimate",
|
|
16737
|
-
retries: 0,
|
|
16738
|
-
replayed: event.replayed === true,
|
|
16739
|
-
open: true
|
|
16740
|
-
};
|
|
16741
|
-
row.phases.push(phase);
|
|
16742
|
-
openPhases.set(`${event.spanId}#${event.invocation}`, phase);
|
|
16743
|
-
break;
|
|
16744
|
-
}
|
|
16745
|
-
case "agent:phase:end": {
|
|
16746
|
-
const key = `${event.spanId}#${event.invocation}`;
|
|
16747
|
-
let phase = openPhases.get(key);
|
|
16748
|
-
if (phase === void 0) {
|
|
16749
|
-
phase = {
|
|
16750
|
-
invocation: event.invocation,
|
|
16751
|
-
role: event.role,
|
|
16752
|
-
model: event.model,
|
|
16753
|
-
durationMs: 0,
|
|
16754
|
-
usage: ZERO,
|
|
16755
|
-
costUsd: 0,
|
|
16756
|
-
costBasis: "aggregate-estimate",
|
|
16757
|
-
retries: 0,
|
|
16758
|
-
replayed: event.replayed === true,
|
|
16759
|
-
open: true
|
|
16760
|
-
};
|
|
16761
|
-
rowFor(event).phases.push(phase);
|
|
16762
|
-
}
|
|
16763
|
-
openPhases.delete(key);
|
|
16764
|
-
phase.open = false;
|
|
16765
|
-
phase.role = event.role;
|
|
16766
|
-
phase.model = event.model;
|
|
16767
|
-
phase.durationMs = event.durationMs;
|
|
16768
|
-
phase.usage = event.usage;
|
|
16769
|
-
phase.costUsd = event.costUsd;
|
|
16770
|
-
phase.costBasis = event.costBasis ?? "aggregate-estimate";
|
|
16771
|
-
phase.outcome = event.outcome;
|
|
16772
|
-
phase.retries = event.retries ?? 0;
|
|
16773
|
-
const bucket = byRole[event.role] ??= {
|
|
16774
|
-
usage: ZERO,
|
|
16775
|
-
costUsd: 0,
|
|
16776
|
-
costBasis: "per-call"
|
|
16777
|
-
};
|
|
16778
|
-
bucket.usage = sumUsage(bucket.usage, event.usage);
|
|
16779
|
-
bucket.costUsd += event.costUsd;
|
|
16780
|
-
if (phase.costBasis === "aggregate-estimate") bucket.costBasis = "aggregate-estimate";
|
|
16781
|
-
break;
|
|
16782
|
-
}
|
|
16783
|
-
case "agent:end": {
|
|
16784
|
-
const row = rowFor(event);
|
|
16785
|
-
row.open = false;
|
|
16786
|
-
row.status = event.status;
|
|
16787
|
-
row.usage = event.usage;
|
|
16788
|
-
row.costUsd = event.costUsd;
|
|
16789
|
-
row.costBasis = event.costBasis ?? "aggregate-estimate";
|
|
16790
|
-
row.usageApprox = event.usageApprox === true;
|
|
16791
|
-
row.retryCount = event.retryCount ?? 0;
|
|
16792
|
-
if (event.toolBudget !== void 0) row.toolBudget = event.toolBudget;
|
|
16793
|
-
totalCostUsd += event.costUsd;
|
|
16794
|
-
break;
|
|
16795
|
-
}
|
|
16796
|
-
default: break;
|
|
16797
|
-
}
|
|
16798
|
-
return {
|
|
16799
|
-
agents: order,
|
|
16800
|
-
byRole,
|
|
16801
|
-
totalCostUsd
|
|
16802
|
-
};
|
|
16803
|
-
}
|
|
16804
|
-
/**
|
|
16805
|
-
* The label the claim-consistency judge invocation dispatches under
|
|
16806
|
-
* (RV1502; named here since RV1604 so the critical-path reducer and the
|
|
16807
|
-
* orchestrator share one constant): the judge rides role 'synthesize',
|
|
16808
|
-
* and this label is what tells its wall apart from a real final
|
|
16809
|
-
* composition in {@link reduceCriticalPath}.
|
|
16810
|
-
*/
|
|
16811
|
-
const CLAIM_JUDGE_LABEL = "claim-consistency-judge";
|
|
16812
|
-
/** Total length of the union of possibly overlapping intervals. */
|
|
16813
|
-
function unionLength(intervals) {
|
|
16814
|
-
const positive = intervals.filter((interval) => interval.to > interval.from);
|
|
16815
|
-
if (positive.length === 0) return 0;
|
|
16816
|
-
const sorted = [...positive].sort((a, b) => a.from - b.from);
|
|
16817
|
-
let total = 0;
|
|
16818
|
-
let from = sorted[0]?.from ?? 0;
|
|
16819
|
-
let to = sorted[0]?.to ?? 0;
|
|
16820
|
-
for (const interval of sorted.slice(1)) if (interval.from > to) {
|
|
16821
|
-
total += to - from;
|
|
16822
|
-
from = interval.from;
|
|
16823
|
-
to = interval.to;
|
|
16824
|
-
} else if (interval.to > to) to = interval.to;
|
|
16825
|
-
return total + (to - from);
|
|
16826
|
-
}
|
|
16827
|
-
function reduceCriticalPath(events) {
|
|
16828
|
-
let runStart;
|
|
16829
|
-
let runEnd;
|
|
16830
|
-
const startBySpan = /* @__PURE__ */ new Map();
|
|
16831
|
-
let lastWorkerEnd;
|
|
16832
|
-
let workerSpans = 0;
|
|
16833
|
-
let synthesisMs = 0;
|
|
16834
|
-
let finalCompositionMs = 0;
|
|
16835
|
-
let semanticJudgeMs = 0;
|
|
16836
|
-
const coordinationModel = [];
|
|
16837
|
-
const coordinationTools = [];
|
|
16838
|
-
const synthesisSpans = [];
|
|
16839
|
-
const spanOf = (durationMs) => Number.isFinite(durationMs) && durationMs > 0 ? durationMs : 0;
|
|
16840
|
-
for (const event of events) {
|
|
16841
|
-
const at = Date.parse(event.ts);
|
|
16842
|
-
if (!Number.isFinite(at)) continue;
|
|
16843
|
-
switch (event.type) {
|
|
16844
|
-
case "run:start":
|
|
16845
|
-
runStart ??= at;
|
|
16846
|
-
break;
|
|
16847
|
-
case "run:end":
|
|
16848
|
-
runEnd = at;
|
|
16849
|
-
break;
|
|
16850
|
-
case "agent:start":
|
|
16851
|
-
startBySpan.set(event.spanId, {
|
|
16852
|
-
role: event.role,
|
|
16853
|
-
at,
|
|
16854
|
-
...event.label === void 0 ? {} : { label: event.label }
|
|
16855
|
-
});
|
|
16856
|
-
break;
|
|
16857
|
-
case "agent:phase:end":
|
|
16858
|
-
if (startBySpan.get(event.spanId)?.role === "orchestrate") coordinationModel.push({
|
|
16859
|
-
phase: event.role,
|
|
16860
|
-
from: at - spanOf(event.durationMs),
|
|
16861
|
-
to: at
|
|
16862
|
-
});
|
|
16863
|
-
break;
|
|
16864
|
-
case "tool:end":
|
|
16865
|
-
if (startBySpan.get(event.spanId)?.role === "orchestrate") coordinationTools.push({
|
|
16866
|
-
name: event.toolName,
|
|
16867
|
-
from: at - spanOf(event.durationMs),
|
|
16868
|
-
to: at
|
|
16869
|
-
});
|
|
16870
|
-
break;
|
|
16871
|
-
case "agent:end": {
|
|
16872
|
-
const started = startBySpan.get(event.spanId);
|
|
16873
|
-
if (started === void 0) break;
|
|
16874
|
-
if (started.role === "synthesize") {
|
|
16875
|
-
const wall = Math.max(0, at - started.at);
|
|
16876
|
-
const judge = started.label === CLAIM_JUDGE_LABEL;
|
|
16877
|
-
synthesisMs += wall;
|
|
16878
|
-
if (judge) semanticJudgeMs += wall;
|
|
16879
|
-
else finalCompositionMs += wall;
|
|
16880
|
-
synthesisSpans.push({
|
|
16881
|
-
from: started.at,
|
|
16882
|
-
to: at,
|
|
16883
|
-
judge
|
|
16884
|
-
});
|
|
16885
|
-
} else if (started.role !== "orchestrate") {
|
|
16886
|
-
workerSpans += 1;
|
|
16887
|
-
lastWorkerEnd = lastWorkerEnd === void 0 ? at : Math.max(lastWorkerEnd, at);
|
|
16888
|
-
}
|
|
16889
|
-
break;
|
|
16867
|
+
const statsBefore = {
|
|
16868
|
+
spawnsBefore: this.budget.spent().agentsSpawned,
|
|
16869
|
+
childrenOfParentBefore: childrenBefore,
|
|
16870
|
+
depth,
|
|
16871
|
+
...evaluated.statsBefore === void 0 ? {} : { lineage: evaluated.statsBefore }
|
|
16872
|
+
};
|
|
16873
|
+
if (evaluated.decision.kind === "reject") return {
|
|
16874
|
+
verdict: {
|
|
16875
|
+
kind: "reject",
|
|
16876
|
+
reason: evaluated.decision.reason
|
|
16877
|
+
},
|
|
16878
|
+
statsBefore
|
|
16879
|
+
};
|
|
16880
|
+
if (this.terminationAccount !== void 0) {
|
|
16881
|
+
if ((spec.ladderLength ?? 1) > this.terminationAccount.limits.kMax) return {
|
|
16882
|
+
verdict: {
|
|
16883
|
+
kind: "reject",
|
|
16884
|
+
reason: { code: "ladder_exceeds_frozen" }
|
|
16885
|
+
},
|
|
16886
|
+
statsBefore
|
|
16887
|
+
};
|
|
16888
|
+
if (this.terminationAccount.spawnUnitsExhausted) return {
|
|
16889
|
+
verdict: {
|
|
16890
|
+
kind: "reject",
|
|
16891
|
+
reason: { code: "termination_exhausted" }
|
|
16892
|
+
},
|
|
16893
|
+
statsBefore
|
|
16894
|
+
};
|
|
16895
|
+
}
|
|
16896
|
+
if (depth > this.maxDepth) return {
|
|
16897
|
+
verdict: {
|
|
16898
|
+
kind: "reject",
|
|
16899
|
+
reason: { code: "depth" }
|
|
16900
|
+
},
|
|
16901
|
+
statsBefore
|
|
16902
|
+
};
|
|
16903
|
+
if (childrenBefore >= this.maxChildrenPerNode) return {
|
|
16904
|
+
verdict: {
|
|
16905
|
+
kind: "reject",
|
|
16906
|
+
reason: { code: "quota" }
|
|
16907
|
+
},
|
|
16908
|
+
statsBefore
|
|
16909
|
+
};
|
|
16910
|
+
if (this.maxTotalSpawns !== void 0 && this.admittedTotal >= this.maxTotalSpawns) return {
|
|
16911
|
+
verdict: {
|
|
16912
|
+
kind: "reject",
|
|
16913
|
+
reason: { code: "lifetime" }
|
|
16914
|
+
},
|
|
16915
|
+
statsBefore
|
|
16916
|
+
};
|
|
16917
|
+
if (spec.roster !== void 0) {
|
|
16918
|
+
const seatsRemaining = spec.roster.floor - spec.roster.admittedChildren;
|
|
16919
|
+
if (seatsRemaining > 0) {
|
|
16920
|
+
const perSeatProjectionUsd = this.projectedDispatchReserveUsd(spec);
|
|
16921
|
+
const remainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16922
|
+
if (remainder !== void 0 && remainder < seatsRemaining * perSeatProjectionUsd + spec.roster.liveExposureUsd) return {
|
|
16923
|
+
verdict: {
|
|
16924
|
+
kind: "reject",
|
|
16925
|
+
reason: {
|
|
16926
|
+
code: "roster_floor",
|
|
16927
|
+
floor: spec.roster.floor,
|
|
16928
|
+
admittedChildren: spec.roster.admittedChildren,
|
|
16929
|
+
seatsRemaining,
|
|
16930
|
+
perSeatProjectionUsd,
|
|
16931
|
+
liveExposureUsd: spec.roster.liveExposureUsd,
|
|
16932
|
+
remainderUsd: remainder
|
|
16933
|
+
}
|
|
16934
|
+
},
|
|
16935
|
+
statsBefore
|
|
16936
|
+
};
|
|
16890
16937
|
}
|
|
16891
|
-
default: break;
|
|
16892
16938
|
}
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
const
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16939
|
+
const spawnToolOrigin = spec.origin === "spawn_agent" || spec.origin === "parallel_agents";
|
|
16940
|
+
let childCeilingUsd;
|
|
16941
|
+
const parentRemainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16942
|
+
if (spawnToolOrigin) {
|
|
16943
|
+
if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
|
|
16944
|
+
} else if (parentRemainder !== void 0) {
|
|
16945
|
+
const fractionCap = this.childBudgetFraction * parentRemainder;
|
|
16946
|
+
childCeilingUsd = spec.budgetUsd === void 0 ? fractionCap : Math.min(spec.budgetUsd, fractionCap);
|
|
16947
|
+
} else if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
|
|
16948
|
+
let reserveUsd = spec.estCostUsd ?? this.flatReserveUsd;
|
|
16949
|
+
const source = spec.estCostUsd === void 0 ? "default" : "estCost";
|
|
16950
|
+
let clampedBy;
|
|
16951
|
+
if (childCeilingUsd !== void 0 && reserveUsd > childCeilingUsd) {
|
|
16952
|
+
clampedBy = spec.budgetUsd !== void 0 && childCeilingUsd === spec.budgetUsd ? "explicit-budget" : "fraction-ceiling";
|
|
16953
|
+
reserveUsd = childCeilingUsd;
|
|
16954
|
+
}
|
|
16955
|
+
const reserve = {
|
|
16956
|
+
reserveUsd,
|
|
16957
|
+
source
|
|
16958
|
+
};
|
|
16959
|
+
if (clampedBy !== void 0) reserve.clampedBy = clampedBy;
|
|
16960
|
+
if (childCeilingUsd !== void 0) reserve.childCeilingUsd = childCeilingUsd;
|
|
16961
|
+
if (this.budget.spawnHeadroom <= 0) return {
|
|
16962
|
+
verdict: {
|
|
16963
|
+
kind: "reject",
|
|
16964
|
+
reason: { code: "lifetime" }
|
|
16965
|
+
},
|
|
16966
|
+
statsBefore
|
|
16967
|
+
};
|
|
16968
|
+
if (commitReserve) try {
|
|
16969
|
+
this.budget.admitSpawn(reserveUsd, spec.parentAccountScope);
|
|
16970
|
+
} catch {
|
|
16907
16971
|
return {
|
|
16908
|
-
|
|
16909
|
-
|
|
16972
|
+
verdict: {
|
|
16973
|
+
kind: "reject",
|
|
16974
|
+
reason: { code: "budget" }
|
|
16975
|
+
},
|
|
16976
|
+
statsBefore
|
|
16910
16977
|
};
|
|
16911
|
-
};
|
|
16912
|
-
const byPhase = {};
|
|
16913
|
-
const modelClipped = [];
|
|
16914
|
-
for (const interval of coordinationModel) {
|
|
16915
|
-
const clipped = clip(interval);
|
|
16916
|
-
if (clipped === void 0) continue;
|
|
16917
|
-
byPhase[interval.phase] = (byPhase[interval.phase] ?? 0) + (clipped.to - clipped.from);
|
|
16918
|
-
modelClipped.push(clipped);
|
|
16919
16978
|
}
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
|
|
16928
|
-
|
|
16979
|
+
else {
|
|
16980
|
+
const remainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
16981
|
+
const projection = this.projectedDispatchReserveUsd(spec);
|
|
16982
|
+
if (remainder !== void 0 && (remainder <= 0 || remainder < projection + (spec.pendingReserveUsd ?? 0))) return {
|
|
16983
|
+
verdict: {
|
|
16984
|
+
kind: "reject",
|
|
16985
|
+
reason: { code: "budget" }
|
|
16986
|
+
},
|
|
16987
|
+
statsBefore
|
|
16988
|
+
};
|
|
16929
16989
|
}
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
const
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16990
|
+
this.childrenOf.set(nodeKey, childrenBefore + 1);
|
|
16991
|
+
this.admittedTotal += 1;
|
|
16992
|
+
const lineage = evaluated.decision.lineage;
|
|
16993
|
+
this.registerLineageAdmit(lineage.logicalTaskId);
|
|
16994
|
+
let spawnUnitsAfter = this.budget.spawnHeadroom;
|
|
16995
|
+
if (this.terminationAccount !== void 0) {
|
|
16996
|
+
const debited = this.terminationAccount.debitSpawn({
|
|
16997
|
+
logicalTaskId: lineage.logicalTaskId,
|
|
16998
|
+
isNew: spec.lineage === void 0,
|
|
16999
|
+
ladderLength: spec.ladderLength ?? 1
|
|
17000
|
+
});
|
|
17001
|
+
if (!debited.ok) return {
|
|
17002
|
+
verdict: {
|
|
17003
|
+
kind: "reject",
|
|
17004
|
+
reason: { code: "termination_exhausted" }
|
|
17005
|
+
},
|
|
17006
|
+
statsBefore
|
|
17007
|
+
};
|
|
17008
|
+
spawnUnitsAfter = debited.spawnUnitsAfter;
|
|
16939
17009
|
}
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
finalCompositionMs: compositionClippedMs,
|
|
16956
|
-
semanticJudgeMs: judgeClippedMs,
|
|
16957
|
-
coveredMs,
|
|
16958
|
-
residueMs: Math.max(0, path.postFanInMs - coveredMs)
|
|
17010
|
+
return {
|
|
17011
|
+
verdict: {
|
|
17012
|
+
kind: "admit",
|
|
17013
|
+
reserve,
|
|
17014
|
+
spawnUnitsAfter,
|
|
17015
|
+
lineage: {
|
|
17016
|
+
logicalTaskId: lineage.logicalTaskId,
|
|
17017
|
+
isNew: spec.lineage === void 0,
|
|
17018
|
+
depth
|
|
17019
|
+
}
|
|
17020
|
+
},
|
|
17021
|
+
statsBefore,
|
|
17022
|
+
nodeId: this.mintId(),
|
|
17023
|
+
lineage,
|
|
17024
|
+
...this.terminationAccount === void 0 ? {} : { ladderLength: spec.ladderLength ?? 1 }
|
|
16959
17025
|
};
|
|
16960
|
-
if (path.postFanInMs > 0) breakdown.residueShare = breakdown.residueMs / path.postFanInMs;
|
|
16961
|
-
path.postFanIn = breakdown;
|
|
16962
17026
|
}
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
17027
|
+
/**
|
|
17028
|
+
* Resume roll-forward for an orchestrator child (M6-T07): restores the
|
|
17029
|
+
* children-quota counter only. The budget seed already counts settled
|
|
17030
|
+
* agent dispatches, and an in-flight child re-commits its reserve
|
|
17031
|
+
* through the ctx.agent dispatch path.
|
|
17032
|
+
*/
|
|
17033
|
+
recoverChild(nodeKey) {
|
|
17034
|
+
this.childrenOf.set(nodeKey, (this.childrenOf.get(nodeKey) ?? 0) + 1);
|
|
17035
|
+
this.admittedTotal += 1;
|
|
16966
17036
|
}
|
|
16967
|
-
|
|
16968
|
-
|
|
17037
|
+
/**
|
|
17038
|
+
* Resume roll-forward for a child that already SETTLED before the
|
|
17039
|
+
* resume: re-registers the counters (maxChildrenPerNode, the lifetime
|
|
17040
|
+
* cap, statsBefore fidelity) without committing any reserve; the spend
|
|
17041
|
+
* itself sits in the root ledger seed.
|
|
17042
|
+
*/
|
|
17043
|
+
recoverSettled(parentAccountScope) {
|
|
17044
|
+
this.budget.admitRecovered(0, parentAccountScope);
|
|
17045
|
+
this.childrenOf.set(parentAccountScope, (this.childrenOf.get(parentAccountScope) ?? 0) + 1);
|
|
17046
|
+
this.admittedTotal += 1;
|
|
17047
|
+
}
|
|
17048
|
+
/**
|
|
17049
|
+
* Resume roll-forward for an admission whose decision entry exists but
|
|
17050
|
+
* whose child has NOT settled: re-applies the recorded reserve and
|
|
17051
|
+
* counters without re-evaluating any limit (replay never
|
|
17052
|
+
* re-evaluates admission; reserves are recovered, never
|
|
17053
|
+
* re-estimated).
|
|
17054
|
+
*/
|
|
17055
|
+
recoverInFlight(parentAccountScope, verdict) {
|
|
17056
|
+
if (verdict.kind === "reject") return;
|
|
17057
|
+
const reserveUsd = verdict.kind === "reuse_full" ? 0 : verdict.reserve.reserveUsd;
|
|
17058
|
+
this.budget.admitRecovered(reserveUsd, parentAccountScope);
|
|
17059
|
+
this.childrenOf.set(parentAccountScope, (this.childrenOf.get(parentAccountScope) ?? 0) + 1);
|
|
17060
|
+
this.admittedTotal += 1;
|
|
17061
|
+
}
|
|
17062
|
+
};
|
|
16969
17063
|
//#endregion
|
|
16970
17064
|
//#region src/model/profile-card.ts
|
|
16971
17065
|
function toolNamesOf(profile) {
|
|
@@ -18708,6 +18802,7 @@ function createCtx(internals, rootWorkflow) {
|
|
|
18708
18802
|
agentType,
|
|
18709
18803
|
role: primaryRole,
|
|
18710
18804
|
budgetAccount: state.budgetScope ?? "run",
|
|
18805
|
+
...opts.label === void 0 ? {} : { label: opts.label },
|
|
18711
18806
|
...opts[kFinalizeReserve] === true ? { finalizeReserve: true } : {}
|
|
18712
18807
|
},
|
|
18713
18808
|
transcriptRef: result.transcriptRef
|
|
@@ -28316,4 +28411,4 @@ function createSandboxBridge(ctx, options) {
|
|
|
28316
28411
|
};
|
|
28317
28412
|
}
|
|
28318
28413
|
//#endregion
|
|
28319
|
-
export { AWAIT_SCHEMA, AdmissionController, AdmissionRejectedError, AgentCallError, BUDGET_ABORT_REASON, BudgetExhaustedError, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_JUDGE_LABEL, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, ConfigError, DECISION_CHAIN_KINDS, DEFAULT_ANCHOR_PATTERN, DEFAULT_ARTIFACT_PATTERN, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_CITATION_SAMPLE, DEFAULT_CLAIM_JUDGE_MAX_TURNS, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_CALLS_PER_ENTRY, DEFAULT_EVIDENCE_GRADE_PHRASES, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_EVIDENCE_OVERHEAD_CALLS, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_CLAIM_PAIRS, DEFAULT_MAX_CONTRADICTIONS, DEFAULT_MAX_DEPTH, DEFAULT_MAX_EXCERPT_CHARS, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PAIR_EXCERPT_CHARS, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_POOL_PER_PAIR, DEFAULT_MAX_QUOTA_DENIALS, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_RUN_FACT_PAIRS, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_SYNTHESIS_MAX_TURNS, DEFAULT_SYNTHESIS_NOTE_MAX_TURNS, DedupIndex, DeterminismError, EMIT_RESULT_TOOL, EMPTY_AUTHORITY_HASH, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EXPOSURE_WAIT_SWEEP_MS, EscalationDecisionAbortedError, EventBus, ExternalRegistry, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_SECTIONAL_SCHEMA, FINISH_TOOL_NAME, FUTURE_RATES_TOLERANCE_MS, FailRunError, FileModelKnowledgeStore, FileTranscriptStore, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, GET_SETTLED_CHILD_RESULTS_SCHEMA, GET_SETTLED_CHILD_RESULTS_TOOL_NAME, GitWorktreeProvider, IMPLEMENTATION_PROFILE_LIMITS, INBOX_PROPOSAL_TTL_DAYS, IN_FLIGHT_EXPOSURE_REFUSAL_PREFIX, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, JOURNAL_ENVELOPE_MARKER, JournalCompatibilityError, JournalMatcher, JournalMissError, JournalOrderViolation, JournalSealedError, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, KeyedLimiter, KnowledgeCasError, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LeaseHeldError, LineageIndex, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_CRITICAL_UNCOVERED, MAX_DEPTH_CEILING, MAX_RUN_FACTS_SHEET_CHARS, MAX_RUN_ID_LENGTH, MAX_TIMER_DELAY_MS, ModelRetry, NoProgressDetector, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OrchestratorCapConfigError, PARALLEL_AGENTS_SCHEMA, PROGRESS_REPORT_TOOL_NAME, ParallelSiteCounter, PlanInvariantError, QUOTA_WINDOW_MS, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, RESEARCH_PROFILE_LIMITS, REVIEW_PROFILE_LIMITS, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_FACTS_ANCHOR, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionFold, RulvarError, RunBudget, SANDBOX_AGENT_OPT_KEYS, SPAWN_ADMISSION_DECISION_TYPE, SPAWN_AGENT_SCHEMA, SandboxError, ScriptRejected, Semaphore, SettlementError, SpanRegistry, SupersededError, TERMINAL_TELEMETRY_SCOPE, TOOL_NAME_PATTERN, TerminationAccount, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, accountSpendFromJournal, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, assertSafeRunId, atCompactionThreshold, attestToolset, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, childRostersFromJournal, citationTargetsValidator, citedValueValidator, claimCoverageOf, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compareRates, compilePermissionChain, compilePermissionPreset, compileSecretMasker, compileVerifiedLayer, constantTimeEqual, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createEnvelopeEncryption, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, dedupeRepeatedClaims, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispatchProjectionReserveUsd, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, enforceToolsetAttestation, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidenceGradeValidator, evidencePreservedValidator, executeWorkflow, executionFactsOf, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, findContradictions, finishContract, foldLedger, foldTermination, formatCharacterValidator, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, headingStructureValidator, identityJcs, implementationAgentProfile, invoiceFromJournal, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, journalPricingSnapshot, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, latestProgressReport, lexShellCommand, liftRetainedParts, lineageWeightOf, localKeyProvider, logicalRunTelemetry, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, memoryQuotaLimiter, mergeQuotaDenial, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, orchestratorAdmissionEstCostUsd, pairDraftClaims, pairRunFactClaims, parallelScope, parseModelRef, parseScopePath, persistedTerminalEnvelope, phiInitialOf, pilotAgentProfile, pipelineScope, planNodeScope, preflightEstimate, priceComponentsOf, priceEntryBilling, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, progressReportTool, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, quotaActualRequestsDelta, quotaActualTokens, quotaEstimateTokens, quotaRuleAdmission, quotaRuleKey, quotaRuleMatches, readRunMeta, readTerminationInit, reconcileRunMeta, reconcileStatement, reduceAuditTrail, reduceCriticalPath, reduceDecisionChain, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, repositoryResearchToolset, requiredFieldsValidator, requiredSectionsValidator, researchAgentProfile, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, reviewAgentProfile, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, sectionCitationsValidator, sectionPatternCountValidator, selectStructuredOutputTier, selfTestFinishValidation, shouldCompact, snapshotQuotaRules, snapshotUsage, spawnDepthOf, spliceSections, statementFromRows, stripFencedBlocks, sumUsage, summarizeInstruction, summarizeOutput, terminalEnvelopeOf, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolAuthority, toolContract, toolContractHash, toolsetAuthorityHash, toolsetHash, ttlState, usageViolations, validateDetachedResolution, validateEditorialCommit, validateEngineQuotaConfig, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateQuotaRules, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateToolsetAttestation, validateUsageLimits, wordCountValidator, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
|
28414
|
+
export { AWAIT_SCHEMA, AdmissionController, AdmissionRejectedError, AgentCallError, BUDGET_ABORT_REASON, BudgetExhaustedError, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_JUDGE_LABEL, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, ConfigError, DECISION_CHAIN_KINDS, DEFAULT_ANCHOR_PATTERN, DEFAULT_ARTIFACT_PATTERN, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_CITATION_SAMPLE, DEFAULT_CLAIM_JUDGE_MAX_TURNS, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_CALLS_PER_ENTRY, DEFAULT_EVIDENCE_GRADE_PHRASES, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_EVIDENCE_OVERHEAD_CALLS, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_CLAIM_PAIRS, DEFAULT_MAX_CONTRADICTIONS, DEFAULT_MAX_DEPTH, DEFAULT_MAX_EXCERPT_CHARS, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PAIR_EXCERPT_CHARS, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_POOL_PER_PAIR, DEFAULT_MAX_QUOTA_DENIALS, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_RUN_FACT_PAIRS, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_SYNTHESIS_MAX_TURNS, DEFAULT_SYNTHESIS_NOTE_MAX_TURNS, DedupIndex, DeterminismError, EMIT_RESULT_TOOL, EMPTY_AUTHORITY_HASH, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EXPOSURE_WAIT_SWEEP_MS, EscalationDecisionAbortedError, EventBus, ExternalRegistry, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_SECTIONAL_SCHEMA, FINISH_TOOL_NAME, FUTURE_RATES_TOLERANCE_MS, FailRunError, FileModelKnowledgeStore, FileTranscriptStore, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, GET_SETTLED_CHILD_RESULTS_SCHEMA, GET_SETTLED_CHILD_RESULTS_TOOL_NAME, GitWorktreeProvider, IMPLEMENTATION_PROFILE_LIMITS, INBOX_PROPOSAL_TTL_DAYS, IN_FLIGHT_EXPOSURE_REFUSAL_PREFIX, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, JOURNAL_ENVELOPE_MARKER, JournalCompatibilityError, JournalMatcher, JournalMissError, JournalOrderViolation, JournalSealedError, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, KeyedLimiter, KnowledgeCasError, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LeaseHeldError, LineageIndex, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_CRITICAL_UNCOVERED, MAX_DEPTH_CEILING, MAX_RUN_FACTS_SHEET_CHARS, MAX_RUN_ID_LENGTH, MAX_TIMER_DELAY_MS, ModelRetry, NoProgressDetector, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OrchestratorCapConfigError, PARALLEL_AGENTS_SCHEMA, PROGRESS_REPORT_TOOL_NAME, ParallelSiteCounter, PlanInvariantError, QUOTA_WINDOW_MS, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, RESEARCH_PROFILE_LIMITS, REVIEW_PROFILE_LIMITS, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_FACTS_ANCHOR, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionFold, RulvarError, RunBudget, SANDBOX_AGENT_OPT_KEYS, SPAWN_ADMISSION_DECISION_TYPE, SPAWN_AGENT_SCHEMA, SandboxError, ScriptRejected, Semaphore, SettlementError, SpanRegistry, SupersededError, TERMINAL_TELEMETRY_SCOPE, TOOL_NAME_PATTERN, TerminationAccount, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, accountSpendFromJournal, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, assertSafeRunId, atCompactionThreshold, attestToolset, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, childRostersFromJournal, citationTargetsValidator, citedValueValidator, claimCoverageOf, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compareRates, compilePermissionChain, compilePermissionPreset, compileSecretMasker, compileVerifiedLayer, constantTimeEqual, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createEnvelopeEncryption, createSandboxBridge, criticalPathFromJournal, currentOnlyKeyRing, decodeCheckpoint, dedupeRepeatedClaims, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispatchProjectionReserveUsd, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, enforceToolsetAttestation, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidenceGradeValidator, evidencePreservedValidator, executeWorkflow, executionFactsOf, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, findContradictions, finishContract, foldLedger, foldTermination, formatCharacterValidator, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, headingStructureValidator, identityJcs, implementationAgentProfile, invoiceFromJournal, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, journalPricingSnapshot, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, latestProgressReport, lexShellCommand, liftRetainedParts, lineageWeightOf, localKeyProvider, logicalRunTelemetry, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, memoryQuotaLimiter, mergeQuotaDenial, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, orchestratorAdmissionEstCostUsd, pairDraftClaims, pairRunFactClaims, parallelScope, parseModelRef, parseScopePath, persistedTerminalEnvelope, phiInitialOf, pilotAgentProfile, pipelineScope, planNodeScope, preflightEstimate, priceComponentsOf, priceEntryBilling, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, progressReportTool, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, quotaActualRequestsDelta, quotaActualTokens, quotaEstimateTokens, quotaRuleAdmission, quotaRuleKey, quotaRuleMatches, readRunMeta, readTerminationInit, reconcileRunMeta, reconcileStatement, reduceAuditTrail, reduceCriticalPath, reduceDecisionChain, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, repositoryResearchToolset, requiredFieldsValidator, requiredSectionsValidator, researchAgentProfile, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, reviewAgentProfile, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, sectionCitationsValidator, sectionPatternCountValidator, selectStructuredOutputTier, selfTestFinishValidation, shouldCompact, snapshotQuotaRules, snapshotUsage, spawnDepthOf, spliceSections, statementFromRows, stripFencedBlocks, sumUsage, summarizeInstruction, summarizeOutput, terminalEnvelopeOf, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolAuthority, toolContract, toolContractHash, toolsetAuthorityHash, toolsetHash, ttlState, usageViolations, validateDetachedResolution, validateEditorialCommit, validateEngineQuotaConfig, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateQuotaRules, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateToolsetAttestation, validateUsageLimits, wordCountValidator, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|