Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/codex/prompts/run-pr-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ instructions.

Complete the repository's authorized Run PR work locally:

1. Verify `HEAD` equals `pull_request.head_sha` from the context.
1. Verify the exact recorded PR head is an ancestor of `HEAD`. A trusted clean
merge can already have advanced the local starting commit without publication.
2. Inspect the bounded failed-check evidence and unresolved review threads.
3. The trusted workflow has already completed a normal merge of the exact
recorded base when the branch was behind. If that merge was not clean, the
workflow stopped before invoking you. Do not fetch, merge another ref, or
alter Git metadata.
recorded base when the branch was behind. In an authorized batch, a conflicting
merge can instead be pending with read-only Git metadata. Resolve only
evidence-backed working-file conflicts, preserving both changes' intent. The
trusted seal stages the result and creates the merge commit. Outside a batch,
conflicts still stop before invoking you. Do not fetch, merge another ref, or
alter Git metadata. If intent is ambiguous, report blocked.
4. Fix only evidenced failures and actionable review findings. Preserve
unrelated work and add focused tests when behavior changes.
5. Run the smallest relevant checks and `npm run format` before finishing.
Consult the arbiter for expensive gates and the browser planner for UI work.
Do not stack broad suites or reproduce successful CI proof. Never wait for CI,
contact live clinical providers, or trigger another repair agent.
6. Do not modify `.github/**`, credentials, environment files, repository
administration, deployments, production data, or live OpenAI/Supabase
provider behavior. Leave workflow/security-policy repairs for a normal
Expand All @@ -42,6 +49,8 @@ schema:

- `summary`: concise description of the work and verification.
- `checks`: exact commands and outcomes.
- `progress_outcome`: `progress`, `blocked`, or `no_change`. A blocked result must
not publish speculative edits or unresolved conflict markers.
- `thread_dispositions`: only thread IDs present in the context. Use
`resolve_fixed`, `resolve_no_change`, or `leave_open`, with a concise reply.
- `rerun_failed_run_ids`: only failed run IDs present in the context, and only
Expand Down
6 changes: 5 additions & 1 deletion .github/codex/run-pr-result.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"required": ["summary", "checks", "thread_dispositions", "rerun_failed_run_ids"],
"required": ["summary", "checks", "progress_outcome", "thread_dispositions", "rerun_failed_run_ids"],
"properties": {
"progress_outcome": {
"type": "string",
"enum": ["progress", "blocked", "no_change"]
},
"summary": {
"type": "string",
"minLength": 1,
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/codex-autofix-review-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ jobs:
permissions:
contents: read
concurrency:
group: codex-autoresolve-${{ github.event.pull_request.number }}
group: pr-batch-mutation
cancel-in-progress: false
queue: max
env:
# Assigned to job env so a step-level `if` can detect an unconfigured
# secret and skip gracefully instead of hard-failing the check.
Expand All @@ -41,13 +42,28 @@ jobs:
- name: Ask Codex to resolve review comments
if: ${{ env.CODEX_TRIGGER_TOKEN != '' }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
BATCH_READ_TOKEN: ${{ github.token }}
with:
# A fine-grained PAT from a real (non-bot) account. The Codex connector
# ignores @codex commands authored by github-actions[bot], so the
# request must be posted by a user identity for Codex to act on it.
github-token: ${{ secrets.CODEX_TRIGGER_TOKEN }}
script: |
const pr = context.payload.pull_request;
// Same reservation contract as the batch operator: queued, active and
// parked members remain owned until the batch completes.
try {
const stored = await github.rest.repos.getContent({ ...context.repo, path: 'state.json', ref: 'codex/pr-batch-state', headers: { authorization: `Bearer ${process.env.BATCH_READ_TOKEN}` } });
const state = JSON.parse(Buffer.from(stored.data.content, 'base64').toString('utf8'));
if (state.version !== 1 || !Array.isArray(state.entries)) throw new Error('Invalid batch state');
if (['running', 'paused'].includes(state.status) && state.entries.some((entry) => entry.number === pr.number && !['merged', 'excluded'].includes(entry.state))) {
core.notice('PR is reserved by the batch runner; yielding automatic repair.');
return;
}
} catch (error) {
if (error.status !== 404) throw error;
}
const review = context.payload.review;
const allowedCodexBotLogins = new Set([
"chatgpt-codex-connector",
Expand Down Expand Up @@ -352,19 +368,30 @@ jobs:
permissions:
contents: read
pull-requests: write
# Each reply resolves a distinct thread, so key concurrency per comment —
# a per-PR group would cap at one running + one pending and drop resolutions
# during a burst of disposition replies.
# Queue every resolution while serializing ownership checks with the batch.
# queue:max avoids replacing a pending resolution during a comment burst.
concurrency:
group: codex-autoresolve-thread-${{ github.event.pull_request.number }}-${{ github.event.comment.id }}
group: pr-batch-mutation
cancel-in-progress: false
queue: max
steps:
- name: Resolve Codex review thread on disposition marker
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ github.token }}
script: |
const pr = context.payload.pull_request;
try {
const stored = await github.rest.repos.getContent({ ...context.repo, path: 'state.json', ref: 'codex/pr-batch-state' });
const state = JSON.parse(Buffer.from(stored.data.content, 'base64').toString('utf8'));
if (state.version !== 1 || !Array.isArray(state.entries)) throw new Error('Invalid batch state');
if (['running', 'paused'].includes(state.status) && state.entries.some((entry) => entry.number === pr.number && !['merged', 'excluded'].includes(entry.state))) {
core.notice('PR is reserved by the batch runner; yielding thread resolution.');
return;
}
} catch (error) {
if (error.status !== 404) throw error;
}
const reviewComment = context.payload.comment;
const allowedCodexBotLogins = new Set([
"chatgpt-codex-connector",
Expand Down
Loading
Loading