Skip to content

refactor(lanes): run lane script entry points through lib/run-main.mjs (part 1 of 2) - #15500

Merged
kyle-sexton merged 2 commits into
mainfrom
refactor/lane-lib-run-main
Nov 12, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
refactor/lane-lib-run-main

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #15448

Summary

Thirteen .github/scripts lane scripts end with the same copied entry tail: run main only when the module is the process entry point, then print ::error::<label> failed on a rejection. A new .github/scripts/lib/run-main.mjs exports runAsScript(metaUrl, label, run), which holds that tail once, and this part moves six scripts onto it: apply-patch.mjs, address-feedback.mjs, adjudicate-feedback.mjs, review-dependency.mjs, apply-dependency-verdict.mjs and fix-ci-context.mjs. Part 1 of 2 of the split in restructuring pass #14159 (R1).

Built in a session because the change spans shared lib/ and the hold floor (host-run); agreed with the hub session.

session: Simplify Planning

Fix

  • lib/run-main.mjs: the entry tail, unchanged in behavior (the same arguments, ::error::<label> failed: <message> line and exit codes); importing a module still runs nothing.
  • Hold floor: one added enforcement row for lib/run-main.mjs, since apply-patch, adjudicate-feedback and fix-ci-context are route entries. Nothing is removed or reclassified. merge-holds.mjs, both review workflows' hold-paths and ci-status's hold_patterns are regenerated by scripts/sync-hold-floor.py, and the test_floor_paths pins follow.
  • Staging: ci-status's base-config sparse list and the write runner's apply-base step copy lib/run-main.mjs with the other cross-directory imports, and the collect-base-activity test fixture stages it. The issue lane already stages base lib/ wholesale.
  • These staging edits, the pin update and two changelog fragments take the change to 18 hand-edited files, past the issue's 15-file cap; each is required for the move to run or release.

Verification

  • Old against new, all six scripts, with the same failing input and an empty environment: identical stdout, stderr and exit code. Importing each prints nothing. Main's dispatch.mjs (the different-label shape in part 2) behaves the same through runAsScript.
  • python3 scripts/sync-hold-floor.py --check: pass. Floor pins: a script reproduced main's pins exactly before they were updated.
  • Full babysit-prs Python suite (4,296), collect-base-activity and callers.test.mjs (435), node suites of apply-patch, pr-unblock, pr-merge and lib (2,878), resolve-config and log-api-budget (1,238): pass.
  • scripts/write-runner-never-rules.test.sh 75/0, scripts/ci-lanes-pr-hold.test.sh 344/0, actionlint clean apart from the known cache-mode key.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH

…s (part 1 of 2)

The same 11-line entry tail (run main only when executed directly, print
`::error::<label> failed` and exit 1 on a rejection) was copied into 13
.github/scripts files. lib/run-main.mjs now holds it once as
runAsScript(metaUrl, label, run), and apply-patch, address-feedback,
adjudicate-feedback, review-dependency, apply-dependency-verdict and
fix-ci-context call it with the same arguments and label as before.
Importing any of them still runs nothing. Part 2 moves the other seven.

Since apply-patch, adjudicate-feedback and fix-ci-context are route
entries and address-feedback is floored, lib/run-main.mjs gets an
enforcement floor row (141 rows to 142, review route 59 to 60; no row
dropped, no class changed), regenerated into merge-holds.mjs, both review
workflows' hold-paths and ci-status's hold_patterns by
scripts/sync-hold-floor.py. ci-status's base-config sparse checkout lists
it beside address-feedback's other lib imports, the write runner's
apply-base step copies it out of the base with apply-patch's other
cross-directory imports, and the collect-base-activity test's base
fixture stages it. The floor tests add the row and move the pinned
counts and digests to the new set.

Refs: #15448
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 12, 2026 02:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T03:01:25.928104Z 641aa98 Draft marked ready
ℹ️ 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 Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 2d7764ab26c830a97c69a231ca038f4806b90880: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental): PR #15500, head 2d7764a

No security issues found. This incremental review covers the changes since 641aa98. Only one file changed, and I read its whole hunk.

What changed. The new test file .github/scripts/lib/run-main.test.mjs covers runAsScript from .github/scripts/lib/run-main.mjs. That module is unchanged since the last review.

How the test works.

  • It writes a fixture module into a fresh mkdtempSync directory under the OS temp dir and removes that directory in after.
  • It runs the fixture with spawnSync(process.execPath, [fixture], …). That is an argument array, not a shell, and the child gets only PATH plus fixed test values (CODE, MODE).
  • The fixture's import URL comes from the test's own import.meta.url and is quoted with JSON.stringify.

No secrets, tokens or outside input reach the test.

Trust controls checked.

  • Trusted paths. The new file is a test. It matches none of the listed globs (the trusted entry is run-main.mjs itself).
  • Controls untouched. The push changes no workflow, permissions: block, token request, trusted-actor list, kill switch, merge hold or hold-floor row.

Blocking only. This lane already reviewed an earlier head, so this review reports only CRITICAL and IMPORTANT findings. There were none.

Spend. None beyond the normal CI test run.

critical-findings: 0

@github-actions github-actions Bot 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.

claude-review: 1 inline finding(s) on 641aa9894dae1262cfbaca324044f547e5bb1af4; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread .github/scripts/lib/run-main.mjs Resolved
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 2d7764ab26c830a97c69a231ca038f4806b90880: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Incremental code review: PR #15500 at 2d7764ab, blocking only

This is an incremental review of the one file changed since 641aa989: .github/scripts/lib/run-main.test.mjs, which is new. I read its whole change. A review of this lane already covered an earlier head, so this one reports blocking findings only.

No blocking findings.

The new test covers the gap I raised last round as an advisory finding. The owner has since resolved that thread. I checked each test against runAsScript in lib/run-main.mjs#L8-L19:

  • Exit code. The test spawns process.execPath on a temporary fixture that imports the helper by file URL. It asserts the resolved code passes through as the exit status, for both 0 and 3, and that stdout stays empty. If process.exitCode = code were dropped, the case for 3 would fail.
  • Rejection. It asserts exit 1 and the exact line ::error::x failed: boom\n on stdout. The helper writes that line with console.log, so a missing label or a changed format would fail this test.
  • Import. It imports the fixture in-process and asserts runCalls stays 0. In this process process.argv[1] is the test file, so the guard returns early. If the guard were inverted, run() would be called synchronously and its body would increment runCalls before any await, so the assert would catch it.
  • Isolation and discovery. The spawned processes get only PATH, so the MODE and CODE values from one test cannot reach another. The temporary directory is removed in after. The file sits next to 14 other .github/scripts/lib/*.test.mjs suites, so the existing suite discovery should pick it up.

I checked this by reading the code; I ran nothing. The owner's claim that "all 3 tests fail" with the guard inverted is unverified.

The earlier whole-PR point about #15448's scope criteria (18 hand-edited files against a cap of 15, and four files the issue does not list) was an advisory finding, so this blocking-only round does not repeat it. This push adds one more file outside the issue's list, but it is the test this lane asked for. No embedded instructions appeared in the settled-threads or prior-findings files. The change spends no extra credits or billing.

A fixture module run as a process must pass a resolved code through and
print `::error::<label> failed: <message>` with exit 1 on a rejection;
imported, it must run nothing. Inverting the entry-point guard fails all
three tests.

Refs: #15448

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit a3776fd Nov 12, 2026
71 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/lane-lib-run-main branch November 12, 2026 04:16
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 12, 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.

Run lane script entry points through one lib helper (part 1 of 2)

1 participant