| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | import type { HostPowerSnapshot } from "@t3tools/contracts"; | 1 | import type { HostPowerSnapshot } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "@effect/vitest"; | 2 | import { describe, expect, it } from "@effect/vitest"; |
| 3 | import * as Cause from "effect/Cause"; | | |
| 4 | import * as DateTime from "effect/DateTime"; | 3 | import * as DateTime from "effect/DateTime"; |
| 5 | import * as Deferred from "effect/Deferred"; | 4 | import * as Deferred from "effect/Deferred"; |
| 6 | import * as Effect from "effect/Effect"; | 5 | import * as Effect from "effect/Effect"; |
| ... | @@ -9,12 +8,9 @@ import * as Ref from "effect/Ref"; | ... | @@ -9,12 +8,9 @@ import * as Ref from "effect/Ref"; |
| 9 | import * as Semaphore from "effect/Semaphore"; | 8 | import * as Semaphore from "effect/Semaphore"; |
| 10 | | 9 | |
| 11 | import { | 10 | import { |
| 12 | NativeTelemetryRequestTimedOut, | | |
| 13 | NativeTelemetryStreamClosed, | | |
| 14 | canCommandNativeTelemetrySidecar, | 11 | canCommandNativeTelemetrySidecar, |
| 15 | canRequestNativeTelemetryRetry, | 12 | canRequestNativeTelemetryRetry, |
| 16 | commitCollectionControlUpdate, | 13 | commitCollectionControlUpdate, |
| 17 | nativeTelemetrySupervisorFailureMessage, | | |
| 18 | retainRecentNativeTelemetryFailures, | 14 | retainRecentNativeTelemetryFailures, |
| 19 | resolveNativeSampleIntervalMs, | 15 | resolveNativeSampleIntervalMs, |
| 20 | synchronizeCollectionControlOnStart, | 16 | synchronizeCollectionControlOnStart, |
| ... | @@ -82,44 +78,6 @@ describe("canCommandNativeTelemetrySidecar", () => { | ... | @@ -82,44 +78,6 @@ describe("canCommandNativeTelemetrySidecar", () => { |
| 82 | }); | 78 | }); |
| 83 | }); | 79 | }); |
| 84 | | 80 | |
| 85 | describe("NativeTelemetryRequestTimedOut", () => { | | |
| 86 | it("models history and sample request deadlines without a fabricated cause", () => { | | |
| 87 | const historyTimeout = new NativeTelemetryRequestTimedOut({ | | |
| 88 | operation: "readHistory", | | |
| 89 | timeoutMs: 15_000, | | |
| 90 | }); | | |
| 91 | const sampleTimeout = new NativeTelemetryRequestTimedOut({ | | |
| 92 | operation: "sampleNow", | | |
| 93 | timeoutMs: 5_000, | | |
| 94 | }); | | |
| 95 | | | |
| 96 | expect(historyTimeout.message).toBe( | | |
| 97 | "Resource monitor 'readHistory' request timed out after 15000ms.", | | |
| 98 | ); | | |
| 99 | expect(sampleTimeout.message).toBe( | | |
| 100 | "Resource monitor 'sampleNow' request timed out after 5000ms.", | | |
| 101 | ); | | |
| 102 | expect("cause" in historyTimeout).toBe(false); | | |
| 103 | expect("cause" in sampleTimeout).toBe(false); | | |
| 104 | }); | | |
| 105 | }); | | |
| 106 | | | |
| 107 | describe("native telemetry supervisor failures", () => { | | |
| 108 | it("distinguishes a closed event stream from a process exit", () => { | | |
| 109 | expect(new NativeTelemetryStreamClosed().message).toBe( | | |
| 110 | "Resource monitor event stream closed unexpectedly.", | | |
| 111 | ); | | |
| 112 | }); | | |
| 113 | | | |
| 114 | it("keeps defect details out of the caller-visible health message", () => { | | |
| 115 | const secret = "credential=do-not-expose"; | | |
| 116 | const message = nativeTelemetrySupervisorFailureMessage(Cause.die(new Error(secret))); | | |
| 117 | | | |
| 118 | expect(message).toBe("Resource monitor supervisor stopped unexpectedly."); | | |
| 119 | expect(message).not.toContain(secret); | | |
| 120 | }); | | |
| 121 | }); | | |
| 122 | | | |
| 123 | describe("retainRecentNativeTelemetryFailures", () => { | 81 | describe("retainRecentNativeTelemetryFailures", () => { |
| 124 | it("expires old failures so an isolated crash restarts from the initial backoff", () => { | 82 | it("expires old failures so an isolated crash restarts from the initial backoff", () => { |
| 125 | expect(retainRecentNativeTelemetryFailures([0, 30_000], 90_001)).toEqual([]); | 83 | expect(retainRecentNativeTelemetryFailures([0, 30_000], 90_001)).toEqual([]); |