clai2: publish bleeding sdists to a `clai2-bleeding` release and install `/update` from it

Merged
MP
2mo ago
+265-101

/update on the bleeding channel asked api.github.com/repos/.../commits for the newest CLAI commit. That endpoint allows 60 unauthenticated requests per hour per IP, so from a shared office IP the status-row check and /update fail with 403 rate limit exceeded (reproduced locally while testing this PR). This is an experiment that moves bleeding to a GitHub release, which is a plain download and not an API call.

What changes

CI: .github/workflows/clai2-bleeding.yml (new). It runs on each push to main that touches src/pydantic_clai2, src/pydantic_ai_harness, pydantic_ai_slim, or pydantic_graph, and on workflow_dispatch. It:

  1. Checks out with full history, because the packages take their versions from tags.
  2. Runs src/pydantic_clai2/scripts/build_bleeding.sh dist/bleeding. This builds sdists of pydantic-clai2, pydantic-ai-harness, pydantic-ai-slim, and pydantic-graph (uv build --sdist --no-sources), names them <package>-<full sha>.tar.gz, and writes clai2-bleeding.json ({"commit": "<sha>"}).
  3. Smoke-tests that the sdists install outside the workspace and that clai2 --help runs.
  4. Moves the clai2-bleeding tag to the commit with GITHUB_TOKEN, so no workflow is triggered. It creates the clai2-bleeding release the first time, as a prerelease with --latest=false so it stays out of "Latest" and the API-compat baseline. It uploads the sdists first and the manifest last, then deletes the previous commit's sdists.

In pydantic/pydantic-ai only main publishes. A fork can publish from any branch through "Run workflow".

ci.yml: the tag trigger now excludes clai2-bleeding. A manual push of that tag can't start release-build or the PyPI publish.

/update (cli/self_update.py): in bleeding mode:

  • latest('bleeding') reads <release>/clai2-bleeding.json. It now makes no api.github.com call.
  • The overrides file points each package at <release>/<package>-<sha>.tar.gz. It still uses --overrides, so the harness/core extras are kept.
  • CLAI_BLEEDING_URL overrides the release folder. The default is https://github.com/pydantic/pydantic-ai/releases/download/clai2-bleeding. Set it to a fork's release or to a local folder served over HTTP.
  • installed() gets the commit from the end of the sdist file name. The same regex still matches old archive/<sha>.tar.gz installs, so current bleeding users are offered the move.
  • Removed UV_DYNAMIC_VERSIONING_BYPASS and the environment plumbing that carried it (powershell, after_exit_script, _run_uv). Each sdist's PKG-INFO already holds the real version and the exact pins between the packages, so bleeding builds now report 0.54.1.devN+g<sha> and not 0.0.0+<sha>.

Docs: README "Updating" covers the release, CLAI_BLEEDING_URL, and the local experiment. The AGENTS.md file map is updated.

How to point /update at the tag/sdist

# Default once the workflow has run on main: nothing to set.
/set updates.channel bleeding
/update

# A fork's release (run the "CLAI2 bleeding" workflow on the fork first):
CLAI_BLEEDING_URL=https://github.com/<you>/pydantic-ai/releases/download/clai2-bleeding clai2

# A local checkout:
src/pydantic_clai2/scripts/build_bleeding.sh /tmp/clai2-bleeding
python -m http.server --directory /tmp/clai2-bleeding 8000 &
CLAI_BLEEDING_URL=http://localhost:8000 clai2

Verified

  • tests/clai2/test_self_update.py: 35 passed, with 100% line and branch coverage of self_update.py. A new test checks that the build script's package list matches PACKAGES.
  • ruff format --check, ruff check, pyright (on the changed files), and zizmor on both workflows: clean. All pre-commit hooks pass.
  • Full tests/clai2: 3083 passed. Also fixes 5 test_run_model_layers.py failures already on main: #9859 added Anthropic caching TTLs to model_defaults while #9804's new test still expected no defaults for a Claude model. That test's clai2 cells were skipped on main. Only the three anthropic_cache* keys were added to the expectations; settings saved for another model still do not reach the Claude model.
  • End to end in tmux: I built sdists of this commit with the script and served them with http.server. From a source checkout with an isolated UV_TOOL_DIR and config, I ran /set updates.channel bleeding then /update. uv installed all four sdists from the server and CLAI restarted into the new build. A second /update there printed CLAI e75e5ce0c is the newest on the bleeding channel. I then changed the manifest to a fake newer commit and restarted: the status row showed update 111111111: /update.
  • Running the CI smoke step locally (uv pip install dist/bleeding/*.tar.gz and clai2 --help): passes.

Not verified / risks for the experiment

  • The workflow itself has not run. It only fires on main or by dispatch. The first run after merge creates the release and tag. Until that run finishes (a few minutes), bleeding /update gets a 404. Old clients still use the archive path, and they are what upgrade users onto this code.
  • Moving a tag with GITHUB_TOKEN needs contents: write, which the job requests. A tag ruleset on clai2-*, if one exists, would block it. No extra secret is needed.
  • Between deleting and re-uploading the manifest, --clobber leaves a gap of a few seconds where the manifest is missing. In that gap the status row stays quiet and /update reports the error. That is acceptable for an experiment.
  • Creating the prerelease the first time notifies release watchers once.