Skip to content

feat(review): retry review lanes once on a fallback token and fix lane drift - #756

Merged
kyle-sexton merged 3 commits into
mainfrom
feat/review-lanes-fallback-and-drift
Oct 17, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
feat/review-lanes-fallback-and-drift

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Refs: melodic-software/claude-code-plugins#7669

Summary

The review lanes (pr-review.yml, pr-review-security.yml) get a one-time retry on a second token when the first attempt hits a usage limit. This PR also fixes four drift items from the claude-code-action audit (D3, D4, D5, D7) and adds a no-change skip for a restack that left the pull request's change as it was (#7669). Callers that pass no new secret or input keep today's single attempt.

Fix

  • Usage-limit fallback. New optional secret fallback-claude-code-oauth-token.
    • With it set, an inline check reads a failed first attempt's execution file. It applies the same rule report-lane-outcome's classify.cjs uses for class=rate-limit; a test pins the two together.
    • A usage limit leaves only a warning with no class= token. Only the final report names the run's class, so a fallback that then fails another way is never read as rate-limited by babysit_merge.py or babysit_review_evidence.py.
    • The review then retries once in the same job on the fallback token. The retry gets whatever is left of the review step's budget (11 min for code review, 14 min for security), so both attempts fit in the job timeout. With under 2 minutes left, no retry starts.
    • A pick step (attempt) passes the chosen attempt's outcome, execution file, start time, budget and structured output to the verify, outcome, record and status steps. The structured output travels through a random 128-bit heredoc delimiter, and an empty fallback output never borrows the first attempt's. The verify window opens when the chosen attempt started.
    • The completion notice ends with account=fallback when the fallback token did the review. Without the secret, none of the new steps run.
  • D3 model. New inputs model (default sonnet) and effort (default high) on both lanes. They are appended as --model/--effort after claude-args, so they win over a --model passed there. --model claude-sonnet-5 is removed from the claude-args default. Values that are not a plain alias/ID, or not a known effort level, fail the compose step.
    • Opus for the security review waits for usage data from the new lane records. The reviews account carries most lane usage, so both lanes stay on Sonnet for now. A caller can override with the model input.
  • D4. classify_inline_comments: false, so inline comments post as they are made and a step timeout cannot drop buffered findings.
  • D5. CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "1" on the review steps. It strips credentials from Bash subprocesses and leaves GitHub tokens in place, so gh pr diff still works.
  • D7. include_fix_links: false.
  • #7669, restack skip. Both lanes share this scope logic.
    • The reviewed-head marker comment gains a second line, <!-- claude-lane-reviewed-base ref=<base branch> merge-base=<sha> -->. The merge gate reads only the first line.
    • When the last reviewed head is not an ancestor of the new head, the run skips (skip=no-change, marker on the new head) only if all three hold:
      1. The base branch is the one recorded.
      2. The change as reviewed (compared from the recorded merge base) touches the same files with the same status and rename source as the change now.
      3. git --literal-pathspecs diff --raw <reviewed> <head> -- <those paths> is empty: same mode, type and blob. It runs after a --depth=1 --filter=blob:none fetch of the reviewed head.
    • A retarget, a mode or type change, an older marker without the base line, or a failed fetch reviews the whole pull request.
    • Race guard. No skip (no-change or docs-only) is taken unless pulls.get still shows the run's head as the live head.

The probe result needs one correction. In pr-pipeline-sandbox run 38965516737, the code lane did not skip because of restack handling; it also saw affa9b3 is not an ancestor. It skipped because the sandbox's pr-review-no-bots control calls pr-review.yml with the same lane id (claude-review) and docs-only-paths: "**". That control's docs-only skip had already moved the shared claude-review marker to 597106f (comment 6224391858, updated 20:53:50) before the real lane read it.

Merge-order dependency

babysit_review_evidence.py RECORD_RE (claude-code-plugins, lines 55-61) is anchored with $ and rejects a trailing account=fallback. The coordinator handles it in claude-code-plugins. That change must land before any caller passes fallback-claude-code-oauth-token.

Changes needed outside this repository (not made here)

standards, components/runner-policy/policy.json. Add a new entry for each lane at this PR's merge sha. Copy the v0.42.2 entries (pr-review.yml@a623e29… at line 124, and the matching pr-review-security.yml@a623e29… entry), then change two things:

  • allowedSecrets: add "fallback-claude-code-oauth-token": "${{ secrets.<FALLBACK_SECRET> }}". Per REVIEW-POLICY §3(b), that secret is AUTOMATIONS_CLAUDE_CODE_OAUTH_TOKEN.
  • allowedInputs: add "model" and "effort" only if callers will pass them. Today's defaults need neither.

standards, components/runner-policy/README.md. Add the registration paragraph after line 1221 (the v0.42.2 paragraph). It should say:

  • one new optional secret, and new model/effort inputs;
  • the review step's model moves from claude-sonnet-5 to the sonnet alias;
  • new steps first-outcome, fallback, claude-review-fallback and attempt;
  • a second anthropics/claude-code-action step that receives the fallback secret;
  • classify_inline_comments, include_fix_links and CLAUDE_CODE_SUBPROCESS_ENV_SCRUB on both action steps;
  • the scope step now runs git fetch/git diff;
  • no permission or runs-on change.

standards caller components (sync-managed). Repin uses: and add the secret line under the existing CLAUDE_CODE_OAUTH_TOKEN: line:

  • components/claude-lanes-hosted/claude-review.yml: uses: line 84, secrets line 96
  • components/claude-lanes-hosted/claude-security-review.yml: uses: line 77, secrets line 89
  • components/claude-lanes/claude-review.yml: uses: line 79, secrets line 91
  • components/claude-lanes/claude-security-review.yml: uses: line 73, secrets line 85

Verification

  • node --test .github/scripts/*.test.cjs .github/actions/report-lane-outcome/*.test.cjs: 425 pass, 0 fail.
  • claude-lane-fallback.test.cjs covers:
    • Parity: the first-attempt check agrees with classify.cjs on 13 execution-file shapes × timed-out or not, and no warning carries class=.
    • The prepare and pick steps' own scripts, run with hand-computed budgets.
    • The chosen structured output, including an empty fallback output and injected outcome=/delimiter text that cannot set another output.
    • The fallback step equals the first attempt except for its token, id, if and timeout.
  • claude-lane-scope.test.cjs covers:
    • The restack skip in both lanes.
    • Mode, type and content changes, file-set or status differences, a retarget, a marker with no base line, and a failed fetch each forcing a whole review.
    • The live-head race guard for restack, no-change and docs-only skips.
    • The record step's base line.
    • A real-git test: a blob-less shallow clone, three rebases onto a moved base, and a path starting with :. same skips; mode (644→755) and type (file→symlink) review.
  • Compose tests: model and effort follow the caller's args, and an injected or unknown value fails before any args are written. Status test: the record carries account=fallback only on a fallback review.
  • actionlint (1.7.12): clean on every workflow. zizmor --offline: the same 2 medium artipacked findings as main (the documented #1236 workaround). gitleaks on the diff: no leaks.
  • Not verified live:
    • a real rate-limit retry;
    • the sonnet alias and --effort on the CLI bundled with action v1.0.250;
    • an expression in a step's timeout-minutes at run time (actionlint accepts it);
    • GitHub serving a --depth=1 fetch of a force-pushed-away reviewed head. If it does not, the run falls back to a whole review.

Related

  • REVIEW-POLICY §3(b), §5 row 1; FINAL-DESIGN amendment A2; ACTION-DRIFT §3 D3/D4/D5/D7 (D1/D2 pin bumps are separate); MODEL-ROUTING §4 (model per owner's later direction: Sonnet on both lanes).

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 17, 2026 11:12
…e drift

- Optional `fallback-claude-code-oauth-token` secret on pr-review.yml and
  pr-review-security.yml: a first attempt that stops on a usage limit
  (class rate-limit) is retried once in the same job, inside the review
  step's budget, before the report steps; the completion record ends
  `account=fallback`. Without the secret the job behaves as before.
- `model` and `effort` inputs (default `sonnet`, `high` on both lanes)
  appended as --model/--effort after claude-args; the legacy
  `--model claude-sonnet-5` default is gone.
- classify_inline_comments: false, include_fix_links: false and
  CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 on the review steps.
- A rebase or restack that leaves every file's status and patch as reviewed,
  with no base change under the pull request's files, is a no-change skip
  (claude-code-plugins#7669).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The reviewed-head marker records the base branch and merge base on its
  second line. A rebase skips only on the same base branch, when the change
  reviewed from that merge base touches the same files the same way, and
  `git diff --raw` shows those paths identical (mode, type, blob) between
  the reviewed head and this one.
- No skip (no-change or docs-only) while the live pull request head differs
  from the run's head.
- The first attempt's usage limit is detected inline by the classify.cjs
  rule (a test pins parity) and leaves a warning with no class= token, so
  only the final report names the run's class.
- The pick step carries the chosen attempt's structured output through a
  random heredoc delimiter; an empty fallback output no longer borrows the
  first attempt's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-10-17T15:53:42.469585Z 8ebf8fc 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.

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 6m 15s —— View job


Claude code review in progress

  • Gather context (CLAUDE.md, REVIEW.md, standards index, gh pr diff)
  • Review workflow changes (pr-review.yml, pr-review-security.yml) — manual pass done
  • Review script/test changes (compose-args, fallback, scope, status-check, review-complete)
  • Review README changes
  • Adversarially verify candidate findings
  • Post inline comments and final summary

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 46s —— View job


Security review in progress

  • Gather context (PR diff, changed files)
  • Review .github/workflows/pr-review.yml + pr-review-security.yml (fallback token, scope/skip logic)
  • Review script test files for security-relevant logic (model/effort injection rejection tests confirm the regex/case-statement guards hold)
  • Review README.md changes (docs only, no issues)
  • Apply instruction-surface deletion lens (no CLAUDE.md/AGENTS.md/rules/skill/agent files touched by this PR)
  • Adversarial verification of two candidate concerns (restack-skip bypass; fallback-token handling) — running
  • Post findings

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ebf8fc393

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/pr-review.yml Resolved
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

claude-security-review has reviewed this pull request through d4d5617; a later push is reviewed from there.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

claude-review has reviewed this pull request through d4d5617; a later push is reviewed from there.

…omments

A first attempt that called the inline-comment tool before its usage limit
is no longer retried on the fallback token, so no finding posts twice and
verification never counts only the retry's comments. The check step keeps
its rate-limit output equal to classify.cjs and adds a retry output that
the fallback gates on, in both review lanes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AfcE6qXwStK92XAx21MG43
@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 37s —— View job


Security review in progress

  • Gather context (incremental diff scope, AGENTS.md, pr-body-contract rule)
  • Read .claude-lane/incremental.diff for the changed-since-last-review scope
  • Review the fallback retry logic in pr-review.yml / pr-review-security.yml
  • Review claude-lane-fallback.test.cjs changes
  • Adversarially verify candidate findings — running
  • Post findings

@claude

claude Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 0s —— View job


Claude code review: no blocking findings

Scope (incremental): reviewed only what changed since 8ebf8fc — .github/scripts/claude-lane-fallback.test.cjs, .github/workflows/pr-review-security.yml, .github/workflows/pr-review.yml (per .claude-lane/incremental.diff). Every other file was reviewed at 8ebf8fc and is unchanged here.

  • Gather context (standards index, CLAUDE.md/REVIEW.md, incremental diff)
  • Review incremental diff in the two workflow files
  • Review incremental diff in claude-lane-fallback.test.cjs
  • Cross-check against Codex's open P2 comment (reconcile published comments before retrying)
  • Adversarially verify candidate findings
  • Post inline comments and final summary

What this increment does

Commit d4d5617 adds a posted check to the first-outcome step in both lanes: it scans every message in the execution file for a tool_use call to mcp__github_inline_comment__create_inline_comment. A new retry output is limited && !posted, and the fallback step's gate moved from steps.first-outcome.outputs.rate-limit == 'true' to steps.first-outcome.outputs.retry == 'true'. This directly closes the gap Codex flagged on the pr-review.yml:734 fallback step: a first attempt that already posted inline findings before hitting the usage limit no longer gets a second full review, so no duplicate inline comments/summary and no verification-window reset onto a fallback-only finding count.

Verification

  • Traced retry's only consumer (fallback.if) and confirmed the now-vestigial rate-limit output isn't read anywhere else downstream (attempt, record, outcome, status steps all key off steps.fallback.outputs.run, not first-outcome.outputs.rate-limit), so the duplicate output doesn't create an inconsistent "fallback ran" signal anywhere.
  • Confirmed the "attempt" pick step still correctly falls back to the primary attempt's outcome/execution file when FALLBACK_RAN is false (i.e., when posted=true suppressed the retry), so the rate-limited-but-posted case still reports account=primary with the correct execution file, not a dangling state.
  • Confirmed the only thing that can post mid-run before a result message exists is the inline-comment MCP tool (the summary comment is the action's own tracked-progress comment, posted from the model's final output, which doesn't exist yet if the run dies on a 429) — so scoping the "already posted" check to that one tool name is correct and complete for the duplicate-finding scenario, not just a partial fix.
  • Checked the new test (a usage limit after an inline comment is not retried...) against the implementation: the message shapes, the retry/rate-limit output pair, and the warning text (no fallback attempt) all match. The added assert.equal(outputs.retry, String(expected)) in the parity-table test is correct since none of those payloads carry a message.content shape, so posted is always false there and retry tracks rate-limit 1:1.
  • pr-review.yml and pr-review-security.yml carry the identical change (only the pre-existing 11/14-minute budget difference remains), so no lane drift between them in this increment.

One intentional tradeoff worth noting but not a blocker: posted is true if the tool was called at all, even if that specific call itself errored before actually posting a comment. That's the conservative direction (never risk a duplicate), consistent with this PR's stated design, so I'm not flagging it as a finding.

No inline comments to post — I didn't find anything a careful reviewer would block on in this increment.

@kyle-sexton
kyle-sexton merged commit e6c87ce into main Oct 17, 2026
29 checks passed
@kyle-sexton
kyle-sexton deleted the feat/review-lanes-fallback-and-drift branch October 17, 2026 16:35
kyle-sexton added a commit that referenced this pull request Oct 17, 2026
…de (#760)

No related issue: org-wide outage fix; every AI review lane run since
about 18:39Z 2026-10-17 fails while installing Claude Code.

## Summary

#756 set `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "1"` on both review attempts
in `pr-review.yml` and `pr-review-security.yml`. Claude Code 2.1.300
(the version claude-code-action v1.0.250 installs) refuses to start on
Linux with the scrub on and no bubblewrap:

```
error: bubblewrap is required for subprocess env scrubbing and isolation. Install with: sudo apt-get install -y bubblewrap, set sandbox.bwrapPath in managed settings, or set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0 to disable (loses subprocess isolation).
```

(claude-code-plugins run 39059470151.) The action's own "Install
subprocess isolation dependencies" step runs only when
`allowed_non_write_users` is set, which the review lanes do not set, so
nothing installed bwrap. `intake-triage.yml` sets
`allowed_non_write_users: "*"`, so the action installs it there and that
lane is unaffected.

## Fix

Add an "Install subprocess isolation" step before the first review
attempt in both workflows: apt-get install `bubblewrap` and `socat` with
three retries, lift the Ubuntu 24.04 AppArmor userns restriction, and
fail closed when `bwrap` is missing. This matches the action's step and
claude-code-plugins' `setup-runner-isolation` action. The scrub stays
on. The fallback attempt runs in the same job, so one install covers
both.

## Verification

- `actionlint` over both files: no new findings. The
`$/.github/actions/report-lane-outcome` finding was already on `main`.
- `node --test .github/scripts/*.test.cjs`: 420 passed, 0 failed.
- This PR's own review lanes run the patched copy only after merge; the
check that matters is the first caller run after the repin.

## Related

- #756 (introduced the scrub env)
- Upstream: https://code.claude.com/docs/en/env-vars (the
`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` row, read 2026-10-17, does not
mention the bubblewrap requirement);
`anthropics/claude-code-action@a26b07d` `action.yml`, "Install
subprocess isolation dependencies".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01AfcE6qXwStK92XAx21MG43

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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