Skip to content

Commit eecca4f

Browse files
author
Lee Penkman
committed
Merge commit 'a34da3b2'
2 parents 49bca09 + a34da3b commit eecca4f

1,729 files changed

Lines changed: 133929 additions & 20077 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelrc

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,50 @@ common:windows --test_env=WINDIR
3838
common --test_env=RUST_MIN_STACK=8388608 # 8 MiB
3939

4040
common --test_output=errors
41-
common --bes_results_url=https://app.buildbuddy.io/invocation/
42-
common --bes_backend=grpcs://remote.buildbuddy.io
43-
common --remote_cache=grpcs://remote.buildbuddy.io
44-
common --remote_download_toplevel
4541
common --nobuild_runfile_links
42+
# These settings tune BuildBuddy/RBE behavior but do not contact a remote
43+
# service unless a `buildbuddy-*` configuration below supplies an endpoint.
44+
common --remote_download_toplevel
4645
common --remote_timeout=3600
4746
common --noexperimental_throttle_remote_action_building
4847
common --experimental_remote_execution_keepalive
4948
common --grpc_keepalive_time=30s
50-
common --experimental_remote_downloader=grpcs://remote.buildbuddy.io
49+
50+
# Opt-in remote configurations selected by
51+
# `.github/scripts/run_bazel_with_buildbuddy.py`. Plain Bazel commands do not
52+
# contact BuildBuddy unless a user selects one of these configurations.
53+
# Use the generic host for cache, BES, and downloads without remote execution.
54+
common:buildbuddy-generic --bes_backend=grpcs://remote.buildbuddy.io
55+
common:buildbuddy-generic --bes_results_url=https://app.buildbuddy.io/invocation/
56+
common:buildbuddy-generic --remote_cache=grpcs://remote.buildbuddy.io
57+
common:buildbuddy-generic --experimental_remote_downloader=grpcs://remote.buildbuddy.io
58+
59+
# Add remote execution on the generic host.
60+
common:buildbuddy-generic-rbe --config=buildbuddy-generic
61+
common:buildbuddy-generic-rbe --config=remote
62+
common:buildbuddy-generic-rbe --remote_executor=grpcs://remote.buildbuddy.io
63+
64+
# Use the OpenAI tenant for cache, BES, and downloads without remote execution.
65+
common:buildbuddy-openai --bes_backend=grpcs://openai.buildbuddy.io
66+
common:buildbuddy-openai --bes_results_url=https://openai.buildbuddy.io/invocation/
67+
common:buildbuddy-openai --remote_cache=grpcs://openai.buildbuddy.io
68+
common:buildbuddy-openai --experimental_remote_downloader=grpcs://openai.buildbuddy.io
69+
70+
# Add remote execution on the OpenAI tenant.
71+
common:buildbuddy-openai-rbe --config=buildbuddy-openai
72+
common:buildbuddy-openai-rbe --config=remote
73+
common:buildbuddy-openai-rbe --remote_executor=grpcs://openai.buildbuddy.io
5174

5275
# This limits both in-flight executions and concurrent downloads. Even with high number
5376
# of jobs execution will still be limited by CPU cores, so this just pays a bit of
5477
# memory in exchange for higher download concurrency.
5578
common --jobs=30
5679

80+
# Shared remote execution policy. The endpoint-bearing `buildbuddy-*-rbe`
81+
# configurations include this group; CI configs override TestRunner below
82+
# when tests must remain local on their runner.
83+
common:remote --strategy=remote
5784
common:remote --extra_execution_platforms=//:rbe
58-
common:remote --remote_executor=grpcs://remote.buildbuddy.io
5985
common:remote --jobs=800
6086
# TODO(team): Evaluate if this actually helps, zbarsky is not sure, everything seems bottlenecked on `core` either way.
6187
# Enable pipelined compilation since we are not bound by local CPU count.
@@ -142,23 +168,17 @@ common:ci-windows --repo_contents_cache=D:/a/.cache/bazel-repo-contents-cache
142168
# Linux crossbuilds don't work until we untangle the libc constraint mess.
143169
common:ci-linux --config=ci-bazel
144170
common:ci-linux --build_metadata=TAG_os=linux
145-
common:ci-linux --config=remote
146-
common:ci-linux --strategy=remote
147171
common:ci-linux --platforms=//:rbe
148172

149173
# On mac, we can run all the build actions remotely but test actions locally.
150174
common:ci-macos --config=ci-bazel
151175
common:ci-macos --build_metadata=TAG_os=macos
152-
common:ci-macos --config=remote
153-
common:ci-macos --strategy=remote
154176
common:ci-macos --strategy=TestRunner=darwin-sandbox,local
155177

156178
# Linux-only V8 CI config.
157179
common:ci-v8 --config=ci
158180
common:ci-v8 --build_metadata=TAG_workflow=v8
159181
common:ci-v8 --build_metadata=TAG_os=linux
160-
common:ci-v8 --config=remote
161-
common:ci-v8 --strategy=remote
162182

163183
# Optional per-user local overrides.
164184
try-import %workspace%/user.bazelrc

.codex/environments/setup.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
3+
"""Set up ignored files that should be shared with Codex worktrees."""
4+
5+
import shutil
6+
import subprocess
7+
from functools import cache
8+
from pathlib import Path
9+
10+
11+
@cache
12+
def worktree_paths() -> tuple[Path, Path]:
13+
script_dir = Path(__file__).resolve().parent
14+
worktree_root = git_path(script_dir / "../..", "--show-toplevel")
15+
common_git_dir = git_path(worktree_root, "--git-common-dir")
16+
return worktree_root, common_git_dir.parent
17+
18+
19+
def git_path(working_directory: Path, argument: str) -> Path:
20+
output = subprocess.check_output(
21+
[
22+
"git",
23+
"-C",
24+
str(working_directory),
25+
"rev-parse",
26+
"--path-format=absolute",
27+
argument,
28+
],
29+
text=True,
30+
)
31+
return Path(output.strip())
32+
33+
34+
def copy_from_main_worktree_to_worktree(repo_relative_path: str) -> None:
35+
relative_path = Path(repo_relative_path)
36+
if relative_path.is_absolute() or ".." in relative_path.parts:
37+
raise ValueError(f"path must be repository-relative: {repo_relative_path}")
38+
39+
worktree_root, main_worktree = worktree_paths()
40+
source_path = main_worktree / relative_path
41+
destination_path = worktree_root / relative_path
42+
43+
print(f" source: {source_path}")
44+
print(f" destination: {destination_path}")
45+
46+
if source_path == destination_path:
47+
print(" result: running in the main worktree; nothing to copy")
48+
elif destination_path.exists():
49+
print(" result: destination already exists; nothing to copy")
50+
elif not source_path.is_file():
51+
print(" result: source does not exist; nothing to copy")
52+
else:
53+
destination_path.parent.mkdir(parents=True, exist_ok=True)
54+
shutil.copy2(source_path, destination_path)
55+
print(f" result: copied {repo_relative_path}")
56+
57+
58+
def main() -> None:
59+
print("Codex environment setup:")
60+
# See codex-rs/docs/bazel.md for the repository's Bazel workflow.
61+
copy_from_main_worktree_to_worktree("user.bazelrc")
62+
63+
64+
if __name__ == "__main__":
65+
main()

.codex/skills/babysit-pr/SKILL.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,51 @@ The watcher surfaces review items from:
8686
- Inline review comments
8787
- Review submissions (COMMENT / APPROVED / CHANGES_REQUESTED)
8888

89+
Only act on published feedback. Ignore review submissions in GitHub's `PENDING` state and inline
90+
comments attached to those pending reviews. Do not mark pending review feedback as seen; it should
91+
be eligible to surface after the reviewer submits the review.
92+
8993
It intentionally surfaces Codex reviewer bot feedback (for example comments/reviews from `chatgpt-codex-connector[bot]`) in addition to human reviewer feedback. Most unrelated bot noise should still be ignored.
9094
For safety, the watcher only auto-surfaces trusted human review authors (for example repo OWNER/MEMBER/COLLABORATOR, plus the authenticated operator) and approved review bots such as Codex.
91-
On a fresh watcher state file, existing pending review feedback may be surfaced immediately (not only comments that arrive after monitoring starts). This is intentional so already-open review comments are not missed.
95+
On a fresh watcher state file, existing unaddressed published review feedback may be surfaced immediately (not only comments that arrive after monitoring starts). This is intentional so already-open review comments are not missed.
9296

9397
When you agree with a comment and it is actionable:
9498

9599
1. Patch code locally.
96100
2. Commit with `codex: address PR review feedback (#<n>)`.
97101
3. Push to the PR head branch.
98-
4. After the push succeeds, mark the associated GitHub review thread/comment as resolved.
102+
4. After the push succeeds, resolve the associated GitHub review thread only when allowed by the GitHub state mutation policy below.
99103
5. Resume watching on the new SHA immediately (do not stop after reporting the push).
100104
6. If monitoring was running in `--watch` mode, restart `--watch` immediately after the push in the same turn; do not wait for the user to ask again.
101105

102106
If you disagree or the comment is non-actionable/already addressed, reply once directly on the GitHub comment/thread so the reviewer gets an explicit answer, then continue the watcher loop. Prefix any GitHub reply to a code review comment/thread with `[codex]` so it is clear the response is automated and not from the human user. If the watcher later surfaces your own reply because the authenticated operator is treated as a trusted review author, treat that self-authored item as already handled and do not reply again.
103107
If a code review comment/thread is already marked as resolved in GitHub, treat it as non-actionable and safely ignore it unless new unresolved follow-up feedback appears.
104108

109+
## GitHub State Mutation Policy
110+
111+
You can read any PR state you need for monitoring. Writes must comply with this policy.
112+
113+
You can push PRs to update the code under review or to force CI re-runs as described above.
114+
115+
You can resolve review comment threads from the human who requested babysitting or from the Codex
116+
review bot. When resolving, leave a comment prefixed with `[from Codex]: ` and explain what changes
117+
you made and which commit includes them. Don't touch review threads if other humans other than the
118+
user who requested babysitting have participated.
119+
120+
Before making any changes, fetch the PR state yourself instead of relying on the PR watcher script's
121+
output.
122+
123+
Unless explicitly asked, do not:
124+
125+
* comment on other humans' review threads, communicate with the user in chat instead
126+
* resolve review threads from humans other than the user
127+
* interact with humans other than the user
128+
* mark PRs as drafts or ready for review
129+
* close or reopen PRs
130+
131+
In general, never act on GitHub in ways that would make it hard to tell whether you or the user did
132+
something visible to other humans. When in doubt, ask the user for clarification in chat.
133+
105134
## Git Safety Rules
106135

107136
- Work only on the PR head branch.

.codex/skills/babysit-pr/references/github-api-notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Reruns only failed jobs (and dependencies) for a workflow run.
4242
- Review submissions:
4343
- `gh api repos/{owner}/{repo}/pulls/<pr_number>/reviews?per_page=100`
4444

45+
Use each inline comment's `pull_request_review_id` to find its parent review. Ignore parent reviews
46+
whose `state` is `PENDING`, along with their inline comments, until the review is submitted.
47+
4548
## JSON fields consumed by the watcher
4649

4750
### `gh pr view`

.codex/skills/babysit-pr/scripts/gh_pr_watch.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,14 @@ def normalize_issue_comments(items):
392392
return out
393393

394394

395-
def normalize_review_comments(items):
395+
def normalize_review_comments(items, review_states):
396396
out = []
397397
for item in items:
398398
if not isinstance(item, dict):
399399
continue
400+
review_id = str(item.get("pull_request_review_id") or "")
401+
if review_states.get(review_id) == "PENDING":
402+
continue
400403
line = item.get("line")
401404
if line is None:
402405
line = item.get("original_line")
@@ -421,6 +424,8 @@ def normalize_reviews(items):
421424
for item in items:
422425
if not isinstance(item, dict):
423426
continue
427+
if str(item.get("state") or "").upper() == "PENDING":
428+
continue
424429
out.append(
425430
{
426431
"kind": "review",
@@ -474,16 +479,33 @@ def fetch_new_review_items(pr, state, fresh_state, authenticated_login=None):
474479
review_payload = gh_api_list_paginated(endpoints["review"], repo=repo)
475480

476481
issue_items = normalize_issue_comments(issue_payload)
477-
review_comment_items = normalize_review_comments(review_comment_payload)
482+
review_states = {
483+
str(item.get("id")): str(item.get("state") or "").upper()
484+
for item in review_payload
485+
if isinstance(item, dict) and item.get("id") not in (None, "")
486+
}
487+
pending_review_ids = {
488+
review_id for review_id, review_state in review_states.items() if review_state == "PENDING"
489+
}
490+
pending_review_comment_ids = {
491+
str(item.get("id"))
492+
for item in review_comment_payload
493+
if isinstance(item, dict)
494+
and item.get("id") not in (None, "")
495+
and str(item.get("pull_request_review_id") or "") in pending_review_ids
496+
}
497+
review_comment_items = normalize_review_comments(review_comment_payload, review_states)
478498
review_items = normalize_reviews(review_payload)
479499
all_items = issue_items + review_comment_items + review_items
480500

481501
seen_issue = {str(x) for x in state.get("seen_issue_comment_ids") or []}
482502
seen_review_comment = {str(x) for x in state.get("seen_review_comment_ids") or []}
483503
seen_review = {str(x) for x in state.get("seen_review_ids") or []}
504+
seen_review_comment.difference_update(pending_review_comment_ids)
505+
seen_review.difference_update(pending_review_ids)
484506

485507
# On a brand-new state file, surface existing review activity instead of
486-
# silently treating it as seen. This avoids missing already-pending review
508+
# silently treating it as seen. This avoids missing already-published review
487509
# feedback when monitoring starts after comments were posted.
488510

489511
new_items = []

.codex/skills/babysit-pr/scripts/test_gh_pr_watch.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,74 @@ def test_recommend_actions_prioritizes_review_comments():
112112
]
113113

114114

115+
def test_pending_review_feedback_surfaces_only_after_publication(monkeypatch):
116+
state = {
117+
"seen_review_comment_ids": ["20"],
118+
"seen_review_ids": ["10"],
119+
}
120+
review = {
121+
"id": 10,
122+
"user": {"login": "octocat"},
123+
"author_association": "MEMBER",
124+
"state": "PENDING",
125+
"body": "Please rename this.",
126+
"created_at": "2026-06-08T10:00:00Z",
127+
"submitted_at": None,
128+
"html_url": "https://github.com/openai/codex/pull/123#pullrequestreview-10",
129+
}
130+
review_comment = {
131+
"id": 20,
132+
"pull_request_review_id": 10,
133+
"user": {"login": "octocat"},
134+
"author_association": "MEMBER",
135+
"body": "Please rename this.",
136+
"created_at": "2026-06-08T10:00:00Z",
137+
"path": "src/example.rs",
138+
"line": 7,
139+
"html_url": "https://github.com/openai/codex/pull/123#discussion_r20",
140+
}
141+
142+
def fake_list(endpoint, **kwargs):
143+
if endpoint.endswith("/issues/123/comments"):
144+
return []
145+
if endpoint.endswith("/pulls/123/comments"):
146+
return [review_comment]
147+
if endpoint.endswith("/pulls/123/reviews"):
148+
return [review]
149+
raise AssertionError(f"unexpected endpoint: {endpoint}")
150+
151+
monkeypatch.setattr(gh_pr_watch, "gh_api_list_paginated", fake_list)
152+
153+
assert (
154+
gh_pr_watch.fetch_new_review_items(
155+
sample_pr(),
156+
state,
157+
fresh_state=True,
158+
authenticated_login="octocat",
159+
)
160+
== []
161+
)
162+
assert state["seen_review_comment_ids"] == []
163+
assert state["seen_review_ids"] == []
164+
165+
review["state"] = "COMMENTED"
166+
review["submitted_at"] = "2026-06-08T10:05:00Z"
167+
168+
published_items = gh_pr_watch.fetch_new_review_items(
169+
sample_pr(),
170+
state,
171+
fresh_state=False,
172+
authenticated_login="octocat",
173+
)
174+
175+
assert {(item["kind"], item["id"]) for item in published_items} == {
176+
("review", "10"),
177+
("review_comment", "20"),
178+
}
179+
assert state["seen_review_comment_ids"] == ["20"]
180+
assert state["seen_review_ids"] == ["10"]
181+
182+
115183
def test_run_watch_keeps_polling_open_ready_to_merge_pr(monkeypatch):
116184
sleeps = []
117185
events = []

.codex/skills/codex-pr-body/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Limit discussion to the _net change_ of the commit. It is generally frowned upon
1919

2020
Avoid references to absolute paths on my local disk. When talking about a path that is within the repository, simply use the repo-relative path.
2121

22+
Avoid references to confidential information including but not limited to codenames or OpenAI-internal URLs.
23+
2224
It is generally helpful to discuss how the change was verified. That said, it is unnecessary to mention things that CI checks automatically, e.g., do not include "ran `just fmt`" as part of the test plan. Though identifying the new tests that were purposely introduced to verify the new behavior introduced by the pull request is often appropriate.
2325

2426
Make use of Markdown to format the pull request professionally. Ensure "code things" appear in single backticks when referenced inline. Fenced code blocks are useful when referencing code or showing a shell transcript. Also, make use of GitHub permalinks when citing existing pieces of code that are relevant to the change.

0 commit comments

Comments
 (0)