Repository navigation
Closed
Labels
bugBug reportsBug reportsdev-leadFor dev-lead agent pickupFor dev-lead agent pickupenhancementFeature requestsFeature requests
Description
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
- 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.
- A required CI check fails the PR when its diff touches any path outside that declared set. The failure message names the offending paths.
- Applied to
#1523's shape retroactively as a fixture test: a PR declaring 3 workflow stubs but touchingpackage.json,prompts/**,evals/**andscripts/**must fail. - 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
- 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.
- On close, the next scheduled
standards-syncrun regenerates the PR from currentmainif the drift still exists — so expiry never loses the underlying work, it only discards the stale attempt. - The age threshold and the enable flag read from config, not hardcoded. Ships enabled; a repo can opt out.
- Human-approved sync PRs are exempt from expiry (approval signals someone owns it).
AC3 — runaway detection gets teeth
- 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-rebasefrom 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. auto-rebaseskips any PR carrying that label and logs why.- Removing the label re-enables auto-rebase, so a human can override.
- The flagged-and-frozen state is visible in the existing runaway report.
AC4 — coverage
- 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.
shellcheck --severity=warning -xclean; suites registered in the existing jobs.
Tasks / Subtasks
- Emit the declared-path manifest from the sync generator (AC: test issue from agent #1)
- Add the scope check + fixture test using chore: sync 3 org-standard workflow stub(s) from petry-projects/.github #1523's shape (AC: Go-live improvements for PR review agent #2, Add @claude delegation, auto-merge, and rebase handling #3, Optimize review: small-PR and incremental fast paths #4)
- Implement age-based expiry with config-driven threshold + approval exemption (AC: feat: add Copilot engine support via REVIEW_ENGINE toggle #5, Workflow should skip no-op PRs in MAX_PRS count #7, Add Claude Code workflow #8)
- Confirm regeneration-after-close on the next sync run (AC: feat: feature ideation framework — adversarial proposer/challenger/synthesizer #6)
- Add the auto-rebase freeze label; wire detection to apply it and auto-rebase to honour it (AC: feat: inline Claude Code workflow to access repo secrets directly #9, fix: skip no-op PRs from MAX_PRS budget in pr-review workflow #10, feat: cross-engine adversarial rubber duck review #11, fix: auto-fallback to Copilot on Claude rate limit, fix E2BIG on large diffs #12)
- Bats coverage + shellcheck (AC: fix: use --admin bypass merge instead of --auto on approval #13, feat: CI gate + poll-loop rebase wait across all review prompts #14)
Dev Notes
- Expiry must not lose work. AC6 is the safety property: closing is only acceptable because the generator will re-open a clean PR if the drift persists. Verify that regeneration path before enabling expiry — an expiry that silently drops real drift is worse than the status quo.
- Reuse the existing runaway detector's computed metrics (commits >50, comments >200, automated cycles >10, open >48h with agent churn, merge-stacked) — do not add a second detector. This issue only adds an action to the existing signal.
- The
auto-rebaseopt-in/out convention already exists (auto-rebase:readyopts a non-draft PR in). Follow that naming and mechanism for the freeze label rather than inventing a new pattern. - Keep the scope check's path matching literal/glob and deterministic — no model involvement. This is a mechanical guard against a mechanical failure.
- Sizing: three independent guards. If the pass approaches the action budget, land AC1 (the scope check — highest value, smallest surface) and split AC2/AC3, rather than losing the pass (Measure and tune the dev-lead action budget: #1609 died 1s over ACTION_TIMEOUT_SEC and lost all its work — near-miss alerting + checkpoint push before tuning the number #1619/Action budget, slice 3a: checkpoint-push partial work before the budget expires #1660).
References
- Closed PR chore: sync 3 org-standard workflow stub(s) from petry-projects/.github #1523 (the evidence, incl. the full revert table) —
petry-projects/.github-private - Runaway PR candidate(s) detected 2026-09-01 #1654 runaway detection report; 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 post-mortem
- [#1621 S1] Harness-only thread resolution: remove the model's resolveReviewThread path #1691 / dev-lead resolves review threads without addressing them — unfixed findings merge through the thread-resolution gate #1621 (what chore: sync 3 org-standard workflow stub(s) from petry-projects/.github #1523 would have reverted); [Incident] Trunk corruption: main's scripts carry 3–6x duplicated function definitions (merged via #1420, #1292) — surgical restoration required #1485 / fix: restore trunk from #1378 re-corruption — engine.sh 13 fns duplicated again, prompts stomped (#1485 recurrence) #1519 (the
package.jsoncorruption signature); chore(dev-lead): repin stub from dev-lead/v1-stable to dev-lead/v139-stable — orphaned v1-* channel family (#1592) #1653 (the channel repin) scripts/aw-standards-sync.sh,.github/workflows/standards-sync.yml,auto-rebasecaller/reusable
Metadata
Metadata
Assignees
Labels
bugBug reportsBug reportsdev-leadFor dev-lead agent pickupFor dev-lead agent pickupenhancementFeature requestsFeature requests
Activity
don-petry commentedon Sep 7, 2026
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-rebasereusable, which is hosted inpetry-projects/.github, not this repo..github/workflows/auto-rebase.ymlhere 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-nextchannel 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 pathsfrom 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/filesvia
gh, skip human PRs, fail naming offending paths for sync PRs.scripts/aw-standards-sync.sh— emit the declared-path manifest into thegenerated PR body (
<!-- standards-sync:declared-paths … -->)..github/workflows/sync-scope-guard.yml—pull_requestcheck running the wrapper..github/workflows/lint.yml— register the new bats suite.Tests to Write
tests/test_sync_scope_check.bats— declared-path extraction; sync-PRidentification (AC4: human PRs pass); in-scope sync passes; out-of-scope
fails and names paths; glob matching; the 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) (AC2/AC3/AC4).tests/fixtures/sync-scope/— chore: sync 3 org-standard workflow stub(s) from petry-projects/.github #1523-shaped body + changed-files fixtures.Deferred to follow-ups
petry-projects/.github).Test Command
scripts/run-bats.sh tests/test_sync_scope_check.bats(full suite via lint.ymlbatsjob);lint via
bash scripts/dev-lead-lint.sh.don-petry commentedon Sep 7, 2026
Dev-Lead: Progress (in progress — not yet durable)
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-rebasereusable hosted in
petry-projects/.github, which the channel-pinned callerstub 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, failsa drifted sync PR naming each offending path.
scripts/aw-standards-sync.sh: emits the declared-path manifest into the PRbody as a machine-readable
<!-- standards-sync:declared-paths … -->block..github/workflows/sync-scope-guard.yml(new):pull_requestrequired 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)
.dev-lead/scripts/dev-lead-lint.sh, andshellcheck --severity=warning -xall ran clean locally; generator→guardround-trip verified by hand.
Notes
self-contained here, split for budget) and AC3 (runaway freeze label →
auto-rebase skip — needs the reusable in
petry-projects/.github).would ship the check via
repo-template(out of scope for AC1).don-petry commentedon Sep 7, 2026
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.
d93312714de33bf452f6cc97b03af90d79400882Review 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.
feat: implement issue #1700 — Sync PRs must expire and stay in scope;…
feat: implement issue #1700 — Sync PRs must expire and stay in scope;…