Skip to content

ci: check custom-code budgets against main's policy - #2447

Merged
apcha-oai merged 1 commit into
mainfrom
apcha/custom-code-ratchet
Aug 21, 2026
Merged

ci: check custom-code budgets against main's policy#2447
apcha-oai merged 1 commit into
mainfrom
apcha/custom-code-ratchet

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Catch accidental growth in the SDK's remaining generated-file customization before it becomes a large patch to maintain. This ports the same layout and tooling approved in Python #3714 and Python #3715, including Python's trusted report computation.

The existing workflow pair measures additions plus deletions against verified generated output, using the checker and budget from main. A PR cannot increase its own allowance; budget changes must be isolated and explicitly justified, and increases require a human approving review. Agents cannot approve or bypass increases.

Technical details live in scripts/castiron/CUSTOM_CODE.md, with references from AGENTS and CONTRIBUTING. No extra workflow files, SDK API changes, checkpoint edits, exclusion changes, or CODEOWNERS changes. Ruleset enforcement is intentionally deferred.

The integrated tooling measures +1,955 / −208 = 2,163 custom lines, below the 3,000-line ceiling. This includes the reporter changes themselves.

Stack

The budget-only foundation has merged. This tooling commit is now restacked onto main at d1410d190d04; the tooling patch is unchanged and the PR contains no budget-file change. CI is rerunning against main. The trusted statuses become active after the tooling lands, but will not be required until a separately authorized ruleset rollout.

@apcha-oai
apcha-oai requested a review from a team as a code owner August 21, 2026 16:17
@apcha-oai apcha-oai added the custom-code-burndown Behavior-preserving reductions of custom code in generated SDK files label Aug 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 21, 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-08-21T17:10:37.393834Z c87c1d9 New commits
🔒 Security Review Completed 2026-08-21T17:11:55.278793Z c87c1d9 New commits
ℹ️ 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 Aug 21, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

32 mixed files remain; 2 existing customizations changed.

Compared d1410d190d04c87c1d95dc4a. Generated baselines verified.

File Result Current custom patch
scripts/castiron/custom_code_report.py Existing customization changed +125 / −31
scripts/castiron/test_custom_code_report.py Existing customization changed +287 / −28
30 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • src/client.ts
  • src/resources/audio/transcriptions.ts
  • src/resources/audio/translations.ts
  • src/resources/beta/assistants.ts
  • src/resources/beta/beta.ts
  • src/resources/beta/index.ts
  • src/resources/beta/responses/internal-base.ts
  • src/resources/beta/responses/responses.ts
  • src/resources/beta/threads/index.ts
  • src/resources/beta/threads/runs/index.ts
  • src/resources/beta/threads/runs/runs.ts
  • src/resources/beta/threads/threads.ts
  • src/resources/chat/completions/completions.ts
  • src/resources/chat/completions/index.ts
  • src/resources/conversations/index.ts
  • src/resources/embeddings.ts
  • src/resources/files.ts
  • src/resources/fine-tuning/checkpoints/permissions.ts
  • src/resources/images.ts
  • src/resources/responses/internal-base.ts
  • src/resources/responses/responses.ts
  • src/resources/skills/skills.ts
  • src/resources/skills/versions/versions.ts
  • src/resources/vector-stores/file-batches.ts
  • src/resources/vector-stores/files.ts
  • src/resources/webhooks/index.ts
  • src/resources/webhooks/webhooks.ts
  • tests/lib/data-residency.test.ts

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 32506622536 --repo openai/openai-node \
  --name castiron-custom-code-32506622536-1 --dir /tmp/castiron-custom-code-32506622536-1
git apply --stat /tmp/castiron-custom-code-32506622536-1/custom-code.patch
cat /tmp/castiron-custom-code-32506622536-1/custom-code.patch

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

git fetch --no-tags origin d1410d190d047be6aa3969a86d043648fdf378fe c87c1d95dc4ab3355912808158425568f1f2d2d8
python3 scripts/castiron/custom_code_report.py report \
  --base d1410d190d047be6aa3969a86d043648fdf378fe \
  --head c87c1d95dc4ab3355912808158425568f1f2d2d8 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-c87c1d95dc4a
cat /tmp/castiron-custom-code-c87c1d95dc4a/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

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please address the inline P2: enforce monotonic source workflow run/attempt ordering before publishing commit statuses so older reruns cannot replace newer successful merge-gate results. Trusted policy isolation and budget calculation otherwise look sound.

const description = !fresh ? 'Evaluation unavailable or base changed; rerun against current main.'
: state === 'success' ? 'Passed against main policy. See the trusted run summary.'
: 'Budget check failed. See the trusted run summary.';
await github.rest.repos.createCommitStatus({...context.repo, sha: head, context: name,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 — Prevent older source workflows from overwriting newer commit statuses. This publisher unconditionally calls createCommitStatus for the same SHA/context without comparing the source workflow run ID and run attempt with the most recent published result. If an older source run is rerun or handlers complete out of order, its transient failure can replace a newer successful status and incorrectly block the PR or merge queue; branch-level concurrency serializes handlers but does not establish source-run freshness. Apply the same monotonic (run_id, run_attempt) guard used by the comment publisher before writing either status, and add an out-of-order/rerun regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're accepting this fail-closed availability edge case for the initial rollout and leaving the implementation unchanged.

Older source reruns recompute against current trusted inputs; they don't replay stale budget results. A later transient evaluation failure can replace green statuses with red and bounce an otherwise valid candidate, but this is recoverable by rerunning the latest workflow or requeuing. The merge queue does not prevent that false block; it remains the boundary for checking the combined candidate against current main once the budget statuses are required.

We don't think source-run ordering state is justified without evidence of recurring disruption in normal queue operation. In particular, source run ID alone is not policy freshness: an older source run can legitimately be rerun against a newer main/policy revision. This also keeps the rollout aligned with the approved Python workflow.

We'll revisit if this becomes a recurring operational problem. No code, budget, ruleset, or review-state changes are being made as part of this response.

Base automatically changed from apcha/custom-code-budget to main August 21, 2026 17:00

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at the reviewer's request.

@apcha-oai
apcha-oai force-pushed the apcha/custom-code-ratchet branch from 972b8dc to c87c1d9 Compare August 21, 2026 17:08
@openai-sdks

openai-sdks Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.406s for Node SDK PR #2447.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 163ms
tests/chat-completions-create.test.ts ✅ Passed 286ms
tests/chat-completions-stream.test.ts ✅ Passed 212ms
tests/files-content-binary.test.ts ✅ Passed 211ms
tests/files-create-multipart.test.ts ✅ Passed 205ms
tests/files-list-pagination.test.ts ✅ Passed 314ms
tests/initialize-config.test.ts ✅ Passed 153ms
tests/instance-isolation.test.ts ✅ Passed 114ms
tests/models-list.test.ts ✅ Passed 201ms
tests/responses-background-lifecycle.test.ts ✅ Passed 262ms
tests/responses-body-method-errors.test.ts ✅ Passed 350ms
tests/responses-cancel-timeout.test.ts ✅ Passed 205ms
tests/responses-cancel.test.ts ✅ Passed 216ms
tests/responses-compact-retries.test.ts ✅ Passed 241ms
tests/responses-compact.test.ts ✅ Passed 290ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 124ms
tests/responses-create-advanced.test.ts ✅ Passed 233ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.251s
tests/responses-create-errors.test.ts ✅ Passed 200ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 238ms
tests/responses-create-retries.test.ts ✅ Passed 232ms
tests/responses-create-stream-failures.test.ts ✅ Passed 297ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.217s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.652s
tests/responses-create-stream.test.ts ✅ Passed 82ms
tests/responses-create-terminal-states.test.ts ✅ Passed 261ms
tests/responses-create-timeout.test.ts ✅ Passed 204ms
tests/responses-create.test.ts ✅ Passed 280ms
tests/responses-delete.test.ts ✅ Passed 262ms
tests/responses-input-items-errors.test.ts ✅ Passed 225ms
tests/responses-input-items-list.test.ts ✅ Passed 276ms
tests/responses-input-items-options.test.ts ✅ Passed 134ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 223ms
tests/responses-input-tokens-count.test.ts ✅ Passed 223ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.373s
tests/responses-not-found-errors.test.ts ✅ Passed 274ms
tests/responses-parse.test.ts ✅ Passed 219ms
tests/responses-retrieve-retries.test.ts ✅ Passed 277ms
tests/responses-retrieve.test.ts ✅ Passed 349ms
tests/responses-stored-method-errors.test.ts ✅ Passed 594ms
tests/retry-behavior.test.ts ✅ Passed 3.392s
tests/sdk-error-shape.test.ts ✅ Passed 266ms

View OkTest run #32506612218

SDK merge (93e0bda3b9b0) · head (c87c1d95dc4a) · base (d1410d190d04) · OkTest (2b1bdfd25e98)

import subprocess
import sys
import tempfile
import unittest
euntaek-hong pushed a commit to wrongbutworks/openai-node that referenced this pull request Aug 21, 2026
## Summary

Set a 3,000-line ceiling on additions **plus** deletions in the
remaining custom patch against verified generated output. This is the
budget-only foundation for the same rollout approved in [Python
#3714](openai/openai-python#3714) and [Python
#3715](openai/openai-python#3715).

The verified current patch is **+1,589 / −181 = 1,770 lines**, leaving
**1,230 lines** of headroom. This is a generous bound on accidental
growth, not a target or permission to add custom code.

Only `.castiron-ratchet.json` changes here. The stacked tooling PR will
use the base-branch allowance, so a PR cannot raise its own budget.
Future increases require a separate budget-only PR, explicit
justification, and a human approving review; agents cannot approve them.

No workflow, CODEOWNERS, or ruleset changes are included. Ruleset
enforcement is a separate, later decision.

Tooling companion: openai#2447
@apcha-oai
apcha-oai added this pull request to the merge queue Aug 21, 2026
Merged via the queue into main with commit 7b7d6ca Aug 21, 2026
41 checks passed
@apcha-oai
apcha-oai deleted the apcha/custom-code-ratchet branch August 21, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

custom-code-burndown Behavior-preserving reductions of custom code in generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants