Skip to content

fix(scripts): end a local check-affected --tests run at its budget - #12756

Merged
kyle-sexton merged 9 commits into
mainfrom
fix/12639-check-affected-budget
Nov 3, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
fix/12639-check-affected-budget

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #12639

Summary

A local scripts/check-affected.sh --tests could run far past its 120 s budget, which stalled the ready flip: nothing stopped the run, and --budget only warned. The budget now ends a local run. Suites past it are named and left to CI, which runs the full set either way.

Fix

  • check-affected.sh sets a deadline once at run start, so the static tier and selector count against the budget, and passes it to the runners through env.
  • run-plugin-tests.sh checks it before each suite, check-affected.sh before each Node package, and check-skill.sh check 7 before each scripts/*.test.sh.
  • Each left suite gets its own SKIP line. A suite that ran and failed still fails the run, with the left ones still named. A later Node package still runs after an earlier one fails.
  • run-plugin-tests.sh counts a .left marker only when a deadline is set and no .rc was recorded.
  • check-skill.sh exits 3 with an INCOMPLETE line when a deadline left script tests and nothing failed; check-changed-skills.sh maps that to a skip.

CI is unaffected: no workflow sets PLUGIN_TEST_DEADLINE, --budget alone stops nothing, and workers unset it for nested runs.

Verification

Run by the worker and again by a fresh verifier on 6a065f21ee, each reading exit status directly: check-affected.test.sh (123 pass), run-plugin-tests.test.sh, check-changed-skills.test.sh, check-skill.test.sh. New cases were seen failing first. Changelog fragment checks pass.

A real --tests run at 1772c34356, before the last fix round: 210 s against the 120 s budget, overlapping another run, naming 91 suites left. An earlier run measured 150 s, with one suite taking 88 s. So "budget plus one suite" holds approximately; the suite durations of the 210 s run were not captured.

Known limits:

  • A full --tests run on a committed skill change was not run. Evidence for that path is the changed-skills gate alone, 22 s against a 20 s deadline, plus suite cases.
  • Time outside the deadline: setup-env --node and non-suite gates, including check-skill's static checks, still run past it.
  • A budget-ended run exits 0, so ready records verify as pass from a sample, and ci-status still gates the merge. This repository has that step off (docs/conventions/source-control.yaml).
  • With a live deadline, a suite that writes its own .left and kills its worker reads as left locally. CI sets no deadline, so the same suite fails there.
  • Longest-first order spends the budget on few suites: 2 of 26 shell suites ran at --jobs 1. Not changed.
  • plugins/skill-quality/skills/check/evals/evals.json still describes PASS or FAIL from the exit code. Exit 3 needs the deadline, which that skill's path does not set.

Related

  • plugins/source-control/skills/pull-request/reference/ready-for-review.md now says a first flip runs the suites up to the budget.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD

kyle-sexton and others added 9 commits November 3, 2026 00:01
The budget only reported an overrun, so a large selection ran far past it
and stalled every ready flip. check-affected now sets a deadline at the
run's start and hands it to run-plugin-tests.sh, which starts no suite after
it. tests reads as a SKIP naming each suite left to CI. A suite that ran and
failed still fails the run. The deadline travels in environment variables
that only check-affected sets, so a CI run, with or without --budget, still
runs every suite it selects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
When the budget leaves suites and other selected suites have no local runner,
the skip line now counts both, since run_check keeps only the last line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
A deadline 2 s away can leave about 1 s once the clock is read in whole
seconds, too little for a loaded runner to launch the first suite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
Under check-affected --tests, changed-skills ran each changed skill's script
tests with no deadline, so a skill-touching branch could run past the budget.
Check 7 of check-skill.sh now reads PLUGIN_TEST_DEADLINE: no script test starts
after it, each one left prints a SKIP line, and with no failure the run ends
INCOMPLETE at exit 3. check-changed-skills.sh reads that as its could-not-look
exit, so changed-skills is a SKIP. With the variable unset every script test
runs, which is how CI runs them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
…corded results

A failed Node package ended the loop, so later packages neither ran nor got
named; each now runs until the deadline and the run still fails at the end.
A suite can reach its own left marker, so a recorded result now outranks that
marker, and the marker counts only on a run with a deadline. The check skill and
the ready reference now state what a budget-ended run does.

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

chatgpt-codex-connector Bot commented Nov 3, 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-03T06:19:13.073167Z e3a17c8 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 3, 2026

Copy link
Copy Markdown
Contributor

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

Security review: no security issues found

I read every hunk of all 12 changed files. The change adds a local deadline to the test runners: scripts/check-affected.sh, scripts/run-plugin-tests.sh, scripts/check-changed-skills.sh and plugins/skill-quality/scripts/check-skill.sh. It also adds their tests, two changelog fragments and two doc edits. None of the changed files matches a trusted path. No workflow, action, manifest, token request, trusted-actor list or merge-hold file is touched.

What I checked:

  • Arithmetic injection through PLUGIN_TEST_DEADLINE. Bash expands a variable's value inside (( )), so an unchecked value could run code. Both entry points reject any value that is not ^[0-9]+$ before using it. In check-skill.sh the check is at line 241 and the use, in check 7, is at line 1437. In run-plugin-tests.sh the check is at line 285. The worker branch (line 190) reads the variable before that check, but only the parent runner starts workers, after validating, and the worker inherits the parent's environment. An attacker would already need control of the local environment, which gains them nothing new.
  • Paths written from the environment. PLUGIN_TEST_LEFT_FILE is written only when it is set, and only check-affected.sh sets it, to its own mktemp path. Its EXIT trap removes $out.left. Workers unset both variables before a suite runs (lines 191 and 1452), so a suite cannot inherit them or redirect where they write.
  • A suite forging the .left marker. A suite can still write <key>.left into PLUGIN_TEST_LOG_DIR. The runner counts the marker only when a deadline is set and no .rc was recorded (line 724). A recorded failure therefore always wins, and with no deadline the marker is ignored. No .github/ workflow or script sets PLUGIN_TEST_DEADLINE (searched), so CI's test lanes still run every suite they select.
  • Merge gating. A local run that stops at its budget now exits 0, and the left suites show as SKIP. check-affected.sh --tests is listed as a lane check in resolve-config. Those runs give no merge authority: ci-status and CI's full test lanes still gate the merge, and none of their files is changed. This lowers what a local run covers but does not affect security (no leak, compromise or charge).

Instruction surfaces: the SKILL.md and ready-for-review.md edits only describe the new exit code 3 / INCOMPLETE outcome and the budget-limited first flip. They remove no guardrail.

PR context: no embedded instructions aimed at this lane.

Spend: a budget-limited local --tests run uses less local runner time. Nothing here adds billed usage.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #12756, a local check-affected --tests run now ends at its budget

I read the whole change in all 12 files. I found no correctness or maintainability problem a careful reviewer would block on or flag. Security was not in scope here because this repository runs a separate security lane.

What I checked

  • Deadline set once and passed down (scripts/check-affected.sh)
    • The deadline is set after the snapshot re-exec, so the inner run sets its own.
    • It is a plain shell variable, not exported. Only the changed-skills and tests steps receive it, through env. The lint-only path gets no deadline.
    • affected-tests.sh calls run-plugin-tests.sh only once, at line 1767. So the single PLUGIN_TEST_LEFT_FILE cannot be overwritten by a second call.
  • How the runner stops (scripts/run-plugin-tests.sh)
    • The worker clears PLUGIN_TEST_DEADLINE and PLUGIN_TEST_LEFT_FILE before any suite runs, so a suite never inherits them.
    • The deadline check covers both the serial and the parallel workers.
    • The collection loop counts .left only when a deadline is set and no .rc was recorded. So a .left file a suite writes itself cannot hide a recorded failure. With no deadline, a worker that never reported still fails as before.
    • The left list is written before the failed exit, so a failed run still names the suites it left.
  • Return codes in affected()
    • Exit 0 with suites left returns 2, which run_check reports as a SKIP.
    • Exit 1 still fails, and the SKIP lines are still printed.
    • Exit 3 goes on to the Node packages, which now run one package at a time. In the per-package result, a failure (1) beats a package that could not run (2), and a later package still runs after an earlier one fails.
    • The combined summary line stays the last line of output, which is the line run_check puts in the skip.
  • Skill script tests (check-skill.sh → check-changed-skills.sh)
    • check-skill.sh exits 3 only when nothing failed, and root mode tallies those skills separately.
    • check-changed-skills.sh maps exit 3 to its own exit 2, so check-affected.sh reports a skip, never a pass. Each script test left is named on a SKIP line, which run_check already picks up.
    • The deadline is removed from each script test's environment with env -u.
  • Bad deadline values: both scripts reject a deadline that is not epoch seconds, including an empty one, with exit 2. The tests cover this.

Closing issue #12639

The one acceptance criterion: "A local check-affected.sh --tests ends within about its budget plus one suite's run, and names the suites it left to CI." I judge it met for the suite-running part, with tests that would fail if it broke:

  • run-plugin-tests.test.sh checks the run time is at most 20 s for a 5 s deadline with 6 s suites, and checks the left file and the LEFT TO CI lines.
  • check-affected.test.sh checks the left suites become named SKIP lines and a skip result, and that a Node package does not start after the deadline.

The time spent outside the deadline (setup-env --node, validate-plugins, and check-skill's static checks) is listed in the PR description as a known limit. I did not run any test. The pass counts in the PR description are the author's claim and I have not confirmed them.

Other notes

  • Path-scoped rules: .claude/rules/skill-bodies-state-current-rules.md and cost-claims.md apply to the changed SKILL.md and ready-for-review.md. Neither change breaks them.
  • No plugin manifest changed. Both changelog fragments are bump: patch.
  • Nothing in the PR context reads as an instruction to this lane. No settled threads or prior findings apply (round 0 of 3).
  • Spend: none. The change affects local scripts only.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 37e332d Nov 3, 2026
102 of 116 checks passed
@kyle-sexton
kyle-sexton deleted the fix/12639-check-affected-budget branch November 3, 2026 06:58
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.

check-affected --tests overruns its budget and stalls the ready flip

1 participant