#!/usr/bin/env node /** * Build memory harness — runs INSIDE a container (see scripts/build-mem.sh). * * Pipeline: * 1. clear — remove server/.next + server/tsconfig.tsbuildinfo (cold build) * 2. build — `npm run build` (or --build-cmd) from /work, captured + timed * 3. sample — every --interval-ms, walk the build's /proc descendant tree and * sum PSS (smaps_rollup); tag each sample with the current stage * (assemblyscript / build-deps / next-build) for attribution * 4. verify — exit 0 AND server/.next/BUILD_ID present (+ best-effort manifests) * * Headline metric is the container's whole-tree cgroup high-water mark, read from * /sys/fs/cgroup/memory.peak (cgroup v2). The PSS sampler is only for attribution * (which stage/process drives the peak). The container is fresh per run, so * memory.peak reflects only this build. * * Output: a human summary, one machine line `[BUILD-MEM RESULT] {json}`, plus * .build-mem/result-