@rulvar/core 1.214.0 → 1.216.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.
Files changed (2) hide show
  1. package/dist/index.js +52 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12623,6 +12623,7 @@ async function runAgent(options) {
12623
12623
  kind: "budget",
12624
12624
  retryable: false
12625
12625
  };
12626
+ errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
12626
12627
  break;
12627
12628
  }
12628
12629
  turns += 1;
@@ -12834,12 +12835,13 @@ async function runAgent(options) {
12834
12835
  });
12835
12836
  try {
12836
12837
  options.budget?.beforeTurn();
12837
- } catch {
12838
+ } catch (thrown) {
12838
12839
  status = "error";
12839
12840
  agentError = {
12840
12841
  kind: "budget",
12841
12842
  retryable: false
12842
12843
  };
12844
+ errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
12843
12845
  endPhase(summarizePhase, "error");
12844
12846
  break;
12845
12847
  }
@@ -13006,11 +13008,12 @@ async function runAgent(options) {
13006
13008
  let proceed = true;
13007
13009
  try {
13008
13010
  options.budget?.beforeTurn();
13009
- } catch {
13011
+ } catch (thrown) {
13010
13012
  events?.emit({
13011
13013
  type: "log",
13012
13014
  level: "warn",
13013
- msg: "the finalization reserve turn was skipped: the budget blocks further turns"
13015
+ msg: "the finalization reserve turn was skipped: the budget blocks further turns",
13016
+ data: { reason: thrown instanceof Error ? thrown.message : String(thrown) }
13014
13017
  });
13015
13018
  proceed = false;
13016
13019
  }
@@ -13114,12 +13117,13 @@ async function runAgent(options) {
13114
13117
  let proceed = true;
13115
13118
  try {
13116
13119
  options.budget?.beforeTurn();
13117
- } catch {
13120
+ } catch (thrown) {
13118
13121
  status = "error";
13119
13122
  agentError = {
13120
13123
  kind: "budget",
13121
13124
  retryable: false
13122
13125
  };
13126
+ errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
13123
13127
  proceed = false;
13124
13128
  }
13125
13129
  if (proceed) {
@@ -13266,12 +13270,13 @@ async function runAgent(options) {
13266
13270
  while (status === "ok") {
13267
13271
  try {
13268
13272
  options.budget?.beforeTurn();
13269
- } catch {
13273
+ } catch (thrown) {
13270
13274
  status = "error";
13271
13275
  agentError = {
13272
13276
  kind: "budget",
13273
13277
  retryable: false
13274
13278
  };
13279
+ errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
13275
13280
  break;
13276
13281
  }
13277
13282
  turns += 1;
@@ -19826,6 +19831,14 @@ const DEFAULT_CITATION_PATTERN = "[\\w./-]+\\.\\w+:\\d+";
19826
19831
  /** The default preserved share, the improvement plan's RV-202 gate. */
19827
19832
  const DEFAULT_EVIDENCE_MIN_SHARE = .95;
19828
19833
  const MAX_LISTED_CITATIONS = 20;
19834
+ /**
19835
+ * The evidence-grade verdict names its offending sentences (RV2105):
19836
+ * bounded so a document written entirely in the graded register cannot
19837
+ * balloon the journaled verdict or the repair prompt, truncated per
19838
+ * sentence for the same reason.
19839
+ */
19840
+ const MAX_NAMED_OFFENDING_SENTENCES = 5;
19841
+ const MAX_OFFENDING_SENTENCE_CHARS = 240;
19829
19842
  function listCitations(values) {
19830
19843
  return values.length <= MAX_LISTED_CITATIONS ? values.join(", ") : `${values.slice(0, MAX_LISTED_CITATIONS).join(", ")} and ${String(values.length - MAX_LISTED_CITATIONS)} more`;
19831
19844
  }
@@ -20043,15 +20056,27 @@ function evidenceGradeValidator(options) {
20043
20056
  name: options?.name ?? "evidence-grade",
20044
20057
  validate: (input) => {
20045
20058
  const unsupported = [];
20059
+ const offenders = [];
20046
20060
  for (const sentence of sentencesOf(input.text)) {
20047
20061
  const haystack = sentence.toLowerCase();
20048
20062
  const found = lowered.filter((phrase) => haystack.includes(phrase));
20049
20063
  if (found.length === 0 || new RegExp(artifactPattern, "").test(sentence)) continue;
20064
+ offenders.push(sentence);
20050
20065
  for (const phrase of found) if (!unsupported.includes(phrase)) unsupported.push(phrase);
20051
20066
  }
20052
- return unsupported.length === 0 ? ok : {
20067
+ if (unsupported.length === 0) return ok;
20068
+ const named = offenders.slice(0, MAX_NAMED_OFFENDING_SENTENCES).map((sentence) => {
20069
+ const flat = sentence.replace(/\s+/gu, " ").trim();
20070
+ return `offending sentence: "${flat.length <= MAX_OFFENDING_SENTENCE_CHARS ? flat : `${flat.slice(0, MAX_OFFENDING_SENTENCE_CHARS)}...`}"`;
20071
+ });
20072
+ const overflow = offenders.length - named.length;
20073
+ return {
20053
20074
  ok: false,
20054
- 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`]
20075
+ reasons: [
20076
+ `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
+ ...named,
20078
+ ...overflow > 0 ? [`and ${String(overflow)} more offending sentences`] : []
20079
+ ]
20055
20080
  };
20056
20081
  }
20057
20082
  };
@@ -24924,6 +24949,26 @@ function preflightEstimate(input) {
24924
24949
  });
24925
24950
  }
24926
24951
  }
24952
+ {
24953
+ const pricing = pricingOf(servedBy);
24954
+ const declared = input.orchestrator?.budget?.synthesisReserveUsd;
24955
+ if (pricing !== void 0 && outputBound !== void 0 && declared !== void 0 && declared > 0) {
24956
+ const compositionUsd = priceUsdOf(pricing, {
24957
+ inputTokens: synthesis.estInputTokens ?? 0,
24958
+ outputTokens: outputBound,
24959
+ cacheReadTokens: 0,
24960
+ cacheWriteTokens: 0
24961
+ });
24962
+ const repairTurns = finishRepairReserve > 0 ? 1 : 0;
24963
+ const requiredUsd = compositionUsd * (1 + repairTurns);
24964
+ if (declared < requiredUsd) say({
24965
+ severity: "warning",
24966
+ code: "synthesis-reserve-below-cap-composition",
24967
+ message: `a synthesis turn writing to its ${String(outputBound)} token output allowance over the declared ${String(synthesis.estInputTokens ?? 0)} input floor prices about ${compositionUsd.toFixed(4)} USD at the rates of '${servedBy}'` + (repairTurns > 0 ? `, and the declared repair reserve prices one more such turn (about ${requiredUsd.toFixed(4)} USD total)` : "") + `; the committed synthesis reserve holds only ${declared.toFixed(4)} USD, so a composition cut at the allowance can fail its validators with no money left for the granted repair; hold the reserve at the cap arithmetic or lower maxOutputTokensPerTurn`,
24968
+ spawn: "synthesis"
24969
+ });
24970
+ }
24971
+ }
24927
24972
  const projected = projectedProviderTurnsOf(merged, overallExecutedCeiling(merged, toolCeilingsOf(merged))) + finishRepairReserve;
24928
24973
  if (orchestratorEcho !== void 0) orchestratorEcho.synthesis = {
24929
24974
  projectedProviderTurns: projected,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.214.0",
3
+ "version": "1.216.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",