@cortexkit/antigravity-auth-core 3.0.28 → 3.0.30

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 (38) hide show
  1. package/dist/account-selector.d.ts.map +1 -1
  2. package/dist/account-selector.js +26 -3
  3. package/dist/account-selector.js.map +1 -1
  4. package/dist/common-auth-embedded/claustrum/consumer.d.ts +12 -0
  5. package/dist/common-auth-embedded/claustrum/consumer.js +36 -0
  6. package/dist/common-auth-embedded/claustrum/custody.d.ts +16 -4
  7. package/dist/common-auth-embedded/claustrum/custody.js +74 -9
  8. package/dist/common-auth-embedded/claustrum/hub.d.ts +3 -2
  9. package/dist/common-auth-embedded/claustrum/hub.js +8 -0
  10. package/dist/common-auth-embedded/claustrum/index.d.ts +1 -0
  11. package/dist/common-auth-embedded/claustrum/roster.d.ts +2 -0
  12. package/dist/common-auth-embedded/claustrum/roster.js +2 -0
  13. package/dist/common-auth-embedded/claustrum/usage.d.ts +41 -0
  14. package/dist/common-auth-embedded/claustrum/usage.js +145 -0
  15. package/dist/common-auth-embedded/commands/builtins.d.ts +5 -0
  16. package/dist/common-auth-embedded/commands/builtins.js +38 -0
  17. package/dist/common-auth-embedded/fs/private-files.d.ts +5 -0
  18. package/dist/common-auth-embedded/fs/private-files.js +7 -0
  19. package/dist/common-auth-embedded/fs/refresh-file-lock.js +142 -47
  20. package/dist/common-auth-embedded/fs/with-lock.js +2 -5
  21. package/dist/common-auth-embedded/routing/admission.d.ts +7 -2
  22. package/dist/common-auth-embedded/routing/admission.js +17 -7
  23. package/dist/common-auth-embedded/source-output.json +126 -94
  24. package/dist/common-auth-embedded/store/attribution.js +3 -2
  25. package/dist/common-auth-embedded/store/errors.d.ts +1 -1
  26. package/dist/common-auth-embedded/store/hooks.d.ts +5 -1
  27. package/dist/common-auth-embedded/store/hooks.js +20 -5
  28. package/dist/common-auth-embedded/store/index.d.ts +1 -0
  29. package/dist/common-auth-embedded/store/limits-namespace.d.ts +7 -0
  30. package/dist/common-auth-embedded/store/limits-namespace.js +34 -0
  31. package/dist/common-auth-embedded/store/pool.d.ts +10 -1
  32. package/dist/common-auth-embedded/store/pool.js +2 -0
  33. package/dist/common-auth-embedded/store/provider-state.js +5 -5
  34. package/dist/common-auth-embedded/store/refresh.js +1 -1
  35. package/dist/common-auth-embedded/store/schema.js +9 -4
  36. package/dist/common-auth-embedded/store/settings.d.ts +2 -0
  37. package/dist/common-auth-embedded/store/settings.js +11 -4
  38. package/package.json +1 -1
@@ -23,11 +23,16 @@ export interface AdmissionInput extends ExclusionInputs {
23
23
  scope?: string;
24
24
  /** Labels the scope requires an entry for; defaults to `['primary']`. */
25
25
  requiredLabels?: readonly string[];
26
+ /**
27
+ * One-dispatch exemptions keyed by row; waive only gate 4. The caller first
28
+ * validates the current account incarnation and checkpointed reset times.
29
+ */
30
+ liftedWindows?: ReadonlyMap<string, readonly WindowRef[]>;
26
31
  now: number;
27
32
  /**
28
- * Called synchronously, once per refusal at gates 2 to 4, with the row id.
33
+ * Called synchronously once per row needing a pull, including lifted windows.
29
34
  * Its return value is ignored and never awaited, so a pull the caller
30
- * starts from here cannot delay the refusal.
35
+ * starts from here cannot delay admission or a refusal.
31
36
  */
32
37
  requestPull?: (rowId: string) => void;
33
38
  }
@@ -14,7 +14,7 @@
14
14
  // 3. a required label with no entry is unknown: refused, pull requested;
15
15
  // 4. a reading at or beyond 100% whose reset is missing, unparsable or not
16
16
  // after `now` cannot confirm the exhaustion, so the window is unknown:
17
- // refused, pull requested;
17
+ // refused unless lifted for this wake dispatch; either way, pull requested;
18
18
  // 5. a reading at or beyond 100% with a future reset is exhausted: refused.
19
19
  // Gates 4 and 5 look at every projected limit, not only the required labels.
20
20
  // Stage 2 judges the credit budget across the stage-1 survivors: a row whose
@@ -36,7 +36,7 @@ export function exclusionFor(id, inputs, now) {
36
36
  }
37
37
  return undefined;
38
38
  }
39
- function judgeStageOne(id, projection, requiredLabels, now) {
39
+ function judgeStageOne(id, projection, requiredLabels, now, liftedWindows) {
40
40
  if (projection.limits.length === 0) {
41
41
  return {
42
42
  id,
@@ -60,7 +60,8 @@ function judgeStageOne(id, projection, requiredLabels, now) {
60
60
  }
61
61
  const exhausted = projection.limits.filter(readsExhausted);
62
62
  for (const limit of exhausted) {
63
- if (futureResetAt(limit, now) === undefined) {
63
+ if (futureResetAt(limit, now) === undefined &&
64
+ !liftedWindows.some((window) => window.scope === limit.scope && window.label === limit.label)) {
64
65
  return {
65
66
  id,
66
67
  stage: 1,
@@ -94,6 +95,7 @@ export function admit(input) {
94
95
  const excluded = [];
95
96
  const refused = [];
96
97
  const survivors = [];
98
+ const needsPull = new Set();
97
99
  for (const row of input.rows) {
98
100
  const exclusion = exclusionFor(row.id, input, input.now);
99
101
  if (exclusion) {
@@ -105,7 +107,12 @@ export function admit(input) {
105
107
  continue;
106
108
  }
107
109
  const projection = projectQuota(row.quota, scope);
108
- const refusal = judgeStageOne(row.id, projection, requiredLabels, input.now);
110
+ const lifted = input.liftedWindows?.get(row.id) ?? [];
111
+ if (projection.limits.some((limit) => readsExhausted(limit) &&
112
+ futureResetAt(limit, input.now) === undefined &&
113
+ lifted.some((window) => window.scope === limit.scope && window.label === limit.label)))
114
+ needsPull.add(row.id);
115
+ const refusal = judgeStageOne(row.id, projection, requiredLabels, input.now, lifted);
109
116
  if (refusal) {
110
117
  refused.push(refusal);
111
118
  continue;
@@ -133,9 +140,12 @@ export function admit(input) {
133
140
  const order = new Map(input.rows.map((row, index) => [row.id, index]));
134
141
  const byInput = (left, right) => (order.get(left.id) ?? 0) - (order.get(right.id) ?? 0);
135
142
  refused.sort(byInput);
136
- const pulls = refused
137
- .filter((refusal) => 'pullRequested' in refusal)
138
- .map((refusal) => refusal.id);
143
+ for (const refusal of refused)
144
+ if ('pullRequested' in refusal)
145
+ needsPull.add(refusal.id);
146
+ const pulls = input.rows
147
+ .filter((row) => needsPull.has(row.id))
148
+ .map((row) => row.id);
139
149
  for (const id of pulls)
140
150
  input.requestPull?.(id);
141
151
  return { admitted, refused, excluded, pulls };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.33.0",
4
+ "version": "0.34.0",
5
5
  "artifactStatus": "published",
6
6
  "publicRoots": {
7
7
  "./store": {
@@ -37,15 +37,15 @@
37
37
  "import": "./dist/pi-slot/index.js"
38
38
  }
39
39
  },
40
- "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.33.0.tgz",
41
- "tarballSha256": "bba9f56f7fb353c9c712113722c7c9361f0e13e930c73f57314185b13032a24c",
42
- "sri": "sha512-cbbyqXTK1TYQZNHb2xA/ueZGQsBvAX6H9hTlQcZZxM7SR/u7tsscyBAWw38ViXl1n/gwkqgsvs2Vbs6cZ0hOrw==",
43
- "canonicalFiles": 147,
44
- "canonicalBytes": 1003209,
40
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.34.0.tgz",
41
+ "tarballSha256": "381a0a78b6ca4873922ce1be1378c5b891136686a5ba85ffe6d39c6a2624f549",
42
+ "sri": "sha512-5V9MnqLQPPNNDdHm17Vluzlc2WDiFUJaUUG3Uw/q/tDPfBYd6L1QqTCkFaTrh1dbDrCjwSPsIYBQwUBxSkViSw==",
43
+ "canonicalFiles": 151,
44
+ "canonicalBytes": 1028206,
45
45
  "generator": {
46
46
  "path": "packages/opencode/scripts/embed-common-auth.ts",
47
47
  "version": 4,
48
- "sha256": "9f9ebaeb47c9c18874ed832504422c0791551627c34092885cb481c6fe23ef19"
48
+ "sha256": "905b90777add2c69e77c300f4a63690a612548e419ac5b7e8302edd1c7506774"
49
49
  },
50
50
  "files": [
51
51
  {
@@ -227,33 +227,33 @@
227
227
  {
228
228
  "source": "package/dist/claustrum/consumer.d.ts",
229
229
  "output": "claustrum/consumer.d.ts",
230
- "bytes": 13934,
231
- "sourceSha256": "97e5fb096153912483b45f75831e4652db19457d94ad76ba8363b1fd232e6fd7",
232
- "outputSha256": "97e5fb096153912483b45f75831e4652db19457d94ad76ba8363b1fd232e6fd7",
230
+ "bytes": 14463,
231
+ "sourceSha256": "e721acf3ff3e92d444b5d8eceb800fd3d958838adaec01fb99d29d0fa97a9f66",
232
+ "outputSha256": "e721acf3ff3e92d444b5d8eceb800fd3d958838adaec01fb99d29d0fa97a9f66",
233
233
  "transform": "verbatim"
234
234
  },
235
235
  {
236
236
  "source": "package/dist/claustrum/consumer.js",
237
237
  "output": "claustrum/consumer.js",
238
- "bytes": 39439,
239
- "sourceSha256": "3b4cf06be8732f3183ac97721dfffb8fc489d4be1044260742a72a9995324391",
240
- "outputSha256": "3b4cf06be8732f3183ac97721dfffb8fc489d4be1044260742a72a9995324391",
238
+ "bytes": 40784,
239
+ "sourceSha256": "997939488c6bc63248301b04a68beaa07fb3181eb480d360f453156919e78a61",
240
+ "outputSha256": "997939488c6bc63248301b04a68beaa07fb3181eb480d360f453156919e78a61",
241
241
  "transform": "verbatim"
242
242
  },
243
243
  {
244
244
  "source": "package/dist/claustrum/custody.d.ts",
245
245
  "output": "claustrum/custody.d.ts",
246
- "bytes": 16390,
247
- "sourceSha256": "3bbbfc2d700cf6c25356339c64d3bef5cee5e00336d141de18bb7522c8a5ceaa",
248
- "outputSha256": "3bbbfc2d700cf6c25356339c64d3bef5cee5e00336d141de18bb7522c8a5ceaa",
246
+ "bytes": 17055,
247
+ "sourceSha256": "552f0e35eb8364b23974247f2cb1024b9416c9b544a52004a9784cc1da935a76",
248
+ "outputSha256": "552f0e35eb8364b23974247f2cb1024b9416c9b544a52004a9784cc1da935a76",
249
249
  "transform": "verbatim"
250
250
  },
251
251
  {
252
252
  "source": "package/dist/claustrum/custody.js",
253
253
  "output": "claustrum/custody.js",
254
- "bytes": 31616,
255
- "sourceSha256": "5ed70e65b78a04ceec3b3430908f46c860ea768b779b6af0f925681fd786593d",
256
- "outputSha256": "5ed70e65b78a04ceec3b3430908f46c860ea768b779b6af0f925681fd786593d",
254
+ "bytes": 34066,
255
+ "sourceSha256": "cd592a37fdf006465a8043dea6a6926374a238e47d80488b21774168b9c6398e",
256
+ "outputSha256": "cd592a37fdf006465a8043dea6a6926374a238e47d80488b21774168b9c6398e",
257
257
  "transform": "verbatim"
258
258
  },
259
259
  {
@@ -307,25 +307,25 @@
307
307
  {
308
308
  "source": "package/dist/claustrum/hub.d.ts",
309
309
  "output": "claustrum/hub.d.ts",
310
- "bytes": 9346,
311
- "sourceSha256": "4c2cbd91b3cc9691ee765f766b7c80d27cf28b38494a0a53ce9410c184e7ca1d",
312
- "outputSha256": "4c2cbd91b3cc9691ee765f766b7c80d27cf28b38494a0a53ce9410c184e7ca1d",
310
+ "bytes": 9460,
311
+ "sourceSha256": "53b70b25379837557d5efa32f77bce4a0e7a7cde4ac641e614105a1c53b57e59",
312
+ "outputSha256": "53b70b25379837557d5efa32f77bce4a0e7a7cde4ac641e614105a1c53b57e59",
313
313
  "transform": "verbatim"
314
314
  },
315
315
  {
316
316
  "source": "package/dist/claustrum/hub.js",
317
317
  "output": "claustrum/hub.js",
318
- "bytes": 45993,
319
- "sourceSha256": "e50ebf6bcf840f8a4229d219ecb20fc1422c74b5b3aa2034dff0b73852380b79",
320
- "outputSha256": "e50ebf6bcf840f8a4229d219ecb20fc1422c74b5b3aa2034dff0b73852380b79",
318
+ "bytes": 46281,
319
+ "sourceSha256": "cc0b1037ebc53a10b2152395150547ba106bb393d69a9ed191f6d7c0d1574ce1",
320
+ "outputSha256": "cc0b1037ebc53a10b2152395150547ba106bb393d69a9ed191f6d7c0d1574ce1",
321
321
  "transform": "verbatim"
322
322
  },
323
323
  {
324
324
  "source": "package/dist/claustrum/index.d.ts",
325
325
  "output": "claustrum/index.d.ts",
326
- "bytes": 4728,
327
- "sourceSha256": "524bec258d060b75e6aeefa1e39e102e9ad7370e6c74ba2c033fcc418a1db4d7",
328
- "outputSha256": "524bec258d060b75e6aeefa1e39e102e9ad7370e6c74ba2c033fcc418a1db4d7",
326
+ "bytes": 4813,
327
+ "sourceSha256": "fcb49372b68cf2488b1750f46036264e1b61eb03f7b2b352e472c53e7244d876",
328
+ "outputSha256": "fcb49372b68cf2488b1750f46036264e1b61eb03f7b2b352e472c53e7244d876",
329
329
  "transform": "verbatim"
330
330
  },
331
331
  {
@@ -387,17 +387,17 @@
387
387
  {
388
388
  "source": "package/dist/claustrum/roster.d.ts",
389
389
  "output": "claustrum/roster.d.ts",
390
- "bytes": 15102,
391
- "sourceSha256": "30fc3b4d572e43a08a700ff169ebcb52206d1200f7ca678d2bff0a3369aaa005",
392
- "outputSha256": "30fc3b4d572e43a08a700ff169ebcb52206d1200f7ca678d2bff0a3369aaa005",
390
+ "bytes": 15204,
391
+ "sourceSha256": "bdc509706fadf7b5efc5e216d236e22a88ec900b1c388064f36528230190b1a8",
392
+ "outputSha256": "bdc509706fadf7b5efc5e216d236e22a88ec900b1c388064f36528230190b1a8",
393
393
  "transform": "verbatim"
394
394
  },
395
395
  {
396
396
  "source": "package/dist/claustrum/roster.js",
397
397
  "output": "claustrum/roster.js",
398
- "bytes": 39340,
399
- "sourceSha256": "6919aa948f9022f76ce2b7aac83733bd7a11a8c21b8511191cf7fbf6bc1a2b30",
400
- "outputSha256": "6919aa948f9022f76ce2b7aac83733bd7a11a8c21b8511191cf7fbf6bc1a2b30",
398
+ "bytes": 39485,
399
+ "sourceSha256": "7bb50959141396cc5519d352b144b262229412fc44f7e873c1504e75a74c0964",
400
+ "outputSha256": "7bb50959141396cc5519d352b144b262229412fc44f7e873c1504e75a74c0964",
401
401
  "transform": "verbatim"
402
402
  },
403
403
  {
@@ -408,6 +408,22 @@
408
408
  "outputSha256": "6ccb19ab5e9bb84a978cb47a32b443abe432b4edfe69a318e45bb404ef75c45e",
409
409
  "transform": "verbatim"
410
410
  },
411
+ {
412
+ "source": "package/dist/claustrum/usage.d.ts",
413
+ "output": "claustrum/usage.d.ts",
414
+ "bytes": 1451,
415
+ "sourceSha256": "21e836ab0303511fe68ccd48a661b5d0f65573be432b5b45955953a9c7bdbab4",
416
+ "outputSha256": "21e836ab0303511fe68ccd48a661b5d0f65573be432b5b45955953a9c7bdbab4",
417
+ "transform": "verbatim"
418
+ },
419
+ {
420
+ "source": "package/dist/claustrum/usage.js",
421
+ "output": "claustrum/usage.js",
422
+ "bytes": 5373,
423
+ "sourceSha256": "1e7c31cd67709503afe5329fa67e3b68317427e4572a89e24cbb8cb151c80028",
424
+ "outputSha256": "1e7c31cd67709503afe5329fa67e3b68317427e4572a89e24cbb8cb151c80028",
425
+ "transform": "verbatim"
426
+ },
411
427
  {
412
428
  "source": "package/dist/claustrum/watch.d.ts",
413
429
  "output": "claustrum/watch.d.ts",
@@ -427,17 +443,17 @@
427
443
  {
428
444
  "source": "package/dist/commands/builtins.d.ts",
429
445
  "output": "commands/builtins.d.ts",
430
- "bytes": 4576,
431
- "sourceSha256": "5ab6cbab696c91fef0fc7288d4b82803cd0bac809b68f939d73671505fc1d894",
432
- "outputSha256": "5ab6cbab696c91fef0fc7288d4b82803cd0bac809b68f939d73671505fc1d894",
446
+ "bytes": 4780,
447
+ "sourceSha256": "2eb3e45f6dd65ad428edaef54864d6b506aa837237958e392b95dacaca131bac",
448
+ "outputSha256": "2eb3e45f6dd65ad428edaef54864d6b506aa837237958e392b95dacaca131bac",
433
449
  "transform": "verbatim"
434
450
  },
435
451
  {
436
452
  "source": "package/dist/commands/builtins.js",
437
453
  "output": "commands/builtins.js",
438
- "bytes": 25155,
439
- "sourceSha256": "c5f7fca0e36dc2f3253b88e7600d3dbed6a193d2b8abbf07d16913b6b46551e6",
440
- "outputSha256": "c5f7fca0e36dc2f3253b88e7600d3dbed6a193d2b8abbf07d16913b6b46551e6",
454
+ "bytes": 26747,
455
+ "sourceSha256": "5817f3451022ce2f1b8f8ebb3b4918d2853b1de448b5365e134cf4d36c4c6063",
456
+ "outputSha256": "5817f3451022ce2f1b8f8ebb3b4918d2853b1de448b5365e134cf4d36c4c6063",
441
457
  "transform": "verbatim"
442
458
  },
443
459
  {
@@ -579,17 +595,17 @@
579
595
  {
580
596
  "source": "package/dist/fs/private-files.d.ts",
581
597
  "output": "fs/private-files.d.ts",
582
- "bytes": 3398,
583
- "sourceSha256": "b344509a32fcd983f09e5814286630a53c8e577ad1b973eabe19f8e58659e8d3",
584
- "outputSha256": "b344509a32fcd983f09e5814286630a53c8e577ad1b973eabe19f8e58659e8d3",
598
+ "bytes": 3632,
599
+ "sourceSha256": "5d8cabba3b26becd458e201309802e57dffa371b1026468a06edf770ed4f0a4e",
600
+ "outputSha256": "5d8cabba3b26becd458e201309802e57dffa371b1026468a06edf770ed4f0a4e",
585
601
  "transform": "verbatim"
586
602
  },
587
603
  {
588
604
  "source": "package/dist/fs/private-files.js",
589
605
  "output": "fs/private-files.js",
590
- "bytes": 14779,
591
- "sourceSha256": "114c06ce4c0998087878d99c5dc37425e90d5fad205f57fe0bdf9694e3c8e31d",
592
- "outputSha256": "114c06ce4c0998087878d99c5dc37425e90d5fad205f57fe0bdf9694e3c8e31d",
606
+ "bytes": 15098,
607
+ "sourceSha256": "d26406b3fd7c4452905c4afe2da1e24c8079a20b89a449d2af45e95c4b5cc189",
608
+ "outputSha256": "d26406b3fd7c4452905c4afe2da1e24c8079a20b89a449d2af45e95c4b5cc189",
593
609
  "transform": "verbatim"
594
610
  },
595
611
  {
@@ -603,9 +619,9 @@
603
619
  {
604
620
  "source": "package/dist/fs/refresh-file-lock.js",
605
621
  "output": "fs/refresh-file-lock.js",
606
- "bytes": 37831,
607
- "sourceSha256": "e0fdcc7a45548f3c88ea49bbe000f6e4022fb9c219f0510aa934492adb72a505",
608
- "outputSha256": "e0fdcc7a45548f3c88ea49bbe000f6e4022fb9c219f0510aa934492adb72a505",
622
+ "bytes": 42093,
623
+ "sourceSha256": "a91c34ec1dcac86a816a70359a16e27bf5f8a52cb12f9e1d8162548bbcd69d4e",
624
+ "outputSha256": "a91c34ec1dcac86a816a70359a16e27bf5f8a52cb12f9e1d8162548bbcd69d4e",
609
625
  "transform": "verbatim"
610
626
  },
611
627
  {
@@ -619,9 +635,9 @@
619
635
  {
620
636
  "source": "package/dist/fs/with-lock.js",
621
637
  "output": "fs/with-lock.js",
622
- "bytes": 3003,
623
- "sourceSha256": "690fb43c6a0eb6a02eac024b8b58caa39775a37d0064118dab879a0e5ac8c996",
624
- "outputSha256": "690fb43c6a0eb6a02eac024b8b58caa39775a37d0064118dab879a0e5ac8c996",
638
+ "bytes": 2855,
639
+ "sourceSha256": "25f4789fc118e10a72f7e687f083eb1212eca06d4fe2c7bfe6f0d773f2abf351",
640
+ "outputSha256": "25f4789fc118e10a72f7e687f083eb1212eca06d4fe2c7bfe6f0d773f2abf351",
625
641
  "transform": "verbatim"
626
642
  },
627
643
  {
@@ -851,17 +867,17 @@
851
867
  {
852
868
  "source": "package/dist/routing/admission.d.ts",
853
869
  "output": "routing/admission.d.ts",
854
- "bytes": 2793,
855
- "sourceSha256": "89bce677803fb17e427bb2b487a1861343c2b03e1981b4d47711484d90d27ff7",
856
- "outputSha256": "89bce677803fb17e427bb2b487a1861343c2b03e1981b4d47711484d90d27ff7",
870
+ "bytes": 3046,
871
+ "sourceSha256": "060b65e47133e58c0d651441675162335f19a1107ec84b1cd0060ec57d71e94c",
872
+ "outputSha256": "060b65e47133e58c0d651441675162335f19a1107ec84b1cd0060ec57d71e94c",
857
873
  "transform": "verbatim"
858
874
  },
859
875
  {
860
876
  "source": "package/dist/routing/admission.js",
861
877
  "output": "routing/admission.js",
862
- "bytes": 5773,
863
- "sourceSha256": "745745ddca9bb590fc02f09f2c0ba93caf5b45af1ed992d15c6700cff551b6f0",
864
- "outputSha256": "745745ddca9bb590fc02f09f2c0ba93caf5b45af1ed992d15c6700cff551b6f0",
878
+ "bytes": 6417,
879
+ "sourceSha256": "95b93ca3848fa5a28df6f3a8e07594c0f6185bfc11c52811dd8ae03394ec8d6e",
880
+ "outputSha256": "95b93ca3848fa5a28df6f3a8e07594c0f6185bfc11c52811dd8ae03394ec8d6e",
865
881
  "transform": "verbatim"
866
882
  },
867
883
  {
@@ -939,17 +955,17 @@
939
955
  {
940
956
  "source": "package/dist/store/attribution.js",
941
957
  "output": "store/attribution.js",
942
- "bytes": 3280,
943
- "sourceSha256": "5b54980a4f158c9b61cd90c4a83a14e83268fe98101fc88409500bb73d1126bb",
944
- "outputSha256": "5b54980a4f158c9b61cd90c4a83a14e83268fe98101fc88409500bb73d1126bb",
958
+ "bytes": 3369,
959
+ "sourceSha256": "ff0dde02e4b14ae66ee7cea0919f271e0e407cb44508961fb64c3288f347db32",
960
+ "outputSha256": "ff0dde02e4b14ae66ee7cea0919f271e0e407cb44508961fb64c3288f347db32",
945
961
  "transform": "verbatim"
946
962
  },
947
963
  {
948
964
  "source": "package/dist/store/errors.d.ts",
949
965
  "output": "store/errors.d.ts",
950
- "bytes": 3191,
951
- "sourceSha256": "3f056ce51fd8bfa503604421df8b562a49154dc77dbe69b497e972787bc2e34f",
952
- "outputSha256": "3f056ce51fd8bfa503604421df8b562a49154dc77dbe69b497e972787bc2e34f",
966
+ "bytes": 3217,
967
+ "sourceSha256": "e2ff1c6c60043137a5dceeb0bfe8cceb7f788bd34d43c4b6842aafdab8f8024e",
968
+ "outputSha256": "e2ff1c6c60043137a5dceeb0bfe8cceb7f788bd34d43c4b6842aafdab8f8024e",
953
969
  "transform": "verbatim"
954
970
  },
955
971
  {
@@ -963,17 +979,17 @@
963
979
  {
964
980
  "source": "package/dist/store/hooks.d.ts",
965
981
  "output": "store/hooks.d.ts",
966
- "bytes": 751,
967
- "sourceSha256": "38739bc4d1cd5e40df1dcbed711c97b813c3b1540aad575fb9decc563012129d",
968
- "outputSha256": "38739bc4d1cd5e40df1dcbed711c97b813c3b1540aad575fb9decc563012129d",
982
+ "bytes": 1067,
983
+ "sourceSha256": "8ebc33dfd6ff7069edc7a06e339edc85101e05d54bbe825257fe2a05c801d1eb",
984
+ "outputSha256": "8ebc33dfd6ff7069edc7a06e339edc85101e05d54bbe825257fe2a05c801d1eb",
969
985
  "transform": "verbatim"
970
986
  },
971
987
  {
972
988
  "source": "package/dist/store/hooks.js",
973
989
  "output": "store/hooks.js",
974
- "bytes": 1269,
975
- "sourceSha256": "fa28be455f27671d530edf15773262398689295e28c28aef0ff9c1142c7f93b5",
976
- "outputSha256": "fa28be455f27671d530edf15773262398689295e28c28aef0ff9c1142c7f93b5",
990
+ "bytes": 1947,
991
+ "sourceSha256": "f5a5b5cddbe648c0d09e586cd73a236ab829aece9ce283e42c6f648164f17155",
992
+ "outputSha256": "f5a5b5cddbe648c0d09e586cd73a236ab829aece9ce283e42c6f648164f17155",
977
993
  "transform": "verbatim"
978
994
  },
979
995
  {
@@ -995,9 +1011,9 @@
995
1011
  {
996
1012
  "source": "package/dist/store/index.d.ts",
997
1013
  "output": "store/index.d.ts",
998
- "bytes": 2061,
999
- "sourceSha256": "ea8c2f617489679e3360840a892523601a32c4f448f5ee930145a4f00ce3ba3b",
1000
- "outputSha256": "ea8c2f617489679e3360840a892523601a32c4f448f5ee930145a4f00ce3ba3b",
1014
+ "bytes": 2140,
1015
+ "sourceSha256": "b7ca320852823a6020fc0bd90aecbe65feac7a0bb4b9e289a731229bd6573f55",
1016
+ "outputSha256": "b7ca320852823a6020fc0bd90aecbe65feac7a0bb4b9e289a731229bd6573f55",
1001
1017
  "transform": "verbatim"
1002
1018
  },
1003
1019
  {
@@ -1008,6 +1024,22 @@
1008
1024
  "outputSha256": "ec9782b6e92e9fb2fe3b17b13d5dbbed0792c30cd0f04b84c1cdaa642f785db8",
1009
1025
  "transform": "verbatim"
1010
1026
  },
1027
+ {
1028
+ "source": "package/dist/store/limits-namespace.d.ts",
1029
+ "output": "store/limits-namespace.d.ts",
1030
+ "bytes": 591,
1031
+ "sourceSha256": "ce194a0f3442f710af0077c567996240a9b97a9c997134eccf833f455fa7cc42",
1032
+ "outputSha256": "ce194a0f3442f710af0077c567996240a9b97a9c997134eccf833f455fa7cc42",
1033
+ "transform": "verbatim"
1034
+ },
1035
+ {
1036
+ "source": "package/dist/store/limits-namespace.js",
1037
+ "output": "store/limits-namespace.js",
1038
+ "bytes": 1565,
1039
+ "sourceSha256": "320f89844d4dabc396145ea6388a444bd2f8f93d3b3d3d0c03bde0f117554ab6",
1040
+ "outputSha256": "320f89844d4dabc396145ea6388a444bd2f8f93d3b3d3d0c03bde0f117554ab6",
1041
+ "transform": "verbatim"
1042
+ },
1011
1043
  {
1012
1044
  "source": "package/dist/store/mutate.d.ts",
1013
1045
  "output": "store/mutate.d.ts",
@@ -1027,17 +1059,17 @@
1027
1059
  {
1028
1060
  "source": "package/dist/store/pool.d.ts",
1029
1061
  "output": "store/pool.d.ts",
1030
- "bytes": 12144,
1031
- "sourceSha256": "64d6e7dd5600f436422e6d309a22b7f874a6afdd866873226ab1f4d5091ebc43",
1032
- "outputSha256": "64d6e7dd5600f436422e6d309a22b7f874a6afdd866873226ab1f4d5091ebc43",
1062
+ "bytes": 12691,
1063
+ "sourceSha256": "c97a802739d95ad6932ee10e87afad9cbe357e6e5605a8027c5d51b42dbccae4",
1064
+ "outputSha256": "c97a802739d95ad6932ee10e87afad9cbe357e6e5605a8027c5d51b42dbccae4",
1033
1065
  "transform": "verbatim"
1034
1066
  },
1035
1067
  {
1036
1068
  "source": "package/dist/store/pool.js",
1037
1069
  "output": "store/pool.js",
1038
- "bytes": 6358,
1039
- "sourceSha256": "1503b5c0f461678f9710a5fe22e345092de70e537a114e57b0cb651795928031",
1040
- "outputSha256": "1503b5c0f461678f9710a5fe22e345092de70e537a114e57b0cb651795928031",
1070
+ "bytes": 6510,
1071
+ "sourceSha256": "94ec36a37ceee242ddb1032414600f7c77def8775eb8c48b6e2d994c9911ba5c",
1072
+ "outputSha256": "94ec36a37ceee242ddb1032414600f7c77def8775eb8c48b6e2d994c9911ba5c",
1041
1073
  "transform": "verbatim"
1042
1074
  },
1043
1075
  {
@@ -1051,9 +1083,9 @@
1051
1083
  {
1052
1084
  "source": "package/dist/store/provider-state.js",
1053
1085
  "output": "store/provider-state.js",
1054
- "bytes": 11543,
1055
- "sourceSha256": "755ba874f216cb91e3df39a084b991034f529596d2e75cd1ccc1884623ed7b40",
1056
- "outputSha256": "755ba874f216cb91e3df39a084b991034f529596d2e75cd1ccc1884623ed7b40",
1086
+ "bytes": 11627,
1087
+ "sourceSha256": "9a4457d1b74ed61fb5442cff6f327175f65daca9dd9fd5c3a578c0e000191d2a",
1088
+ "outputSha256": "9a4457d1b74ed61fb5442cff6f327175f65daca9dd9fd5c3a578c0e000191d2a",
1057
1089
  "transform": "verbatim"
1058
1090
  },
1059
1091
  {
@@ -1123,9 +1155,9 @@
1123
1155
  {
1124
1156
  "source": "package/dist/store/refresh.js",
1125
1157
  "output": "store/refresh.js",
1126
- "bytes": 10645,
1127
- "sourceSha256": "698ad72c223ba36eda5005078e4303e726d9d9b8f3407c07b72ffa777466252c",
1128
- "outputSha256": "698ad72c223ba36eda5005078e4303e726d9d9b8f3407c07b72ffa777466252c",
1158
+ "bytes": 10651,
1159
+ "sourceSha256": "6c62f81df966e697d90f0674751de0abf34a5f1af440994bd84acad776c999ad",
1160
+ "outputSha256": "6c62f81df966e697d90f0674751de0abf34a5f1af440994bd84acad776c999ad",
1129
1161
  "transform": "verbatim"
1130
1162
  },
1131
1163
  {
@@ -1179,25 +1211,25 @@
1179
1211
  {
1180
1212
  "source": "package/dist/store/schema.js",
1181
1213
  "output": "store/schema.js",
1182
- "bytes": 31533,
1183
- "sourceSha256": "ae55f6f875ff8a9e9a09795eac1bedfd4bf795bd6802e8de37b52586b61208d0",
1184
- "outputSha256": "ae55f6f875ff8a9e9a09795eac1bedfd4bf795bd6802e8de37b52586b61208d0",
1214
+ "bytes": 31711,
1215
+ "sourceSha256": "a9c91e1da2d0b1c8f2afd022a12af3c62d8a3f627e100af79bd7b22b4b5f0f29",
1216
+ "outputSha256": "a9c91e1da2d0b1c8f2afd022a12af3c62d8a3f627e100af79bd7b22b4b5f0f29",
1185
1217
  "transform": "verbatim"
1186
1218
  },
1187
1219
  {
1188
1220
  "source": "package/dist/store/settings.d.ts",
1189
1221
  "output": "store/settings.d.ts",
1190
- "bytes": 2994,
1191
- "sourceSha256": "32446dea1f8431e3fb7e38940d1dec7259dbd5c794b4117efe3875be92405fef",
1192
- "outputSha256": "32446dea1f8431e3fb7e38940d1dec7259dbd5c794b4117efe3875be92405fef",
1222
+ "bytes": 3144,
1223
+ "sourceSha256": "a9ca8fd8d0729647b338ba2c160e09879faf5a363b548505d69da73a743e93b2",
1224
+ "outputSha256": "a9ca8fd8d0729647b338ba2c160e09879faf5a363b548505d69da73a743e93b2",
1193
1225
  "transform": "verbatim"
1194
1226
  },
1195
1227
  {
1196
1228
  "source": "package/dist/store/settings.js",
1197
1229
  "output": "store/settings.js",
1198
- "bytes": 5766,
1199
- "sourceSha256": "5ed4e0458800923b843b9b8f0671cca0c04cb26e428453e3bcc8b6d06b51470f",
1200
- "outputSha256": "5ed4e0458800923b843b9b8f0671cca0c04cb26e428453e3bcc8b6d06b51470f",
1230
+ "bytes": 6395,
1231
+ "sourceSha256": "5fb7fc8af7966be2aee5aca72fd863a9f78f5fed22ce33871145da07f4813b33",
1232
+ "outputSha256": "5fb7fc8af7966be2aee5aca72fd863a9f78f5fed22ce33871145da07f4813b33",
1201
1233
  "transform": "verbatim"
1202
1234
  },
1203
1235
  {
@@ -1,4 +1,5 @@
1
1
  import { PoolOperationError } from './errors.js';
2
+ import { runInsideCodec } from './hooks.js';
2
3
  import { toFailure, withTransaction, } from './mutate.js';
3
4
  import { LockStack } from './refresh-lock.js';
4
5
  import { refusal, requireBound, unknownRow, } from './runtime.js';
@@ -31,8 +32,8 @@ export function assertQuotaRow(id, attribution, row) {
31
32
  });
32
33
  }
33
34
  export function mergedQuota(ctx, id, stored, observation) {
34
- const merged = ctx.codec.merge(stored, observation);
35
- if (!ctx.codec.validate(merged))
35
+ const merged = runInsideCodec(() => ctx.codec.merge(stored, observation));
36
+ if (!runInsideCodec(() => ctx.codec.validate(merged)))
36
37
  throw refusal('pull', id, 'invalid-quota', 'the quota codec rejected the merged map');
37
38
  return merged;
38
39
  }
@@ -1,6 +1,6 @@
1
1
  import type { StoredCredential } from './schema.js';
2
2
  /** Every library operation that can fail, as named in the failure value. */
3
- export type PoolOperation = 'initialize' | 'add' | 'replace' | 'rotate' | 'disable' | 'enable' | 'remove' | 'reorder' | 'updateSettings' | 'recordIdentity' | 'updateProviderState' | 'refresh' | 'pull' | 'publishRoster';
3
+ export type PoolOperation = 'initialize' | 'add' | 'replace' | 'rotate' | 'disable' | 'enable' | 'remove' | 'reorder' | 'updateSettings' | 'updateLimitsNamespace' | 'recordIdentity' | 'updateProviderState' | 'refresh' | 'pull' | 'publishRoster';
4
4
  /**
5
5
  * How far an operation got before it failed.
6
6
  *
@@ -1,7 +1,11 @@
1
1
  import { type PoolOperation } from './errors.js';
2
2
  /** Refuses a row operation or refresh called from inside a hook. */
3
3
  export declare function assertNotInsideHook(operation: PoolOperation): void;
4
- export declare function runInsideHook<T>(operation: PoolOperation, fn: () => Promise<T> | T): Promise<T>;
4
+ /** Namespace writes need only the store locks, not the row lock a hook may retain. */
5
+ export declare function assertLimitsWriteAllowed(): void;
6
+ /** Codecs may run under store locks even when no asynchronous hook is active. */
7
+ export declare function runInsideCodec<T>(fn: () => T): T;
8
+ export declare function runInsideHook<T>(operation: PoolOperation, fn: () => Promise<T> | T, storeLocksReleased?: boolean): Promise<T>;
5
9
  export interface PoolLogger {
6
10
  warn(message: string, data?: unknown): void;
7
11
  }
@@ -1,18 +1,33 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import { PoolReentryError } from './errors.js';
3
3
  /**
4
- * Set while a hook of a lock-holding operation runs. Async context is
5
- * inherited by every timer, promise and continuation created inside the hook,
4
+ * Set while a store hook runs, recording whether its store locks are released.
5
+ * Async context is inherited by every timer, promise and continuation inside the hook,
6
6
  * so work a hook schedules is inside the guarded region too.
7
7
  */
8
8
  const insideHook = new AsyncLocalStorage();
9
+ const insideCodec = new AsyncLocalStorage();
9
10
  /** Refuses a row operation or refresh called from inside a hook. */
10
11
  export function assertNotInsideHook(operation) {
11
12
  if (insideHook.getStore() !== undefined)
12
13
  throw new PoolReentryError(operation);
13
14
  }
14
- export function runInsideHook(operation, fn) {
15
- return insideHook.run(operation, async () => await fn());
15
+ /** Namespace writes need only the store locks, not the row lock a hook may retain. */
16
+ export function assertLimitsWriteAllowed() {
17
+ if (insideHook.getStore()?.storeLocksReleased === false ||
18
+ insideCodec.getStore())
19
+ throw new PoolReentryError('updateLimitsNamespace');
20
+ }
21
+ /** Codecs may run under store locks even when no asynchronous hook is active. */
22
+ export function runInsideCodec(fn) {
23
+ return insideCodec.run(true, fn);
24
+ }
25
+ export function runInsideHook(operation, fn, storeLocksReleased = false) {
26
+ return insideHook.run({
27
+ operation,
28
+ storeLocksReleased: storeLocksReleased &&
29
+ insideHook.getStore()?.storeLocksReleased !== false,
30
+ }, async () => await fn());
16
31
  }
17
32
  /**
18
33
  * Runs a failure hook. A hook that throws never replaces the failure it was
@@ -22,7 +37,7 @@ export async function callFailureHook(operation, hook, rowId, error, logger) {
22
37
  if (!hook)
23
38
  return;
24
39
  try {
25
- await runInsideHook(operation, () => hook(rowId, error));
40
+ await runInsideHook(operation, () => hook(rowId, error), true);
26
41
  }
27
42
  catch (hookError) {
28
43
  logger?.warn('store failure hook threw; the original failure stands', {
@@ -3,6 +3,7 @@ export type { PoolFailureKind, PoolFailurePhase, PoolOperation, } from './errors
3
3
  export { PoolOperationError, PoolReentryError } from './errors.js';
4
4
  export type { PoolLogger } from './hooks.js';
5
5
  export { countUnknownIdentityRows, DUPLICATE_IDENTITY_REASON, } from './identity.js';
6
+ export type { PoolLimitsMutator, PoolLimitsRow } from './limits-namespace.js';
6
7
  export type { HoldPoint, InitializeOutcome, WriteStep } from './mutate.js';
7
8
  export type { OpenPoolStoreOptions, PoolLoad, PoolStore, } from './pool.js';
8
9
  export { openPoolStore } from './pool.js';
@@ -0,0 +1,7 @@
1
+ import type { StoreRuntime } from './runtime.js';
2
+ import type { PoolRow } from './schema.js';
3
+ /** Row IDs, credential epochs and identities only; mutators never receive credentials. */
4
+ export type PoolLimitsRow = Pick<PoolRow, 'id' | 'credentialEpoch' | 'identity'>;
5
+ export type PoolLimitsMutator = (envelope: unknown, rows: readonly PoolLimitsRow[]) => unknown | Promise<unknown>;
6
+ /** A namespace merge and its check of current row bindings share one locked config snapshot. */
7
+ export declare function updatePoolLimitsNamespace(rt: StoreRuntime, mutator: PoolLimitsMutator): Promise<void>;