Skip to content

Prewarm Go dependencies for TW tasks#14

Merged
mohit-rag merged 4 commits into
scaleapi:mainfrom
mohit-raghavendra:prewarm-tw-go-dependencies
Jul 20, 2026
Merged

Prewarm Go dependencies for TW tasks#14
mohit-rag merged 4 commits into
scaleapi:mainfrom
mohit-raghavendra:prewarm-tw-go-dependencies

Conversation

@mohit-raghavendra

@mohit-raghavendra mohit-raghavendra commented Jul 17, 2026

Copy link
Copy Markdown

Summary

  • remove docker_image from all 38 TW Go task configs so Harbor builds each task Dockerfile
  • download each repository pinned Go module graph while the image build has network access
  • force agent and verifier runtime dependency resolution offline with GOPROXY=off and GOSUMDB=off
  • install the task Go 1.23.1 toolchain in the one Grafana image that does not consistently include Go

Validation

  • ran all 38 affected tasks in three batches (5 + 20 + 13): 38 completed, 0 errored, 0 retries
  • confirmed the result task set exactly matches the 38 task directories in this PR
  • validated 38 Dockerfile/task.toml pairs and confirmed each task.toml only removes docker_image
  • git diff --check

Greptile Summary

This PR pre-warms Go module dependencies into the Docker images for all 38 TW Go tasks, then enforces offline dependency resolution at agent/verifier runtime via GOPROXY=off and GOSUMDB=off. It also removes the pre-pulled docker_image field from every task.toml, letting Harbor build each task Dockerfile, and increases build timeouts from 600 s to 1800 s to accommodate the additional go mod download step.

  • Standard pattern (37 tasks): Sets WORKDIR /app, runs go mod download during the image build to populate the module cache, and bakes GOPROXY=off/GOSUMDB=off into ENV so agents cannot reach external Go module services at runtime.
  • Grafana task (27209): Adds a conditional Go 1.23.1 installation step before go mod download because the base image does not consistently ship a Go toolchain.
  • README update: Documents the new network-access restrictions for agents in TW tasks.

Confidence Score: 5/5

Safe to merge — the pattern is consistent across all 38 tasks and the author validated all tasks ran to completion with zero errors or retries.

The change applies a uniform, mechanically verified pattern across 37 tasks and a well-commented special case for Grafana. The author ran all 38 tasks end-to-end and confirmed 38 completions, 0 errors. The previous review thread surfaced the notable concerns specific to the Grafana tarball installation; no new defects were found in this pass.

data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile — the Grafana-specific Go installation block has outstanding feedback from a previous review thread worth resolving before the pattern is used in additional tasks.

Important Files Changed

Filename Overview
data/tw/task-6902ef3ab97fe23e2ad271f9/environment/Dockerfile Representative standard pattern: adds WORKDIR /app, go mod download, and GOPROXY=off/GOSUMDB=off ENV — consistent across 37 of 38 tasks
data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile Special Grafana task: conditionally installs Go 1.23.1 from go.dev before downloading modules; previous review thread already flagged checksum, version guard, and architecture concerns
data/tw/task-6902ef3ab97fe23e2ad271f9/task.toml Removes docker_image field and increases build_timeout_sec from 600 to 1800 — consistent and expected change across all 38 task configs
README.md Adds a note documenting the new restricted-internet-access policy for TW tasks

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[task.toml
- remove docker_image
- build_timeout 600→1800s] --> B[Harbor builds Dockerfile]
    B --> C{Is this the
Grafana task?}
    C -- No
37 tasks --> D[FROM swe_atlas base image
WORKDIR /app
RUN go mod download
ENV GOPROXY=off GOSUMDB=off]
    C -- Yes
1 task --> E[FROM grafana base image
WORKDIR /app
Conditionally install Go 1.23.1
RUN go mod download
ENV PATH + GOPROXY=off GOSUMDB=off]
    D --> F[Baked image:
module cache populated
proxy/sumdb disabled]
    E --> F
    F --> G[Agent runs inside container]
    G --> H{Agent tries
go build/test}
    H -- deps in cache --> I[Success
served from local cache]
    H -- new/missing dep --> J[Failure
GOPROXY=off blocks network]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[task.toml
- remove docker_image
- build_timeout 600→1800s] --> B[Harbor builds Dockerfile]
    B --> C{Is this the
Grafana task?}
    C -- No
37 tasks --> D[FROM swe_atlas base image
WORKDIR /app
RUN go mod download
ENV GOPROXY=off GOSUMDB=off]
    C -- Yes
1 task --> E[FROM grafana base image
WORKDIR /app
Conditionally install Go 1.23.1
RUN go mod download
ENV PATH + GOPROXY=off GOSUMDB=off]
    D --> F[Baked image:
module cache populated
proxy/sumdb disabled]
    E --> F
    F --> G[Agent runs inside container]
    G --> H{Agent tries
go build/test}
    H -- deps in cache --> I[Success
served from local cache]
    H -- new/missing dep --> J[Failure
GOPROXY=off blocks network]
Loading

Reviews (4): Last reviewed commit: "Note harness-level internet restrictions..." | Re-trigger Greptile

Comment on lines +11 to +13
&& wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
&& rm /tmp/go.tar.gz \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No checksum verification on Go tarball download

The tarball is fetched from go.dev/dl/ over HTTPS and extracted immediately without verifying a SHA-256 digest against a known-good value. A compromised CDN response or a partial download would be extracted silently; tar accepts partial archives as long as the stream doesn't terminate mid-block. The official Go download page publishes SHA-256 digests for every release — adding a sha256sum --check step before tar would close this gap and is a standard practice in secure Dockerfiles that fetch remote binaries.

Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 11-13

Comment:
**No checksum verification on Go tarball download**

The tarball is fetched from `go.dev/dl/` over HTTPS and extracted immediately without verifying a SHA-256 digest against a known-good value. A compromised CDN response or a partial download would be extracted silently; `tar` accepts partial archives as long as the stream doesn't terminate mid-block. The official Go download page publishes SHA-256 digests for every release — adding a `sha256sum --check` step before `tar` would close this gap and is a standard practice in secure Dockerfiles that fetch remote binaries.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Cursor Fix in Claude Code Fix in Codex

Comment on lines +8 to +16
RUN if ! command -v go >/dev/null 2>&1; then \
apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates wget \
&& wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
&& rm /tmp/go.tar.gz \
&& rm -rf /var/lib/apt/lists/*; \
fi \
&& PATH="/usr/local/go/bin:${PATH}" go mod download

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Conditional install may silently use wrong Go version

The guard if ! command -v go >/dev/null 2>&1 skips installation whenever any go binary is on the PATH — regardless of version. The comment states the intent is to install "the version used by the task's test runner" (1.23.1), but if the base image happens to ship Go at a different version the condition will pass, go mod download will run with that version, and the ENV PATH extension will simply prepend the non-existent /usr/local/go/bin without error. The baked module cache may then be incompatible with whatever go the agent or verifier actually resolves at runtime. Pinning the check to the exact version string (e.g. go version | grep -q go1.23.1) would make this intent explicit and enforceable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 8-16

Comment:
**Conditional install may silently use wrong Go version**

The guard `if ! command -v go >/dev/null 2>&1` skips installation whenever any `go` binary is on the PATH — regardless of version. The comment states the intent is to install "the version used by the task's test runner" (1.23.1), but if the base image happens to ship Go at a different version the condition will pass, `go mod download` will run with that version, and the `ENV PATH` extension will simply prepend the non-existent `/usr/local/go/bin` without error. The baked module cache may then be incompatible with whatever `go` the agent or verifier actually resolves at runtime. Pinning the check to the exact version string (e.g. `go version | grep -q go1.23.1`) would make this intent explicit and enforceable.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Cursor Fix in Claude Code Fix in Codex

RUN if ! command -v go >/dev/null 2>&1; then \
apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates wget \
&& wget -q https://go.dev/dl/go1.23.1.linux-amd64.tar.gz -O /tmp/go.tar.gz \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Architecture hard-coded to linux-amd64

The tarball name go1.23.1.linux-amd64.tar.gz will install the wrong binary — or fail at runtime under non-emulated execution — if the Docker build ever runs on an ARM64 host. The 37 other tasks rely on whatever Go the base image ships (which is presumably already arch-appropriate), but this task installs from a fixed URL. Consider using $(dpkg --print-architecture) or $(uname -m) to derive the correct suffix, or document the assumption that build infrastructure is always x86-64.

Prompt To Fix With AI
This is a comment left during a code review.
Path: data/tw/task-6902ef3ab97fe23e2ad27209/environment/Dockerfile
Line: 11

Comment:
**Architecture hard-coded to `linux-amd64`**

The tarball name `go1.23.1.linux-amd64.tar.gz` will install the wrong binary — or fail at runtime under non-emulated execution — if the Docker build ever runs on an ARM64 host. The 37 other tasks rely on whatever Go the base image ships (which is presumably already arch-appropriate), but this task installs from a fixed URL. Consider using `$(dpkg --print-architecture)` or `$(uname -m)` to derive the correct suffix, or document the assumption that build infrastructure is always x86-64.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Cursor Fix in Claude Code Fix in Codex

@mohit-rag
mohit-rag merged commit 6de82c3 into scaleapi:main Jul 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants