Skip to content

Honor the server's configured cache retention for backing blobs - #4339

Open
ss1909 wants to merge 4 commits into
mainfrom
a-1831-agent-honor-cache-retention
Open

Honor the server's configured cache retention for backing blobs#4339
ss1909 wants to merge 4 commits into
mainfrom
a-1831-agent-honor-cache-retention

Conversation

@ss1909

@ss1909 ss1909 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the agent honor the cache registry's configured retention when it stamps a backing blob's lifetime, instead of a hard-coded 72h.

Companion to the backend work in buildkite/buildkite#33814 (A-1831, cache retention configurable via a service quota). The backend now returns retention_seconds on the cache store (upload) and retrieve responses; this PR consumes it.

Why

NscStore set the Namespace artifact lifetime to nscDefaultExpiry = "72h" on both upload (--expires_in) and refresh (--ensure_minimum). If an org's registry TTL is raised above 72h, the registry metadata outlives its backing blob: a later exact hit returns from the registry, the blob download 404s, and it collapses to a (self-invalidating) miss. So raising the quota bought hosted customers nothing. This threads the real retention to the blob so the two clocks stay aligned.

Changes

  • api/cache.go: add RetentionSeconds to CacheEntryCreateResp and CacheEntryRetrieveResp.
  • store.Blob.Upload and store.RetentionRefresher.RefreshRetention take a retention time.Duration.
  • NscStore uses it for --expires_in (upload) and --ensure_minimum (refresh) via a new nscExpiry helper that rounds up to whole hours and falls back to 72h when the server sends nothing (older server) — backward compatible in both directions.
  • S3Blob / LocalFileBlob accept the duration but ignore it (S3 lifetime is governed by the bucket lifecycle policy; local has no TTL).
  • save.go passes the store response's retention on upload; restore.go passes the retrieve response's retention on the exact-hit refresh (fallback hits still skip the refresh).

Verification

  • go build ./..., go vet ./internal/cache/..., go test ./internal/cache/... all pass.
  • New TestNscExpiry (fallback, whole-hours, multi-day, round-up); nsc_test asserts the formatted --expires_in / --ensure_minimum; restore_test asserts the retention propagates through maybeRefreshRetention.

🤖 Generated with Claude Code

ss1909 and others added 2 commits September 7, 2026 14:19
The agent hard-coded the Namespace artifact lifetime to 72h on upload
(--expires_in) and on refresh (--ensure_minimum), so a cache registry
whose TTL is raised above 72h (via the new cache-retention service
quota) would keep live metadata past the point its backing blob had
already expired — turning later exact hits into hollow misses.

Thread the retention the server now returns (retention_seconds on the
cache store and retrieve responses) into the blob store: Upload and
RefreshRetention take a duration, and NscStore formats it for
--expires_in / --ensure_minimum via nscExpiry, falling back to 72h when
the server sends nothing (older server). S3 and local stores ignore it
(S3 lifetime is governed by the bucket lifecycle policy).

Stacks on the A-1775 confirm-restore work.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The constant holds a retention duration (a fallback used only when the
server omits one), and the helper formats a retention for the nsc CLI —
'expiry' misnamed both. Keep the nsc prefix: these are NSC-specific (the
72h default and hours formatting are nsc artifact conventions; S3/local
ignore retention).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Base automatically changed from a-1775-refresh-expiry-after-blob-verified to main September 7, 2026 07:02
@ss1909 ss1909 added the change Not a new feature, but a user observable non-breaking behavior change. label Sep 8, 2026
@ss1909
ss1909 marked this pull request as ready for review September 8, 2026 01:12
@ss1909
ss1909 requested review from a team as code owners September 8, 2026 01:12

@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.

No concrete issues found. This changes cache save/restore behavior and the backend-agent response contract, 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 26576, 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. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and 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 when repository policy or a verified grant allows it; otherwise comment-only.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human review always required.

@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.

No concrete issues found. This changes the cache save/restore path and the backend-agent response contract, 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 26600, then answer my questions about the findings.

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

Match the server switching retention_seconds -> retention_days: the
field is now RetentionDays and the store conversions use
time.Duration(days) * 24 * time.Hour.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ss1909
ss1909 force-pushed the a-1831-agent-honor-cache-retention branch from fb9534c to b43b2c7 Compare September 8, 2026 02:02

@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 days-based contract now matches the companion backend response, and I found no concrete issues. This still changes cache save/restore behavior and the backend-agent response contract, so it 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 26630, 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

change Not a new feature, but a user observable non-breaking behavior change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant