Skip to content

feat: private cache buckets per trust level, repo-owned pass lists and post-checkout hook - #39

Merged
charlielye merged 3 commits into
mainfrom
cl/release-cache
Nov 27, 2026
Merged

charlielye merged 3 commits into
mainfrom
cl/release-cache

Conversation

@charlielye

@charlielye charlielye commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Every CI build instance writes the shared build cache (s3://aztec-ci-artifacts/build-cache), including pull request builds, which run code nobody has reviewed. It is also publicly readable. Releases read from it, so they publish whatever an earlier build uploaded under their content hashes. Builds of private code either skip the cache or would leak into it.

This PR gives each trust level its own cache and instances. It also moves repository-specific release logic out of ci3.

Three caches

Bucket Readable by Written by
aztec-ci-artifacts anyone: build-cache/ and protocol/ only. The rest, logs included, only through the dashboard and by administrators. public build instances (PRs, next, merge queues); every build's logs (logs/)
aztec-ci-private-cache private build roles, administrators private build instances
aztec-ci-release-cache release instances and publish jobs public release instances

The buckets and their IAM come from aztec-labs-eng/iac#87. Every build, private ones included, logs to aztec-ci-artifacts/logs. Logs are viewed only through the dashboard, behind its password, so there is one log location.

Changes

  • Configurable bucket: the cache scripts take their bucket from CI3_CACHE_BUCKET, defaulting to aztec-ci-artifacts. This covers cache_download, cache_upload, cache_exists, the _stream variants, cache_ls and cache_delete.
    • Any other bucket is private, so it is read only through authenticated S3, never the public HTTP endpoints.
    • CACHE_LOCAL_DIR keeps a private bucket's objects in their own subdirectory.
  • source_cache_bucket <bucket> (new, opt-in): the repository picks the bucket. On CI it fails at once if the bucket isn't accessible, rather than after a full build.
    • bootstrap_ec2 forwards CI3_CACHE_BUCKET and NO_CACHE_UPLOAD.
  • One Group tag per trust level: an instance's Group is its instance profile's name without ci3- and -profile (build-instance, release-build-instance, private-build-instance, private-release-build-instance).
    • The launching roles' EC2 and SSM permissions are scoped per group.
    • A public PR build can no longer reach release or private instances.
  • Repository-specific settings leave ci3:
    • bootstrap_ec2 forwards only ci3's own settings (plus the npm and docker credentials that source_npm_auth, deploy_npm and docker_login read).
    • A repository names the rest in CI3_PASS_ENV.
    • It names file-path variables in the new CI3_PASS_FILES. Their files are copied to /tmp/ci3-files on the instance, and the variable is passed pointing at the copy. This replaces the hard-coded GCP key, network env file and aztec-nr deploy key handling.
  • Post-checkout hook: an executable .github/ci3_post_checkout.sh runs after checkout and before ci3/source. Its stdout is replayed at the start of the run. source_release_target and internal/apply_private_release_patch move into aztec-node, the patch step becoming its hook.

Breaking for consumers (both are updated in their own PRs, pinned to this branch):

  • A private build must set CI3_INSTANCE_PROFILE_NAME to its private profile: its runner role can launch only its own group.
  • Removed: source_release_cache, source_release_target.
  • No longer forwarded by ci3: GCP_PROJECT_ID, RELEASE_TARGET, R2_*, CHONK_INPUTS_STATE_DIR, NETLIFY_*, AZTEC_NR_*, NAMESPACE, NETWORK, AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION, GOOGLE_APPLICATION_CREDENTIALS, NETWORK_ENV_FILE.

Testing

  • tests/cache_bucket_test runs against LocalStack, with a curl stub that records and fails every HTTP read. Under source_cache_bucket:
    • uploads land only in the chosen bucket;
    • downloads read it through S3, never over HTTP;
    • an object that only the shared cache has (or a local copy of it) is a miss;
    • a build without access fails fast.
  • tests/instance_group_test: the four profiles map to their groups.
  • The CI3_PASS_FILES round trip was checked by hand:
    • the runner's encoding, run through the host script, reproduces the file byte for byte, at mode 600;
    • empty and missing variables are skipped;
    • bad names are rejected.
  • redact_test, ssm_send_command_test and refname_test pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DSxF9AgGYcAcCTjXEeJT4L

… cache

Every CI build instance writes the shared build cache, including pull request builds, so a release
that read from it would publish whatever an earlier build had uploaded under its content hashes.

- The cache scripts take their bucket from CI3_CACHE_BUCKET (default aztec-ci-artifacts). Any other
  bucket is private, so it is read only through authenticated S3, never the public HTTP endpoints,
  and CACHE_LOCAL_DIR keeps its objects in their own directory.
- source_release_cache points a release at aztec-ci-release-cache, and on CI fails at once if the
  bucket is not accessible. source_release_target sources it for public releases; private releases
  keep using no cache at all.
- tests/release_cache_test checks, against LocalStack, that a release uploads to and downloads from
  the release bucket only, never over HTTP, ignores objects only the shared cache (or a local copy
  of it) has, and fails fast without access; and that nothing changes without it.

The bucket, and the IAM that keeps every other identity out of it, come with the matching
aztec-labs-eng/iac change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DSxF9AgGYcAcCTjXEeJT4L
…roup tag per trust level

- source_release_cache becomes source_cache_bucket <bucket>: the consuming repository picks which
  private bucket a build caches in (release cache, private cache); CI3_CACHE_BUCKET and
  NO_CACHE_UPLOAD are forwarded into the build container.
- An instance's Group tag is derived from its instance profile (instance_group), so the roles that
  launch and drive instances can be scoped to one trust level each.
- bootstrap_ec2 no longer forwards repository-specific variables. A repository names them in
  CI3_PASS_ENV, and names variables holding file paths in CI3_PASS_FILES, whose files are copied to
  /tmp/ci3-files on the instance.
- The private release patch and release target move to the repository that owns them: ci3 runs an
  optional executable .github/ci3_post_checkout.sh after checkout and before ci3/source.
- The dashboard reads a log missing from the public bucket from the private cache bucket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DSxF9AgGYcAcCTjXEeJT4L
@charlielye charlielye changed the title feat(cache): a public release reads and writes only a private release cache feat: private cache buckets per trust level, repo-owned pass lists and post-checkout hook Nov 26, 2026
Logs of private builds go to aztec-ci-artifacts/logs with every other log,
which only the dashboard and CI roles can read once the bucket's public
read is narrowed to the build cache, so the dashboard no longer looks in
a second, private bucket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DSxF9AgGYcAcCTjXEeJT4L
@charlielye
charlielye merged commit b43917c into main Nov 27, 2026
1 check passed
charlielye added a commit to AztecProtocol/aztec-packages that referenced this pull request Nov 27, 2026
…#25907)

Pins ci3 to aztec-labs-eng/ci3#40, on top of aztec-labs-eng/ci3#39.
Together they give each trust level its own build cache and instance
group. The shared cache, `aztec-ci-artifacts`, can be written by any CI
build, including pull requests that nobody has reviewed, and its build
cache is public. Until now, releases built from it, and the private
fork's CI wrote to it.

ci3 now picks the cache from the instance profile, so this repository
doesn't choose a bucket anywhere except the publish job:

| Build | Instance profile | Cache |
|---|---|---|
| PRs, `next`, merge queues | `ci3-build-instance-profile` |
`aztec-ci-artifacts` |
| Releases (tags, master environment) |
`ci3-release-build-instance-profile` | `aztec-ci-release-cache`, which
only release instances can write |
| AztecProtocol/aztec-packages-private, CI and releases |
`ci3-private-build-instance-profile` | `aztec-ci-private-cache`, which
nothing public can read or write |

**Changes**
- **Publish:** `bootstrap.sh publish` reads the release bundle from the
release cache. It runs on a GitHub runner, in ci3.yml's publish job with
the master environment's release role, so it names the bucket itself:
there's no instance profile to take it from.
- **Private fork:** it no longer uploads benches, which would need a
bench box its instances can't launch. Its logs go to
`aztec-ci-artifacts/logs` with every other log, which only the dashboard
serves.
- **What reaches the build container:** ci3 now forwards only its own
settings, so `ci.sh` lists the rest:
- `CI3_PASS_ENV`: `GCP_PROJECT_ID`, `NETLIFY_*`,
`AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION`, `CHONK_INPUTS_STATE_DIR`;
  - `CI3_PASS_FILES`: `GOOGLE_APPLICATION_CREDENTIALS`.
- **Chonk inputs:** `download_pinned_chonk_inputs` checks the tarball
against the pin, its sha256 prefix, before extracting it. `protocol/`
was writable by anyone until recently and is still writable by every PR
build.

**Testing**
- The chonk check was tested red/green by hand (a tampered tarball
served under the pinned name was extracted before the change and refused
after it), and the real pinned inputs still download.
- **Not run in PR CI:** the release and publish paths, which need the
release role and a tag. The next nightly exercises them.

**Needs setting in AztecProtocol/aztec-packages-private:** the secret
`CI3_INSTANCE_PROFILE_NAME=ci3-private-build-instance-profile`. Without
it, the fork's runner role can't launch instances at all.

A `v…-private…` tag in this repo, which builds the private fork's source
on a public release instance, still runs with `NO_CACHE_UPLOAD=1`, so
its bundle never reaches the publish job. That was already true before
this PR and isn't changed here.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DSxF9AgGYcAcCTjXEeJT4L

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant