@cortexkit/antigravity-auth-core 3.0.10 → 3.0.12

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.
Files changed (42) hide show
  1. package/dist/agy-transport.d.ts.map +1 -1
  2. package/dist/agy-transport.js +4 -0
  3. package/dist/agy-transport.js.map +1 -1
  4. package/dist/common-auth-embedded/claustrum/consumer.d.ts +7 -1
  5. package/dist/common-auth-embedded/claustrum/consumer.js +17 -2
  6. package/dist/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
  7. package/dist/common-auth-embedded/claustrum/enrollment.js +27 -0
  8. package/dist/common-auth-embedded/claustrum/errors.d.ts +1 -1
  9. package/dist/common-auth-embedded/claustrum/index.d.ts +1 -1
  10. package/dist/common-auth-embedded/claustrum/index.js +1 -1
  11. package/dist/common-auth-embedded/claustrum/quota-writer.js +4 -54
  12. package/dist/common-auth-embedded/claustrum/roster.d.ts +31 -0
  13. package/dist/common-auth-embedded/claustrum/roster.js +72 -0
  14. package/dist/common-auth-embedded/commands/builtins.d.ts +37 -0
  15. package/dist/common-auth-embedded/commands/builtins.js +95 -13
  16. package/dist/common-auth-embedded/commands/index.d.ts +1 -1
  17. package/dist/common-auth-embedded/fs/private-files.d.ts +2 -0
  18. package/dist/common-auth-embedded/fs/private-files.js +49 -3
  19. package/dist/common-auth-embedded/quota/pending.js +48 -0
  20. package/dist/common-auth-embedded/source-output.json +86 -70
  21. package/dist/common-auth-embedded/store/attribution.d.ts +5 -0
  22. package/dist/common-auth-embedded/store/attribution.js +39 -25
  23. package/dist/common-auth-embedded/store/pool.d.ts +17 -0
  24. package/dist/common-auth-embedded/store/pool.js +18 -3
  25. package/dist/common-auth-embedded/store/pull.js +3 -1
  26. package/dist/common-auth-embedded/store/quota-writer.js +298 -0
  27. package/dist/common-auth-embedded/store/runtime.d.ts +2 -0
  28. package/dist/pre-response-deadline.d.ts.map +1 -1
  29. package/dist/pre-response-deadline.js +6 -5
  30. package/dist/pre-response-deadline.js.map +1 -1
  31. package/dist/quota-manager.d.ts +3 -3
  32. package/dist/quota-manager.d.ts.map +1 -1
  33. package/dist/quota-manager.js +59 -36
  34. package/dist/quota-manager.js.map +1 -1
  35. package/dist/transform/gemini.d.ts.map +1 -1
  36. package/dist/transform/gemini.js +12 -0
  37. package/dist/transform/gemini.js.map +1 -1
  38. package/dist/vault-enrollment-authority.d.ts +2 -0
  39. package/dist/vault-enrollment-authority.d.ts.map +1 -1
  40. package/dist/vault-enrollment-authority.js +2 -0
  41. package/dist/vault-enrollment-authority.js.map +1 -1
  42. package/package.json +1 -1
@@ -1,8 +1,41 @@
1
1
  import { PoolOperationError } from './errors.js';
2
- import { toFailure, withTransaction } from './mutate.js';
2
+ import { toFailure, withTransaction, } from './mutate.js';
3
3
  import { LockStack } from './refresh-lock.js';
4
4
  import { refusal, requireBound, unknownRow, } from './runtime.js';
5
5
  import { isCredentialEpoch } from './schema.js';
6
+ export function assertQuotaEpoch(id, attribution) {
7
+ if (!isCredentialEpoch(attribution?.credentialEpoch))
8
+ throw refusal('pull', id, 'invalid-input', 'the credential epoch the reading was issued for must be a positive safe integer');
9
+ }
10
+ // Shared by preflight and the locked commit: accepting into memory must never
11
+ // hide a refusal the immediate writer would have returned to its caller.
12
+ export function assertQuotaRow(id, attribution, row) {
13
+ if (!row)
14
+ throw unknownRow('pull', id);
15
+ if (row.invalid)
16
+ throw refusal('pull', id, 'invalid-row', `row ${id} is invalid`);
17
+ if (!row.credential)
18
+ throw refusal('pull', id, 'no-credential', `row ${id} holds no credential`);
19
+ requireBound('pull', row);
20
+ if (row.torn ||
21
+ !row.hasEntry ||
22
+ row.credentialEpoch !== attribution.credentialEpoch ||
23
+ row.identity !== attribution.identity)
24
+ throw new PoolOperationError({
25
+ operation: 'pull',
26
+ rowId: id,
27
+ phase: 'pull',
28
+ retryable: true,
29
+ kind: 'attribution',
30
+ message: `quota for ${id} was issued for a credential the row no longer holds`,
31
+ });
32
+ }
33
+ export function mergedQuota(ctx, id, stored, observation) {
34
+ const merged = ctx.codec.merge(stored, observation);
35
+ if (!ctx.codec.validate(merged))
36
+ throw refusal('pull', id, 'invalid-quota', 'the quota codec rejected the merged map');
37
+ return merged;
38
+ }
6
39
  /**
7
40
  * Merges a quota observation into a row's stored map under the store locks,
8
41
  * after attribution passes. Needs no row lock, so it is permitted from
@@ -13,37 +46,18 @@ export async function recordQuota(rt, id, attribution, observation) {
13
46
  const locks = new LockStack(ctx.lockDefaults, ctx.lockEnv);
14
47
  const progress = { writes: 0 };
15
48
  try {
16
- if (!isCredentialEpoch(attribution?.credentialEpoch))
17
- throw refusal('pull', id, 'invalid-input', 'the credential epoch the reading was issued for must be a positive safe integer');
49
+ assertQuotaEpoch(id, attribution);
18
50
  await withTransaction(ctx, locks, progress, { operation: 'pull', rowId: id }, async (tx) => {
19
51
  tx.assertNotStaged(id);
20
52
  const row = tx.row(id);
21
- if (!row)
22
- throw unknownRow('pull', id);
23
- if (row.invalid)
24
- throw refusal('pull', id, 'invalid-row', `row ${id} is invalid`);
25
53
  // A reading belongs to one (epoch, identity, credential). A row
26
54
  // holding no credential, or torn between the writes of a replace,
27
55
  // has no such triple on disk, so no reading is recorded for it.
28
- if (!row.credential)
29
- throw refusal('pull', id, 'no-credential', `row ${id} holds no credential`);
30
- requireBound('pull', row);
56
+ assertQuotaRow(id, attribution, row);
31
57
  const entry = tx.entry(id);
32
- if (row.torn ||
33
- !entry ||
34
- entry.credentialEpoch !== attribution.credentialEpoch ||
35
- row.identity !== attribution.identity)
36
- throw new PoolOperationError({
37
- operation: 'pull',
38
- rowId: id,
39
- phase: 'pull',
40
- retryable: true,
41
- kind: 'attribution',
42
- message: `quota for ${id} was issued for a credential the row no longer holds`,
43
- });
44
- const merged = ctx.codec.merge(entry.quota, observation);
45
- if (!ctx.codec.validate(merged))
46
- throw refusal('pull', id, 'invalid-quota', 'the quota codec rejected the merged map');
58
+ if (!entry)
59
+ throw unknownRow('pull', id);
60
+ const merged = mergedQuota(ctx, id, entry.quota, observation);
47
61
  tx.setEntry(id, { ...entry, quota: merged, needsFirstReading: false });
48
62
  await tx.commitConfig();
49
63
  },
@@ -16,6 +16,19 @@ export interface OpenPoolStoreOptions {
16
16
  configPath: string;
17
17
  statePath: string;
18
18
  quota: QuotaCodec;
19
+ /**
20
+ * Opt in to detached, coalesced quota publication, with any `quota` codec.
21
+ * Each accepted observation is queued whole for its row and binding, and
22
+ * the queue is applied in arrival order through `quota.merge` under the
23
+ * store locks, so the codec's own merge decides which fields a newer or
24
+ * older reading replaces. Accepted readings appear in read/load
25
+ * immediately, merged the same way; the returned promise still rejects
26
+ * current-row refusals before queueing. Await dispose or close at shutdown
27
+ * to drain.
28
+ */
29
+ coalesceQuota?: boolean;
30
+ /** Bounded quota drain on close/dispose, in milliseconds; defaults to 1,000. */
31
+ quotaDrainTimeoutMs?: number;
19
32
  /**
20
33
  * The codec of the provider state kept beside each row's credential (see
21
34
  * `ProviderStateCodec`). Without it no row shows a provider state, and
@@ -189,6 +202,10 @@ export interface PoolStore {
189
202
  }>;
190
203
  refresh(id: string, provider: ProviderRefresh, options?: RefreshOptions): Promise<RefreshOutcome>;
191
204
  recordQuota(id: string, attribution: Attribution, observation: unknown): Promise<void>;
205
+ /** Drain opted-in quota publication; subsequent coalesced readings refuse. Idempotent. */
206
+ close(): Promise<void>;
207
+ /** Same bounded quota drain as close(). Does not wait for provider pull hooks. */
208
+ dispose(): Promise<void>;
192
209
  /** Fires a pull for a row admission refused for want of a reading. */
193
210
  requestReading(id: string): void;
194
211
  /** Resolves once every pull fired so far has settled. */
@@ -3,6 +3,7 @@ import { initializePool, readPool, } from './mutate.js';
3
3
  import { updateProviderStateRow, } from './provider-state.js';
4
4
  import { publication, publishRoster, } from './publication.js';
5
5
  import { PullScheduler } from './pull.js';
6
+ import { PoolQuotaWriter } from './quota-writer.js';
6
7
  import { refreshRow, } from './refresh.js';
7
8
  import { POOL_LOCK_DEFAULTS, } from './refresh-lock.js';
8
9
  import { addRow, disableRow, enableRow, recordRowIdentity, removeRow, reorderRows, replaceRow, rotateRow, } from './rows.js';
@@ -80,9 +81,21 @@ export function openPoolStore(options) {
80
81
  rowLockOptions: options.rowLockOptions ?? {},
81
82
  firePull: (id, reason) => pulls.fire(id, reason),
82
83
  };
84
+ const quotaWriter = options.coalesceQuota
85
+ ? new PoolQuotaWriter(rt, options.quotaDrainTimeoutMs)
86
+ : undefined;
87
+ const record = (id, attribution, observation) => quotaWriter
88
+ ? quotaWriter.record(id, attribution, observation)
89
+ : recordQuota(rt, id, attribution, observation);
90
+ rt.publishQuota = record;
91
+ const overlay = (result) => {
92
+ if (result.status === 'ready' && quotaWriter)
93
+ return { ...result, rows: quotaWriter.overlay(result.rows) };
94
+ return result;
95
+ };
83
96
  return {
84
97
  async load() {
85
- const result = await readPool(ctx);
98
+ const result = overlay(await readPool(ctx));
86
99
  if (result.status === 'ready') {
87
100
  // A torn row is no candidate, but its pull is fired too: the pull
88
101
  // completes the row on disk before reading it, so an interrupted
@@ -96,7 +109,7 @@ export function openPoolStore(options) {
96
109
  return toLoad(result);
97
110
  },
98
111
  async read() {
99
- return toLoad(await readPool(ctx));
112
+ return toLoad(overlay(await readPool(ctx)));
100
113
  },
101
114
  async initialize(input = {}) {
102
115
  return { status: await initializePool(ctx, input.dropKeys ?? []) };
@@ -115,7 +128,9 @@ export function openPoolStore(options) {
115
128
  updateSettings: (mutator, callOptions) => updatePoolSettings(rt, mutator, callOptions),
116
129
  recordIdentity: (id, identity, attribution, callOptions) => recordRowIdentity(rt, id, identity, attribution, callOptions),
117
130
  refresh: (id, provider, callOptions) => refreshRow(rt, id, provider, callOptions),
118
- recordQuota: (id, attribution, observation) => recordQuota(rt, id, attribution, observation),
131
+ recordQuota: record,
132
+ close: () => quotaWriter?.close() ?? Promise.resolve(),
133
+ dispose: () => quotaWriter?.close() ?? Promise.resolve(),
119
134
  requestReading: (id) => pulls.fire(id, 'admission'),
120
135
  pullsSettled: () => pulls.settled(),
121
136
  };
@@ -105,7 +105,9 @@ export class PullScheduler {
105
105
  cause,
106
106
  });
107
107
  }
108
- await recordQuota(rt, id, {
108
+ const publish = rt.publishQuota ??
109
+ ((rowId, attribution, value) => recordQuota(rt, rowId, attribution, value));
110
+ await publish(id, {
109
111
  credentialEpoch: request.credentialEpoch,
110
112
  ...(request.identity !== undefined
111
113
  ? { identity: request.identity }
@@ -0,0 +1,298 @@
1
+ import { createLogger } from '../logger/index.js';
2
+ import { assertQuotaEpoch, assertQuotaRow, mergedQuota, } from './attribution.js';
3
+ import { PoolOperationError } from './errors.js';
4
+ import { toFailure, withTransaction } from './mutate.js';
5
+ import { LockStack } from './refresh-lock.js';
6
+ import { readRow, refusal } from './runtime.js';
7
+ import { entryIn } from './schema.js';
8
+ const COALESCE_MS = 100;
9
+ /**
10
+ * The most readings one row keeps waiting for a flush. Hosts record a reading
11
+ * about every 100 ms at most, so for them a queue this long means another
12
+ * writer has held the store locks for many seconds. Reaching it starts
13
+ * a flush at once instead of waiting for the coalescing timer or a retry
14
+ * backoff; a further reading for the row waits for room (never dropping an
15
+ * older one) for as long as the store's normal lock budget, and is then
16
+ * refused with `lock-contention`, as the immediate writer would refuse it.
17
+ */
18
+ export const POOL_QUOTA_QUEUE_LIMIT = 128;
19
+ // Readings are queued whole per row and applied at flush in arrival order
20
+ // through the codec's own merge, so the codec alone decides which fields a
21
+ // newer or older reading replaces. Like the roster writer, a reading stays
22
+ // queued until the flush that took it commits: one queued while a flush waits
23
+ // for its locks must survive that flush.
24
+ export class PoolQuotaWriter {
25
+ rt;
26
+ timeoutMs;
27
+ pending = new Map();
28
+ warned = new Set();
29
+ wake = new Set();
30
+ logger;
31
+ timer;
32
+ running;
33
+ closing;
34
+ closed = false;
35
+ stopped = false;
36
+ failures = 0;
37
+ constructor(rt, timeoutMs = 1_000) {
38
+ this.rt = rt;
39
+ this.timeoutMs = timeoutMs;
40
+ this.logger = rt.ctx.logger ?? createLogger('store');
41
+ }
42
+ async record(id, attribution, observation) {
43
+ try {
44
+ this.assertOpen(id);
45
+ assertQuotaEpoch(id, attribution);
46
+ // Snapshot before the first await: callers may reuse their headers object.
47
+ const publication = structuredClone({
48
+ id,
49
+ attribution,
50
+ observation,
51
+ });
52
+ const { row, result } = await readRow(this.rt, 'pull', id);
53
+ assertQuotaRow(id, publication.attribution, row);
54
+ // Merge into what read() shows now, so a reading the codec refuses is
55
+ // refused to its caller here, as the immediate writer would refuse it.
56
+ mergedQuota(this.rt.ctx, id, this.overlayRow({ ...row, quota: entryIn(result.config, id)?.quota })
57
+ .quota, publication.observation);
58
+ await this.room(id);
59
+ this.assertOpen(id);
60
+ // No await between the room check and the push, so the cap holds.
61
+ const queue = this.pending.get(id) ?? [];
62
+ queue.push(publication);
63
+ this.pending.set(id, queue);
64
+ if (queue.length >= POOL_QUOTA_QUEUE_LIMIT)
65
+ this.flushNow();
66
+ else
67
+ this.schedule(COALESCE_MS);
68
+ }
69
+ catch (error) {
70
+ throw toFailure(error, 'pull', id, { writes: 0 });
71
+ }
72
+ }
73
+ queued(id) {
74
+ return this.pending.get(id)?.length ?? 0;
75
+ }
76
+ // Waits while the row's queue is full, flushing at once on every wake-up,
77
+ // for at most the store's own lock acquisition budget.
78
+ async room(id) {
79
+ if (this.queued(id) < POOL_QUOTA_QUEUE_LIMIT)
80
+ return;
81
+ const { ctx } = this.rt;
82
+ const budget = Math.max(0, ...ctx.storeLocks.map((spec) => spec.timeoutMs ?? ctx.lockDefaults.timeoutMs));
83
+ const deadline = performance.now() + budget;
84
+ while (this.queued(id) >= POOL_QUOTA_QUEUE_LIMIT) {
85
+ this.assertOpen(id);
86
+ this.flushNow();
87
+ const left = deadline - performance.now();
88
+ if (left <= 0)
89
+ throw refusal('pull', id, 'lock-contention', `pool quota queue for ${id} is full (${POOL_QUOTA_QUEUE_LIMIT} readings) and the store locks stayed held`, true);
90
+ await new Promise((resolve) => {
91
+ const done = () => {
92
+ clearTimeout(timer);
93
+ this.wake.delete(done);
94
+ resolve();
95
+ };
96
+ const timer = setTimeout(done, left);
97
+ this.wake.add(done);
98
+ });
99
+ }
100
+ }
101
+ assertOpen(id) {
102
+ if (this.closed)
103
+ throw refusal('pull', id, 'invalid-input', 'pool quota writer is closed');
104
+ }
105
+ // What read() and load() show: the stored map, then each queued reading of
106
+ // the row still bound to it, in arrival order through the codec's merge.
107
+ // A reading the codec now refuses is left out, as the flush drops it.
108
+ overlayRow(row) {
109
+ let next = row;
110
+ for (const publication of this.pending.get(row.id) ?? []) {
111
+ try {
112
+ assertQuotaRow(row.id, publication.attribution, row);
113
+ next = {
114
+ ...next,
115
+ quota: mergedQuota(this.rt.ctx, row.id, next.quota, publication.observation),
116
+ needsFirstReading: false,
117
+ };
118
+ }
119
+ catch { }
120
+ }
121
+ return next;
122
+ }
123
+ overlay(rows) {
124
+ return rows.map((row) => this.overlayRow(row));
125
+ }
126
+ schedule(delay) {
127
+ if (this.running || this.timer || !this.pending.size || this.stopped)
128
+ return;
129
+ this.timer = setTimeout(() => {
130
+ this.timer = undefined;
131
+ this.flush();
132
+ }, delay);
133
+ if (!this.closed)
134
+ this.timer.unref?.();
135
+ }
136
+ // Starts a flush now rather than at the coalescing timer or retry backoff;
137
+ // a flush already running is left to finish.
138
+ flushNow() {
139
+ if (this.running)
140
+ return;
141
+ clearTimeout(this.timer);
142
+ this.timer = undefined;
143
+ this.flush();
144
+ }
145
+ flush() {
146
+ if (this.running || this.stopped || !this.pending.size)
147
+ return;
148
+ // Every queued reading, each row's in arrival order.
149
+ const batch = [...this.pending.values()].flat();
150
+ // Short lock attempts allow retries to pick up freshly queued readings and
151
+ // bound shutdown even when the normal store acquisition budget is long.
152
+ const ctx = {
153
+ ...this.rt.ctx,
154
+ storeLocks: this.rt.ctx.storeLocks.map((spec) => ({
155
+ ...spec,
156
+ timeoutMs: Math.min(spec.timeoutMs ?? this.rt.ctx.lockDefaults.timeoutMs, 100),
157
+ })),
158
+ };
159
+ const locks = new LockStack(ctx.lockDefaults, ctx.lockEnv);
160
+ this.running = (async () => {
161
+ try {
162
+ await withTransaction(ctx, locks, { writes: 0 }, { operation: 'pull', rowId: undefined }, async (tx) => {
163
+ if (this.stopped)
164
+ return;
165
+ let changed = false;
166
+ for (const publication of batch) {
167
+ const { id, attribution, observation } = publication;
168
+ const witness = JSON.stringify([
169
+ id,
170
+ attribution.credentialEpoch,
171
+ attribution.identity,
172
+ ]);
173
+ try {
174
+ tx.assertNotStaged(id);
175
+ assertQuotaRow(id, attribution, tx.row(id));
176
+ }
177
+ catch (error) {
178
+ if (!(error instanceof PoolOperationError))
179
+ throw error;
180
+ if (!this.warned.has(witness)) {
181
+ this.warned.add(witness);
182
+ this.warn('pool quota publication dropped; account binding changed', { id, kind: error.kind });
183
+ }
184
+ continue;
185
+ }
186
+ const entry = tx.entry(id);
187
+ if (!entry)
188
+ continue;
189
+ let quota;
190
+ try {
191
+ quota = mergedQuota(ctx, id, entry.quota, observation);
192
+ }
193
+ catch (error) {
194
+ // The codec accepted this reading when it was queued, but not
195
+ // against what is stored now (another writer changed it).
196
+ // Drop only this reading: failing the transaction would retry
197
+ // the same refusal forever and hold back every other row.
198
+ const key = `codec:${witness}`;
199
+ if (!this.warned.has(key)) {
200
+ this.warned.add(key);
201
+ this.warn('pool quota publication dropped; the quota codec refused it', {
202
+ id,
203
+ error: error instanceof Error ? error.message : String(error),
204
+ });
205
+ }
206
+ continue;
207
+ }
208
+ tx.setEntry(id, { ...entry, quota, needsFirstReading: false });
209
+ changed = true;
210
+ }
211
+ if (changed && !this.stopped)
212
+ await tx.commitConfig();
213
+ }, { completeTorn: false });
214
+ const flushed = new Set(batch);
215
+ for (const [id, queue] of this.pending) {
216
+ const rest = queue.filter((publication) => !flushed.has(publication));
217
+ if (rest.length)
218
+ this.pending.set(id, rest);
219
+ else
220
+ this.pending.delete(id);
221
+ }
222
+ this.failures = 0;
223
+ }
224
+ catch (error) {
225
+ if (!this.stopped && this.failures++ === 0)
226
+ this.warn('pool quota publication delayed; retrying', {
227
+ error: error instanceof Error ? error.message : String(error),
228
+ });
229
+ // Retain the mailbox on failure, including fresher readings queued meanwhile.
230
+ }
231
+ finally {
232
+ await locks.releaseAll();
233
+ this.running = undefined;
234
+ for (const wake of this.wake)
235
+ wake();
236
+ const delay = this.failures
237
+ ? Math.min(5_000, 100 * 2 ** Math.min(this.failures, 6)) *
238
+ (0.5 + Math.random())
239
+ : COALESCE_MS;
240
+ this.schedule(delay);
241
+ }
242
+ })();
243
+ }
244
+ warn(message, data) {
245
+ try {
246
+ this.logger.warn(message, data);
247
+ }
248
+ catch {
249
+ /* Logging cannot stop publication. */
250
+ }
251
+ }
252
+ close() {
253
+ if (this.closing)
254
+ return this.closing;
255
+ this.closed = true;
256
+ this.closing = this.drain();
257
+ return this.closing;
258
+ }
259
+ async drain() {
260
+ clearTimeout(this.timer);
261
+ this.timer = undefined;
262
+ let deadline;
263
+ let wake;
264
+ const drained = new Promise((done) => {
265
+ wake = () => {
266
+ if (!this.pending.size)
267
+ done();
268
+ };
269
+ this.wake.add(wake);
270
+ wake();
271
+ });
272
+ try {
273
+ this.flush();
274
+ await Promise.race([
275
+ drained,
276
+ new Promise((done) => {
277
+ deadline = setTimeout(done, Math.max(0, this.timeoutMs));
278
+ }),
279
+ ]);
280
+ }
281
+ finally {
282
+ this.stopped = true;
283
+ clearTimeout(deadline);
284
+ clearTimeout(this.timer);
285
+ this.wake.delete(wake);
286
+ if (this.pending.size)
287
+ this.warn('pool quota drain timed out; pending readings left', {
288
+ accounts: this.pending.size,
289
+ readings: [...this.pending.values()].reduce((sum, queue) => sum + queue.length, 0),
290
+ });
291
+ this.pending.clear();
292
+ // A reading waiting for room in a full queue is refused as closed when
293
+ // the drain ends, not when its own lock budget runs out.
294
+ for (const wake of this.wake)
295
+ wake();
296
+ }
297
+ }
298
+ }
@@ -1,3 +1,4 @@
1
+ import type { Attribution } from './attribution.js';
1
2
  import { type PoolOperation, PoolOperationError } from './errors.js';
2
3
  import { type ReadResult, type StoreContext } from './mutate.js';
3
4
  import type { PoolLockOptions, PoolLockSpec } from './refresh-lock.js';
@@ -10,6 +11,7 @@ export interface StoreRuntime {
10
11
  providerLock: PoolLockSpec;
11
12
  rowLockOptions: Partial<PoolLockOptions>;
12
13
  firePull(id: string, reason: PullReason): void;
14
+ publishQuota?: (id: string, attribution: Attribution, observation: unknown) => Promise<void>;
13
15
  }
14
16
  /**
15
17
  * The row lock's (name, path): keyed by the row's recorded wire identity when
@@ -1 +1 @@
1
- {"version":3,"file":"pre-response-deadline.d.ts","sourceRoot":"","sources":["../src/pre-response-deadline.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB,SAAU,CAAA;AAG/C,eAAO,MAAM,4BAA4B,wHAC8E,CAAA;AAEvH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,OAAM;IACnB,QAAQ,CAAC,MAAM,yBAAwB;IACvC,QAAQ,CAAC,MAAM,0BAAyB;;CAMzC;AAED,wBAAgB,0BAA0B,IAAI,QAAQ,CAWrD;AAED,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,GAAG,IAAI,MAAM,CAAA;IACb,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAAA;CAC5D;AAWD,+EAA+E;AAC/E,qBAAa,mBAAmB;IAU5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAVvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;gBAGnC,MAAM,CAAC,GAAE,WAAW,GAAG,IAAI,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,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;gBAGnC,MAAM,CAAC,GAAE,WAAW,GAAG,IAAI,aAAA,EAC3B,IAAI,GAAE,gBAAwB;IAcjD,WAAW,IAAI,MAAM;IAIrB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI;IAS7C,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,MAAM;IAKd,KAAK,IAAI,IAAI;IAQb,aAAa,IAAI,IAAI;IAKrB,sBAAsB,IAAI,IAAI;IAM9B,MAAM,IAAI,IAAI;IAMd,2EAA2E;IAC3E,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAatD,iFAAiF;IAC3E,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAuBzD,OAAO,IAAI,IAAI;CAOhB"}
@@ -1,8 +1,9 @@
1
- // Measured through the native Antigravity CLI: Claude Opus 5.5 high sends
2
- // response headers within about 3 s and then streams its thinking, while
3
- // Gemini 3.8 Flash and Argon at high hold the headers until thinking ends
4
- // (5-6 s on short prompts). Ten minutes leaves wide headroom over both; it is
5
- // a backstop for an endpoint that never answers, not a thinking limit.
1
+ // Measured through the native Antigravity CLI (agy 1.4.5 for the long Gemini
2
+ // runs): Claude Opus 5.5 high sends response headers in 1.4-3.1 s, and Gemini
3
+ // 3.8 Flash high sends them in about 3.7 s even when it then thinks for 23-30k
4
+ // tokens over 50-66 s. Both stream their thinking after the headers. Ten
5
+ // minutes leaves wide headroom; it is a backstop for an endpoint that never
6
+ // answers, not a thinking limit.
6
7
  export const PRE_RESPONSE_DEADLINE_MS = 600_000;
7
8
  // Fixed text avoids status-code and quota phrases scanned by host retry policies.
8
9
  export const PRE_RESPONSE_TIMEOUT_MESSAGE = 'Antigravity did not begin a response within the pre-response time limit. Check your connection and try again later.';
@@ -1 +1 @@
1
- {"version":3,"file":"pre-response-deadline.js","sourceRoot":"","sources":["../src/pre-response-deadline.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,0EAA0E;AAC1E,8EAA8E;AAC9E,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAE/C,kFAAkF;AAClF,MAAM,CAAC,MAAM,4BAA4B,GACvC,qHAAqH,CAAA;AAEvH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,GAAG,GAAG,CAAA;IACV,MAAM,GAAG,qBAAqB,CAAA;IAC9B,MAAM,GAAG,sBAAsB,CAAA;IAExC;QACE,KAAK,CAAC,4BAA4B,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CAAC;QACb,KAAK,EAAE;YACL,IAAI,EAAE,GAAG;YACT,MAAM,EAAE,qBAAqB;YAC7B,OAAO,EAAE,4BAA4B;SACtC;KACF,CAAC,EACF,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,CACjE,CAAA;AACH,CAAC;AAQD,MAAM,KAAK,GAAqB;IAC9B,GAAG,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO;QACxB,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAC3C,K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,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;QAC5B,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,EAAE,CAAA;QACjD,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAA;IAC/B,CAAC;CACF"}
@@ -108,6 +108,7 @@ export interface RetrieveUserQuotaSummaryBucket {
108
108
  window: 'weekly' | '5h';
109
109
  resetTime: string;
110
110
  remainingFraction: number;
111
+ disabled?: boolean;
111
112
  description?: string;
112
113
  }
113
114
  export interface RetrieveUserQuotaSummaryGroup {
@@ -122,9 +123,8 @@ export interface RetrieveUserQuotaSummaryResponse {
122
123
  /**
123
124
  * Aggregate a retrieveUserQuotaSummary response into a QuotaSummary.
124
125
  *
125
- * Each RUQS group maps to a pool via bucketId prefix. Within a pool,
126
- * windows are stored shortest-first (5h before weekly, etc.). The pool's
127
- * `remainingFraction`/`resetTime` derive from the most-constrained window.
126
+ * Only known bucket IDs contribute. Their windows are merged across groups,
127
+ * stored shortest-first, and reduced to the most-constrained pool reading.
128
128
  */
129
129
  export declare function aggregateQuotaSummary(response: RetrieveUserQuotaSummaryResponse): QuotaSummary;
130
130
  export interface FetchQuotaSummaryOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"quota-manager.d.ts","sourceRoot":"","sources":["../src/quota-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAK3D,OAAO,KAAK,EACV,kBAAkB,EAElB,UAAU,EAEV,YAAY,EAEb,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,qCAAqC,QAAS,CAAA;AAC3D,eAAO,MAAM,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