maxpool 1.8.3 → 1.8.5
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 +7 -1
- package/src/capacity-ledger.js +23 -1
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -3066,7 +3066,13 @@ export class AccountManager {
|
|
|
3066
3066
|
// window (>=5h) — the 60s epsilon separates it by three orders of magnitude.
|
|
3067
3067
|
// Provider stamps (z.ai/Kimi probe) are absolute and never jitter.
|
|
3068
3068
|
const nowMs = Date.now();
|
|
3069
|
-
|
|
3069
|
+
// A close can never be dated in the FUTURE. An advance stamp legitimately points
|
|
3070
|
+
// at the NEW window's reset (a fresh 5h away) — that is evidence the OLD window
|
|
3071
|
+
// rolled, not the moment it rolled. Close at NOW (live 2026-08-23: a 3,658-token
|
|
3072
|
+
// cycle was recorded as endedAt 4.9h in the future; the invariant checker caught
|
|
3073
|
+
// it minutes later). `min` also floors the late-probe case (a stamp already
|
|
3074
|
+
// expired) — endedAt is always within [start, now].
|
|
3075
|
+
const boundary = Math.min(nextResetAt, nowMs);
|
|
3070
3076
|
if (boundary - prevResetAt < WINDOW_ADVANCE_EPSILON_MS) return;
|
|
3071
3077
|
this.capacity.closeCycle(accountName, window, boundary, { resetAt: prevResetAt });
|
|
3072
3078
|
}
|
package/src/capacity-ledger.js
CHANGED
|
@@ -15,11 +15,18 @@
|
|
|
15
15
|
* Pre-mortem (2026-08-22) blockers B1/B2 + majors M3-M7 are the load-bearing comments.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
// v3 (2026-08-23): every v2 row was written before the joined-mid-window fix, so each
|
|
19
|
+
// account's first cycle is a TAIL-only observation recorded as `complete` (measured on
|
|
20
|
+
// the live ledger: 14.6, 64.3, 64.4 and 74.4 minutes for 5h windows — all four rows it
|
|
21
|
+
// held). Rather than drop history a second time, v3 MIGRATES: closed v2 rows are kept
|
|
22
|
+
// and shown, marked partial with a reason, so they never reach an average and never
|
|
23
|
+
// re-alert. Forward rows are correct by construction.
|
|
24
|
+
//
|
|
18
25
|
// v2 (2026-08-23): v1 histories are POISONED and are deliberately dropped on load.
|
|
19
26
|
// The OAuth reset-stamp jitter (see AccountManager.noteCapacityWindowAdvance) shredded
|
|
20
27
|
// real windows into slivers and recorded future-dated weekly cycles, so a v1 payload's
|
|
21
28
|
// averages are wrong for weeks. Starting empty costs one window; keeping it costs trust.
|
|
22
|
-
const SCHEMA_VERSION =
|
|
29
|
+
const SCHEMA_VERSION = 3;
|
|
23
30
|
|
|
24
31
|
// Two closes this far apart are the SAME boundary observed twice (a clock-close and a
|
|
25
32
|
// stamp-advance racing across the boundary second), not two windows.
|
|
@@ -41,6 +48,21 @@ export class CapacityLedger {
|
|
|
41
48
|
* start empty and KEEP the file (the caller preserves it); a corrupt shape → empty. */
|
|
42
49
|
static fromSerialized(payload, { now = () => Date.now() } = {}) {
|
|
43
50
|
const l = new CapacityLedger({ now });
|
|
51
|
+
// v2 → v3: keep the rows, demote them. They were all written before the
|
|
52
|
+
// joined-mid-window fix, so each is a partial observation mislabelled complete.
|
|
53
|
+
if (payload?.schemaVersion === 2) {
|
|
54
|
+
const migrated = { schemaVersion: SCHEMA_VERSION, accounts: {} };
|
|
55
|
+
for (const [name, rec] of Object.entries(payload.accounts || {})) {
|
|
56
|
+
migrated.accounts[name] = {
|
|
57
|
+
ses: { open: rec.ses?.open || null,
|
|
58
|
+
closed: (rec.ses?.closed || []).map(c => ({ ...c, complete: false, partialReason: 'pre-v3-unverified' })) },
|
|
59
|
+
wk: { open: rec.wk?.open || null,
|
|
60
|
+
closed: (rec.wk?.closed || []).map(c => ({ ...c, complete: false, partialReason: 'pre-v3-unverified' })) },
|
|
61
|
+
days: rec.days || {},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return CapacityLedger.fromSerialized(migrated, { now });
|
|
65
|
+
}
|
|
44
66
|
if (!payload || payload.schemaVersion !== SCHEMA_VERSION) {
|
|
45
67
|
// No history to continue: whatever window each account is in RIGHT NOW is
|
|
46
68
|
// already in progress, so the next cycle we close saw only its tail. Flag it so
|