Skip to content

ci: resolve fork PRs missing Castiron run associations - #180

Merged
saioai merged 1 commit into
mainfrom
codex/fix-castiron-pr-association
Sep 11, 2026
Merged

ci: resolve fork PRs missing Castiron run associations#180
saioai merged 1 commit into
mainfrom
codex/fix-castiron-pr-association

Conversation

@marcuswood-oai

Copy link
Copy Markdown
Contributor

Summary

When GitHub omits a fork PR from both the workflow-run association and the base repository's commit-to-PR endpoint, Castiron cannot resolve the PR and leaves the required budget statuses missing.

Port the focused fix from openai/openai-python#3831: fall back to listing open PRs by the source run's fork owner and branch, then retain the existing exact-head, target, freshness, and ambiguity checks. Cover report computation, budget evaluation, and publication; update the reporter integrity digest.

Validation

  • Both evaluator and status-publisher regressions reproduce on unpatched main.
  • Castiron reporter/budget suite: 53 tests, OK (1 optional compiler-contract test skipped), including JavaScript publishers, pagination, stale heads, wrong targets, and ambiguous matches.
  • Ruff and Pyright for scripts/castiron; git diff --check.
  • Patched lookup verified against fix(output): stop pagination at max items #43 with read-only GitHub requests.

The trusted handler runs from main. After merging, rerun affected Castiron custom-code workflows so the required statuses can be published.

@marcuswood-oai
marcuswood-oai requested a review from a team as a code owner September 9, 2026 23:44
Copilot AI lite review requested due to automatic review settings September 9, 2026 23:44
@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-09T23:46:06.663503Z 8e09c6a PR opened
🔒 Security Review Completed 2026-09-09T23:49:39.220932Z 8e09c6a PR opened
ℹ️ 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Castiron custom code

✅ No new custom-code files detected.

5 mixed files remain; 2 existing customizations changed.

Compared 9b6774cbdfb38e09c6af154b. Generated baselines verified.

File Result Current custom patch
scripts/castiron/custom_code_report.py Existing customization changed +142 / −31
scripts/castiron/test_custom_code_report.py Existing customization changed +341 / −31
3 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/cmd.go
  • scripts/castiron/README.md

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 34418241438 --repo openai/openai-cli \
  --name castiron-custom-code-34418241438-1 --dir /tmp/castiron-custom-code-34418241438-1
git apply --stat /tmp/castiron-custom-code-34418241438-1/custom-code.patch
cat /tmp/castiron-custom-code-34418241438-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 9b6774cbdfb3e713abb5aa2203315f9458f5ef6b 8e09c6af154bf768c4d195407cd5124349827edb
python3 scripts/castiron/custom_code_report.py report \
  --base 9b6774cbdfb3e713abb5aa2203315f9458f5ef6b \
  --head 8e09c6af154bf768c4d195407cd5124349827edb --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-8e09c6af154b
cat /tmp/castiron-custom-code-8e09c6af154b/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

Copilot AI 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.

🟢 Approval recommended

The fallback association logic is narrowly scoped, preserves existing validation checks, and is covered by targeted regression tests across report, budget, and publishing paths.

Pull request overview

This PR updates Castiron’s custom-code reporter/budget evaluation to reliably resolve fork pull requests when GitHub omits both the workflow-run PR association and the commit-to-PR association, by falling back to listing open PRs for the fork owner+branch and then applying the existing head/target/freshness/ambiguity validation.

Changes:

  • Add a shared associated_pulls() helper that falls back to pulls.list (state=open, head=owner:branch) when both association endpoints return empty.
  • Wire the new association logic into report publication and budget evaluation paths.
  • Extend unit coverage for fork fallback behavior and update the reporter integrity digest in the workflow.
File summaries
File Description
scripts/castiron/custom_code_report.py Introduces associated_pulls() and uses it for trusted report computation and comment publication.
scripts/castiron/custom_code_budget.py Uses report.associated_pulls() for PR-run association resolution during budget evaluation.
scripts/castiron/test_custom_code_report.py Adds fork-missing-association cases and pagination coverage for the fallback PR listing.
scripts/castiron/test_custom_code_budget.py Adds fork scenarios for status publication when commit association is missing.
.github/workflows/castiron-custom-code.yml Updates REPORTER_SHA256 to match the modified reporter script.
.github/workflows/castiron-custom-code-comment.yml Adds the same fork fallback (pulls.list by head) to the trusted status/comment publisher workflow logic.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@saioai saioai 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.

This makes sense. It fixes the missing PR link we saw on #181 and still checks the exact commit before posting results. Looks good to me.

@saioai
saioai added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit 225dacc Sep 11, 2026
15 checks passed
@saioai
saioai deleted the codex/fix-castiron-pr-association branch September 11, 2026 23:55
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.

3 participants