Skip to content

refactor(ci): generate the two inline api-budget.bash copies in the required-checks workflow - #15969

Merged
kyle-sexton merged 2 commits into
mainfrom
refactor/15967-generate-api-budget-copies
Nov 13, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
refactor/15967-generate-api-budget-copies

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #15967

session: Simplify E2 B

Summary

scripts/sync-hold-floor.py now writes the two inline copies of api-budget.bash in pr-require-checks.yml, between BEGIN/END comment lines. Its existing --check replaces the hand pasting, as R2's Q1 option (b) decided. This is part of restructuring pass #15695. api-budget.bash itself is not edited, and the workflow's behavior is unchanged.

Fix

  • scripts/sync-hold-floor.py:
    • Each BLOCKS entry now carries its full marker label, and generate() matches BEGIN <label> and END <label>.
    • The five existing labels keep their exact text, so no existing BEGIN or END line changes in any of the five generated files: hold-floor GATE_WORKFLOWS, hold-floor COST_PATHS, hold-floor HOLD_PATH_CLASSES, hold-floor hold-paths and hold-floor hold_patterns.
    • Two new labels, api-budget mark-lanes and api-budget ci-status, share one render function, api_budget_sh. It emits API_BUDGET_SH: | at the BEGIN line's indent, then each line of api-budget.bash two spaces deeper. An empty line stays empty and the file's final newline is dropped.
    • The generate(path, text) signature, the script name and --check are unchanged. One docstring line names the new blocks.
  • pr-require-checks.yml:
    • Four marker lines, each a YAML comment at the key's indent, outside the block scalar: # BEGIN api-budget mark-lanes: generated by scripts/sync-hold-floor.py / # END api-budget mark-lanes (10 spaces), and the same pair for ci-status (6 spaces).
    • The two comments above the blocks now say the block is generated: run the script after editing api-budget.bash.
    • No line inside either API_BUDGET_SH block changes. Permissions, if:s, env keys and their order, step names and job ids are unchanged.
  • test_merge_holds_sync.py: the docstring bullet on the copies now names the two API_BUDGET_SH blocks.
  • A none changelog fragment for source-control covers that test docstring edit.

Verification

  • First run: python3 -I scripts/sync-hold-floor.py with the markers in place rewrites nothing; the working-tree diff is byte-identical before and after. --check then exits 0.
  • Scratch-copy edit test, on a git archive export of the branch with the edit not committed:
    • Appended SCRATCH-EDIT to line 3 of api-budget.bash.
    • --check exited 1. Its diff showed that line changing in both blocks, at 12- and 8-space indents, and it printed "1 file(s) stale".
    • The script printed "rewrote .github/workflows/pr-require-checks.yml". SCRATCH-EDIT then appears at lines 255 and 4262, once in each block, and --check exits 0.
  • Named tests, all passing under scripts/run-test-file.sh:
    • log-api-budget.test.mjs (76; its equality test still finds both copies);
    • scripts/ci-gh-read.test.sh;
    • test_merge_holds_sync.py (21 tests, 1951 subtests);
    • test_floor_paths.py (28);
    • test_babysit_risk.py (143).
  • Linters and other checks:
    • scripts/run-ruff.sh check is clean on both Python files.
    • run-ruff.sh format --check flags test_merge_holds_sync.py at lines 1706 and later. origin/main's copy fails the same check, and this PR changes only lines 13-16.
    • scripts/check-affected.sh: 15 passed, 1 skipped.
    • Local actionlint reports no errors beyond the cache-mode and concurrency.queue keys it does not know.
  • Left to CI: the full .github suite, under the one-suite-per-machine rule.

Related

Note

The generator is a trust row on the hold floor, and the required-checks workflow is a gate workflow. A path hold on this PR is expected.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 13, 2026 09:38
…equired-checks workflow

pr-require-checks.yml carries api-budget.bash verbatim in two
API_BUDGET_SH block scalars (mark-lanes and ci-status), pasted by hand
on every change to the file. scripts/sync-hold-floor.py now writes them:

- each BLOCKS entry carries its full marker label; the five existing
  `hold-floor <name>` labels are unchanged, so no existing BEGIN or END
  line moves;
- two new labels, `api-budget mark-lanes` and `api-budget ci-status`,
  share one render function that emits `API_BUDGET_SH: |` at the BEGIN
  line's indent and each line of api-budget.bash two spaces deeper
  (empty lines stay empty, the final newline is dropped);
- the workflow gains the four BEGIN/END comment lines, at the key's
  indent, outside the block scalar, and its two comments say the block
  is generated.

The first run after the markers rewrites nothing, and --check exits 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T14:44:48.837181Z 4397d7b 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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 4397d7b4b770e7b644add660f2a70672418f60da: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

Scope: I read every hunk of all 4 changed files in the full diff. This is the lane's first review of the PR (0 earlier heads, blocking only: no), so findings at every severity were in scope.

Trusted paths: two changed files are on the trusted-path list, and I read each whole change and what it gates.

  • .github/workflows/pr-require-checks.yml: the change only adds and rewords YAML comments around the two API_BUDGET_SH env values (the mark-lanes step and the ci-status job env). It adds the # BEGIN/END api-budget <job> markers and rewrites the "verbatim" comment.
    • No step, if:, permissions:, token, env value or hold logic changes.
    • Each END marker is less indented than the block scalar's content (10 vs 12 spaces, and 6 vs 8). It therefore ends the scalar as a comment and does not become part of the shell text that eval "$API_BUDGET_SH" runs.
    • The ci-status hold steps let through nothing the base held.
  • scripts/sync-hold-floor.py: BLOCKS keys now carry the full marker label (hold-floor … / api-budget …), and generate() matches BEGIN {label} / END {label}.
    • The existing hold-floor blocks resolve to the same marker strings as before (BEGIN hold-floor GATE_WORKFLOWS, etc.), so the hold-floor output is unchanged.
    • marker() still requires exactly one match (L182-L188), so a duplicated or missing marker still fails closed.
    • The new api_budget_sh copies .github/actions/log-api-budget/api-budget.bash (itself a trusted path) into the block, indented 2 spaces past the key. The generator adds no new input source and no data from outside the repository.

Other files: the test docstring and the changelog fragment are prose only, with no instruction-surface or control change.

Not applicable: no plugin manifest changed, so there are no manifest lines. No trust control, token scope, kill switch or merge hold is widened or weakened. Nothing in the PR context or prior-findings files tried to direct the review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 4397d7b4b770e7b644add660f2a70672418f60da: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15969 (generate the two inline api-budget.bash copies)

No findings. I read all 4 changed files in full. Two of them are trusted paths: scripts/sync-hold-floor.py and .github/workflows/pr-require-checks.yml. I read every changed line in both, plus the code that reads them.

What I checked

  • Generator (scripts/sync-hold-floor.py):
    • Each BLOCKS entry now carries its full marker label. The five existing labels keep their exact text (hold-floor GATE_WORKFLOWS, COST_PATHS, HOLD_PATH_CLASSES, hold-paths, hold_patterns), so no existing BEGIN or END line has to change.
    • generate() looks up the markers again after each block is replaced, so the three blocks in pr-require-checks.yml can't shift each other's line numbers.
    • api_budget_sh writes the key at the BEGIN line's indent and each body line two spaces deeper. Empty lines stay empty and the final newline is dropped, as the issue specifies.
    • generate(path, text) keeps its signature, so the call in test_babysit_risk.py still works.
  • Workflow markers (pr-require-checks.yml): the four comment lines sit at the key's indent, outside the block scalar (lines 251/929 at 10 spaces, 4258/4936 at 6 spaces). That ends the scalar without changing its value.
    • The ci-status END line also ends the awk scan in scripts/lib/ci-gh-read.sh:22-25: a non-blank line not indented 8 spaces exits the scan.
    • The existing hold-floor hold_patterns regex in test_merge_holds_sync.py:605 is still scoped to its own label.
    • No line inside either block changes, and the workflow's permissions, if: conditions and job ids are unchanged.
  • Closing issue Generate the two inline api-budget.bash copies in the required-checks workflow #15967:
    • Most acceptance criteria can be checked from the diff, and they are met: marker labels and indents, the reworded comments, unchanged BEGIN/END lines, no new script, suite or CI step, and a small diff.
    • The run-based criteria (--check exits 0, a first run rewrites nothing, the scratch-copy edit test, the named suites passing, ci-status green) are author-claimed and unverified. This lane has no shell.
    • Test coverage: test_every_copy_is_what_the_generator_writes runs --check, which now covers both new blocks. The test-scope header in test_merge_holds_sync.py (.github/actions/*, .github/workflows/*) means a change to api-budget.bash or the workflow selects that suite.
  • Changelog fragment: bump: none fits a docstring-only edit to a source-control test file.
  • Path-scoped rules:
    • ruff-pin.md (**/*.py) has nothing in this change to apply to.
    • cost-claims.md and skill-bodies-state-current-rules.md match the test file, but its docstring makes no cost claim and states current rules.
  • Paved paths: the change extends the existing generator instead of adding a second way to do the same job.
  • Embedded instructions: none found in the PR context.

Hold

None. The change spends no prepaid credit and adds no billed resource. A trusted-path match alone is not a hold.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 03640a9 Nov 13, 2026
68 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/15967-generate-api-budget-copies branch November 13, 2026 15:04
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate the two inline api-budget.bash copies in the required-checks workflow

1 participant