oficina / equipo Public

runner: Task 16 review 2, the go command's zip size cap is too large

preflight maps x/mod/zip.CheckZip's SizeError to ErrTooLarge (so a zip
past the go command's own cap ends deps_too_large), other CheckZip
failures staying ErrUnsafePath. moduleDirs cites the ruling that its
testdata, dot and underscore exclusions match the go tool and personal
runners.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 050ae43e97368b880195312347a635b5763b8480 parent 46a07ee
4 files changed, +60 −2
  • docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md +12 −0
  • internal/runner/depsbundle/depsbundle_test.go +41 −0
  • internal/runner/depsbundle/gosum.go +1 −0
  • internal/runner/depsbundle/stage.go +6 −2

CI failed — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/hosted-runners-2: Type  Size Avail | ext4   96G   84G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   84G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.3s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 10.0s
ci-box: pi: installed and verified in 7.4s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.7s
ci-box: clone deepened in 4.7s
ci-box: file times set from content: 3877 files, 270 directories
ci-box: ready in 18.2s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
--- FAIL: TestReleaseCopyReviewed (0.09s)
    task_pages_test.go:236: COPY REVIEW REQUIRED: copy-status.py verify found copy pending review or stale bookkeeping
FAIL
rastrillo-budget/v1 ran 88ms
FAIL	amadan.net/oficina/equipo/internal/equipotest	0.234s
FAIL
make: *** [Makefile:273: copy-release-check] Error 1

amadan: step copy failed: exit status 2

amadan: job failed at step copy — its output is above, not at the tail of this log
diff --git a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
index c6c9e3fd..018763fb 100644
--- a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
@@ -1251,3 +1251,15 @@ Green: `go test ./internal/runner/depsbundle -count=3`: ok. `make budget build v
191. New pins limited to versions the base does not pin at all (`pins[l.m].Zip == ""` → `pins[l.m] == (Pin{})`). `-run TestCandidateTreeLineIsNewModule`: FAIL `depsbundle_test.go:798: NewModules = [example.com/added@v1.0.0], <nil>; want [example.com/added@v1.0.0 example.com/dep@v1.0.0]: the candidate adds their tree lines`. Restored.
192. A go.mod-only module reported missing again (`return pin.Zip == "", nil` → `return false, nil`). `-run TestGoModOnlyPinStaged`: FAIL both subtests, `depsbundle_test.go:748: missing [example.com/dep@v1.0.0], want none: a go.mod-only requirement is metadata`. Restored.
+
+### Task 16 review round 2 (t16-r2.md: 1, 2 and 4 addressed; 3 ruled; one Minor fixed)
+
+Finding 3 is ruled correct by the coordinator: module discovery skips testdata, dot and underscore directories, as the go tool and personal runners' `checks.GoModuleDirs` do. There is now a one-line comment in `moduleDirs` (gosum.go) citing the ruling.
+
+Minor: `preflight` mapped every `x/mod/zip.CheckZip` failure to `ErrUnsafePath`, so a zip past the go command's own cap (500 MiB declared, below Equipo's 2 GiB expanded limit) could not end `deps_too_large`. Now `CheckedFiles.SizeError` is `ErrTooLarge`, and other CheckZip failures stay `ErrUnsafePath`. New test `TestZipSizeCapIsTooLarge`: a small zip declaring `MaxZipFile+1` bytes for one entry, with a pin that does not match, so a hash first would answer otherwise.
+
+Red: `go test ./internal/runner/depsbundle -run TestZipSizeCapIsTooLarge -count=1` FAIL `depsbundle_test.go:842: Stage of a zip past the go command's size cap = {Dir: Missing:[]}, example.com/dep@v1.0.0: depsbundle: unsafe path in the dependencies: total uncompressed size of module contents too large (max size is 524288000 bytes); want ErrTooLarge before the hash`.
+
+Green: `go test ./internal/runner/depsbundle -count=3`: ok. `make budget build vet`: exit 0. staticcheck v0.7.0, gofmt and `git diff --check`: clean.
+
+193. SizeError not told apart (`if cf.SizeError != nil {` → `if cf.SizeError != nil && false {`). `-run TestZipSizeCapIsTooLarge`: FAIL `depsbundle_test.go:842: ... depsbundle: unsafe path in the dependencies: total uncompressed size of module contents too large (max size is 524288000 bytes); want ErrTooLarge before the hash`. Restored (checked with `cmp`).
diff --git a/internal/runner/depsbundle/depsbundle_test.go b/internal/runner/depsbundle/depsbundle_test.go
index a8c9fc75..efc62ded 100644
--- a/internal/runner/depsbundle/depsbundle_test.go
+++ b/internal/runner/depsbundle/depsbundle_test.go
@@ -804,3 +804,44 @@ func TestCandidateTreeLineIsNewModule(t *testing.T) {
t.Fatalf("Conflicts = %v, %v; want none: no base pin changed", got, err)
}
}
+
+// TestZipSizeCapIsTooLarge: a zip whose declared contents pass the go
+// command's own cap (x/mod/zip.MaxZipFile) is ErrTooLarge, from its
+// directory, before its bodies are hashed; within Equipo's own expanded
+// limit, only x/mod/zip's SizeError can say so.
+func TestZipSizeCapIsTooLarge(t *testing.T) {
+ cache := t.TempDir()
+ gomod := []byte("module example.com/dep\n")
+ var buf bytes.Buffer
+ w := zip.NewWriter(&buf)
+ f, err := w.Create("example.com/dep@v1.0.0/go.mod")
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Write(gomod)
+ body := []byte("package dep\n")
+ raw, err := w.CreateRaw(&zip.FileHeader{Name: "example.com/dep@v1.0.0/big.go", Method: zip.Store, CompressedSize64: uint64(len(body)), UncompressedSize64: modzip.MaxZipFile + 1, CRC32: crc(body)})
+ if err != nil {
+ t.Fatal(err)
+ }
+ raw.Write(body)
+ if err := w.Close(); err != nil {
+ t.Fatal(err)
+ }
+ at := cacheDir(t, cache, dep)
+ if err := os.WriteFile(filepath.Join(at, "v1.0.0.zip"), buf.Bytes(), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(at, "v1.0.0.mod"), gomod, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ pin := Pin{Mod: hashGoMod(t, gomod), Zip: "h1:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="}
+ base := fstest.MapFS{"go.mod": {Data: []byte(goModFor("example.com/app", dep))}, "go.sum": {Data: []byte(sumText(sumFor(dep, pin)))}}
+ dir := stageDir(t)
+ if s, err := stage(t, bundleFor(t, cache, base, base), base, dir, Limits{}); !errors.Is(err, ErrTooLarge) {
+ t.Errorf("Stage of a zip past the go command's size cap = %+v, %v; want ErrTooLarge before the hash", s, err)
+ }
+ if left := leftBehind(t, dir); len(left) != 0 {
+ t.Errorf("a refused Stage left %v", left)
+ }
+}
diff --git a/internal/runner/depsbundle/gosum.go b/internal/runner/depsbundle/gosum.go
index 566af643..45cf7ca3 100644
--- a/internal/runner/depsbundle/gosum.go
+++ b/internal/runner/depsbundle/gosum.go
@@ -113,6 +113,7 @@ func moduleDirs(tree fs.FS) ([]string, error) {
return err
}
if d.IsDir() {
+ // Ruled (t16-r2): the go tool ignores testdata, dot and underscore directories; personal runners' checks.GoModuleDirs does too.
if base := d.Name(); name != "." && (base == "vendor" || base == "testdata" || strings.HasPrefix(base, ".") || strings.HasPrefix(base, "_")) {
return fs.SkipDir
}
diff --git a/internal/runner/depsbundle/stage.go b/internal/runner/depsbundle/stage.go
index c2c3c01c..86274586 100644
--- a/internal/runner/depsbundle/stage.go
+++ b/internal/runner/depsbundle/stage.go
@@ -348,14 +348,18 @@ func (st *stager) stage(ctx context.Context, m Module, pins map[Module]Pin) (boo
// preflight reads only the zip's directory, before any body is read: its
// structure as x/mod/zip.CheckZip judges it (every entry a clean path
-// inside the module, no collisions, the go command's size caps), plain
+// inside the module, no collisions, the go command's size caps, whose
+// SizeError is ErrTooLarge), plain
// files only (CheckZip and Unzip ignore a symlink's mode), and its
// declared sizes and file count within what is left of the limits. The
// actual bytes are bounded by those declared sizes: archive/zip fails a
// body that outgrows its declared size (hashing), as Unzip does
// (extraction).
func (st *stager) preflight(m Module, zipPath string) error {
- if _, err := modzip.CheckZip(module.Version{Path: m.Path, Version: m.Version}, zipPath); err != nil {
+ if cf, err := modzip.CheckZip(module.Version{Path: m.Path, Version: m.Version}, zipPath); err != nil {
+ if cf.SizeError != nil {
+ return fmt.Errorf("%w: %v", ErrTooLarge, cf.SizeError)
+ }
return fmt.Errorf("%w: %v", ErrUnsafePath, err)
}
z, err := zip.OpenReader(zipPath)