Skip to content

run-ci-tests --affected: rebuild unlanded derived files before the suites, as CI does - #2430

Merged
remigiusz-antczak merged 2 commits into
mainfrom
fix-affected-regen
Nov 19, 2026
Merged

remigiusz-antczak merged 2 commits into
mainfrom
fix-affected-regen

Conversation

@remigiusz-antczak

@remigiusz-antczak remigiusz-antczak commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

run-ci-tests.sh --affected now rebuilds unlanded derived files before the suites, comparing against the merge-base of HEAD and origin/main, the same way CI does. A lane PR that adds a script no longer fails low-context-index.sh locally (STALE INDEX.md) while passing in CI.

Why

The pre-push hook runs --affected, but CI runs regen-unlanded.sh origin/main before every gate. Lane PRs never commit INDEX*.md, SHA256SUMS or size rows, so the local gate and CI disagreed on any PR that adds a file.

What changed

  • scripts/run-ci-tests.sh: after selection and before the suites, --affected runs regen-unlanded.sh origin/main. If the ref is stale or missing, it skips the rebuild and checks strictly (fail-closed).
  • It snapshots the tree before the rebuild and hashes it after, then restores every file the rebuild changed. Files that were already dirty keep their edits, files the rebuild created are removed, and files edited after the rebuild are kept, with a note.
  • A TERM or INT during the rebuild waits until the rebuild exits; the EXIT trap then restores the tree.
  • Selection, the privacy scan and the receipt all use the pre-rebuild tree. --list-affected stays dry.
  • scripts/test-run-ci-tests-affected.sh: 5 new cases. Three of them (rebuild, edit after rebuild, TERM) fail on the old runner, which passes 27/30. The other two (exact restore, dry list) are guards and pass on both.

Review

An independent review found 0 🔴 and 2 🟡: a signal during the rebuild, and a rebuild against a stale base. Both are fixed, and a re-review of the amend found 0 🔴 and 0 🟡. A second independent review of the PR found 0 🔴 and 3 🟡, all now fixed in 0902751, each with a test that fails when its fix is reverted:

  • A branch cut before the latest land compared its VERSION with origin/main and skipped the rebuild. It now compares at the merge-base, matching CI's merge ref.
  • land-release.sh --regen took the land lock, so every pre-push failed during a land or after a crash that left the lock behind. --regen now runs before the lock.
  • The restore reverted any file the rebuild window touched. It now restores only paths matching GENERATED in land-release.sh, which is read from that file rather than copied.

One 🔵 is logged for a follow-up: a SIGKILL during the rebuild leaves the derived files dirty.

Tests

Tests: 43/43 (test-run-ci-tests-affected.sh, test-land-release.sh). bash -n passes, with no new shellcheck warnings and 0 privacy-grep hits.
CI-parity pre-push on 0902751: scripts/run-ci-tests.sh --affected ran 26 suites with 0 failures.

Rollback

A single git revert: --affected goes back to skipping the rebuild.

🤖 Generated with Claude Code

remigiusz-antczak and others added 2 commits November 18, 2026 22:12
…ites, as CI does

The pre-push hook runs `run-ci-tests.sh --affected`, but CI runs `regen-unlanded.sh origin/main`
before any gate (ci.yml "Regenerate derived files"). Lane PRs do not commit INDEX*.md, SHA256SUMS
or size rows, so a PR that adds a script failed low-context-index.sh locally (STALE INDEX.md) and
passed in CI.

--affected now runs `regen-unlanded.sh origin/main` (CI's ref, not the push BASE: an older BASE
after a land would skip the rebuild) after selection and before the suites. It snapshots the
working tree (lkg.py tree) first and hashes the rebuilt tree after. It then restores every file
that differs between the two whose bytes are still the rebuild's, before the receipt is hashed and
again from the EXIT trap. An already-dirty file keeps its edit, a file the rebuild created is
removed, and a file edited after the rebuild is kept with a note. TERM/INT during the rebuild is
deferred until it exits, then the EXIT trap restores (it re-hashes the tree when the signal came
before the post-rebuild hash). Selection, the privacy scan and the receipt tree are the pre-rebuild
tree; --list-affected stays dry. No regen-unlanded.sh or no tree hash: no rebuild (old behavior).

Verified: test-run-ci-tests-affected.sh 30/30 (5 new cases: rebuild against origin/main, exact
restore, dry --list-affected, edit-after-rebuild kept, TERM during the rebuild; the rebuild,
edit-after-rebuild and TERM cases fail on the old runner, 27/30 there; exact restore and dry
--list-affected are guards that pass on both), bash -n, shellcheck no new warnings. The previous revision also passed a real
run-ci-tests.sh --affected (13 suites, incl. low-context-index.sh with a new script present).

Tests: 30/30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ved files

Three follow-ups to the pre-suite rebuild of derived files:

- Compare against the merge-base of HEAD and origin/main instead of
  origin/main. CI rebuilds on its merge ref, whose VERSION is
  origin/main's, so a branch cut before the latest land must still count
  as unlanded locally. With no merge-base, origin/main is used as before.
- land-release.sh --regen now runs before the land lock is taken. A
  rebuild writes only its own worktree, so a land in progress or a
  leftover lock no longer fails every push in every worktree.
- The post-suite restore only touches paths that match GENERATED in
  land-release.sh (read the same way train_land.sh reads it). Any other
  file changed while the rebuild ran keeps its new bytes.

Each fix has a regression case that fails with that fix reverted.

Tests: 43/43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@remigiusz-antczak
remigiusz-antczak merged commit e066d7d into main Nov 19, 2026
13 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the fix-affected-regen branch November 19, 2026 03:14
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.

1 participant