maxpool 1.22.4 → 1.23.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 +1 -1
- package/src/account-manager.js +43 -6
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -156,6 +156,16 @@ const DEFAULT_SCHEDULER = {
|
|
|
156
156
|
// half of every window, then opens it up over the second half — so the reserve is
|
|
157
157
|
// protected while there is still time to use it, and spent when there is not.
|
|
158
158
|
capRampStart: 0.5,
|
|
159
|
+
// SOAK MODE (owner-directed 2026-09-26): an account with NO weekly limit (z.ai
|
|
160
|
+
// no-weekly plans, quota.weeklyAbsent) should soak up as much traffic as its session
|
|
161
|
+
// window allows — its capacity expires unused every ~5h, while weekly-limited
|
|
162
|
+
// siblings pay a whole week for the same requests. Escalates fast-refill from
|
|
163
|
+
// "a preference that fades" to "the default route, bounded by the session window
|
|
164
|
+
// and the hard anti-dogpile gates". soakDiscount 0.9 ≈ 10x early-window preference;
|
|
165
|
+
// soakFadeUtil 0.9 keeps the preference until the session window is nearly full
|
|
166
|
+
// (parity only in the last stretch, where capacity really is running out).
|
|
167
|
+
soakDiscount: 0.9,
|
|
168
|
+
soakFadeUtil: 0.9,
|
|
159
169
|
// Routing-cost tuning (lower cost = preferred). The goal is to AVOID
|
|
160
170
|
// short-term (rate/concurrency) throttling by spreading load across healthy
|
|
161
171
|
// accounts. So in-flight concurrency is the DOMINANT term, with a steep
|
|
@@ -2798,8 +2808,18 @@ export class AccountManager {
|
|
|
2798
2808
|
// per unit, still >2x the largest balancing term at the max discount) and
|
|
2799
2809
|
// the hard per-account request gate (safetyMaxActivePerAccount), cooldowns
|
|
2800
2810
|
// and failurePenalty remain undiscounted backstops.
|
|
2811
|
+
// SAFETY TERM — carries fastRefill's discount but NOT soak's (2026-09-26). The
|
|
2812
|
+
// past-D floor is what forces load to fan out before an account is dogpiled toward
|
|
2813
|
+
// a 429. Under soakDiscount 0.9 a discounted floor is 10x weaker, and the
|
|
2814
|
+
// production-shaped simulation (RTT 20s, weight 50) showed the consequence: the
|
|
2815
|
+
// unlimited account wins EVERY pick until the weekly-limited sibling is fully
|
|
2816
|
+
// starved — the account then rides at extreme in-flight depth and eats 429s, the
|
|
2817
|
+
// exact outcome the floor exists to prevent. A soak preference should change WHERE
|
|
2818
|
+
// traffic goes at equal depth, not how deep one account is allowed to stack.
|
|
2819
|
+
const safetyMult = this.scheduler.soakDiscount < 1
|
|
2820
|
+
? this._fastRefillMultiplier(account, { capFloor: true }) : refillMult;
|
|
2801
2821
|
const capPenalty = this.scheduler.capPenaltyWeight
|
|
2802
|
-
* Math.max(0, inflight - concTarget) *
|
|
2822
|
+
* Math.max(0, inflight - concTarget) * safetyMult;
|
|
2803
2823
|
|
|
2804
2824
|
// Burn-pace COST only (demoted from the old dominant scarcity×6 term): a
|
|
2805
2825
|
// soft de-preference of accounts burning ahead of an even pace. Never a bench.
|
|
@@ -3092,11 +3112,22 @@ export class AccountManager {
|
|
|
3092
3112
|
* non-negative band structure reserveFloorCost/criticalPressureCost were calibrated
|
|
3093
3113
|
* against), and never on safety terms (concurrency, capPenalty, reserve, critical).
|
|
3094
3114
|
*/
|
|
3095
|
-
_fastRefillMultiplier(account) {
|
|
3096
|
-
|
|
3115
|
+
_fastRefillMultiplier(account, { capFloor = false } = {}) {
|
|
3116
|
+
// SOAK MODE (2026-09-26): the multiplier call-site is shared, so the escalation is
|
|
3117
|
+
// a knob swap here — the caller's invariants (balancing terms only, hard gates
|
|
3118
|
+
// untouched, fades to 1) all hold unchanged. `capFloor: true` clamps the discount
|
|
3119
|
+
// at fastRefill's historical 0.6 — used ONLY by the past-D safety floor so a soak
|
|
3120
|
+
// preference cannot weaken anti-dogpile protection (see the capPenalty site).
|
|
3121
|
+
const soak = account?.type === 'provider' && account.quota?.weeklyAbsent;
|
|
3122
|
+
let disc = soak ? this.scheduler.soakDiscount : this.scheduler.fastRefillDiscount;
|
|
3123
|
+
if (capFloor) disc = Math.min(disc, this.scheduler.fastRefillDiscount);
|
|
3097
3124
|
if (!(disc > 0)) return 1; // feature off → multiplier 1
|
|
3098
|
-
if (!(
|
|
3099
|
-
|
|
3125
|
+
if (!soak) return 1; // (non-weeklyAbsent never reaches here with soak)
|
|
3126
|
+
// The FADE is clamped under capFloor as well: clamping only the discount left
|
|
3127
|
+
// soak's wider fade (0.90) applying a residual ~0.98 multiplier at ses 0.87 —
|
|
3128
|
+
// inside the reserve band, which the floor is supposed to protect absolutely.
|
|
3129
|
+
let fade = soak ? this.scheduler.soakFadeUtil : this.scheduler.fastRefillFadeUtil;
|
|
3130
|
+
if (capFloor) fade = Math.min(fade, this.scheduler.fastRefillFadeUtil);
|
|
3100
3131
|
const ses = clamp01(account.quota.providerSes ?? 0);
|
|
3101
3132
|
if (ses >= fade) return 1;
|
|
3102
3133
|
// 1 at ses=0 → 1-disc at ses=0; linear to 1 at ses=fade
|
|
@@ -4470,7 +4501,13 @@ export class AccountManager {
|
|
|
4470
4501
|
// actually being applied — a flag that can never show "inert" is not a
|
|
4471
4502
|
// monitorable feature. Mirrors the peak block's shape.
|
|
4472
4503
|
fastRefill: {
|
|
4473
|
-
|
|
4504
|
+
// Reports BOTH regimes: `discount`/`fadeUtil` are fast-refill's, and `soak`
|
|
4505
|
+
// names what a weeklyAbsent account actually runs on — the per-account
|
|
4506
|
+
// `multiplier` rows below are computed from the soak knobs for those
|
|
4507
|
+
// accounts, so advertising only the fast-refill numbers made the block
|
|
4508
|
+
// describe settings that were not in force (caught 2026-09-26).
|
|
4509
|
+
enabled: this.scheduler.fastRefillDiscount > 0 || this.scheduler.soakDiscount > 0,
|
|
4510
|
+
soak: { discount: this.scheduler.soakDiscount, fadeUtil: this.scheduler.soakFadeUtil },
|
|
4474
4511
|
discount: this.scheduler.fastRefillDiscount,
|
|
4475
4512
|
fadeUtil: this.scheduler.fastRefillFadeUtil,
|
|
4476
4513
|
accounts: this.accounts
|