@rulvar/core 1.216.0 → 1.217.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 CHANGED
@@ -9992,6 +9992,17 @@ interface OrchestrateClaimConsistencyMeta {
9992
9992
  /** Present when the judge invocation did not settle ok. */
9993
9993
  judgeFailed?: true;
9994
9994
  /**
9995
+ * Present when the judge invocation was refused ADMISSION and never
9996
+ * dispatched (RV2106): the ninth parity run's judge estimate did not
9997
+ * fit the orchestrator account's working room past the held
9998
+ * synthesis reserve, and the bare refusal killed a run whose fan-out
9999
+ * and draft were already complete. The declined pass degrades like a
10000
+ * failed judge (the meta names it, the journaled decision carries
10001
+ * the arithmetic, only the armed 'fail' posture stops the run) and
10002
+ * the synthesis its reserve was holding money for still dispatches.
10003
+ */
10004
+ judgeDeclined?: true;
10005
+ /**
9995
10006
  * The one field a consumer reads INSTEAD of inferring semantic
9996
10007
  * health from an empty findings array (RV1702):
9997
10008
  * {@link claimCoverageOf} over this meta, so `completion:
@@ -13068,6 +13079,20 @@ interface PreflightOrchestratorSpec {
13068
13079
  exposeChildResultTools?: boolean; /** Mirrors OrchestrateSynthesis.context; default 'digests'. */
13069
13080
  context?: "digests" | "full";
13070
13081
  };
13082
+ /**
13083
+ * The claim-consistency judge's admission estimate (RV2106), exactly
13084
+ * OrchestrateClaimConsistency.judge.estCost: the post-fan-in judge
13085
+ * admits against the ORCHESTRATOR account, whose working room past
13086
+ * the held synthesis reserve the coordination loop's own turns spend
13087
+ * from first. Declaring the estimate lets the estimator judge that
13088
+ * room statically (`orchestrator-working-room`); absent, the finding
13089
+ * stays silent, exactly like every other undeclared input.
13090
+ */
13091
+ claimConsistency?: {
13092
+ judge?: {
13093
+ estCost?: number;
13094
+ };
13095
+ };
13071
13096
  }
13072
13097
  /** The full input: engine surface, run surface, and the declared wave. */
13073
13098
  interface PreflightInput {
package/dist/index.js CHANGED
@@ -13909,10 +13909,12 @@ var RunBudget = class {
13909
13909
  const committed = account.spentUsd + account.committedReserveUsd + account.finalizeReserveUsd + account.synthesisReserveUsd;
13910
13910
  if (committed >= account.ceilingUsd || committed + reserveUsd > account.ceilingUsd) {
13911
13911
  if (account.scope === "run") this.exhaustedInternal = true;
13912
- throw new BudgetExhaustedError(`budget ceiling reached on account '${account.scope}': spent ${account.spentUsd.toFixed(4)} USD plus committed reserves ${(account.committedReserveUsd + account.finalizeReserveUsd).toFixed(4)} USD plus the proposed reserve ${reserveUsd.toFixed(4)} USD does not fit the ceiling ${account.ceilingUsd.toFixed(4)} USD`, { data: {
13912
+ throw new BudgetExhaustedError(`budget ceiling reached on account '${account.scope}': spent ${account.spentUsd.toFixed(4)} USD plus committed reserves ${(account.committedReserveUsd + account.finalizeReserveUsd).toFixed(4)} USD ` + (account.synthesisReserveUsd > 0 ? `plus the held synthesis reserve ${account.synthesisReserveUsd.toFixed(4)} USD ` : "") + `plus the proposed reserve ${reserveUsd.toFixed(4)} USD does not fit the ceiling ${account.ceilingUsd.toFixed(4)} USD`, { data: {
13913
13913
  account: account.scope,
13914
13914
  spentUsd: account.spentUsd,
13915
13915
  committedReserveUsd: account.committedReserveUsd,
13916
+ finalizeReserveUsd: account.finalizeReserveUsd,
13917
+ synthesisReserveUsd: account.synthesisReserveUsd,
13916
13918
  proposedReserveUsd: reserveUsd,
13917
13919
  ceilingUsd: account.ceilingUsd
13918
13920
  } });
@@ -23402,7 +23404,42 @@ function makeOrchestratorWorkflow(goal, opts) {
23402
23404
  ...spec.judge?.effort === void 0 ? {} : { effort: spec.judge.effort },
23403
23405
  ...spec.judge?.estCost === void 0 ? {} : { estCost: spec.judge.estCost }
23404
23406
  };
23405
- const judged = await runtime.runInScope(judgeState, () => ctx.agent(judgePrompt, judgeOpts));
23407
+ let judged;
23408
+ try {
23409
+ judged = await runtime.runInScope(judgeState, () => ctx.agent(judgePrompt, judgeOpts));
23410
+ } catch (declined) {
23411
+ if (!(declined instanceof BudgetExhaustedError)) throw declined;
23412
+ claimConsistencyMeta = finishMeta({
23413
+ judgeInvoked: false,
23414
+ judgeDeclined: true
23415
+ });
23416
+ const declineKey = deriverV2.deriveKey({ kind: "orchestrator-claim-judge-declined" });
23417
+ if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === declineKey)) await internals.replayer.appendSinglePhase({
23418
+ scope: callingState.scope,
23419
+ key: declineKey,
23420
+ kind: "decision",
23421
+ status: "ok",
23422
+ spanId: internals.spans.mint(callingState.spanId),
23423
+ site: "orchestrator-budget",
23424
+ value: {
23425
+ decisionType: "orchestrator_claim_judge_declined",
23426
+ reason: declined.message.slice(0, 300),
23427
+ remainingUsd: internals.budget.remainingUsd(orchestratorAccount ?? "run") ?? null
23428
+ }
23429
+ });
23430
+ internals.events.emit({
23431
+ type: "log",
23432
+ level: "warn",
23433
+ msg: "orchestrator claim consistency judge declined by admission",
23434
+ data: { reason: declined.message.slice(0, 300) }
23435
+ }, callingState.spanId);
23436
+ if (onFound === "fail") throw new FailRunError("the claim-consistency judge could not be admitted within the orchestrator account, so the armed fail posture cannot pass the draft: " + declined.message.slice(0, 300), { data: {
23437
+ source: "orchestrator_claim_consistency",
23438
+ claimConsistencyMeta,
23439
+ ...snapshot ?? {}
23440
+ } });
23441
+ return;
23442
+ }
23406
23443
  if (judged.status !== "ok" || judged.output === null || judged.output === void 0) {
23407
23444
  claimConsistencyMeta = finishMeta({
23408
23445
  judgeInvoked: true,
@@ -24524,6 +24561,7 @@ function preflightEstimate(input) {
24524
24561
  if (input.orchestrator !== void 0) {
24525
24562
  if (input.orchestrator.estInputTokens !== void 0) requireNonNegativeInteger(input.orchestrator.estInputTokens, "preflight.orchestrator.estInputTokens");
24526
24563
  if (input.orchestrator.acceptance?.minSpawnedChildren !== void 0) requirePositiveInteger$2(input.orchestrator.acceptance.minSpawnedChildren, "preflight.orchestrator.acceptance.minSpawnedChildren");
24564
+ if (input.orchestrator.claimConsistency?.judge?.estCost !== void 0) requireNonNegativeNumber(input.orchestrator.claimConsistency.judge.estCost, "preflight.orchestrator.claimConsistency.judge.estCost");
24527
24565
  const spec = input.orchestrator.budget;
24528
24566
  const fraction = spec?.capFraction ?? .2;
24529
24567
  const fromFraction = ceilingUsd === void 0 ? void 0 : fraction * ceilingUsd;
@@ -25060,6 +25098,17 @@ function preflightEstimate(input) {
25060
25098
  code: "reserve-line-headroom",
25061
25099
  message: `the admitted wave's steady state sits ${reserveLineHeadroomUsd.toFixed(4)} USD under the reserve line ${reserveLineUsd.toFixed(4)} USD (the ceiling minus the synthesis reserve), less than two coordination turn floors of headroom (${liveRootExposureTermUsd.toFixed(4)} USD each): child spend past the declared estimates eats that headroom, the coordination loop is then refused at the line, and the run settles partial with the synthesis redeemed from its reserve (RV2101); size the wave below the line or raise the ceiling to keep coordinating past it`
25062
25100
  });
25101
+ {
25102
+ const judgeEstUsd = input.orchestrator?.claimConsistency?.judge?.estCost;
25103
+ if (judgeEstUsd !== void 0 && effectiveCapUsd !== void 0 && synthesisHoldUsd > 0) {
25104
+ const workingRoomUsd = effectiveCapUsd - synthesisHoldUsd;
25105
+ if (workingRoomUsd < liveRootExposureTermUsd + judgeEstUsd) say({
25106
+ severity: "warning",
25107
+ code: "orchestrator-working-room",
25108
+ message: `the orchestrator account's working room past the held synthesis reserve is ${workingRoomUsd.toFixed(4)} USD (cap ${effectiveCapUsd.toFixed(4)} minus the ${synthesisHoldUsd.toFixed(4)} USD hold), below one coordination turn floor (${liveRootExposureTermUsd.toFixed(4)} USD) plus the declared ${judgeEstUsd.toFixed(4)} USD claim-consistency judge estimate: the judge admission will be declined once the coordination loop has taken even one turn, and the pass degrades to its journaled declined verdict (RV2106); raise the cap, shrink the judge estimate, or shrink the synthesis reserve`
25109
+ });
25110
+ }
25111
+ }
25063
25112
  if (wave.length > 0 && denied > 0) {
25064
25113
  const deniedLabels = wave.filter((row) => !row.admitted).map((row) => row.label);
25065
25114
  if (admitted === 0) say({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.216.0",
3
+ "version": "1.217.0",
4
4
  "description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",