Skip to content

Add lazy Namespace storage client - #4257

Draft
buildkate wants to merge 15 commits into
mainfrom
A-1435-namespace-storage-api-phase-1
Draft

Add lazy Namespace storage client#4257
buildkate wants to merge 15 commits into
mainfrom
A-1435-namespace-storage-api-phase-1

Conversation

@buildkate

@buildkate buildkate commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Replace nsc artifact subprocesses with the Namespace Storage API, removing the runtime dependency on the NSC CLI while preserving cache expiry, misses, metrics, and integrity checks.

Context

A-1435
Plan

Changes

  • Use direct API uploads, streamed downloads with transient retries, and best-effort 24-hour expiry refreshes.
  • Share one lazy Namespace client per cache command and close it after workers finish.
  • Exclude Namespace's unlicensed generated modules from acknowledgements generation (they confirmed they use the same license as in their repo); but it is not publish with the modules.
buildkite-agent cache save/restore
                 │
                 ▼
       Load cache configuration
                 │
                 ▼
      Resolve requested cache names
                 │
                 ▼
       Start cache worker goroutines
          ┌──────┼──────┐
          ▼      ▼      ▼
       Cache A Cache B Cache C
          └──────┼──────┘
                 ▼
        Wait for every worker
                 │
                 ▼
             Command exits

Testing

  • Tests have run locally (with go test ./...).
  • Ran Namespace integration test locally which makes real calls to Namespace
  • Code is formatted (with go tool gofumpt -extra -w .).

Disclosures / Credits

Implemented with Amp.

@socket-security

socket-security Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​buf.build/​gen/​go/​namespace/​cloud/​protocolbuffers/​go@​v1.36.12-20260820164744-a1973bcf4d87.174100100100100
Addedgolang/​namespacelabs.dev/​integrations@​v0.0.11-0.20260508113815-6a8135624a3597100100100100

View full report

Version int `json:"version"` // Metadata schema version
}

func validateFilePath(filePath string) error {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was moved unchanged from nsc.go as it's not required by the API but still used by the local file store for validation.

"testing"
)

func TestValidateFilePath(t *testing.T) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

similarly to file.go, all these tests were just moved from nsc_test.go to here.

@buildkate
buildkate marked this pull request as ready for review August 24, 2026 23:52
@buildkate
buildkate requested review from a team as code owners August 24, 2026 23:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 948571aaff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cache/store/nsc.go 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 direct download path drops the CLI downloader's retry behavior, leaving transient stream failures to abort cache restores. 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 20459, 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 paths). Human review always required.

Comment thread internal/cache/store/nsc.go Outdated
@buildkate
buildkate force-pushed the A-1435-namespace-storage-api-phase-1 branch from 948571a to f836ac4 Compare August 24, 2026 23:58

@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 previous download-retry blocker is still open; the latest revision only renames the Namespace client types and fields.

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 20467, then answer my questions about the findings.

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

@buildkate buildkate added the internal Non-user facing, internal change. label Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

Copy link
Copy Markdown
Contributor Author

@codex review

Head: a9e8c09

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a9e8c096b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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 retry blocker remains open for one transient stream-failure class; details are in the existing thread. I found no other new concerns in 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 20481, then answer my questions about the findings.

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

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

buildkate commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Head: fd7dbb6

buildsworth-bk-app[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

1 similar comment

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

Copy link
Copy Markdown
Contributor Author

@codex review

Head: 8986893

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 8986893d24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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 HTTP/2 reset path is fixed, but one part of the existing download-retry blocker remains open; details are in its thread. I found no other new concerns in 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 20502, then answer my questions about the findings.

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

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

Copy link
Copy Markdown
Contributor Author

@codex review

Head: c2d4afc

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2d4afccac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cache/store/nsc.go Outdated
@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 25, 2026 00:49

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 previous download-retry concern is fixed. The signed-download HTTP 404 miss-mapping thread is blocking this revision.

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 20522, then answer my questions about the findings.

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

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

Copy link
Copy Markdown
Contributor Author

@codex review

Head: 72a965c

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 72a965c820

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 25, 2026 01:23

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 signed-download HTTP 404 mapping now addresses the previous blocker, and I found no new concerns. This cache transport and shared client-lifecycle change is above the L1 approval ceiling, so I’m leaving this as a comment.

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 20557, then answer my questions about the findings.

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

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

  • Have you tested back portability? I'm just curious if our existing pipelines (bk/bk) will continue to work, once we move to this. It should - but just curious if you tested.
  • Any reason you opted to go for a single stream download? This is going to be significantly slower that the exisiting nsc CLI. And it seems we lose all the chunk based retry, and the exponential backoff that nsc CLI gave us. Any reason for dropping this?

@buildkate

Copy link
Copy Markdown
Contributor Author
  • Have you tested back portability? I'm just curious if our existing pipelines (bk/bk) will continue to work, once we move to this. It should - but just curious if you tested.
  • Any reason you opted to go for a single stream download? This is going to be significantly slower that the exisiting nsc CLI. And it seems we lose all the chunk based retry, and the exponential backoff that nsc CLI gave us. Any reason for dropping this?

@jamiemonserrate

  • re testing: will do testing before merging
  • re single stream download vs CLI behavior: I switched to using the Namespace SDK which has no built in helper to do the chunking and retry that the CLI had. So admittedly the this differs to the CLI implementation.

These are the three options I see:

  1. Use ResolveArtifactStream
  • Lowest implementation effort.
  • Removes the CLI dependency.
  • Loses parallel throughput and chunk-level retries.
  • Whole-file retries can retransmit large amounts of data.
  1. Implement ranged downloads using ResolveArtifact
  • Removes the CLI dependency while preserving performance and resilience.
  • Require a lot of time implementation, testing, and validation + additional complexity
  • We own ongoing downloader maintenance
  1. Keep using the CLI
  • Preserves existing proven download behavior.
  • Lowest engineering effort.
  • Does not solve A-1435: containerized jobs without nsc continue to fail.
  • Retains subprocess and CLI-version dependencies.

Given that I'll be doing regression testing, if the results are tolerable with the current implementation (option 1), I will go with that.

Wdyt?

@jamiemonserrate

Copy link
Copy Markdown
Contributor
  • Have you tested back portability? I'm just curious if our existing pipelines (bk/bk) will continue to work, once we move to this. It should - but just curious if you tested.
  • Any reason you opted to go for a single stream download? This is going to be significantly slower that the exisiting nsc CLI. And it seems we lose all the chunk based retry, and the exponential backoff that nsc CLI gave us. Any reason for dropping this?

@jamiemonserrate

  • re testing: will do testing before merging
  • re single stream download vs CLI behavior: I switched to using the Namespace SDK which has no built in helper to do the chunking and retry that the CLI had. So admittedly the this differs to the CLI implementation.

These are the three options I see:

  1. Use ResolveArtifactStream
  • Lowest implementation effort.
  • Removes the CLI dependency.
  • Loses parallel throughput and chunk-level retries.
  • Whole-file retries can retransmit large amounts of data.
  1. Implement ranged downloads using ResolveArtifact
  • Removes the CLI dependency while preserving performance and resilience.
  • Require a lot of time implementation, testing, and validation + additional complexity
  • We own ongoing downloader maintenance
  1. Keep using the CLI
  • Preserves existing proven download behavior.
  • Lowest engineering effort.
  • Does not solve A-1435: containerized jobs without nsc continue to fail.
  • Retains subprocess and CLI-version dependencies.

Given that I'll be doing regression testing, if the results are tolerable with the current implementation (option 1), I will go with that.

Wdyt?

Yeah - my inclination is to continue using the nsc CLI, if the implementation & maintenance cost of the parallel downloading is too high. Since this is caching, we assume speed is of the essence, so I would rather err on the side of speed rather than usability (it means we have to document to inform users to do restore outside their containers).

But this is based on the assumption that there is a 75% drop in speed for large artifacts. Would love to see what you find.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 26, 2026 01:52

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 previous download handling concerns remain addressed, and I found no new code concerns in the retry-limit update. The direct cache transport and shared Namespace client lifecycle are above the L1 approval ceiling; the branch also currently conflicts with main in go.mod/go.sum, and build #14096 is failing.

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 21111, then answer my questions about the findings.

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

ampagent and others added 15 commits August 26, 2026 01:55
@buildkate
buildkate force-pushed the A-1435-namespace-storage-api-phase-1 branch from 9c7480c to 9488a06 Compare August 26, 2026 01:58
@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review August 26, 2026 02:03

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 rebase resolves the previous go.mod/go.sum conflict, and the download-handling concerns remain addressed; I found no new code concerns. The direct cache transport and shared Namespace client lifecycle remain above the L1 approval ceiling, and build #14097 is currently failing.

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 21125, then answer my questions about the findings.

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

@buildkate
buildkate marked this pull request as draft August 27, 2026 01:32
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.

3 participants