@checkstack/healthcheck-common 0.11.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @checkstack/healthcheck-common
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 208ad71: Centralize realtime cache invalidation: signals now carry their owning `pluginId` end-to-end, and a single `SignalAutoInvalidator` mounted near the React Query client invalidates `[[pluginId]]` for every incoming signal automatically.
8
+
9
+ **Breaking change to `createSignal`** (`@checkstack/signal-common`): the factory now takes a single object argument with `pluginMetadata`, `event`, and `payloadSchema`. The signal id is constructed as `${pluginMetadata.pluginId}.${event}` and the resulting `Signal` carries a `pluginId` field. The `SignalMessage` wire envelope and `ServerToClientMessage` `signal` variant gained a `pluginId` field so the frontend can route invalidations without parsing the id.
10
+
11
+ ```ts
12
+ // Before
13
+ export const ANOMALY_STATE_CHANGED = createSignal(
14
+ "anomaly.state_changed",
15
+ z.object({ ... }),
16
+ );
17
+
18
+ // After
19
+ export const ANOMALY_STATE_CHANGED = createSignal({
20
+ pluginMetadata,
21
+ event: "state_changed",
22
+ payloadSchema: z.object({ ... }),
23
+ });
24
+ ```
25
+
26
+ **New plugin field**: `FrontendPlugin.foreignSignals?: Signal<unknown>[]` lets a plugin opt its `[[pluginId]]` cache into invalidation when another plugin's signal fires (e.g. `dependency-frontend` declares `[SYSTEM_STATUS_CHANGED]` because dependency payloads embed system status). Same-plugin signals must NOT be listed — they are always auto-invalidated.
27
+
28
+ **Removed boilerplate**: per-component `useSignal(X, () => refetch())` and `useSignal(X, () => queryClient.invalidateQueries(...))` calls have been removed across `incident-frontend`, `maintenance-frontend`, `healthcheck-frontend`, `slo-frontend`, `dependency-frontend`, `satellite-frontend`, `announcement-frontend`, `notification-frontend`, and `dashboard-frontend`. The `NotificationBell` unread count is now derived directly from the `getUnreadCount` query (auto-invalidated) instead of a local state mirror.
29
+
30
+ **User-visible bug fix**: the system detail page anomaly widget (`SystemAnomalyWidget`) now updates in real-time when anomalies change, with no per-widget signal subscription required. The dashboard status page also stays fresh on `ANOMALY_STATE_CHANGED`, `ANOMALY_BASELINE_UPDATED`, and `ANOMALY_TREND_DETECTED`.
31
+
32
+ UI-state consumers that legitimately need a `useSignal` (the dashboard activity terminal, the queue lag alert, and the rolling-preset date refresh in `useHealthCheckData`) keep their handlers; the auto-invalidator runs alongside them.
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [208ad71]
37
+ - @checkstack/signal-common@0.2.0
38
+
39
+ ## 0.12.0
40
+
41
+ ### Minor Changes
42
+
43
+ - 8d1ef12: ## Downstream consumer bumps for the anomaly detection + cache system rollout
44
+
45
+ Packages on this branch were updated as part of the anomaly detection feature (schema annotations on result fields, plugin metadata for the modular cache system) but were not listed in the upstream changesets.
46
+
47
+ - **`@checkstack/healthcheck-common`** (minor) — new RPC contract additions and schema changes supporting per-field anomaly metadata.
48
+ - **`@checkstack/cache-memory-common`** (minor) — new package providing access rules + plugin metadata for the in-memory cache backend.
49
+ - **healthcheck plugins** (patch) — adopt the new `x-anomaly-*` schema annotations on their result fields so anomaly detection works automatically against their checks. No public API changes.
50
+ - **integration / notification / auth / queue / collector plugins** (patch) — minor internal updates as consumers of upstream API changes (cache plugin registry, schema additions). No public API changes.
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [8d1ef12]
55
+ - @checkstack/common@0.7.0
56
+ - @checkstack/signal-common@0.1.10
57
+
3
58
  ## 0.11.0
4
59
 
5
60
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/healthcheck-common",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -8,8 +8,8 @@
8
8
  }
9
9
  },
10
10
  "dependencies": {
11
- "@checkstack/common": "0.6.5",
12
- "@checkstack/signal-common": "0.1.9",
11
+ "@checkstack/common": "0.7.0",
12
+ "@checkstack/signal-common": "0.1.10",
13
13
  "zod": "^4.2.1"
14
14
  },
15
15
  "devDependencies": {
package/src/index.ts CHANGED
@@ -49,14 +49,16 @@ export { healthcheckRoutes } from "./routes";
49
49
 
50
50
  import { createSignal } from "@checkstack/signal-common";
51
51
  import { z } from "zod";
52
+ import { pluginMetadata } from "./plugin-metadata";
52
53
 
53
54
  /**
54
55
  * Broadcast when a health check run completes.
55
56
  * Frontend components listening to this signal can update live activity feeds.
56
57
  */
57
- export const HEALTH_CHECK_RUN_COMPLETED = createSignal(
58
- "healthcheck.run.completed",
59
- z.object({
58
+ export const HEALTH_CHECK_RUN_COMPLETED = createSignal({
59
+ pluginMetadata,
60
+ event: "run.completed",
61
+ payloadSchema: z.object({
60
62
  systemId: z.string(),
61
63
  systemName: z.string(),
62
64
  configurationId: z.string(),
@@ -64,7 +66,7 @@ export const HEALTH_CHECK_RUN_COMPLETED = createSignal(
64
66
  status: z.enum(["healthy", "degraded", "unhealthy"]),
65
67
  latencyMs: z.number().optional(),
66
68
  }),
67
- );
69
+ });
68
70
 
69
71
  /**
70
72
  * Broadcast when a system's overall health status transitions.
@@ -72,11 +74,12 @@ export const HEALTH_CHECK_RUN_COMPLETED = createSignal(
72
74
  * NOT on every individual health check run. Use this for coarse-grained reactivity
73
75
  * like dashboard badges and dependency map node statuses.
74
76
  */
75
- export const SYSTEM_STATUS_CHANGED = createSignal(
76
- "healthcheck.system.status-changed",
77
- z.object({
77
+ export const SYSTEM_STATUS_CHANGED = createSignal({
78
+ pluginMetadata,
79
+ event: "system.status_changed",
80
+ payloadSchema: z.object({
78
81
  systemId: z.string(),
79
82
  previousStatus: z.enum(["healthy", "degraded", "unhealthy"]),
80
83
  newStatus: z.enum(["healthy", "degraded", "unhealthy"]),
81
84
  }),
82
- );
85
+ });
@@ -443,6 +443,31 @@ export const healthCheckContract = {
443
443
  }),
444
444
  )
445
445
  .output(z.void()),
446
+
447
+ getRunsForAnalysis: proc({
448
+ operationType: "query",
449
+ userType: "service",
450
+ access: [],
451
+ })
452
+ .input(
453
+ z.object({
454
+ startDate: z.date(),
455
+ limitPerAssignment: z.number().optional().default(200),
456
+ }),
457
+ )
458
+ .output(
459
+ z.array(
460
+ z.object({
461
+ systemId: z.string(),
462
+ configurationId: z.string(),
463
+ runs: z.array(
464
+ z.object({
465
+ result: z.record(z.string(), z.unknown()).nullable().optional(),
466
+ }),
467
+ ),
468
+ }),
469
+ ),
470
+ ),
446
471
  };
447
472
  // Export contract type
448
473
  export type HealthCheckContract = typeof healthCheckContract;
@@ -12,7 +12,7 @@ import {
12
12
  describe("stripEphemeralFields", () => {
13
13
  it("should strip fields marked with x-ephemeral", () => {
14
14
  const schema = healthResultSchema({
15
- statusCode: healthResultNumber({ "x-chart-type": "counter" }),
15
+ statusCode: healthResultNumber({ "x-chart-type": "counter", "x-anomaly-enabled": false }),
16
16
  body: healthResultJSONPath({ "x-ephemeral": true }), // Explicitly marked ephemeral
17
17
  });
18
18
 
@@ -29,8 +29,8 @@ describe("stripEphemeralFields", () => {
29
29
 
30
30
  it("should preserve non-ephemeral fields", () => {
31
31
  const schema = healthResultSchema({
32
- responseTimeMs: healthResultNumber({ "x-chart-type": "line" }),
33
- statusText: healthResultString({ "x-chart-type": "text" }),
32
+ responseTimeMs: healthResultNumber({ "x-chart-type": "line", "x-anomaly-enabled": false }),
33
+ statusText: healthResultString({ "x-chart-type": "text", "x-anomaly-enabled": false }),
34
34
  });
35
35
 
36
36
  const result = {
@@ -45,7 +45,7 @@ describe("stripEphemeralFields", () => {
45
45
 
46
46
  it("should preserve unknown fields like _collectorId", () => {
47
47
  const schema = healthResultSchema({
48
- value: healthResultNumber({ "x-chart-type": "counter" }),
48
+ value: healthResultNumber({ "x-chart-type": "counter", "x-anomaly-enabled": false }),
49
49
  body: healthResultJSONPath({ "x-ephemeral": true }),
50
50
  });
51
51
 
@@ -96,7 +96,8 @@ export function healthResultSchema<T extends HealthResultShape>(
96
96
  // ============================================================================
97
97
 
98
98
  /** Chart metadata (excludes x-jsonpath, use healthResultJSONPath for that) */
99
- type ChartMeta = Omit<HealthResultMeta, "x-jsonpath">;
99
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
100
+ type ChartMeta = DistributiveOmit<HealthResultMeta, "x-jsonpath">;
100
101
 
101
102
  /**
102
103
  * Create a health result string field with typed chart metadata.
@@ -114,7 +115,8 @@ export function healthResultString(
114
115
  meta: ChartMeta,
115
116
  ): HealthResultField<z.ZodString> {
116
117
  const schema = z.string();
117
- schema.register(healthResultRegistry, meta);
118
+ const finalMeta = (meta["x-ephemeral"] ? { ...meta, "x-anomaly-enabled": false as const } : meta) as HealthResultMeta;
119
+ schema.register(healthResultRegistry, finalMeta);
118
120
  return schema as HealthResultField<z.ZodString>;
119
121
  }
120
122
 
@@ -125,7 +127,8 @@ export function healthResultNumber(
125
127
  meta: ChartMeta,
126
128
  ): HealthResultField<z.ZodNumber> {
127
129
  const schema = z.number();
128
- schema.register(healthResultRegistry, meta);
130
+ const finalMeta = (meta["x-ephemeral"] ? { ...meta, "x-anomaly-enabled": false as const } : meta) as HealthResultMeta;
131
+ schema.register(healthResultRegistry, finalMeta);
129
132
  return schema as HealthResultField<z.ZodNumber>;
130
133
  }
131
134
 
@@ -136,7 +139,8 @@ export function healthResultBoolean(
136
139
  meta: ChartMeta,
137
140
  ): HealthResultField<z.ZodBoolean> {
138
141
  const schema = z.boolean();
139
- schema.register(healthResultRegistry, meta);
142
+ const finalMeta = (meta["x-ephemeral"] ? { ...meta, "x-anomaly-enabled": false as const } : meta) as HealthResultMeta;
143
+ schema.register(healthResultRegistry, finalMeta);
140
144
  return schema as HealthResultField<z.ZodBoolean>;
141
145
  }
142
146
 
@@ -155,7 +159,8 @@ export function healthResultArray(
155
159
  meta: ChartMeta,
156
160
  ): HealthResultField<z.ZodArray<z.ZodString>> {
157
161
  const schema = z.array(z.string());
158
- schema.register(healthResultRegistry, meta);
162
+ const finalMeta = (meta["x-ephemeral"] ? { ...meta, "x-anomaly-enabled": false as const } : meta) as HealthResultMeta;
163
+ schema.register(healthResultRegistry, finalMeta);
159
164
  return schema as HealthResultField<z.ZodArray<z.ZodString>>;
160
165
  }
161
166
 
@@ -176,7 +181,11 @@ export function healthResultJSONPath(
176
181
  meta: ChartMeta,
177
182
  ): HealthResultField<z.ZodString> {
178
183
  const schema = z.string();
179
- schema.register(healthResultRegistry, { ...meta, "x-jsonpath": true });
184
+ schema.register(healthResultRegistry, {
185
+ ...meta,
186
+ "x-jsonpath": true,
187
+ "x-anomaly-enabled": false as const // Always disable anomaly detection for raw body payloads
188
+ } as HealthResultMeta);
180
189
  return schema as HealthResultField<z.ZodString>;
181
190
  }
182
191