Skip to content

fix(rewrites): preserve async PR merge authority - #231

Merged
vincentkoc merged 3 commits into
mainfrom
fix/async-merge-structural-guard-20261006
Oct 6, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/async-merge-structural-guard-20261006

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Async PR merges could enter generic JSON rewriting, allowing a policy to change the reviewed SHA, merge method, or action before GitHub received the request.

User Impact

Protected async merges preserve merge authority and rewrite only commit title/message text. Status polling keeps the local writer identity. Callers can require this behavior by putting -H 'X-Octopool-Require: merge-async-v1' first after gh api; older protected CLIs refuse it and require a CLI upgrade. No Worker deployment, policy change, credential change, or migration is needed.

Why This Change Was Made

Extend the existing merge snapshot owner with the async fields and guarded missing-head lookup. Unsupported merge request syntax and rewritten merge endpoints cannot enter generic fallback. Local --template/-t formatting now uses the modeled snapshot path alongside --jq; formatter bytes stay unchanged. The marker prevents older wrappers from silently rewriting new callers' authority; response validation alone occurs too late.

Related: openclaw/openclaw#163579 (comment)

Evidence

  • Focused async/synchronous merge tests passed, including malformed payloads, missing-head preflight failures, immutable private snapshots, status polling, and rejection before child GitHub I/O.
  • The built executable and copied gh shim preserve the allowed file request and native exit/output; an anchored squash -> rebase rule dispatches no child.
  • Broad rewrite/native-read regression selection passed: go test ./cmd/octopool -run '^(TestStringRewrite.*|TestRewrite.*|TestProtectedPRRead.*|TestCLIHelpBootstrap/(explicit|shim)/operational)' -count=1 (initial head: 92.957s; formatting correction: 88.509s).
  • Installed Octopool 0.6.4 (e2eae0a) reproduced the unsafe rewrite with a synthetic child: without marker, one child received rebase; marker-first exited 1 with zero child calls. No live merge was submitted by this fixture.
  • Live configured-wrapper metadata GET accepted the marker; GitHub async merge contract and native gh API options checked.
  • Independent P0/P1 autoreview: scoped-clean. gofmt, targeted Markdown formatting, and git diff --check passed.
  • Production net +88 lines adds the async contract and prevents fallback from changing merge authority; tests net +298, docs +21. Existing synchronous merge and native read paths are covered.

Review compatibility decision

Resolved the formatting concern by preserving harmless --template/-t output options through the protected parser, including separate, attached, and equals spellings on synchronous/async PUT and UUID GET. Native GitHub CLI v2.98.0 source confirms these are local output options and rejects incompatible format flags before its API request.

Request-affecting --cache, pagination, and raw-body Content-Type remain deliberately rejected for protected merges: they are not output formatting, and generic rewriting cannot preserve merge authority. Use the modeled JSON request directly and fresh status reads. This implements the review's recommended option without an unsafe fallback.

Current head: 32fb0b8ed600156e2a17c80533717ed2e65d5557. Focused protection-read/API/built-wrapper tests passed (11.883s). The Windows CI failure on the preceding head was reproduced locally: an old test still expected --template to take generic rewriting. The test-only correction moves that expectation into the preserved-formatting matrix and adds rulesets GET sibling coverage (24 cases total). Independent review found the correction sound. The prior runtime diff has scoped-clean autoreview and ClawSweeper approval; Current-head CI passed on Linux and Windows; ClawSweeper marked this exact head ready with no findings or remaining rank-up moves.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 6, 2026 12:05
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 8:27 AM ET / 12:27 UTC (Revision 3).

ClawSweeper review

What this changes

Octopool’s GitHub CLI wrapper protects asynchronous merge control fields, pins omitted head commits, preserves local output formatting, and polls merge status using the caller’s credentials.

Merge readiness

✅ Ready for maintainer review

The test correction is sound, production code is unchanged since the previous review, and no blocking defect remains. The async merge protection is still absent from the pinned main branch, so this PR remains useful.

Priority: P2
Reviewed head: 32fb0b8ed600156e2a17c80533717ed2e65d5557

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent protection repair with sound re-review corrections and no remaining actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER author is exempt from ordinary contributor proof. Supplied built-wrapper evidence exercises snapshots and rejection through a synthetic child, rather than a live merge; source tracing found no unresolved introduced authority violation requiring the scoped exception. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER author is exempt from ordinary contributor proof. Supplied built-wrapper evidence exercises snapshots and rejection through a synthetic child, rather than a live merge; source tracing found no unresolved introduced authority violation requiring the scoped exception. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: Read the complete nine-file introduced diff from the pinned main SHA to the exact PR head; changes are confined to CLI rewrite protection, tests, documentation, and changelog.
Re-review continuity: GitHub’s exact-head commit patch changes only protection_reads_test.go and string_rewrites_api_async_merge_test.go. It removes the obsolete generic template rewrite expectation and expands the formatting matrix to four endpoints with six spellings each. The parent is the previously reviewed f19e6d1.
Authority and final dispatch: Async payloads validate SHA, method, action, and Boolean bypass fields without rewriting them. Omitted SHA resolution precedes immutable snapshot creation; status reads bypass pooled identities. Generic fallback rejects both original and rewritten merge endpoints before child dispatch. Native dispatch retains the caller’s credentials; no authorization credential is persisted or transferred.
Findings None None.
Security None None.

How this fits together

Octopool pools GitHub reads while keeping writes on the caller’s local GitHub identity. Its CLI rewrite guard checks requests and snapshots publication content before invoking native GitHub CLI.

flowchart TD
 A[GitHub CLI request] --> B[Local rewrite policy]
 B --> C{Supported merge request?}
 C -->|No| D[Reject before dispatch]
 C -->|Yes| E[Validate authority and pin head]
 E --> F[Snapshot rewritten commit text]
 F --> G[Native GitHub CLI with caller credentials]
 G --> H[GitHub merge or status response]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth production +109/-21 (net +88); tests +304/-6 (net +298) Production growth implements the async guard and fallback exclusion, with focused coverage for snapshots, rejection, preflight, and formatting.
Latest revision 2 test files changed; 0 production files changed; 24 formatting cases The current correction preserves the previously reviewed runtime behavior while aligning protection-read expectations.

Technical review

Best possible solution:

Keep merge authority in the existing typed snapshot guard, preserve response formatters literally, and retain the documented upgrade contract.

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

Yes, from source: pinned main lacks an async merge schema, allowing those requests into generic rewriting. No runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes. Extending the existing immutable merge snapshot owner avoids a parallel implementation, and the latest test correction matches native response-formatting semantics.

AGENTS.md: not found in the target repository.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded repair to protected CLI merge behavior; pending checks do not raise its priority.
  • merge-risk: 🚨 compatibility: Unsupported protected merge requests now fail before dispatch; the MEMBER author explicitly accepts this restriction and documents the supported request and upgrade path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER author is exempt from ordinary contributor proof. Supplied built-wrapper evidence exercises snapshots and rejection through a synthetic child, rather than a live merge; source tracing found no unresolved introduced authority violation requiring the scoped exception. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: Read the complete nine-file introduced diff from the pinned main SHA to the exact PR head; changes are confined to CLI rewrite protection, tests, documentation, and changelog. (32fb0b8ed600)
  • Re-review continuity: GitHub’s exact-head commit patch changes only protection_reads_test.go and string_rewrites_api_async_merge_test.go. It removes the obsolete generic template rewrite expectation and expands the formatting matrix to four endpoints with six spellings each. The parent is the previously reviewed f19e6d1. (cmd/octopool/string_rewrites_api_async_merge_test.go:17, 32fb0b8ed600)
  • Authority and final dispatch: Async payloads validate SHA, method, action, and Boolean bypass fields without rewriting them. Omitted SHA resolution precedes immutable snapshot creation; status reads bypass pooled identities. Generic fallback rejects both original and rewritten merge endpoints before child dispatch. Native dispatch retains the caller’s credentials; no authorization credential is persisted or transferred. (cmd/octopool/string_rewrites_api.go:317, 32fb0b8ed600)
  • Recorded compatibility choice: The MEMBER-authored captured PR body explicitly chooses preserved local template formatting and deliberate rejection of cache, pagination, and raw-body headers. docs/cli.md documents the modeled request alternative and marker-first CLI upgrade path. This covers the current unchanged production diff, so the accepted restriction is retained as compatibility context rather than reopened as a blocker. (docs/cli.md:1340, 32fb0b8ed600)
  • Still necessary on main: The pinned main implementation models synchronous pull merges only and lacks the async schema and merge-family fallback guard. The latest GitHub release remains v0.9.5, published 2026-10-04. No verified merged replacement was established. (cmd/octopool/string_rewrites_api.go:389, 005feef519da)
  • Native formatting dependency: The target forwards preserved formatter arguments to native gh in snapshotRewriteAPI, establishing an affirmative dependency on GitHub CLI semantics. The official gh api manual describes template and jq as response formatting, while cache and pagination affect request handling.

Likely related people:

  • steipete: 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-10-06T12:09:59.795Z sha f90f415 :: blocked before merge. :: none
  • reviewed 2026-10-06T12:21:12.535Z sha f19e6d1 :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head f19e6d123dd2297fd9a5cd1e57adcec720e010fd. The requested compatibility correction now preserves native --template/-t output formatting inside the typed merge guard. Request-affecting flags remain explicitly refused; the PR body records the contract and upgrade path. Focused API/shim tests passed (6.745s), the broader rewrite/protected-read/shim suite passed (88.509s), and independent review found no P0/P1 issues.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head 32fb0b8ed600156e2a17c80533717ed2e65d5557 changes tests only after your ready verdict on f19e6d1. Windows CI exposed the obsolete expectation that --template used generic rewriting. The correction removes that outdated case and extends the unchanged-formatting matrix to protection/rulesets GET. Original failure reproduced; focused protection/API/built-wrapper tests pass (11.883s), and independent read-only review confirms coverage. Production code is unchanged since your ready verdict.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit c75889d into main Oct 6, 2026
10 checks passed
@vincentkoc
vincentkoc deleted the fix/async-merge-structural-guard-20261006 branch October 6, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. 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