maxpool 1.8.3 → 1.8.4
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/capacity-ledger.js +23 -1
package/package.json
CHANGED
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
|