maxpool 1.8.1 → 1.8.2

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.8.1",
3
+ "version": "1.8.2",
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",
@@ -3055,19 +3055,20 @@ export class AccountManager {
3055
3055
  * covers the case where the old stamp was never learned. */
3056
3056
  noteCapacityWindowAdvance(accountName, window, prevResetAt, nextResetAt) {
3057
3057
  if (!prevResetAt || !nextResetAt) return;
3058
- // EPSILON, not `>`. An OAuth reset stamp is derived per-response as
3059
- // `Date.now() + delay_seconds * 1000` (parseResetHeader), so the SAME window
3060
- // boundary reads a little later on every response — sub-second to ~2s of jitter.
3061
- // A bare `nextResetAt > prevResetAt` fired the advance-close on each of those,
3062
- // shredding one real 5h window into 9-10 fake cycles and closing a "weekly"
3063
- // cycle whose endedAt was a week in the FUTURE. Measured on live state.json
3064
- // 2026-08-23, 12h after v1.8.0 shipped: mk@dubner.io had 9 ses cycles between
3065
- // 01:00 and 06:00, the shortest 0.2 minutes. A REAL advance is a whole window
3066
- // (>=5h); 60s separates the two by three orders of magnitude.
3067
- // Provider stamps (z.ai/Kimi probe) are absolute and did NOT jitter — which is
3068
- // how the defect localized to the OAuth path.
3069
- if (nextResetAt - prevResetAt < WINDOW_ADVANCE_EPSILON_MS) return;
3070
- this.capacity.closeCycle(accountName, window, prevResetAt, { resetAt: prevResetAt });
3058
+ // TWO guards, both learned from live data (2026-08-23):
3059
+ // 1. PAST stamp = a probe that answered late (its window rolled mid-request) or
3060
+ // vendor clock skew — honoring it closed a minutes-long "cycle" sliver. Close
3061
+ // at NOW instead: the window genuinely rolled, just later than the stale stamp.
3062
+ // 2. JITTER: OAuth stamps derive per-response as Date.now()+delay*1000
3063
+ // (parseResetHeader), so one boundary reads ~2s later on every response; a
3064
+ // bare `>` comparison shredded one real 5h window into 9-10 fake cycles and
3065
+ // dated a "weekly" cycle a week into the future. A real advance moves a whole
3066
+ // window (>=5h) — the 60s epsilon separates it by three orders of magnitude.
3067
+ // Provider stamps (z.ai/Kimi probe) are absolute and never jitter.
3068
+ const nowMs = Date.now();
3069
+ const boundary = nextResetAt <= nowMs ? nowMs : nextResetAt;
3070
+ if (boundary - prevResetAt < WINDOW_ADVANCE_EPSILON_MS) return;
3071
+ this.capacity.closeCycle(accountName, window, boundary, { resetAt: prevResetAt });
3071
3072
  }
3072
3073
 
3073
3074
  /**