Skip to content

feat(pr): add resumable sequential merge batches - #2761

Open
BigSimmo wants to merge 1 commit into
mainfrom
codex/chat-pr-batch-runner-1076
Open

feat(pr): add resumable sequential merge batches#2761
BigSimmo wants to merge 1 commit into
mainfrom
codex/chat-pr-batch-runner-1076

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a disabled-by-default sequential PR batch runner with a fixed snapshot, JSON state branch, event-driven reconciliation, bounded isolated repairs, and protected merge requests tied to the verified head.
  • Coordinate the existing PR operator and review auto-fix through shared ownership. Journal publication, replies, resolutions, and reruns so recovery does not blindly repeat external writes.
  • Add the Clear PRs repository shortcut and activation guide. Preserve migration, clinical/RAG, provider, and controller-policy exclusions.

Verification

Prior implementation checks (not repeated for this publication):

  • npm run test -- tests/pr-batch-runner.test.ts tests/pr-batch-github.test.ts tests/codex-run-pr-operator-workflow.test.ts tests/codex-autofix-workflow.test.ts — 124 tests passed.
  • npm run typecheck — passed.
  • Managed lint:changed:internal on changed scripts and tests with --max-warnings 0 — passed.
  • npm run check:github-actions and npm run check:codex-autofix-workflow — passed.
  • node scripts/update-docs-inventory.mjs --check and git diff --check — passed.
  • Verification not run: the full verify:pr-local suite; focused controller/operator tests and workflow guards cover the changed contracts. Hosted checks remain authoritative before merge.
  • UI verification not run: no application UI changes. Release, live-provider, and retrieval evaluations were not run; this PR does not change those behaviors.

Risk and rollout

  • Risk: automation publishes feature branches and requests production-triggering merges when separately activated. Offline tests do not establish live GitHub integration correctness.
  • Rollback: keep PR_BATCH_ENABLED absent/false or pause a batch. Pausing does not revoke an already-issued merge request; never silently disable user-owned auto-merge.
  • Provider or production effects: the new batch controller ships disabled. Existing operator/auto-fix ownership checks change on installation. Subsequent activation authorizes bounded repair API costs, GitHub writes, and resulting Railway deployments; no Supabase migrations are included.
  • RAG impact: none.
  • Rollout: publication only in this task. Merge, activation, and the initial pilot await the owner's later instruction. Existing armed PRs must settle before batch launch.

Clinical Governance Preflight

Not applicable to application behavior: no ingestion, clinical output, document access, privacy, source rendering, or production environment configuration changes. The batch eligibility checks preserve existing governance and migration restrictions.

Notes

  • Authorization reference: codex://threads/01a085a9-110d-7da2-be3c-12b16e2cf3ad.
  • Implementation is excluded from its own automatic merge batch because it changes controller and workflow policy.
  • Publication uses the repository's bare-PR route. The whole-repository format pass was interrupted when scope changed to publication only; changed-file formatting had already passed. No additional local checks or hosted CI observation are performed for publication.

Note

High Risk
Introduces automation that can dispatch repairs, push feature branches, and request protected merges plus downstream Railway deploys once PR_BATCH_ENABLED is set; coordination changes affect existing Run PR and auto-resolve behavior even when the batch runner stays off.

Overview
Adds a disabled-by-default sequential PR batch runner that snapshots eligible open PRs, journals state on codex/pr-batch-state, and processes them one at a time with bounded Codex repairs, branch sync, and protected gh pr merge --auto handoffs. New scripts/pr-batch-* modules implement eligibility (protected paths, RAG canary evidence, dependencies), durable mutations with per-effect receipts, and workflow policy guards wired into check-github-action-pins.

Integrates the existing Codex Run PR operator for batch repairs: optional batch_id/batch_operation, ownership claims via pr-batch-worker.mjs, pending base merges with working-tree conflict resolution (sealed against OPERATOR_COMPARE_TREE), required progress_outcome on repair results, and journaled publish/reply/rerun steps when batch_id is set. Standalone operator and Codex auto-fix now share pr-batch-mutation concurrency and yield when a PR is batch-reserved.

Documents the Clear PRs agent shortcut and activation in AGENTS.md, pull-request-workflow.md, and docs/pr-batch-runner.md; extends operator prompt/schema and artifact retention (7 days); ignores .codex-run-pr/ in Prettier.

Reviewed by Cursor Bugbot for commit 49bcab6. Configure here.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: efc2112f-e0fe-45bc-8813-0b6ee51d63d6


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Sep 9, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 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-09-09T14:11:20.787595Z 49bcab6 Manual request
ℹ️ 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.

@cursor

cursor Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_abeb2a10-ee34-4ebc-9302-3ac53a8102d3)

@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: 49bcab61f3

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

concurrency:
group: pr-batch-mutation
cancel-in-progress: false
queue: max

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the unsupported concurrency queue key

GitHub Actions concurrency mappings support group and cancel-in-progress, but not queue; adding queue: max makes this workflow invalid before any job can run. The same key was also added to the Codex operator and auto-resolve workflows, so enabling this change prevents both the new batch runner and existing repair automation from loading.

Useful? React with 👍 / 👎.

Comment thread scripts/pr-batch-core.mjs
Comment on lines +34 to +36
if (
!/^(?!\/)(?!.*\.\.)(?!.*@\{)[A-Za-z0-9._/-]+$/.test(pr.headRef) ||
/^(?:main|master|develop|release(?:\/|$))/.test(pr.headRef) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Protect auth directories, not only auth filenames

The sensitive-name expression only examines the final path component, so the existing src/app/auth/callback/route.ts returns false from protectedPath; with a policy-compliant PR body, eligibility consequently returns no exclusion. A change to this authentication callback can therefore be repaired and merged automatically despite the documented exclusion for authorization/security changes; test every path segment or explicitly cover auth/security directories.

Useful? React with 👍 / 👎.

Comment on lines +77 to +83
const tree = (await this.gh.rest.git.getTree({ ...this.repo, tree_sha: commit.tree.sha, recursive: "1" })).data;
if (tree.truncated || tree.tree.some((item) => item.type === "blob" && !item.path.endsWith(".json")))
throw new Error("Unsafe state branch tree");
const entry = tree.tree.find((item) => item.path === "state.json" && item.type === "blob");
if (!entry) throw new Error("Missing state.json on existing state branch");
const blob = (await this.gh.rest.git.getBlob({ ...this.repo, file_sha: entry.sha })).data;
const state = validateState(JSON.parse(Buffer.from(blob.content, "base64").toString("utf8")));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Authenticate batch state before executing mutations

If any repository writer updates the otherwise unprotected codex/pr-batch-state branch, load() trusts a forged state.json after checking only its structure and a self-computable manifest digest. A scheduled wake can then use the stored GH_TOKEN and OPENAI_API_KEY to repair or merge the attacker's selected eligible PR without the owner ever issuing the required Clear PRs authorization; the state needs provenance that ordinary writers cannot forge, such as a protected state store or authenticated signature.

AGENTS.md reference: AGENTS.md:L280-L285

Useful? React with 👍 / 👎.

@BigSimmo

BigSimmo commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. The only repository destination is BigSimmo/Database, and the only branch destination is the pull request head branch codex/chat-pr-batch-runner-1076 at starting commit 49bcab6; never publish fixes to a detached or synthetic work branch and never create a stacked pull request. Use the authenticated GitHub connector to commit each approved fix to BigSimmo/Database:codex/chat-pr-batch-runner-1076, then verify that the pull request head contains the published commit before reporting success. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. For a fixed thread, reply with as the first line and as the second line. For a no-code disposition, use followed by . These result markers authorize the workflow to close that exact thread only after it verifies a fixed commit is the pull request head; a local-only commit is not a fix. If publication or verification fails, do not use either result marker, do not claim success, and leave the thread open with the blocker. If human input or new authorization is required, do the same. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 49bcab61f3

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

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 3 failed job(s):

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • Static PR checksneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #16436 (failure).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

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