feat: implement issue #2220 — dev-lead repins its own caller stub to the legacy dev-lead/v1-stable channel to silence template-drift (salvaged checkpoint)

Merged
DO
1mo ago
+706-19

Closes #2220

Provenance: salvaged checkpoint, not a finished pass

dev-lead's run on #2220 (38094945253) hit the 45-minute action budget and escalated. Before stopping it pushed its work as one commit, ab82dc92 ("checkpoint(dev-lead): INCOMPLETE — partial work for issue #2220 (stage timeout — unreviewed, do not merge)"). This PR is opened from that branch unchanged, so CI and the normal review passes can finish it in smaller steps. Nothing here has been reviewed yet.

What the checkpoint contains

  • scripts/lib/channel-pin-guard.sh (new): a harness guard that scans a pass's diff and refuses a change to a first-party channel pin on a caller stub (uses: ref or agent_ref), including SHA-pinning or deleting the stub. Restoring the base branch's pin, or adopting a pin the base branch moved to, is allowed.
  • scripts/dev-lead-fix-reviews.sh, scripts/dev-lead-fix-ci.sh: the guard runs before the push for every pushing intent; a refusal stops the pass and escalates.
  • .github/workflows/dev-lead-reusable.yml, scripts/dev-lead-fix-ci.sh, prompts/dev-lead/fix-ci.md: a red template-drift check is no longer relayed and no longer starts a fix-ci pass on its own.
  • scripts/template_stub_drift.sh: a DRIFTED or MISSING row no longer carries a file= anchor on this repo's stub, and says the drift is in petry-projects/repo-template.
  • Tests: tests/dev-lead/unit/test_channel_pin_guard.bats (new, 351 lines) and additions to tests/template_stub_drift.bats.
  • AGENTS.md: the rule in prose.

Against the issue's criteria

CriterionState in this checkpoint
1. dev-lead never edits a caller stub's channel pin (harness, not prompt)Implemented with tests; needs review
2. template-drift is not a fix-ci triggerImplemented with tests; needs review
3. The template stops asking for itPartly: the annotation no longer points at this repo's stub. The standards-baseline side is not addressed here
4. Clean up the affected PRsNot code. PR #2157 and PR #2205 merged with clean stubs and PR #2210's stub was restored before it merged. PR #1796 is still open with the dev-lead/v1-stable repin and must be restored separately
5. TestsPresent for criteria 1 and 2

Known before review

  • The branch is behind main. scripts/template_stub_drift.sh also changed on main at 00:22 UTC on 2026-10-11 (#2219, AHEAD classification), so expect a rebase conflict in that file.
  • It edits .github/workflows/dev-lead-reusable.yml (the reusable, +6/−1), which is the intended place for the relay exclusion. It does not touch any caller stub.

Related: #2215 (on hold behind this issue; covers what this does not), #2214, #2185, #2212.

🤖 Generated with Claude Code

Problem

See the linked issue.

Risk

Medium — changes GitHub Actions workflow behavior, which is exercised only post-merge; verify via the affected workflow runs.

Test plan

Tests added/updated: tests/dev-lead/unit/test_channel_pin_guard.bats,tests/template_stub_drift.bats. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the bats suite runs in CI.

Rollback

Revert this PR. No non-revertible side effects (no tags, migrations, or external state).

Monitoring

Watch the affected workflow run(s) in the Actions tab and this PR's Lint check for regressions.