Skip to content

feat(review): hand reviewers the read-only target repository token - #1489

Merged
steipete merged 2 commits into
mainfrom
review/readonly-github-token
Sep 8, 2026
Merged

steipete merged 2 commits into
mainfrom
review/readonly-github-token

Conversation

@steipete

@steipete steipete commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where hosted ClawSweeper reviewers hit unauthenticated GitHub API limits on shared runners despite having allowlisted network access. Related: #1484 and #1487.

Why This Change Was Made

Restore the existing target-repository GitHub App inspection token to the review child only as GH_TOKEN, through codexEnv. It has read-only contents, issues, and pull-request access and expires within an hour. Both the hosted workflow's prebuilt prompt and runtime-generated prompts use the same sanitized environment that reaches the reviewer. Legacy Codex sandbox selections retain token pass-through; the app-server worker already inherits this environment. OpenClaw retains its existing final child credential filter, so its prompts correctly continue to say that no GitHub token is supplied.

The managed proxy mode, host allowlist, filesystem permissions, and write-credential boundary are unchanged. Reviewers are instructed to use authenticated GitHub reads and never put the token in a URL, log it, or send it to a non-GitHub host.

User Impact

Codex reviewers can authenticate target-repository reads instead of consuming the shared runner's public GitHub rate limit. When no token is supplied, prompts continue to direct reviewers to public endpoints and pre-fetched context. This change does not give reviewers GitHub write access.

OpenClaw Bay Impact

Unaffected: this changes reviewer authentication and capability guidance only. It changes no lifecycle state, review publication format, queue behavior, public observer data contract, or Bay UI/API surface.

Documentation Impact

Updated active security guidance in README.md and the active “Reviewer network boundary” section in docs/pr-review-comments.md, plus the Unreleased changelog. ClawSweeper maintainers own the boundary; the review runtime, codexEnv, and setup permission profile are its sources of truth. Scope verified against this PR and Codex 0.153.3; update when token handling, runner selection, the pinned CLI, or the permission profile changes. Corrected the stale credential comment in the permission profile without changing its settings.

Evidence

  • Node 24.20.0, pnpm 11.10.0: all 179 focused tests passed across codex-review-runner, review-prompt-policy, agent-runner, codex-process, review-command-workflow, and openclaw-process after the accepted OpenClaw finding was fixed.
  • Coverage checks token-present/token-absent exec environments, source-token stripping, both prompt variants, hosted prebuilt prompts, and app-server inheritance for profile and legacy sandbox selections.
  • Build, repair/dashboard builds, formatting, documentation/static checks, lint, and all 13 focused changed-coverage tests passed.
  • Full local check: 5,347 passed, 19 failed, 13 skipped. The additional workflow failures were traced to Homebrew Bash 5.3.15 blocking in heredoc_write; affected stalled test processes were terminated, and all 151 sweep/cluster/reconcile tests plus all 6 dispatcher tests passed when rerun with system Bash through a task-local PATH wrapper. The remaining unrecovered failures are confined to the known host-environment fixtures test/apply-drift-refresh.test.ts and test/live-proof-review-environment.test.ts.
  • Initial test:unit: 3,497 passed, 22 failed, 6 skipped. It began before all repair artifacts were built; the scanner file affected by that setup error passed all 260 tests after the build. The same Bash recovery and known host-fixture limitations apply. No source changes were made for host/toolchain failures.
  • All hosted CI, including pnpm check, passed for the initial head 294c48dde52241b2c611680206db24342b85a2fb. CI runs again for the OpenClaw correction; the follow-up local full check also runs with the system Bash wrapper.
  • Pre-commit Codex reviews, including the consolidated candidate after the OpenClaw correction: scoped-clean at P0–P2; no accepted/actionable findings.

Real Behavior Proof

Claim and surface: a synthetic inspection token reaches the real Codex exec review sandbox only as GH_TOKEN; a bearer-authenticated GitHub request reaches GitHub while an unlisted host remains blocked.

Revision: 8ca5453. Both boundary probes were rerun after this commit.

Environment and fixture: local macOS 27.0 arm64, Node 24.20.0, pinned @openai/[email protected], isolated CODEX_HOME, and the repository's clawsweeper-review permission profile. Provider: local macOS Codex sandbox; container image/lease: not applicable. The Responses provider was a local scripted fixture that emitted the tool calls; Codex exec, its shell tools, managed proxy, and the HTTPS requests were real. The parent environment was cleared with env -i; only the synthetic token was supplied. No real GitHub credential or model-service credential was used.

Harness command and environment handoff:

npm install --prefix .artifacts/codex-0.153.3 @openai/[email protected]
# With Node 24 first on PATH:
env -i HOME="$HOME" PATH="$PATH" \
  CLAWSWEEPER_PROOF_INSPECTION_TOKEN=ghs_synthetic_not_a_real_token \
  node .artifacts/proof-exec.mjs

The harness calls codexEnv({ ghToken: process.env.CLAWSWEEPER_PROOF_INSPECTION_TOKEN }), sets the isolated CODEX_HOME, and launches the pinned binary with exec --ephemeral --skip-git-repo-check --json -C <proof-directory> -c 'default_permissions="clawsweeper-review"'. It uses the unchanged permission-profile contents. The controlled provider requests these three commands as separate real shell calls:

printf 'GH_TOKEN='; printenv GH_TOKEN
printf 'source token and GITHUB_TOKEN (must be empty):\n'
printenv CLAWSWEEPER_PROOF_INSPECTION_TOKEN GITHUB_TOKEN || true

curl -sS --max-time 20 -w '\nGitHub HTTP %{http_code}\n' \
  -H "Authorization: Bearer $GH_TOKEN" https://api.github.com/rate_limit

curl -sS --max-time 20 https://example.com/

Observed output:

Codex exit: 0
GH_TOKEN=ghs_synthetic_not_a_real_token
source token and GITHUB_TOKEN (must be empty):

{
  "message": "Bad credentials",
  "documentation_url": "https://docs.github.com/rest",
  "status": "401"
}
GitHub HTTP 401

exec_command failed: ProcessFailed { message: "Network access to \"example.com\" was blocked: domain is not on the allowlist for the current sandbox mode." }

The environment command exited 0 with no output for the two forbidden names. The GitHub command exited 0 and returned HTTP 401, proving transport and bearer-header pass-through with a synthetic credential. The unlisted host was rejected by Codex's managed network enforcement.

Artifact/trace: the observed tool outputs are transcribed above; the local harness retained proof-transcript.txt, the exec JSONL trace, and tool-output JSON for the handoff. The runtime and app-server regression tests separately verify that production environment wiring supplies the same token-only mapping.

Limits: this synthetic proof does not validate a real installation token's permissions, expiration, or authenticated quota. It exercises local macOS; the existing credential-free Ubuntu review-network-smoke CI job covers hosted Linux proxy/filesystem enforcement. No claim of resistance to prompt injection is made.

OpenClaw final child boundary

The accepted P2 finding is corrected: OpenClaw strips GH_TOKEN in its final child environment allowlist. Capability reporting now accounts for that filter, its existing subprocess test compares the advertised capability to the observed child environment, and README/review guidance no longer promise a token to OpenClaw.

A controlled execution of production runOpenclawProcess used a synthetic child CLI probe to record the actual worker/child environment. This exercises the real environment filtering and subprocess chain; it does not exercise the OpenClaw gateway or contact a model provider.

env -i HOME="$HOME" PATH="$PATH" \
  CLAWSWEEPER_PROOF_INSPECTION_TOKEN=ghs_synthetic_not_a_real_token \
  node .artifacts/proof-openclaw.mjs
capabilities: {"networkCapability":"unrestricted","hasGitHubToken":false}
child environment: {"GH_TOKEN":null,"GITHUB_TOKEN":null,"CLAWSWEEPER_PROOF_INSPECTION_TOKEN":null}
exit: 0

Review Disposition and Maintainer Decision

  • Accepted and fixed: the P2 OpenClaw capability mismatch. Its final credential filter is preserved; capability reporting, docs, prompt tests, and a production subprocess-boundary probe now agree.
  • Owner decision already made: the maintainer explicitly authorized handing the existing read-only, single-repository, one-hour GitHub App token to Codex reviewers, with the documented allowed-third-party disclosure risk. This PR implements that decision. Replacing the token with a trusted credential-holding read broker is outside this approved scope.
  • Proof scope explicitly selected by the maintainer: use only a synthetic token; GitHub HTTP 401 is an acceptable transport/header result. Real-token successful reads, denied operations, and revocation tests were not authorized for this proof and were not run. The existing workflow permission requests establish the requested read scope; this PR changes token handoff, not token minting or lifetime.
  • Rank-up disposition: the OpenClaw improvement is implemented. The broader authority-chain and allowed-third-party-recipient demonstrations remain outside the selected synthetic-only proof; the recipient exposure is an accepted known gap, not an enforced protection or a resolved containment claim.

Known Gaps

A prompt-injected reviewer could still leak the token in a GET query string to an allowlisted third-party host. The mitigation is the token's read-only, single-repository, one-hour scope. The prompt warning is guidance, not an enforced credential containment boundary. Authenticated installation limits still apply.

Maintainer Decision

The repository owner decided to hand reviewers the read-only target-repository token and accepts the documented exception: the credential handoff, bearer transport, unlisted-host rejection, and OpenClaw child filtering are proven with a synthetic token on the current head; scoped authorization and revocation are not exercised with a live App token outside the hosted job, and the residual disclosure path is a prompt-injected GET to an allowlisted third-party host, bounded by the token's read-only, single-repository, one-hour scope. proof: override records this decision.

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 8, 2026 06:45
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 8, 2026, 3:23 AM ET / 07:23 UTC.

ClawSweeper review

What this changes

Pass the existing read-only repository token to Codex reviewers and make capability prompts reflect each runner’s actual credential environment.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful: current main does not supply the inspection token to reviewers. The prior OpenClaw finding is fixed, and the recorded proof override resolves the previous proof blocker. No actionable patch defect remains.

Priority: P2
Reviewed head: 8ca545360b53ff6b16b94990de9276dd146e1932

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused implementation and relevant boundary traces support normal mergeable quality under the explicit proof override and accepted security tradeoff.
Proof confidence 🐚 platinum hermit (4/6) Override: A maintainer applied proof: override for this PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Overridden Override: A maintainer applied proof: override for this PR.
Evidence reviewed 9 items Repository policy and introduced changes inspected: Read the full root AGENTS.md and the complete introduced diff locally. No nested AGENTS.md or maintainer-notes directory was found. The policy’s proof, review-continuity, and Bay-impact guidance applies; the body explains why Bay is unaffected.
Still needed on current main: The pinned main implementation creates the reviewer environment without ghToken. The merged network-access work at #1487 explicitly retained token-free reviewers; #1484 addresses attachment preparation instead. Neither supersedes this change. The latest release tag lacks this split runtime path, so no released equivalent was established.
Token producer and sanitization: The workflow requests a target-repository inspection token with contents, issues, and pull requests read permissions. reviewEnvironment passes that token through the existing sanitizer, which removes ambient GitHub credentials and restores only the explicitly supplied GH_TOKEN. The workflow reuses the same environment for prompt generation and execution.
Findings None None.
Security None None.

How this fits together

ClawSweeper prepares repository context and launches an agent to review it. This change connects the workflow’s inspection token to Codex’s environment while keeping OpenClaw’s credential filter and both runners’ capability descriptions consistent.

flowchart TD
  A[Workflow inspection token] --> B[Sanitized reviewer environment]
  B --> C[Runner selection]
  C --> D[Codex receives token]
  C --> E[OpenClaw filters token]
  D --> F[Authenticated GitHub reads]
  B --> G[Capability prompt]
  E --> G
Loading

Before merge

  • Resolve merge risk (P1) - The accepted design exposes a short-lived read token to untrusted review execution; an injected GET to an allowed third-party host can disclose it. Live permission scope and revocation were not exercised and remain covered by the recorded proof override.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +38/-9; tests +102/-21 The production growth connects one sanitized environment to both prompt paths, with focused coverage across both runners and Codex transports.

Merge-risk options

Maintainer options:

  1. Retain the recorded exception (recommended)
    Proceed within the already accepted single-repository read-token boundary and preserve the explicit disclosure-risk and proof-limit documentation.

Technical review

Best possible solution:

Keep the narrowly scoped token handoff, truthful runner-specific prompts, and documented maintainer acceptance together without broadening credentials or network permissions.

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

Not applicable as a new capability; source confirms main omits the reviewer token, and current-head traces demonstrate the new handoff without establishing live authenticated quota.

Is this the best way to solve the issue?

Yes, within the recorded maintainer-approved boundary: it reuses the existing token and sanitizer while preserving OpenClaw filtering and aligning both prompt paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f6b3a613c509.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Override: A maintainer applied proof: override for this PR.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded reviewer-authentication improvement addressing shared-runner GitHub rate limits.
  • merge-risk: 🚨 security-boundary: The PR intentionally gives untrusted review execution a reusable read credential with a documented, accepted disclosure path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Override: A maintainer applied proof: override for this PR.

Evidence

What I checked:

  • Repository policy and introduced changes inspected: Read the full root AGENTS.md and the complete introduced diff locally. No nested AGENTS.md or maintainer-notes directory was found. The policy’s proof, review-continuity, and Bay-impact guidance applies; the body explains why Bay is unaffected. (AGENTS.md:77, 8ca545360b53)
  • Still needed on current main: The pinned main implementation creates the reviewer environment without ghToken. The merged network-access work at feat(review): give reviewers allowlisted network access and a truthful capability prompt #1487 explicitly retained token-free reviewers; fix(media-proof): fetch GitHub attachment URLs for review evidence #1484 addresses attachment preparation instead. Neither supersedes this change. The latest release tag lacks this split runtime path, so no released equivalent was established. (src/clawsweeper-review-runtime.ts:995, f6b3a613c509)
  • Token producer and sanitization: The workflow requests a target-repository inspection token with contents, issues, and pull requests read permissions. reviewEnvironment passes that token through the existing sanitizer, which removes ambient GitHub credentials and restores only the explicitly supplied GH_TOKEN. The workflow reuses the same environment for prompt generation and execution. (src/clawsweeper-review-runtime.ts:963, 8ca545360b53)
  • Read-only workflow scope: The scheduled review job separates its write-capable host token from the Codex inspection token; the latter is scoped to the selected target repository and requests only read permissions. (.github/workflows/sweep.yml:4868, 8ca545360b53)
  • Prior OpenClaw finding resolved: Capability reporting now requires the Codex runner before advertising GH_TOKEN. OpenClaw’s production child environment still uses its existing allowlist, which excludes GitHub tokens; the updated subprocess test compares the advertised capability with the observed child environment. (src/agent-runner.ts:59, 8ca545360b53)
  • Current-head proof and explicit override: The supplied body at sourceRevision 04537e95c4c8749754baaead02eb70736842523af68e311d026653651aa3e673 records current-head macOS Codex 0.153.3 traces showing synthetic GH_TOKEN handoff, GitHub HTTP 401, unlisted-host rejection, and production OpenClaw child filtering. These establish transport and filtering, not live token authorization or revocation. The snapshot records proof: override applied at 2026-09-08T07:20:50Z and an explicit body disposition accepting those limits, satisfying the previous review’s rank-up request. (8ca545360b53)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-08T06:49:05.068Z sha 294c48d :: needs real behavior proof before merge. :: [P2] Derive OpenClaw token capability after its credential filter
  • reviewed 2026-09-08T07:07:54.582Z sha 8ca5453 :: needs real behavior proof before merge. :: none

@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the accepted OpenClaw capability finding on the current head while preserving its final credential filter. The main PR body now contains the finding disposition, current synthetic Codex exec proof, an OpenClaw subprocess-boundary probe, and the maintainer's explicit token-exposure decision and synthetic-only proof scope.

@clawsweeper

clawsweeper Bot commented Sep 8, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete steipete added the proof: override Maintainer accepted a documented proof exception for this PR. label Sep 8, 2026
@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 8, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 8, 2026
@steipete
steipete merged commit c6ead21 into main Sep 8, 2026
24 of 29 checks passed
@steipete
steipete deleted the review/readonly-github-token branch September 8, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: override Maintainer accepted a documented proof exception for this PR. 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