@rulvar/core 1.215.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
  } });
@@ -19831,6 +19833,14 @@ const DEFAULT_CITATION_PATTERN = "[\\w./-]+\\.\\w+:\\d+";
19831
19833
  /** The default preserved share, the improvement plan's RV-202 gate. */
19832
19834
  const DEFAULT_EVIDENCE_MIN_SHARE = .95;
19833
19835
  const MAX_LISTED_CITATIONS = 20;
19836
+ /**
19837
+ * The evidence-grade verdict names its offending sentences (RV2105):
19838
+ * bounded so a document written entirely in the graded register cannot
19839
+ * balloon the journaled verdict or the repair prompt, truncated per
19840
+ * sentence for the same reason.
19841
+ */
19842
+ const MAX_NAMED_OFFENDING_SENTENCES = 5;
19843
+ const MAX_OFFENDING_SENTENCE_CHARS = 240;
19834
19844
  function listCitations(values) {
19835
19845
  return values.length <= MAX_LISTED_CITATIONS ? values.join(", ") : `${values.slice(0, MAX_LISTED_CITATIONS).join(", ")} and ${String(values.length - MAX_LISTED_CITATIONS)} more`;
19836
19846
  }
@@ -20048,15 +20058,27 @@ function evidenceGradeValidator(options) {
20048
20058
  name: options?.name ?? "evidence-grade",
20049
20059
  validate: (input) => {
20050
20060
  const unsupported = [];
20061
+ const offenders = [];
20051
20062
  for (const sentence of sentencesOf(input.text)) {
20052
20063
  const haystack = sentence.toLowerCase();
20053
20064
  const found = lowered.filter((phrase) => haystack.includes(phrase));
20054
20065
  if (found.length === 0 || new RegExp(artifactPattern, "").test(sentence)) continue;
20066
+ offenders.push(sentence);
20055
20067
  for (const phrase of found) if (!unsupported.includes(phrase)) unsupported.push(phrase);
20056
20068
  }
20057
- return unsupported.length === 0 ? ok : {
20069
+ if (unsupported.length === 0) return ok;
20070
+ const named = offenders.slice(0, MAX_NAMED_OFFENDING_SENTENCES).map((sentence) => {
20071
+ const flat = sentence.replace(/\s+/gu, " ").trim();
20072
+ return `offending sentence: "${flat.length <= MAX_OFFENDING_SENTENCE_CHARS ? flat : `${flat.slice(0, MAX_OFFENDING_SENTENCE_CHARS)}...`}"`;
20073
+ });
20074
+ const overflow = offenders.length - named.length;
20075
+ return {
20058
20076
  ok: false,
20059
- reasons: [`evidence-grade claims cite no run or repro artifact in their own sentence: ${listCitations(unsupported)}; each such claim must name a run id or a file:line citation beside it`]
20077
+ reasons: [
20078
+ `evidence-grade claims cite no run or repro artifact in their own sentence: ${listCitations(unsupported)}; each such claim must name a run id or a file:line citation beside it`,
20079
+ ...named,
20080
+ ...overflow > 0 ? [`and ${String(overflow)} more offending sentences`] : []
20081
+ ]
20060
20082
  };
20061
20083
  }
20062
20084
  };
@@ -23382,7 +23404,42 @@ function makeOrchestratorWorkflow(goal, opts) {
23382
23404
  ...spec.judge?.effort === void 0 ? {} : { effort: spec.judge.effort },
23383
23405
  ...spec.judge?.estCost === void 0 ? {} : { estCost: spec.judge.estCost }
23384
23406
  };
23385
- 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
+ }
23386
23443
  if (judged.status !== "ok" || judged.output === null || judged.output === void 0) {
23387
23444
  claimConsistencyMeta = finishMeta({
23388
23445
  judgeInvoked: true,
@@ -24504,6 +24561,7 @@ function preflightEstimate(input) {
24504
24561
  if (input.orchestrator !== void 0) {
24505
24562
  if (input.orchestrator.estInputTokens !== void 0) requireNonNegativeInteger(input.orchestrator.estInputTokens, "preflight.orchestrator.estInputTokens");
24506
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");
24507
24565
  const spec = input.orchestrator.budget;
24508
24566
  const fraction = spec?.capFraction ?? .2;
24509
24567
  const fromFraction = ceilingUsd === void 0 ? void 0 : fraction * ceilingUsd;
@@ -25040,6 +25098,17 @@ function preflightEstimate(input) {
25040
25098
  code: "reserve-line-headroom",
25041
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`
25042
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
+ }
25043
25112
  if (wave.length > 0 && denied > 0) {
25044
25113
  const deniedLabels = wave.filter((row) => !row.admitted).map((row) => row.label);
25045
25114
  if (admitted === 0) say({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.215.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",