Skip to content

ci: authenticate released dependency readiness checks - #84

Merged
zoeyrose merged 3 commits into
mainfrom
ci/authenticate-readiness-metadata
Nov 23, 2026
Merged

zoeyrose merged 3 commits into
mainfrom
ci/authenticate-readiness-metadata

Conversation

@zoeyrose

@zoeyrose zoeyrose commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Client validation ran the released-dependency readiness check without a token. Since main moved to the modern atrinik-protocol 0.2.1 pin (#83), that check makes GitHub REST API reads on every run, against the runner's shared 60/hour unauthenticated budget. #81 failed both jobs with dependency readiness/update failed: HTTP Error 403: rate limit exceeded (run 43643580125). This PR authenticates those reads with the workflow's read-only token, gives the token to that step only, and stops the Linux job from repeating the API reads.

Implementation / behavior

  • Why it surfaced now. The historical 0.1.0 and 0.2.0 pins are verified against crates.io only. A modern pin goes through full upstream release discovery: repository identity, release pages, and one tag ref per release with a crate manifest. Today that is 17 API documents for each ready.
  • Before. The Linux job ran ready twice, once as its own step and once inside tools/validate.sh. That is 34 unauthenticated calls per run, plus 17 on Windows. Each new protocol release adds one call to each ready. At about 29 releases with manifests, the Linux job alone would exceed 60 every run.
  • ready --output PATH. It writes the sanitized documents it fetched in the existing metadata cache format. The writer is shared with metadata, so the schema, sanitization, size bound and create-only open are unchanged. If ready is already reading a cache, it refuses to write one, so a cache only ever holds documents fetched by that host process.
  • validate.yml.
    • Linux and Windows readiness steps get GITHUB_READ_TOKEN: ${{ github.token }} on that step only.
    • The Linux step writes the cache to RUNNER_TEMP. The tools/validate.sh step gets CRATE_RELEASE_METADATA_CACHE, so its second ready makes no GitHub API calls: a document cache miss fails closed. It still downloads release assets and checks crates.io, as before.
    • Both checkouts now set persist-credentials: false, so the token is not left in a Git credentials file for later steps. Nothing after checkout needs authenticated Git: the steps use only local history (rev-parse, check-attr, worktree add, archive, status, diff), and Cargo uses registry sources. The repository is public.
    • Workflow permissions stay contents: read.
  • Same pattern as the hourly updater. released-dependencies.yml already collects metadata on the host with the read-only token and runs the updater-policy tests and ready against that file.
  • Why not reuse metadata. It also requires the latest upstream crate to be on crates.io. Protocol's v2.25.0 GitHub release was published about 40 seconds before crates.io had 0.2.1. Reusing it would make every client PR fail during upstream release windows, or on a yanked newer version. ready verifies only the pinned version, as before.

Validation

  • python3 -m unittest discover -s tools -p 'test_released_dependencies.py': 83 tests passed. That is 82 existing plus a new fixture covering:

    • ready --output writes exactly the sanitized document;
    • a cached ready reuses it without any fetch;
    • output is refused while reading a cache.

    The new fixture fails against the previous tool.

  • Live, at main 3095a02 with an instrumented fetch:

    Call GitHub API calls Release and crates.io downloads
    ready --output 17 46
    ready with CRATE_RELEASE_METADATA_CACHE 0 46
    Old token-less second ready 17 46
  • Client validation passed on b2f1bdd (run 45123800538). The log shows the token only in the readiness step's environment (masked), and the cached ready inside tools/validate.sh passed.

  • git diff --check and py_compile passed, and the workflow YAML parses. actionlint was not available locally, so this PR's own Client validation run is the workflow proof.

Limitations / follow-up

🤖 Generated with Claude Code

Client validation ran the readiness check without a token. Since main
moved to the modern atrinik-protocol 0.2.1 pin, each check reads 17
public GitHub API documents, and the Linux job ran it twice: 34
unauthenticated calls per run against the runner's shared 60/hour
budget. PR #81 failed both jobs with HTTP 403 rate limit exceeded.

Pass the workflow's read-only token to the readiness step only. Let
`ready --output` seal the sanitized documents it fetched, as `metadata`
already does, and hand that file to tools/validate.sh so its second
check runs offline and its Cargo steps never receive the token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

zoeyrose and others added 2 commits November 23, 2026 00:35
Both validation checkouts kept the default persist-credentials, which
leaves the workflow token in a Git credentials file that later steps
can read. Nothing after checkout needs authenticated Git: the steps use
only local history, and Cargo uses registry sources. Turn persistence
off so the readiness step is the only one that gets the token.

Say that the cached readiness check makes no GitHub API calls rather
than that it runs offline, since it still downloads release assets and
checks crates.io. Describe the cache as a create-only write, not a seal.
Have the readiness fixture assert the exact cached document and the
printed result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Later validation steps still fetch the public advisory database over
anonymous network Git, so say they need no authenticated Git rather
than only local Git. Checkout itself also uses the workflow token, so
say the readiness step is the only step after checkout that gets it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zoeyrose

Copy link
Copy Markdown
Member Author

Self-review: #84 at 453c226

What was reviewed

  1. Full diff 3095a02..b2f1bdda. A fresh-context reviewer (a new agent with an intent brief, not a fork) read the whole diff and the code it touches:

    • tools/released_dependencies.py (fetch/document/load_metadata/write_metadata/main) and its tests;
    • tools/validate.sh and tools/validate-dependency-candidate.sh;
    • .github/workflows/validate.yml and released-dependencies.yml;
    • README.

    It found no P0–P2 issues and four P3 findings.

  2. Delta b2f1bdda..f2c148bf, the fix commit. A second fresh-context reviewer found no P0–P2 issues and two optional P3 wording nits.

  3. Delta f2c148bf..453c226a. It changes one workflow comment and one README sentence, using the second reviewer's suggested wording. I reviewed it myself, since it is trivial and contains no code.

Findings and outcomes

  • P3: commit-message brief claimed ci: avoids a release. Accepted as a reporting fix. scripts/release/release-policy.cjs maps every type to minor on main, and ci: report dependency advisories without blocking merges #70, ci: only fail pull requests on advisories they introduce #74 and ci: assign Dependabot pull requests to zoeyrose #79 shipped as v1.14.0, v1.16.0 and v1.21.0. The PR body's Limitations now states that merging cuts a minor client release. No code change.
  • P3: README and workflow comment overclaimed that Cargo never receives the token. Both checkouts kept persist-credentials: true. Fixed in f2c148b with persist-credentials: false on both checkouts, after checking that no later step needs authenticated Git:
    • the Git commands used are rev-parse, check-attr, worktree add from fetch-depth 0 history, archive, status and diff;
    • Cargo has registry sources only;
    • advisories.yml already runs the same advisory check with false.
  • P3: "runs offline" / "seals" wording was inaccurate. The cached ready still downloads release assets and checks crates.io. Fixed in f2c148b: the README, comments, docstring and PR body now say "makes no GitHub API calls" and "create-only write".
  • P3: test nits. Fixed in f2c148b:
    • the test captures and asserts stdout;
    • the assertion that could never fail is replaced by exact equality on the cached document, which also proves temp_clone_token is dropped.
  • P3 (delta): the comment said later steps use "only local Git". cargo-deny fetches the public advisory DB over anonymous network Git. Fixed in 453c226: "need no authenticated Git".
  • P3 (delta): README said the token went only to the readiness step. Checkout also uses it. Fixed in 453c226: the token goes to the readiness step "but to no later step".

Validation at the reviewed head

  • Client validation run 45125628593 on 453c226: Linux, Windows and the aggregate passed.
    • The token appears only in the readiness step's environment.
    • The checkout removed its credentials file before that step.
    • Inside tools/validate.sh, 83 tests passed, the cached ready passed, and advisories ok.
  • Locally:
    • 83 unit tests passed, and the new fixture fails against the base tool;
    • an instrumented live run made 17 API calls for ready --output and 0 for the cached ready;
    • git diff --check passed, and the YAML parses.
  • Not run: actionlint was not available locally.

@zoeyrose
zoeyrose marked this pull request as ready for review November 23, 2026 06:45
@zoeyrose zoeyrose self-assigned this Nov 23, 2026
@zoeyrose
zoeyrose requested a review from a team November 23, 2026 06:45
@zoeyrose
zoeyrose merged commit a9b27dd into main Nov 23, 2026
10 checks passed
@zoeyrose
zoeyrose deleted the ci/authenticate-readiness-metadata branch November 23, 2026 06:56
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