Skip to content

fix(pr-pipeline): note an over-cap done run in its PR and split act-turns counts - #11839

Merged
kyle-sexton merged 3 commits into
mainfrom
host-run/7901-max-turns-over-cap
Nov 1, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
host-run/7901-max-turns-over-cap

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #7901

Summary

Two of #7901's criteria, from the 2026-10-31 decision:

  • A done run that finished past its --max-turns now says so in its PR's Summary: The run went past its turn budget (turns=N max-turns=M): the work may be too big for one run. A run within its cap gets no such line.
  • act-turns.json now records how many assistant messages in the execution file belong to the main loop (parent_tool_use_id null) and how many to subagents (set). That gives the evidence to explain a num_turns above the cap, such as 140 of 75.

Fix

  • .github/scripts/lib/act-turns.mjs: the act-turns step's logic, moved out of the inline scripts in both runners.
    • It adds turn_counts: main_loop and subagent message counts, plus main_loop_turns and subagent_turns, which count distinct model turns by message id.
    • When the file holds no subagent message, it adds a note saying it holds main-loop messages only.
    • The 32768-byte cap is unchanged.
  • Both runners copy the script out of .base before the head checkout and record its SHA-256 as a step output. The act-turns step imports only bytes that match that hash, loading them from a data: URL so the file cannot change between the check and the load.
    • Model-run code can rewrite files in RUNNER_TEMP. In the write runner this step holds the lane token, so a rewritten script must never load.
  • Read runner lane.json: adds turns from the act-turns step's existing turns output.
  • report-outcome.mjs: readOverCap returns {turns, cap} when turns > max-turns. decide passes it through, the resumed-branch path included, and adds the Summary line. lane.json is rewritable, so the line only informs and never changes the plan.

Verification

  • scripts/check-affected.sh --tests on the committed head: 11 static checks passed. It selected 68 test suites and left them to CI, because the workflow files changed. I ran the directly affected suites locally, and all passed:
    • report-outcome.test.mjs: 354 pass.
    • callers.test.mjs, .github/scripts/lib/*.test.mjs, open.test.mjs, seal.test.mjs: 246 pass.
    • scripts/act-turns-denied.test.sh: 63 pass, 0 fail.
  • New tests:
    • report-outcome.test.mjs: readOverCap cases. An over-cap done run returns open-pr with the turns=140 max-turns=75 line in its Summary. A run within its cap has no line.
    • .github/scripts/lib/act-turns.test.mjs: a fixture with both message kinds asserts both counts, plus the main-loop-only note, the worst case under the 32768-byte cap, and redaction.
    • scripts/act-turns-denied.test.sh: runs each runner's step body against the shared script. Added cases: a script that fails the hash fails the step and writes nothing, and the copy step comes before the head checkout.

Related

  • Not in this PR (ci-workflows): report-lane-outcome needs its own class=max-turns text, and "max-turns exhaustion" must come out of its infrastructure-error line. Once a release carries that, every report-lane-outcome pin here moves to it.
  • Host-run step, after this ships: read act-turns.json from one over-cap run and record the main-loop and subagent counts against its cap in fix(pr-pipeline): explain turns above max-turns and report max-turns as a sizing stop #7901.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 1, 2026 00:44
…urns counts

A run that finishes past its --max-turns is a success to run-claude-cli, so
its PR said nothing about the cap. The read runner's lane.json now carries
the act-turns step's `turns` beside `max-turns`, and report-outcome adds a
Summary line, "The run went past its turn budget (turns=N max-turns=M)", to
the PR of a done run whose turns exceed the cap. lane.json is rewritable, so
the line only informs and never changes the plan.

The act-turns step's logic moves out of both runners' inline scripts into
.github/scripts/lib/act-turns.mjs. Each runner copies it from .base before
the head checkout, with its SHA-256, and the step loads only bytes that
match. act-turns.json now records turn_counts: assistant messages with a
null parent_tool_use_id (main loop) and with one set (subagents), each also
as distinct model turns by message id, with a note when the file holds
main-loop messages only. The 32768-byte cap is unchanged.

Refs: #7901

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 1, 2026 05:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-01T05:02:13.019435Z ef5b122 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 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review (incremental since ef5b122)

Scope: .github/workflows/pr-run-activity-write.yml, which is a trusted path, so I read its whole incremental change.

No security issues found.

The only change since the last review moves one YAML comment block (6 lines). The block describes the issue-mode base checkout and how scripts/setup-env.sh is copied out. It used to sit above the act-turns script copy step and now sits above the Copy the dependency setup from the base step it describes. No step, if: condition, permissions: entry, token request, script body or step order changed. The change widens no trust control, exposes no secret, adds no injection surface and loosens no pin.

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 ef5b122447904c4840425b076e44e5652967f191; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Incremental review (ef5b122 → 2cc2bdd): no findings.

Scope: .github/workflows/pr-run-activity-write.yml, which is on the trusted-path list, so I read its whole incremental change and the steps around it (lines 1389–1444 at head).

The change only moves comments. Six comment lines that had ended up above the new Copy the act-turns script from the base step go back above Copy the dependency setup from the base (now L1410-L1415), where they describe the setup-env copy. Each step now sits under its own comment, and the change fixes the comment placement the earlier commit got wrong.

Nothing executable changed: step order, if: conditions, env values, the run scripts and the head checkout are the same as at ef5b122. The act-turns copy and its SHA-256 output still run before Check out the PR head, as the PR description requires. The other 7 files have not changed since ef5b122, which this lane already reviewed.

The act-turns copy step was inserted under the setup-env step's comment in
the write runner, so that comment described the wrong step.

Refs: #7901

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 2f86fb1 Nov 1, 2026
50 checks passed
@kyle-sexton
kyle-sexton deleted the host-run/7901-max-turns-over-cap branch November 1, 2026 06:03
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 1, survived 5, timeout 0, no coverage 0, invalid 0, not run 1.
Covered-code score 17%; mutation score 17%.

File Killed Survived Timeout No coverage Invalid Not run
.github/scripts/lib/act-turns.mjs 1 5 0 0 0 0
.github/scripts/work-resolve-issue/report-outcome.mjs 0 0 0 0 0 1

Surviving mutants

Location Operator Disposition Cause
.github/scripts/lib/act-turns.mjs:69 ROR productive input-gap
.github/scripts/lib/act-turns.mjs:87 SBR productive input-gap
.github/scripts/lib/act-turns.mjs:95 SBR productive input-gap
.github/scripts/lib/act-turns.mjs:116 ROR productive input-gap
.github/scripts/lib/act-turns.mjs:122 LCR productive input-gap

The run's summary has the full report.

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