@rulvar/core 1.115.0 → 1.117.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
@@ -2973,7 +2973,10 @@ declare class Replayer {
2973
2973
  appendSuspended(input: SuspendedAppend): Promise<JournalEntry>;
2974
2974
  /**
2975
2975
  * The budget ledger fold: usage sums over terminal entries once, never twice; agentsSpawned
2976
- * counts agent dispatches.
2976
+ * counts agent dispatches. Dollars fold on the settled billing basis
2977
+ * (RV801): per provider call where the entry's records cover its
2978
+ * usage, the per-slice aggregate otherwise, the same basis as the
2979
+ * CostReport and the invoice.
2977
2980
  */
2978
2981
  ledger(): Ledger;
2979
2982
  /** Read-only view of the appended entries, in per-run total order. */
@@ -5459,7 +5462,8 @@ declare class RunBudget {
5459
5462
  priceUsd?: (servedBy: ModelRef, usage: Usage) => number | undefined; /** Raw price-row resolution for the layer-2b output bound. */
5460
5463
  pricingOf?: (servedBy: ModelRef) => Pricing | undefined;
5461
5464
  /**
5462
- * The resume ledger fold: spend is never
5465
+ * The resume seed, folded from the persisted journal (the settled
5466
+ * per-call fold, RV801): spend is never
5463
5467
  * reset and never double-counted; replayed entries are already inside
5464
5468
  * this seed and add no increments.
5465
5469
  */
package/dist/index.js CHANGED
@@ -7258,7 +7258,10 @@ var Replayer = class {
7258
7258
  }
7259
7259
  /**
7260
7260
  * The budget ledger fold: usage sums over terminal entries once, never twice; agentsSpawned
7261
- * counts agent dispatches.
7261
+ * counts agent dispatches. Dollars fold on the settled billing basis
7262
+ * (RV801): per provider call where the entry's records cover its
7263
+ * usage, the per-slice aggregate otherwise, the same basis as the
7264
+ * CostReport and the invoice.
7262
7265
  */
7263
7266
  ledger() {
7264
7267
  const usage = {
@@ -7280,7 +7283,7 @@ var Replayer = class {
7280
7283
  usage.cacheReadTokens += entry.usage.cacheReadTokens;
7281
7284
  usage.cacheWriteTokens += entry.usage.cacheWriteTokens;
7282
7285
  reasoning += entry.usage.reasoningTokens ?? 0;
7283
- if (this.priceUsd !== void 0) usd += priceEntryUsage(entry, this.priceUsd).usd;
7286
+ if (this.priceUsd !== void 0) usd += priceEntryBilling(entry, this.priceUsd).usd;
7284
7287
  }
7285
7288
  if (reasoning > 0) usage.reasoningTokens = reasoning;
7286
7289
  return {
@@ -13053,9 +13056,11 @@ async function runAgent(options) {
13053
13056
  * account and plan/NodeId accounts). A child's spend propagates to ALL
13054
13057
  * ancestors up to the run root; the root ceiling remains the true
13055
13058
  * invariant. Sub-account spend is per-process state: on resume the root
13056
- * is seeded from the ledger fold while sub-accounts restart empty (their
13057
- * reserves are recovered from spawn-admission decision entries); the
13058
- * per-account historical fold completes with DEF-7 in M7.
13059
+ * is seeded from the settled journal fold (the per-call billing basis
13060
+ * and per-segment pricing pins of outcome.cost.totalUsd, RV801) while
13061
+ * sub-accounts restart empty (their reserves are recovered from
13062
+ * spawn-admission decision entries); the per-account historical fold
13063
+ * completes with DEF-7 in M7.
13059
13064
  *
13060
13065
  * Full contract: https://docs.rulvar.com/guide/budgets
13061
13066
  */
@@ -21343,8 +21348,10 @@ function createEngine(options) {
21343
21348
  replayer.setAliasDisposition(dispositionHook({ isAbandoned: () => false }, registry, replayer.invalidatedSeqs, { runSettledOk }));
21344
21349
  if (resumeCtx !== void 0) {
21345
21350
  const prior = replayer.ledger();
21351
+ const priorPinned = journalPricingSnapshot(replayer.snapshot());
21352
+ const priorPriceUsd = priorPinned === void 0 ? (servedBy, usage) => priceUsd(servedBy, usage) : priorPinned.composedPriceUsd((servedBy, usage) => priceUsd(servedBy, usage));
21346
21353
  budgetSeed = {
21347
- usd: prior.usd,
21354
+ usd: costReportFromJournal(replayer.snapshot(), priorPriceUsd).totalUsd,
21348
21355
  usage: prior.usage,
21349
21356
  agentsSpawned: prior.agentsSpawned
21350
21357
  };
@@ -21675,7 +21682,7 @@ function createEngine(options) {
21675
21682
  bus.emit({
21676
21683
  type: "run:end",
21677
21684
  status,
21678
- totalUsd: ledger.usd,
21685
+ totalUsd: outcome.cost.totalUsd,
21679
21686
  ...outcome.cost.usageApprox === true ? { usageApprox: true } : {},
21680
21687
  ...lifted === void 0 ? {} : lifted
21681
21688
  }, rootSpanId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.115.0",
3
+ "version": "1.117.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",