Skip to content

fix(sweep): allow PR review lease comments - #539

Merged
brokemac79 merged 1 commit into
mainfrom
codex/csw-035-common-shard-failure
Jul 14, 2026
Merged

brokemac79 merged 1 commit into
mainfrom
codex/csw-035-common-shard-failure

Conversation

@brokemac79

@brokemac79 brokemac79 commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Grants the scheduled review shard's target App token pull-requests: write, while retaining its existing issues: write scope.
  • Adds a focused workflow regression test that requires both write permissions in the Create target review token block.

Problem

The scheduled ClawHub sweep in run 29261805316 minted a token with issues: write but pull-requests: read. Review-shard lease/status comments use POST /repos/{target}/issues/{number}/comments; on PR items that endpoint needs the App's Pull requests write permission. All 29 ClawHub PR shards therefore received 403 Resource not accessible by integration, while the one ordinary issue succeeded.

This is independent of PR #518's recovery/fanout handling and PR #521's ledger lifecycle work.

Implementation

Only the review-shard Create target review token block in .github/workflows/sweep.yml changes:

  • permission-pull-requests: read becomes permission-pull-requests: write.
  • No recovery, queue, state publication, labels, gates, application credentials, or other token scopes change.

Validation

  • pnpm run build:all — passed.
  • node --test --test-name-pattern "sweep target review token can post pull request review leases" test/sweep-workflow.test.ts — passed (1/1).
  • node --test --test-name-pattern "sweep target review token can post pull request review leases|review workflow gives Codex a read-only inspection token" test/sweep-workflow.test.ts — passed (2/2).
  • node --test --test-name-pattern "codex subprocess env strips GitHub and App credentials|codex subprocess env can expose an explicit read-only GitHub token" test/clawsweeper.test.ts — passed (2/2).
  • node --test test/sweep-workflow.test.ts — passed (62/62) in Linux local-container Crabbox proof, provider local-container, lease cbx_8c70bf6e5438, commit f38ac5bb6d75f01ea21fdf2d70927b0965dedde4. The one-shot lease stopped automatically.
  • Docker clean-copy proof (node:24-bookworm, Debian 12): mounted the PR worktree read-only, copied source into /work, installed with pnpm install --frozen-lockfile, then passed:
    • node --test --test-name-pattern "sweep target review token can post pull request review leases|review workflow gives Codex a read-only inspection token" test/sweep-workflow.test.ts — passed (2/2).
    • node --test --test-name-pattern "codex subprocess env strips GitHub and App credentials|codex subprocess env can expose an explicit read-only GitHub token" test/clawsweeper.test.ts — passed (2/2).
    • node --test --test-name-pattern "review start status comment is marker-backed and crustacean-friendly|spoofed durable markers cannot suppress a bot-owned start lease|concurrent review lease election uses server comment order, not client timestamps" test/review-comment-rendering.test.ts — passed (3/3).
  • pnpm exec oxlint test/sweep-workflow.test.ts --deny-warnings — passed.
  • YAML parse of .github/workflows/sweep.yml — passed.
  • git diff --check origin/main...HEAD — passed.
  • actionlint — unavailable on this host: executable is not on PATH.
  • pnpm run format:check reports pre-existing formatting differences across 373 files, including both unchanged full files touched here; no repository-wide formatting rewrite was applied.

Credential-boundary proof

  • The review shard still receives the short-lived target review token as GH_TOKEN only for deterministic review orchestration and lease/status publication.
  • A distinct Create target Codex inspection token step requests only contents: read, issues: read, and pull-requests: read. The Review shard step passes that token separately as CLAWSWEEPER_PROOF_INSPECTION_TOKEN.
  • src/codex-env.ts deletes inherited GH_TOKEN, GITHUB_TOKEN, App credentials, and CLAWSWEEPER_PROOF_INSPECTION_TOKEN before reinjecting only the explicit inspection token for the Codex subprocess. Existing tests cover both stripping inherited credentials and passing an explicit inspection token.

This preserves the intended boundary: deterministic workflow code can post the lease/status comment; the untrusted Codex subprocess receives the separate read-only inspection credential.

Deployment prerequisite and installation evidence

The ClawSweeper GitHub App installation for openclaw/clawhub must allow Pull requests: Read & write. actions/create-github-app-token can narrow an installation permission but cannot grant a permission that the installation does not have.

The installation settings endpoint is not readable with the available user authentication: GET /repos/openclaw/clawhub/installation returns 401 A JSON web token could not be decoded. The capability is nevertheless proven by redacted live workflow evidence from the failing parent run itself: run 29261805316, job Publish review artifacts (86858453103), ran Create target write token at 2026-07-13T15:27:35Z for openclaw/clawhub with permission-pull-requests: write; that step succeeded and its normal post-step cleanup revoked the token. The pinned workflow at the run head requested the same write scope. This establishes that the installation could mint a ClawHub PR-write token at incident time; the remaining defect was that the review shard requested only PR read.

Post-merge behavior proof

The Docker proof above is deterministic local-container evidence for the workflow/token boundary and lease-comment behavior. It is not claimed as the requested live post-deployment App-token proof; the real lease/status comment URLs still require a normal default-branch run after merge or an explicit maintainer proof override.

The requested real App-token proof cannot be produced from this unmerged branch: scheduled review shards execute the default-branch workflow, and this PR does not dispatch or rerun workflows. Before treating the rollout as complete, a maintainer must:

  1. Let a normal scheduled or maintainer-requested review process one ClawHub PR and one ordinary issue after this change is deployed.
  2. Capture redacted run output and the two resulting lease/status comment URLs, then request @clawsweeper re-review.

Maintainer rollout decision

Maintainer decision recorded 2026-07-14:

Authenticated approval: proof: override comment by brokemac79.

  • Approve a monitored rollout of this single short-lived target-review-token change: pull-requests: write alongside its existing issues: write scope.
  • Accept a pre-merge real-behavior proof override because the required real App-token evidence necessarily depends on the default-branch workflow after deployment.
  • Do not widen any other token, credential, workflow, state-publication, recovery, or Codex subprocess capability.
  • Require the first normal post-merge review cycle to capture redacted run output plus both a pull-request and ordinary-issue lease/status comment URL, then request a normal @clawsweeper re-review.

Risks and rollout

The additional scope is limited to the short-lived review token already used for deterministic lease/status comments. Repository contents, checks, statuses, and the Codex inspection token remain read-only. The remaining proof is a post-deployment normal-run observation; this PR does not dispatch or rerun anything.

Codex review closeout

  • codex review --uncommitted — clean; no accepted or actionable findings.
  • codex review --base origin/main — clean; no accepted or actionable findings.

@brokemac79
brokemac79 requested a review from a team as a code owner July 13, 2026 17:18
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 13, 2026, 11:46 PM ET / July 14, 2026, 03:46 UTC.

Summary
Changes the scheduled review-shard target token from pull-request read to write permission and adds a focused workflow test requiring issue-write and pull-request-write scopes.

Reproducibility: yes. The linked production run consistently failed all 29 PR review shards with authorization errors while the ordinary issue succeeded, and current main's token permissions explain that split.

Review metrics: 3 noteworthy metrics.

  • Permission surface: 1 token scope changed. The functional patch only promotes the review shard's Pull requests permission from read to write.
  • Regression coverage: 1 focused test, 13 lines added. The new assertion protects both required write scopes in the exact workflow block.
  • Observed incident: 29 PR shards failed, 1 issue succeeded. The production split strongly localizes the outage to pull-request comment authorization.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • After merge, attach redacted output and the resulting PR and issue lease/status comment URLs from the first normal review cycle.

Risk before merge

  • [P1] The short-lived deterministic review token gains the broader Pull requests write capability, so compromise or unintended expansion of that trusted workflow path could permit PR mutations beyond lease/status comments.
  • [P1] The positive end-to-end result remains deployment-dependent: the first normal default-branch run must confirm successful lease/status comments on both a pull request and an issue while preserving the read-only Codex credential boundary.

Maintainer options:

  1. Proceed with monitored rollout (recommended)
    Merge the scoped permission change under the recorded override and verify both PR and issue comment publication in the first normal post-deployment review cycle.
  2. Pause for a narrower publisher design
    Keep this PR open if maintainers no longer accept PR-write permission in the review shard and instead move comment publication to a separately write-authorized trusted job.

Next step before merge

  • No automated repair is needed; the remaining action is ordinary maintainer merge followed by the approved post-deployment observation.

Security
Needs attention: The code preserves Codex credential isolation, but intentionally grants the trusted review shard PR-write capability and therefore requires the approved monitored rollout.

Review details

Best possible solution:

Merge the narrow token change under the approved monitored rollout, then capture redacted output and resulting comment URLs from the first normal pull-request and issue review cycle and re-review the deployed behavior.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked production run consistently failed all 29 PR review shards with authorization errors while the ordinary issue succeeded, and current main's token permissions explain that split.

Is this the best way to solve the issue?

Yes. Changing only the affected short-lived review token is the narrowest correction, while the separate read-only Codex credential and focused regression assertion preserve the intended security boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b30773af54b4.

Label changes

Label justifications:

  • P1: Scheduled ClawHub pull-request review shards cannot publish lease/status comments, breaking an active automation workflow for every selected PR.
  • merge-risk: 🚨 automation: The diff changes credentials used by scheduled review orchestration, and successful end-to-end publication can only be confirmed after default-branch deployment.
  • merge-risk: 🚨 security-boundary: The patch intentionally broadens a short-lived trusted token from Pull requests read to write while keeping the Codex subprocess on a separate read-only token.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Override: An explicit proof override accepts that real App-token success can only be observed after default-branch deployment; extensive focused, Crabbox, Docker, and credential-boundary validation supports the monitored rollout.
Evidence reviewed

Security concerns:

  • [medium] Monitor the expanded PR-write token boundary — .github/workflows/sweep.yml:1835
    The review orchestration token can now perform pull-request write operations beyond comments if its trusted execution path is compromised or later expanded; retain the separate read-only Codex token and verify the first deployed run.
    Confidence: 0.96

What I checked:

  • Current-main failure path: Current main gives the scheduled target review token issues: write but only pull-requests: read, matching the reported authorization split where PR comment publication fails while issue publication succeeds. (ithub.global.ssl.fastly.net) (.github/workflows/sweep.yml:1832, b30773af54b4)
  • Narrow permission correction: The branch changes only the affected review token to permission-pull-requests: write; GitHub's issue-comment surface applies to both issues and pull requests, and the App-token action supports narrowing installation permissions through permission-* inputs. (github.com) (.github/workflows/sweep.yml:1835, f38ac5bb6d75)
  • Regression coverage: The added test isolates the single target review-token block and asserts both issue-write and pull-request-write permissions. (test/sweep-workflow.test.ts:1599, f38ac5bb6d75)
  • Credential separation retained: The workflow continues to mint a separate read-only Codex inspection token, and the established subprocess boundary strips inherited GitHub and App credentials before exposing only that inspection credential. (github.com) (src/codex-env.ts:1, b30773af54b4)
  • Production reproduction and installation capability: The linked incident processed 29 pull requests that failed with 403 Resource not accessible by integration while one issue succeeded; the same run also successfully minted another short-lived token requesting pull-request write permission, showing the installation supported the proposed scope. (.github/workflows/sweep.yml:1832, 435a9246e4fa)
  • Validation and proof override: The PR reports focused and full workflow tests, credential-isolation tests, Linux Crabbox and clean Docker validation, and all reported GitHub checks are successful; the discussion now contains an explicit proof: override approving monitored deployment with required post-merge evidence. (test/sweep-workflow.test.ts:1599, f38ac5bb6d75)

Likely related people:

  • brokemac79: Beyond proposing this PR, they authored the merged failed-shard recovery work in fix(sweep): bound failed shard recovery #518, which recently modified the same central sweep workflow and its operational boundaries. (role: recent workflow contributor; confidence: high; commits: 7296ed70fb91; files: .github/workflows/sweep.yml, test/sweep-workflow.test.ts)
  • vincentkoc: They authored the latest large merged action-ledger and automation lifecycle change on current main, making them relevant to interactions between review tokens, workflow publication, and audit behavior. (role: recent automation lifecycle contributor; confidence: medium; commits: b30773af54b4; files: .github/workflows/sweep.yml)
  • steipete: Repository policy routes live ClawSweeper workflow controls and sensitive automation decisions to Peter, making him a likely escalation owner if the monitored rollout needs reconsideration. (role: security-boundary decision owner; confidence: medium; files: .github/workflows/sweep.yml, src/codex-env.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-13T19:59:01.132Z sha f38ac5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-13T22:36:25.393Z sha f38ac5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-13T23:45:54.583Z sha f38ac5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-14T01:23:08.306Z sha f38ac5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-14T02:31:06.610Z sha f38ac5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-14T02:44:06.988Z sha f38ac5b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T03:07:00.591Z sha f38ac5b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T03:31:04.789Z sha f38ac5b :: needs maintainer review before merge. :: none

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

1 similar comment
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 13, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 14, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

proof: override

As a maintainer, I approve a monitored rollout of #539's only new capability: the short-lived target-review token may request pull-requests: write alongside its existing issues: write permission.

This is a pre-merge proof override because real App-token PR-and-issue lease/status-comment proof is only possible after the default-branch workflow is deployed. Do not widen any other token, workflow capability, state publication path, or the read-only Codex subprocess boundary.

Before the rollout is considered complete, capture redacted output from the first normal post-merge review run plus the resulting pull-request and ordinary-issue lease/status comment URLs.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 14, 2026
@brokemac79
brokemac79 merged commit 97e8237 into main Jul 14, 2026
25 checks passed
@brokemac79
brokemac79 deleted the codex/csw-035-common-shard-failure branch July 14, 2026 04:06
steipete added a commit that referenced this pull request Jul 14, 2026
Reverts merge commit b30773a while preserving follow-up #539 and #545 behavior.
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Reverts merge commit c0aa0bc while preserving follow-up openclaw#539 and openclaw#545 behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant