Skip to content

fix(ci): stop a credit-stopped release-lane run from spending the daily cap - #13242

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

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

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #13233

Summary

upstream-apply-changelog caps model runs at 3 a day by counting upstream-apply-changelog-started records, which the gate wrote before the model ran. #13064 skips the model inside KEY_CREDIT_WINDOW_HOURS of a credit stop. But once the window ends, the lane probes the key again, and a probe that credit-stops (400, out of credit) had already left its start record. So an out-of-credit ISSUE_LANE_CLAUDE_API_KEY used up the cap, and the lane never took a release (#13233's runs at 02:28-02:49Z, and the 13:21Z gate at its cap).

Fix

  • .github/workflows/upstream-apply-changelog.yml:
    • The start record is written in the model job, after the credit marker upload (:442-490): "Record the start", a credential scan, then "Upload the start record". The record step runs always() and skips only when steps.run.outputs.handoff-reason == 'credit-stop' and the marker uploaded.
    • Success, any other failure, install failures and an unread key history all still count, so the cap still bounds real runs.
    • The runs are serial (concurrency queue: max, :55-58), so the next gate always sees the record. No new read is added.
  • Timeout: the leg ends at 70 min (leg-timeout-minutes, :385), before the step's 75 (:338) and the job's 90 (:214). A model timeout fails the step, and the record step still runs and counts.
  • Records:
    • a credit-stopped run writes a ::warning:: and a job summary line naming the release and whether it counts;
    • the in-window skip also writes its notice to the summary.
  • .github/artifact-retention.json:570-571 (the started row now says scan: upload), docs/conventions/pr-pipeline.yaml:1095-1097, and a changelog fragment.
  • Not added: a subscription or OAuth fallback. This lane reads outside-authored changelog text, so it skips a credit-stopped key instead (owner decision Q2 (a)).

Verification

  • upstream-apply-changelog.test.mjs 51/51, with these new tests:
    • a credit-stopped leg whose marker uploaded writes no start record, which fails on main;
    • a leg that ran writes one: success, other, timeout, max-turns, auth, and a credit stop with no marker;
    • the cap gate run against a local HTTP stub: 2 starts proceed, 3 stop;
    • the timeout order: leg < step ≤ job − 5.
  • callers.test.mjs 240/240; api-budget-coverage with workflow-gates 60/60; check-artifact-retention.sh clean.
  • scripts/check-affected.sh --base origin/main --no-fetch: exit 0.
  • Left out:
    • this lane writes no report-lane-outcome record today, so a lane-outcome entry for the credit stop is not added. The summary and warning carry it.
    • UNVERIFIED: whether Actions enforces timeout-minutes on this uses: step. The leg timeout inside run-claude-cli ends the leg first either way.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 4, 2026 08:42
…ly cap

The upstream-apply-changelog gate wrote its start record before the
model ran, so a run whose key credit-stopped still counted toward the
per-day cap of 3, and an out-of-credit key used the cap every day
without a model turn.

The model job now writes the start record after the leg, rewritten and
scanned as the credit-stop marker is, and skips it only when the leg
ended in a credit stop and that marker uploaded. A credit stop with no
marker still counts, so the cap stays the brake. The concurrency group
runs one run at a time, so the later write opens no race with the next
gate. A credit-stopped run, and a run the credit window skips, write a
job summary line.

Refs: #13233

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The start record step runs after a failed model step, so a leg that
times out still counts toward the per-day cap only while the step's
timeout-minutes ends before the job's. The new test checks the leg
timeout is below the step's and the step's at least 5 minutes below
the job's.

Refs: #13233

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 4, 2026 13:48
@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-04T13:50:18.736190Z df60880 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-security-review reviewed f0155d94457abf80d48ee06f5f1a20a3bbe80267: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #13242 (head f0155d9)

No security issues found. I read every hunk of all 5 changed files. This lane already reviewed an earlier head (df60880d), so this review reports only CRITICAL and IMPORTANT findings.

What changed since the last review: two sets of conditions moved from steps.run.outcome != 'skipped' to steps.models.outcome != 'skipped':

  • the start-record condition;
  • the conditions on the trusted checkout steps, "Clear the trusted checkout path" and "Check out the base for the sealer" (L395-406).

The code-review thread on pre-leg setup failures is resolved, and this head fixes it.

Trusted-path files

  • .github/workflows/upstream-apply-changelog.yml. I read the model job, L213-515.
    • The job if: (L217) is unchanged.
    • permissions: contents: read (L221-222) is unchanged.
    • The kill-switch step (L254-259) is unchanged.
    • The run-claude-cli pin, tools, allowed tools and disallowed tools (L339-390) are unchanged.
  • The trusted checkout now also runs when setup failed before the leg. It checks out needs.gate.outputs.base-sha with persist-credentials: false (L403-405). It holds no token, and the only new consumer is the scan-upload of the start record.
  • The seal step still runs only when the leg ran (L511).
  • The new steps (L454-496) take only needs.gate.outputs.release, which the gate chose. They pass it through env: and quote it in shell, so the model's output has no injection path.
  • docs/conventions/pr-pipeline.yaml (L1095-1098): only comment text changed. No lane slot, activity effect, merge setting or limit value changed.

Trust controls: none is widened.

  • The trusted-actor check, lane token scope and kill switch are unchanged. The model job is still gated on steps.kill.outputs.proceed through steps.models.
  • Broker inputs and merge holds are unchanged.

Forged credit stop: a model steered to fake one cannot buy extra runs. Leaving out the start record needs handoff-reason == 'credit-stop' and a marker that uploaded (L456). That marker holds the next runs off the key for the credit window.

Other files

  • .github/artifact-retention.json: scan changes from none to upload, which is stricter.
  • The test file's Function() evaluates if: text from the repository's own workflow. Its HTTP stub listens only on 127.0.0.1. Both are test-only.
  • The changelog fragment is prose.

Spend: credit-stopped runs no longer count toward limits.upstream-apply-changelog-per-day, so more model runs may draw on the prepaid ISSUE_LANE_CLAUDE_API_KEY credits. That is not a hold.

PR context: no text in it tells the lane to pass the PR, skip a check, drop a finding or post elsewhere.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on df60880d88de2565b0f0f948502cdd5fcb79ea7b; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed f0155d94457abf80d48ee06f5f1a20a3bbe80267: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #13242, head f0155d94

No blocking findings. This lane already reviewed an earlier head (df60880d), so this pass reports blocking findings only and leaves out advisory ones.

What this PR changes

  • It moves the upstream-apply-changelog-started record out of the gate job and into the model job. The record is written after the leg and scanned before upload.
  • It skips the record only when the leg ended in a credit stop and the credit-stop marker uploaded.
  • The credit stop and the in-window skip now each write a line to the job summary.
  • The retention row (scan: upload), the pr-pipeline.yaml comment and the changelog fragment are updated to match.

How I reviewed

  • I read every hunk of all 5 changed files.
  • I also read the model job's step conditions at head, upstream-apply-changelog.yml:254-540.
  • I ran nothing. The test counts in the PR body (51/51, 240/240, check-affected.sh) are the author's claims and I did not verify them.

Earlier finding (settled thread at line 450)

The owner resolved it in f0155d9, and I confirmed the fix at head:

  • "Record the start" now runs on always() && steps.models.outcome != 'skipped' (L456). A failure in "Resolve the model" or any later setup step before the leg now writes a record. Only a kill-switch skip writes none.
  • The trusted checkout that the record's scan needs runs on the same condition (L396-L400).
  • The new "setup failure before the leg" test checks the step's real if: and would fail on the old condition.

Closing issue #13233

Other notes

  • Spend: Credit-stopped runs no longer use cap slots, so more model legs a day can reach ISSUE_LANE_CLAUDE_API_KEY. This spends prepaid API credit only.
  • Scope checks:
    • No .claude/rules/ path rule matches the changed files.
    • No plugin manifest changed.
    • The PR context contains no embedded instructions.

kyle-sexton and others added 2 commits November 4, 2026 08:57
…ease cap

The start record needed the leg to have run, so a persistent setup fault
(route error, checkout failure) reran the model job every tick uncapped.
It now counts every model job past the kill switch, and the trusted
checkout its scan uses runs on the same condition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it-stop-cap

# Conflicts:
#	.github/scripts/upstream-apply-changelog/upstream-apply-changelog.test.mjs
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit cb4194e Nov 4, 2026
53 checks passed
@kyle-sexton
kyle-sexton deleted the fix/release-lane-credit-stop-cap branch November 4, 2026 14:18
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.

fix(ci): upstream-apply-changelog spends its daily cap on credit stops and never reaches a model turn

1 participant