@phosphorco/bb-thread-metrics 0.1.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.
@@ -1,3 +1,5 @@
1
+ export * from './recent.js';
2
+ export * from './heat-settings.js';
1
3
  import { z } from 'zod';
2
4
  export type { UsageVector } from '@phosphorco/bb-usage-algebra/vector';
3
5
  export declare const LIMITS: Readonly<{
@@ -23,6 +25,7 @@ export declare const METHODS: Readonly<{
23
25
  describe: "threadMetricsDescribe";
24
26
  read: "threadMetricsReadV1";
25
27
  detail: "threadMetricsDetailV1";
28
+ recentSnapshot: "threadMetricsRecentSnapshotV1";
26
29
  }>;
27
30
  export declare const windowSchema: z.ZodEnum<{
28
31
  m20: "m20";
@@ -36,14 +39,14 @@ export declare const coverageSchema: z.ZodEnum<{
36
39
  unknown: "unknown";
37
40
  }>;
38
41
  export declare const coverageReasonSchema: z.ZodEnum<{
42
+ unpriced: "unpriced";
39
43
  "source-gap": "source-gap";
40
44
  "root-unattested": "root-unattested";
41
45
  "history-unavailable": "history-unavailable";
46
+ "missing-thread": "missing-thread";
42
47
  "member-cap": "member-cap";
43
48
  "depth-cap": "depth-cap";
44
49
  "edge-cap": "edge-cap";
45
- "missing-thread": "missing-thread";
46
- unpriced: "unpriced";
47
50
  retention: "retention";
48
51
  "row-cap": "row-cap";
49
52
  pagination: "pagination";
@@ -52,12 +55,12 @@ export declare const coverageReasonSchema: z.ZodEnum<{
52
55
  export declare const approximationSchema: z.ZodObject<{
53
56
  approximate: z.ZodBoolean;
54
57
  reasons: z.ZodArray<z.ZodEnum<{
55
- "source-gap": "source-gap";
56
58
  "closest-model": "closest-model";
57
59
  "provider-default": "provider-default";
58
60
  "model-attribution": "model-attribution";
59
61
  "bucket-boundary": "bucket-boundary";
60
62
  "missing-price": "missing-price";
63
+ "source-gap": "source-gap";
61
64
  }>>;
62
65
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
66
  providerId: z.ZodString;
@@ -212,14 +215,14 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
212
215
  unknown: "unknown";
213
216
  }>;
214
217
  coverageReasons: z.ZodArray<z.ZodEnum<{
218
+ unpriced: "unpriced";
215
219
  "source-gap": "source-gap";
216
220
  "root-unattested": "root-unattested";
217
221
  "history-unavailable": "history-unavailable";
222
+ "missing-thread": "missing-thread";
218
223
  "member-cap": "member-cap";
219
224
  "depth-cap": "depth-cap";
220
225
  "edge-cap": "edge-cap";
221
- "missing-thread": "missing-thread";
222
- unpriced: "unpriced";
223
226
  retention: "retention";
224
227
  "row-cap": "row-cap";
225
228
  pagination: "pagination";
@@ -234,12 +237,12 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
234
237
  approximation: z.ZodObject<{
235
238
  approximate: z.ZodBoolean;
236
239
  reasons: z.ZodArray<z.ZodEnum<{
237
- "source-gap": "source-gap";
238
240
  "closest-model": "closest-model";
239
241
  "provider-default": "provider-default";
240
242
  "model-attribution": "model-attribution";
241
243
  "bucket-boundary": "bucket-boundary";
242
244
  "missing-price": "missing-price";
245
+ "source-gap": "source-gap";
243
246
  }>>;
244
247
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
245
248
  providerId: z.ZodString;
@@ -308,14 +311,14 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
308
311
  unknown: "unknown";
309
312
  }>;
310
313
  coverageReasons: z.ZodArray<z.ZodEnum<{
314
+ unpriced: "unpriced";
311
315
  "source-gap": "source-gap";
312
316
  "root-unattested": "root-unattested";
313
317
  "history-unavailable": "history-unavailable";
318
+ "missing-thread": "missing-thread";
314
319
  "member-cap": "member-cap";
315
320
  "depth-cap": "depth-cap";
316
321
  "edge-cap": "edge-cap";
317
- "missing-thread": "missing-thread";
318
- unpriced: "unpriced";
319
322
  retention: "retention";
320
323
  "row-cap": "row-cap";
321
324
  pagination: "pagination";
@@ -330,12 +333,12 @@ export declare const summaryRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
330
333
  approximation: z.ZodObject<{
331
334
  approximate: z.ZodBoolean;
332
335
  reasons: z.ZodArray<z.ZodEnum<{
333
- "source-gap": "source-gap";
334
336
  "closest-model": "closest-model";
335
337
  "provider-default": "provider-default";
336
338
  "model-attribution": "model-attribution";
337
339
  "bucket-boundary": "bucket-boundary";
338
340
  "missing-price": "missing-price";
341
+ "source-gap": "source-gap";
339
342
  }>>;
340
343
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
341
344
  providerId: z.ZodString;
@@ -460,14 +463,14 @@ export declare const readResultSchema: z.ZodObject<{
460
463
  unknown: "unknown";
461
464
  }>;
462
465
  coverageReasons: z.ZodArray<z.ZodEnum<{
466
+ unpriced: "unpriced";
463
467
  "source-gap": "source-gap";
464
468
  "root-unattested": "root-unattested";
465
469
  "history-unavailable": "history-unavailable";
470
+ "missing-thread": "missing-thread";
466
471
  "member-cap": "member-cap";
467
472
  "depth-cap": "depth-cap";
468
473
  "edge-cap": "edge-cap";
469
- "missing-thread": "missing-thread";
470
- unpriced: "unpriced";
471
474
  retention: "retention";
472
475
  "row-cap": "row-cap";
473
476
  pagination: "pagination";
@@ -482,12 +485,12 @@ export declare const readResultSchema: z.ZodObject<{
482
485
  approximation: z.ZodObject<{
483
486
  approximate: z.ZodBoolean;
484
487
  reasons: z.ZodArray<z.ZodEnum<{
485
- "source-gap": "source-gap";
486
488
  "closest-model": "closest-model";
487
489
  "provider-default": "provider-default";
488
490
  "model-attribution": "model-attribution";
489
491
  "bucket-boundary": "bucket-boundary";
490
492
  "missing-price": "missing-price";
493
+ "source-gap": "source-gap";
491
494
  }>>;
492
495
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
493
496
  providerId: z.ZodString;
@@ -556,14 +559,14 @@ export declare const readResultSchema: z.ZodObject<{
556
559
  unknown: "unknown";
557
560
  }>;
558
561
  coverageReasons: z.ZodArray<z.ZodEnum<{
562
+ unpriced: "unpriced";
559
563
  "source-gap": "source-gap";
560
564
  "root-unattested": "root-unattested";
561
565
  "history-unavailable": "history-unavailable";
566
+ "missing-thread": "missing-thread";
562
567
  "member-cap": "member-cap";
563
568
  "depth-cap": "depth-cap";
564
569
  "edge-cap": "edge-cap";
565
- "missing-thread": "missing-thread";
566
- unpriced: "unpriced";
567
570
  retention: "retention";
568
571
  "row-cap": "row-cap";
569
572
  pagination: "pagination";
@@ -578,12 +581,12 @@ export declare const readResultSchema: z.ZodObject<{
578
581
  approximation: z.ZodObject<{
579
582
  approximate: z.ZodBoolean;
580
583
  reasons: z.ZodArray<z.ZodEnum<{
581
- "source-gap": "source-gap";
582
584
  "closest-model": "closest-model";
583
585
  "provider-default": "provider-default";
584
586
  "model-attribution": "model-attribution";
585
587
  "bucket-boundary": "bucket-boundary";
586
588
  "missing-price": "missing-price";
589
+ "source-gap": "source-gap";
587
590
  }>>;
588
591
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
589
592
  providerId: z.ZodString;
@@ -646,8 +649,8 @@ export declare const detailInputSchema: z.ZodObject<{
646
649
  }>;
647
650
  includeArchived: z.ZodOptional<z.ZodBoolean>;
648
651
  axis: z.ZodEnum<{
649
- model: "model";
650
652
  time: "time";
653
+ model: "model";
651
654
  }>;
652
655
  window: z.ZodEnum<{
653
656
  m20: "m20";
@@ -672,12 +675,12 @@ export declare const detailRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
672
675
  approximation: z.ZodObject<{
673
676
  approximate: z.ZodBoolean;
674
677
  reasons: z.ZodArray<z.ZodEnum<{
675
- "source-gap": "source-gap";
676
678
  "closest-model": "closest-model";
677
679
  "provider-default": "provider-default";
678
680
  "model-attribution": "model-attribution";
679
681
  "bucket-boundary": "bucket-boundary";
680
682
  "missing-price": "missing-price";
683
+ "source-gap": "source-gap";
681
684
  }>>;
682
685
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
683
686
  providerId: z.ZodString;
@@ -705,12 +708,12 @@ export declare const detailRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
705
708
  approximation: z.ZodObject<{
706
709
  approximate: z.ZodBoolean;
707
710
  reasons: z.ZodArray<z.ZodEnum<{
708
- "source-gap": "source-gap";
709
711
  "closest-model": "closest-model";
710
712
  "provider-default": "provider-default";
711
713
  "model-attribution": "model-attribution";
712
714
  "bucket-boundary": "bucket-boundary";
713
715
  "missing-price": "missing-price";
716
+ "source-gap": "source-gap";
714
717
  }>>;
715
718
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
716
719
  providerId: z.ZodString;
@@ -733,8 +736,8 @@ export declare const detailResultSchema: z.ZodObject<{
733
736
  family: "family";
734
737
  }>;
735
738
  axis: z.ZodEnum<{
736
- model: "model";
737
739
  time: "time";
740
+ model: "model";
738
741
  }>;
739
742
  window: z.ZodEnum<{
740
743
  m20: "m20";
@@ -753,14 +756,14 @@ export declare const detailResultSchema: z.ZodObject<{
753
756
  unknown: "unknown";
754
757
  }>;
755
758
  coverageReasons: z.ZodArray<z.ZodEnum<{
759
+ unpriced: "unpriced";
756
760
  "source-gap": "source-gap";
757
761
  "root-unattested": "root-unattested";
758
762
  "history-unavailable": "history-unavailable";
763
+ "missing-thread": "missing-thread";
759
764
  "member-cap": "member-cap";
760
765
  "depth-cap": "depth-cap";
761
766
  "edge-cap": "edge-cap";
762
- "missing-thread": "missing-thread";
763
- unpriced: "unpriced";
764
767
  retention: "retention";
765
768
  "row-cap": "row-cap";
766
769
  pagination: "pagination";
@@ -770,12 +773,12 @@ export declare const detailResultSchema: z.ZodObject<{
770
773
  approximation: z.ZodObject<{
771
774
  approximate: z.ZodBoolean;
772
775
  reasons: z.ZodArray<z.ZodEnum<{
773
- "source-gap": "source-gap";
774
776
  "closest-model": "closest-model";
775
777
  "provider-default": "provider-default";
776
778
  "model-attribution": "model-attribution";
777
779
  "bucket-boundary": "bucket-boundary";
778
780
  "missing-price": "missing-price";
781
+ "source-gap": "source-gap";
779
782
  }>>;
780
783
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
781
784
  providerId: z.ZodString;
@@ -812,12 +815,12 @@ export declare const detailResultSchema: z.ZodObject<{
812
815
  approximation: z.ZodObject<{
813
816
  approximate: z.ZodBoolean;
814
817
  reasons: z.ZodArray<z.ZodEnum<{
815
- "source-gap": "source-gap";
816
818
  "closest-model": "closest-model";
817
819
  "provider-default": "provider-default";
818
820
  "model-attribution": "model-attribution";
819
821
  "bucket-boundary": "bucket-boundary";
820
822
  "missing-price": "missing-price";
823
+ "source-gap": "source-gap";
821
824
  }>>;
822
825
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
823
826
  providerId: z.ZodString;
@@ -845,12 +848,12 @@ export declare const detailResultSchema: z.ZodObject<{
845
848
  approximation: z.ZodObject<{
846
849
  approximate: z.ZodBoolean;
847
850
  reasons: z.ZodArray<z.ZodEnum<{
848
- "source-gap": "source-gap";
849
851
  "closest-model": "closest-model";
850
852
  "provider-default": "provider-default";
851
853
  "model-attribution": "model-attribution";
852
854
  "bucket-boundary": "bucket-boundary";
853
855
  "missing-price": "missing-price";
856
+ "source-gap": "source-gap";
854
857
  }>>;
855
858
  rates: z.ZodOptional<z.ZodArray<z.ZodObject<{
856
859
  providerId: z.ZodString;
@@ -876,6 +879,8 @@ export declare const capabilitiesSchema: z.ZodObject<{
876
879
  summary: z.ZodLiteral<true>;
877
880
  series: z.ZodBoolean;
878
881
  detail: z.ZodBoolean;
882
+ recentSnapshotV1: z.ZodOptional<z.ZodBoolean>;
883
+ heatSettingsV1: z.ZodOptional<z.ZodBoolean>;
879
884
  }, z.core.$strip>;
880
885
  export declare const describeV1Schema: z.ZodObject<{
881
886
  protocol: z.ZodLiteral<"bb-thread-metrics">;
@@ -884,6 +889,8 @@ export declare const describeV1Schema: z.ZodObject<{
884
889
  summary: z.ZodLiteral<true>;
885
890
  series: z.ZodBoolean;
886
891
  detail: z.ZodBoolean;
892
+ recentSnapshotV1: z.ZodOptional<z.ZodBoolean>;
893
+ heatSettingsV1: z.ZodOptional<z.ZodBoolean>;
887
894
  }, z.core.$strip>;
888
895
  }, z.core.$loose>;
889
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>;