maxpool 1.24.53 → 1.24.54
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 +35 -0
- package/src/index.js +10 -0
- package/src/pool-link.js +30 -0
- package/src/prober.js +3 -1
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -4762,6 +4762,28 @@ export class AccountManager {
|
|
|
4762
4762
|
this.applyPoolLinks();
|
|
4763
4763
|
}
|
|
4764
4764
|
|
|
4765
|
+
/** Boot-time single-writer guard: seed each link's persisted identity map
|
|
4766
|
+
* (state.json) so a boot during a link outage keeps local copies benched
|
|
4767
|
+
* until the first successful poll (red-team 2026-10-31). */
|
|
4768
|
+
seedPoolLinks(saved, savedAt) {
|
|
4769
|
+
if (!saved || typeof saved !== 'object') return;
|
|
4770
|
+
for (const l of this.poolLinks) {
|
|
4771
|
+
const byName = saved[l.name];
|
|
4772
|
+
if (byName) l.seedPoolIdentities?.(byName, savedAt);
|
|
4773
|
+
}
|
|
4774
|
+
this.applyPoolLinks();
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4777
|
+
/** Per-link identity maps for state.json (keyed by link name). */
|
|
4778
|
+
exportPoolIdentities() {
|
|
4779
|
+
const out = {};
|
|
4780
|
+
for (const l of this.poolLinks) {
|
|
4781
|
+
const ids = l.exportPoolIdentities?.();
|
|
4782
|
+
if (ids) out[l.name] = ids;
|
|
4783
|
+
}
|
|
4784
|
+
return Object.keys(out).length ? out : null;
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4765
4787
|
/** Apply duplicate benching + link health from the links' last polls. Idempotent. */
|
|
4766
4788
|
applyPoolLinks() {
|
|
4767
4789
|
const ids = new Map();
|
|
@@ -4774,6 +4796,19 @@ export class AccountManager {
|
|
|
4774
4796
|
for (const a of this.accounts) {
|
|
4775
4797
|
const wasBenched = Boolean(a.poolBenchedBy);
|
|
4776
4798
|
const d = dups.find(x => x.index === a.index);
|
|
4799
|
+
// Token-divergence alarm (red-team 2026-10-31): the cloud row for this
|
|
4800
|
+
// identity is refreshDead while the local copy holds a healthy credential —
|
|
4801
|
+
// both sides went dark in the boot-outage scenario. Name it loudly instead
|
|
4802
|
+
// of silently benching the only working copy.
|
|
4803
|
+
if (d) {
|
|
4804
|
+
const remoteRow = (this.poolLinks || [])
|
|
4805
|
+
.flatMap(l => (l.status?.accounts || []).filter(r => r.name === d.remoteName))[0];
|
|
4806
|
+
if (remoteRow?.refreshDead && !a.refreshDead && a.refreshToken) {
|
|
4807
|
+
const msg = `[Maxpool] Token divergence: team pool's "${d.remoteName}" is refreshDead but local "${a.name}" holds a live token — run /login on the local row to re-auth the team pool (one keystroke), or the account stays dark on both sides`;
|
|
4808
|
+
console.log(msg);
|
|
4809
|
+
appendEventLog(msg);
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4777
4812
|
a.poolBenchedBy = d ? (d.remoteName || 'team pool') : null;
|
|
4778
4813
|
if (d && !wasBenched) {
|
|
4779
4814
|
console.log(`[Maxpool] Duplicate guard: local account "${a.name}" also lives in team pool (${a.poolBenchedBy}) — benched locally, no routing, no token refresh`);
|
package/src/index.js
CHANGED
|
@@ -648,6 +648,12 @@ async function serverWorkerCommand() {
|
|
|
648
648
|
// final flush and restores fully (the reported zero-request case).
|
|
649
649
|
if (savedState?.runtimeProviders) accountManager.restoreRuntimeProviders(savedState.runtimeProviders);
|
|
650
650
|
if (savedState?.callerStats) accountManager.restoreCallerStats?.(savedState.callerStats);
|
|
651
|
+
// Boot-time single-writer guard: seed each link's identity map from the last
|
|
652
|
+
// persisted run so a boot during a link outage doesn't un-bench local copies
|
|
653
|
+
// (red-team 2026-10-31). Replaced by the first successful poll.
|
|
654
|
+
if (savedState?.poolIdentities) {
|
|
655
|
+
accountManager.seedPoolLinks?.(savedState.poolIdentities, savedState.poolIdentitiesAt);
|
|
656
|
+
}
|
|
651
657
|
|
|
652
658
|
// ── config-sourced providers (GCP Secret Manager) ──────────────────────────
|
|
653
659
|
// Provider keys (GLM, Kimi) defined in the config's `providers` section, each
|
|
@@ -747,6 +753,10 @@ async function serverWorkerCommand() {
|
|
|
747
753
|
// SC22 per-person analytics — same generation-guarded payload, survives
|
|
748
754
|
// restarts and seamless reloads.
|
|
749
755
|
callerStats: accountManager.exportCallerStats?.() || {},
|
|
756
|
+
// Last-good remote identity maps — the boot-time single-writer guard reads
|
|
757
|
+
// these (see restore above). Rides the same generation-guarded payload.
|
|
758
|
+
poolIdentities: accountManager.exportPoolIdentities?.() || null,
|
|
759
|
+
poolIdentitiesAt: Date.now(),
|
|
750
760
|
},
|
|
751
761
|
{ expectedGeneration },
|
|
752
762
|
)
|
package/src/pool-link.js
CHANGED
|
@@ -157,6 +157,17 @@ function sanitizeRemoteStatus(json) {
|
|
|
157
157
|
return json;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Boot-time single-writer guard (red-team 2026-10-31, blocking): a fresh PoolLink
|
|
162
|
+
* starts with EMPTY identities, so a boot during a link outage saw ids={} and the
|
|
163
|
+
* duplicate guard RELEASED every local copy — which then served and rotated tokens
|
|
164
|
+
* the cloud still held (invalid_grant on the cloud row when the link returned; the
|
|
165
|
+
* healthy local copy re-benched → account dark on BOTH sides). The last good
|
|
166
|
+
* identity map is persisted in state.json; seedPoolIdentities() restores it at boot
|
|
167
|
+
* so a link that hasn't polled yet still benches what it benched last run.
|
|
168
|
+
*/
|
|
169
|
+
const BOOT_IDS_TTL_MS = 14 * 24 * 3600 * 1000; // stale beyond this → trust a fresh boot instead
|
|
170
|
+
|
|
160
171
|
export class PoolLink {
|
|
161
172
|
constructor(def, deps = {}) {
|
|
162
173
|
this.name = def.name;
|
|
@@ -176,6 +187,25 @@ export class PoolLink {
|
|
|
176
187
|
this.summary = null;
|
|
177
188
|
}
|
|
178
189
|
|
|
190
|
+
/** Seed identities persisted from a previous run (state.json). Used until the
|
|
191
|
+
* first successful poll replaces them; old seeds (>14d) are ignored. */
|
|
192
|
+
seedPoolIdentities(saved, savedAt) {
|
|
193
|
+
if (!saved || typeof saved !== 'object') return;
|
|
194
|
+
if (savedAt != null && Date.now() - savedAt > BOOT_IDS_TTL_MS) return;
|
|
195
|
+
if (this.identities && this.identities.size > 0) return; // a real poll already ran
|
|
196
|
+
const m = new Map(Object.entries(saved).map(([k, v]) => [k, v]));
|
|
197
|
+
if (m.size > 0) {
|
|
198
|
+
this.identities = m;
|
|
199
|
+
this._bootSeeded = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Identity map for persistence (plain object). */
|
|
204
|
+
exportPoolIdentities() {
|
|
205
|
+
return this.identities && this.identities.size > 0
|
|
206
|
+
? Object.fromEntries(this.identities) : null;
|
|
207
|
+
}
|
|
208
|
+
|
|
179
209
|
async poll() {
|
|
180
210
|
if (this._polling) return; // never stack polls
|
|
181
211
|
this._polling = true;
|
package/src/prober.js
CHANGED
|
@@ -333,7 +333,9 @@ export class Prober {
|
|
|
333
333
|
// Claude banked resets (cedar_ember) piggyback on the oauth poll — same
|
|
334
334
|
// OWNER GATE as z.ai cards: a DISABLED account is never listed or claimed.
|
|
335
335
|
try {
|
|
336
|
-
|
|
336
|
+
// A pool-benched duplicate never claims a grant: the cloud owns this account
|
|
337
|
+
// (mirror of the z.ai card guard above; red-team 2026-10-31).
|
|
338
|
+
if (account.enabled !== false && account.credential && !account.poolBenchedBy && this.am.applyResetGrants) {
|
|
337
339
|
const listing = await this._withTimeout(this.grantsFn(account.credential));
|
|
338
340
|
if (listing) {
|
|
339
341
|
this.am.applyResetGrants(account.index, listing);
|