import { type RitualOptions, type RitualResult } from "./ritual.js"; import type { TrendVerdict } from "./trend.js"; /** * A server that leaks on purpose, written out at run time. * * Kept as a template rather than a file under `src/` because a file has to * survive tsup, the published tarball and the pack smoke test to be there when * a user runs the check; a string cannot be dropped by a build step. * * The retention pattern is the phase-0 one the whole tool was validated * against: `Buffer.alloc().toString()` materializes a real 8 KB string, where * `"z".repeat(8192)` would give V8 a ~400 byte cons rope and leak almost * nothing. */ export declare const SELF_CHECK_SERVER = "import http from \"node:http\";\n\nconst port = Number(process.env.PORT ?? 3000);\nconst hostname = process.env.HOSTNAME ?? \"127.0.0.1\";\n\nconst retained = [];\n\nhttp\n .createServer((req, res) => {\n retained.push(Buffer.alloc(8192, retained.length & 0xff).toString(\"latin1\"));\n res.setHeader(\"content-type\", \"application/json\");\n res.end(JSON.stringify({ retained: retained.length }));\n })\n .listen(port, hostname);\n"; /** Bytes the planted server retains per request. */ export declare const PLANTED_LEAK_BYTES_PER_REQUEST = 8192; export type SelfCheckResult = { /** True when the harness detected the leak it planted. */ passed: boolean; verdict: TrendVerdict; growthPer1000Requests: number; /** What the run should say about it, pass or fail. */ summary: string; }; export type SelfCheckOptions = { bootstrapPath: string; appPort: number; warmupRequests?: number; loadRequests?: number; connections?: number; cycles?: number; idleMs?: number; maxOldSpaceMb?: number; }; export type SelfCheckDeps = { ritual: (options: RitualOptions) => Promise; }; /** * Measures a leak of known size in the environment the user is measuring from. * * A `stable` verdict means one of two things — the app does not leak, or the * measurement does not work — and nothing in a run tells them apart. This * plants 8 KB per request and checks the ritual sees it, under the same Node * binary, heap cap, concurrency and container limits a real run would use. * * A failure here is not a warning about this route. It says every verdict from * this environment is worthless, which is worth knowing before acting on one. */ export declare function runSelfCheck(options: SelfCheckOptions, deps?: SelfCheckDeps): Promise;