@checkstack/healthcheck-backend 1.4.0 → 1.6.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 +303 -0
- package/drizzle/0018_abnormal_preak.sql +10 -0
- package/drizzle/meta/0018_snapshot.json +600 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +26 -21
- package/src/ai/assertion-validation.test.ts +117 -0
- package/src/ai/assertion-validation.ts +147 -0
- package/src/ai/healthcheck-capabilities.test.ts +158 -0
- package/src/ai/healthcheck-capabilities.ts +217 -0
- package/src/ai/healthcheck-delete.test.ts +81 -0
- package/src/ai/healthcheck-delete.ts +81 -0
- package/src/ai/healthcheck-projection.test.ts +36 -0
- package/src/ai/healthcheck-propose.test.ts +268 -0
- package/src/ai/healthcheck-propose.ts +290 -0
- package/src/ai/healthcheck-script-tools.test.ts +93 -0
- package/src/ai/healthcheck-script-tools.ts +179 -0
- package/src/ai/healthcheck-update.test.ts +123 -0
- package/src/ai/healthcheck-update.ts +123 -0
- package/src/ai/notify-subscribers.test.ts +109 -0
- package/src/ai/notify-subscribers.ts +176 -0
- package/src/ai/register-ai-tools.test.ts +41 -0
- package/src/ai/register-ai-tools.ts +53 -0
- package/src/ai/shell-env-table.test.ts +47 -0
- package/src/automations.test.ts +2 -1
- package/src/automations.ts +9 -1
- package/src/collector-script-test.test.ts +53 -1
- package/src/collector-script-test.ts +59 -7
- package/src/effective-environments.test.ts +93 -0
- package/src/effective-environments.ts +64 -0
- package/src/health-entity-id.ts +57 -0
- package/src/health-entity.test.ts +405 -31
- package/src/health-entity.ts +99 -43
- package/src/health-state.ts +41 -4
- package/src/healthcheck-gitops-kinds.test.ts +95 -0
- package/src/healthcheck-gitops-kinds.ts +56 -13
- package/src/index.ts +33 -0
- package/src/migration-chain-contract.test.ts +57 -0
- package/src/queue-executor.test.ts +814 -0
- package/src/queue-executor.ts +342 -50
- package/src/realtime-aggregation.test.ts +30 -0
- package/src/realtime-aggregation.ts +16 -0
- package/src/retention-job.ts +167 -93
- package/src/retention-rollup.test.ts +118 -0
- package/src/router.test.ts +120 -1
- package/src/router.ts +20 -0
- package/src/schema.ts +44 -6
- package/src/service.ts +199 -43
- package/src/state-evaluator.test.ts +50 -5
- package/src/state-evaluator.ts +9 -2
- package/src/state-transitions.test.ts +104 -0
- package/src/state-transitions.ts +39 -1
- package/src/validate-configuration.test.ts +205 -0
- package/src/validate-configuration.ts +159 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract test: every healthcheck-backend-owned Versioned config that is
|
|
3
|
+
* stored and read back via the migration chain MUST have a COMPLETE,
|
|
4
|
+
* contiguous chain from version 1 to its current `version`. Pure STRUCTURAL
|
|
5
|
+
* check (`validateMigrationChainFromV1` — no `migrate()` is run), so it carries
|
|
6
|
+
* zero per-config upkeep: the day someone bumps a config's `version` without
|
|
7
|
+
* shipping a covering migration, the read path would silently fail at runtime
|
|
8
|
+
* on a genuinely-v1 stored blob — this test turns that into a CI failure
|
|
9
|
+
* instead. See the HTTP plugin's equivalent test for the full rationale.
|
|
10
|
+
*
|
|
11
|
+
* Covers the configs this CORE package owns: the per-assignment state
|
|
12
|
+
* thresholds wrapper and every built-in automation action config. The
|
|
13
|
+
* strategy / collector `config` / `result` / `aggregatedResult` Versioned
|
|
14
|
+
* schemas are registered by the healthcheck strategy plugins (e.g.
|
|
15
|
+
* healthcheck-http-backend) and are guarded by an equivalent contract test in
|
|
16
|
+
* each plugin package.
|
|
17
|
+
*/
|
|
18
|
+
import { describe, expect, it } from "bun:test";
|
|
19
|
+
import type { QueueManager } from "@checkstack/queue-api";
|
|
20
|
+
import type { Hook } from "@checkstack/backend-api";
|
|
21
|
+
import { stateThresholds } from "./state-thresholds-migrations";
|
|
22
|
+
import { createHealthCheckActions } from "./automations";
|
|
23
|
+
import type { HealthCheckService } from "./service";
|
|
24
|
+
|
|
25
|
+
// `createHealthCheckActions` only constructs the action definitions; the deps
|
|
26
|
+
// are touched lazily inside `execute()`, which the contract check never calls.
|
|
27
|
+
// Stubs are sufficient.
|
|
28
|
+
const stubService = {} as unknown as HealthCheckService;
|
|
29
|
+
const stubQueueManager = {} as unknown as QueueManager;
|
|
30
|
+
const stubEmitHook = async <T>(_hook: Hook<T>, _payload: T): Promise<void> => {};
|
|
31
|
+
|
|
32
|
+
describe("healthcheck config migration-chain contract", () => {
|
|
33
|
+
it("the state-thresholds config has a complete v1->version chain", () => {
|
|
34
|
+
const problem = stateThresholds.validateMigrationChainFromV1();
|
|
35
|
+
expect(
|
|
36
|
+
problem,
|
|
37
|
+
`state thresholds config (version ${stateThresholds.version}) has a broken migration chain: ${problem}`,
|
|
38
|
+
).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("every built-in action config has a complete v1->version chain", () => {
|
|
42
|
+
const actions = createHealthCheckActions({
|
|
43
|
+
service: stubService,
|
|
44
|
+
queueManager: stubQueueManager,
|
|
45
|
+
emitHook: stubEmitHook,
|
|
46
|
+
});
|
|
47
|
+
expect(actions.length).toBeGreaterThan(0);
|
|
48
|
+
|
|
49
|
+
for (const action of actions) {
|
|
50
|
+
const problem = action.config.validateMigrationChainFromV1();
|
|
51
|
+
expect(
|
|
52
|
+
problem,
|
|
53
|
+
`Action "${action.id}" config (version ${action.config.version}) has a broken migration chain: ${problem}`,
|
|
54
|
+
).toBeUndefined();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|