You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ci: run the jobs that read provider keys in an environment (main) - #2020
Mirrors the main side of #2019 by hand, since the files have diverged and its diff does not apply here:
run_tests.yml: new environment input (default empty), used as environment: on the test job.
daily.yml and release.yml (integration job): pass environment: integration.
The nightly schedule and v* releases run from main, so they need the same change as accelerate.
It also ports to release.yml and its actions the hardening that accelerate has had since #1488:
id-token: write moves from the workflow to build-core, so the integration job, which holds every provider key, cannot mint a PyPI token.
build-core skips the uv cache, through a new enable-cache input on python-uv-setup (default "true", so other callers keep the cache). A cache saved by another run in main's scope cannot reach the job that publishes.
astral-sh/setup-uv and slackapi/slack-github-action are pinned by commit SHA, with the same pins as accelerate (v7.6.0, v2.1.1).
python-uv-setup installs uv 0.13.6, as accelerate does, instead of latest.
In build-core, hatch is pinned (hatch==1.18.2) and uv build --all reads .github/release-build-constraints.txt through UV_BUILD_CONSTRAINT (hatchling, hatch-vcs, setuptools-scm, at the versions uv.lock resolves), so the job that holds the PyPI token pins the build tools it downloads; their own dependencies are not pinned. uv build --all was run locally with that file: all 41 packages built (sdist and wheel).
actionlint on the workflows: clean, except one shellcheck warning (SC2046) in release-sdk-js.yml, which this PR does not touch.
Order
Pairs with #2019. This PR must merge before the admin moves the secrets into environments, or the nightly run and the release integration run lose their keys. With no environment configured yet, nothing changes. The first run after merge creates integration with no rules; the rules it needs (main, accelerate and tag v*, since a release runs on its tag) are step 7 of #2019.
The reusable test workflow accepts an optional environment input and assigns it to the test job. The daily and release workflows assign the integration environment to their jobs. The release workflow scopes OIDC permission to build-core, disables dependency caching, applies release build constraints, and pins the tool used for version extraction. The Slack and uv setup actions use pinned references. The uv setup action adds configurable caching.
Merge Risk: Moderate · up to de1af
The release workflow's version-extraction step still installs unpinned build backends in the job that holds the PyPI OIDC token, which weakens the supply-chain hardening this PR adds. Pin that environment or read the version from the built wheel before merging. The other changes look fine.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
VERDICT: GO (head ce34f02, merge base = current origin/main8e2d3a1)
Every secret read on a non-PR trigger is in a job with an environment.git grep 'secrets\.' on the head, excluding GITHUB_TOKEN: the only readers are run_tests.yml:74-98 (test job, environment at :72) and run_tests.yml:129 (SLACK_WEBHOOK_URL, same job). secrets: inherit appears only at daily.yml:21 and release.yml:20, and both pass environment: integration (daily.yml:20, release.yml:19). Nothing left out: release-sdk-js.yml:55,68 read GITHUB_TOKEN only; release-sdk-go.yml, sdk-go.yml, python-versions.yml, labeler.yml and the two composite actions read none (secrets: inherit is absent there). build-core uses OIDC and no secret. No vars.* reads.
No pull_request path enters integration.ci.yml:51-54 (push and pull_request) calls run_tests.yml with only marker, so inputs.environment is ''. It has no secrets: inherit. The only callers that name the environment are daily.yml (schedule, dispatch) and release.yml (release published, guarded by startsWith(tag_name,'v')). labeler.yml is the only pull_request_target workflow and reads no secret.
Matches #2019.run_tests.yml: the input block (name, description, required: false, default: "", type: string) and the test-job comment and line are identical to #2019's hunk. release.yml: identical hunk. daily.yml: same environment: integration line; the comment is reworded because main has no ref input (the #2019 wording about the ref line does not apply). Nothing else differs.
build-core unchanged.release.yml:26 still environment: pypi; the diff against base touches 3 files, +12 lines, no deletions.
CI green on the head: gh pr checks 2020 shows both unit / Lint and both unit / Test "not integration" pass, plus CodeQL (actions, go, python), labeler, GitGuardian. actionlint on the head's workflows reports only a shellcheck warning in release-sdk-js.yml:57, untouched by this PR.
Findings
[Nit] R1.1 PR body, "Order": it does not say that the integration environment does not exist yet on this repo (the environments list has only pypi and two others), so the first run after merge creates it with no rules. It also does not say that a release event runs on refs/tags/vX.Y.Z, so the environment needs a v* tag rule next to main/accelerate, or the release's integration job is refused. #2019 step 5 covers both; link that step from here so the admin does not miss it. Ticket, not fixed in this PR.
Mutations (YAML wiring, no unit test can fail on it): dropping environment: integration from daily.yml or release.yml would pass CI unchanged. #2019 already lists that gap as a follow-up; same here.
Unverified: the environment's rules (not yet created); that environment secrets reach a called workflow's job through secrets: inherit is per GitHub docs and #2019's probe, not re-run here.
The reason will be displayed to describe this comment to others. Learn more.
Security review of 96236d5, paired with #2019 (e54f585); full analysis on #2019. CI: 11 pass. actionlint: clean.
Nothing in this diff weakens the current state. inputs.environment is set only by daily.yml:20 and release.yml:19 in the same ref, so an attacker's branch cannot choose an environment that its own ref is not allowed into. The test job is the only reader of the integration keys, and the diff puts it in integration.
Findings on main that come before this PR (ticket, not this PR):
[Nit] T2release.yml:8 grants id-token: write to the whole workflow. That reaches the called run_tests.ymltest job, which holds every integration key. build-core (PyPI OIDC) restores the uv cache (python-uv-setup/action.yml:21-29, enable-cache: true). That cache may have been saved by the nightly in main's scope, and the nightly runs accelerate's code. Also, astral-sh/setup-uv@v7 and slackapi/slack-github-action@v2.1.1 are pinned by tag inside the job that holds the keys. accelerate already fixes all three (per-job id-token, enable-cache: "false" in build-core, SHA pins); port the same changes to main.
Verdict: this PR is ready as is. The pair is NO-GO until #2019's admin steps take R1.1-R1.4 from that review.
…Slack (S1.8)
Ports accelerate's #1488 hardening of these files to main: the PyPI OIDC token
is build-core's alone, build-core skips the uv cache through the new
enable-cache input, and both third-party actions are pinned by commit SHA.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
release.yml: id-token: write moves from the workflow to build-core only, so the integration job cannot mint a token.
build-core passes enable-cache: "false" to python-uv-setup. It is a new input, default "true", so other callers keep the cache.
astral-sh/setup-uv@37802adc… # v7.6.0 and slackapi/slack-github-action@91efab10… # v2.1.1. Both SHAs were checked against the upstream tags with git ls-remote.
actionlint: clean. The one SC2046 warning is in release-sdk-js.yml, which this PR does not touch. The body lists what the PR now covers.
The reason will be displayed to describe this comment to others. Learn more.
Delta security review of bc20447 (was 96236d5). Verdict: NO-GO until the one Should fix below is in. S1.8 itself is fixed.
S1.8: fixed
id-token: write moved from the workflow to build-core only; the integration job (all provider keys) inherits contents: read only. Mutation: reverting restores the workflow-level grant at release.yml:8.
build-core passes enable-cache: "false"; the new input defaults to "true", so run_tests.yml, python-versions.yml and test-core-index keep the cache. The quoted string parses as a boolean in setup-uv. No other job with an OIDC token uses the action.
Pins checked with git ls-remote: astral-sh/setup-uvv7.6.0 = 37802adc94f370d6bfd71619e3f0bf239e1f3b78, slackapi/slack-github-actionv2.1.1 = 91efab103c0de0a537f72a35f6b8cda0ee76bf0a. Same pins as accelerate.
CI: 11 pass, none failing.
New finding
N1, Should fix (python-uv-setup/action.yml:28).version: "latest" is kept while accelerate pins 0.13.6. In build-core (environment pypi, id-token: write) the uv binary then comes from the newest upstream release and is checked only against what that release publishes; with a fixed version, the pinned setup-uv commit carries the checksum (the 0.13.6 entry is in its known-checksums.ts). A bad uv release would run with the PyPI publish token in reach, and the SHA pin on setup-uv does not cover it. Fix: version: "0.13.6" and the step name "Install uv", as on accelerate. Checked: uvx --from uv==0.13.6 uv sync --frozen --all-extras --dev --dry-run on this head succeeds (lock revision 3, same as accelerate).
Nit (unchanged code, both branches): uvx -q hatch version and uv build --all fetch unpinned hatch and build backends from PyPI inside the same job. Pin hatch==<x> in that step if you want it closed here.
Attacker model: this PR adds no path. Nightly and release integration runs reach the keys only from main, accelerate or a v* tag (steps 5, 7 of #2019); the cache a main-scope nightly saves can no longer be restored by the publishing job.
The reason will be displayed to describe this comment to others. Learn more.
N1 (Should fix): pin version: "0.13.6" as accelerate does. In build-core this binary runs next to the PyPI publish token, and latest is not covered by the pinned setup-uv checksums.
Reviewing files that changed from the base of the PR and between bc20447 and de1afe6.
Files selected for processing: 3
.github/actions/python-uv-setup/action.yml
.github/release-build-constraints.txt
.github/workflows/release.yml
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Security & Privacy · Quick win
Pin the backends used for version extraction.
hatch version creates a separate build environment from agents-core’s unpinned build requirements. The constraints on the preceding step do not apply here. A new compromised backend release could therefore execute in the OIDC-enabled job. Read the version from the built distribution, or constrain this environment too. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
Delta security review of de1afe6 (was bc20447). Verdict: GO. One body-wording nit remains.
Prior findings
S2.2 fixed: python-uv-setup installs uv 0.13.6 (a published release), the same pin as accelerate.
S2.3 fixed: hatch==1.18.2 is pinned. .github/release-build-constraints.txt pins hatchling 1.30.1, hatch-vcs 0.5.0 and setuptools-scm 10.2.0; all three match uv.lock. UV_BUILD_CONSTRAINT is the env form of uv build --build-constraints (uv CLI reference, listed under uv build). I ran uv build -v on agents-core with the file: the resolver selected hatchling 1.30.1, hatch-vcs 0.5.0 and setuptools-scm 10.2.0 only. The path is absolute through github.workspace.
The constraints file cannot be changed by a pull request and read in the pypi job: pypi admits v* tags only (step 8 of #2019), and the tag ruleset (step 4) stops an attacker creating or moving a tag. The file is read from the tagged commit.
Heads checked unchanged; CI is green.
Nit
Body: "the job that holds the PyPI token downloads no unpinned build tool" overstates it. The pinned tools' own dependencies (for example packaging, pathspec, pluggy and the hatch dependency tree) are still resolved at their latest. Reword to "pins the build tools it downloads; their own dependencies are not pinned". Hash-pinning the whole set would close it, but that is more than this PR needs.
No remaining path for an org member with push access to read a secret or publish from this PR's files, given the admin steps of #2019.
## Why
Repo-level secrets are readable by any workflow pushed to any branch.
Environments with deployment-branch rules limit them to the branches
that need them. This PR makes every job that reads secrets name an
environment, so the secrets can move into environments in repo settings.
The move is an admin step after merge (below).
The PR alone changes nothing for a push: an environment that is not
configured yet has no rules and still sees the repo-level secrets. The
one change is on pull requests: `integration.yml` no longer gives
`MEM0_API_KEY` to a pull request's code, and the mem0 suites skip there,
as they already did for forks.
## How it works
```
job names environment E
├─ E is '' -> no environment, no deployment (probed, below)
├─ E not created yet -> created with no rules; repo secrets visible
└─ E has branch rules
├─ ref matches a rule -> job gets E's secrets
└─ ref does not match -> job is refused before it reaches a runner
push to any branch -> workflow without E -> no secrets
push to accelerate -> ci.yml -> run_tests.yml -> no environment, no secrets
push to accelerate -> integration.yml mem0 -> E = integration, MEM0_API_KEY
schedule / dispatch -> daily.yml -> run_tests -> E = integration, provider keys
pull_request -> integration.yml mem0 -> E = '', no MEM0_API_KEY
```
| Workflow / job | Environment | When |
| --- | --- | --- |
| `run_tests.yml` `test` | `inputs.environment` (new, default `''`) |
caller decides |
| `daily.yml` -> `run_tests.yml` | `integration` | schedule, dispatch |
| `release.yml` `integration` -> `run_tests.yml` | `integration` |
release `v*` |
| `ci.yml` `unit` -> `run_tests.yml` | none (unchanged) | push, PR |
| `integration.yml` `mem0` matrix entries | `integration` on push, `''`
on PR | push, PR |
| `publish-sdk-kotlin.yml` `publish`, `upload` | `release` | push only
(existing `if`) |
| `release-sdk-js.yml` `release` (npm, OIDC) | `registry-publish` (new)
| dispatch on `accelerate` (existing `if`) |
| `release-sdk-dotnet.yml` `release` (NuGet, OIDC) | `registry-publish`
(new) | dispatch on `accelerate` (existing `if`) |
| `release.yml` `build-core` | `pypi` (unchanged) | release `v*` |
The environment goes on the job inside the reusable workflow: the
caller's job cannot set one, and `secrets: inherit` still has to pass
the secret ([GitHub docs, reuse
workflows](https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows)).
## Validation
- **Empty environment name.** The docs allow an expression for
`environment` / `environment.name` with the `github`, `inputs`, `matrix`
(and other) contexts, and say nothing about an empty value ([workflow
syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idenvironment)).
A throwaway branch (deleted since) ran seven jobs: literal `environment:
''`, `environment: {name: ''}`, an expression that yields `''`, a matrix
expression that yields `''` for one entry, and a reusable workflow's
`environment: ${{ inputs.environment }}` with the default and with `''`.
All seven succeeded, the deployments API showed no deployment for that
commit, and no environment was created. A job in `pypi` does create one
(its last deployment has ref `v0.6.6`), so the check can tell.
actionlint refuses the literal `''` forms (`string should not be
empty`), so this PR uses only expressions.
- **This PR's CI** runs `run_tests.yml` from `ci.yml` with the empty
default, and `integration.yml` on `pull_request` with the expression
yielding `''`.
- actionlint on the seven changed files: clean, except one shellcheck
warning (SC2046) in `release-sdk-js.yml` that the base already has.
- No other workflow publishes. `client-sdks.yml` runs `flutter pub
publish --dry-run` only, with no `id-token` and no secret. `release.yml`
`build-core` (PyPI) is the only other job with `id-token: write`.
## After merge (repo admin)
Do the steps in order. Steps 1-10 come before any secret moves, and no
step widens access compared with today.
1. Merge the `main` PR, #2020, once its CI is green. The nightly
schedule and `v*` releases run from `main`: `daily.yml` resolves
`run_tests.yml` in `main`'s commit, and Python releases are tagged on
`main`. `main` has diverged for these files, so #2020 holds the same
three edits by hand: the `environment` input and `environment: ${{
inputs.environment }}` on the `test` job of `run_tests.yml`, and
`environment: integration` in `daily.yml` and in `release.yml`'s
`integration` job. Without it the nightly and the release integration
run lose their keys after step 11. `integration.yml` and
`publish-sdk-kotlin.yml` are not on `main`.
2. Workflow token settings. Under Settings -> Actions -> General ->
Workflow permissions, at repo level and at org level:
- turn off "Allow GitHub Actions to create and approve pull requests".
When it is on, a workflow pushed to any branch can ask for
`pull-requests: write` and approve a pull request as
`github-actions[bot]`, which meets the approval rule of step 3
([docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)).
- set the default workflow permissions to read. Every workflow here
already sets `permissions:` at the top or on every job, so none of them
changes.
3. Add a branch ruleset on `accelerate`, with the same options on
`main`'s ruleset. The deployment-branch rules below only hold as far as
the branches they name are protected, and the nightly runs
`accelerate`'s code in `integration`.
- restrict deletions; block force pushes;
- require a pull request before merging, with 1 approval;
- turn on "Dismiss stale pull request approvals when new commits are
pushed" and "Require approval of the most recent reviewable push", so a
commit pushed onto someone else's approved pull request needs a new
approval;
- bypass list: repository and organization admins only, on `main` too.
4. Add a tag ruleset on `v*`: limit who may create, update and delete
those tags. `release.yml` runs on a release whose `GITHUB_REF` is
`refs/tags/vX.Y.Z`, so `integration` and `pypi` accept `v*` tags (steps
7 and 8), and this ruleset is what keeps the path closed.
5. Create or configure environment `release`, for the Kotlin jobs only:
- deployment branches and tags: Branch `accelerate`, Branch
`release-kotlin-*-SNAPSHOT`;
- required reviewers: a team of at least two people, with "Prevent
self-review" on, so the person who started a run cannot approve it. With
one member the rule would block every run.
Anyone who can push could create `release-kotlin-x-SNAPSHOT` with an
edited `publish-sdk-kotlin.yml` (its `push` trigger includes that file)
and enter `release`. The required reviewers close that path with one
setting on the environment that guards the secrets, and hold every
Kotlin publish on a merge to `accelerate` until a reviewer approves the
run.
6. Create environment `registry-publish`, for the npm and NuGet jobs:
Branch `accelerate` only, the same required reviewers as `release` with
"Prevent self-review" on. A separate environment keeps these jobs out of
the `release-kotlin-*-SNAPSHOT` branches that `release` admits, because
neither registry checks the ref.
7. Create or configure environment `integration` (the first push of a
mem0 job after merge creates it with no rules): Branch `main`, Branch
`accelerate`, Tag `v*`. Enter `v*` as a Tag rule: as a Branch rule it
would admit any pushed branch named `v-x`.
8. Configure environment `pypi`: Tag `v*` only. Then check on PyPI that
the trusted publisher of each published package names environment
`pypi`. If it names none, a job in any `release.yml` on any branch can
publish.
9. Make the npm and NuGet trusted publishers require environment
`registry-publish`: on npm, the trusted publisher of
`@stream-io/stream-agents` for `release-sdk-js.yml`; on nuget.org, the
trusted publishing policy for `release-sdk-dotnet.yml`. Neither registry
checks the ref ([npm](https://docs.npmjs.com/trusted-publishers),
[NuGet](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing)),
so the environment is what keeps a job on another branch from
publishing. A dry run now also waits for a reviewer.
10. An org admin removes Vision-Agents from the access list of every
organization secret that no workflow here reads. Check with `gh api
repos/GetStream/Vision-Agents/actions/organization-secrets`. The two
`STREAM_REPO_*` secrets below are read; an environment does not limit an
organization secret, so keep them on the access list only until step 11
is done, then remove this repo from their lists too.
11. Move each secret from repo level into its environment, then delete
the repo copy:
- `integration`: `ANTHROPIC_API_KEY`, `ASSEMBLYAI_API_KEY`,
`AWS_ACCESS_KEY_ID`, `AWS_BEARER_TOKEN_BEDROCK`, `AWS_BEDROCK_API_KEY`,
`AWS_SECRET_ACCESS_KEY`, `CARTESIA_API_KEY`, `DEEPGRAM_API_KEY`,
`ELEVENLABS_API_KEY`, `FAL_KEY`, `FISH_API_KEY`, `GOOGLE_API_KEY`,
`HF_TOKEN`, `INWORLD_API_KEY`, `MISTRAL_API_KEY`, `NVIDIA_API_KEY`,
`OPENAI_API_KEY`, `OPENAI_MODEL`, `OPENROUTER_API_KEY`,
`SARVAM_API_KEY`, `STREAM_API_KEY`, `STREAM_API_SECRET`,
`TURBOPUFFER_API_KEY`, `TWELVELABS_API_KEY`, `XAI_API_KEY`,
`SLACK_WEBHOOK_URL`, `MEM0_API_KEY`. (`TELNYX_API_KEY` is read by
`run_tests.yml` but is not set at repo level.)
- `release`: `SIGNING_KEY`, `SIGNING_KEY_ID`, `SIGNING_PASSWORD`,
`STREAM_REPO_ENDPOINT`, `STREAM_REPO_BUCKET`.
- `STREAM_REPO_ACCESS_KEY_ID` and `STREAM_REPO_SECRET_ACCESS_KEY` are
organization secrets: put them in `release`, then remove this repo from
the organization secrets' access lists. Organization secrets cannot be
read back, so get the values from the owner of that credential, or
create a new key.
Once the `integration` rules exist, a pull-request job that names the
environment is refused (ref `refs/pull/N/merge`) and CI goes red, so a
dropped `github.event_name == 'push' &&` guard is caught.
After the move, Run workflow on `daily.yml` from a branch other than
`main` or `accelerate` is refused by the `integration` rules, instead of
testing that branch with the keys.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mirrors the
mainside of #2019 by hand, since the files have diverged and its diff does not apply here:run_tests.yml: newenvironmentinput (default empty), used asenvironment:on thetestjob.daily.ymlandrelease.yml(integrationjob): passenvironment: integration.The nightly schedule and
v*releases run frommain, so they need the same change asaccelerate.It also ports to
release.ymland its actions the hardening thatacceleratehas had since #1488:id-token: writemoves from the workflow tobuild-core, so theintegrationjob, which holds every provider key, cannot mint a PyPI token.build-coreskips the uv cache, through a newenable-cacheinput onpython-uv-setup(default"true", so other callers keep the cache). A cache saved by another run inmain's scope cannot reach the job that publishes.astral-sh/setup-uvandslackapi/slack-github-actionare pinned by commit SHA, with the same pins asaccelerate(v7.6.0,v2.1.1).python-uv-setupinstalls uv0.13.6, asacceleratedoes, instead oflatest.build-core,hatchis pinned (hatch==1.18.2) anduv build --allreads.github/release-build-constraints.txtthroughUV_BUILD_CONSTRAINT(hatchling, hatch-vcs, setuptools-scm, at the versionsuv.lockresolves), so the job that holds the PyPI token pins the build tools it downloads; their own dependencies are not pinned.uv build --allwas run locally with that file: all 41 packages built (sdist and wheel).actionlint on the workflows: clean, except one shellcheck warning (SC2046) in
release-sdk-js.yml, which this PR does not touch.Order
Pairs with #2019. This PR must merge before the admin moves the secrets into environments, or the nightly run and the release integration run lose their keys. With no environment configured yet, nothing changes. The first run after merge creates
integrationwith no rules; the rules it needs (main,accelerateand tagv*, since a release runs on its tag) are step 7 of #2019.🤖 Generated with Claude Code