@holonograph/client 0.4.0 → 0.5.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.
package/README.md CHANGED
@@ -93,6 +93,37 @@ status, an error code, and any details the lens returned.
93
93
 
94
94
  Everything is fully typed; the package ships its own type declarations.
95
95
 
96
+ ## Watching for changes
97
+
98
+ Pull-side alerting, transport-agnostic. Poll any windowed lens read on a cadence
99
+ and act only on the delta — a steady state is silent (the same "no all-quiet
100
+ pings" discipline the lens applies to its own output). You supply the fetch and
101
+ where the change goes; the client supplies the cadence and change-detection.
102
+
103
+ - **`watchByKey({ poll, intervalMs, keyOf, onChange })`** — poll a collection and
104
+ fire `onChange(diff)` only when items are `added` / `removed` / `changed`
105
+ (matched by `keyOf`). Returns a handle with `.stop()`. The first poll silently
106
+ seeds the baseline, so you only hear about change since the watch started (pass
107
+ `emitInitial: true` for a cold-start inventory).
108
+ - **`diffByKey(prev, next, keyOf)`** / **`hasChanges(diff)`** — the underlying
109
+ keyed diff, if you want change-detection without the loop.
110
+ - **`createPoller({ poll, intervalMs, onResult })`** — the bare cadence loop
111
+ (non-overlapping; errors isolated to `onError`, never kill the watcher).
112
+ - **`watchReconciliation(...)` / `watchEmission(...)`** — typed sugar over
113
+ `watchByKey` for the lens's reconciliation + emission reads.
114
+
115
+ ```ts
116
+ import { watchByKey } from '@holonograph/client';
117
+
118
+ const handle = watchByKey({
119
+ poll: (signal) => fetchReconciliation({ signal }), // your windowed read
120
+ intervalMs: 30_000,
121
+ keyOf: (row) => row.emissionStreamId,
122
+ onChange: (diff) => notifyOnCall(diff), // added / removed / changed only
123
+ });
124
+ // later: handle.stop();
125
+ ```
126
+
96
127
  ## Requirements
97
128
 
98
129
  This client does nothing on its own — it needs a **running Holonograph lens** to
package/dist/index.d.ts CHANGED
@@ -1768,6 +1768,9 @@ declare enum ZodFirstPartyTypeKind {
1768
1768
  declare const RunModeSchema: ZodEnum<["production", "test", "eval", "replay", "local_dev"]>;
1769
1769
  type RunMode = TypeOf<typeof RunModeSchema>;
1770
1770
 
1771
+ declare const EmissionExpectationSchema: ZodEnum$1<["always", "conditional"]>;
1772
+ type EmissionExpectation = TypeOf$1<typeof EmissionExpectationSchema>;
1773
+
1771
1774
  declare const SubstrateSnapshotSchema: ZodObject<{
1772
1775
  lensVersion: ZodString;
1773
1776
  lightSourceIdentifier: ZodString;
@@ -5932,6 +5935,22 @@ declare const LightSnapshotSchema: ZodObject<{
5932
5935
 
5933
5936
  rawResponsePresence: ZodOptional$1<ZodEnum$1<["present", "omitted-by-policy", "pending-attach", "failed-attach"]>>;
5934
5937
  }, "strip", ZodTypeAny$1, {
5938
+ rawResponse?: unknown;
5939
+ toolCalls?: unknown[] | undefined;
5940
+ tokens?: {
5941
+ input?: number | undefined;
5942
+ output?: number | undefined;
5943
+ cacheRead?: number | undefined;
5944
+ cacheWrite?: number | undefined;
5945
+ } | undefined;
5946
+ latencyMs?: number | undefined;
5947
+ reasoning?: string | undefined;
5948
+ vendorMetadata?: Record<string, unknown> | undefined;
5949
+ error?: {
5950
+ message: string;
5951
+ type: string;
5952
+ vendorErrorCode?: string | undefined;
5953
+ } | undefined;
5935
5954
  rawRequest?: objectOutputType<{
5936
5955
  surfaceId: ZodString;
5937
5956
  correlationId: ZodOptional$1<ZodString>;
@@ -6110,8 +6129,10 @@ declare const LightSnapshotSchema: ZodObject<{
6110
6129
  strict: ZodOptional$1<ZodBoolean>;
6111
6130
  stream: ZodOptional$1<ZodBoolean>;
6112
6131
  }, ZodTypeAny$1, "passthrough"> | undefined;
6132
+ rawRequestOmitted?: boolean | undefined;
6133
+ rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
6134
+ }, {
6113
6135
  rawResponse?: unknown;
6114
- reasoning?: string | undefined;
6115
6136
  toolCalls?: unknown[] | undefined;
6116
6137
  tokens?: {
6117
6138
  input?: number | undefined;
@@ -6120,15 +6141,13 @@ declare const LightSnapshotSchema: ZodObject<{
6120
6141
  cacheWrite?: number | undefined;
6121
6142
  } | undefined;
6122
6143
  latencyMs?: number | undefined;
6144
+ reasoning?: string | undefined;
6145
+ vendorMetadata?: Record<string, unknown> | undefined;
6123
6146
  error?: {
6124
6147
  message: string;
6125
6148
  type: string;
6126
6149
  vendorErrorCode?: string | undefined;
6127
6150
  } | undefined;
6128
- vendorMetadata?: Record<string, unknown> | undefined;
6129
- rawRequestOmitted?: boolean | undefined;
6130
- rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
6131
- }, {
6132
6151
  rawRequest?: objectInputType<{
6133
6152
  surfaceId: ZodString;
6134
6153
  correlationId: ZodOptional$1<ZodString>;
@@ -6307,22 +6326,6 @@ declare const LightSnapshotSchema: ZodObject<{
6307
6326
  strict: ZodOptional$1<ZodBoolean>;
6308
6327
  stream: ZodOptional$1<ZodBoolean>;
6309
6328
  }, ZodTypeAny$1, "passthrough"> | undefined;
6310
- rawResponse?: unknown;
6311
- reasoning?: string | undefined;
6312
- toolCalls?: unknown[] | undefined;
6313
- tokens?: {
6314
- input?: number | undefined;
6315
- output?: number | undefined;
6316
- cacheRead?: number | undefined;
6317
- cacheWrite?: number | undefined;
6318
- } | undefined;
6319
- latencyMs?: number | undefined;
6320
- error?: {
6321
- message: string;
6322
- type: string;
6323
- vendorErrorCode?: string | undefined;
6324
- } | undefined;
6325
- vendorMetadata?: Record<string, unknown> | undefined;
6326
6329
  rawRequestOmitted?: boolean | undefined;
6327
6330
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
6328
6331
  }>;
@@ -6392,7 +6395,7 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
6392
6395
 
6393
6396
  lensVersion: ZodString;
6394
6397
 
6395
- kind: ZodDefault$1<ZodEnum$1<["evaluation", "availability.transition", "analysis.noise-floor-calibration", "analysis.variance-decomposition", "analysis.lifecycle-transition", "analysis.eval-recommendation", "analysis.conformance-fixture", "analysis.emission-coverage", "analysis.delivery-orphan"]>>;
6398
+ kind: ZodDefault$1<ZodEnum$1<["evaluation", "availability.transition", "analysis.noise-floor-calibration", "analysis.variance-decomposition", "analysis.lifecycle-transition", "analysis.eval-recommendation", "analysis.conformance-fixture", "analysis.emission-coverage", "analysis.delivery-orphan", "analysis.orthogonality-hypothesis"]>>;
6396
6399
 
6397
6400
  light: ZodOptional$1<ZodObject<{
6398
6401
 
@@ -6974,6 +6977,22 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
6974
6977
 
6975
6978
  rawResponsePresence: ZodOptional$1<ZodEnum$1<["present", "omitted-by-policy", "pending-attach", "failed-attach"]>>;
6976
6979
  }, "strip", ZodTypeAny$1, {
6980
+ rawResponse?: unknown;
6981
+ toolCalls?: unknown[] | undefined;
6982
+ tokens?: {
6983
+ input?: number | undefined;
6984
+ output?: number | undefined;
6985
+ cacheRead?: number | undefined;
6986
+ cacheWrite?: number | undefined;
6987
+ } | undefined;
6988
+ latencyMs?: number | undefined;
6989
+ reasoning?: string | undefined;
6990
+ vendorMetadata?: Record<string, unknown> | undefined;
6991
+ error?: {
6992
+ message: string;
6993
+ type: string;
6994
+ vendorErrorCode?: string | undefined;
6995
+ } | undefined;
6977
6996
  rawRequest?: objectOutputType<{
6978
6997
  surfaceId: ZodString;
6979
6998
  correlationId: ZodOptional$1<ZodString>;
@@ -7152,8 +7171,10 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
7152
7171
  strict: ZodOptional$1<ZodBoolean>;
7153
7172
  stream: ZodOptional$1<ZodBoolean>;
7154
7173
  }, ZodTypeAny$1, "passthrough"> | undefined;
7174
+ rawRequestOmitted?: boolean | undefined;
7175
+ rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
7176
+ }, {
7155
7177
  rawResponse?: unknown;
7156
- reasoning?: string | undefined;
7157
7178
  toolCalls?: unknown[] | undefined;
7158
7179
  tokens?: {
7159
7180
  input?: number | undefined;
@@ -7162,15 +7183,13 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
7162
7183
  cacheWrite?: number | undefined;
7163
7184
  } | undefined;
7164
7185
  latencyMs?: number | undefined;
7186
+ reasoning?: string | undefined;
7187
+ vendorMetadata?: Record<string, unknown> | undefined;
7165
7188
  error?: {
7166
7189
  message: string;
7167
7190
  type: string;
7168
7191
  vendorErrorCode?: string | undefined;
7169
7192
  } | undefined;
7170
- vendorMetadata?: Record<string, unknown> | undefined;
7171
- rawRequestOmitted?: boolean | undefined;
7172
- rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
7173
- }, {
7174
7193
  rawRequest?: objectInputType<{
7175
7194
  surfaceId: ZodString;
7176
7195
  correlationId: ZodOptional$1<ZodString>;
@@ -7349,22 +7368,6 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
7349
7368
  strict: ZodOptional$1<ZodBoolean>;
7350
7369
  stream: ZodOptional$1<ZodBoolean>;
7351
7370
  }, ZodTypeAny$1, "passthrough"> | undefined;
7352
- rawResponse?: unknown;
7353
- reasoning?: string | undefined;
7354
- toolCalls?: unknown[] | undefined;
7355
- tokens?: {
7356
- input?: number | undefined;
7357
- output?: number | undefined;
7358
- cacheRead?: number | undefined;
7359
- cacheWrite?: number | undefined;
7360
- } | undefined;
7361
- latencyMs?: number | undefined;
7362
- error?: {
7363
- message: string;
7364
- type: string;
7365
- vendorErrorCode?: string | undefined;
7366
- } | undefined;
7367
- vendorMetadata?: Record<string, unknown> | undefined;
7368
7371
  rawRequestOmitted?: boolean | undefined;
7369
7372
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
7370
7373
  }>>;
@@ -8310,11 +8313,73 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8310
8313
  emissionStreamId: string;
8311
8314
  witnessedAtMs: number;
8312
8315
  }>>;
8316
+
8317
+ orthogonalityHypothesis: ZodOptional$1<ZodObject<{
8318
+
8319
+ draftId: ZodString;
8320
+
8321
+ targetSurfaceId: ZodString;
8322
+
8323
+ targetDimensionId: ZodString;
8324
+
8325
+ candidateColumnId: ZodString;
8326
+
8327
+ proposedHypothesis: ZodString;
8328
+
8329
+ evidence: ZodObject<{
8330
+ scoredEventCount: ZodNumber;
8331
+ sigmaObservedSquared: ZodNumber;
8332
+ sigmaAgentSquared: ZodNumber;
8333
+ sigmaAgentCILower: ZodNumber;
8334
+ }, "strip", ZodTypeAny$1, {
8335
+ scoredEventCount: number;
8336
+ sigmaObservedSquared: number;
8337
+ sigmaAgentSquared: number;
8338
+ sigmaAgentCILower: number;
8339
+ }, {
8340
+ scoredEventCount: number;
8341
+ sigmaObservedSquared: number;
8342
+ sigmaAgentSquared: number;
8343
+ sigmaAgentCILower: number;
8344
+ }>;
8345
+
8346
+ approverId: ZodString;
8347
+
8348
+ occurredAt: ZodString;
8349
+ }, "strip", ZodTypeAny$1, {
8350
+ approverId: string;
8351
+ occurredAt: string;
8352
+ draftId: string;
8353
+ targetSurfaceId: string;
8354
+ targetDimensionId: string;
8355
+ candidateColumnId: string;
8356
+ proposedHypothesis: string;
8357
+ evidence: {
8358
+ scoredEventCount: number;
8359
+ sigmaObservedSquared: number;
8360
+ sigmaAgentSquared: number;
8361
+ sigmaAgentCILower: number;
8362
+ };
8363
+ }, {
8364
+ approverId: string;
8365
+ occurredAt: string;
8366
+ draftId: string;
8367
+ targetSurfaceId: string;
8368
+ targetDimensionId: string;
8369
+ candidateColumnId: string;
8370
+ proposedHypothesis: string;
8371
+ evidence: {
8372
+ scoredEventCount: number;
8373
+ sigmaObservedSquared: number;
8374
+ sigmaAgentSquared: number;
8375
+ sigmaAgentCILower: number;
8376
+ };
8377
+ }>>;
8313
8378
  }, "strip", ZodTypeAny$1, {
8314
8379
  lensVersion: string;
8315
8380
  correlationId: string;
8316
8381
  surfaceId: string;
8317
- kind: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan";
8382
+ kind: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | "analysis.orthogonality-hypothesis";
8318
8383
  occurredAt: string;
8319
8384
  eventId: string;
8320
8385
  substrate?: {
@@ -8328,6 +8393,22 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8328
8393
  } | undefined;
8329
8394
  emissionStreamId?: string | undefined;
8330
8395
  light?: {
8396
+ rawResponse?: unknown;
8397
+ toolCalls?: unknown[] | undefined;
8398
+ tokens?: {
8399
+ input?: number | undefined;
8400
+ output?: number | undefined;
8401
+ cacheRead?: number | undefined;
8402
+ cacheWrite?: number | undefined;
8403
+ } | undefined;
8404
+ latencyMs?: number | undefined;
8405
+ reasoning?: string | undefined;
8406
+ vendorMetadata?: Record<string, unknown> | undefined;
8407
+ error?: {
8408
+ message: string;
8409
+ type: string;
8410
+ vendorErrorCode?: string | undefined;
8411
+ } | undefined;
8331
8412
  rawRequest?: objectOutputType<{
8332
8413
  surfaceId: ZodString;
8333
8414
  correlationId: ZodOptional$1<ZodString>;
@@ -8506,22 +8587,6 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8506
8587
  strict: ZodOptional$1<ZodBoolean>;
8507
8588
  stream: ZodOptional$1<ZodBoolean>;
8508
8589
  }, ZodTypeAny$1, "passthrough"> | undefined;
8509
- rawResponse?: unknown;
8510
- reasoning?: string | undefined;
8511
- toolCalls?: unknown[] | undefined;
8512
- tokens?: {
8513
- input?: number | undefined;
8514
- output?: number | undefined;
8515
- cacheRead?: number | undefined;
8516
- cacheWrite?: number | undefined;
8517
- } | undefined;
8518
- latencyMs?: number | undefined;
8519
- error?: {
8520
- message: string;
8521
- type: string;
8522
- vendorErrorCode?: string | undefined;
8523
- } | undefined;
8524
- vendorMetadata?: Record<string, unknown> | undefined;
8525
8590
  rawRequestOmitted?: boolean | undefined;
8526
8591
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
8527
8592
  } | undefined;
@@ -8691,6 +8756,21 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8691
8756
  emissionStreamId: string;
8692
8757
  witnessedAtMs: number;
8693
8758
  } | undefined;
8759
+ orthogonalityHypothesis?: {
8760
+ approverId: string;
8761
+ occurredAt: string;
8762
+ draftId: string;
8763
+ targetSurfaceId: string;
8764
+ targetDimensionId: string;
8765
+ candidateColumnId: string;
8766
+ proposedHypothesis: string;
8767
+ evidence: {
8768
+ scoredEventCount: number;
8769
+ sigmaObservedSquared: number;
8770
+ sigmaAgentSquared: number;
8771
+ sigmaAgentCILower: number;
8772
+ };
8773
+ } | undefined;
8694
8774
  }, {
8695
8775
  lensVersion: string;
8696
8776
  correlationId: string;
@@ -8706,9 +8786,25 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8706
8786
  correlationId: string;
8707
8787
  columns: Record<string, string>;
8708
8788
  } | undefined;
8709
- kind?: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | undefined;
8789
+ kind?: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | "analysis.orthogonality-hypothesis" | undefined;
8710
8790
  emissionStreamId?: string | undefined;
8711
8791
  light?: {
8792
+ rawResponse?: unknown;
8793
+ toolCalls?: unknown[] | undefined;
8794
+ tokens?: {
8795
+ input?: number | undefined;
8796
+ output?: number | undefined;
8797
+ cacheRead?: number | undefined;
8798
+ cacheWrite?: number | undefined;
8799
+ } | undefined;
8800
+ latencyMs?: number | undefined;
8801
+ reasoning?: string | undefined;
8802
+ vendorMetadata?: Record<string, unknown> | undefined;
8803
+ error?: {
8804
+ message: string;
8805
+ type: string;
8806
+ vendorErrorCode?: string | undefined;
8807
+ } | undefined;
8712
8808
  rawRequest?: objectInputType<{
8713
8809
  surfaceId: ZodString;
8714
8810
  correlationId: ZodOptional$1<ZodString>;
@@ -8887,22 +8983,6 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
8887
8983
  strict: ZodOptional$1<ZodBoolean>;
8888
8984
  stream: ZodOptional$1<ZodBoolean>;
8889
8985
  }, ZodTypeAny$1, "passthrough"> | undefined;
8890
- rawResponse?: unknown;
8891
- reasoning?: string | undefined;
8892
- toolCalls?: unknown[] | undefined;
8893
- tokens?: {
8894
- input?: number | undefined;
8895
- output?: number | undefined;
8896
- cacheRead?: number | undefined;
8897
- cacheWrite?: number | undefined;
8898
- } | undefined;
8899
- latencyMs?: number | undefined;
8900
- error?: {
8901
- message: string;
8902
- type: string;
8903
- vendorErrorCode?: string | undefined;
8904
- } | undefined;
8905
- vendorMetadata?: Record<string, unknown> | undefined;
8906
8986
  rawRequestOmitted?: boolean | undefined;
8907
8987
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
8908
8988
  } | undefined;
@@ -9072,11 +9152,26 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9072
9152
  emissionStreamId: string;
9073
9153
  witnessedAtMs: number;
9074
9154
  } | undefined;
9155
+ orthogonalityHypothesis?: {
9156
+ approverId: string;
9157
+ occurredAt: string;
9158
+ draftId: string;
9159
+ targetSurfaceId: string;
9160
+ targetDimensionId: string;
9161
+ candidateColumnId: string;
9162
+ proposedHypothesis: string;
9163
+ evidence: {
9164
+ scoredEventCount: number;
9165
+ sigmaObservedSquared: number;
9166
+ sigmaAgentSquared: number;
9167
+ sigmaAgentCILower: number;
9168
+ };
9169
+ } | undefined;
9075
9170
  }>, {
9076
9171
  lensVersion: string;
9077
9172
  correlationId: string;
9078
9173
  surfaceId: string;
9079
- kind: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan";
9174
+ kind: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | "analysis.orthogonality-hypothesis";
9080
9175
  occurredAt: string;
9081
9176
  eventId: string;
9082
9177
  substrate?: {
@@ -9090,6 +9185,22 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9090
9185
  } | undefined;
9091
9186
  emissionStreamId?: string | undefined;
9092
9187
  light?: {
9188
+ rawResponse?: unknown;
9189
+ toolCalls?: unknown[] | undefined;
9190
+ tokens?: {
9191
+ input?: number | undefined;
9192
+ output?: number | undefined;
9193
+ cacheRead?: number | undefined;
9194
+ cacheWrite?: number | undefined;
9195
+ } | undefined;
9196
+ latencyMs?: number | undefined;
9197
+ reasoning?: string | undefined;
9198
+ vendorMetadata?: Record<string, unknown> | undefined;
9199
+ error?: {
9200
+ message: string;
9201
+ type: string;
9202
+ vendorErrorCode?: string | undefined;
9203
+ } | undefined;
9093
9204
  rawRequest?: objectOutputType<{
9094
9205
  surfaceId: ZodString;
9095
9206
  correlationId: ZodOptional$1<ZodString>;
@@ -9268,22 +9379,6 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9268
9379
  strict: ZodOptional$1<ZodBoolean>;
9269
9380
  stream: ZodOptional$1<ZodBoolean>;
9270
9381
  }, ZodTypeAny$1, "passthrough"> | undefined;
9271
- rawResponse?: unknown;
9272
- reasoning?: string | undefined;
9273
- toolCalls?: unknown[] | undefined;
9274
- tokens?: {
9275
- input?: number | undefined;
9276
- output?: number | undefined;
9277
- cacheRead?: number | undefined;
9278
- cacheWrite?: number | undefined;
9279
- } | undefined;
9280
- latencyMs?: number | undefined;
9281
- error?: {
9282
- message: string;
9283
- type: string;
9284
- vendorErrorCode?: string | undefined;
9285
- } | undefined;
9286
- vendorMetadata?: Record<string, unknown> | undefined;
9287
9382
  rawRequestOmitted?: boolean | undefined;
9288
9383
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
9289
9384
  } | undefined;
@@ -9453,6 +9548,21 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9453
9548
  emissionStreamId: string;
9454
9549
  witnessedAtMs: number;
9455
9550
  } | undefined;
9551
+ orthogonalityHypothesis?: {
9552
+ approverId: string;
9553
+ occurredAt: string;
9554
+ draftId: string;
9555
+ targetSurfaceId: string;
9556
+ targetDimensionId: string;
9557
+ candidateColumnId: string;
9558
+ proposedHypothesis: string;
9559
+ evidence: {
9560
+ scoredEventCount: number;
9561
+ sigmaObservedSquared: number;
9562
+ sigmaAgentSquared: number;
9563
+ sigmaAgentCILower: number;
9564
+ };
9565
+ } | undefined;
9456
9566
  }, {
9457
9567
  lensVersion: string;
9458
9568
  correlationId: string;
@@ -9468,9 +9578,25 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9468
9578
  correlationId: string;
9469
9579
  columns: Record<string, string>;
9470
9580
  } | undefined;
9471
- kind?: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | undefined;
9581
+ kind?: "evaluation" | "availability.transition" | "analysis.noise-floor-calibration" | "analysis.variance-decomposition" | "analysis.lifecycle-transition" | "analysis.eval-recommendation" | "analysis.conformance-fixture" | "analysis.emission-coverage" | "analysis.delivery-orphan" | "analysis.orthogonality-hypothesis" | undefined;
9472
9582
  emissionStreamId?: string | undefined;
9473
9583
  light?: {
9584
+ rawResponse?: unknown;
9585
+ toolCalls?: unknown[] | undefined;
9586
+ tokens?: {
9587
+ input?: number | undefined;
9588
+ output?: number | undefined;
9589
+ cacheRead?: number | undefined;
9590
+ cacheWrite?: number | undefined;
9591
+ } | undefined;
9592
+ latencyMs?: number | undefined;
9593
+ reasoning?: string | undefined;
9594
+ vendorMetadata?: Record<string, unknown> | undefined;
9595
+ error?: {
9596
+ message: string;
9597
+ type: string;
9598
+ vendorErrorCode?: string | undefined;
9599
+ } | undefined;
9474
9600
  rawRequest?: objectInputType<{
9475
9601
  surfaceId: ZodString;
9476
9602
  correlationId: ZodOptional$1<ZodString>;
@@ -9649,22 +9775,6 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9649
9775
  strict: ZodOptional$1<ZodBoolean>;
9650
9776
  stream: ZodOptional$1<ZodBoolean>;
9651
9777
  }, ZodTypeAny$1, "passthrough"> | undefined;
9652
- rawResponse?: unknown;
9653
- reasoning?: string | undefined;
9654
- toolCalls?: unknown[] | undefined;
9655
- tokens?: {
9656
- input?: number | undefined;
9657
- output?: number | undefined;
9658
- cacheRead?: number | undefined;
9659
- cacheWrite?: number | undefined;
9660
- } | undefined;
9661
- latencyMs?: number | undefined;
9662
- error?: {
9663
- message: string;
9664
- type: string;
9665
- vendorErrorCode?: string | undefined;
9666
- } | undefined;
9667
- vendorMetadata?: Record<string, unknown> | undefined;
9668
9778
  rawRequestOmitted?: boolean | undefined;
9669
9779
  rawResponsePresence?: "present" | "omitted-by-policy" | "pending-attach" | "failed-attach" | undefined;
9670
9780
  } | undefined;
@@ -9834,6 +9944,21 @@ declare const EvaluationEventSchema: ZodEffects$1<ZodObject<{
9834
9944
  emissionStreamId: string;
9835
9945
  witnessedAtMs: number;
9836
9946
  } | undefined;
9947
+ orthogonalityHypothesis?: {
9948
+ approverId: string;
9949
+ occurredAt: string;
9950
+ draftId: string;
9951
+ targetSurfaceId: string;
9952
+ targetDimensionId: string;
9953
+ candidateColumnId: string;
9954
+ proposedHypothesis: string;
9955
+ evidence: {
9956
+ scoredEventCount: number;
9957
+ sigmaObservedSquared: number;
9958
+ sigmaAgentSquared: number;
9959
+ sigmaAgentCILower: number;
9960
+ };
9961
+ } | undefined;
9837
9962
  }>;
9838
9963
  type EvaluationEvent = TypeOf$1<typeof EvaluationEventSchema>;
9839
9964
 
@@ -10074,6 +10199,7 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10074
10199
  output?: unknown;
10075
10200
  isError?: boolean | undefined;
10076
10201
  })[];
10202
+ ok: true;
10077
10203
  tokens: {
10078
10204
  input: number;
10079
10205
  output: number;
@@ -10081,14 +10207,13 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10081
10207
  cacheWrite?: number | undefined;
10082
10208
  };
10083
10209
  latencyMs: number;
10084
- ok: true;
10085
10210
  rawResponse?: unknown;
10086
- reasoning?: string | undefined;
10087
10211
  toolCalls?: {
10088
10212
  toolUseId: string;
10089
10213
  toolName: string;
10090
10214
  input?: unknown;
10091
10215
  }[] | undefined;
10216
+ reasoning?: string | undefined;
10092
10217
  vendorMetadata?: Record<string, unknown> | undefined;
10093
10218
  stopReason?: "tool_use" | "end_turn" | "max_tokens" | "stop_sequence" | "refusal" | "other" | undefined;
10094
10219
  }, {
@@ -10107,6 +10232,7 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10107
10232
  output?: unknown;
10108
10233
  isError?: boolean | undefined;
10109
10234
  })[];
10235
+ ok: true;
10110
10236
  tokens: {
10111
10237
  input: number;
10112
10238
  output: number;
@@ -10114,14 +10240,13 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10114
10240
  cacheWrite?: number | undefined;
10115
10241
  };
10116
10242
  latencyMs: number;
10117
- ok: true;
10118
10243
  rawResponse?: unknown;
10119
- reasoning?: string | undefined;
10120
10244
  toolCalls?: {
10121
10245
  toolUseId: string;
10122
10246
  toolName: string;
10123
10247
  input?: unknown;
10124
10248
  }[] | undefined;
10249
+ reasoning?: string | undefined;
10125
10250
  vendorMetadata?: Record<string, unknown> | undefined;
10126
10251
  stopReason?: "tool_use" | "end_turn" | "max_tokens" | "stop_sequence" | "refusal" | "other" | undefined;
10127
10252
  }>, ZodObject<{
@@ -10152,6 +10277,7 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10152
10277
 
10153
10278
  vendorMetadata: ZodOptional$1<ZodRecord<ZodString, ZodUnknown>>;
10154
10279
  }, "strip", ZodTypeAny$1, {
10280
+ ok: false;
10155
10281
  latencyMs: number;
10156
10282
  error: {
10157
10283
  message: string;
@@ -10159,10 +10285,10 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10159
10285
  retryable: boolean;
10160
10286
  vendorErrorCode?: string | undefined;
10161
10287
  };
10162
- ok: false;
10163
10288
  rawResponse?: unknown;
10164
10289
  vendorMetadata?: Record<string, unknown> | undefined;
10165
10290
  }, {
10291
+ ok: false;
10166
10292
  latencyMs: number;
10167
10293
  error: {
10168
10294
  message: string;
@@ -10170,7 +10296,6 @@ declare const LightSourceResultSchema: ZodDiscriminatedUnion<"ok", [ZodObject<{
10170
10296
  retryable: boolean;
10171
10297
  vendorErrorCode?: string | undefined;
10172
10298
  };
10173
- ok: false;
10174
10299
  rawResponse?: unknown;
10175
10300
  vendorMetadata?: Record<string, unknown> | undefined;
10176
10301
  }>]>;
@@ -11049,6 +11174,92 @@ declare const LensAvailabilityMarkResponseSchema: ZodObject<{
11049
11174
  }>;
11050
11175
  type LensAvailabilityMarkResponse = TypeOf$1<typeof LensAvailabilityMarkResponseSchema>;
11051
11176
 
11177
+ interface LensReadWindow {
11178
+ readonly since?: string;
11179
+ readonly until?: string;
11180
+ }
11181
+
11182
+ interface ReconciliationQuery extends LensReadWindow {
11183
+ readonly emissionStreamId?: string;
11184
+ }
11185
+
11186
+ interface EmissionAuditQuery extends LensReadWindow {
11187
+ readonly surfaceId?: string;
11188
+ }
11189
+
11190
+ interface EmitterReconciliation {
11191
+ readonly emissionStreamId: string;
11192
+
11193
+ readonly persisted: number;
11194
+
11195
+ readonly dark: number;
11196
+
11197
+ readonly total: number;
11198
+
11199
+ readonly completeness: number;
11200
+
11201
+ readonly darkEventIds: readonly string[];
11202
+ }
11203
+
11204
+ interface ReconciliationSummary {
11205
+ readonly emitterCount: number;
11206
+ readonly totalPersisted: number;
11207
+ readonly totalDark: number;
11208
+
11209
+ readonly overallCompleteness: number;
11210
+ }
11211
+
11212
+ interface ReconciliationReport {
11213
+ readonly emitters: readonly EmitterReconciliation[];
11214
+ readonly summary: ReconciliationSummary;
11215
+ }
11216
+
11217
+ interface ReconciliationResponse extends ReconciliationReport {
11218
+ readonly since?: string;
11219
+ readonly until?: string;
11220
+ }
11221
+
11222
+ type ColumnEmissionVerdict = 'no-data' | 'ok' | 'partial' | 'expectation-mismatch' | 'missing' | 'present' | 'absent';
11223
+ interface ColumnEmissionByDay {
11224
+
11225
+ readonly date: string;
11226
+
11227
+ readonly populated: number;
11228
+
11229
+ readonly total: number;
11230
+ }
11231
+ interface ColumnEmissionRow {
11232
+ readonly columnId: string;
11233
+
11234
+ readonly emissionExpectation: EmissionExpectation;
11235
+
11236
+ readonly populated: number;
11237
+
11238
+ readonly total: number;
11239
+
11240
+ readonly verdict: ColumnEmissionVerdict;
11241
+
11242
+ readonly byDay: readonly ColumnEmissionByDay[];
11243
+
11244
+ readonly firstEmittedAt: string | null;
11245
+ readonly lastEmittedAt: string | null;
11246
+ }
11247
+ interface SurfaceColumnEmission {
11248
+ readonly surfaceId: string;
11249
+
11250
+ readonly total: number;
11251
+
11252
+ readonly columns: readonly ColumnEmissionRow[];
11253
+
11254
+ readonly undeclaredObserved: readonly string[];
11255
+ }
11256
+
11257
+ interface EmissionAuditResponse {
11258
+ readonly since?: string;
11259
+ readonly until?: string;
11260
+ readonly surfaces: readonly SurfaceColumnEmission[];
11261
+ }
11262
+
11052
11263
  interface HolonographCallHandle {
11053
11264
 
11054
11265
  result: MediatorCallResult | GateExecutionResult;
@@ -11223,6 +11434,10 @@ interface Transport {
11223
11434
 
11224
11435
  getContract?(): Promise<ContractRegisterResponse>;
11225
11436
 
11437
+ getReconciliation?(query?: ReconciliationQuery): Promise<ReconciliationResponse>;
11438
+
11439
+ getEmission?(query?: EmissionAuditQuery): Promise<EmissionAuditResponse>;
11440
+
11226
11441
  markAvailability?(req: LensAvailabilityMarkRequest): Promise<LensAvailabilityMarkResponse>;
11227
11442
  }
11228
11443
 
@@ -11265,12 +11480,112 @@ declare class HttpTransport implements Transport {
11265
11480
  shutdown(): Promise<void>;
11266
11481
  postContract(contract: SurfaceContract): Promise<ContractRegisterResponse>;
11267
11482
  getContract(): Promise<ContractRegisterResponse>;
11483
+ getReconciliation(query?: ReconciliationQuery): Promise<ReconciliationResponse>;
11484
+ getEmission(query?: EmissionAuditQuery): Promise<EmissionAuditResponse>;
11268
11485
  markAvailability(req: LensAvailabilityMarkRequest): Promise<LensAvailabilityMarkResponse>;
11269
11486
  private post;
11270
11487
 
11271
11488
  private get;
11272
11489
  }
11273
11490
 
11491
+ interface KeyedDiff<T> {
11492
+
11493
+ added: T[];
11494
+
11495
+ removed: T[];
11496
+
11497
+ changed: {
11498
+ key: string;
11499
+ prev: T;
11500
+ next: T;
11501
+ }[];
11502
+
11503
+ unchanged: T[];
11504
+ }
11505
+
11506
+ declare function hasChanges<T>(diff: KeyedDiff<T>): boolean;
11507
+
11508
+ declare function diffByKey<T>(prev: readonly T[], next: readonly T[], keyOf: (item: T) => string, opts?: {
11509
+ equals?: (a: T, b: T) => boolean;
11510
+ }): KeyedDiff<T>;
11511
+
11512
+ interface PollerHandle {
11513
+
11514
+ stop(): void;
11515
+ }
11516
+ interface PollerOptions<T> {
11517
+
11518
+ poll: (signal: AbortSignal) => Promise<T>;
11519
+
11520
+ intervalMs: number;
11521
+
11522
+ onResult: (result: T) => void | Promise<void>;
11523
+
11524
+ onError?: (err: unknown) => void;
11525
+
11526
+ signal?: AbortSignal;
11527
+
11528
+ immediate?: boolean;
11529
+ }
11530
+
11531
+ declare function createPoller<T>(opts: PollerOptions<T>): PollerHandle;
11532
+ interface WatchByKeyOptions<T> {
11533
+
11534
+ poll: (signal: AbortSignal) => Promise<readonly T[]>;
11535
+
11536
+ intervalMs: number;
11537
+
11538
+ keyOf: (item: T) => string;
11539
+
11540
+ onChange: (diff: KeyedDiff<T>) => void | Promise<void>;
11541
+
11542
+ equals?: (a: T, b: T) => boolean;
11543
+
11544
+ onError?: (err: unknown) => void;
11545
+
11546
+ signal?: AbortSignal;
11547
+
11548
+ emitInitial?: boolean;
11549
+ }
11550
+
11551
+ declare function watchByKey<T>(opts: WatchByKeyOptions<T>): PollerHandle;
11552
+
11553
+ interface ReconciliationReader {
11554
+ getReconciliation(query?: ReconciliationQuery): Promise<ReconciliationResponse>;
11555
+ }
11556
+
11557
+ interface EmissionReader {
11558
+ getEmission(query?: EmissionAuditQuery): Promise<EmissionAuditResponse>;
11559
+ }
11560
+ interface CommonWatchOptions {
11561
+ intervalMs: number;
11562
+ onError?: (err: unknown) => void;
11563
+ signal?: AbortSignal;
11564
+ emitInitial?: boolean;
11565
+ }
11566
+ interface WatchReconciliationOptions extends CommonWatchOptions {
11567
+ reader: ReconciliationReader;
11568
+
11569
+ query?: ReconciliationQuery;
11570
+
11571
+ onChange: (diff: KeyedDiff<EmitterReconciliation>) => void | Promise<void>;
11572
+
11573
+ equals?: (a: EmitterReconciliation, b: EmitterReconciliation) => boolean;
11574
+ }
11575
+
11576
+ declare function watchReconciliation(opts: WatchReconciliationOptions): PollerHandle;
11577
+ interface WatchEmissionOptions extends CommonWatchOptions {
11578
+ reader: EmissionReader;
11579
+
11580
+ query?: EmissionAuditQuery;
11581
+
11582
+ onChange: (diff: KeyedDiff<SurfaceColumnEmission>) => void | Promise<void>;
11583
+
11584
+ equals?: (a: SurfaceColumnEmission, b: SurfaceColumnEmission) => boolean;
11585
+ }
11586
+
11587
+ declare function watchEmission(opts: WatchEmissionOptions): PollerHandle;
11588
+
11274
11589
  interface HolonographClientOptions {
11275
11590
 
11276
11591
  endpoint: string;
@@ -11315,5 +11630,5 @@ interface HolonographClient {
11315
11630
 
11316
11631
  declare const HolonographClient: new (options: HolonographClientOptions) => HolonographClient;
11317
11632
 
11318
- export { HolonographClient, HolonographGradeAfterReportError, HolonographHttpError, HolonographMarkerPairingWarningError, HolonographNoObserversError, HolonographObserverNotFoundError, HttpTransport };
11319
- export type { AvailabilityMarkOptions, CompletenessWindow, ContractRegisterResponse, ContractSurfaceSummary, EmitChannel, EmitChannelCompleteness, EmitMode, EmitOptions, ExtremeSustainedLoadEvent, HolonographCallHandle, HolonographClientOptions, HolonographMessageRequest as HolonographMessageRequest, HolonographMessageResponse as HolonographMessageResponse, HttpTransportOptions, MediatorCallRequest, OtlpEmitConfig, SurfaceOutcomeReport };
11633
+ export { HolonographClient, HolonographGradeAfterReportError, HolonographHttpError, HolonographMarkerPairingWarningError, HolonographNoObserversError, HolonographObserverNotFoundError, HttpTransport, createPoller, diffByKey, hasChanges, watchByKey, watchEmission, watchReconciliation };
11634
+ export type { AvailabilityMarkOptions, CompletenessWindow, ContractRegisterResponse, ContractSurfaceSummary, EmissionReader, EmitChannel, EmitChannelCompleteness, EmitMode, EmitOptions, ExtremeSustainedLoadEvent, HolonographCallHandle, HolonographClientOptions, HolonographMessageRequest as HolonographMessageRequest, HolonographMessageResponse as HolonographMessageResponse, HttpTransportOptions, KeyedDiff, MediatorCallRequest, OtlpEmitConfig, PollerHandle, PollerOptions, ReconciliationReader, SurfaceOutcomeReport, WatchByKeyOptions, WatchEmissionOptions, WatchReconciliationOptions };
package/dist/index.js CHANGED
@@ -4064,7 +4064,9 @@ var SYSTEM_ROLE_SURFACE_IDS = {
4064
4064
 
4065
4065
  conformanceClerk: "system:conformance-clerk",
4066
4066
 
4067
- blastRadiusJudge: "system:blast-radius-judging"
4067
+ blastRadiusJudge: "system:blast-radius-judging",
4068
+
4069
+ orthogonalityHypothesisDrafter: "system:orthogonality-hypothesis-drafting"
4068
4070
  };
4069
4071
  var PLATFORM_SYSTEM_ROLE_SURFACES = [
4070
4072
  {
@@ -4081,6 +4083,11 @@ var PLATFORM_SYSTEM_ROLE_SURFACES = [
4081
4083
  role: "judge",
4082
4084
  surfaceId: SYSTEM_ROLE_SURFACE_IDS.blastRadiusJudge,
4083
4085
  label: "blast-radius-judge"
4086
+ },
4087
+ {
4088
+ role: "clerk",
4089
+ surfaceId: SYSTEM_ROLE_SURFACE_IDS.orthogonalityHypothesisDrafter,
4090
+ label: "orthogonality-hypothesis-drafter"
4084
4091
  }
4085
4092
  ];
4086
4093
  new Set(
@@ -4771,7 +4778,9 @@ var EvaluationEventKindSchema = external_exports.enum([
4771
4778
 
4772
4779
  "analysis.emission-coverage",
4773
4780
 
4774
- "analysis.delivery-orphan"
4781
+ "analysis.delivery-orphan",
4782
+
4783
+ "analysis.orthogonality-hypothesis"
4775
4784
  ]);
4776
4785
  var AvailabilityTransitionDirectionSchema = external_exports.enum([
4777
4786
  "reachable->unreachable",
@@ -4947,6 +4956,29 @@ var ConformanceFixtureRecordSchema = external_exports.object({
4947
4956
 
4948
4957
  sourceSurfaceId: external_exports.string().min(1).optional()
4949
4958
  });
4959
+ var OrthogonalityHypothesisRecordSchema = external_exports.object({
4960
+
4961
+ draftId: external_exports.string().min(1),
4962
+
4963
+ targetSurfaceId: external_exports.string().min(1),
4964
+
4965
+ targetDimensionId: external_exports.string().min(1),
4966
+
4967
+ candidateColumnId: external_exports.string().min(1),
4968
+
4969
+ proposedHypothesis: external_exports.string().min(1),
4970
+
4971
+ evidence: external_exports.object({
4972
+ scoredEventCount: external_exports.number().int().nonnegative(),
4973
+ sigmaObservedSquared: external_exports.number().nonnegative(),
4974
+ sigmaAgentSquared: external_exports.number().nonnegative(),
4975
+ sigmaAgentCILower: external_exports.number().nonnegative()
4976
+ }),
4977
+
4978
+ approverId: external_exports.string().min(1),
4979
+
4980
+ occurredAt: external_exports.string().min(1)
4981
+ });
4950
4982
  var EmissionCoverageSchema = external_exports.object({
4951
4983
 
4952
4984
  streamId: external_exports.string().min(1),
@@ -5005,37 +5037,42 @@ var EvaluationEventSchema = external_exports.object({
5005
5037
 
5006
5038
  emissionCoverage: EmissionCoverageSchema.optional(),
5007
5039
 
5008
- deliveryOrphan: DeliveryOrphanSchema.optional()
5040
+ deliveryOrphan: DeliveryOrphanSchema.optional(),
5041
+
5042
+ orthogonalityHypothesis: OrthogonalityHypothesisRecordSchema.optional()
5009
5043
  }).refine(
5010
5044
  (e) => {
5011
5045
  if (e.kind === "evaluation") {
5012
- return e.light !== void 0 && e.substrate !== void 0 && e.surface !== void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5046
+ return e.light !== void 0 && e.substrate !== void 0 && e.surface !== void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5013
5047
  }
5014
5048
  if (e.kind === "availability.transition") {
5015
- return e.availability !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5049
+ return e.availability !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5016
5050
  }
5017
5051
  if (e.kind === "analysis.noise-floor-calibration") {
5018
- return e.noiseFloorCalibration !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5052
+ return e.noiseFloorCalibration !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5019
5053
  }
5020
5054
  if (e.kind === "analysis.variance-decomposition") {
5021
- return e.varianceDecomposition !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5055
+ return e.varianceDecomposition !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5022
5056
  }
5023
5057
  if (e.kind === "analysis.lifecycle-transition") {
5024
- return e.lifecycleTransition !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5058
+ return e.lifecycleTransition !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5025
5059
  }
5026
5060
  if (e.kind === "analysis.eval-recommendation") {
5027
- return e.evalRecommendation !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5061
+ return e.evalRecommendation !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.conformanceFixtureRecord === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5028
5062
  }
5029
5063
  if (e.kind === "analysis.conformance-fixture") {
5030
- return e.conformanceFixtureRecord !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0;
5064
+ return e.conformanceFixtureRecord !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.emissionCoverage === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5031
5065
  }
5032
5066
  if (e.kind === "analysis.emission-coverage") {
5033
- return e.emissionCoverage !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.deliveryOrphan === void 0;
5067
+ return e.emissionCoverage !== void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.deliveryOrphan === void 0 && e.orthogonalityHypothesis === void 0;
5068
+ }
5069
+ if (e.kind === "analysis.delivery-orphan") {
5070
+ return e.deliveryOrphan !== void 0 && e.emissionCoverage === void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0 && e.orthogonalityHypothesis === void 0;
5034
5071
  }
5035
- return e.deliveryOrphan !== void 0 && e.emissionCoverage === void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0;
5072
+ return e.orthogonalityHypothesis !== void 0 && e.deliveryOrphan === void 0 && e.emissionCoverage === void 0 && e.light === void 0 && e.substrate === void 0 && e.surface === void 0 && e.availability === void 0 && e.noiseFloorCalibration === void 0 && e.varianceDecomposition === void 0 && e.lifecycleTransition === void 0 && e.evalRecommendation === void 0 && e.conformanceFixtureRecord === void 0;
5036
5073
  },
5037
5074
  {
5038
- message: "EvaluationEvent shape invariant: each kind requires exactly its corresponding payload and forbids the others. kind='evaluation' \u2192 light+substrate+surface; kind='availability.transition' \u2192 availability; kind='analysis.noise-floor-calibration' \u2192 noiseFloorCalibration; kind='analysis.variance-decomposition' \u2192 varianceDecomposition; kind='analysis.lifecycle-transition' \u2192 lifecycleTransition; kind='analysis.eval-recommendation' \u2192 evalRecommendation; kind='analysis.conformance-fixture' \u2192 conformanceFixtureRecord; kind='analysis.emission-coverage' \u2192 emissionCoverage; kind='analysis.delivery-orphan' \u2192 deliveryOrphan."
5075
+ message: "EvaluationEvent shape invariant: each kind requires exactly its corresponding payload and forbids the others. kind='evaluation' \u2192 light+substrate+surface; kind='availability.transition' \u2192 availability; kind='analysis.noise-floor-calibration' \u2192 noiseFloorCalibration; kind='analysis.variance-decomposition' \u2192 varianceDecomposition; kind='analysis.lifecycle-transition' \u2192 lifecycleTransition; kind='analysis.eval-recommendation' \u2192 evalRecommendation; kind='analysis.conformance-fixture' \u2192 conformanceFixtureRecord; kind='analysis.emission-coverage' \u2192 emissionCoverage; kind='analysis.delivery-orphan' \u2192 deliveryOrphan; kind='analysis.orthogonality-hypothesis' \u2192 orthogonalityHypothesis."
5039
5076
  }
5040
5077
  );
5041
5078
  function newEventId(occurredAt = new Date()) {
@@ -5578,8 +5615,10 @@ var EvaluationEventEmitter = class {
5578
5615
  }, opts.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS);
5579
5616
  this.stopSentinelInterval = this.emitsSentinels ? schedule(() => {
5580
5617
  this.sentinelTick();
5581
- }, opts.sentinelIntervalMs ?? DEFAULT_SENTINEL_INTERVAL_MS) : () => {
5582
- };
5618
+ }, opts.sentinelIntervalMs ?? DEFAULT_SENTINEL_INTERVAL_MS) : (
5619
+
5620
+ () => void 0
5621
+ );
5583
5622
  }
5584
5623
 
5585
5624
  enqueue(event) {
@@ -6068,6 +6107,18 @@ var HttpTransport = class {
6068
6107
  async getContract() {
6069
6108
  return this.get("/holonograph/contract");
6070
6109
  }
6110
+ async getReconciliation(query = {}) {
6111
+ const { since, until, emissionStreamId } = query;
6112
+ return this.get(
6113
+ `/holonograph/reconciliation${toQueryString({ since, until, emissionStreamId })}`
6114
+ );
6115
+ }
6116
+ async getEmission(query = {}) {
6117
+ const { since, until, surfaceId } = query;
6118
+ return this.get(
6119
+ `/holonograph/emission${toQueryString({ since, until, surfaceId })}`
6120
+ );
6121
+ }
6071
6122
  async markAvailability(req) {
6072
6123
  return this.post("/lens/availability/mark", req);
6073
6124
  }
@@ -6175,6 +6226,14 @@ function lightSnapshotFromResult(result) {
6175
6226
  }
6176
6227
  return snapshot;
6177
6228
  }
6229
+ function toQueryString(query) {
6230
+ const params = new URLSearchParams();
6231
+ for (const [k, v] of Object.entries(query)) {
6232
+ if (v !== void 0) params.set(k, v);
6233
+ }
6234
+ const s = params.toString();
6235
+ return s.length > 0 ? `?${s}` : "";
6236
+ }
6178
6237
 
6179
6238
  function isHttpOptions(opts) {
6180
6239
  return "endpoint" in opts;
@@ -6524,6 +6583,128 @@ var HolonographClient = class {
6524
6583
  }
6525
6584
  };
6526
6585
 
6586
+ function hasChanges(diff) {
6587
+ return diff.added.length > 0 || diff.removed.length > 0 || diff.changed.length > 0;
6588
+ }
6589
+ function structuralEquals(a, b) {
6590
+ if (a === b) return true;
6591
+ try {
6592
+ return JSON.stringify(a) === JSON.stringify(b);
6593
+ } catch {
6594
+ return false;
6595
+ }
6596
+ }
6597
+ function diffByKey(prev, next, keyOf, opts = {}) {
6598
+ const equals = opts.equals ?? structuralEquals;
6599
+ const prevByKey = new Map();
6600
+ for (const item of prev) prevByKey.set(keyOf(item), item);
6601
+ const nextByKey = new Map();
6602
+ for (const item of next) nextByKey.set(keyOf(item), item);
6603
+ const diff = { added: [], removed: [], changed: [], unchanged: [] };
6604
+ for (const [key, nextItem] of nextByKey) {
6605
+ const prevItem = prevByKey.get(key);
6606
+ if (prevItem === void 0) {
6607
+ diff.added.push(nextItem);
6608
+ } else if (equals(prevItem, nextItem)) {
6609
+ diff.unchanged.push(nextItem);
6610
+ } else {
6611
+ diff.changed.push({ key, prev: prevItem, next: nextItem });
6612
+ }
6613
+ }
6614
+ for (const [key, prevItem] of prevByKey) {
6615
+ if (!nextByKey.has(key)) diff.removed.push(prevItem);
6616
+ }
6617
+ return diff;
6618
+ }
6619
+
6620
+ function createPoller(opts) {
6621
+ const { poll, intervalMs, onResult, onError, signal, immediate = true } = opts;
6622
+ let timer;
6623
+ const controller = new AbortController();
6624
+ const stopped = () => controller.signal.aborted;
6625
+ const stop = () => {
6626
+ if (stopped()) return;
6627
+ if (timer !== void 0) clearTimeout(timer);
6628
+ controller.abort();
6629
+ };
6630
+ if (signal !== void 0) {
6631
+ if (signal.aborted) {
6632
+ stop();
6633
+ return { stop };
6634
+ }
6635
+ signal.addEventListener("abort", stop, { once: true });
6636
+ }
6637
+ const scheduleNext = () => {
6638
+ if (stopped()) return;
6639
+ timer = setTimeout(() => void tick(), intervalMs);
6640
+ };
6641
+ const tick = async () => {
6642
+ if (stopped()) return;
6643
+ try {
6644
+ const result = await poll(controller.signal);
6645
+ if (stopped()) return;
6646
+ await onResult(result);
6647
+ } catch (err) {
6648
+ if (!stopped()) onError?.(err);
6649
+ }
6650
+ scheduleNext();
6651
+ };
6652
+ if (immediate) void tick();
6653
+ else scheduleNext();
6654
+ return { stop };
6655
+ }
6656
+ function watchByKey(opts) {
6657
+ const { poll, intervalMs, keyOf, onChange, equals, onError, signal, emitInitial = false } = opts;
6658
+ const diffOpts = equals !== void 0 ? { equals } : {};
6659
+ let baseline;
6660
+ return createPoller({
6661
+ poll,
6662
+ intervalMs,
6663
+ ...onError !== void 0 ? { onError } : {},
6664
+ ...signal !== void 0 ? { signal } : {},
6665
+ onResult: async (next) => {
6666
+ if (baseline === void 0) {
6667
+ baseline = next;
6668
+ if (emitInitial) {
6669
+ const diff2 = diffByKey([], next, keyOf, diffOpts);
6670
+ if (hasChanges(diff2)) await onChange(diff2);
6671
+ }
6672
+ return;
6673
+ }
6674
+ const diff = diffByKey(baseline, next, keyOf, diffOpts);
6675
+ baseline = next;
6676
+ if (hasChanges(diff)) await onChange(diff);
6677
+ }
6678
+ });
6679
+ }
6680
+
6681
+ function watchReconciliation(opts) {
6682
+ const { reader, query, intervalMs, onChange, equals, onError, signal, emitInitial } = opts;
6683
+ return watchByKey({
6684
+ intervalMs,
6685
+ onChange,
6686
+ keyOf: (e) => e.emissionStreamId,
6687
+ poll: async () => (await reader.getReconciliation(query)).emitters,
6688
+ ...equals !== void 0 ? { equals } : {},
6689
+ ...onError !== void 0 ? { onError } : {},
6690
+ ...signal !== void 0 ? { signal } : {},
6691
+ ...emitInitial !== void 0 ? { emitInitial } : {}
6692
+ });
6693
+ }
6694
+ function watchEmission(opts) {
6695
+ const { reader, query, intervalMs, onChange, equals, onError, signal, emitInitial } = opts;
6696
+ return watchByKey({
6697
+ intervalMs,
6698
+ onChange,
6699
+ keyOf: (s) => s.surfaceId,
6700
+ poll: async () => (await reader.getEmission(query)).surfaces,
6701
+ ...equals !== void 0 ? { equals } : {},
6702
+ ...onError !== void 0 ? { onError } : {},
6703
+ ...signal !== void 0 ? { signal } : {},
6704
+ ...emitInitial !== void 0 ? { emitInitial } : {}
6705
+ });
6706
+ }
6707
+
6527
6708
  var HolonographClient2 = HolonographClient;
6528
6709
 
6529
- export { HolonographClient2 as HolonographClient, HolonographGradeAfterReportError, HolonographHttpError, HolonographMarkerPairingWarningError, HolonographNoObserversError, HolonographObserverNotFoundError, HttpTransport };
6710
+ export { HolonographClient2 as HolonographClient, HolonographGradeAfterReportError, HolonographHttpError, HolonographMarkerPairingWarningError, HolonographNoObserversError, HolonographObserverNotFoundError, HttpTransport, createPoller, diffByKey, hasChanges, watchByKey, watchEmission, watchReconciliation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holonograph/client",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript HTTP client for a Holonograph lens. Send messages through the lens and report scored outcomes back to it.",
5
5
  "license": "MIT",
6
6
  "type": "module",