Skip to content

fix(upstream-apply-changelog): skip the key after a credit-stop - #13064

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/release-lane-credit-stop-skip
Nov 4, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/release-lane-credit-stop-skip

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Refs: #7407

Summary

Run 41760968895 (release 2.1.318) ended its model step with class=credit-stop on ISSUE_LANE_CLAUDE_API_KEY. A credit stop writes no done marker, so every 10-minute tick re-ran the model on the same release and credit-stopped again. This reuses the key-credit mechanism pr-verify and pr-review-main already use, so the lane retries a dead key once per window instead of every tick.

Fix

  • Marker. After the leg, the model job writes key-credit-stop-upstream-apply-changelog.yml-model when steps.run.outputs.handoff-reason == 'credit-stop' and the gate's marker output names that artifact. It scans the marker with the trusted checkout's scan-upload and uploads it with 1-day retention. pr-verify uses the same three steps.
  • Gate. Once Pick the release proceeds, the gate job runs check-key-credit@09cf6f2 (key-job: model, window-hours: vars.KEY_CREDIT_WINDOW_HOURS || '1'). When it returns skip-key, the run skips the start record (so the per-day cap is not charged) and skips the model job. It also prints a ::notice:: naming the marker run and the UTC time the window ends, dated by one artifact read. The action's own notice ends "the subscription job reviews". That is wrong for this lane, which has no subscription leg; the lane's notice follows it.
  • Probing off (probe-minutes: "0"). The workflow's concurrency group runs one run at a time, so no second run can reach the key while the first run after the window tries it. That keeps the gate to one read.
  • Permissions. The gate job already has actions: read. The upload uses the runner token.
  • Call count. The schedule comment now says at most 13 GITHUB_TOKEN REST calls per tick, 78 an hour. Before this change it was 11 and 66.
  • Retention. New exact row in .github/artifact-retention.json. The key-credit-stop-* wildcard claims only computed names, so it does not cover this literal upload.
  • Dispatches. A workflow_dispatch inside the window is skipped too, the same as pr-verify. A topped-up key is tried once the window ends.

No subscription or OAuth fallback leg, and no secret changes.

Verification

  • node --test .github/scripts/upstream-apply-changelog/upstream-apply-changelog.test.mjs: 45 pass, 0 fail. Four tests are new: the gate step is pinned and wired, a skipped key starts no model and records no start, the notice dates the window's end (run against a fake gh), and the marker is written on credit stop, scanned and kept 1 day.
  • scripts/check-artifact-retention.sh: 86 upload steps match (61 families).
  • scripts/check-affected.sh --base origin/main --no-fetch: 10 passed, 6 skipped, exit 0.

Related

Remaining

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 3, 2026 22:07
A credit stop of the model job wrote no done marker, so every 10-minute
tick re-ran the model on the same release and credit-stopped again.

The model job now uploads key-credit-stop-upstream-apply-changelog.yml-model
after the leg's credit-stop handoff, as pr-verify does. The gate reads it
with ci-workflows check-key-credit once a release is picked; inside the
window the run starts no model, records no start, and prints a notice
naming the marker run and when the window ends.

Refs: #7407

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MWmASNtP63MZxdDeoxYztD
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 4, 2026 03:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T03:15:20.733604Z 1e36dfd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of 04dd6daff2f443465259f5c80baebaa2c1cb1cd6: no file of this pull request changed since the review of be1b167.

Code review: PR #13064, skip the key after a credit stop

Scope: I read every hunk of all 3 changed files: .github/workflows/upstream-apply-changelog.yml, .github/artifact-retention.json and .github/scripts/upstream-apply-changelog/upstream-apply-changelog.test.mjs. The workflow is a trusted path, so I also read the head workflow from the gate job through the new marker-upload steps. I compared it with pr-verify's credit gate as well.

Findings: none.

What I checked:

  • Gate order and skip. Read the key's credit history runs only after Pick the release proceeds (L156-L165). A skip leaves out both the start record and its upload, so the per-day cap is not charged. The model job's if also checks needs.gate.outputs.skip-key != 'true' (L228). The gate job already has actions: read.
  • Fails open. The gate step has continue-on-error: true. If it fails, skip-key and credit-marker are both empty, so the model runs and no marker is written.
  • Marker wiring. The write step fires only when the gate's marker output equals the literal name. That name is also the upload name and the new retention row (1 day, scan: upload), so the gate's name and the upload name cannot drift apart unnoticed. The write runs after Check out the base for the sealer and is scanned with the trusted checkout's scan-upload. This matches pr-verify.
  • Action outputs. handoff-reason is read from run-claude-cli@09cf6f2, the same pin that pr-verify, pr-review-main and maintenance-audit-lane-runs read it from. check-key-credit@09cf6f2 is the same pin pr-verify and pr-review-main use.
  • Notice script. Under bash -e, gh api … || true, the integer check on WINDOW_HOURS and the ${ends:-an unread time} fallback cannot abort the step, and the step is continue-on-error anyway.
  • Tests. The four new tests cover the gate wiring, the skip conditions, the notice's end-time arithmetic (run against a fake gh) and the marker steps. Everything they need is imported. I could not run them because this lane has no shell. The author reports 45 pass, 0 fail; I have not verified that.

Prior findings: the lane's earlier round, at head 1e36dfd, had 0 findings and nothing to carry forward. Round cap 3, not past it.

Closing issue: the PR body says Refs: #7407 and closes no issue, so there are no acceptance criteria to check.

Paved paths / path-scoped rules / manifests: no plugin manifest changed. The change reuses the existing check-key-credit approach from pr-verify and pr-review-main rather than adding a second way to do it.

Spend (not a hold): this lowers prepaid API-key spend, because a key that is out of credit is tried once per window instead of every 10-minute tick. It adds at most 2 GITHUB_TOKEN REST calls per tick, which uses rate budget, not billing.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review needs no new review of 04dd6daff2f443465259f5c80baebaa2c1cb1cd6: no file of this pull request changed since the review of be1b167.

Security review: PR #13064 (head be1b167)

No security issues found. I read every hunk of all 3 changed files: .github/artifact-retention.json, .github/scripts/upstream-apply-changelog/upstream-apply-changelog.test.mjs and .github/workflows/upstream-apply-changelog.yml. The workflow is a trusted path, so I also read the model job around the new steps. The new head merges main into the branch. This PR's own changes match the head this lane reviewed earlier, 1e36dfd1, which also had no findings.

What I checked

  • Gate job, "Read the key's credit history" (L182-L191):
    • The action is pinned to a full SHA: check-key-credit@09cf6f2ecd22f7188e62552dea9af48adbd23bb1.
    • It is passed no secrets.
    • The job's permissions are unchanged.
    • The step is continue-on-error, so a failed read leaves skip-key empty and the model runs, which is what happened before this change.
  • Gate job, "Report the credit skip" (L195-L213):
    • Every value reaches the run: script through env:. No ${{ }} expression is placed inside the script.
    • WINDOW_HOURS must be a whole number (^[0-9]+$) before it is used in arithmetic.
    • created comes from the GitHub API, not from user text.
    • GH_TOKEN is the default github.token, limited by the job's existing permissions.
  • Model job, credit-stop marker steps (L427-L455):
    • They run after the model step and after a fresh checkout to .lane-trusted (L406-L417). The scan-upload action therefore comes from that checkout, not from anything the model wrote to disk.
    • The marker directory is deleted with rm -rf, recreated, and holds only $GITHUB_RUN_ID.
    • The job's permissions stay at contents: read (L232-L233).
  • Worst case if the marker is forced: upstream changelog text could steer the model step into reporting handoff-reason == 'credit-stop', but it cannot change what the marker file holds. The most it can do is pause the lane for one credit window. Nothing leaks, no account or machine is compromised, and nothing is billed.
  • Trust controls: the change leaves these as they were, so nothing is widened:
    • the kill switch checks;
    • the trusted-trigger check;
    • the lane token request and broker;
    • every merge hold;
    • the trusted-actor list.
  • Retention row and tests: the new row keeps the marker for 1 day and is scanned on upload. The test file adds checks on the workflow's structure and one test that runs against a fake gh in a temporary directory. Neither has a security surface.
  • Instruction files and plugin manifests: the diff changes neither, so those checks don't apply.

Spend: inside a credit window, runs no longer start the model on ISSUE_LANE_CLAUDE_API_KEY, so this change spends fewer prepaid API credits. The only added cost is up to 2 more GITHUB_TOKEN REST calls per tick. Not a hold.

critical-findings: 0

kyle-sexton and others added 2 commits November 3, 2026 23:39
The new "Report the credit skip" step read the marker artifact with a bare
gh call, which the api-budget guard test rejects. Source api-budget.bash
and wrap gh like the job's other steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head be1b167031aaed9e1a4c399aca6cb25899b3d1bf. What it wrote, as data:

What it wrote (28 lines)
Summary: PR #13064 is linked to #7407 by a `Refs:` line, so it delivers only part of that issue.
  That part is in scope: a credit-stop gate so the upstream-apply-changelog lane stops re-running
  the model against a key with no credit. The diff looks correct, and the test-node job that covers
  the changed test file passed. It still fails because the PR body never says what remains of #7407
  for later work, and a `refs` delivery has to name that.
- PR body: the issue is linked by `Refs: #7407` (spec_kind `refs`), but the body never names the
  work that remains for #7407. Add a 'Remaining for #7407' section. Per the owner-decided acceptance
  amendment, it should name at least the first live scheduled run of upstream-apply-changelog.yml
  that processes a new release and opens its PRs, recorded on the issue (run URL, release, PRs
  opened), and say that this PR does not close the issue.
- PR body: the part it delivers is named clearly (the credit-stop marker plus the gate that skips
  the model and the start record), and it fits the issue's lane and per-day-cap requirements. Once
  the remaining work is named, nothing else blocks.
- .github/workflows/upstream-apply-changelog.yml:187: adds a third-party action from the org's own
  ci-workflows repo (check-key-credit), pinned to a full SHA. It gets no secrets, and it has
  continue-on-error, so a failure leaves skip-key empty and the model runs as before. No safety
  concern found.
- .github/workflows/upstream-apply-changelog.yml:182-191: the window is set by
  vars.KEY_CREDIT_WINDOW_HOURS, defaulting to 1 hour. That is a schedule/spend setting within the
  subscription, not a real charge, and it does not loosen any cap: skipped runs no longer count
  toward the per-day cap, because the model never starts on them.
- .github/scripts/upstream-apply-changelog/upstream-apply-changelog.test.mjs: test-node passed on
  the judged head
  (https://github.com/melodic-software/claude-code-plugins/actions/runs/41774606053/job/126392050785).
  The new tests check how the workflow is wired, and they run the notice script against a fake gh,
  so they can fail.
- Not judged against the spec: the issue's own outstanding acceptance item (the recorded live run)
  is a person-recorded step and is not expected from this diff.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

PR body contract — issue linkage

This PR body conforms to the issue-linkage contract. Nothing to do.

@github-actions github-actions Bot added needs-issue-linkage Pull request body has no issue linkage line; set by the check-contract step, advisory. and removed needs-issue-linkage Pull request body has no issue linkage line; set by the check-contract step, advisory. pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. labels Nov 4, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 2f6eab4 Nov 4, 2026
58 checks passed
@kyle-sexton
kyle-sexton deleted the fix/release-lane-credit-stop-skip branch November 4, 2026 05:22
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