Add forward-only submodule CI guard

Merged
TE
2mo ago
+445-2

Summary

PR #15747 cut its branch before two submodule bumps reached main, then a squash merge moved both gitlinks backwards. The bonsplit rollback removed types that main already referenced, which caused macOS compile admission and dependent checks to fail across the repository.

This adds a Linux guard that reads every path from .gitmodules, compares the merge base gitlink with the PR head gitlink, and checks commit ancestry inside the submodule. Unchanged and forward moves pass. Backward moves and diverged histories fail with the dropped commit count and subjects, the likely squash-merge cause, and the remedy of merging main into the branch. If local objects cannot decide, the guard uses the GitHub compare API and fails loudly if that also cannot decide.

A file-list check would not have caught #15747 because both submodule paths were present in the diff with explicit gitlink replacements. The diff shows that a pointer changed, while ancestry shows whether it moved backwards. A deliberate rollback can be declared per path by adding a branch commit containing submodule-forward-only: allow <submodule-path>; the marker cannot excuse undecidable ancestry.

Verification

  • actionlint .github/workflows/ci-guards.yml
  • python3 tests/test_submodule_forward_only.py (13 tests)
  • python3 tests/test_ci_linux_guard_routing.py (35 tests)
  • python3 tests/test_ci_test_execution_registry.py (29 tests)
  • python3 scripts/ci/validate_test_execution_registry.py
  • python3 tests/test_ci_run_guards.py (16 tests)
  • python3 scripts/verify-local.py (15 of 16 selected checks ran and passed; no native build)
  • python3 /Users/leoli/Projects/guard-sweep.py 4 completed. It reported the expected unbound runner variables and missing submodule source roots, plus unrelated baseline failures in web complexity, scheduled main full-suite, iOS upload lean checkout, and pipe-safe capture.
  • Mutation checks made the merge-base, API direction, API divergence, submodule-addition, marker-scope, and guard-status tests fail, then each change was restored.
  • A stale-branch sanity check with gitlinks equal to the merge base printed unchanged and exited 0.

Changelog

Added a Linux CI guard that rejects backwards or diverged submodule gitlink moves.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • CI Improvements
    • Added a required check that prevents submodule references from moving backward or diverging from the base revision.
    • Submodule rollbacks can pass when explicitly allowed for the affected path.
    • Added automated coverage for forward updates, rollbacks, and unavailable commit history.