cast/src
dan-claude-bot 7f0e886851 fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites
The suite allocated temp dirs at 68 sites across 21 files and removed none,
accumulating ~6700 directories and 189MB per machine-day, some holding age
keys. All 68 now go through a single `tmp()` helper allocating inside a
per-run root that vitest's globalSetup teardown removes wholesale, and a
class-guard test fails if `mkdtempSync` appears under test/ outside the
helpers.

The per-worker `process.once("exit")` reaper that suggests itself here does
not work under vitest and fails silently: the pool recycles workers by
killing them, so exit handlers registered in a test file never run. Measured
— a probe test writing from an exit hook produced no file, and a full run
with per-worker hooks still left 750 directories. globalSetup's teardown runs
in the main process, after every worker, and vitest awaits it.

Separately, and contrary to #117's framing that "cast itself does not leak":
resolveCheckout() mkdtemps an `infra-checkout-` dir, clones the infra repo
into it, and never removes it, so every `cast apply`/`diff`/`capture` without
--path leaked a full clone. The box that reported #117 was holding 602 such
directories, 73MB of real .git trees, from the same day. The leak fires on
the failure path too, since the dir is created before the clone runs.
Ephemeral checkouts are now reaped on process exit — the lifetime that fits,
since callers read the tree after resolveCheckout returns; a --path checkout
is the operator's own tree and is never registered.

Empirical: /tmp/cast-* + /tmp/infra-* count is 0 before and 0 after a full
`npm test`, against 750 with the exit-hook design. 626 tests green.

Refs #117
2026-07-21 12:58:14 +00:00
..
apply.ts fix(apply): refuse to write the generated-secret placeholder over a live value 2026-07-14 22:56:27 +00:00
bindings.ts feat(destroy): a scoped teardown verb, gated in state (#43) 2026-07-14 22:52:17 +00:00
capture.ts Merge pull request #56 from claude-hdb/fix/reserved-env-names 2026-07-14 23:54:15 +01:00
cli.ts fix: a manifest with no ${…} refs applies without a store (#104) 2026-07-19 13:06:34 +00:00
config.ts feat: select the Coolify instance by name instead of editing .coolify.env (#14) 2026-07-13 16:42:45 +00:00
coolify.ts fix(draft): read backup schedules and emit backup blocks (#75) 2026-07-16 18:25:34 +00:00
destroy.ts feat(destroy): a scoped teardown verb, gated in state (#43) 2026-07-14 22:52:17 +00:00
diff.ts fix(diff): Coolify's own generated vars are not orphans (#87) 2026-07-16 16:56:34 +00:00
draft.ts Merge pull request #95 from dan-claude-bot/feat/draft-service-domains 2026-07-18 21:25:37 +01:00
envtemplate.ts feat(resolve): derive base-URL env vars from manifest domains via ${domain:...} (#66) 2026-07-15 12:02:33 +00:00
fleet.ts feat: --all — every project in an environment, and a report that says so (#26) 2026-07-13 20:23:23 +00:00
inventory.ts fix(inventory): biome lint — a bare template literal and a string concat 2026-07-13 19:22:07 +00:00
manifest.ts feat(service): set and diff per-container service hostnames via urls (#72) 2026-07-16 15:14:29 +00:00
reserved.ts fix(diff): Coolify's own generated vars are not orphans (#87) 2026-07-16 16:56:34 +00:00
resolve.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
secrets.ts fix: CAST_AGE_KEY_FILE_<ENV> maps to a name a shell can set (#102) 2026-07-19 13:09:17 +00:00
server.ts feat: cast — the Coolify executor, extracted from the infra state repo 2026-07-11 12:25:44 +00:00
smoke.ts fix: never write an env var whose name Coolify injects itself (#50) 2026-07-14 22:29:23 +00:00
team.ts feat: assert the token's team before touching Coolify (fail-closed) 2026-07-12 20:55:04 +00:00