Repository navigation
perf(check-key-credit): read the credit stop from one artifact marker - #973
Conversation
No related issue: hub volume cut #2; the gate read run history on every run (2-4 calls, ~152/h on the review lanes) The gate listed the caller workflow's completed runs, then read up to three of their job lists to find a record step, so every run paid 2-4 calls and a run that carried no record (a no-op) could push the stop out of the scan. Now the key job uploads an artifact named for the caller workflow and key job (gate.cjs markerName) after the launcher's credit-stop, after a credential scan like every other upload, kept one day. The gate makes one call, the repository's artifacts of that exact name, and skips the key while the newest unexpired marker is inside the window, citing the run that uploaded it. The window counts from that upload, so a topped-up key is tried on the first run after it. Any failure runs the key, as before. - gate.cjs: one artifacts?name= read replaces the run and job scan; outputs the marker name. - pr-review-cli.yml: the gate job drops its carry step and hands the marker name on; the key job writes, scans and uploads the marker; the subscription and fallback jobs' record steps, which no gate read, go. The three legs' job limits rise by 2 minutes for the two added steps. - Tests: a marker in the window skips with one call and no run or job read; an older one runs the key (the topped-up case); no, expired, misnamed or malformed markers run the key; runs without a record cannot starve the decision; every read failure fails open; the key job alone uploads the marker, only after a credit stop, kept one day. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VcupojVgxFqBnrah9DwFLE
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-review reviewed Incremental review of 9d97661 (since a9c489c): no findings. The change makes
The PR names no closing issue; its body says "No related issue", so there are no acceptance criteria to check. The README's entry on the marker (around line 782) is outside this increment. |
|
claude-security-review reviewed Incremental security review of 9d97661 against a9c489c ( What changed: Trust-control check: This narrows the gate, so it widens nothing. Before this change, a fork's Other files: The test changes only exercise the new check. The manifest fields: not touched. |
A fork's pull_request run holds no secret, but it can upload an artifact of any name from a modified caller workflow; the head-repository guard covers only the reusable workflow's own jobs. A marker named key-credit-stop-<caller>-<key-job> from such a run made every later run skip the key leg for the window and spend subscription quota. The run-history read excluded pull request runs; the marker read now does the same by origin. judgeMarkers counts a marker only when its workflow_run carries integer repository_id and head_repository_id and they are equal, so only a run whose head is this repository can start the window. The gate's and the workflow's security comments now say so; the old comment claimed every forger already held the secrets, which is false for a fork. Tests: a fork marker inside the window is ignored and the key runs (in judgeMarkers and in main); a same-repository marker still skips; a marker missing either id, or with null or string ids, is ignored; a newer fork marker does not hide an older same-repository one. Against the previous gate.cjs the two new assertions fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No related issue: hub volume cut #2. The key-credit gate read run history on every run: 2-4 GITHUB_TOKEN calls (1 runs list + up to 3 job lists), ~152 calls/h across the claude-code-plugins review lanes. The API-key leg actually ran on only a few of those runs.
Summary
The gate now reads the credit stop from one exact-name artifact marker:
GET /repos/{repo}/actions/artifacts?name=<marker>&per_page=100. That is 1 call on every path. A credit-stopped key leg uploads the marker; the gate skips the key while the newest unexpired marker is inside the window.Fix
.github/actions/check-key-credit/gate.cjs:markerName(workflow, keyJob)buildskey-credit-stop-<caller-workflow-file>-<key-job>, so each caller is judged only on its own stops, as before.judgeMarkerstakes the newestcreated_atwithexpired == falseinside the window. It does not rely on response order, since the docs state none. A skip citesworkflow_run.id, and every read failure runs the key, as before.RECORD_PATTERN,MODEL_STEP,MAX_JOB_READS,judgeRun) is removed, along with the starved-scan case (newest runs that carry no record).action.yml: newmarkeroutput..github/workflows/pr-review-cli.yml:marker.lane-class == 'credit-stop', writes a one-line file, scans it withscan-upload, and uploads it withretention-days: 1(allcontinue-on-error).namefilter, from List artifacts for a repository: "When specified, only artifacts with this name will be returned." Anyone with read access may call it, soactions: readis enough. No new permission, token, secret or cache use.Verification
check-key-credit.test.cjs:/runsor/jobsURL;created_atwins in any order, and expired, misnamed or malformed markers are ignored;pr-review-cli.test.cjs: only the key job uploads, only after a credit stop, never with an empty name, scanned first, with 1-day retention; the gate job has no carry step.node --test .github/scripts/*.test.cjs: 881 pass.npx @biomejs/biome@2.5.11 ci --error-on-warningson.github/scriptsand.github/actions/check-key-credit: clean.Related
pr-verify.ymlandpr-review-main.yml, replace their record steps with the marker upload and delete their carry steps. Then gatecheck-intent-creditandreview-handoffs-creditafter their no-op exits, which this change makes safe (~100-155/h more).🤖 Generated with Claude Code
https://claude.ai/code/session_01VcupojVgxFqBnrah9DwFLE