Skip to content

Sync PRs must expire and stay in scope; runaway detection must stop auto-rebase (from the #1523 post-mortem) #1700

Closed

Description

@don-petry

Summary

#1523 was closed 2026-09-07 not as stale but as unsafe to merge: it would have reverted #1691 (merged hours earlier), resurrected a package.json that is deliberately absent (the 2026-08-14 trunk-corruption signature, #1485/#1519), and undone #1653's channel repin. It survived three weeks and 255 commits across 18 files while automation actively maintained it.

The conditions that produced it are all still in place. This issue installs the three guardrails so the next one expires instead of accumulating.

The pattern to fix: our automation is optimised to keep PRs alive, never to let them die. Combined with detect-only monitoring, a bad PR gets indefinitely maintained.

Acceptance Criteria

AC1 — a sync PR may only touch what it claims to sync

  1. The stub-sync PR generator records, in a machine-readable form on the PR (body payload or a committed manifest), the exact set of paths it intends to sync.
  2. A required CI check fails the PR when its diff touches any path outside that declared set. The failure message names the offending paths.
  3. Applied to #1523's shape retroactively as a fixture test: a PR declaring 3 workflow stubs but touching package.json, prompts/**, evals/** and scripts/** must fail.
  4. The check is scoped to generated sync PRs (identified by their automation marker), not to human PRs.

AC2 — sync PRs expire; they are regenerated, not rebased

  1. A generated sync PR older than a configurable age (default 7 days) with no human approval is closed automatically, with a comment stating it is superseded and that a fresh sync will regenerate it.
  2. On close, the next scheduled standards-sync run regenerates the PR from current main if the drift still exists — so expiry never loses the underlying work, it only discards the stale attempt.
  3. The age threshold and the enable flag read from config, not hardcoded. Ships enabled; a repo can opt out.
  4. Human-approved sync PRs are exempt from expiry (approval signals someone owns it).

AC3 — runaway detection gets teeth

  1. When runaway detection flags a PR (the P2 (#860 follow-up): runaway-PR detection in daily health check (commits/comments/cycles/age thresholds) #948/P2 (#860 follow-up): keep agent branches rebased/squashed instead of merge-stacked #949/feat: implement issue #846 — [Phase 2] Cache the LSP index and enforce the 30s cold-start SLA with auto-skip #860 thresholds it already computes), it applies a label that stops auto-rebase from touching that PR. Detection currently states "Detection only — no PR is mutated"; that stays true of the PR's content — this changes only whether automation keeps resuscitating it.
  2. auto-rebase skips any PR carrying that label and logs why.
  3. Removing the label re-enables auto-rebase, so a human can override.
  4. The flagged-and-frozen state is visible in the existing runaway report.

AC4 — coverage

  1. Bats coverage for each guard: scope violation fails; in-scope sync passes; a PR at/over the age threshold closes while an approved one does not; a runaway-labelled PR is skipped by auto-rebase.
  2. shellcheck --severity=warning -x clean; suites registered in the existing jobs.

Tasks / Subtasks

Dev Notes

References

Activity

  1. don-petry commented on Sep 7, 2026

    @don-petry
    CollaboratorAuthor

    Dev-Lead Implementation Plan

    Issue: #1700 — Sync PRs must expire and stay in scope; runaway detection must stop auto-rebase (from the #1523 post-mortem)

    Scope decision (sizing)

    Three independent guards (AC1/AC2/AC3). Per the issue's own sizing guidance
    ("land AC1 — the scope check, highest value, smallest surface — and split
    AC2/AC3, rather than losing the pass") this pass lands AC1 in full and
    splits AC2 and AC3 into follow-ups.

    Additional reason AC3 is split: AC10/AC11 (auto-rebase must skip a freeze-labelled
    PR and log why) live in the auto-rebase reusable, which is hosted in
    petry-projects/.github, not this repo.
    .github/workflows/auto-rebase.yml
    here is a thin channel-pinned caller stub; per AGENTS.md "Caller-stub input
    forwarding across channel pins" I must not teach the stub a behaviour the pinned
    @auto-rebase/v2-next channel does not yet declare. The label-application side
    (AC9/AC12, in the runaway detector) is implementable here but is inert without
    the reusable honouring it, so AC3 is deferred as one coherent cross-repo unit.

    AC1 — a sync PR may only touch what it claims to sync

    Implemented here, fully self-contained, with the #1523 retroactive fixture.

    Implementation Checklist

    • scripts/lib/sync-scope-check.sh — pure functions: extract declared paths
      from a PR-body marker block, identify a generated sync PR, compute
      out-of-scope changed paths (literal + glob, deterministic, no model).
    • scripts/sync-scope-guard.sh — network wrapper: read PR labels/body/files
      via gh, skip human PRs, fail naming offending paths for sync PRs.
    • scripts/aw-standards-sync.sh — emit the declared-path manifest into the
      generated PR body (<!-- standards-sync:declared-paths … -->).
    • .github/workflows/sync-scope-guard.yml — pull_request check running the wrapper.
    • .github/workflows/lint.yml — register the new bats suite.

    Tests to Write

    Deferred to follow-ups

    • AC2 (age-based expiry + regeneration + config flags) — self-contained here, split for budget.
    • AC3 (runaway freeze label → auto-rebase skip) — cross-repo (reusable in petry-projects/.github).

    Test Command

    scripts/run-bats.sh tests/test_sync_scope_check.bats (full suite via lint.yml bats job);
    lint via bash scripts/dev-lead-lint.sh.

  2. don-petry commented on Sep 7, 2026

    @don-petry
    CollaboratorAuthor

    Dev-Lead: Progress (in progress — not yet durable)

    Provisional. Nothing is pushed yet; the automation posts the authoritative
    completion record (with PR number + head SHA) after the push. Treat the notes
    below as intent, not delivered results.

    Scope landed this pass

    AC1 only (a sync PR may only touch what it claims to sync), per the issue's
    sizing guidance. AC2 (expiry) and AC3 (runaway freeze → auto-rebase skip) are
    split. AC3 is additionally cross-repo: AC10/AC11 live in the auto-rebase
    reusable hosted in petry-projects/.github, which the channel-pinned caller
    stub here must not race ahead of.

    Files touched (this workspace, not yet pushed)

    • scripts/lib/sync-scope-check.sh (new): pure declared-path extraction,
      generated-sync-PR identification, and literal+glob scope-violation logic.
    • scripts/sync-scope-guard.sh (new): network wrapper — skips human PRs, fails
      a drifted sync PR naming each offending path.
    • scripts/aw-standards-sync.sh: emits the declared-path manifest into the PR
      body as a machine-readable <!-- standards-sync:declared-paths … --> block.
    • .github/workflows/sync-scope-guard.yml (new): pull_request required check.
    • tests/test_sync_scope_check.bats (new) + tests/fixtures/sync-scope/ — incl.
      the retroactive chore: sync 3 org-standard workflow stub(s) from petry-projects/.github #1523 fixture (declares 3 workflow stubs, touches
      package.json/prompts/evals/scripts → must fail).
    • .github/workflows/lint.yml: registers the new bats suite.

    Local checks (provisional — not the pushed run)

    • New bats suite, .dev-lead/scripts/dev-lead-lint.sh, and
      shellcheck --severity=warning -x all ran clean locally; generator→guard
      round-trip verified by hand.

    Notes

    • Follow-ups to file: AC2 (age-based expiry + regeneration + config flags —
      self-contained here, split for budget) and AC3 (runaway freeze label →
      auto-rebase skip — needs the reusable in petry-projects/.github).
    • The live workflow guards this repo's own generated sync PRs; org-wide coverage
      would ship the check via repo-template (out of scope for AC1).
  3. don-petry commented on Sep 7, 2026

    @don-petry
    CollaboratorAuthor

    Dev-Lead: Implementation Complete — PR #1703

    The implementation for issue #1700 is durable: commits are pushed and a pull request is open. This record is backed by verifiable artifacts you can confirm in one click.

    Review happens on the PR. Acceptance criteria and test results are evidenced by the PR's diff and CI checks — not asserted here. If a later stage fails, this claim is retracted in place.

  4. added 2 commits that reference this issue on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug reportsdev-leadFor dev-lead agent pickupenhancementFeature requests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions