@rulvar/core 1.226.0 → 1.228.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 +489 -10
- package/dist/index.js +531 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8745,6 +8745,94 @@ function lastRunSettle(entries) {
|
|
|
8745
8745
|
}
|
|
8746
8746
|
}
|
|
8747
8747
|
}
|
|
8748
|
+
/**
|
|
8749
|
+
* The scope of every field the engine writes onto a terminal (RV2510),
|
|
8750
|
+
* as one exported table rather than as sentences scattered through
|
|
8751
|
+
* field docs.
|
|
8752
|
+
*
|
|
8753
|
+
* The twenty-fifth comparison run was killed and resumed, and its two
|
|
8754
|
+
* terminals mixed both kinds with nothing marking which was which: the
|
|
8755
|
+
* money was cumulative, the wake count and the replay figures were not,
|
|
8756
|
+
* and reconciling them into one honest account of the logical run was
|
|
8757
|
+
* hand work over a joined journal. Keys are field paths as a consumer
|
|
8758
|
+
* reads them off `RunOutcome` (`cost.orchestrator.wakes`); the
|
|
8759
|
+
* doctrine test holds this table against the keys a real outcome
|
|
8760
|
+
* carries, so a new terminal field cannot ship without declaring what
|
|
8761
|
+
* it counts.
|
|
8762
|
+
*/
|
|
8763
|
+
const TERMINAL_TELEMETRY_SCOPE = Object.freeze({
|
|
8764
|
+
status: "terminal",
|
|
8765
|
+
value: "terminal",
|
|
8766
|
+
error: "terminal",
|
|
8767
|
+
envelope: "terminal",
|
|
8768
|
+
completion: "terminal",
|
|
8769
|
+
childStatusCounts: "cumulative",
|
|
8770
|
+
degradedReasons: "cumulative",
|
|
8771
|
+
salvagedPartialChildren: "cumulative",
|
|
8772
|
+
salvagedTerminalOutputChildren: "cumulative",
|
|
8773
|
+
belowFloorOkChildren: "cumulative",
|
|
8774
|
+
acceptanceChildren: "cumulative",
|
|
8775
|
+
semanticPasses: "terminal",
|
|
8776
|
+
claimConsistencyMeta: "terminal",
|
|
8777
|
+
synthesisSkipped: "terminal",
|
|
8778
|
+
deliverableAccepted: "terminal",
|
|
8779
|
+
resultAvailable: "terminal",
|
|
8780
|
+
acceptedArtifactRef: "terminal",
|
|
8781
|
+
rejectedFinishCandidates: "cumulative",
|
|
8782
|
+
dropped: "cumulative",
|
|
8783
|
+
pending: "terminal",
|
|
8784
|
+
usage: "cumulative",
|
|
8785
|
+
cost: "cumulative",
|
|
8786
|
+
"cost.totalUsd": "cumulative",
|
|
8787
|
+
"cost.grossUsd": "cumulative",
|
|
8788
|
+
"cost.wireRequests": "cumulative",
|
|
8789
|
+
"cost.orchestrator.spentUsd": "cumulative",
|
|
8790
|
+
"cost.orchestrator.wakes": "segment",
|
|
8791
|
+
"cost.orchestrator.forcedFinish": "segment",
|
|
8792
|
+
"cost.orchestrator.reserveUsedUsd": "segment",
|
|
8793
|
+
transportRetries: "segment",
|
|
8794
|
+
schemaRejectedFinishExchanges: "segment",
|
|
8795
|
+
schemaRecoveredFinishExchanges: "segment"
|
|
8796
|
+
});
|
|
8797
|
+
/**
|
|
8798
|
+
* Folds a run's journal into the logical run's telemetry (RV2510): how
|
|
8799
|
+
* many segments ran, how each settled, and how much durable work each
|
|
8800
|
+
* one did, from entries the journal already holds. No new field, so it
|
|
8801
|
+
* reads journals written by every prior version exactly as well as
|
|
8802
|
+
* today's.
|
|
8803
|
+
*
|
|
8804
|
+
* The replay dedup is the design. Cumulative figures are deliberately
|
|
8805
|
+
* NOT here: money and usage fold from the WHOLE journal through
|
|
8806
|
+
* `costReportFromJournal` and the usage ledger, and re-summing them per
|
|
8807
|
+
* segment would count every replayed operation once per segment that
|
|
8808
|
+
* replayed it, which is exactly the reconciliation this fold exists to
|
|
8809
|
+
* make unnecessary. What it reports instead is a PARTITION of the
|
|
8810
|
+
* journal by settle boundary, so no entry is counted twice by
|
|
8811
|
+
* construction, and the segment-scoped figures a terminal carries
|
|
8812
|
+
* ({@link TERMINAL_TELEMETRY_SCOPE} names them) can be read against the
|
|
8813
|
+
* segment that produced them.
|
|
8814
|
+
*/
|
|
8815
|
+
function logicalRunTelemetry(entries) {
|
|
8816
|
+
const statuses = [];
|
|
8817
|
+
const entriesPerSegment = [];
|
|
8818
|
+
let sinceLastSettle = 0;
|
|
8819
|
+
for (const entry of entries) {
|
|
8820
|
+
sinceLastSettle += 1;
|
|
8821
|
+
if (entry.kind !== "decision") continue;
|
|
8822
|
+
const value = entry.value;
|
|
8823
|
+
if (value?.decisionType !== "run_settle" || typeof value.runStatus !== "string" || !RUN_STATUSES.has(value.runStatus)) continue;
|
|
8824
|
+
statuses.push(value.runStatus);
|
|
8825
|
+
entriesPerSegment.push(sinceLastSettle);
|
|
8826
|
+
sinceLastSettle = 0;
|
|
8827
|
+
}
|
|
8828
|
+
return {
|
|
8829
|
+
segments: statuses.length,
|
|
8830
|
+
statuses,
|
|
8831
|
+
entriesPerSegment,
|
|
8832
|
+
entries: entries.length,
|
|
8833
|
+
entriesAfterLastSettle: sinceLastSettle
|
|
8834
|
+
};
|
|
8835
|
+
}
|
|
8748
8836
|
function structure(entries) {
|
|
8749
8837
|
const referenced = /* @__PURE__ */ new Set();
|
|
8750
8838
|
for (const entry of entries) if (entry.ref !== void 0) referenced.add(entry.ref);
|
|
@@ -10926,11 +11014,16 @@ function applyOutputBudget(req, target, budget) {
|
|
|
10926
11014
|
const floor = outputFloorOf(target);
|
|
10927
11015
|
if (req.maxOutputTokens !== void 0 && req.maxOutputTokens < floor) throw new ConfigError(`the per-turn output cap ${String(req.maxOutputTokens)} is below the ${String(floor)} token output floor of ${target.resolved.ref}; the provider would reject every dispatch, so raise limits.maxOutputTokensPerTurn to at least the floor`);
|
|
10928
11016
|
const hook = budget?.maxAffordableOutputTokens;
|
|
10929
|
-
|
|
10930
|
-
|
|
11017
|
+
const exposureHook = budget?.maxExposureOutputTokens;
|
|
11018
|
+
if (hook === void 0 && exposureHook === void 0) return req;
|
|
11019
|
+
const estimatedInput = estimateInputTokens(req.messages);
|
|
11020
|
+
const budgetAffordable = hook?.(target.resolved.ref, estimatedInput);
|
|
11021
|
+
const exposureAffordable = exposureHook?.(target.resolved.ref, estimatedInput);
|
|
11022
|
+
const usableExposure = exposureAffordable !== void 0 && exposureAffordable >= floor ? exposureAffordable : void 0;
|
|
11023
|
+
const affordable = budgetAffordable === void 0 ? usableExposure : usableExposure === void 0 ? budgetAffordable : Math.min(budgetAffordable, usableExposure);
|
|
10931
11024
|
if (affordable === void 0) return req;
|
|
10932
11025
|
if (affordable < floor) {
|
|
10933
|
-
const zeroInputAffordable = hook(target.resolved.ref, 0);
|
|
11026
|
+
const zeroInputAffordable = hook?.(target.resolved.ref, 0);
|
|
10934
11027
|
if (zeroInputAffordable !== void 0 && zeroInputAffordable < floor) throw new BudgetExhaustedError(floor === 1 ? `the remaining budget cannot afford one output token from ${target.resolved.ref}; the turn was not dispatched` : `the remaining budget cannot afford the ${String(floor)} token output floor of ${target.resolved.ref}; the turn was not dispatched`, { data: { reason: "output-floor" } });
|
|
10935
11028
|
return {
|
|
10936
11029
|
...req,
|
|
@@ -13572,7 +13665,12 @@ async function runAgent(options) {
|
|
|
13572
13665
|
* model, and a turn that cannot afford one output token is denied before
|
|
13573
13666
|
* dispatch. Layer 3: the AbortSignal ceiling severing live streams, with
|
|
13574
13667
|
* partial usage written usageApprox.
|
|
13575
|
-
* B0 is immutable
|
|
13668
|
+
* B0 is immutable WITHIN a segment: no API tops up a live run's ceiling
|
|
13669
|
+
* (RV2511 corrects the older "immutable after start", which RV2208 made
|
|
13670
|
+
* false). The one thing that can change it is `ResumeOptions.run`, an
|
|
13671
|
+
* explicit host decision journaled as its own decision entry, and it
|
|
13672
|
+
* takes effect only by opening a NEW segment: a live run can never
|
|
13673
|
+
* raise the bound it is already being measured against.
|
|
13576
13674
|
*
|
|
13577
13675
|
* The account tree: the run root plus one
|
|
13578
13676
|
* sub-account per admitted child workflow (and, from M7, the orchestrator
|
|
@@ -13677,6 +13775,8 @@ var RunBudget = class {
|
|
|
13677
13775
|
* reservation surface is inert and reserveTurnExposure never binds.
|
|
13678
13776
|
*/
|
|
13679
13777
|
maxInFlightExposureUsd;
|
|
13778
|
+
/** The opt-in lone-dispatch clamp (RV2503); see maxExposureOutputTokens. */
|
|
13779
|
+
clampTurnToExposure = false;
|
|
13680
13780
|
lifetimeSpawnCap;
|
|
13681
13781
|
events;
|
|
13682
13782
|
priceUsd;
|
|
@@ -13745,6 +13845,7 @@ var RunBudget = class {
|
|
|
13745
13845
|
requireValidCeiling(options.maxInFlightExposureUsd, "maxInFlightExposureUsd");
|
|
13746
13846
|
this.maxInFlightExposureUsd = options.maxInFlightExposureUsd;
|
|
13747
13847
|
}
|
|
13848
|
+
this.clampTurnToExposure = options.clampTurnToExposure === true;
|
|
13748
13849
|
this.lifetimeSpawnCap = options.lifetimeSpawnCap ?? 500;
|
|
13749
13850
|
if (options.events !== void 0) this.events = options.events;
|
|
13750
13851
|
if (options.priceUsd !== void 0) this.priceUsd = options.priceUsd;
|
|
@@ -14327,6 +14428,59 @@ var RunBudget = class {
|
|
|
14327
14428
|
return affordableOutputTokens(pricing, remainingUsd, estimatedInputTokens);
|
|
14328
14429
|
}
|
|
14329
14430
|
/**
|
|
14431
|
+
* The same layer-2b question asked of the IN-FLIGHT EXPOSURE ceiling
|
|
14432
|
+
* (RV2503): the output tokens `cap - spent - live estimates` still
|
|
14433
|
+
* affords from `servedBy` for an estimated prompt, priced by the
|
|
14434
|
+
* settlement function like every other estimate here.
|
|
14435
|
+
*
|
|
14436
|
+
* The clamp above has always existed for the budget ceiling while
|
|
14437
|
+
* {@link reserveTurnExposure} only ever answered yes or no, so a
|
|
14438
|
+
* turn whose FULL planned output overshot the exposure line was
|
|
14439
|
+
* refused outright even when a shorter one fit and the budget could
|
|
14440
|
+
* pay for it. The 1.226.0 comparison run died exactly there: it held
|
|
14441
|
+
* 0.8642 USD of budget, the exposure ceiling had 0.5642 USD of room,
|
|
14442
|
+
* the mandatory repair turn was estimated at 0.7066 USD against an
|
|
14443
|
+
* 18000 token output plan, and the dispatch was refused before any
|
|
14444
|
+
* provider call. The same turn, re-issued after the operator raised
|
|
14445
|
+
* the ceiling, wrote 12840 output tokens and cost 0.4788 USD: it fit
|
|
14446
|
+
* the ceiling that refused it, and a clamp to the ~13253 tokens the
|
|
14447
|
+
* room afforded would have let it run.
|
|
14448
|
+
*
|
|
14449
|
+
* Answered ONLY for a dispatch that is alone in flight, which is the
|
|
14450
|
+
* whole difference between a refusal that means something and one
|
|
14451
|
+
* that means nothing. With siblings live the refusal is TRANSIENT:
|
|
14452
|
+
* RV1902 parks on it and the turn runs at its full planned length
|
|
14453
|
+
* the moment one of them releases, so shortening it would trade a
|
|
14454
|
+
* complete answer for a truncated one and buy nothing. With nothing
|
|
14455
|
+
* live the refusal is PERMANENT (RV2003's sweep wakes such a waiter
|
|
14456
|
+
* 'drained' precisely because no hold will ever return), and the
|
|
14457
|
+
* only choices left are a shorter turn or no turn at all. The
|
|
14458
|
+
* concurrent-wave bound of RV711 is therefore untouched.
|
|
14459
|
+
*
|
|
14460
|
+
* Opt-in through `RunOptions.clampTurnToExposure`, so the drained
|
|
14461
|
+
* refusal terminals RV1902, RV2002 and RV2003 built out of live
|
|
14462
|
+
* parity deaths keep their shapes until a host asks for this one.
|
|
14463
|
+
*
|
|
14464
|
+
* Undefined when the clamp is not armed, when the cap is not
|
|
14465
|
+
* configured, when anything is in flight, or when the model has no
|
|
14466
|
+
* price row, so a run that declares nothing keeps every byte of its
|
|
14467
|
+
* historical path. Zero or
|
|
14468
|
+
* negative when the room cannot even pay for the prompt, the same
|
|
14469
|
+
* convention {@link maxAffordableOutputTokens} inherits from
|
|
14470
|
+
* `affordableOutputTokens`; the caller decides what a sub-floor
|
|
14471
|
+
* answer means, and the loop deliberately ignores one so a true
|
|
14472
|
+
* exposure exhaustion still refuses through
|
|
14473
|
+
* {@link reserveTurnExposure} with its own typed reason instead of
|
|
14474
|
+
* an output-floor verdict.
|
|
14475
|
+
*/
|
|
14476
|
+
maxExposureOutputTokens(servedBy, estimatedInputTokens) {
|
|
14477
|
+
const cap = this.maxInFlightExposureUsd;
|
|
14478
|
+
if (!this.clampTurnToExposure || cap === void 0 || this.inFlightExposureUsd > 0) return;
|
|
14479
|
+
const pricing = this.pricingOf?.(servedBy);
|
|
14480
|
+
if (pricing === void 0) return;
|
|
14481
|
+
return affordableOutputTokens(pricing, Math.max(0, cap - this.root.spentUsd), estimatedInputTokens);
|
|
14482
|
+
}
|
|
14483
|
+
/**
|
|
14330
14484
|
* Live accounting; spend propagates from `accountScope` to every
|
|
14331
14485
|
* ancestor. Crossing a ceiling severs the crossing account's subtree
|
|
14332
14486
|
* via its layer-3 AbortSignal (overshoot bounded by one turn per
|
|
@@ -18132,6 +18286,7 @@ function createCtx(internals, rootWorkflow) {
|
|
|
18132
18286
|
remainingUsd: () => internals.budget.remainingUsd(budgetAccount),
|
|
18133
18287
|
...internals.budget.strictPricing === void 0 ? {} : { assertPricedDispatch: (servedBy) => internals.budget.assertPricedDispatch(servedBy) },
|
|
18134
18288
|
...internals.budget.maxInFlightExposureUsd === void 0 ? {} : {
|
|
18289
|
+
maxExposureOutputTokens: (servedBy, estimatedInputTokens) => internals.budget.maxExposureOutputTokens(servedBy, estimatedInputTokens),
|
|
18135
18290
|
admitTurnExposure: (servedBy, estimatedInputTokens, plannedOutputTokens) => internals.budget.reserveTurnExposure(servedBy, estimatedInputTokens, plannedOutputTokens, `agent:${running.seq}`),
|
|
18136
18291
|
awaitExposureRelease: (signal) => internals.budget.awaitExposureRelease(signal),
|
|
18137
18292
|
liveExposureUsd: () => internals.budget.liveExposureUsd
|
|
@@ -19954,6 +20109,29 @@ const MAX_LISTED_CITATIONS = 20;
|
|
|
19954
20109
|
*/
|
|
19955
20110
|
const MAX_NAMED_OFFENDING_SENTENCES = 5;
|
|
19956
20111
|
const MAX_OFFENDING_SENTENCE_CHARS = 240;
|
|
20112
|
+
/**
|
|
20113
|
+
* The shortest run id {@link evidenceGradeValidator} will accept as an
|
|
20114
|
+
* artifact (RV2501). The floor mirrors the id half of
|
|
20115
|
+
* {@link DEFAULT_ARTIFACT_PATTERN}: a two character id would satisfy
|
|
20116
|
+
* nearly every sentence by accident, which is the fail-open the empty
|
|
20117
|
+
* pattern guard exists to prevent. The id is additionally matched as a
|
|
20118
|
+
* whole identifier, so it cannot be credited from inside a longer
|
|
20119
|
+
* word, and only inside the sentence making the claim.
|
|
20120
|
+
*/
|
|
20121
|
+
const MIN_RUN_ID_ARTIFACT_CHARS = 6;
|
|
20122
|
+
/**
|
|
20123
|
+
* True when `value` occurs in `haystack` as a whole IDENTIFIER
|
|
20124
|
+
* (RV2501). Deliberately not {@link containsToken}: that boundary
|
|
20125
|
+
* class carries the dot, so an id written at the end of a sentence is
|
|
20126
|
+
* followed by the sentence period and would never be credited, which
|
|
20127
|
+
* is the most natural place to write one. Word characters alone bound
|
|
20128
|
+
* an id, so `x<id>y` is refused while `` `<id>` `` and `<id>.` are
|
|
20129
|
+
* credited. The value is matched literally (metacharacters escaped).
|
|
20130
|
+
*/
|
|
20131
|
+
function containsIdentifier(haystack, value) {
|
|
20132
|
+
const escaped = value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
20133
|
+
return new RegExp(`(?<!\\w)${escaped}(?!\\w)`, "u").test(haystack);
|
|
20134
|
+
}
|
|
19957
20135
|
function listCitations(values) {
|
|
19958
20136
|
return values.length <= MAX_LISTED_CITATIONS ? values.join(", ") : `${values.slice(0, MAX_LISTED_CITATIONS).join(", ")} and ${String(values.length - MAX_LISTED_CITATIONS)} more`;
|
|
19959
20137
|
}
|
|
@@ -20228,7 +20406,22 @@ const DEFAULT_ARTIFACT_PATTERN = "(?:run[ -]?[0-9A-HJKMNP-TV-Z]{6,26}|[\\w./-]+\
|
|
|
20228
20406
|
* paragraphs away no longer satisfies the grade. Purely textual: what
|
|
20229
20407
|
* the referenced artifact contains is
|
|
20230
20408
|
* {@link citedValueValidator}'s question, and whether it exists on
|
|
20231
|
-
* disk is the host's.
|
|
20409
|
+
* disk is the host's.
|
|
20410
|
+
*
|
|
20411
|
+
* The run's OWN id is an artifact (RV2501). `DEFAULT_ARTIFACT_PATTERN`
|
|
20412
|
+
* only ever matched the literal word `run` followed by a ULID, so the
|
|
20413
|
+
* escape the verdict advertised was unreachable for every run whose id
|
|
20414
|
+
* the engine did not mint in that exact shape: the comparison run's
|
|
20415
|
+
* `comparison-rulvar-v12260-aug09-...` matched nothing, its synthesis
|
|
20416
|
+
* had no artifact it could name, and a document that told the truth
|
|
20417
|
+
* about the run it was part of could not be written at all. When
|
|
20418
|
+
* {@link FinishValidationInput.runId} is supplied (the orchestrator
|
|
20419
|
+
* runtime always supplies it), a sentence carrying that id verbatim as
|
|
20420
|
+
* a whole token satisfies the grade, and the verdict names the id so
|
|
20421
|
+
* the repair instruction is executable rather than aspirational. An id
|
|
20422
|
+
* shorter than `MIN_RUN_ID_ARTIFACT_CHARS` (six) is ignored, and
|
|
20423
|
+
* without an id the verdict is byte identical to the historical one.
|
|
20424
|
+
* Default name 'evidence-grade'.
|
|
20232
20425
|
*/
|
|
20233
20426
|
function evidenceGradeValidator(options) {
|
|
20234
20427
|
const phrases = options?.phrases === void 0 ? [...DEFAULT_EVIDENCE_GRADE_PHRASES] : requireNonEmptyStrings(options.phrases, "evidenceGradeValidator phrases");
|
|
@@ -20246,10 +20439,11 @@ function evidenceGradeValidator(options) {
|
|
|
20246
20439
|
validate: (input) => {
|
|
20247
20440
|
const unsupported = [];
|
|
20248
20441
|
const offenders = [];
|
|
20442
|
+
const runId = typeof input.runId === "string" && input.runId.trim().length >= MIN_RUN_ID_ARTIFACT_CHARS ? input.runId.trim() : void 0;
|
|
20249
20443
|
for (const sentence of sentencesOf(input.text)) {
|
|
20250
20444
|
const haystack = sentence.toLowerCase();
|
|
20251
20445
|
const found = lowered.filter((phrase) => haystack.includes(phrase));
|
|
20252
|
-
if (found.length === 0 || new RegExp(artifactPattern, "").test(sentence)) continue;
|
|
20446
|
+
if (found.length === 0 || new RegExp(artifactPattern, "").test(sentence) || runId !== void 0 && containsIdentifier(sentence, runId)) continue;
|
|
20253
20447
|
offenders.push(sentence);
|
|
20254
20448
|
for (const phrase of found) if (!unsupported.includes(phrase)) unsupported.push(phrase);
|
|
20255
20449
|
}
|
|
@@ -20262,7 +20456,7 @@ function evidenceGradeValidator(options) {
|
|
|
20262
20456
|
return {
|
|
20263
20457
|
ok: false,
|
|
20264
20458
|
reasons: [
|
|
20265
|
-
`evidence-grade claims cite no run or repro artifact in their own sentence: ${listCitations(unsupported)}; give each such claim a file:line citation in its own sentence, or state its run id in a SEPARATE sentence carrying no source citation (a run id written beside a path:line citation is not in the cited window and trades this failure for a cited-value one)`,
|
|
20459
|
+
runId === void 0 ? `evidence-grade claims cite no run or repro artifact in their own sentence: ${listCitations(unsupported)}; give each such claim a file:line citation in its own sentence, or state its run id in a SEPARATE sentence carrying no source citation (a run id written beside a path:line citation is not in the cited window and trades this failure for a cited-value one)` : `evidence-grade claims cite no run or repro artifact in their own sentence: ${listCitations(unsupported)}; write this run's id ${runId} inside each such sentence, or give the claim a file:line citation instead (the id may share a sentence with a source citation: cited-value reads a run id as identity, not as a value asserted about the cited line)`,
|
|
20266
20460
|
...named,
|
|
20267
20461
|
...overflow > 0 ? [`and ${String(overflow)} more offending sentences`] : []
|
|
20268
20462
|
]
|
|
@@ -20273,6 +20467,15 @@ function evidenceGradeValidator(options) {
|
|
|
20273
20467
|
/** Splits a citation into its path and line halves at the LAST colon. */
|
|
20274
20468
|
const CITATION_TAIL$1 = /^(.*):(\d+)$/u;
|
|
20275
20469
|
/**
|
|
20470
|
+
* A commit sha span (RV2502). Twelve hex characters is the floor: real
|
|
20471
|
+
* abbreviations run 7 to 12 and full shas 40, while shorter hex words
|
|
20472
|
+
* (`deadbeef`) are ordinary literals a document may legitimately assert
|
|
20473
|
+
* about a cited line, so they stay judged.
|
|
20474
|
+
*/
|
|
20475
|
+
const COMMIT_SHA_SPAN = /^[0-9a-f]{12,64}$/u;
|
|
20476
|
+
/** A release version span (RV2502), with an optional tail. */
|
|
20477
|
+
const VERSION_SPAN = /^v?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z][0-9A-Za-z.-]*)?$/u;
|
|
20478
|
+
/**
|
|
20276
20479
|
* True when `value` occurs in `haystack` as a WHOLE token (RV1402, the
|
|
20277
20480
|
* seventeenth comparison experiment P0-1). Substring matching credited
|
|
20278
20481
|
* an asserted `3` against a line that says `30`, so the validator
|
|
@@ -20308,6 +20511,27 @@ function containsToken(haystack, value) {
|
|
|
20308
20511
|
* ({@link citationTargetsValidator} judges every citation with no such
|
|
20309
20512
|
* precondition).
|
|
20310
20513
|
*
|
|
20514
|
+
* One span class is IDENTITY, not assertion (RV2502, the 1.226.0
|
|
20515
|
+
* comparison run): a span naming the artefact under review says which
|
|
20516
|
+
* commit, run, or release the document is about, and asserts nothing
|
|
20517
|
+
* about any cited line. That run's synthesis wrote its frozen commit
|
|
20518
|
+
* sha beside source citations and the validator demanded the sha appear
|
|
20519
|
+
* in the cited source, an impossible repair, in the same verdict that
|
|
20520
|
+
* demanded three real value fixes; two granted repairs burned and the
|
|
20521
|
+
* finish was rejected. Three shapes are structural and always excluded:
|
|
20522
|
+
* a commit sha (12 to 64 hex characters, long enough that ordinary hex
|
|
20523
|
+
* literals stay judged), a release version (`1.2.3`, `v1.2.3`, with an
|
|
20524
|
+
* optional prerelease or build tail), and the run's own id when the
|
|
20525
|
+
* runtime supplies `runId`. Host vocabulary is declared: `notValues`
|
|
20526
|
+
* lists spans this document writes as identity, verdict words like
|
|
20527
|
+
* `conditionally ready` among them.
|
|
20528
|
+
*
|
|
20529
|
+
* The run-id exclusion is what makes the bundle self consistent
|
|
20530
|
+
* (RV2501, RV2202): the evidence grade instructs a failing model to
|
|
20531
|
+
* write this run's id inside the offending sentence, and before RV2502
|
|
20532
|
+
* doing so beside a citation traded an evidence-grade failure for a
|
|
20533
|
+
* cited-value one. The two repair instructions now compose.
|
|
20534
|
+
*
|
|
20311
20535
|
* `resolve` is host code and must be PURE over a snapshot the host
|
|
20312
20536
|
* froze before the run, exactly like every other finish validator: a
|
|
20313
20537
|
* resolver that reads the filesystem live would make a verdict depend
|
|
@@ -20318,6 +20542,9 @@ function containsToken(haystack, value) {
|
|
|
20318
20542
|
*/
|
|
20319
20543
|
function citedValueValidator(options) {
|
|
20320
20544
|
if (typeof options.resolve !== "function") throw new ConfigError("citedValueValidator resolve must be a function");
|
|
20545
|
+
if (options.notValues !== void 0) {
|
|
20546
|
+
if (!Array.isArray(options.notValues) || options.notValues.some((value) => typeof value !== "string" || value.length === 0)) throw new ConfigError("citedValueValidator notValues must be an array of non empty strings");
|
|
20547
|
+
}
|
|
20321
20548
|
const window = options.window ?? 0;
|
|
20322
20549
|
if (!Number.isInteger(window) || window < 0) throw new ConfigError(`citedValueValidator window must be a non negative integer; got ${String(window)}`);
|
|
20323
20550
|
const pattern = options.pattern ?? "[\\w./-]+\\.\\w+:\\d+";
|
|
@@ -20326,10 +20553,17 @@ function citedValueValidator(options) {
|
|
|
20326
20553
|
} catch (thrown) {
|
|
20327
20554
|
throw new ConfigError(`citedValueValidator pattern does not compile: ${thrown instanceof Error ? thrown.message : String(thrown)}`);
|
|
20328
20555
|
}
|
|
20556
|
+
const declaredNotValues = new Set(options.notValues ?? []);
|
|
20329
20557
|
return {
|
|
20330
20558
|
name: options.name ?? "cited-value",
|
|
20331
20559
|
validate: (input) => {
|
|
20332
20560
|
const reasons = [];
|
|
20561
|
+
const runId = typeof input.runId === "string" && input.runId.trim().length >= MIN_RUN_ID_ARTIFACT_CHARS ? input.runId.trim() : void 0;
|
|
20562
|
+
/**
|
|
20563
|
+
* True when the span NAMES the artefact under review instead of
|
|
20564
|
+
* asserting something about a cited line (RV2502).
|
|
20565
|
+
*/
|
|
20566
|
+
const isIdentity = (span) => declaredNotValues.has(span) || span === runId || COMMIT_SHA_SPAN.test(span) || VERSION_SPAN.test(span);
|
|
20333
20567
|
for (const sentence of sentencesOf(input.text)) {
|
|
20334
20568
|
const spans = [...sentence.matchAll(/`([^`]+)`/gu)].map((match) => match[1]);
|
|
20335
20569
|
const citations = [];
|
|
@@ -20341,7 +20575,7 @@ function citedValueValidator(options) {
|
|
|
20341
20575
|
path: parsed[1],
|
|
20342
20576
|
line
|
|
20343
20577
|
});
|
|
20344
|
-
else values.push(span);
|
|
20578
|
+
else if (!isIdentity(span)) values.push(span);
|
|
20345
20579
|
}
|
|
20346
20580
|
if (citations.length === 0 || values.length === 0) continue;
|
|
20347
20581
|
for (const citation of citations) {
|
|
@@ -20917,8 +21151,10 @@ function pairRunFactClaims(draftText, sheet, options) {
|
|
|
20917
21151
|
/** Derives the {@link ClaimCoverageGrade} of a claim-consistency meta. */
|
|
20918
21152
|
function claimCoverageOf(meta) {
|
|
20919
21153
|
if (meta.judgeFailed === true) return "judge-failed";
|
|
21154
|
+
if (meta.judgeDeclined === true) return "judge-declined";
|
|
20920
21155
|
if ((meta.criticalUncoveredTotal ?? 0) > 0) return "critical-uncovered";
|
|
20921
21156
|
if (meta.truncated || meta.runFactPairsTruncated === true || meta.coveredCitingSentences < meta.draftCitingSentences) return "partial";
|
|
21157
|
+
if (meta.draftCitingSentences === 0) return "vacuous";
|
|
20922
21158
|
return "full";
|
|
20923
21159
|
}
|
|
20924
21160
|
//#endregion
|
|
@@ -21481,6 +21717,8 @@ function validateOrchestrateOptions(opts) {
|
|
|
21481
21717
|
}
|
|
21482
21718
|
if (fv.maxRepairs !== void 0) requireNonNegativeInteger(fv.maxRepairs, "orchestrate finishValidation.maxRepairs");
|
|
21483
21719
|
if (fv.repairTurnReserve !== void 0) requireNonNegativeInteger(fv.repairTurnReserve, "orchestrate finishValidation.repairTurnReserve");
|
|
21720
|
+
const retain = fv.retainRejectedCandidates;
|
|
21721
|
+
if (retain !== void 0 && typeof retain !== "boolean") throw new ConfigError("orchestrate finishValidation.retainRejectedCandidates must be a boolean");
|
|
21484
21722
|
const draftPolicy = fv.draftPolicy;
|
|
21485
21723
|
if (draftPolicy !== void 0) {
|
|
21486
21724
|
if (draftPolicy !== "contract" && (typeof draftPolicy !== "object" || draftPolicy === null)) throw new ConfigError("orchestrate finishValidation.draftPolicy must be an object or the sentinel 'contract'");
|
|
@@ -21545,6 +21783,11 @@ function validateOrchestrateOptions(opts) {
|
|
|
21545
21783
|
if (typeof conditional.carryDraftGaps !== "boolean") throw new ConfigError("orchestrate synthesis.carryDraftGaps must be a boolean; got " + typeof conditional.carryDraftGaps);
|
|
21546
21784
|
if (conditional.carryDraftGaps && conditional.skipWhenDraftValid !== true) throw new ConfigError("orchestrate synthesis.carryDraftGaps requires skipWhenDraftValid: the gaps ARE the failed pre-pass verdict, and without the pre-pass there is nothing to carry");
|
|
21547
21785
|
}
|
|
21786
|
+
const floor = synthesis.fallbackToValidDraft;
|
|
21787
|
+
if (floor !== void 0) {
|
|
21788
|
+
if (typeof floor !== "boolean") throw new ConfigError("orchestrate synthesis.fallbackToValidDraft must be a boolean; got " + typeof floor);
|
|
21789
|
+
if (floor && opts.finishValidation === void 0) throw new ConfigError("orchestrate synthesis.fallbackToValidDraft requires finishValidation: without a declared finish contract there is nothing to judge the draft valid by");
|
|
21790
|
+
}
|
|
21548
21791
|
if (symmetry.context !== void 0 && symmetry.context !== "digests" && symmetry.context !== "full") throw new ConfigError("orchestrate synthesis.context must be 'digests' or 'full'; got " + JSON.stringify(symmetry.context));
|
|
21549
21792
|
const index = synthesis.evidenceIndex;
|
|
21550
21793
|
if (index !== void 0) {
|
|
@@ -21610,6 +21853,9 @@ function validateOrchestrateOptions(opts) {
|
|
|
21610
21853
|
if (opts.synthesis === void 0) throw new ConfigError("orchestrate claimConsistency.onFound 'carry' requires synthesis: without the post-fan-in invocation there is no prompt to carry the findings into; use 'report' or 'fail'");
|
|
21611
21854
|
if (opts.synthesis.mode === "incremental") throw new ConfigError("orchestrate claimConsistency.onFound 'carry' needs a 'single' synthesis: the deterministic 'incremental' reconciliation has no prompt for the findings to ride");
|
|
21612
21855
|
}
|
|
21856
|
+
const stage = consistency.stage ?? "draft";
|
|
21857
|
+
if (stage !== "draft" && stage !== "final" && stage !== "both") throw new ConfigError("orchestrate claimConsistency.stage must be 'draft', 'final' or 'both'; got " + JSON.stringify(consistency.stage));
|
|
21858
|
+
if (stage !== "draft" && opts.synthesis === void 0) throw new ConfigError(`orchestrate claimConsistency.stage '${stage}' requires synthesis: without the post-fan-in invocation the coordination draft IS the final artifact, and the default 'draft' already judges it`);
|
|
21613
21859
|
if (consistency.pattern !== void 0) {
|
|
21614
21860
|
if (typeof consistency.pattern !== "string") throw new ConfigError(`orchestrate claimConsistency.pattern must be a string; got ${typeof consistency.pattern}`);
|
|
21615
21861
|
let probe;
|
|
@@ -22900,7 +23146,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
22900
23146
|
const input = {
|
|
22901
23147
|
result,
|
|
22902
23148
|
text: typeof result === "string" ? result : JSON.stringify(result),
|
|
22903
|
-
children: validationChildren()
|
|
23149
|
+
children: validationChildren(),
|
|
23150
|
+
runId: internals.runId
|
|
22904
23151
|
};
|
|
22905
23152
|
const failed = [];
|
|
22906
23153
|
for (const validator of validationSpec.validators) {
|
|
@@ -22921,6 +23168,25 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
22921
23168
|
});
|
|
22922
23169
|
}
|
|
22923
23170
|
const repairsUsed = known.filter((candidate) => candidate.verdict !== "accepted" && contractGenerationCurrent(candidate)).length;
|
|
23171
|
+
const rejectedCandidate = failed.length > 0;
|
|
23172
|
+
let candidateRef;
|
|
23173
|
+
if (rejectedCandidate && validationSpec.retainRejectedCandidates === true) {
|
|
23174
|
+
const ref = `${internals.runId}/finish-rejected/${call.id}`;
|
|
23175
|
+
try {
|
|
23176
|
+
await internals.transcripts.put(ref, new TextEncoder().encode(input.text), internals.lease);
|
|
23177
|
+
candidateRef = ref;
|
|
23178
|
+
} catch (writeFailed) {
|
|
23179
|
+
internals.events.emit({
|
|
23180
|
+
type: "log",
|
|
23181
|
+
level: "warn",
|
|
23182
|
+
msg: "orchestrator rejected finish candidate not retained",
|
|
23183
|
+
data: {
|
|
23184
|
+
ref,
|
|
23185
|
+
reason: (writeFailed instanceof Error ? writeFailed.message : String(writeFailed)).slice(0, 200)
|
|
23186
|
+
}
|
|
23187
|
+
}, callingState.spanId);
|
|
23188
|
+
}
|
|
23189
|
+
}
|
|
22924
23190
|
decision = {
|
|
22925
23191
|
decisionType: "orchestrator_finish_validation",
|
|
22926
23192
|
callId: call.id,
|
|
@@ -22928,7 +23194,12 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
22928
23194
|
failed,
|
|
22929
23195
|
repairsUsed,
|
|
22930
23196
|
maxRepairs,
|
|
22931
|
-
...validationSpec.contract === void 0 ? {} : { contractHash: validationSpec.contract.hash }
|
|
23197
|
+
...validationSpec.contract === void 0 ? {} : { contractHash: validationSpec.contract.hash },
|
|
23198
|
+
...rejectedCandidate ? {
|
|
23199
|
+
candidateHash: createHash("sha256").update(jcsSerialize(result), "utf8").digest("hex"),
|
|
23200
|
+
candidateChars: input.text.length,
|
|
23201
|
+
...candidateRef === void 0 ? {} : { candidateRef }
|
|
23202
|
+
} : {}
|
|
22932
23203
|
};
|
|
22933
23204
|
await internals.replayer.appendSinglePhase({
|
|
22934
23205
|
scope: callingState.scope,
|
|
@@ -23013,7 +23284,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23013
23284
|
const input = {
|
|
23014
23285
|
result,
|
|
23015
23286
|
text,
|
|
23016
|
-
children: validationChildren()
|
|
23287
|
+
children: validationChildren(),
|
|
23288
|
+
runId: internals.runId
|
|
23017
23289
|
};
|
|
23018
23290
|
for (const validator of validationSpec?.validators ?? []) {
|
|
23019
23291
|
let verdict;
|
|
@@ -23395,6 +23667,14 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23395
23667
|
*/
|
|
23396
23668
|
let synthesisSkippedByValidDraft = false;
|
|
23397
23669
|
/**
|
|
23670
|
+
* The journal seq of the skip decision that carried the RV510 gate
|
|
23671
|
+
* (RV2506): the addressable provenance of the artifact a skipped
|
|
23672
|
+
* run settles on, since a skipped synthesis leaves no accepted
|
|
23673
|
+
* finish-validation decision behind and the draft's acceptance
|
|
23674
|
+
* lives in the skip entry instead.
|
|
23675
|
+
*/
|
|
23676
|
+
let synthesisSkipDecisionRef;
|
|
23677
|
+
/**
|
|
23398
23678
|
* The bounded contradiction pass's findings (RV1302), set exactly
|
|
23399
23679
|
* when the pass is configured: an EMPTY array is a fact (the pass
|
|
23400
23680
|
* ran and the pool agreed) and `undefined` is a different fact
|
|
@@ -23414,6 +23694,18 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23414
23694
|
/** Set whenever the pass ran, findings or not (the RV1404 pairing). */
|
|
23415
23695
|
let claimConsistencyMeta;
|
|
23416
23696
|
/**
|
|
23697
|
+
* Which document the claim-consistency pass judges (RV2509),
|
|
23698
|
+
* default `'draft'`: the historical ordering, byte for byte.
|
|
23699
|
+
*/
|
|
23700
|
+
const claimStage = opts?.claimConsistency?.stage ?? "draft";
|
|
23701
|
+
/**
|
|
23702
|
+
* Under `stage: 'both'` the pre-synthesis verdict, kept beside the
|
|
23703
|
+
* final one (RV2509): `claimConsistencyMeta` reports the SHIPPED
|
|
23704
|
+
* document because that is what a consumer gates on, and the draft
|
|
23705
|
+
* verdict is the record of the gate that let the synthesis run.
|
|
23706
|
+
*/
|
|
23707
|
+
let claimConsistencyDraftMeta;
|
|
23708
|
+
/**
|
|
23417
23709
|
* The salvage arms the acceptance decision counted (RV1403), set on
|
|
23418
23710
|
* the accepted path AFTER the decision, fresh or rolled forward
|
|
23419
23711
|
* from the journal, so live and resume read the same lists; a
|
|
@@ -23511,7 +23803,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23511
23803
|
* entry, so a resume replays the verdict with zero paid calls and
|
|
23512
23804
|
* this pass journals nothing of its own.
|
|
23513
23805
|
*/
|
|
23514
|
-
const runClaimConsistencyPass = async (draft, snapshot) => {
|
|
23806
|
+
const runClaimConsistencyPass = async (draft, snapshot, stage = "draft") => {
|
|
23515
23807
|
const spec = opts?.claimConsistency;
|
|
23516
23808
|
if (spec === void 0) return;
|
|
23517
23809
|
await recoveryDone;
|
|
@@ -23607,7 +23899,9 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23607
23899
|
};
|
|
23608
23900
|
return {
|
|
23609
23901
|
...bare,
|
|
23610
|
-
coverage: claimCoverageOf(bare)
|
|
23902
|
+
coverage: claimCoverageOf(bare),
|
|
23903
|
+
judgedStage: stage,
|
|
23904
|
+
judgedHash: createHash("sha256").update(jcsSerialize(draft ?? null), "utf8").digest("hex")
|
|
23611
23905
|
};
|
|
23612
23906
|
};
|
|
23613
23907
|
if (spec.onLowCoverage === "fail" && metaBase.lowCoverage !== void 0) {
|
|
@@ -23666,7 +23960,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23666
23960
|
const judgeOpts = {
|
|
23667
23961
|
role: "synthesize",
|
|
23668
23962
|
result: "full",
|
|
23669
|
-
label: CLAIM_JUDGE_LABEL
|
|
23963
|
+
label: stage === "draft" ? CLAIM_JUDGE_LABEL : `${CLAIM_JUDGE_LABEL}-final`,
|
|
23670
23964
|
schema: CLAIM_JUDGE_SCHEMA,
|
|
23671
23965
|
limits: spec.judge?.limits ?? { maxTurns: 3 },
|
|
23672
23966
|
...spec.judge?.model === void 0 ? {} : { model: spec.judge.model },
|
|
@@ -23682,7 +23976,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23682
23976
|
judgeInvoked: false,
|
|
23683
23977
|
judgeDeclined: true
|
|
23684
23978
|
});
|
|
23685
|
-
const declineKey = deriverV2.deriveKey({ kind: "orchestrator-claim-judge-declined" });
|
|
23979
|
+
const declineKey = deriverV2.deriveKey({ kind: stage === "draft" ? "orchestrator-claim-judge-declined" : "orchestrator-claim-judge-declined-final" });
|
|
23686
23980
|
if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === declineKey)) await internals.replayer.appendSinglePhase({
|
|
23687
23981
|
scope: callingState.scope,
|
|
23688
23982
|
key: declineKey,
|
|
@@ -23801,6 +24095,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23801
24095
|
const prior = internals.replayer.snapshot().filter((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.key === skipKey).at(-1);
|
|
23802
24096
|
if (prior !== void 0 && applies(prior.value)) {
|
|
23803
24097
|
synthesisSkippedByValidDraft = true;
|
|
24098
|
+
synthesisSkipDecisionRef = prior.seq;
|
|
23804
24099
|
announceSkip(prior.seq);
|
|
23805
24100
|
return draft;
|
|
23806
24101
|
}
|
|
@@ -23848,7 +24143,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23848
24143
|
const input = {
|
|
23849
24144
|
result: draftValue,
|
|
23850
24145
|
text: typeof draftValue === "string" ? draftValue : JSON.stringify(draftValue),
|
|
23851
|
-
children: validationChildren()
|
|
24146
|
+
children: validationChildren(),
|
|
24147
|
+
runId: internals.runId
|
|
23852
24148
|
};
|
|
23853
24149
|
const failed = [];
|
|
23854
24150
|
for (const validator of validationSpec.validators) {
|
|
@@ -23914,6 +24210,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23914
24210
|
});
|
|
23915
24211
|
if (orchestratorAccount !== void 0 && (opts?.budget?.synthesisReserveUsd ?? 0) > 0) internals.budget.releaseSynthesisReserve(orchestratorAccount);
|
|
23916
24212
|
synthesisSkippedByValidDraft = true;
|
|
24213
|
+
synthesisSkipDecisionRef = skipEntry.seq;
|
|
23917
24214
|
announceSkip(skipEntry.seq);
|
|
23918
24215
|
return draft;
|
|
23919
24216
|
}
|
|
@@ -24036,13 +24333,14 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24036
24333
|
}
|
|
24037
24334
|
return `RUN FACTS: ${JSON.stringify({
|
|
24038
24335
|
scope: "settled-children-only",
|
|
24336
|
+
runId: internals.runId,
|
|
24039
24337
|
children: settledEntries.length,
|
|
24040
24338
|
byStatus: Object.fromEntries(Object.keys(byStatus).sort().map((status) => [status, byStatus[status]])),
|
|
24041
24339
|
wireRequests,
|
|
24042
24340
|
wireIdsMissing,
|
|
24043
24341
|
inputTokens,
|
|
24044
24342
|
outputTokens
|
|
24045
|
-
})} (live-observed by this run's own harness; production evidence it is not; the settled children ONLY, excluding this orchestrator, judges, and synthesis; the whole run's totals are the terminal envelope and invoice)`;
|
|
24343
|
+
})} (live-observed by run ${internals.runId}, this run's own harness; production evidence it is not; the settled children ONLY, excluding this orchestrator, judges, and synthesis; the whole run's totals are the terminal envelope and invoice)`;
|
|
24046
24344
|
})()] : [],
|
|
24047
24345
|
`GOAL: ${goal}`,
|
|
24048
24346
|
`DRAFT: ${draftJson}`,
|
|
@@ -24403,14 +24701,160 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24403
24701
|
} : { ran: true },
|
|
24404
24702
|
synthesis
|
|
24405
24703
|
});
|
|
24704
|
+
/**
|
|
24705
|
+
* The no-regression fallback verdict (RV2505), set only when the
|
|
24706
|
+
* floor actually caught a failing synthesis: the truncated failure
|
|
24707
|
+
* message and the journal seq of the decision that recorded it.
|
|
24708
|
+
*/
|
|
24709
|
+
let synthesisRegressed;
|
|
24710
|
+
/**
|
|
24711
|
+
* The no-regression floor under the synthesis (RV2505, the 1.226.0
|
|
24712
|
+
* comparison run): a synthesis that fails terminally must not throw
|
|
24713
|
+
* away a coordination draft the SAME declared contract accepts.
|
|
24714
|
+
* Judges the draft with the validator bundle, journals what it
|
|
24715
|
+
* found either way, and answers whether the caller should settle on
|
|
24716
|
+
* the draft instead of rethrowing. Pure: the verdict is a function
|
|
24717
|
+
* of the draft and the validators, so a resume that re-fails the
|
|
24718
|
+
* synthesis re-derives the identical answer, and the journaled
|
|
24719
|
+
* decision is reused rather than duplicated.
|
|
24720
|
+
*/
|
|
24721
|
+
const draftFallbackOnRegression = async (draft, thrown) => {
|
|
24722
|
+
if (!(opts?.synthesis?.fallbackToValidDraft === true) || validationSpec === void 0) return { used: false };
|
|
24723
|
+
if (thrown instanceof ConfigError) return { used: false };
|
|
24724
|
+
const draftValue = draft ?? null;
|
|
24725
|
+
const draftHash = createHash("sha256").update(jcsSerialize(draftValue), "utf8").digest("hex");
|
|
24726
|
+
const validatorNames = validationSpec.validators.map((validator) => validator.name);
|
|
24727
|
+
const input = {
|
|
24728
|
+
result: draftValue,
|
|
24729
|
+
text: typeof draftValue === "string" ? draftValue : JSON.stringify(draftValue),
|
|
24730
|
+
children: validationChildren()
|
|
24731
|
+
};
|
|
24732
|
+
const failed = [];
|
|
24733
|
+
for (const validator of validationSpec.validators) {
|
|
24734
|
+
let verdict;
|
|
24735
|
+
try {
|
|
24736
|
+
verdict = validator.validate(input);
|
|
24737
|
+
} catch (validatorThrew) {
|
|
24738
|
+
throw new ConfigError(`finish validator '${validator.name}' threw instead of returning a verdict during the fallbackToValidDraft judgement: ` + (validatorThrew instanceof Error ? validatorThrew.message : String(validatorThrew)));
|
|
24739
|
+
}
|
|
24740
|
+
if (!verdict.ok) failed.push({
|
|
24741
|
+
name: validator.name,
|
|
24742
|
+
reasons: verdict.reasons
|
|
24743
|
+
});
|
|
24744
|
+
}
|
|
24745
|
+
const regressed = failed.length === 0;
|
|
24746
|
+
const reason = (thrown instanceof Error ? thrown.message : String(thrown)).slice(0, 300);
|
|
24747
|
+
const key = deriverV2.deriveKey({ kind: regressed ? "orchestrator-synthesis-regressed" : "orchestrator-synthesis-fallback-declined" });
|
|
24748
|
+
const entryRef = internals.replayer.snapshot().find((entry) => entry.kind === "decision" && entry.key === key)?.seq ?? (await internals.replayer.appendSinglePhase({
|
|
24749
|
+
scope: callingState.scope,
|
|
24750
|
+
key,
|
|
24751
|
+
kind: "decision",
|
|
24752
|
+
status: "ok",
|
|
24753
|
+
spanId: internals.spans.mint(callingState.spanId),
|
|
24754
|
+
site: "orchestrator-synthesis-fallback",
|
|
24755
|
+
value: {
|
|
24756
|
+
decisionType: regressed ? "orchestrator_synthesis_regressed" : "orchestrator_synthesis_fallback_declined",
|
|
24757
|
+
reason,
|
|
24758
|
+
validators: validatorNames,
|
|
24759
|
+
...regressed ? {} : { failed },
|
|
24760
|
+
...validationSpec.contract === void 0 ? {} : { contractHash: validationSpec.contract.hash },
|
|
24761
|
+
draftHash
|
|
24762
|
+
}
|
|
24763
|
+
})).seq;
|
|
24764
|
+
internals.events.emit({
|
|
24765
|
+
type: "log",
|
|
24766
|
+
level: "warn",
|
|
24767
|
+
msg: regressed ? "orchestrator synthesis regressed" : "orchestrator synthesis fallback declined",
|
|
24768
|
+
data: {
|
|
24769
|
+
reason,
|
|
24770
|
+
decisionRef: entryRef,
|
|
24771
|
+
...regressed ? {} : { draftFailed: failed.map((row) => row.name) }
|
|
24772
|
+
}
|
|
24773
|
+
}, callingState.spanId);
|
|
24774
|
+
if (!regressed) return { used: false };
|
|
24775
|
+
synthesisRegressed = {
|
|
24776
|
+
reason,
|
|
24777
|
+
decisionRef: entryRef
|
|
24778
|
+
};
|
|
24779
|
+
return { used: true };
|
|
24780
|
+
};
|
|
24781
|
+
/**
|
|
24782
|
+
* The explicit deliverable verdict (RV2506, the 1.226.0 comparison
|
|
24783
|
+
* run): whether the artifact THIS terminal carries was accepted by
|
|
24784
|
+
* the declared finish contract, whether there is an artifact to
|
|
24785
|
+
* read at all, and where its acceptance is journaled. The harness
|
|
24786
|
+
* that scored the comparison could not answer the first question
|
|
24787
|
+
* from the terminal: it read `status: 'ok'`, and the run had in
|
|
24788
|
+
* fact accepted its children, failed its synthesis three times,
|
|
24789
|
+
* and settled carrying nothing the contract ever accepted. Every
|
|
24790
|
+
* input is a fact the run already journaled, so the verdict is
|
|
24791
|
+
* derived, never remembered, and a resume re-derives the same one.
|
|
24792
|
+
*
|
|
24793
|
+
* `deliverableAccepted` is ABSENT (never false) when no
|
|
24794
|
+
* `finishValidation` was declared: nothing judged anything, and
|
|
24795
|
+
* the RV1209 provenance doctrine says absence means NOT RECORDED.
|
|
24796
|
+
* `acceptedArtifactRef` names the decision entry that holds the
|
|
24797
|
+
* acceptance, which is the finish-validation decision on the
|
|
24798
|
+
* ordinary path, the RV510 skip decision when the gate skipped the
|
|
24799
|
+
* synthesis, and the RV2505 regression decision when a failing
|
|
24800
|
+
* synthesis handed the run back to its draft: three different
|
|
24801
|
+
* entries, one question, one field.
|
|
24802
|
+
*/
|
|
24803
|
+
const deliverableVerdict = (artifact) => {
|
|
24804
|
+
const resultAvailable = artifact !== void 0 && artifact !== null;
|
|
24805
|
+
if (validationSpec === void 0) return { resultAvailable };
|
|
24806
|
+
if (synthesisRegressed !== void 0) return {
|
|
24807
|
+
resultAvailable,
|
|
24808
|
+
deliverableAccepted: true,
|
|
24809
|
+
acceptedArtifactRef: synthesisRegressed.decisionRef
|
|
24810
|
+
};
|
|
24811
|
+
if (synthesisSkipDecisionRef !== void 0) return {
|
|
24812
|
+
resultAvailable,
|
|
24813
|
+
deliverableAccepted: true,
|
|
24814
|
+
acceptedArtifactRef: synthesisSkipDecisionRef
|
|
24815
|
+
};
|
|
24816
|
+
const accepted = internals.replayer.snapshot().filter((entry) => {
|
|
24817
|
+
if (entry.kind !== "decision" || entry.scope !== callingState.scope) return false;
|
|
24818
|
+
const value = entry.value;
|
|
24819
|
+
return value?.decisionType === "orchestrator_finish_validation" && value.verdict === "accepted" && contractGenerationCurrent(value);
|
|
24820
|
+
}).at(-1);
|
|
24821
|
+
return accepted === void 0 ? {
|
|
24822
|
+
resultAvailable,
|
|
24823
|
+
deliverableAccepted: false
|
|
24824
|
+
} : {
|
|
24825
|
+
resultAvailable,
|
|
24826
|
+
deliverableAccepted: true,
|
|
24827
|
+
acceptedArtifactRef: accepted.seq
|
|
24828
|
+
};
|
|
24829
|
+
};
|
|
24830
|
+
/**
|
|
24831
|
+
* The rejected candidates of the CURRENT contract generation, in
|
|
24832
|
+
* judgement order (RV2507): a pure fold over decisions the journal
|
|
24833
|
+
* already holds, so a resume re-derives the identical list without
|
|
24834
|
+
* re-running a validator. A superseded generation's rejections stay
|
|
24835
|
+
* in the journal as the history they are and drop out here, exactly
|
|
24836
|
+
* as they drop out of the repair budget.
|
|
24837
|
+
*/
|
|
24838
|
+
const rejectedFinishCandidates = () => validationDecisions().filter((decision) => decision.verdict !== "accepted" && contractGenerationCurrent(decision) && decision.candidateHash !== void 0).map((decision) => ({
|
|
24839
|
+
callId: decision.callId,
|
|
24840
|
+
verdict: decision.verdict,
|
|
24841
|
+
hash: decision.candidateHash ?? "",
|
|
24842
|
+
chars: decision.candidateChars ?? 0,
|
|
24843
|
+
failed: decision.failed,
|
|
24844
|
+
...decision.candidateRef === void 0 ? {} : { ref: decision.candidateRef }
|
|
24845
|
+
}));
|
|
24406
24846
|
const enrichSynthesisFailure = (thrown, snapshot) => {
|
|
24407
24847
|
const passTruth = {
|
|
24408
24848
|
...claimConsistencyMeta === void 0 ? {} : { claimConsistencyMeta },
|
|
24409
24849
|
semanticPasses: semanticPassesSummary({
|
|
24410
24850
|
ran: false,
|
|
24411
24851
|
reason: "synthesis-failed"
|
|
24412
|
-
})
|
|
24852
|
+
}),
|
|
24853
|
+
resultAvailable: false,
|
|
24854
|
+
...validationSpec === void 0 ? {} : { deliverableAccepted: false }
|
|
24413
24855
|
};
|
|
24856
|
+
const rejected = rejectedFinishCandidates();
|
|
24857
|
+
if (rejected.length > 0) passTruth.rejectedFinishCandidates = rejected;
|
|
24414
24858
|
if (thrown instanceof BudgetExhaustedError) throw new BudgetExhaustedError(thrown.message, { data: {
|
|
24415
24859
|
...thrown.data ?? {},
|
|
24416
24860
|
...snapshot ?? {},
|
|
@@ -24440,13 +24884,17 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24440
24884
|
if (result.status !== "ok") throw new ConfigError(`the orchestrator agent terminated with status '${result.status}'` + (result.errorMessage === void 0 ? "" : `: ${result.errorMessage}`));
|
|
24441
24885
|
if (opts?.acceptance === void 0) {
|
|
24442
24886
|
await runContradictionPass();
|
|
24443
|
-
await runClaimConsistencyPass(result.output);
|
|
24887
|
+
if (claimStage !== "final") await runClaimConsistencyPass(result.output);
|
|
24888
|
+
let bare;
|
|
24444
24889
|
try {
|
|
24445
|
-
|
|
24890
|
+
bare = await runSynthesis(result.output);
|
|
24446
24891
|
} catch (thrown) {
|
|
24447
24892
|
await journalSynthesisAdmissionDecline(thrown);
|
|
24448
|
-
|
|
24893
|
+
if ((await draftFallbackOnRegression(result.output, thrown)).used) bare = result.output;
|
|
24894
|
+
else return enrichSynthesisFailure(thrown);
|
|
24449
24895
|
}
|
|
24896
|
+
if (claimStage !== "draft") await runClaimConsistencyPass(bare, void 0, "final");
|
|
24897
|
+
return bare;
|
|
24450
24898
|
}
|
|
24451
24899
|
const acceptanceKey = "acceptance";
|
|
24452
24900
|
const priorAcceptance = internals.replayer.snapshot().find((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.key === acceptanceKey);
|
|
@@ -24640,19 +25088,21 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24640
25088
|
...decision.salvagedPartialChildren === void 0 ? {} : { salvagedPartialChildren: decision.salvagedPartialChildren },
|
|
24641
25089
|
...decision.salvagedTerminalOutputChildren === void 0 ? {} : { salvagedTerminalOutputChildren: decision.salvagedTerminalOutputChildren }
|
|
24642
25090
|
});
|
|
24643
|
-
|
|
25091
|
+
const acceptanceSnapshot = {
|
|
24644
25092
|
completion: decision.completion,
|
|
24645
25093
|
childStatusCounts: decision.childStatusCounts,
|
|
24646
25094
|
degradedReasons: decision.degradedReasons,
|
|
24647
25095
|
...decision.salvagedPartialChildren === void 0 ? {} : { salvagedPartialChildren: decision.salvagedPartialChildren },
|
|
24648
25096
|
...decision.salvagedTerminalOutputChildren === void 0 ? {} : { salvagedTerminalOutputChildren: decision.salvagedTerminalOutputChildren }
|
|
24649
|
-
}
|
|
25097
|
+
};
|
|
25098
|
+
if (claimStage !== "final") await runClaimConsistencyPass(result.output, acceptanceSnapshot);
|
|
24650
25099
|
let synthesizedFinal;
|
|
24651
25100
|
try {
|
|
24652
25101
|
synthesizedFinal = await runSynthesis(result.output);
|
|
24653
25102
|
} catch (thrown) {
|
|
24654
25103
|
await journalSynthesisAdmissionDecline(thrown);
|
|
24655
|
-
|
|
25104
|
+
if ((await draftFallbackOnRegression(result.output, thrown)).used) synthesizedFinal = result.output;
|
|
25105
|
+
else enrichSynthesisFailure(thrown, {
|
|
24656
25106
|
completion: decision.completion,
|
|
24657
25107
|
childStatusCounts: decision.childStatusCounts,
|
|
24658
25108
|
degradedReasons: decision.degradedReasons,
|
|
@@ -24662,10 +25112,31 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24662
25112
|
...decision.children === void 0 ? {} : { acceptanceChildren: decision.children }
|
|
24663
25113
|
});
|
|
24664
25114
|
}
|
|
25115
|
+
if (claimStage !== "draft") {
|
|
25116
|
+
claimConsistencyDraftMeta = claimStage === "both" ? claimConsistencyMeta : void 0;
|
|
25117
|
+
await runClaimConsistencyPass(synthesizedFinal, acceptanceSnapshot, "final");
|
|
25118
|
+
}
|
|
24665
25119
|
const envelopeSchemaRecovered = (result.schemaRecoveredTerminalExchanges ?? 0) + synthesisSchemaRecoveredExchanges;
|
|
25120
|
+
const deliverable = deliverableVerdict(synthesizedFinal);
|
|
25121
|
+
const draftToFinal = opts?.synthesis === void 0 ? void 0 : (() => {
|
|
25122
|
+
const hashOf = (value) => createHash("sha256").update(jcsSerialize(value ?? null), "utf8").digest("hex");
|
|
25123
|
+
const draftHash = hashOf(result.output);
|
|
25124
|
+
const finalHash = hashOf(synthesizedFinal);
|
|
25125
|
+
return {
|
|
25126
|
+
draftHash,
|
|
25127
|
+
finalHash,
|
|
25128
|
+
rewritten: draftHash !== finalHash,
|
|
25129
|
+
...claimConsistencyMeta === void 0 ? {} : { claimsJudgedOn: claimStage }
|
|
25130
|
+
};
|
|
25131
|
+
})();
|
|
25132
|
+
const envelopeRejectedCandidates = rejectedFinishCandidates();
|
|
24666
25133
|
return {
|
|
24667
25134
|
result: synthesizedFinal,
|
|
24668
25135
|
completion: decision.completion,
|
|
25136
|
+
resultAvailable: deliverable.resultAvailable,
|
|
25137
|
+
...deliverable.deliverableAccepted === void 0 ? {} : { deliverableAccepted: deliverable.deliverableAccepted },
|
|
25138
|
+
...deliverable.acceptedArtifactRef === void 0 ? {} : { acceptedArtifactRef: deliverable.acceptedArtifactRef },
|
|
25139
|
+
...envelopeRejectedCandidates.length === 0 ? {} : { rejectedFinishCandidates: envelopeRejectedCandidates },
|
|
24669
25140
|
childStatusCounts: decision.childStatusCounts,
|
|
24670
25141
|
degradedReasons: decision.degradedReasons,
|
|
24671
25142
|
...decision.salvagedPartialChildren === void 0 ? {} : { salvagedPartialChildren: decision.salvagedPartialChildren },
|
|
@@ -24676,6 +25147,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24676
25147
|
...envelopeSchemaRecovered === 0 ? {} : { schemaRecoveredFinishExchanges: envelopeSchemaRecovered },
|
|
24677
25148
|
...synthesisReserveLifecycle === void 0 ? {} : { synthesisReserve: synthesisReserveLifecycle },
|
|
24678
25149
|
...synthesisSkippedByValidDraft ? { synthesisSkipped: "synthesis_skipped_by_valid_draft" } : {},
|
|
25150
|
+
...synthesisRegressed === void 0 ? {} : { synthesisRegressed },
|
|
24679
25151
|
...contradictionsFound === void 0 ? {} : {
|
|
24680
25152
|
contradictions: contradictionsFound,
|
|
24681
25153
|
contradictionsMeta
|
|
@@ -24684,6 +25156,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
24684
25156
|
...claimFindingsFound === void 0 ? {} : { claimContradictions: claimFindingsFound },
|
|
24685
25157
|
claimConsistencyMeta
|
|
24686
25158
|
},
|
|
25159
|
+
...claimConsistencyDraftMeta === void 0 ? {} : { claimConsistencyDraftMeta },
|
|
25160
|
+
...draftToFinal === void 0 ? {} : { draftToFinal },
|
|
24687
25161
|
semanticPasses: semanticPassesSummary(opts?.synthesis === void 0 ? {
|
|
24688
25162
|
ran: false,
|
|
24689
25163
|
reason: "not-configured"
|
|
@@ -25337,12 +25811,18 @@ function preflightEstimate(input) {
|
|
|
25337
25811
|
cacheReadTokens: 0,
|
|
25338
25812
|
cacheWriteTokens: 0
|
|
25339
25813
|
});
|
|
25340
|
-
const
|
|
25341
|
-
const
|
|
25342
|
-
|
|
25343
|
-
|
|
25814
|
+
const grantedRepairs = input.finishValidation === void 0 ? 0 : input.finishValidation.maxRepairs ?? 1;
|
|
25815
|
+
const tailTurns = 1 + grantedRepairs;
|
|
25816
|
+
const requiredUsd = compositionUsd * tailTurns;
|
|
25817
|
+
const exposureCapUsd = input.run?.maxInFlightExposureUsd;
|
|
25818
|
+
const reserveLineUsd = ceilingUsd === void 0 ? void 0 : ceilingUsd - declared;
|
|
25819
|
+
const exposureRoomUsd = exposureCapUsd === void 0 || reserveLineUsd === void 0 ? void 0 : exposureCapUsd - reserveLineUsd;
|
|
25820
|
+
const reserveShort = declared < requiredUsd;
|
|
25821
|
+
const exposureShort = exposureRoomUsd !== void 0 && exposureRoomUsd < requiredUsd;
|
|
25822
|
+
if (reserveShort || exposureShort) say({
|
|
25823
|
+
severity: reserveShort && exposureShort ? "error" : "warning",
|
|
25344
25824
|
code: "synthesis-reserve-below-cap-composition",
|
|
25345
|
-
message: `
|
|
25825
|
+
message: `the mandatory synthesis tail is ${String(tailTurns)} turn(s) (one composition ` + (grantedRepairs === 0 ? "and no granted repair" : `plus the ${String(grantedRepairs)} granted repair(s)`) + `), each writing to its ${String(outputBound)} token output allowance over the declared ${String(synthesis.estInputTokens ?? 0)} input floor: ${String(tailTurns)} x ${compositionUsd.toFixed(4)} = ${requiredUsd.toFixed(4)} USD at the rates of '${servedBy}'` + (reserveShort ? `; the committed synthesis reserve holds only ${declared.toFixed(4)} USD` : `; the committed ${declared.toFixed(4)} USD reserve covers it`) + (exposureRoomUsd === void 0 ? "" : exposureShort ? `, and maxInFlightExposureUsd ${(exposureCapUsd ?? 0).toFixed(4)} leaves only ${exposureRoomUsd.toFixed(4)} USD above the reserve line ${(reserveLineUsd ?? 0).toFixed(4)} USD` : `, and the exposure ceiling leaves ${exposureRoomUsd.toFixed(4)} USD above the reserve line`) + ": a composition cut at the allowance can fail its validators with no room left for the repairs the runtime will grant; hold the reserve at the tail arithmetic, raise maxInFlightExposureUsd toward the ceiling, lower maxOutputTokensPerTurn, or grant fewer repairs",
|
|
25346
25826
|
spawn: "synthesis"
|
|
25347
25827
|
});
|
|
25348
25828
|
}
|
|
@@ -26336,6 +26816,21 @@ function liftRunCompletion(candidate) {
|
|
|
26336
26816
|
if (typeof metaCandidate === "object" && metaCandidate !== null && !Array.isArray(metaCandidate)) lifted.claimConsistencyMeta = { ...metaCandidate };
|
|
26337
26817
|
const skippedCandidate = candidate.synthesisSkipped;
|
|
26338
26818
|
if (typeof skippedCandidate === "boolean" || typeof skippedCandidate === "string") lifted.synthesisSkipped = skippedCandidate;
|
|
26819
|
+
const acceptedCandidate = candidate.deliverableAccepted;
|
|
26820
|
+
if (typeof acceptedCandidate === "boolean") lifted.deliverableAccepted = acceptedCandidate;
|
|
26821
|
+
const availableCandidate = candidate.resultAvailable;
|
|
26822
|
+
if (typeof availableCandidate === "boolean") lifted.resultAvailable = availableCandidate;
|
|
26823
|
+
const artifactRefCandidate = candidate.acceptedArtifactRef;
|
|
26824
|
+
if (typeof artifactRefCandidate === "number" && Number.isSafeInteger(artifactRefCandidate) && artifactRefCandidate >= 0) lifted.acceptedArtifactRef = artifactRefCandidate;
|
|
26825
|
+
const rejectedCandidates = candidate.rejectedFinishCandidates;
|
|
26826
|
+
if (Array.isArray(rejectedCandidates)) {
|
|
26827
|
+
const validRow = (row) => {
|
|
26828
|
+
if (typeof row !== "object" || row === null) return false;
|
|
26829
|
+
const { callId, verdict, hash, chars, failed, ref } = row;
|
|
26830
|
+
return typeof callId === "string" && (verdict === "repair" || verdict === "rejected") && typeof hash === "string" && typeof chars === "number" && Number.isSafeInteger(chars) && chars >= 0 && (ref === void 0 || typeof ref === "string") && Array.isArray(failed) && failed.every((entry) => typeof entry === "object" && entry !== null && typeof entry.name === "string" && Array.isArray(entry.reasons) && entry.reasons.every((reason) => typeof reason === "string"));
|
|
26831
|
+
};
|
|
26832
|
+
if (rejectedCandidates.every(validRow)) lifted.rejectedFinishCandidates = rejectedCandidates.map((row) => ({ ...row }));
|
|
26833
|
+
}
|
|
26339
26834
|
return lifted;
|
|
26340
26835
|
}
|
|
26341
26836
|
/**
|
|
@@ -26513,6 +27008,7 @@ function createEngine(options) {
|
|
|
26513
27008
|
if (wf.kind !== "workflow" && wf.kind !== "compiled-workflow") throw new ConfigError("engine.run accepts in-process Workflow values or compileScript CompiledWorkflow values");
|
|
26514
27009
|
if (opts?.budgetUsd !== void 0) requireNonNegativeNumber(opts.budgetUsd, "RunOptions.budgetUsd");
|
|
26515
27010
|
if (opts?.maxInFlightExposureUsd !== void 0) requireNonNegativeNumber(opts.maxInFlightExposureUsd, "RunOptions.maxInFlightExposureUsd");
|
|
27011
|
+
if (opts?.clampTurnToExposure !== void 0 && typeof opts.clampTurnToExposure !== "boolean") throw new ConfigError("RunOptions.clampTurnToExposure must be a boolean; got " + JSON.stringify(opts.clampTurnToExposure));
|
|
26516
27012
|
if (opts?.strictPricing !== void 0 && typeof opts.strictPricing !== "boolean" && (typeof opts.strictPricing !== "object" || opts.strictPricing === null || Array.isArray(opts.strictPricing))) throw new ConfigError("RunOptions.strictPricing must be a boolean or an options object; got " + JSON.stringify(opts.strictPricing));
|
|
26517
27013
|
if (opts?.limits !== void 0) validateUsageLimits(opts.limits, "RunOptions.limits");
|
|
26518
27014
|
const deadlineAtMs = opts?.deadlineAt === void 0 ? void 0 : parseDeadlineAt(opts.deadlineAt);
|
|
@@ -26550,6 +27046,7 @@ function createEngine(options) {
|
|
|
26550
27046
|
const makeBudget = () => new RunBudget({
|
|
26551
27047
|
...ceilingUsd === void 0 ? {} : { ceilingUsd },
|
|
26552
27048
|
...exposureCapUsd === void 0 ? {} : { maxInFlightExposureUsd: exposureCapUsd },
|
|
27049
|
+
...opts?.clampTurnToExposure === true ? { clampTurnToExposure: true } : {},
|
|
26553
27050
|
...strictPricing === void 0 ? {} : {
|
|
26554
27051
|
strictPricing,
|
|
26555
27052
|
now: realNow
|
|
@@ -26929,6 +27426,10 @@ function createEngine(options) {
|
|
|
26929
27426
|
if (lifted.semanticPasses !== void 0) outcomeFacts.semanticPasses = lifted.semanticPasses;
|
|
26930
27427
|
if (lifted.claimConsistencyMeta !== void 0) outcomeFacts.claimConsistencyMeta = lifted.claimConsistencyMeta;
|
|
26931
27428
|
if (lifted.synthesisSkipped !== void 0) outcomeFacts.synthesisSkipped = lifted.synthesisSkipped;
|
|
27429
|
+
if (lifted.deliverableAccepted !== void 0) outcomeFacts.deliverableAccepted = lifted.deliverableAccepted;
|
|
27430
|
+
if (lifted.resultAvailable !== void 0) outcomeFacts.resultAvailable = lifted.resultAvailable;
|
|
27431
|
+
if (lifted.acceptedArtifactRef !== void 0) outcomeFacts.acceptedArtifactRef = lifted.acceptedArtifactRef;
|
|
27432
|
+
if (lifted.rejectedFinishCandidates !== void 0) outcomeFacts.rejectedFinishCandidates = lifted.rejectedFinishCandidates;
|
|
26932
27433
|
}
|
|
26933
27434
|
let settlementFailure;
|
|
26934
27435
|
let supersededBy;
|
|
@@ -27590,4 +28091,4 @@ function createSandboxBridge(ctx, options) {
|
|
|
27590
28091
|
};
|
|
27591
28092
|
}
|
|
27592
28093
|
//#endregion
|
|
27593
|
-
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_AGENT_SCHEMA, SandboxError, ScriptRejected, Semaphore, SettlementError, SpanRegistry, SupersededError, 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, 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, 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 };
|
|
28094
|
+
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_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, 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 };
|