Skip to content

Standards sweep reuses a same-date sync branch as-is — a narrower second run opens a PR carrying the first run's commits #1296

Open

Description

@don-petry

Problem

sd_deploy_files_via_pr (scripts/lib/standards-deploy.sh, step 4) names the sync branch standards-sync/workflows-<UTC date> and, when that branch already exists, reuses it as-is ("reuse it if a prior run already created it"). It then PUTs the current run's files on top. Nothing checks that the branch still descends cleanly from the default branch, or that what is already on it belongs to this run.

So a second run on the same UTC day inherits the first run's commits, even when the second run is narrower and even when the first run's PR was closed.

Observed 2026-10-11 (workflow_dispatch runs of Standards Deploy):

Repo First run Second run (target_workflow=persona-mention.yml) Second PR actually contained
TalkTerm PR 532, 5 stubs, closed run 38108113406 PR 534: all 5 stubs (6 commits)
bmad-bgreat-suite PR 500, 3 stubs, closed run 38108761306 PR 503: all 3 stubs (4 commits)

In ContentTwin, markets and google-app-scripts, where no branch existed for that date, the same scoped run opened a one-file PR as intended. The scoped run logged OK … (1 stub(s): persona-mention.yml) in every case, so the log does not reveal the difference; only the PR's file list does.

The same reuse also means that anything an agent pushed to the branch after the first run (review "fixes" to synced stubs) is carried into the next run's PR.

Acceptance criteria

  1. A run never opens a PR containing files it did not write in that run. Either the branch is created fresh from the default branch's current tip each run (unique name, or reset when no open PR uses it), or the run fails loudly when the existing branch holds commits it does not recognise.
  2. When an open sync PR exists for the repo the current SKIP_PR_OPEN behaviour is unchanged.
  3. The run's own summary line reports the number of files in the PR it opened, read back from the API, not the number it intended to write.
  4. bats in the standards-deploy suite: a pre-existing same-date branch with extra commits and no open PR → the new PR contains only this run's files (or the run fails with a message naming the branch).

Budget guard

AC 1 with its test is the one that matters. AC 3 can be split into a follow-up if it needs changes outside sd_deploy_files_via_pr.

Activity

  1. don-petry commented on Oct 11, 2026

    @don-petry
    ContributorAuthor

    Dev-Lead Implementation Plan

    Issue: #1296 — Standards sweep reuses a same-date sync branch as-is — a narrower second run opens a PR carrying the first run's commits

    Scope

    When the same-date sync branch already exists, sd_deploy_files_via_pr resets it to the default branch's current tip (force ref update) before writing — but only after confirming no open PR (any label) uses that branch; if one does, or the probe errors, the run fails loudly naming the branch. AC 2 (SKIP_PR_OPEN) path untouched.

    Implementation Checklist

    • scripts/lib/standards-deploy.sh step 4: on existing branch → gh pr list --head <branch> --state open probe → FAILED branch-in-use:<branch>#<pr> / FAILED branch-pr-probe-failed:<branch> / else PATCH git/refs/heads/<branch> sha=<base> force=true (FAILED branch-reset-failed:<branch> on error); update header comments.
    • AC 3 (read-back file count in the summary line) needs changes in the callers' outcome parsing (deploy-standard-workflows.sh, compliance-remediate.sh, sync-gitignore-baseline.sh), so per the budget guard it is deferred to a follow-up.

    Tests to Write

    • test/scripts/lib/standards-deploy.bats: stateful fake branch — pre-existing same-date branch with stale stub commits, no open PR → branch reset to base tip before any PUT; branch afterwards holds only this run's file.
    • branch in use by an open (unlabeled) PR → FAILED branch-in-use: naming the branch, no reset/PUT/PR create.
    • head-PR probe error → fails, no reset; reset error → FAILED branch-reset-failed:<branch>.
    • fresh branch → no reset call.

    Test Command

    npx bats test/scripts/lib/standards-deploy.bats test/scripts/deploy-standard-workflows test/scripts/compliance-remediate + bash .dev-lead/scripts/dev-lead-lint.sh

  2. don-petry commented on Oct 11, 2026

    @don-petry
    ContributorAuthor

    Dev-Lead: Implementation Complete — PR #1299

    The implementation for issue #1296 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.

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 pickup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions