Skip to content

feat(cache): cache v2 in the agent - #4237

Open
ss1909 wants to merge 6 commits into
mainfrom
sneha/cache-v2-dogfood-a-1638
Open

feat(cache): cache v2 in the agent#4237
ss1909 wants to merge 6 commits into
mainfrom
sneha/cache-v2-dogfood-a-1638

Conversation

@ss1909

@ss1909 ss1909 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Integrates Cache™ v2 (Cache Registries) into this repo's real CI: Lint, Check protobuf generation, and every step in Tests and Coverage (Linux AMD64/ARM64, Windows, race) now restore the Go module cache (gomodcache) and build cache (gocache) via buildkite-agent cache restore/save, in place of the old host-mounted ~/gocache/~/gomodcache directories.

Context

Started as an isolated dogfood step to validate cache v2's wiring (auth, S3 storage, registry policy) against production without risking the real gating CI steps. That surfaced two confirmed bugs (below) and validated fallback matching and policy enforcement (scopes + CEL rules) end-to-end. With those understood, the standalone step was redundant — it duplicated a full go mod download/go build ./... purely to exercise cache v2, while Lint/Tests kept building from the host mount and got no benefit from it. This PR replaces that step with real integration instead.

Changes

  • docker-compose.yml: lint/agent services no longer bind-mount ~/gocache/~/gomodcache from the host. GOCACHE/GOMODCACHE now point at .gocache/.gomodcache inside /work (the checkout) — a plain subdirectory is never a mount point itself, which also sidesteps finding Unresolved TODO in /buildbox/script.go : 51 #2 below for these two paths.
  • cache.yml: target_paths updated to match (.gocache/.gomodcache, relative) — one definition works identically on Linux and Windows. gocache's cache_key no longer includes branch: Go's build cache is already content-addressed internally, so scoping it by branch only fragmented it across feature branches for no correctness benefit.
  • Real steps wired to cache v2 (shared aws-assume-role-with-web-identity OIDC role via a YAML anchor, no static credentials):
    • Lint (check-code-committed.sh): restores at the top, saves at the end — the sole writer.
    • Check protobuf generation: restores only.
    • Tests and Coverage (Linux AMD64/ARM64, Windows, race): restore only, added mount-buildkite-agent: true where missing so buildkite-agent is available in-container.
  • Removed the standalone cache-v2-dogfood step and script — superseded by the above.

Why only Lint saves — the parallel-race problem this avoids

Tests and Coverage runs up to ~9 concurrent job instances across its parallelism. If every shard also saved, they'd all resolve to the same cache_key (no per-shard distinction) and redundantly re-download/rebuild just to have something to save — up to 9x the work for nothing. Saves do race safely in that scenario (peek-then-create, last-committer-wins on a narrow TOCTOU window, never a torn or corrupt entry — Go's build cache is itself content-addressed so mixed content isn't wrong either), but it's still pure waste. Restoring is read-only and safely idempotent in every shard; only Lint (unparallelized, and already populating most of gocache as a side effect of go generate/gofumpt/golangci-lint) needs to write.

Known issues

  1. gocache save fails once the archive exceeds ~2GiB (server-side 500): CacheRegistry::Entry::Blob#file_size is a 4-byte :integer column with no limit: override in buildkite/buildkite. Root cause confirmed by reading the source; fix is a one-line limit: 8, not yet applied. Until it lands, Lint will fail red on its cache save — not soft_fail, so the gap stays visible rather than passing silently.
  2. Windows: no docker-compose there, so no mount-buildkite-agent equivalent is needed (the agent binary is already on the host), but the aws-assume-role-with-web-identity plugin's behavior on that queue specifically hasn't been verified end-to-end yet.

Testing

Not applicable in the usual sense — this PR only changes pipeline/cache/docker-compose config and shell scripts, no Go code. Verified instead by repeatedly triggering real builds against isolated test cache registries and confirming actual restore/save/policy behavior (cold miss → save → warm hit, scope isolation, CEL rule enforcement, default-deny) against production.

Disclosures / Credits

Claude Code was used throughout this work: designing the cache definitions and pipeline wiring, tracing the file_size overflow and mount-point cleanPath bugs to confirmed root causes across both repos, validating cache v2's policy behavior (scopes, CEL rules, fallback matching) against production, and designing/implementing this integration pass (in-checkout cache paths, single-writer save to avoid the parallel-shard race). I reviewed and directed all of it.

@ss1909 ss1909 added the internal Non-user facing, internal change. label Aug 12, 2026
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 2874146 to 1cb0be1 Compare August 12, 2026 00:42
@ss1909
ss1909 marked this pull request as ready for review August 12, 2026 00:42
@ss1909
ss1909 requested review from a team as code owners August 12, 2026 00:42

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The dogfood path cannot currently reach its first cache operation; I also found that the active smoke definition does not exercise fallback as described. Details are inline.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14333, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

About buildsworth

Model: gpt-5.6-sol with xhigh thinking.

How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.

Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. To let it approve, grant L2 approval by mentioning @buildsworth-bk (see L2 approval grant):

  • L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
  • L2 — Standard risk (new UI, additive API fields, refactors). Approved only with an L2 grant; otherwise comment-only.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical paths). Human review always required.

Comment thread .buildkite/pipeline.yml Outdated
Comment thread .buildkite/cache.yml
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch 2 times, most recently from 977c3e9 to 8acdb7d Compare August 12, 2026 00:57

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both prior concerns remain open on the current revision; I’ve kept the details in their existing threads.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14350, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch 2 times, most recently from bf83819 to 45276eb Compare August 12, 2026 01:06

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The binary-mount blocker is fixed. The fallback coverage concern remains, and I found two issues in the skipped Go-cache path; details are inline. This changes live CI/cache behavior, so I’m leaving a comment-only review.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14364, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread .buildkite/cache.yml Outdated
Comment thread .buildkite/pipeline.yml Outdated

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Activating the Go-cache step makes the bind-mounted restore path a blocker; the fallback and branch-key concerns also remain open in their existing threads.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14394, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 968138b to 5b4ca3e Compare August 12, 2026 01:45

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The branch-key concern is fixed. The bind-mounted restore blocker and fallback coverage concern remain open in their existing threads.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14402, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One prior concern is now addressed. The fallback/scenarios concern remains open in its existing thread because the new job cannot start.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14677, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 531130e to 54ff2d1 Compare August 12, 2026 06:34

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fallback/scenarios blocker remains open on the current revision; I’ve kept the detail in its existing thread. I found no new issues this pass.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14695, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 54ff2d1 to 3c8ce01 Compare August 12, 2026 06:42

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fallback/scenarios blocker remains open in its existing thread; I found no new issues this pass.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14702, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 12, 2026 06:48

Previous concerns have been addressed.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The scenarios step can now start, and I found no new issues in this revision. This changes live CI/cache behavior, so I’m leaving a comment-only review.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 14706, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from a9ed28b to 1c396ba Compare August 13, 2026 22:13
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 1c396ba to a50ff2c Compare August 13, 2026 22:15
@ss1909 ss1909 changed the title (WIP) testing cache v2 feat(cache): cache v2 in the agent Aug 13, 2026
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from b1a96f8 to fcf362f Compare August 13, 2026 22:59
@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 13, 2026 23:20

Previous concerns have been addressed.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The earlier dogfood concerns are resolved by the current integration rewrite. I found two blockers in the active cache path and two non-blocking cache coverage/effectiveness regressions; details are inline.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 15703, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread .buildkite/docker-compose.yml Outdated
Comment thread .buildkite/steps/check-code-committed.sh
Comment thread .buildkite/cache.yml
cache_key:
- v2
- { agent: os }
- { agent: arch }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking: This exact address never changes, and cache save explicitly skips an address that already exists. After the first successful Linux/AMD64 save, gocache is frozen at that snapshot: new dependency or toolchain outputs are rebuilt on every job but can never refresh the shared entry. A changing exact suffix after a fallback boundary would preserve cross-branch reuse while allowing refreshed entries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still open — gocache still has a fixed exact key, so an existing entry cannot be refreshed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still open — the gocache key is still fixed, so once the first entry exists, later runs cannot refresh it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still open — the new platform writers do not change the fixed key, so once each platform’s first entry exists, later runs still cannot refresh it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still open — both gocache and the new race cache have fixed exact addresses, so successful entries cannot be refreshed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still open — both build-cache definitions retain fixed exact addresses, so existing entries still cannot be refreshed.

Comment thread .buildkite/docker-compose.yml Outdated
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 0c08cc5 to 5265b8c Compare August 13, 2026 23:26

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving the caches out of the checkout fixes the gofumpt blocker. The per-platform writer, frozen gocache key, and Binary-build cache regression remain open in their existing threads, and the new parent-relative targets introduce another save blocker.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 15715, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread .buildkite/cache.yml Outdated

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The home-anchored targets address the latest save blocker. The per-platform writer remains blocking, and the cache-refresh and Binary-build regressions remain open in their existing threads; I found no new issues this pass.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16010, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 16, 2026 21:54

Previous blocking concerns have been addressed.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The platform writers and Binary-build restore address the prior blocker and regression. The fixed gocache key still cannot refresh, as noted in its existing thread. This also changes live CI cache and OIDC credential handling, so it still needs a human sanity-check.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16586, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 16, 2026 22:22

Previous concerns have been addressed.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Windows cache path now follows the native agent's USERPROFILE home, and I found no new code issue in this revision. The fixed gocache address remains open in its existing thread. Build #13997 is currently failing, but the available GitHub status does not expose which job failed; the live cache/OIDC path still needs human verification.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16597, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The prior cache-refresh concern remains open in its existing thread, and this revision adds a new blocker in the shared cache config; details are inline.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16737, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread .buildkite/cache.yml Outdated
@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from bbb46e8 to 67d4919 Compare August 17, 2026 02:21

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The race-cache blocker remains open in its existing thread, and the non-refreshing cache-key concern is unchanged. I found no new issues this pass.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16742, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@ss1909
ss1909 force-pushed the sneha/cache-v2-dogfood-a-1638 branch from 67d4919 to cbe3873 Compare August 17, 2026 02:24

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The race-cache naming blocker is fixed. The cache-refresh concern remains open in its existing thread; I found no new issues in this revision. Build #14000 is still pending, and the live cache/OIDC credential path needs human verification.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 16744, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

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

Labels

internal Non-user facing, internal change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant