Skip to content

Add doctor check for sandbox Go cache size #293

Description

@yottadynamics

Problem or motivation

Sandboxed Go test runs use an isolated persistent cache under ~/.yottacode/sandbox-go-cache/ so containers can reuse GOCACHE and GOMODCACHE without bind-mounting the host's normal Go cache paths.

That isolation is the right default, but the cache is currently hidden and unbounded. On one local machine it reached:

du -csh ~/.yottacode/sandbox-go-cache/
2.2G    /home/ppetkov/.yottacode/sandbox-go-cache/
2.2G    total

A quick breakdown showed most of that was compiled build/test cache, not downloaded modules:

1.7G    ~/.yottacode/sandbox-go-cache/cache
479M    ~/.yottacode/sandbox-go-cache/modcache

Proposed solution

Add a yottacode doctor check that reports sandbox Go cache size when ~/.yottacode/sandbox-go-cache/ exists, with a warning when it exceeds a reasonable threshold.

The check should distinguish at least:

  • total sandbox Go cache size
  • build/test cache size: ~/.yottacode/sandbox-go-cache/cache
  • module cache size: ~/.yottacode/sandbox-go-cache/modcache

Suggested behavior:

  • no warning when the directory does not exist
  • informational output when it exists and is modest
  • warning when total size exceeds a threshold such as 1–2 GB
  • include cleanup guidance that preserves the distinction between build cache and module cache

Example guidance:

# Reclaim compiled build/test artifacts; modules remain cached.
GOCACHE="$HOME/.yottacode/sandbox-go-cache/cache" \
GOMODCACHE="$HOME/.yottacode/sandbox-go-cache/modcache" \
go clean -cache -testcache

# Stronger cleanup; next sandboxed Go run may redownload dependencies.
GOCACHE="$HOME/.yottacode/sandbox-go-cache/cache" \
GOMODCACHE="$HOME/.yottacode/sandbox-go-cache/modcache" \
go clean -cache -testcache -modcache

Alternatives considered

  • Reuse host Go cache paths directly (~/.cache/go-build, ~/go/pkg/mod, or custom host GOCACHE/GOMODCACHE). Rejected as the default because it widens the sandbox boundary, exposes/mutates broader developer state, and complicates Podman/SELinux/cache configuration.
  • Automatically clean on every sandboxed test run. Rejected because it defeats cache reuse and would make the first Go command in every sandbox session slow again.
  • Automatically clean modcache. Rejected as a default because it causes future dependency downloads.

Prior art

Go exposes explicit cleanup through go clean -cache, go clean -testcache, and go clean -modcache. yottacode should surface the same distinction for its own isolated sandbox cache.

Would you be willing to contribute this?

Yes, I'd like to open a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions