build: name the source-archive ceilings in the context check (SUP2-1094)

Merged
JW
6d ago
+218-14

Fixes SUP2-1094. insta build --json said needs-attention with only a "large context" warning at 315.3 MB. The 256 MiB compressed upload cap first showed up at insta deploy, after packing (307.7 MiB > 256.0 MiB).

What changes

The context check in insta build now measures the context against the archive lane's limits (pack.ts ARCHIVE_LIMITS). Build stays offline, so these are labelled as defaults; the server's negotiated figures still win at deploy.

CaseMessage
over the extracted-size or entry limit,too large for insta deploy <dir>: …
already-compressed files (.gz/.xz/.zip/images/video…) alone, or payload plus tar headers/padding, over the upload limitships only if it compresses below the cap (extension-based estimate, never a certain verdict)
uncompressed size over the upload limitX MiB uncompressed (Y of it already compressed) — ships only if it compresses below the cap
under the capunchanged

Uncompressed bytes alone never make the call, because a large text tree can pack small. When a ceiling applies, the next action also covers intentional large assets: recompress with xz/zstd, or fetch the file at start-up. That's the reporter's case: a checkpoint they ship on purpose.

--json gains archiveLimits: {maxArchiveBytes, maxExtractedBytes, maxFiles, source: "default"}.

Verification

  • npm run typecheck passes. test/build.test.ts passes 41/41, including new cases: 315 MB reported case, compressible vs incompressible, extracted/entry limits, custom limits, compressed-file accounting.
  • Ran it on real directories (300 MiB):
    • random checkpoint.gz → too large for insta deploy <dir>: already-compressed files alone are 300.0 MiB, over the 256.0 MiB compressed upload limit
    • zero-filled data.bin → ships only if it compresses below that
  • npm test: test/setup-agent.test.ts fails 12 tests with ApiError: unauthorized. It fails the same way on unmodified main on my machine (local login state), so this PR doesn't cause it.

Docs: skills insta/cli-reference.md updated in a companion PR.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

The insta build context check now flags contexts that exceed the deploy archive ceilings at build time, instead of surfacing only at insta deploy after packing.

  • Ceilings are measured against what the packer would actually archive (root .dockerignore, else .gitignore fallback), not the docker context, and count tar headers and gzip framing along with the payload.
  • Over the extracted-size or entry limit → certain failure: too large for insta deploy <dir>. Uncompressed size alone never triggers a certain verdict, since compressible trees can pack well below the cap.
  • Already-compressed files (.gz, .xz, .zip, images, video, etc.) alone over the upload cap → warning that it ships only if it compresses below the cap (extension-based estimate; stored files can still shrink), with guidance to recompress intentional large assets with xz/zstd or fetch them at start-up.
  • Uncompressed size over the cap but compressible → similar warning, noting how much is already compressed and any payload that sits near the limit once tar headers count.
  • --json gains archiveLimits with the default ceilings, labelled as such since build runs offline and the server's negotiated figures still win at deploy.