instar 1.3.591 → 1.3.592

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.
@@ -45,6 +45,31 @@ export declare function scoreAccount(a: SubscriptionAccount, nowMs: number): num
45
45
  * the account that just hit its limit.
46
46
  */
47
47
  export declare function selectAccount(accounts: SubscriptionAccount[], opts?: SelectionOptions, excludeId?: string): SubscriptionAccount | null;
48
+ /**
49
+ * Pool-headroom summary for the QUOTA THROTTLE (`QuotaTracker` provider). This is
50
+ * DISTINCT from `selectAccount`, which picks WHERE to place a session for
51
+ * use-it-or-lose-it (it favors the soonest-to-reset account, which may be highly
52
+ * used). The throttle asks a different question — "is there capacity for this work
53
+ * ANYWHERE in the pool?" — so it must gate on the MOST-HEADROOM eligible account,
54
+ * not the drain-first winner. (Live proof against the real pool, 2026-06-16: with a
55
+ * fresh 0% reserve alongside an 85% drain-first account, gating on the drain-first
56
+ * account wrongly shed all non-critical work — overriding codex round-2 minor #2's
57
+ * "accepted as marginal" with real evidence that it materially under-delivered.)
58
+ *
59
+ * Crucially it shares the EXACT eligibility predicate `selectAccount` uses
60
+ * (`isEligibleStatus` + binding utilization below the soft threshold), so
61
+ * `placeable` here ⟺ `selectAccount(...) !== null` — the never-loop invariant
62
+ * holds (the throttle never allows when placement can place nothing). Percentages
63
+ * are clamped to [0,100]; `degraded:true` when the best account has no trustworthy
64
+ * live reading, so the throttle applies its bounded degraded cap instead of a
65
+ * phantom "0% fresh".
66
+ */
67
+ export declare function poolHeadroom(accounts: SubscriptionAccount[], opts?: SelectionOptions): {
68
+ placeable: boolean;
69
+ weeklyPercent: number | null;
70
+ fiveHourPercent: number | null;
71
+ degraded: boolean;
72
+ };
48
73
  /** Is this account at/over the soft pressure threshold on its binding window? */
49
74
  export declare function accountAtPressure(a: SubscriptionAccount, softThresholdPct?: number): boolean;
50
75
  /** Injected session-restart-with-resume (wraps SessionRefresh in prod). */
@@ -1 +1 @@
1
- {"version":3,"file":"Qu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,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;CAClE;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;gBACpC,GAAG,EAAE,yBAAyB;IAI1C,qEAAqE;IACrE,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAO1D;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE;QAC1B,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,UAAU,CAAC;CA+BxB"}
@@ -94,6 +94,42 @@ export function selectAccount(accounts, opts = {}, excludeId) {
94
94
  .map((a) => ({ a, s: scoreAccount(a, nowMs) }))
95
95
  .sort((x, y) => y.s - x.s)[0].a;
96
96
  }
97
+ /**
98
+ * Pool-headroom summary for the QUOTA THROTTLE (`QuotaTracker` provider). This is
99
+ * DISTINCT from `selectAccount`, which picks WHERE to place a session for
100
+ * use-it-or-lose-it (it favors the soonest-to-reset account, which may be highly
101
+ * used). The throttle asks a different question — "is there capacity for this work
102
+ * ANYWHERE in the pool?" — so it must gate on the MOST-HEADROOM eligible account,
103
+ * not the drain-first winner. (Live proof against the real pool, 2026-06-16: with a
104
+ * fresh 0% reserve alongside an 85% drain-first account, gating on the drain-first
105
+ * account wrongly shed all non-critical work — overriding codex round-2 minor #2's
106
+ * "accepted as marginal" with real evidence that it materially under-delivered.)
107
+ *
108
+ * Crucially it shares the EXACT eligibility predicate `selectAccount` uses
109
+ * (`isEligibleStatus` + binding utilization below the soft threshold), so
110
+ * `placeable` here ⟺ `selectAccount(...) !== null` — the never-loop invariant
111
+ * holds (the throttle never allows when placement can place nothing). Percentages
112
+ * are clamped to [0,100]; `degraded:true` when the best account has no trustworthy
113
+ * live reading, so the throttle applies its bounded degraded cap instead of a
114
+ * phantom "0% fresh".
115
+ */
116
+ export function poolHeadroom(accounts, opts = {}) {
117
+ const soft = opts.softThresholdPct ?? DEFAULT_SOFT_THRESHOLD;
118
+ const eligible = accounts.filter((a) => isEligibleStatus(a) && bindingUtilization(a.lastQuota) < soft);
119
+ if (eligible.length === 0) {
120
+ return { placeable: false, weeklyPercent: null, fiveHourPercent: null, degraded: false };
121
+ }
122
+ let best = eligible[0];
123
+ for (const a of eligible) {
124
+ if (bindingUtilization(a.lastQuota) < bindingUtilization(best.lastQuota))
125
+ best = a;
126
+ }
127
+ const clamp = (v) => typeof v === 'number' && isFinite(v) ? Math.max(0, Math.min(100, v)) : null;
128
+ const weeklyPercent = clamp(best.lastQuota?.sevenDay?.utilizationPct);
129
+ const fiveHourPercent = clamp(best.lastQuota?.fiveHour?.utilizationPct);
130
+ const degraded = weeklyPercent === null && fiveHourPercent === null;
131
+ return { placeable: true, weeklyPercent, fiveHourPercent, degraded };
132
+ }
97
133
  /** Is this account at/over the soft pressure threshold on its binding window? */
98
134
  export function accountAtPressure(a, softThresholdPct = DEFAULT_SOFT_THRESHOLD) {
99
135
  return bindingUtilization(a.lastQuota) >= softThresholdPct;
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaAwareScheduler.js","sourceRoot":"","sources":["../../src/core/QuotaAwareScheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAgBH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,uDAAuD;AACvD,SAAS,gBAAgB,CAAC,CAAsB;IAC9C,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,IAA6C;IACvE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,C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C,EAAE;SACnB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CACnB,yBAAyB,WAAW,aAAa,IAAI,CAAC,EAAE,6BAA6B,CACtF,CAAC;YACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAClB,yBAAyB,WAAW,gBAAgB,IAAI,CAAC,EAAE,SAAS,kBAAkB,yCAAyC,CAChI,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChF,CAAC;CACF"}
@@ -12,6 +12,32 @@
12
12
  * - JobScheduler calls canRunJob before spawning sessions
13
13
  */
14
14
  import type { QuotaState, JobPriority, JobSchedulerConfig } from '../core/types.js';
15
+ /**
16
+ * Live pool-placeability signal for the POOL-AWARE quota throttle. Returned by an
17
+ * injected provider (wired in server.ts) that asks the placement layer's OWN
18
+ * `selectAccount` "is there a placeable account, and what is its headroom?". The
19
+ * throttle uses placement's exact eligibility predicate by construction, so a
20
+ * throttle "allow" always corresponds to a real account the pool can place on —
21
+ * closing the band where the brake could allow work that placement couldn't land
22
+ * (the respawn-loop gap). Spec: docs/specs/POOL-AWARE-QUOTA-THROTTLE-SPEC.md.
23
+ */
24
+ export interface PoolQuota {
25
+ /** True iff placement's selectAccount returned a placeable account. */
26
+ placeable: boolean;
27
+ /** Best placeable account's weekly utilization (0-100), or null if unknown. */
28
+ weeklyPercent?: number | null;
29
+ /** Best placeable account's 5-hour utilization (0-100), or null if unknown. */
30
+ fiveHourPercent?: number | null;
31
+ /**
32
+ * True when the pool has a placeable account by STATUS but no trustworthy live
33
+ * quota reading for it (e.g. a freshly-enrolled or just-after-an-outage pool
34
+ * whose per-account snapshots are missing/stale). The throttle then applies the
35
+ * SAME bounded degraded-mode cap as the file path (shed low, allow medium+)
36
+ * rather than trusting a phantom "0% fresh" reading. Closes the round-2 finding
37
+ * that the pool path had no staleness/provenance guard.
38
+ */
39
+ degraded?: boolean;
40
+ }
15
41
  export interface QuotaTrackerConfig {
16
42
  /** Path to the quota state JSON file */
17
43
  quotaFile: string;
@@ -26,7 +52,21 @@ export declare class QuotaTracker {
26
52
  private lastRead;
27
53
  private readCooldownMs;
28
54
  private warnedNoFile;
55
+ /**
56
+ * Optional live pool-placeability provider (wired post-construction in
57
+ * server.ts for multi-account agents). When set, the throttle reasons over the
58
+ * pool's real placeability instead of a single account's usage. Unset on solo
59
+ * agents → the legacy single-account path runs unchanged.
60
+ */
61
+ private poolQuotaProvider?;
29
62
  constructor(config: QuotaTrackerConfig);
63
+ /**
64
+ * Inject (or clear) the live pool-placeability provider. Wired in server.ts to
65
+ * `() => selectAccount(subscriptionPool.list(), …)` so the throttle shares
66
+ * placement's exact eligibility. Pass `undefined` to revert to single-account
67
+ * gating.
68
+ */
69
+ setPoolQuotaProvider(fn: (() => PoolQuota | null) | undefined): void;
30
70
  /**
31
71
  * Read the current quota state from the file.
32
72
  * Returns null if file doesn't exist or is corrupted.
@@ -57,6 +97,22 @@ export declare class QuotaTracker {
57
97
  allowed: boolean;
58
98
  reason: string;
59
99
  };
100
+ /**
101
+ * Bounded degraded-mode decision, shared by the file path (non-authoritative
102
+ * estimate) and the pool path (placeable account with no trustworthy reading).
103
+ * We don't KNOW the real usage, so: honor a genuine authoritative 5-hour wall,
104
+ * then shed the lowest-priority work and allow medium+ — a conservative cap, not
105
+ * an unbounded fail-open and not a whole-agent stall. Spec §4.
106
+ */
107
+ private boundedDegradedDecision;
108
+ /**
109
+ * Evaluate ONE account's (weekly, 5-hour) usage against the configured
110
+ * thresholds for a given priority. Extracted so the pool-aware path can score
111
+ * each account independently and pick the best-available one. The single-account
112
+ * (legacy) path calls this directly with the one account's numbers, preserving
113
+ * the exact prior behavior for agents that don't run a multi-account pool.
114
+ */
115
+ private evaluateAccountQuota;
60
116
  /**
61
117
  * Write a quota state to the file (for collector scripts or manual updates).
62
118
  */
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaTracker.d.ts","sourceRoot":"","sources":["../../src/monitoring/QuotaTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGpF,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,UAAU,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAClD,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,cAAc,CAAQ;IAM9B,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,kBAAkB;IAItC;;;OAGG;IACH,QAAQ,IAAI,UAAU,GAAG,IAAI;IAwC7B;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO;IAKzC;;;;;OAKG;IACH,kBAAkB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAmDhF;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAsBpC;;OAEG;IACH,iBAAiB,IAAI,UAAU,CAAC,gBAAgB,CAAC;IAkBjD;;;;;;;;;;;OAWG;IACG,gBAAgB,CACpB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,S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B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -26,9 +26,25 @@ export class QuotaTracker {
26
26
  // 902×/day on the gemini-cli agent — pure log spam that drowns real signal).
27
27
  // Re-armed when the file reappears so a later disappearance warns once more.
28
28
  warnedNoFile = false;
29
+ /**
30
+ * Optional live pool-placeability provider (wired post-construction in
31
+ * server.ts for multi-account agents). When set, the throttle reasons over the
32
+ * pool's real placeability instead of a single account's usage. Unset on solo
33
+ * agents → the legacy single-account path runs unchanged.
34
+ */
35
+ poolQuotaProvider;
29
36
  constructor(config) {
30
37
  this.config = config;
31
38
  }
39
+ /**
40
+ * Inject (or clear) the live pool-placeability provider. Wired in server.ts to
41
+ * `() => selectAccount(subscriptionPool.list(), …)` so the throttle shares
42
+ * placement's exact eligibility. Pass `undefined` to revert to single-account
43
+ * gating.
44
+ */
45
+ setPoolQuotaProvider(fn) {
46
+ this.poolQuotaProvider = fn;
47
+ }
32
48
  /**
33
49
  * Read the current quota state from the file.
34
50
  * Returns null if file doesn't exist or is corrupted.
@@ -93,11 +109,104 @@ export class QuotaTracker {
93
109
  * Checks both weekly AND 5-hour rate limits.
94
110
  */
95
111
  shouldSpawnSession(priority) {
112
+ // POOL-AWARE PATH (the robustness fix): when a live pool-placeability provider
113
+ // is wired (multi-account agent), the brake reflects POOL placeability — shared
114
+ // BY CONSTRUCTION with the placement layer. The provider asks placement's OWN
115
+ // selectAccount "is there a placeable account, and what's its headroom?", so a
116
+ // throttle "allow" always corresponds to an account the pool can actually place
117
+ // on. This both (a) fixes the account-blind throttle that stopped the WHOLE
118
+ // agent on one maxed account while fresh accounts sat idle, and (b) closes the
119
+ // band where the old design allowed work placement couldn't land → respawn loop
120
+ // (selectAccount's soft threshold is stricter than the shutdown threshold).
121
+ // Live, status-aware data — no stale snapshot. Spec: docs/specs/POOL-AWARE-QUOTA-THROTTLE-SPEC.md.
122
+ if (this.poolQuotaProvider) {
123
+ let pool = null;
124
+ try {
125
+ pool = this.poolQuotaProvider();
126
+ }
127
+ catch {
128
+ // @silent-fallback-ok: a provider throw deliberately falls through to the
129
+ // conservative file-based quota logic below (fail-safe — the throttle still
130
+ // gates, never silently allows). This is a hot path (every spawn gate), so
131
+ // reporting per-call would spam; the fallthrough IS the intended degraded
132
+ // behavior, not a swallowed error.
133
+ pool = null;
134
+ }
135
+ if (pool) {
136
+ if (!pool.placeable) {
137
+ // NOTE: "placeable" is evaluated at DECISION time. A later placement that
138
+ // finds the last account just got consumed is a NORMAL, non-looping
139
+ // outcome (the caller backs off / retries), not the old respawn loop —
140
+ // that loop came from the throttle and placement DISAGREEING, which can no
141
+ // longer happen now that the throttle asks placement's own predicate.
142
+ return { allowed: false, reason: 'No placeable account in the pool — every account is at/over capacity' };
143
+ }
144
+ // DATA-QUALITY GUARD: if the pool has a placeable account by STATUS but no
145
+ // trustworthy live reading for it (degraded flag, or a non-finite/implausible
146
+ // percent), do NOT trust a phantom "0% fresh" — apply the SAME bounded
147
+ // degraded-mode cap as the file path. (Closes the round-2 finding: the pool
148
+ // path otherwise inherited selectAccount's unclamped, staleness-blind view.)
149
+ const weekly = pool.weeklyPercent;
150
+ const weeklyTrustworthy = typeof weekly === 'number' && isFinite(weekly) && weekly >= 0 && weekly <= 100;
151
+ if (pool.degraded || (weekly !== null && weekly !== undefined && !weeklyTrustworthy)) {
152
+ return this.boundedDegradedDecision(pool.fiveHourPercent ?? undefined, priority, 'pool quota reading is missing/untrustworthy');
153
+ }
154
+ // selectAccount already vouched for placeability; gate the best placeable
155
+ // account's effective usage (weekly + 5h, both checked in evaluateAccountQuota)
156
+ // by priority so load-shedding still applies. An allow here is guaranteed
157
+ // placeable. A null percent means "unknown but placeable" → treated as 0.
158
+ const r = this.evaluateAccountQuota(weekly ?? 0, pool.fiveHourPercent ?? undefined, priority);
159
+ return r.allowed
160
+ ? { allowed: true, reason: `Pool headroom — best placeable account at ${Math.round(weekly ?? 0)}% weekly` }
161
+ : r;
162
+ }
163
+ // provider threw / returned null → fall through to the file-based logic below.
164
+ }
96
165
  const state = this.getState();
97
166
  if (!state)
98
167
  return { allowed: true, reason: 'No quota data — fail open' };
168
+ // DEGRADED-DATA HARDENING (bounded): a non-authoritative estimate (JSONL
169
+ // token-counting) or an implausible >100% value must NOT slam the brake on the
170
+ // whole agent (the 2026-06-15 incident: a claude-jsonl 186% estimate stopped
171
+ // everything). But because we genuinely do not KNOW the real usage, fail-open is
172
+ // BOUNDED — we shed the lowest-priority work and still honor a genuine
173
+ // authoritative 5-hour wall. An AUTHORITATIVE source (anthropic-oauth) is never
174
+ // treated as degraded, so a real wall still stops. Spec §3.
175
+ const authoritative = state.source === 'anthropic-oauth';
176
+ const degraded = !authoritative &&
177
+ (state.source === 'claude-jsonl' || (typeof state.usagePercent === 'number' && state.usagePercent > 100));
178
+ if (degraded) {
179
+ return this.boundedDegradedDecision(state.fiveHourPercent, priority, 'quota data is a non-authoritative estimate');
180
+ }
181
+ // SINGLE-ACCOUNT PATH (legacy, unchanged): gate on the one account's usage.
182
+ return this.evaluateAccountQuota(state.usagePercent, state.fiveHourPercent, priority);
183
+ }
184
+ /**
185
+ * Bounded degraded-mode decision, shared by the file path (non-authoritative
186
+ * estimate) and the pool path (placeable account with no trustworthy reading).
187
+ * We don't KNOW the real usage, so: honor a genuine authoritative 5-hour wall,
188
+ * then shed the lowest-priority work and allow medium+ — a conservative cap, not
189
+ * an unbounded fail-open and not a whole-agent stall. Spec §4.
190
+ */
191
+ boundedDegradedDecision(fiveHourPercent, priority, reasonContext) {
192
+ if (typeof fiveHourPercent === 'number' && isFinite(fiveHourPercent) && fiveHourPercent >= 95) {
193
+ return { allowed: false, reason: `5-hour rate limit at ${fiveHourPercent}% — sessions will fail immediately` };
194
+ }
195
+ if (priority === 'low') {
196
+ return { allowed: false, reason: `${reasonContext} — shedding low-priority work (degraded mode)` };
197
+ }
198
+ return { allowed: true, reason: `${reasonContext} — running medium+ priority in degraded mode (low-priority shed)` };
199
+ }
200
+ /**
201
+ * Evaluate ONE account's (weekly, 5-hour) usage against the configured
202
+ * thresholds for a given priority. Extracted so the pool-aware path can score
203
+ * each account independently and pick the best-available one. The single-account
204
+ * (legacy) path calls this directly with the one account's numbers, preserving
205
+ * the exact prior behavior for agents that don't run a multi-account pool.
206
+ */
207
+ evaluateAccountQuota(rawWeekly, rawFiveHour, priority) {
99
208
  // Check 5-hour rate limit first — these cause immediate session failures
100
- const fiveHour = state.fiveHourPercent;
209
+ const fiveHour = rawFiveHour;
101
210
  if (typeof fiveHour === 'number' && isFinite(fiveHour)) {
102
211
  if (fiveHour >= 95) {
103
212
  return { allowed: false, reason: `5-hour rate limit at ${fiveHour}% — sessions will fail immediately` };
@@ -107,11 +216,10 @@ export class QuotaTracker {
107
216
  }
108
217
  }
109
218
  // Check weekly usage
110
- const rawUsage = state.usagePercent;
111
- if (typeof rawUsage !== 'number' || !isFinite(rawUsage)) {
219
+ if (typeof rawWeekly !== 'number' || !isFinite(rawWeekly)) {
112
220
  return { allowed: true, reason: 'Invalid weekly data — fail open' };
113
221
  }
114
- const usage = Math.max(0, Math.min(100, rawUsage));
222
+ const usage = Math.max(0, Math.min(100, rawWeekly));
115
223
  const { normal, elevated, critical, shutdown } = this.config.thresholds;
116
224
  if (usage >= shutdown) {
117
225
  return { allowed: false, reason: `Weekly quota at ${usage}% — all jobs stopped` };
@@ -1 +1 @@
1
- {"version":3,"file":"QuotaTracker.js","sourceRoot":"","sources":["../../src/monitoring/QuotaTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAW3D,MAAM,OAAO,YAAY;IACf,MAAM,CAAqB;IAC3B,WAAW,GAAsB,IAAI,CAAC;IACtC,QAAQ,GAAW,CAAC,CAAC;IACrB,cAAc,GAA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 I declare owner/blockedOn at commitment creation; a later state change goes thro
781
781
  - **Continuity guarantee** — a long session that hits its account's quota resumes on another eligible account (conversation preserved via \`--resume\`), never dies. Manual lever: \`POST /subscription-pool/swap\` \`{"sessionName":"...","exhaustedAccountId":"..."}\`. Auto-swap on rate-limit ships OFF (opt-in via \`subscriptionPool.autoSwapOnRateLimit\` — it moves a live session, real authority).
782
782
  - **Pre-limit (proactive) swap** — beyond the reactive swap above, I can move a session OFF an account BEFORE it walls, at a lag-aware measured threshold (default 80% — the polled reading trails real usage, so the swap completes with margin). It also covers the UNTAGGED interactive session (resolves its account from the default login), so the session you talk to doesn't wedge at the wall. Opt-in via \`subscriptionPool.proactiveSwap.enabled\` (same authority as auto-swap, earlier trigger). Status: \`GET /subscription-pool/proactive-swap\`; run a pass now: \`POST /subscription-pool/proactive-swap/check\`.
783
783
  - **Enroll a new account from your phone** — \`POST /subscription-pool/enroll\` \`{"id","label","provider","framework","configHome"}\` starts a login and returns a public code/URL (never a token); \`GET /subscription-pool/pending-logins\` is the surface; expired codes are auto-reissued. Mark done with \`POST /subscription-pool/enroll/:id/complete\`.
784
+ - **Pool-aware quota brake (the global load-shed is NOT account-blind)** — the global quota throttle (\`QuotaTracker.shouldSpawnSession\`) that decides "can I run work right now?" gates on the **best-available account's headroom across the whole pool**, NOT a single account. So one maxed account can NEVER stop the whole agent while another account still has room — the subscription pool just places the work on the account with the most headroom. A non-authoritative/implausible usage reading (a JSONL token-estimate, or any value >100%) **fails open** rather than slamming the brake on a guess. (A solo, single-account agent keeps the exact legacy single-account gating.) The collector folds every account's live usage into \`quota-state.json\` → \`accounts[]\` so the brake can see the whole pool.
784
785
  - **Dashboard**: the **Subscriptions tab** shows live quota bars (5h + weekly + reset countdown), status, and the Pending Logins panel — share the dashboard URL + PIN.
785
- - **When to use** (PROACTIVE): "how much quota is left across my accounts?" / "am I about to hit a limit?" → \`GET /subscription-pool\`; the user wants to add another subscription → drive the enrollment wizard (never ask them to paste a token); a long job is at risk of a quota wall → the continuity guarantee + \`/swap\` keep it alive. Single-account pools are a no-op.
786
+ - **When to use** (PROACTIVE): "how much quota is left across my accounts?" / "am I about to hit a limit?" → \`GET /subscription-pool\`; the user wants to add another subscription → drive the enrollment wizard (never ask them to paste a token); a long job is at risk of a quota wall → the continuity guarantee + \`/swap\` keep it alive. **"Why didn't the agent stall / get stuck with one account maxed out?"** → the pool-aware quota brake above: it only stops work when EVERY account in the pool is at capacity, so idle accounts get used instead of the agent halting. Single-account pools are a no-op.
786
787
 
787
788
  **Live Credential Re-pointing (move a pool account's login between config-home "slots" without restarting — WS5.2)** — Beyond the subscription pool's session-MOVING, this MOVES the credential itself: it exchanges which pool account's OAuth login sits in which config-home "slot" via a staged keychain swap, so the sessions already reading that slot pick up the new account on their NEXT API call — no restart, no re-login, nothing on your screen. The unit shuffled is the CREDENTIAL (always a clean SWAP between two slots, never a copy — one home per credential), verified by identity after every move (quarantine-never-repair when the identity oracle can't confirm). **On a development agent it runs LIVE in dry-run** (the developmentAgent gate, \`subscriptionPool.credentialRepointing.enabled\` omitted → resolves live-on-dev / dark-fleet) — the \`/credentials/*\` levers return real data and the balancer runs its full decision loop, but the executor performs ZERO credential writes while \`dryRun\` holds (the write-safety canary; on the fleet every lever 503s). Actually MOVING a credential needs a deliberate \`dryRun:false\` — that decision is yours (gated behind running the §5 livetest battery first).
788
789
  - **Which account is in which slot?** (Registry First — read it, never guess) \`curl -H "Authorization: Bearer $AUTH" http://localhost:${port}/credentials/locations\` → the ledger census (slot ↔ account, since, lastVerifiedAt, quarantine state, journal tail, mode).
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oFAAoF;AACpF,qFAAqF;AACrF,oFAAoF;AACpF,mFAAmF;AACnF,4BAA4B;AAC5B,OAAO,EAAE,4CAA4C,EAAE,MAAM,+BAA+B,CAAC;AAS7F;;GAEG;AACH,MAAM,UAAU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AAiB,EACjB,IAAY,EACZ,WAAoB,EACpB,cAAuB,KAAK;IAE5B,IAAI,OAAO,GAAG,iBAAiB,WAAW;;;;OAIrC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCT,SAAS;;gCAEgB,IAAI,qFAAqF,IAAI;;;;;;CAM5H,CAAC;IAEA,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;IACA,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAI;;;;CAId,CAAC;IACA,CAAC;IAED,OAAO,IAAI;;;;;;;8EAOiE,IAAI;;;yFAGO,IAAI;;;;;;;uGAOU,IAAI;yFAClB,IAAI;;;;;;0DAMnC,IAAI;;;;;;;;;;;;;;;;;;;;;;;2FAuB6B,IAAI;8FACD,IAAI;+MAC6G,IAAI;mGAChH,IAAI;;;mMAG4F,IAAI;;;;;0LAKb,IAAI;;;;4EAIlH,IAAI;+LAC+G,IAAI;;;;8DAIrI,IAAI;;;;;;;;;;;0CAWxB,IAAI;oCACV,IAAI;;;;;;;;;;;;;yDAaiB,IAAI;;;;;;;;0DAQH,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+GhD,SAAS;;;;;;;;;;;;sEAY+C,IAAI;;CAEzE,CAAC;IAEA,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.591",
3
+ "version": "1.3.592",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-06-16T06:55:01.483Z",
5
- "instarVersion": "1.3.591",
4
+ "generatedAt": "2026-06-16T08:21:53.499Z",
5
+ "instarVersion": "1.3.592",
6
6
  "entryCount": 201,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -802,8 +802,9 @@ I declare owner/blockedOn at commitment creation; a later state change goes thro
802
802
  - **Continuity guarantee** — a long session that hits its account's quota resumes on another eligible account (conversation preserved via \`--resume\`), never dies. Manual lever: \`POST /subscription-pool/swap\` \`{"sessionName":"...","exhaustedAccountId":"..."}\`. Auto-swap on rate-limit ships OFF (opt-in via \`subscriptionPool.autoSwapOnRateLimit\` — it moves a live session, real authority).
803
803
  - **Pre-limit (proactive) swap** — beyond the reactive swap above, I can move a session OFF an account BEFORE it walls, at a lag-aware measured threshold (default 80% — the polled reading trails real usage, so the swap completes with margin). It also covers the UNTAGGED interactive session (resolves its account from the default login), so the session you talk to doesn't wedge at the wall. Opt-in via \`subscriptionPool.proactiveSwap.enabled\` (same authority as auto-swap, earlier trigger). Status: \`GET /subscription-pool/proactive-swap\`; run a pass now: \`POST /subscription-pool/proactive-swap/check\`.
804
804
  - **Enroll a new account from your phone** — \`POST /subscription-pool/enroll\` \`{"id","label","provider","framework","configHome"}\` starts a login and returns a public code/URL (never a token); \`GET /subscription-pool/pending-logins\` is the surface; expired codes are auto-reissued. Mark done with \`POST /subscription-pool/enroll/:id/complete\`.
805
+ - **Pool-aware quota brake (the global load-shed is NOT account-blind)** — the global quota throttle (\`QuotaTracker.shouldSpawnSession\`) that decides "can I run work right now?" gates on the **best-available account's headroom across the whole pool**, NOT a single account. So one maxed account can NEVER stop the whole agent while another account still has room — the subscription pool just places the work on the account with the most headroom. A non-authoritative/implausible usage reading (a JSONL token-estimate, or any value >100%) **fails open** rather than slamming the brake on a guess. (A solo, single-account agent keeps the exact legacy single-account gating.) The collector folds every account's live usage into \`quota-state.json\` → \`accounts[]\` so the brake can see the whole pool.
805
806
  - **Dashboard**: the **Subscriptions tab** shows live quota bars (5h + weekly + reset countdown), status, and the Pending Logins panel — share the dashboard URL + PIN.
806
- - **When to use** (PROACTIVE): "how much quota is left across my accounts?" / "am I about to hit a limit?" → \`GET /subscription-pool\`; the user wants to add another subscription → drive the enrollment wizard (never ask them to paste a token); a long job is at risk of a quota wall → the continuity guarantee + \`/swap\` keep it alive. Single-account pools are a no-op.
807
+ - **When to use** (PROACTIVE): "how much quota is left across my accounts?" / "am I about to hit a limit?" → \`GET /subscription-pool\`; the user wants to add another subscription → drive the enrollment wizard (never ask them to paste a token); a long job is at risk of a quota wall → the continuity guarantee + \`/swap\` keep it alive. **"Why didn't the agent stall / get stuck with one account maxed out?"** → the pool-aware quota brake above: it only stops work when EVERY account in the pool is at capacity, so idle accounts get used instead of the agent halting. Single-account pools are a no-op.
807
808
 
808
809
  **Live Credential Re-pointing (move a pool account's login between config-home "slots" without restarting — WS5.2)** — Beyond the subscription pool's session-MOVING, this MOVES the credential itself: it exchanges which pool account's OAuth login sits in which config-home "slot" via a staged keychain swap, so the sessions already reading that slot pick up the new account on their NEXT API call — no restart, no re-login, nothing on your screen. The unit shuffled is the CREDENTIAL (always a clean SWAP between two slots, never a copy — one home per credential), verified by identity after every move (quarantine-never-repair when the identity oracle can't confirm). **On a development agent it runs LIVE in dry-run** (the developmentAgent gate, \`subscriptionPool.credentialRepointing.enabled\` omitted → resolves live-on-dev / dark-fleet) — the \`/credentials/*\` levers return real data and the balancer runs its full decision loop, but the executor performs ZERO credential writes while \`dryRun\` holds (the write-safety canary; on the fleet every lever 503s). Actually MOVING a credential needs a deliberate \`dryRun:false\` — that decision is yours (gated behind running the §5 livetest battery first).
809
810
  - **Which account is in which slot?** (Registry First — read it, never guess) \`curl -H "Authorization: Bearer $AUTH" http://localhost:${port}/credentials/locations\` → the ledger census (slot ↔ account, since, lastVerifiedAt, quarantine state, journal tail, mode).
@@ -0,0 +1,40 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The global quota brake (`QuotaTracker.shouldSpawnSession`) was account-blind: it stopped the WHOLE agent
9
+ on a single account's usage, so when one Claude account hit its weekly limit the agent froze even though
10
+ other pooled accounts sat at 0% (the 2026-06-15 "two accounts untouched while work stalls" incident; a
11
+ degraded JSONL estimate reading 186% jammed it harder). It now reasons over the whole pool by asking the
12
+ placement layer's OWN `selectAccount` predicate (via a provider wired in `server.ts`): the brake never
13
+ halts the agent while a placeable account has headroom, and never allows work placement can't land — the
14
+ 90–95% "allowed-but-unplaceable" respawn-loop band is closed by construction (`allowed ⟹ placeable`).
15
+ Missing/implausible/degraded readings trigger a BOUNDED mode (shed low priority, allow medium+, honor an
16
+ authoritative 5-hour wall) instead of a stall or unbounded fail-open.
17
+
18
+ ## What to Tell Your User
19
+
20
+ If you run several Claude accounts pooled together, the agent no longer freezes when one account hits its
21
+ weekly limit — it keeps working on the accounts that still have room, and it won't get stuck in the
22
+ "session respawned" restart loop. Single-account agents are completely unaffected (byte-identical
23
+ behavior). Nothing to configure; it's on by default because it removes a bug.
24
+
25
+ ## Summary of New Capabilities
26
+
27
+ - `QuotaTracker.setPoolQuotaProvider()` — the brake shares placement's exact eligibility predicate, so a
28
+ maxed account can never stop the whole agent while a placeable account exists.
29
+ - Bounded degraded-data handling (shared by the pool and single-account paths): non-authoritative /
30
+ out-of-range / missing readings shed low priority and allow medium+, instead of stalling or running blind.
31
+ - The "use-it-or-lose-it" optimizations (drain near-reset accounts first, burn-rate balancing) are the
32
+ tracked SECOND PR — this one is the robust+safe foundation.
33
+
34
+ ## Evidence
35
+
36
+ Converged over 3 `/spec-converge` rounds (6 internal reviewers + codex GPT-5.5); the first two designs were
37
+ rejected by review (one dead in production, one with a staleness/loop gap) and redesigned. 253 quota tests
38
+ pass with no regressions, including a test proving `allowed ⟹ placeable` across a 0→100 usage sweep and the
39
+ 90–95% band → stop. Spec: `docs/specs/POOL-AWARE-QUOTA-THROTTLE-SPEC.md`. Acceptance: the two previously-idle
40
+ accounts demonstrably carry load after the fix (live proof).