maxpool 1.18.0 → 1.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Multi-account Claude Code proxy with adaptive, rate-aware load balancing across Claude accounts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -170,16 +170,18 @@ const DEFAULT_SCHEDULER = {
170
170
  // account sat at ~17% of fleet traffic (measured 2026-08-25) while four Claude
171
171
  // accounts ran at weekly 1.0.
172
172
  //
173
- // The discount is a MULTIPLIER on those two terms only — never a flat bonus. A flat
174
- // bonus would drive an idle account's total NEGATIVE (idle floor is concurrency×2 = 2),
175
- // below the entire band structure that reserveFloorCost:5 / criticalPressureCost:21
176
- // assume is non-negative. A multiplier in [0,1] cannot: it only ever REMOVES cost that
177
- // is already there, so the total stays ≥ the concurrency floor and every safety term
178
- // (concurrency, capPenalty, reserve, critical, ramp, failures) is untouched.
179
- //
180
- // It also DECAYS: at session util 0 the discount is full, and it is gone by
181
- // fastRefillFadeUtil — so as the fast window fills, the account converges back to
182
- // normal pricing and the fleet re-balances smoothly instead of flapping at a cliff.
173
+ // The discount is a MULTIPLIER on the BALANCING terms — never a flat bonus. A flat
174
+ // bonus would drive an idle account's total NEGATIVE, below the entire band structure
175
+ // that reserveFloorCost:5 / criticalPressureCost:21 assume is non-negative. A
176
+ // multiplier in [0,1] cannot: it only ever REMOVES cost that is already there.
177
+ // Term set as of 2026-08-29 (v1.19.0): utilization + pace (original, 2026-08-25),
178
+ // spread (v1.18.0), and the in-flight terms — linear concurrency + capPenalty
179
+ // (v1.19.0). The in-flight extension exists because live requests run 18-27s at
180
+ // weight 10-50, making in-flight the marginal price of traffic: measured
181
+ // 2026-08-28, spread-only left the unlimited account at parity (0.24x share),
182
+ // defeating the owner's approved outcome. Reserve/critical/ramp/failure costs stay
183
+ // undiscounted, as do the hard gates (safetyMaxActivePerAccount, usage cap,
184
+ // cooldowns) — those are the anti-dogpile backstops, not price signals.
183
185
  fastRefillDiscount: 0.6, // 0 = off (full cost), 0.6 = discount up to 60% of the two balancing terms
184
186
  fastRefillFadeUtil: 0.65, // discount reaches 0 at this session utilization (weeklySoftThreshold)
185
187
  recoveryRampWeight: 4, // decaying penalty applied to a just-recovered account
@@ -2542,11 +2544,20 @@ export class AccountManager {
2542
2544
  const now = ctx?.now ?? Date.now();
2543
2545
  const reqWeight = Math.max(1, requestInfo.weight || 1);
2544
2546
  const inflight = account.activeWeight + reqWeight;
2547
+ const refillMult = this._fastRefillMultiplier(account);
2545
2548
 
2546
2549
  // DOMINANT term: in-flight concurrency. Short-term throttling is driven by
2547
2550
  // how many requests pile on one account, so least-loaded-first spread is
2548
2551
  // the primary objective.
2549
- const concurrency = inflight * this.scheduler.concurrencyWeight;
2552
+ // FAST-REFILL (2026-08-29 extension): in the LIVE regime this term (plus the
2553
+ // capPenalty below) is what actually sets the equilibrium share — requests
2554
+ // run 18-27s at weight 10-50, so in-flight dwarfs every balancing term.
2555
+ // Measured 2026-08-28 post-v1.18.0: a spread-only discount left the
2556
+ // unlimited account at parity (12 of 56 GLM switches, share 0.24x). The
2557
+ // linear term is BALANCING (it shares load), so it carries the discount;
2558
+ // the steep past-D floor, the hard request gate, cooldowns and failure
2559
+ // backoff are the anti-dogpile machinery and are handled below.
2560
+ const concurrency = inflight * this.scheduler.concurrencyWeight * refillMult;
2550
2561
 
2551
2562
  // Steep soft cap past depth D — the throttle safety floor. No single
2552
2563
  // account absorbs a deep concurrent burst no matter how "cheap" it looks. A
@@ -2560,15 +2571,21 @@ export class AccountManager {
2560
2571
  const concTarget = (weeklyState === 'reserve' || (weeklyState === 'critical' && criticalUnlock))
2561
2572
  ? this.scheduler.reserveConcurrencyTarget
2562
2573
  : this.scheduler.perAccountConcurrencyTarget;
2574
+ // FAST-REFILL (2026-08-29): carries the discount for the same reason as the
2575
+ // linear term — at live weights every account sits past D, so the marginal
2576
+ // in-flight price IS capPenalty; discounting one without the other changes
2577
+ // nothing. The floor stays STEEP in absolute terms (≥ capPenaltyWeight*mult
2578
+ // per unit, still >2x the largest balancing term at the max discount) and
2579
+ // the hard per-account request gate (safetyMaxActivePerAccount), cooldowns
2580
+ // and failurePenalty remain undiscounted backstops.
2563
2581
  const capPenalty = this.scheduler.capPenaltyWeight
2564
- * Math.max(0, inflight - concTarget);
2582
+ * Math.max(0, inflight - concTarget) * refillMult;
2565
2583
 
2566
2584
  // Burn-pace COST only (demoted from the old dominant scarcity×6 term): a
2567
2585
  // soft de-preference of accounts burning ahead of an even pace. Never a bench.
2568
- // FAST-REFILL DISCOUNT: applied to the pace and utilization terms (and only
2569
- // those) for an account whose only cap is a fast-refilling session window —
2570
- // see the DEFAULT_SCHEDULER block for the full rationale.
2571
- const refillMult = this._fastRefillMultiplier(account);
2586
+ // FAST-REFILL DISCOUNT: applied to the pace and utilization terms for an
2587
+ // account whose only cap is a fast-refilling session window — see the
2588
+ // DEFAULT_SCHEDULER block for the full rationale (refillMult computed above).
2572
2589
  const paceCost = this._accountScarcity(account, now) * this.scheduler.paceCostWeight * refillMult;
2573
2590
 
2574
2591
  // RAW utilization cost — direct, not pace-adjusted. The pace cost above discounts
@@ -2601,9 +2618,8 @@ export class AccountManager {
2601
2618
  // unused every 5h. Discounted, the equilibrium share of a weeklyAbsent account is
2602
2619
  // ~mult/(1-disc*(1-share)) of a sibling's — at the default 0.6 discount roughly
2603
2620
  // 2.3x early in its window, fading to parity at the same ses 0.65 the multiplier
2604
- // already uses. Same safety invariants as the other discounted terms: a
2605
- // multiplier of 1 makes it byte-identical to pre-2026-08-25 behaviour, and it is
2606
- // never applied to concurrency/capPenalty/reserve/critical.
2621
+ // already uses. A multiplier of 1 makes every discounted term byte-identical to
2622
+ // pre-2026-08-25 behaviour; reserve/critical/ramp/failure are never discounted.
2607
2623
  const spread = share * this.scheduler.spreadShareWeight * refillMult;
2608
2624
 
2609
2625
  const ramp = this._recoveryRamp(account, now);