@cortexkit/common-auth 0.33.0 → 0.35.0

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 (108) hide show
  1. package/dist/claustrum/consumer.d.ts +12 -0
  2. package/dist/claustrum/consumer.js +36 -0
  3. package/dist/claustrum/custody.d.ts +16 -4
  4. package/dist/claustrum/custody.js +74 -9
  5. package/dist/claustrum/hub.d.ts +3 -2
  6. package/dist/claustrum/hub.js +8 -0
  7. package/dist/claustrum/index.d.ts +1 -0
  8. package/dist/claustrum/roster.d.ts +2 -0
  9. package/dist/claustrum/roster.js +2 -0
  10. package/dist/claustrum/usage.d.ts +41 -0
  11. package/dist/claustrum/usage.js +145 -0
  12. package/dist/commands/builtins.d.ts +5 -0
  13. package/dist/commands/builtins.js +38 -0
  14. package/dist/fs/private-files.d.ts +5 -0
  15. package/dist/fs/private-files.js +7 -0
  16. package/dist/fs/refresh-file-lock.js +142 -47
  17. package/dist/fs/with-lock.js +2 -5
  18. package/dist/limits/activity.d.ts +26 -0
  19. package/dist/limits/activity.js +52 -0
  20. package/dist/limits/axes.d.ts +69 -0
  21. package/dist/limits/axes.js +7 -0
  22. package/dist/limits/bridge.d.ts +4 -0
  23. package/dist/limits/bridge.js +10 -0
  24. package/dist/limits/decide.d.ts +146 -0
  25. package/dist/limits/decide.js +425 -0
  26. package/dist/limits/duration.d.ts +8 -0
  27. package/dist/limits/duration.js +20 -0
  28. package/dist/limits/envelope-loss.d.ts +29 -0
  29. package/dist/limits/envelope-loss.js +150 -0
  30. package/dist/limits/families.d.ts +59 -0
  31. package/dist/limits/families.js +149 -0
  32. package/dist/limits/header-classifier.d.ts +9 -0
  33. package/dist/limits/header-classifier.js +121 -0
  34. package/dist/limits/hold.d.ts +13 -0
  35. package/dist/limits/hold.js +25 -0
  36. package/dist/limits/identity.d.ts +14 -0
  37. package/dist/limits/identity.js +21 -0
  38. package/dist/limits/index.d.ts +45 -0
  39. package/dist/limits/index.js +26 -0
  40. package/dist/limits/jitter.d.ts +2 -0
  41. package/dist/limits/jitter.js +9 -0
  42. package/dist/limits/labels.d.ts +3 -0
  43. package/dist/limits/labels.js +11 -0
  44. package/dist/limits/marker.d.ts +69 -0
  45. package/dist/limits/marker.js +107 -0
  46. package/dist/limits/merge-laws.d.ts +15 -0
  47. package/dist/limits/merge-laws.js +31 -0
  48. package/dist/limits/namespace.d.ts +92 -0
  49. package/dist/limits/namespace.js +191 -0
  50. package/dist/limits/persistence.d.ts +33 -0
  51. package/dist/limits/persistence.js +9 -0
  52. package/dist/limits/pi-wait.d.ts +16 -0
  53. package/dist/limits/pi-wait.js +51 -0
  54. package/dist/limits/pool-adapter.d.ts +16 -0
  55. package/dist/limits/pool-adapter.js +162 -0
  56. package/dist/limits/presets.d.ts +11 -0
  57. package/dist/limits/presets.js +240 -0
  58. package/dist/limits/registry.d.ts +61 -0
  59. package/dist/limits/registry.js +478 -0
  60. package/dist/limits/request-history.d.ts +79 -0
  61. package/dist/limits/request-history.js +120 -0
  62. package/dist/limits/reset.d.ts +21 -0
  63. package/dist/limits/reset.js +44 -0
  64. package/dist/limits/routing-hold.d.ts +16 -0
  65. package/dist/limits/routing-hold.js +23 -0
  66. package/dist/limits/scope.d.ts +12 -0
  67. package/dist/limits/scope.js +10 -0
  68. package/dist/limits/signal.d.ts +41 -0
  69. package/dist/limits/signal.js +1 -0
  70. package/dist/limits/terminal.d.ts +52 -0
  71. package/dist/limits/terminal.js +133 -0
  72. package/dist/limits/unconfirmed-retain-counter.d.ts +13 -0
  73. package/dist/limits/unconfirmed-retain-counter.js +41 -0
  74. package/dist/limits/vault-adapter.d.ts +16 -0
  75. package/dist/limits/vault-adapter.js +123 -0
  76. package/dist/limits/vault.d.ts +1 -0
  77. package/dist/limits/vault.js +1 -0
  78. package/dist/limits/wake.d.ts +21 -0
  79. package/dist/limits/wake.js +47 -0
  80. package/dist/limits/wording.d.ts +25 -0
  81. package/dist/limits/wording.js +114 -0
  82. package/dist/opencode2/index.d.ts +1 -1
  83. package/dist/opencode2/install.d.ts +2 -2
  84. package/dist/opencode2/install.js +161 -18
  85. package/dist/opencode2/types.d.ts +95 -9
  86. package/dist/routing/admission.d.ts +7 -2
  87. package/dist/routing/admission.js +17 -7
  88. package/dist/routing-accessor/handle.d.ts +1 -0
  89. package/dist/routing-accessor/handle.js +10 -0
  90. package/dist/routing-accessor/index.d.ts +13 -3
  91. package/dist/routing-accessor/index.js +11 -10
  92. package/dist/rpc/port-file.d.ts +12 -3
  93. package/dist/rpc/port-file.js +46 -4
  94. package/dist/store/attribution.js +3 -2
  95. package/dist/store/errors.d.ts +1 -1
  96. package/dist/store/hooks.d.ts +5 -1
  97. package/dist/store/hooks.js +20 -5
  98. package/dist/store/index.d.ts +1 -0
  99. package/dist/store/limits-namespace.d.ts +7 -0
  100. package/dist/store/limits-namespace.js +34 -0
  101. package/dist/store/pool.d.ts +10 -1
  102. package/dist/store/pool.js +2 -0
  103. package/dist/store/provider-state.js +5 -5
  104. package/dist/store/refresh.js +1 -1
  105. package/dist/store/schema.js +9 -4
  106. package/dist/store/settings.d.ts +2 -0
  107. package/dist/store/settings.js +11 -4
  108. package/package.json +10 -2
@@ -0,0 +1,162 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { isDeepStrictEqual } from 'node:util';
3
+ import { PoolOperationError } from '../store/errors.js';
4
+ import { EnvelopeHistory, EnvelopeRepair, } from './envelope-loss.js';
5
+ import { applyLimitsCommands, createLimitsNamespace, } from './namespace.js';
6
+ import { LimitsPersistenceRefusal, } from './persistence.js';
7
+ function bindingsOf(namespace, rows) {
8
+ return rows.flatMap((row) => row.credentialEpoch === undefined
9
+ ? []
10
+ : [
11
+ {
12
+ account: {
13
+ namespace,
14
+ accountId: row.id,
15
+ // Pool epochs change on replacement, not on refresh or rotation.
16
+ incarnation: String(row.credentialEpoch),
17
+ },
18
+ credentialEpoch: String(row.credentialEpoch),
19
+ ...(row.identity === undefined ? {} : { identity: row.identity }),
20
+ },
21
+ ]);
22
+ }
23
+ function decodeEnvelope(value, namespace, generation) {
24
+ if (value === undefined)
25
+ return createLimitsNamespace(namespace, generation);
26
+ if (value === null ||
27
+ typeof value !== 'object' ||
28
+ !('schemaVersion' in value) ||
29
+ value.schemaVersion !== 1 ||
30
+ !('namespace' in value) ||
31
+ value.namespace !== namespace ||
32
+ !('generation' in value) ||
33
+ typeof value.generation !== 'string' ||
34
+ !('revision' in value) ||
35
+ !Number.isSafeInteger(value.revision) ||
36
+ value.revision < 0 ||
37
+ !('lowWatermark' in value) ||
38
+ !Number.isSafeInteger(value.lowWatermark) ||
39
+ value.lowWatermark < 0 ||
40
+ !('marks' in value) ||
41
+ !Array.isArray(value.marks) ||
42
+ !('tombstones' in value) ||
43
+ !Array.isArray(value.tombstones) ||
44
+ !('operationIds' in value) ||
45
+ !Array.isArray(value.operationIds) ||
46
+ !('access' in value) ||
47
+ !Array.isArray(value.access))
48
+ throw new TypeError('Invalid or unsupported pool limits namespace');
49
+ return value;
50
+ }
51
+ /**
52
+ * Activate after initialize/load reports ready. Reads never acquire a write
53
+ * lock; recovery is detached and commits merge under the store locks.
54
+ */
55
+ export async function createPoolLimitsAdapter(options) {
56
+ const { store, namespace } = options;
57
+ if (!store.updateLimitsNamespace)
58
+ throw new LimitsPersistenceRefusal('limits-unsupported');
59
+ const update = store.updateLimitsNamespace.bind(store);
60
+ const generation = randomUUID();
61
+ const history = new EnvelopeHistory();
62
+ const repair = new EnvelopeRepair(options.logger);
63
+ const now = options.now ?? Date.now;
64
+ const readBindings = async () => {
65
+ const pool = await store.read();
66
+ if (pool.status !== 'ready') {
67
+ if (pool.status === 'error' && pool.kind === 'snapshot-contended')
68
+ throw new Error(pool.reason);
69
+ throw new LimitsPersistenceRefusal('pool-not-ready');
70
+ }
71
+ return bindingsOf(namespace, pool.rows);
72
+ };
73
+ const readEnvelope = async () => {
74
+ const settings = await store.readSettings();
75
+ if (settings.status !== 'ready')
76
+ throw new LimitsPersistenceRefusal('pool-not-ready');
77
+ const envelope = settings.settings.commonAuthLimits;
78
+ return envelope === undefined
79
+ ? undefined
80
+ : decodeEnvelope(envelope, namespace, generation);
81
+ };
82
+ const read = async (previous) => {
83
+ let bindings = await readBindings();
84
+ let snapshot = await readEnvelope();
85
+ let last;
86
+ for (let attempt = 0; attempt < 3; attempt++) {
87
+ const checked = await readBindings();
88
+ const checkedSnapshot = await readEnvelope();
89
+ // A replacement between the envelope and binding reads must not make an
90
+ // old envelope authoritative for a new incarnation. Recheck the envelope
91
+ // too: its generation or revision can change while the rows stay the same.
92
+ // Bounded retries keep a busy writer from delaying a provider request.
93
+ const stable = isDeepStrictEqual(bindings, checked) &&
94
+ isDeepStrictEqual(snapshot, checkedSnapshot);
95
+ last = {
96
+ snapshot: snapshot ?? createLimitsNamespace(namespace, generation),
97
+ bindings,
98
+ authoritative: stable,
99
+ };
100
+ if (stable) {
101
+ if (history.lost(snapshot, previous)) {
102
+ repair.schedule(() => adapter.commit([], previous));
103
+ return {
104
+ snapshot: history.recover(snapshot, previous, namespace, now()),
105
+ bindings,
106
+ authoritative: false,
107
+ degradedAgreement: true,
108
+ };
109
+ }
110
+ if (snapshot)
111
+ history.remember(snapshot);
112
+ return last;
113
+ }
114
+ bindings = checked;
115
+ snapshot = checkedSnapshot;
116
+ }
117
+ return last;
118
+ };
119
+ const adapter = {
120
+ namespace,
121
+ read,
122
+ subscribe: repair.subscribe,
123
+ async commit(commands, previous) {
124
+ let committed;
125
+ try {
126
+ await update((envelope, rows) => {
127
+ const bindings = bindingsOf(namespace, rows);
128
+ const present = envelope === undefined
129
+ ? undefined
130
+ : decodeEnvelope(envelope, namespace, generation);
131
+ const degradedAgreement = history.lost(present, previous);
132
+ const result = applyLimitsCommands(degradedAgreement
133
+ ? history.recover(present, previous, namespace, now())
134
+ : (present ?? createLimitsNamespace(namespace, generation)), commands, {
135
+ now: now(),
136
+ bindings,
137
+ authorizeEpoch: (observed, current) => observed.credentialEpoch === current.credentialEpoch,
138
+ });
139
+ committed = {
140
+ ...result,
141
+ bindings,
142
+ authoritative: true,
143
+ degradedAgreement,
144
+ };
145
+ return result.snapshot;
146
+ });
147
+ }
148
+ catch (error) {
149
+ if (error instanceof PoolOperationError &&
150
+ (error.kind === 'pending-migration' || error.kind === 'load-error'))
151
+ throw new LimitsPersistenceRefusal('pool-not-ready');
152
+ throw error;
153
+ }
154
+ if (!committed)
155
+ throw new Error('Pool limits mutator was not called');
156
+ history.remember(committed.snapshot, previous);
157
+ return committed;
158
+ },
159
+ };
160
+ await read();
161
+ return adapter;
162
+ }
@@ -0,0 +1,11 @@
1
+ import type { LimitAxes } from './axes.js';
2
+ export declare const confirmedAffinity: LimitAxes;
3
+ export declare const earliestPoolEngine: LimitAxes;
4
+ export declare const windowRouter: LimitAxes;
5
+ export declare const statusVaultOrder: LimitAxes;
6
+ export declare const limitPresets: {
7
+ 'confirmed-affinity': LimitAxes;
8
+ 'earliest-pool-engine': LimitAxes;
9
+ 'window-router': LimitAxes;
10
+ 'status-vault-order': LimitAxes;
11
+ };
@@ -0,0 +1,240 @@
1
+ import { ANTIGRAVITY_FAILURE_LADDER } from './marker.js';
2
+ function immutable(value) {
3
+ if (value && typeof value === 'object') {
4
+ for (const child of Object.values(value))
5
+ immutable(child);
6
+ Object.freeze(value);
7
+ }
8
+ return value;
9
+ }
10
+ function hosts(value) {
11
+ return { opencode1: value, opencode2: value, pi: value };
12
+ }
13
+ const reselect = {
14
+ action: 'reselect',
15
+ affinity: 'always',
16
+ hint: 'none',
17
+ defaultMs: 60000,
18
+ };
19
+ const sticky = {
20
+ ...reselect,
21
+ action: 'retain',
22
+ affinity: 'sticky',
23
+ };
24
+ const auth = {
25
+ family: 'local-auth',
26
+ messageKey: 'auth.no-account',
27
+ retryable: false,
28
+ hostRetry: 'leave',
29
+ };
30
+ function refusals(quota, incomplete) {
31
+ return {
32
+ auth: hosts(auth),
33
+ quota: hosts(quota),
34
+ incomplete: hosts(incomplete),
35
+ 'model-unavailable': hosts({
36
+ family: 'json-412',
37
+ messageKey: 'model-unavailable',
38
+ retryable: false,
39
+ hostRetry: 'veto',
40
+ }),
41
+ };
42
+ }
43
+ const off = { kind: 'off' };
44
+ const strict = { requestEscape: 'off', retryExhaustion: 'terminal' };
45
+ const noAdvance = { statuses: [], attributedLimitOnly: true };
46
+ const engineQuota = {
47
+ family: 'json-412',
48
+ messageKey: 'quota.pool-exhausted',
49
+ retryable: false,
50
+ hostRetry: 'veto',
51
+ };
52
+ export const confirmedAffinity = immutable({
53
+ unconfirmedRetainLimit: 2,
54
+ evidence: 'per-field-overlay',
55
+ markers: hosts({
56
+ kind: 'reset',
57
+ mergeLaw: 'latest-evidence',
58
+ defaultMs: 60000,
59
+ }),
60
+ readingClearsCoveredScopes: 'on',
61
+ successClearsCoveredScopes: 'on',
62
+ unknown: {
63
+ opencode1: { ...reselect, action: 'retain', hint: 'minimum' },
64
+ opencode2: reselect,
65
+ pi: { ...reselect, action: 'pass' },
66
+ },
67
+ shortLimit: {
68
+ holdBound: 'cache-ttl',
69
+ preference: 'same-account-first',
70
+ jitter: 'session-sha256',
71
+ },
72
+ retainBound: 'none',
73
+ poolWaiting: off,
74
+ execution: 'host',
75
+ requestExclusion: 'off',
76
+ advance: hosts(noAdvance),
77
+ markedPool: strict,
78
+ terminalMetadata: 'setting-capped-fresh',
79
+ terminalPolicy: 'provided',
80
+ refusals: refusals({
81
+ family: 'claude-429',
82
+ messageKey: 'quota.all-accounts',
83
+ retryable: true,
84
+ hostRetry: 'leave',
85
+ }, {
86
+ family: 'claude-econnreset',
87
+ messageKey: 'incomplete.snapshot',
88
+ retryable: true,
89
+ hostRetry: 'leave',
90
+ }),
91
+ });
92
+ export const earliestPoolEngine = immutable({
93
+ evidence: 'typed',
94
+ markers: hosts(ANTIGRAVITY_FAILURE_LADDER),
95
+ readingClearsCoveredScopes: 'off',
96
+ successClearsCoveredScopes: 'off',
97
+ unknown: hosts(reselect),
98
+ shortLimit: {
99
+ holdBound: 'disabled',
100
+ preference: 'ready-alternative-first',
101
+ jitter: 'none',
102
+ },
103
+ retainBound: 'none',
104
+ poolWaiting: {
105
+ kind: 'earliest',
106
+ budgetMs: 300000,
107
+ requestDeadlineMs: 600000,
108
+ hardFallbackMs: 60000,
109
+ singleEligibleSoftExemption: true,
110
+ },
111
+ execution: 'engine',
112
+ requestExclusion: 'on',
113
+ advance: hosts({ statuses: [429, 503, 529], attributedLimitOnly: false }),
114
+ markedPool: strict,
115
+ terminalMetadata: 'baseline',
116
+ terminalPolicy: 'pool',
117
+ refusals: refusals(engineQuota, {
118
+ ...engineQuota,
119
+ messageKey: 'incomplete.timeout',
120
+ }),
121
+ });
122
+ export const windowRouter = immutable({
123
+ evidence: 'named-window',
124
+ markers: {
125
+ opencode1: { kind: 'reset', mergeLaw: 'max-until', defaultMs: 60000 },
126
+ opencode2: { kind: 'reset', mergeLaw: 'max-until', defaultMs: 60000 },
127
+ pi: off,
128
+ },
129
+ readingClearsCoveredScopes: 'off',
130
+ successClearsCoveredScopes: 'off',
131
+ unknown: { opencode1: sticky, opencode2: reselect, pi: sticky },
132
+ shortLimit: {
133
+ holdBound: 'disabled',
134
+ preference: 'ready-alternative-first',
135
+ jitter: 'none',
136
+ },
137
+ retainBound: 'none',
138
+ poolWaiting: off,
139
+ execution: 'host',
140
+ requestExclusion: 'off',
141
+ advance: hosts({ statuses: [401, 403, 429], attributedLimitOnly: false }),
142
+ markedPool: {
143
+ requestEscape: 'ignore-timed-marks-if-all-marked',
144
+ retryExhaustion: 'same-host-delay',
145
+ },
146
+ terminalMetadata: 'baseline',
147
+ terminalPolicy: 'provided',
148
+ refusals: refusals({
149
+ family: 'openai-429',
150
+ messageKey: 'quota.no-route',
151
+ retryable: true,
152
+ hostRetry: 'leave',
153
+ }, {
154
+ family: 'openai-429',
155
+ messageKey: 'incomplete.snapshot',
156
+ retryable: true,
157
+ hostRetry: 'leave',
158
+ }),
159
+ });
160
+ export const statusVaultOrder = immutable({
161
+ evidence: 'hints-only',
162
+ markers: {
163
+ opencode1: {
164
+ kind: 'hint',
165
+ mergeLaw: 'overwrite',
166
+ defaultMs: 60000,
167
+ defaultMsByKind: { 'payment-balance': 300000 },
168
+ causes: ['rate-limit', 'payment-balance'],
169
+ ignoredKinds: ['payment-cap'],
170
+ minimumMs: 0,
171
+ zero: 'accept',
172
+ hintClock: 'signal',
173
+ },
174
+ opencode2: {
175
+ kind: 'hint',
176
+ mergeLaw: 'overwrite',
177
+ defaultMs: 60000,
178
+ defaultMsByKind: { 'payment-balance': 300000 },
179
+ causes: ['rate-limit', 'payment-balance'],
180
+ ignoredKinds: ['payment-cap'],
181
+ minimumMs: 0,
182
+ zero: 'accept',
183
+ hintClock: 'marker',
184
+ },
185
+ pi: {
186
+ kind: 'hint',
187
+ mergeLaw: 'overwrite',
188
+ defaultMs: 60000,
189
+ defaultMsByKind: { 'payment-balance': 300000 },
190
+ causes: ['rate-limit', 'payment-balance'],
191
+ ignoredKinds: ['payment-cap'],
192
+ minimumMs: 0,
193
+ zero: 'accept',
194
+ hintClock: 'signal',
195
+ },
196
+ },
197
+ readingClearsCoveredScopes: 'off',
198
+ successClearsCoveredScopes: 'off',
199
+ unknown: hosts(reselect),
200
+ shortLimit: {
201
+ holdBound: 'disabled',
202
+ preference: 'ready-alternative-first',
203
+ jitter: 'none',
204
+ },
205
+ retainBound: 'none',
206
+ poolWaiting: off,
207
+ execution: 'host',
208
+ requestExclusion: 'off',
209
+ advance: {
210
+ opencode1: { statuses: [401, 429], attributedLimitOnly: false },
211
+ opencode2: noAdvance,
212
+ pi: { statuses: [401, 429], attributedLimitOnly: false },
213
+ },
214
+ markedPool: {
215
+ requestEscape: 'ignore-timed-marks-if-all-marked',
216
+ retryExhaustion: 'host-delay',
217
+ },
218
+ terminalMetadata: 'baseline',
219
+ terminalPolicy: 'status-history',
220
+ terminalStatusHistory: {
221
+ minRetryMs: 1000,
222
+ defaultRetryMs: 60000,
223
+ paymentBalance: {
224
+ family: 'claustrum-402',
225
+ messageKey: 'payment.insufficient-balance',
226
+ },
227
+ },
228
+ refusals: refusals({
229
+ family: 'claustrum-429',
230
+ messageKey: 'quota.accounts-rate-limited',
231
+ retryable: true,
232
+ hostRetry: 'leave',
233
+ }, { ...auth, messageKey: 'incomplete.no-account' }),
234
+ });
235
+ export const limitPresets = immutable({
236
+ 'confirmed-affinity': confirmedAffinity,
237
+ 'earliest-pool-engine': earliestPoolEngine,
238
+ 'window-router': windowRouter,
239
+ 'status-vault-order': statusVaultOrder,
240
+ });
@@ -0,0 +1,61 @@
1
+ import type { SessionActivityStore } from './activity.js';
2
+ import type { IdentityBinding } from './identity.js';
3
+ import type { LimitMarkCause } from './marker.js';
4
+ import type { LimitsCommand, LimitsNamespace } from './namespace.js';
5
+ import type { LimitsPersistenceOutcome, PersistenceAdapter } from './persistence.js';
6
+ export declare const LIMITS_REGISTRY_KEY: unique symbol;
7
+ export interface LimitsClock {
8
+ now(): number;
9
+ setTimeout(callback: () => void, delayMs: number): unknown;
10
+ clearTimeout(timer: unknown): void;
11
+ }
12
+ export interface LimitsRegistryEvent {
13
+ readonly type: 'mark' | 'success';
14
+ readonly command: LimitsCommand;
15
+ readonly revision: number;
16
+ }
17
+ export interface LimitsRegistryOptions {
18
+ readonly adapter: PersistenceAdapter;
19
+ readonly clock?: LimitsClock;
20
+ /** Access is provider-owned; the registry must not guess its stored shape. */
21
+ readonly isAccessRestrictive: (state: unknown) => boolean;
22
+ readonly onEvent?: (event: LimitsRegistryEvent) => void;
23
+ readonly onRejected?: (command: LimitsCommand, outcome: LimitsPersistenceOutcome) => void;
24
+ }
25
+ export interface LimitsDispatchView {
26
+ readonly snapshot: LimitsNamespace;
27
+ /** Pending commands and identity/access restrictions only; callers still evaluate timed marks. */
28
+ readonly blocked: boolean;
29
+ }
30
+ export interface LimitsRegistry {
31
+ readonly snapshot: LimitsNamespace;
32
+ readonly lastReloadAt: number;
33
+ readonly degradedAgreement: boolean;
34
+ readonly lastFailure: unknown;
35
+ readonly pendingCommands: number;
36
+ readonly activity: SessionActivityStore;
37
+ /** Capture before observing provider evidence, never at publication time. */
38
+ observe(binding: IdentityBinding): {
39
+ readonly binding: IdentityBinding;
40
+ readonly baseRevision: number;
41
+ };
42
+ /** Synchronous; a timed mark never waits for persistence on the request path. */
43
+ enqueue(command: LimitsCommand, event?: 'success'): void;
44
+ beforeDispatch(binding: IdentityBinding): Promise<LimitsDispatchView>;
45
+ flush(): Promise<void>;
46
+ reload(): Promise<void>;
47
+ dispose(): Promise<void>;
48
+ }
49
+ export type SuccessfulProbeClear = Omit<Extract<LimitsCommand, {
50
+ type: 'clear';
51
+ }>, 'type'> & {
52
+ readonly cause: LimitMarkCause;
53
+ readonly evidenceAt: number;
54
+ };
55
+ /** Publish a recovery fence even when expiry already removed the observed timer.
56
+ * Capture binding/baseRevision with observe before the probe; dispatch to that
57
+ * account joins the clear acknowledgment through beforeDispatch, not here.
58
+ */
59
+ export declare function clearLimitsAfterProbe(registry: LimitsRegistry, input: SuccessfulProbeClear): void;
60
+ /** Shared owners use one journal/listener; a last-owner replacement waits for handoff. */
61
+ export declare function acquireLimitsRegistry(options: LimitsRegistryOptions): Promise<LimitsRegistry>;