@phosphorco/bb-thread-metrics 0.2.0 → 0.2.1

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.
@@ -0,0 +1,413 @@
1
+ import { z } from 'zod';
2
+ import type { ScoringConfigV2, ScoringConfigV3, StoredScoringConfig } from './recent.js';
3
+ /** Settings authority remains ledger-owned. No storage, SDK or React imports. */
4
+ export declare const HEAT_SETTINGS_METHODS: Readonly<{
5
+ read: "threadMetricsHeatSettingsReadV1";
6
+ save: "threadMetricsHeatSettingsSaveV1";
7
+ }>;
8
+ export declare const HEAT_SETTINGS_LIMITS: Readonly<{
9
+ configBytes: number;
10
+ inputBytes: number;
11
+ outputBytes: number;
12
+ operationKeys: 128;
13
+ }>;
14
+ export declare const heatConfigInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
+ schemaVersion: z.ZodLiteral<3>;
16
+ domain: z.ZodObject<{
17
+ version: z.ZodLiteral<1>;
18
+ kind: z.ZodLiteral<"root-family">;
19
+ }, z.core.$strict>;
20
+ mode: z.ZodLiteral<"percentile">;
21
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
22
+ gates: z.ZodObject<{
23
+ m20: z.ZodNumber;
24
+ h24: z.ZodNumber;
25
+ d7: z.ZodNumber;
26
+ }, z.core.$strict>;
27
+ }, z.core.$strict>, z.ZodObject<{
28
+ schemaVersion: z.ZodLiteral<3>;
29
+ domain: z.ZodObject<{
30
+ version: z.ZodLiteral<1>;
31
+ kind: z.ZodLiteral<"root-family">;
32
+ }, z.core.$strict>;
33
+ mode: z.ZodLiteral<"absolute">;
34
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
35
+ thresholds: z.ZodObject<{
36
+ m20: z.ZodNumber;
37
+ h24: z.ZodNumber;
38
+ d7: z.ZodNumber;
39
+ lifetime: z.ZodNumber;
40
+ }, z.core.$strict>;
41
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
42
+ }, z.core.$strict>], "mode">;
43
+ /** Byte-compatible V2 receipts; V3 canonicalization includes the domain. */
44
+ export declare function canonicalHeatConfig(value: StoredScoringConfig): string;
45
+ /** Stored legacy values are interpreted, never defaulted or migrated on read. */
46
+ export declare function validateHeatConfig(value: unknown): StoredScoringConfig;
47
+ export declare function validateRootFamilyHeatConfig(value: unknown): ScoringConfigV3;
48
+ export declare function prepareRootFamilyMigration(record: HeatConfigRecord, review?: {
49
+ disableLifetime?: boolean;
50
+ }): {
51
+ kind: 'review';
52
+ base: HeatConfigRecord;
53
+ candidate: ScoringConfigV3;
54
+ } | {
55
+ kind: 'blocked';
56
+ reason: string;
57
+ };
58
+ export declare const heatSettingsReadInputSchema: z.ZodObject<{
59
+ protocolVersion: z.ZodLiteral<1>;
60
+ operationKey: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strict>;
62
+ export declare const heatSettingsSaveInputSchema: z.ZodObject<{
63
+ protocolVersion: z.ZodLiteral<1>;
64
+ baseConfigVersion: z.ZodString;
65
+ operationKey: z.ZodString;
66
+ candidate: z.ZodDiscriminatedUnion<[z.ZodObject<{
67
+ schemaVersion: z.ZodLiteral<3>;
68
+ domain: z.ZodObject<{
69
+ version: z.ZodLiteral<1>;
70
+ kind: z.ZodLiteral<"root-family">;
71
+ }, z.core.$strict>;
72
+ mode: z.ZodLiteral<"percentile">;
73
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
74
+ gates: z.ZodObject<{
75
+ m20: z.ZodNumber;
76
+ h24: z.ZodNumber;
77
+ d7: z.ZodNumber;
78
+ }, z.core.$strict>;
79
+ }, z.core.$strict>, z.ZodObject<{
80
+ schemaVersion: z.ZodLiteral<3>;
81
+ domain: z.ZodObject<{
82
+ version: z.ZodLiteral<1>;
83
+ kind: z.ZodLiteral<"root-family">;
84
+ }, z.core.$strict>;
85
+ mode: z.ZodLiteral<"absolute">;
86
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
87
+ thresholds: z.ZodObject<{
88
+ m20: z.ZodNumber;
89
+ h24: z.ZodNumber;
90
+ d7: z.ZodNumber;
91
+ lifetime: z.ZodNumber;
92
+ }, z.core.$strict>;
93
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
94
+ }, z.core.$strict>], "mode">;
95
+ }, z.core.$strict>;
96
+ export type HeatSettingsReadInput = z.infer<typeof heatSettingsReadInputSchema>;
97
+ export type HeatSettingsSaveInput = z.infer<typeof heatSettingsSaveInputSchema>;
98
+ export declare const heatConfigRecordSchema: z.ZodObject<{
99
+ version: z.ZodString;
100
+ value: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
101
+ mode: z.ZodLiteral<"percentile">;
102
+ gates: z.ZodObject<{
103
+ m20: z.ZodNumber;
104
+ h24: z.ZodNumber;
105
+ d7: z.ZodNumber;
106
+ }, z.core.$strip>;
107
+ schemaVersion: z.ZodLiteral<2>;
108
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ mode: z.ZodLiteral<"absolute">;
111
+ thresholds: z.ZodObject<{
112
+ m20: z.ZodNumber;
113
+ h24: z.ZodNumber;
114
+ d7: z.ZodNumber;
115
+ lifetime: z.ZodNumber;
116
+ }, z.core.$strip>;
117
+ lifetimeEnabled: z.ZodOptional<z.ZodBoolean>;
118
+ schemaVersion: z.ZodLiteral<2>;
119
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
120
+ }, z.core.$strip>], "mode">, z.ZodDiscriminatedUnion<[z.ZodObject<{
121
+ mode: z.ZodLiteral<"percentile">;
122
+ gates: z.ZodObject<{
123
+ m20: z.ZodNumber;
124
+ h24: z.ZodNumber;
125
+ d7: z.ZodNumber;
126
+ }, z.core.$strip>;
127
+ schemaVersion: z.ZodLiteral<3>;
128
+ domain: z.ZodObject<{
129
+ version: z.ZodLiteral<1>;
130
+ kind: z.ZodLiteral<"root-family">;
131
+ }, z.core.$strip>;
132
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ mode: z.ZodLiteral<"absolute">;
135
+ thresholds: z.ZodObject<{
136
+ m20: z.ZodNumber;
137
+ h24: z.ZodNumber;
138
+ d7: z.ZodNumber;
139
+ lifetime: z.ZodNumber;
140
+ }, z.core.$strip>;
141
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
142
+ schemaVersion: z.ZodLiteral<3>;
143
+ domain: z.ZodObject<{
144
+ version: z.ZodLiteral<1>;
145
+ kind: z.ZodLiteral<"root-family">;
146
+ }, z.core.$strip>;
147
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
148
+ }, z.core.$strip>], "mode">]>;
149
+ }, z.core.$strip>;
150
+ export type HeatConfigRecord = z.infer<typeof heatConfigRecordSchema>;
151
+ export declare const heatSettingsReadResultSchema: z.ZodObject<{
152
+ protocolVersion: z.ZodLiteral<1>;
153
+ current: z.ZodObject<{
154
+ version: z.ZodString;
155
+ value: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
156
+ mode: z.ZodLiteral<"percentile">;
157
+ gates: z.ZodObject<{
158
+ m20: z.ZodNumber;
159
+ h24: z.ZodNumber;
160
+ d7: z.ZodNumber;
161
+ }, z.core.$strip>;
162
+ schemaVersion: z.ZodLiteral<2>;
163
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ mode: z.ZodLiteral<"absolute">;
166
+ thresholds: z.ZodObject<{
167
+ m20: z.ZodNumber;
168
+ h24: z.ZodNumber;
169
+ d7: z.ZodNumber;
170
+ lifetime: z.ZodNumber;
171
+ }, z.core.$strip>;
172
+ lifetimeEnabled: z.ZodOptional<z.ZodBoolean>;
173
+ schemaVersion: z.ZodLiteral<2>;
174
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
175
+ }, z.core.$strip>], "mode">, z.ZodDiscriminatedUnion<[z.ZodObject<{
176
+ mode: z.ZodLiteral<"percentile">;
177
+ gates: z.ZodObject<{
178
+ m20: z.ZodNumber;
179
+ h24: z.ZodNumber;
180
+ d7: z.ZodNumber;
181
+ }, z.core.$strip>;
182
+ schemaVersion: z.ZodLiteral<3>;
183
+ domain: z.ZodObject<{
184
+ version: z.ZodLiteral<1>;
185
+ kind: z.ZodLiteral<"root-family">;
186
+ }, z.core.$strip>;
187
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
188
+ }, z.core.$strip>, z.ZodObject<{
189
+ mode: z.ZodLiteral<"absolute">;
190
+ thresholds: z.ZodObject<{
191
+ m20: z.ZodNumber;
192
+ h24: z.ZodNumber;
193
+ d7: z.ZodNumber;
194
+ lifetime: z.ZodNumber;
195
+ }, z.core.$strip>;
196
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
197
+ schemaVersion: z.ZodLiteral<3>;
198
+ domain: z.ZodObject<{
199
+ version: z.ZodLiteral<1>;
200
+ kind: z.ZodLiteral<"root-family">;
201
+ }, z.core.$strip>;
202
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
203
+ }, z.core.$strip>], "mode">]>;
204
+ }, z.core.$strip>;
205
+ published: z.ZodObject<{
206
+ instance: z.ZodString;
207
+ sequence: z.ZodNumber;
208
+ configVersion: z.ZodNullable<z.ZodString>;
209
+ }, z.core.$strip>;
210
+ writable: z.ZodBoolean;
211
+ reason: z.ZodNullable<z.ZodString>;
212
+ migration: z.ZodOptional<z.ZodObject<{
213
+ kind: z.ZodLiteral<"domain-required">;
214
+ target: z.ZodObject<{
215
+ version: z.ZodLiteral<1>;
216
+ kind: z.ZodLiteral<"root-family">;
217
+ }, z.core.$strip>;
218
+ }, z.core.$strip>>;
219
+ outcome: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
220
+ kind: z.ZodLiteral<"saved">;
221
+ operationKey: z.ZodString;
222
+ record: z.ZodObject<{
223
+ version: z.ZodString;
224
+ value: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
225
+ mode: z.ZodLiteral<"percentile">;
226
+ gates: z.ZodObject<{
227
+ m20: z.ZodNumber;
228
+ h24: z.ZodNumber;
229
+ d7: z.ZodNumber;
230
+ }, z.core.$strip>;
231
+ schemaVersion: z.ZodLiteral<2>;
232
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
233
+ }, z.core.$strip>, z.ZodObject<{
234
+ mode: z.ZodLiteral<"absolute">;
235
+ thresholds: z.ZodObject<{
236
+ m20: z.ZodNumber;
237
+ h24: z.ZodNumber;
238
+ d7: z.ZodNumber;
239
+ lifetime: z.ZodNumber;
240
+ }, z.core.$strip>;
241
+ lifetimeEnabled: z.ZodOptional<z.ZodBoolean>;
242
+ schemaVersion: z.ZodLiteral<2>;
243
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
244
+ }, z.core.$strip>], "mode">, z.ZodDiscriminatedUnion<[z.ZodObject<{
245
+ mode: z.ZodLiteral<"percentile">;
246
+ gates: z.ZodObject<{
247
+ m20: z.ZodNumber;
248
+ h24: z.ZodNumber;
249
+ d7: z.ZodNumber;
250
+ }, z.core.$strip>;
251
+ schemaVersion: z.ZodLiteral<3>;
252
+ domain: z.ZodObject<{
253
+ version: z.ZodLiteral<1>;
254
+ kind: z.ZodLiteral<"root-family">;
255
+ }, z.core.$strip>;
256
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ mode: z.ZodLiteral<"absolute">;
259
+ thresholds: z.ZodObject<{
260
+ m20: z.ZodNumber;
261
+ h24: z.ZodNumber;
262
+ d7: z.ZodNumber;
263
+ lifetime: z.ZodNumber;
264
+ }, z.core.$strip>;
265
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
266
+ schemaVersion: z.ZodLiteral<3>;
267
+ domain: z.ZodObject<{
268
+ version: z.ZodLiteral<1>;
269
+ kind: z.ZodLiteral<"root-family">;
270
+ }, z.core.$strip>;
271
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
272
+ }, z.core.$strip>], "mode">]>;
273
+ }, z.core.$strip>;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ kind: z.ZodLiteral<"conflict">;
276
+ operationKey: z.ZodString;
277
+ record: z.ZodObject<{
278
+ version: z.ZodString;
279
+ value: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
280
+ mode: z.ZodLiteral<"percentile">;
281
+ gates: z.ZodObject<{
282
+ m20: z.ZodNumber;
283
+ h24: z.ZodNumber;
284
+ d7: z.ZodNumber;
285
+ }, z.core.$strip>;
286
+ schemaVersion: z.ZodLiteral<2>;
287
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
288
+ }, z.core.$strip>, z.ZodObject<{
289
+ mode: z.ZodLiteral<"absolute">;
290
+ thresholds: z.ZodObject<{
291
+ m20: z.ZodNumber;
292
+ h24: z.ZodNumber;
293
+ d7: z.ZodNumber;
294
+ lifetime: z.ZodNumber;
295
+ }, z.core.$strip>;
296
+ lifetimeEnabled: z.ZodOptional<z.ZodBoolean>;
297
+ schemaVersion: z.ZodLiteral<2>;
298
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
299
+ }, z.core.$strip>], "mode">, z.ZodDiscriminatedUnion<[z.ZodObject<{
300
+ mode: z.ZodLiteral<"percentile">;
301
+ gates: z.ZodObject<{
302
+ m20: z.ZodNumber;
303
+ h24: z.ZodNumber;
304
+ d7: z.ZodNumber;
305
+ }, z.core.$strip>;
306
+ schemaVersion: z.ZodLiteral<3>;
307
+ domain: z.ZodObject<{
308
+ version: z.ZodLiteral<1>;
309
+ kind: z.ZodLiteral<"root-family">;
310
+ }, z.core.$strip>;
311
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
312
+ }, z.core.$strip>, z.ZodObject<{
313
+ mode: z.ZodLiteral<"absolute">;
314
+ thresholds: z.ZodObject<{
315
+ m20: z.ZodNumber;
316
+ h24: z.ZodNumber;
317
+ d7: z.ZodNumber;
318
+ lifetime: z.ZodNumber;
319
+ }, z.core.$strip>;
320
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
321
+ schemaVersion: z.ZodLiteral<3>;
322
+ domain: z.ZodObject<{
323
+ version: z.ZodLiteral<1>;
324
+ kind: z.ZodLiteral<"root-family">;
325
+ }, z.core.$strip>;
326
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
327
+ }, z.core.$strip>], "mode">]>;
328
+ }, z.core.$strip>;
329
+ }, z.core.$strip>, z.ZodObject<{
330
+ kind: z.ZodLiteral<"unknown">;
331
+ operationKey: z.ZodString;
332
+ }, z.core.$strip>], "kind">>;
333
+ }, z.core.$strip>;
334
+ export declare const heatSettingsSaveResultSchema: z.ZodObject<{
335
+ protocolVersion: z.ZodLiteral<1>;
336
+ kind: z.ZodEnum<{
337
+ saved: "saved";
338
+ conflict: "conflict";
339
+ }>;
340
+ operationKey: z.ZodString;
341
+ record: z.ZodObject<{
342
+ version: z.ZodString;
343
+ value: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
344
+ mode: z.ZodLiteral<"percentile">;
345
+ gates: z.ZodObject<{
346
+ m20: z.ZodNumber;
347
+ h24: z.ZodNumber;
348
+ d7: z.ZodNumber;
349
+ }, z.core.$strip>;
350
+ schemaVersion: z.ZodLiteral<2>;
351
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
352
+ }, z.core.$strip>, z.ZodObject<{
353
+ mode: z.ZodLiteral<"absolute">;
354
+ thresholds: z.ZodObject<{
355
+ m20: z.ZodNumber;
356
+ h24: z.ZodNumber;
357
+ d7: z.ZodNumber;
358
+ lifetime: z.ZodNumber;
359
+ }, z.core.$strip>;
360
+ lifetimeEnabled: z.ZodOptional<z.ZodBoolean>;
361
+ schemaVersion: z.ZodLiteral<2>;
362
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
363
+ }, z.core.$strip>], "mode">, z.ZodDiscriminatedUnion<[z.ZodObject<{
364
+ mode: z.ZodLiteral<"percentile">;
365
+ gates: z.ZodObject<{
366
+ m20: z.ZodNumber;
367
+ h24: z.ZodNumber;
368
+ d7: z.ZodNumber;
369
+ }, z.core.$strip>;
370
+ schemaVersion: z.ZodLiteral<3>;
371
+ domain: z.ZodObject<{
372
+ version: z.ZodLiteral<1>;
373
+ kind: z.ZodLiteral<"root-family">;
374
+ }, z.core.$strip>;
375
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
376
+ }, z.core.$strip>, z.ZodObject<{
377
+ mode: z.ZodLiteral<"absolute">;
378
+ thresholds: z.ZodObject<{
379
+ m20: z.ZodNumber;
380
+ h24: z.ZodNumber;
381
+ d7: z.ZodNumber;
382
+ lifetime: z.ZodNumber;
383
+ }, z.core.$strip>;
384
+ lifetimeEnabled: z.ZodOptional<z.ZodLiteral<false>>;
385
+ schemaVersion: z.ZodLiteral<3>;
386
+ domain: z.ZodObject<{
387
+ version: z.ZodLiteral<1>;
388
+ kind: z.ZodLiteral<"root-family">;
389
+ }, z.core.$strip>;
390
+ providerWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
391
+ }, z.core.$strip>], "mode">]>;
392
+ }, z.core.$strip>;
393
+ publicationPending: z.ZodBoolean;
394
+ }, z.core.$strip>;
395
+ export type HeatSettingsReadResult = z.infer<typeof heatSettingsReadResultSchema>;
396
+ export type HeatSettingsSaveResult = z.infer<typeof heatSettingsSaveResultSchema>;
397
+ export interface HeatSettingsPort {
398
+ read(input: HeatSettingsReadInput, signal?: AbortSignal): Promise<HeatSettingsReadResult>;
399
+ save(input: HeatSettingsSaveInput, signal?: AbortSignal): Promise<HeatSettingsSaveResult>;
400
+ }
401
+ type ScoreWindow = 'm20' | 'h24' | 'd7' | 'lifetime';
402
+ type RankWindow = Exclude<ScoreWindow, 'lifetime'>;
403
+ /** Population counts belong to the same rank epoch/scope/config as ranks.
404
+ * Owner ruling: singleton/empty percentile populations never heat, even gate0. */
405
+ export declare function scoringHeatV2(values: Record<ScoreWindow, {
406
+ amount: number | null;
407
+ }>, ranks: Record<RankWindow, number | null>, population: Record<RankWindow, number>, config: ScoringConfigV2): 'on-fire' | 'hot' | 'heavy' | null;
408
+ export declare function bounded<T>(schema: z.ZodType<T>, value: unknown, maxBytes: number): T;
409
+ export declare function validateHeatSaveInput(value: unknown): HeatSettingsSaveInput;
410
+ /** Unknown outcomes require an operation receipt AND candidate agreement. Equality
411
+ * alone cannot attribute another editor's write to this operation. */
412
+ export declare function reconcileHeatSave(input: HeatSettingsSaveInput, read: HeatSettingsReadResult): 'saved' | 'unchanged' | 'conflict' | 'unknown';
413
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from './recent.js';
2
+ export * from './heat-settings.js';
2
3
  import { z } from 'zod';
3
4
  export type { UsageVector } from '@phosphorco/bb-usage-algebra/vector';
4
5
  export declare const LIMITS: Readonly<{
@@ -38,8 +39,8 @@ export declare const coverageSchema: z.ZodEnum<{
38
39
  unknown: "unknown";
39
40
  }>;
40
41
  export declare const coverageReasonSchema: z.ZodEnum<{
41
- "source-gap": "source-gap";
42
42
  unpriced: "unpriced";
43
+ "source-gap": "source-gap";
43
44
  "root-unattested": "root-unattested";
44
45
  "history-unavailable": "history-unavailable";
45
46
  "missing-thread": "missing-thread";
@@ -66,9 +67,9 @@ export declare const approximationSchema: z.ZodObject<{
66
67
  modelId: z.ZodString;
67
68
  rateId: z.ZodNullable<z.ZodString>;
68
69
  basis: z.ZodEnum<{
70
+ unpriced: "unpriced";
69
71
  "closest-model": "closest-model";
70
72
  "provider-default": "provider-default";
71
- unpriced: "unpriced";
72
73
  matched: "matched";
73
74
  }>;
74
75
  }, z.core.$strip>>>;
@@ -214,8 +215,8 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
214
215
  unknown: "unknown";
215
216
  }>;
216
217
  coverageReasons: z.ZodArray<z.ZodEnum<{
217
- "source-gap": "source-gap";
218
218
  unpriced: "unpriced";
219
+ "source-gap": "source-gap";
219
220
  "root-unattested": "root-unattested";
220
221
  "history-unavailable": "history-unavailable";
221
222
  "missing-thread": "missing-thread";
@@ -248,9 +249,9 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
248
249
  modelId: z.ZodString;
249
250
  rateId: z.ZodNullable<z.ZodString>;
250
251
  basis: z.ZodEnum<{
252
+ unpriced: "unpriced";
251
253
  "closest-model": "closest-model";
252
254
  "provider-default": "provider-default";
253
- unpriced: "unpriced";
254
255
  matched: "matched";
255
256
  }>;
256
257
  }, z.core.$strip>>>;
@@ -310,8 +311,8 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
310
311
  unknown: "unknown";
311
312
  }>;
312
313
  coverageReasons: z.ZodArray<z.ZodEnum<{
313
- "source-gap": "source-gap";
314
314
  unpriced: "unpriced";
315
+ "source-gap": "source-gap";
315
316
  "root-unattested": "root-unattested";
316
317
  "history-unavailable": "history-unavailable";
317
318
  "missing-thread": "missing-thread";
@@ -344,9 +345,9 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
344
345
  modelId: z.ZodString;
345
346
  rateId: z.ZodNullable<z.ZodString>;
346
347
  basis: z.ZodEnum<{
348
+ unpriced: "unpriced";
347
349
  "closest-model": "closest-model";
348
350
  "provider-default": "provider-default";
349
- unpriced: "unpriced";
350
351
  matched: "matched";
351
352
  }>;
352
353
  }, z.core.$strip>>>;
@@ -462,8 +463,8 @@ export declare const readResultSchema: z.ZodObject<{
462
463
  unknown: "unknown";
463
464
  }>;
464
465
  coverageReasons: z.ZodArray<z.ZodEnum<{
465
- "source-gap": "source-gap";
466
466
  unpriced: "unpriced";
467
+ "source-gap": "source-gap";
467
468
  "root-unattested": "root-unattested";
468
469
  "history-unavailable": "history-unavailable";
469
470
  "missing-thread": "missing-thread";
@@ -496,9 +497,9 @@ export declare const readResultSchema: z.ZodObject<{
496
497
  modelId: z.ZodString;
497
498
  rateId: z.ZodNullable<z.ZodString>;
498
499
  basis: z.ZodEnum<{
500
+ unpriced: "unpriced";
499
501
  "closest-model": "closest-model";
500
502
  "provider-default": "provider-default";
501
- unpriced: "unpriced";
502
503
  matched: "matched";
503
504
  }>;
504
505
  }, z.core.$strip>>>;
@@ -558,8 +559,8 @@ export declare const readResultSchema: z.ZodObject<{
558
559
  unknown: "unknown";
559
560
  }>;
560
561
  coverageReasons: z.ZodArray<z.ZodEnum<{
561
- "source-gap": "source-gap";
562
562
  unpriced: "unpriced";
563
+ "source-gap": "source-gap";
563
564
  "root-unattested": "root-unattested";
564
565
  "history-unavailable": "history-unavailable";
565
566
  "missing-thread": "missing-thread";
@@ -592,9 +593,9 @@ export declare const readResultSchema: z.ZodObject<{
592
593
  modelId: z.ZodString;
593
594
  rateId: z.ZodNullable<z.ZodString>;
594
595
  basis: z.ZodEnum<{
596
+ unpriced: "unpriced";
595
597
  "closest-model": "closest-model";
596
598
  "provider-default": "provider-default";
597
- unpriced: "unpriced";
598
599
  matched: "matched";
599
600
  }>;
600
601
  }, z.core.$strip>>>;
@@ -686,9 +687,9 @@ export declare const detailRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
686
687
  modelId: z.ZodString;
687
688
  rateId: z.ZodNullable<z.ZodString>;
688
689
  basis: z.ZodEnum<{
690
+ unpriced: "unpriced";
689
691
  "closest-model": "closest-model";
690
692
  "provider-default": "provider-default";
691
- unpriced: "unpriced";
692
693
  matched: "matched";
693
694
  }>;
694
695
  }, z.core.$strip>>>;
@@ -719,9 +720,9 @@ export declare const detailRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
719
720
  modelId: z.ZodString;
720
721
  rateId: z.ZodNullable<z.ZodString>;
721
722
  basis: z.ZodEnum<{
723
+ unpriced: "unpriced";
722
724
  "closest-model": "closest-model";
723
725
  "provider-default": "provider-default";
724
- unpriced: "unpriced";
725
726
  matched: "matched";
726
727
  }>;
727
728
  }, z.core.$strip>>>;
@@ -755,8 +756,8 @@ export declare const detailResultSchema: z.ZodObject<{
755
756
  unknown: "unknown";
756
757
  }>;
757
758
  coverageReasons: z.ZodArray<z.ZodEnum<{
758
- "source-gap": "source-gap";
759
759
  unpriced: "unpriced";
760
+ "source-gap": "source-gap";
760
761
  "root-unattested": "root-unattested";
761
762
  "history-unavailable": "history-unavailable";
762
763
  "missing-thread": "missing-thread";
@@ -784,9 +785,9 @@ export declare const detailResultSchema: z.ZodObject<{
784
785
  modelId: z.ZodString;
785
786
  rateId: z.ZodNullable<z.ZodString>;
786
787
  basis: z.ZodEnum<{
788
+ unpriced: "unpriced";
787
789
  "closest-model": "closest-model";
788
790
  "provider-default": "provider-default";
789
- unpriced: "unpriced";
790
791
  matched: "matched";
791
792
  }>;
792
793
  }, z.core.$strip>>>;
@@ -826,9 +827,9 @@ export declare const detailResultSchema: z.ZodObject<{
826
827
  modelId: z.ZodString;
827
828
  rateId: z.ZodNullable<z.ZodString>;
828
829
  basis: z.ZodEnum<{
830
+ unpriced: "unpriced";
829
831
  "closest-model": "closest-model";
830
832
  "provider-default": "provider-default";
831
- unpriced: "unpriced";
832
833
  matched: "matched";
833
834
  }>;
834
835
  }, z.core.$strip>>>;
@@ -859,9 +860,9 @@ export declare const detailResultSchema: z.ZodObject<{
859
860
  modelId: z.ZodString;
860
861
  rateId: z.ZodNullable<z.ZodString>;
861
862
  basis: z.ZodEnum<{
863
+ unpriced: "unpriced";
862
864
  "closest-model": "closest-model";
863
865
  "provider-default": "provider-default";
864
- unpriced: "unpriced";
865
866
  matched: "matched";
866
867
  }>;
867
868
  }, z.core.$strip>>>;
@@ -879,6 +880,7 @@ export declare const capabilitiesSchema: z.ZodObject<{
879
880
  series: z.ZodBoolean;
880
881
  detail: z.ZodBoolean;
881
882
  recentSnapshotV1: z.ZodOptional<z.ZodBoolean>;
883
+ heatSettingsV1: z.ZodOptional<z.ZodBoolean>;
882
884
  }, z.core.$strip>;
883
885
  export declare const describeV1Schema: z.ZodObject<{
884
886
  protocol: z.ZodLiteral<"bb-thread-metrics">;
@@ -888,6 +890,7 @@ export declare const describeV1Schema: z.ZodObject<{
888
890
  series: z.ZodBoolean;
889
891
  detail: z.ZodBoolean;
890
892
  recentSnapshotV1: z.ZodOptional<z.ZodBoolean>;
893
+ heatSettingsV1: z.ZodOptional<z.ZodBoolean>;
891
894
  }, z.core.$strip>;
892
895
  }, z.core.$loose>;
893
896
  export type ReadInput = z.infer<typeof readInputSchema>;
@@ -0,0 +1,51 @@
1
+ import type { RecentSnapshot, RecentSnapshotInput, RecentPublicationIdentity } from './index.js';
2
+ export interface RecentSnapshotSource {
3
+ readonly pluginId: string;
4
+ recentSnapshot(input: RecentSnapshotInput, signal: AbortSignal): Promise<unknown>;
5
+ }
6
+ export type RecentSessionFailure = 'inactive' | 'busy' | 'aborted-before-start' | 'aborted' | 'timeout' | 'source-replaced' | 'stale-call' | 'stale-publication' | 'publication-conflict' | 'missing-publication';
7
+ export declare class RecentSnapshotSessionError extends Error {
8
+ readonly reason: RecentSessionFailure;
9
+ constructor(reason: RecentSessionFailure);
10
+ }
11
+ /** Local proof only: this session did not invoke a source transport for this call. */
12
+ export declare class RecentSnapshotNotStarted extends RecentSnapshotSessionError {
13
+ readonly notStarted = true;
14
+ constructor(reason: 'inactive' | 'busy' | 'aborted-before-start');
15
+ }
16
+ export interface RecentSnapshotObservation {
17
+ readonly snapshot: RecentSnapshot;
18
+ readonly publication: RecentPublicationIdentity;
19
+ readonly ownerGeneration: number;
20
+ readonly sourceGeneration: number;
21
+ }
22
+ export interface RecentSessionClock {
23
+ later(run: () => void, ms: number): () => void;
24
+ }
25
+ /** ONE instance in an existing native source-owner resource, outside React.
26
+ * No discovery, subscriptions, refresh/retry loop, queue or value graph. The
27
+ * caller drives its existing cadence and owns source-selection authority.
28
+ * Local deadlines/abort/remount/replacement never release an ACTUAL read slot.
29
+ * Do not recreate this instance while it holds a transport. */
30
+ export declare function createRecentSnapshotSession(initial: RecentSnapshotSource, options?: {
31
+ timeoutMs?: number;
32
+ clock?: RecentSessionClock;
33
+ }): {
34
+ readonly current: RecentSnapshotObservation | undefined;
35
+ readonly outstandingReads: 1 | 0;
36
+ readonly ownerGeneration: number;
37
+ readonly sourceGeneration: number;
38
+ readonly pluginId: string;
39
+ /** Ordinary wrapper/reconnect update: same selected source, NO reset. */
40
+ updateSource(value: RecentSnapshotSource): void;
41
+ /** Authoritative selected-source replacement ONLY. A new UUID, lower
42
+ * sequence, timeout or ordinary reconnect is NOT authority to invoke this. */
43
+ replaceSource(value: RecentSnapshotSource): void;
44
+ /** Mount/visibility lifecycle retains both watermark and actual admission. */
45
+ setActive(value: boolean): void;
46
+ read(options?: {
47
+ signal?: AbortSignal;
48
+ full?: boolean;
49
+ }): Promise<RecentSnapshotObservation>;
50
+ };
51
+ export type RecentSnapshotSession = ReturnType<typeof createRecentSnapshotSession>;