maxpool 1.8.6 → 1.8.7

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.6",
3
+ "version": "1.8.7",
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",
@@ -40,9 +40,9 @@ const MAX_DAY_BUCKETS = 10;
40
40
  // CLAMPS a future endedAt to startedAt so the stored row itself stops violating
41
41
  // invariants after migration, not just the averages.
42
42
  function demote(c) {
43
- const fixed = { ...c, complete: false, partialReason: 'pre-v3-unverified' };
44
- if (fixed.endedAt > Date.now() + 60_000) fixed.endedAt = fixed.startedAt;
45
- return fixed;
43
+ // Timestamp repair is NOT done here — the load-time pass below handles a future
44
+ // endedAt at every schema version, so doing it twice would be two places to fix.
45
+ return { ...c, complete: false, partialReason: 'pre-v3-unverified' };
46
46
  }
47
47
 
48
48
  export class CapacityLedger {
@@ -88,7 +88,19 @@ export class CapacityLedger {
88
88
  const a = { ses: { open: null, closed: [] }, wk: { open: null, closed: [] }, days: {} };
89
89
  for (const w of ['ses', 'wk']) {
90
90
  if (rec[w]?.open) a[w].open = { ...rec[w].open };
91
- if (Array.isArray(rec[w]?.closed)) a[w].closed = rec[w].closed.slice(-MAX_CYCLES_PER_WINDOW);
91
+ if (Array.isArray(rec[w]?.closed)) {
92
+ // LOAD-TIME REPAIR, applied at EVERY version — not inside the v2→v3 branch,
93
+ // which is where it was first (wrongly) placed: a future-dated row can be
94
+ // written by any build whose writer had the bug, and the payload it lands in
95
+ // is then already current, so a version-gated repair never runs. Measured
96
+ // 2026-08-23: a row ending 19:54 survived the v3 migration untouched because
97
+ // the state was already v3. A cycle cannot end after now; such a row is
98
+ // corrupt, so demote it and clamp it rather than let it re-alert until evicted.
99
+ a[w].closed = rec[w].closed.slice(-MAX_CYCLES_PER_WINDOW).map(c =>
100
+ (c.endedAt > Date.now() + 60_000)
101
+ ? { ...c, endedAt: c.startedAt, complete: false, partialReason: 'repaired-future-endedAt' }
102
+ : c);
103
+ }
92
104
  }
93
105
  if (rec.days && typeof rec.days === 'object') {
94
106
  for (const [d, v] of Object.entries(rec.days)) a.days[d] = { ...v };