Skip to content

#498 refactor: resolve co-core from the co-pypi index, retire the wheelhouse - #559

Merged
gregoryfoster merged 5 commits into
mainfrom
498-co-pypi-index
Nov 27, 2026
Merged

gregoryfoster merged 5 commits into
mainfrom
498-co-pypi-index

Conversation

@gregoryfoster

Copy link
Copy Markdown
Member

Closes #498 (epic #503). Brief: #498 (comment). Corrections to the brief: #498 (comment)

What

co-core and co-core-aio now resolve from cannobserv's co-pypi Artifact Registry index, and the GCS wheelhouse is retired. The shape is broker#144's.

  • pyproject.toml: an explicit [[tool.uv.index]] co-pypi at the org registry's URL byte for byte, plus a [tool.uv.sources] entry for each package. The pin stays at >=0.38,<0.39. A new co-pypi dependency group (google-auth[requests]) holds the helper's own dependency, locked.
  • uv.lock: only the two co-core entries change, still at 0.38.0, from .wheelhouse filenames to index URLs with sha256s. Two other lines change: the group's metadata, and google-auth's requests extra. The package set and every version are identical (checked by diff).
  • scripts/co-pypi.sh + scripts/co_pypi_token.py (ported from broker#144): bash scripts/co-pypi.sh uv <cmd> mints a co-pypi-reader token and execs that one uv. UV_INDEX_CO_PYPI_USERNAME/_PASSWORD are set in the child's environment alone, starting from an allowlist. The token is never in argv, a file or output.
    • The one difference from broker: the outer uv run is --isolated. deploy.sh runs the release's wrapper (D10), and a plain uv run --project <release> would fill the release's .venv with packages hardlinked from the cache before the --link-mode copy sync, so chown -R could reach the uv cache.
  • scripts/deploy.sh:
    • The build runs bash scripts/co-pypi.sh uv sync --locked --no-dev … inside the release, with ARCHIVER_CO_PYPI_KEY taken from deploy.env's GOOGLE_APPLICATION_CREDENTIALS.
    • It refuses a commit that has no wrapper.
    • It now also unsets ARCHIVER_CO_PYPI_KEY and the UV_INDEX_CO_PYPI_* pair from its caller.
    • Every failure still says "nothing switched".
  • CI (lint, test, browser): the wheelhouse sync step is gone. The auth step gains id: auth and token_format: access_token, and the pair goes on the uv sync step alone. That step is now --locked: with a token present, an unlocked sync could re-lock against the index.
  • Removed: scripts/sync_wheelhouse.py, .wheelhouse/.gitkeep and tests/scripts/test_wheelhouse_gitkeep.py. One /.wheelhouse/ ignore line stays, so an existing checkout's files can't be committed by accident.
  • Docs: AGENTS.md (§ Environment & Tooling, Common Commands, Detail Docs), README, deploy/README.md, docs/DEPLOYMENT.md (new § The co-pypi index), ENVIRONMENT (ARCHIVER_CO_PYPI_KEY), ARCHITECTURE, CONVENTIONS and SKILLS, plus the dependabot.yml/audit.yml headers and audit_lock.sh's fix message. The .skills/ doc maps and context-seams allowlist were re-judged.

No CHANGELOG entry: no contract path is touched (alembic/versions/, src/api/routes/, src/api/schemas/, clients/python/).

Not changed:

Provenance: same bytes

The index's sha256 equals the bucket object's (gs://co-gcs-pypi/wheels/) and the main checkout's .wheelhouse copy, for all four 0.38.0 files. The table is in the corrections comment. The new lock carries exactly those hashes.

Tests

  • New:
    • tests/test_dependency_index.py: the index rules, a sha256 per file, wheels locked, no credential in a committed URL, the co-pypi group's closure (PyPI only, certifi included, never a default group), and the wheelhouse gone.
    • tests/scripts/test_co_pypi_token.py: the allowlist, the key, refusals, no token in output, and the shell wrapper's argv including --isolated.
    • tests/ci/test_ci_co_pypi.py: the token reaches the locked sync step alone, and client-drift/changelog get no OIDC.
  • Rewritten: TestWheels becomes TestIndex in tests/deploy/test_deploy.py, against a recording fake wrapper: the release's own wrapper runs with deploy.env's key; a shell key or pair never reaches it; a failed mint switches nothing; a commit without the wrapper switches nothing. The certifi floor's fetch check now covers any --no-project --with env, and checks that the mint runs from the floored lock.
  • Gate: bash scripts/pre-ship.sh passed, with 6161 passed, 8 skipped, and vitest 142 passed.

Rehearsal (before merge, as the brief asked)

git archive HEAD, empty UV_CACHE_DIR, no .wheelhouse:

  • Without a token: uv sync --locked --no-dev gets 401 Unauthorized on co_core-0.38.0-py3-none-any.whl.
  • Deploy-shaped (ARCHIVER_CO_PYPI_KEY from deploy.env, bash scripts/co-pypi.sh uv sync --locked --no-dev --compile-bytecode --link-mode copy --python /usr/bin/python3.12): rc 0 in 15.6 s.
    • The venv has co-core and co-core-aio 0.38.0, both import, and no dev packages.
    • 0 files are hardlinked, and home = /usr/bin.
    • No token appears in the output.

What works without a token, on a synced venv [measured]: uv run, uv sync --locked with nothing to fetch, uv lock --check and uv audit --frozen. So pre-ship.sh and dev_server.sh need no change.

Known limits

  • Pre-Resolve co-core from the co-pypi Artifact Registry index; retire the GCS wheelhouse (cannobserv#447, sibling of broker#144) #498 commits can't be rebuilt. This deploy.sh stops with "nothing switched" on a commit that has no scripts/co-pypi.sh, because its lock names .wheelhouse. A switch-back reuses the existing release, so it isn't affected.
  • Children of the wrapped uv inherit the pair: hatchling building the editable project, and git for the two git-sourced SDKs. That's accepted, as in broker#144. The bound is the reader role and the token's hour.
  • The co-pypi group is resolved from PyPI by hash at the first wrapper run on an empty cache: 11 packages, which Archiver already locks through google-cloud-storage.
  • Dependabot uv runs (Dependabot security updates for uv fail on every advisory (co-core 404) and mark main red #437) still need an org owner to admit this repo to the PYTHON_INDEX_OIDC_GCP registry. That's cannobserv docs/DEPENDABOT.md, step 3: repo id 1231433739, in both the provider condition and the registry list. My PAT can't read the registry (it needs admin:org), so whether that's already done is unmeasured.

Deploying

This deploys: pyproject.toml, uv.lock and scripts/deploy.sh change.

  • Not on Fri 2026-11-27 (broker#85's Valkey switch), and not in the Mon 2026-11-30 06:00–08:00Z patch window.
  • Merge on the deploy day, after broker#85's post-window notice.

🤖 Generated with Claude Code

…elhouse

co-core and co-core-aio 0.38.0 now lock from cannobserv's Artifact Registry
index (explicit [[tool.uv.index]] + a [tool.uv.sources] entry each), with a
sha256 per file; the index's four 0.38.0 files equal the bucket's byte for
byte. No other package moves in uv.lock.

scripts/co-pypi.sh + co_pypi_token.py (ported from broker#144) mint a
co-pypi-reader access token and exec one uv with the pair in its environment
alone, from an allowlist, out of the lock's co-pypi group, --isolated so a
release's .venv is built by its own sync only. deploy.sh runs the release's
wrapper (D10) with deploy.env's key; CI's lint/test/browser jobs take the token
from WIF on the uv sync --locked step alone. scripts/sync_wheelhouse.py,
.wheelhouse/.gitkeep and its test go; docs, allowlists and guards follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gregoryfoster and others added 4 commits November 27, 2026 00:23
…floored env, so it cannot pass vacuously

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sync under it stays quiet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… insecure-host and config variables before the build

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orrowed from google-auth

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregoryfoster

Copy link
Copy Markdown
Member Author

CR: findings addressed (head b08a0f91)

All five findings are resolved: four fixed and one stet, one commit per fix. The full gate passed after the last fix: 6167 passed, 8 skipped, vitest 142. CI is green on b08a0f91 across lint, test, browser, client-drift, changelog and audit.

Item Action Result
1 Fixed e433e846: the certifi sweep now runs through _unfloored(). A parametrized self-test proves the pattern catches an unfloored env, on one line and continued with \, and passes floored ones, so the sweep can't pass vacuously.
2 Fixed 72ffa0a0: the wrapper's outer uv run is --quiet. A cold-cache deploy-shaped sync now prints 0 bytes, and an unquiet wrapped command still prints its own output.
3 Stet The red tests and the implementation shipped in one commit. The red run was observed in-session (30 failed, 1 error).
4 Fixed 32aa2ee2: deploy.sh unsets the caller's UV_INDEX, UV_DEFAULT_INDEX, UV_INDEX_URL, UV_EXTRA_INDEX_URL, UV_FIND_LINKS, UV_INSECURE_HOST, UV_INDEX_STRATEGY, UV_KEYRING_PROVIDER and UV_CONFIG_FILE. The new test fails against the previous deploy.sh, and passes with the change. ENVIRONMENT.md notes it.
5 Fixed b08a0f91: cryptography>=50,<51 is in the dev group. I re-locked through bash scripts/co-pypi.sh uv lock. uv.lock gains only the two group-metadata lines, and the co-core entries are unchanged.

Still paused before the merge and the deploy. Merge on a deploy day, after broker#85's post-window notice: not Fri 11-27, and not in the Mon 11-30 06:00–08:00Z window. The host steps are in #498 (comment). The head to merge is now b08a0f91ec0aa0a4d3767fb5095e20ef6f08b510.

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.

Resolve co-core from the co-pypi Artifact Registry index; retire the GCS wheelhouse (cannobserv#447, sibling of broker#144)

1 participant