@rulvar/core 1.205.0 → 1.206.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
@@ -6758,6 +6758,23 @@ interface BudgetReserve {
6758
6758
  reserveUsd: number;
6759
6759
  /** The child sub-account ceiling; absent when the parent is uncapped. */
6760
6760
  childCeilingUsd?: number;
6761
+ /**
6762
+ * The reserve derivation (RV2004): where reserveUsd came from, so a
6763
+ * journal reader never reverse-engineers the arithmetic. 'estCost'
6764
+ * is the declared estimate (spawn opts or the agentType profile),
6765
+ * 'default' the engine flat reserve.
6766
+ */
6767
+ source?: "estCost" | "default";
6768
+ /**
6769
+ * Set when the derived reserve was clamped DOWN to the child's
6770
+ * ceiling: 'explicit-budget' by a declared budgetUsd,
6771
+ * 'fraction-ceiling' by the childBudgetFraction allowance an ORIGIN
6772
+ * WITH a materialized allowance account enforces (ctx.workflow).
6773
+ * The spawn-tool path never carries 'fraction-ceiling': its
6774
+ * dispatch enforces no fraction account, and journaling that clamp
6775
+ * is exactly the parity rerun's 0.50-versus-0.70 lie (RV2004).
6776
+ */
6777
+ clampedBy?: "explicit-budget" | "fraction-ceiling";
6761
6778
  }
6762
6779
  /** The lineage block every non-reject verdict carries (DEF-3). */
6763
6780
  interface AdmitLineage {
@@ -13096,6 +13113,18 @@ interface PreflightReport {
13096
13113
  * fourth workers. Present whenever the wave has rows.
13097
13114
  */
13098
13115
  requiredMinimumCeilingUsd?: number;
13116
+ /**
13117
+ * The live-root-exposure term of the wave projection (RV2004): the
13118
+ * orchestrator's own worst-case turn floor, the money coordination
13119
+ * has ALWAYS already spent (and holds in flight) by the time any
13120
+ * spawn tool runs. The parity rerun's fourth seat fit the plain
13121
+ * wave (5.95 under 6.00) and was refused live by exactly this
13122
+ * term; the embedded spawn gate and requiredMinimumCeilingUsd now
13123
+ * carry it, so a seat that cannot admit live cannot admit in
13124
+ * preflight either. Present on orchestrate waves whose
13125
+ * coordination turn prices.
13126
+ */
13127
+ liveRootExposureTermUsd?: number;
13099
13128
  wave: PreflightAdmissionRow[];
13100
13129
  admitted: number;
13101
13130
  denied: number;
package/dist/index.js CHANGED
@@ -16047,15 +16047,27 @@ var AdmissionController = class {
16047
16047
  },
16048
16048
  statsBefore
16049
16049
  };
16050
+ const spawnToolOrigin = spec.origin === "spawn_agent" || spec.origin === "parallel_agents";
16050
16051
  let childCeilingUsd;
16051
16052
  const parentRemainder = this.budget.remainderOf(spec.parentAccountScope);
16052
- if (parentRemainder !== void 0) {
16053
+ if (spawnToolOrigin) {
16054
+ if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
16055
+ } else if (parentRemainder !== void 0) {
16053
16056
  const fractionCap = this.childBudgetFraction * parentRemainder;
16054
16057
  childCeilingUsd = spec.budgetUsd === void 0 ? fractionCap : Math.min(spec.budgetUsd, fractionCap);
16055
16058
  } else if (spec.budgetUsd !== void 0) childCeilingUsd = spec.budgetUsd;
16056
16059
  let reserveUsd = spec.estCostUsd ?? this.flatReserveUsd;
16057
- if (childCeilingUsd !== void 0) reserveUsd = Math.min(reserveUsd, childCeilingUsd);
16058
- const reserve = { reserveUsd };
16060
+ const source = spec.estCostUsd === void 0 ? "default" : "estCost";
16061
+ let clampedBy;
16062
+ if (childCeilingUsd !== void 0 && reserveUsd > childCeilingUsd) {
16063
+ clampedBy = spec.budgetUsd !== void 0 && childCeilingUsd === spec.budgetUsd ? "explicit-budget" : "fraction-ceiling";
16064
+ reserveUsd = childCeilingUsd;
16065
+ }
16066
+ const reserve = {
16067
+ reserveUsd,
16068
+ source
16069
+ };
16070
+ if (clampedBy !== void 0) reserve.clampedBy = clampedBy;
16059
16071
  if (childCeilingUsd !== void 0) reserve.childCeilingUsd = childCeilingUsd;
16060
16072
  if (this.budget.spawnHeadroom <= 0) return {
16061
16073
  verdict: {
@@ -24726,6 +24738,7 @@ function preflightEstimate(input) {
24726
24738
  }
24727
24739
  const maxSpawns = input.orchestrator?.maxSpawns;
24728
24740
  const orchestrateWave = input.orchestrator !== void 0;
24741
+ const liveRootExposureTermUsd = orchestrateWave ? units.find((unit) => unit.label === "orchestrator")?.turnFloorUsd ?? 0 : 0;
24729
24742
  for (const [reportIndex, report] of spawnReports.entries()) {
24730
24743
  const gate = waveGateInputs[reportIndex] ?? {};
24731
24744
  for (let i = 0; i < report.count; i += 1) {
@@ -24736,7 +24749,7 @@ function preflightEstimate(input) {
24736
24749
  else if (maxSpawns !== void 0 && children >= maxSpawns) deniedBy = "orchestrator-max-spawns";
24737
24750
  else {
24738
24751
  if (orchestrateWave && ceilingUsd !== void 0) {
24739
- const remainder = ceilingUsd - heldAgainstRoot();
24752
+ const remainder = ceilingUsd - heldAgainstRoot() - liveRootExposureTermUsd;
24740
24753
  const projection = dispatchProjectionReserveUsd(gate, flatReserveUsd);
24741
24754
  if (remainder <= 0 || remainder <= projection) deniedBy = "budget";
24742
24755
  }
@@ -24758,7 +24771,7 @@ function preflightEstimate(input) {
24758
24771
  }
24759
24772
  const admitted = wave.filter((row) => row.admitted).length;
24760
24773
  const denied = wave.length - admitted;
24761
- const requiredMinimumCeilingUsd = wave.length === 0 ? void 0 : wave.reduce((sum, row) => sum + row.reserveUsd, 0) + reservedForFinalizationUsd + synthesisHoldUsd;
24774
+ const requiredMinimumCeilingUsd = wave.length === 0 ? void 0 : wave.reduce((sum, row) => sum + row.reserveUsd, 0) + reservedForFinalizationUsd + synthesisHoldUsd + liveRootExposureTermUsd;
24762
24775
  if (wave.length > 0 && denied > 0) {
24763
24776
  const deniedLabels = wave.filter((row) => !row.admitted).map((row) => row.label);
24764
24777
  if (admitted === 0) say({
@@ -25016,6 +25029,7 @@ function preflightEstimate(input) {
25016
25029
  reservedForFinalizationUsd,
25017
25030
  synthesisReserveUsd: synthesisHoldUsd,
25018
25031
  ...requiredMinimumCeilingUsd === void 0 ? {} : { requiredMinimumCeilingUsd },
25032
+ ...liveRootExposureTermUsd > 0 ? { liveRootExposureTermUsd } : {},
25019
25033
  wave,
25020
25034
  admitted,
25021
25035
  denied
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.205.0",
3
+ "version": "1.206.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",