Skip to content

[CI] Satya/stale branch archive - #5617

Merged
Boss2002n merged 2 commits into
mainfrom
satya/stale_branch_archive
Oct 8, 2026
Merged

Boss2002n merged 2 commits into
mainfrom
satya/stale_branch_archive

Conversation

@Boss2002n

@Boss2002n Boss2002n commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Weekly, off until STALE_BRANCHES_ARCHIVE is 'true'; until then every run reports and writes nothing.

A branch with no commits for 30 days is copied to archive// and its ref removed. 30 days later a deletion notice is posted; 14 days after that the archive ref is deleted. 74 days end to end, restorable at any stage with git push origin archive//:, which both bot comments print.

No stored state: the archive date is in the ref name, the notice date is the bot's comment. Deleting that comment opts a branch out. Only refs this workflow created are managed — its own archiving comment is the provenance — and markers name their ref, so two branches on one commit can't share a clock.

Deletion is a leased git push, the only server-side compare-and-swap available; protection and open-PR head/base membership are re-checked immediately before it. Exemptions are the checked-in .github/stale-branch-exemptions.txt, consulted at every stage against the original name, so a line added later rescues an archived branch without restoring it. The policy runs from the default branch only; --max-actions caps a run at 50 so the ~700 branches already past 30 days drain over weeks.

@Boss2002n
Boss2002n requested review from a team, gyohuangxin and zufayu and a lite review from Copilot September 17, 2026 04:11
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5617 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

@github-actions github-actions Bot changed the title Satya/stale branch archive [CI] Satya/stale branch archive Sep 17, 2026
@github-actions github-actions Bot added the CI label Sep 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The workflow permits shell injection, while race conditions and partial API failures can lose commits or leave cleanup permanently stuck.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds an opt-in weekly workflow to archive stale branches, notify owners, and later delete archived refs.

Changes:

  • Adds GitHub Actions scheduling, dry-run controls, and action limits.
  • Implements branch lifecycle management through GitHub APIs.
  • Adds checked-in branch exemption patterns.
File summaries
File Description
.github/workflows/stale-branches-archive.yml Runs the stale-branch lifecycle workflow.
.github/scripts/archive_stale_branches.py Implements scanning, archiving, notices, and deletion.
.github/stale-branch-exemptions.txt Defines protected branch names and patterns.
Review details

Suppressed comments (1)

.github/scripts/archive_stale_branches.py:321

  • [verified] name is interpolated raw into the REST URL. Git permits # in a branch name such as feature/#42, but urllib treats #42 as a URI fragment, so this DELETE reaches the wrong ref and leaves cleanup stuck; the same construction is used for the live-branch delete at line 225. Author must URL-encode ref path components before constructing REST paths.
            api.write("DELETE", f"/git/refs/heads/{name}")
  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 17, 2026 04:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The cleanup can misidentify shared-commit markers and delete incorrectly encoded or concurrently changed refs.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

.github/scripts/archive_stale_branches.py:219

  • This endpoint is paginated, but the helper reads only page 1. Once a commit has more than 100 comments and the bot marker is outside that page, the script treats the marker as absent, so it can repost archive/notice comments and fail to honor the intended notice clock. Author must follow the pagination links (or otherwise search all comment pages) before deciding that a marker is missing.
  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Destructive branch operations have unresolved pagination, exemption-race, restore, and failure-handling issues.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

.github/scripts/archive_stale_branches.py:256

  • [verified] This only reads the first 100 commit comments. Once a commit has more comments, the archived/notice marker may be on another page, so the next run can repost notices indefinitely (or fail to find provenance and strand an archive). Author must paginate this endpoint before deciding a marker is absent.
    .github/scripts/archive_stale_branches.py:395
  • [verified] A user following the notice's "restore the branch" command recreates the original ref at the old archived commit, whose committer date is still more than 30 days old. On the next run this path archives/deletes that restored ref again, so the advertised one-command rescue does not keep it unless the user also creates a new commit or edits the exemption list. Author must detect a restored archive or change the flow/message so restoring the ref actually opts it out.
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The destructive workflow has confirmed lifecycle, security, and archive-safety issues.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

.github/scripts/archive_stale_branches.py:428

  • [verified] Restoring the branch with the command printed in the notice recreates it at the old archived commit, but this live-branch path only checks commit age. On the next weekly run that still-old tip is at least --stale-days old, so it is moved to a new archive and deleted again; the advertised restore does not keep the branch. Author must recognize a restored/provenance-marked live branch (or require a new commit or explicit exemption) before re-archiving it.
    .github/scripts/archive_stale_branches.py:460
  • [verified] Deleting the notice comment does not stop deletion: once notice is absent and the archive is at least 30 days old, this path calls give_notice again on the next run, and the later age check can delete the archive. That contradicts the documented per-branch opt-out and “only happens while it stands” message. Author must add a durable opt-out signal or change the lifecycle and user-facing contract so a deleted notice cannot be silently recreated.

.github/scripts/archive_stale_branches.py:365

  • [verified] The notice's restore command has the same shell-injection problem: the original branch name is emitted raw into a copy-paste shell command. A branch containing shell metacharacters can change what the maintainer executes when following the notice. Author must emit shell-quoted refs here as well as in the archive comment.
                f"```\ngit push origin {branch['name']}:{original}\n```\n\n"
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 05:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Branch URL handling, fork PR detection, comment pagination, and the documented notice opt-out currently have correctness issues.

Review details

Suppressed comments (5)

Previously missed (1) — in code that hasn't changed since the last review.

.github/scripts/archive_stale_branches.py:241

  • head.ref is only a branch in this repository when the PR head repository is this repository. As written, an open PR from a fork named (for example) feature/foo exempts an unrelated local feature/foo, potentially preventing its cleanup for as long as the fork PR remains open. Add the head-repository check before adding head.ref; keep the base branch exemption unconditional.

This issue also appears in the following locations of the same file:

  • line 248
  • line 268
  • line 284
  • line 468

.github/scripts/archive_stale_branches.py:248

  • The GitHub ref endpoint requires the slash in a branch name to be URL-escaped, but safe='/' leaves it as a path separator. For a normal branch such as feature/foo, this can make ref_sha return 404/None, so every archive attempt is reported as having moved and the branch is never processed. Encode the branch component with safe=''.
        ref = api.get(f"/git/ref/heads/{urllib.parse.quote(name, safe='/')}")

.github/scripts/archive_stale_branches.py:268

  • The branches endpoint treats {branch} as one path parameter, so leaving / unescaped breaks common names such as feature/foo. still_exempt then treats the live branch as missing and archive() leaves it untouched, while archived branches with slashes cannot pass the same guard. Quote the branch name as a single path component.
        branch = api.get(f"/branches/{urllib.parse.quote(name, safe='/')}")

.github/scripts/archive_stale_branches.py:472

  • The notice text promises that deleting this comment is the per-branch opt-out, but the next run enters this block again once the archive is old enough and posts a fresh notice. The archive will therefore still be deleted after another notice period unless the user keeps deleting comments; either persist an opt-out or change the documented behavior to a reset/pause. Author must make the implementation and contract agree.
        if notice is None:
            if (today - archived_on).days < args.archive_days:
                return None
            return give_notice(
                api, branch, original, today + dt.timedelta(days=args.notice_days)

.github/scripts/archive_stale_branches.py:284

  • This only reads the first 100 commit comments. The workflow deliberately puts markers on commits, and many branch refs can share one commit, so a marker beyond page 1 is not found: archive comments can be duplicated and notice/deletion processing can be skipped or restarted on every run. Paginate the endpoint before searching for markers.
    return api.get(f"/commits/{sha}/comments?per_page=100") or []
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@zufayu

zufayu commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

ROCm/aiter PR #5617 — [CI] Satya/stale branch archive

Adds an opt-in weekly workflow that moves branches with no commits for 30 days to archive/<date>/<name> refs, gives notice, then deletes the archive ref two weeks later, skipping protected branches, open-PR refs and a checked-in exemption list.

Review (advisory): 🔴 HIGH RISK
Validation (deterministic): N/A — no runtime surface changed
Perf (advisory): N/A — no runtime surface changed

🔴 [verified] archive_stale_branches.py:468-473 re-posts a fresh delete notice whenever the notice comment is absent and the archive is past 30 days, so the per-branch opt-out promised by the module docstring (lines 11-13, "deleting that comment stops the deletion") and by the notice text itself (lines 379-380, "the deletion only happens while it stands") does not exist — a user who deletes the notice per its own instruction gets a new one the next Monday and the archive ref is deleted 14 days later (confirmed by driving the script against a mock API: run 2 re-noticed, run 3 deleted). Author must make a missing notice on an archive past archive-days mean opted-out, or rewrite the docstring and notice text to say the clock restarts.

⚠️ [verified] The restore command both bot comments print (archive_stale_branches.py:350, 378) recreates the branch at its old tip commit, and act() line 439 judges staleness only by that tip's committedDate, so the next run re-archives the restored branch and deletes the ref again — "To keep it, restore the branch" (line 377) keeps nothing unless the user also pushes a commit or edits the exemption list (confirmed against a mock API: a branch restored at its old tip was re-archived on the very next run). Author must state restore-plus-new-commit in the notice, or teach act() to recognize a branch restored from an archive it created.

⚠️ [verified] pr_branches() at archive_stale_branches.py:240 adds pull["head"]["ref"] without checking the head repository, so an open PR from a fork exempts an unrelated same-named local branch for as long as the PR stays open — 12 such collisions exist in ROCm/aiter today (666 open PRs, 363 fork heads, 3 of them named "main"), while still_exempt() line 277 correctly scopes its head query to owner:branch, so the scan-time skip and the pre-delete check disagree. Author must ignore head refs whose pull request comes from another repository.

⚠️ [verified] comments() at archive_stale_branches.py:284 reads only the first 100 commit comments (per_page=100, no page loop) and is the sole input to find_marker, so once a tip commit carries more than 100 comments the markers become invisible: notices are re-posted every Monday and the deletion branch at lines 475-482 is never reached, stranding the archive — and this script itself posts one comment per archived branch onto tip commits that several stale branches can share, so the ceiling is reachable in this repo's own operation (frequency inferred, not measured). Author must follow the comment pagination before deciding a marker is absent.

Copilot AI review requested due to automatic review settings September 18, 2026 04:56
@Boss2002n

Copy link
Copy Markdown
Contributor Author

ROCm/aiter PR #5617 — [CI] Satya/stale branch archive

Adds an opt-in weekly workflow that moves branches with no commits for 30 days to archive// refs, gives notice, then deletes the archive ref two weeks later, skipping protected branches, open-PR refs and a checked-in exemption list.

Review (advisory): 🔴 HIGH RISK Validation (deterministic): N/A — no runtime surface changed Perf (advisory): N/A — no runtime surface changed

🔴 [verified] archive_stale_branches.py:468-473 re-posts a fresh delete notice whenever the notice comment is absent and the archive is past 30 days, so the per-branch opt-out promised by the module docstring (lines 11-13, "deleting that comment stops the deletion") and by the notice text itself (lines 379-380, "the deletion only happens while it stands") does not exist — a user who deletes the notice per its own instruction gets a new one the next Monday and the archive ref is deleted 14 days later (confirmed by driving the script against a mock API: run 2 re-noticed, run 3 deleted). Author must make a missing notice on an archive past archive-days mean opted-out, or rewrite the docstring and notice text to say the clock restarts.

⚠️ [verified] The restore command both bot comments print (archive_stale_branches.py:350, 378) recreates the branch at its old tip commit, and act() line 439 judges staleness only by that tip's committedDate, so the next run re-archives the restored branch and deletes the ref again — "To keep it, restore the branch" (line 377) keeps nothing unless the user also pushes a commit or edits the exemption list (confirmed against a mock API: a branch restored at its old tip was re-archived on the very next run). Author must state restore-plus-new-commit in the notice, or teach act() to recognize a branch restored from an archive it created.

⚠️ [verified] pr_branches() at archive_stale_branches.py:240 adds pull["head"]["ref"] without checking the head repository, so an open PR from a fork exempts an unrelated same-named local branch for as long as the PR stays open — 12 such collisions exist in ROCm/aiter today (666 open PRs, 363 fork heads, 3 of them named "main"), while still_exempt() line 277 correctly scopes its head query to owner:branch, so the scan-time skip and the pre-delete check disagree. Author must ignore head refs whose pull request comes from another repository.

⚠️ [verified] comments() at archive_stale_branches.py:284 reads only the first 100 commit comments (per_page=100, no page loop) and is the sole input to find_marker, so once a tip commit carries more than 100 comments the markers become invisible: notices are re-posted every Monday and the deletion branch at lines 475-482 is never reached, stranding the archive — and this script itself posts one comment per archived branch onto tip commits that several stale branches can share, so the ceiling is reachable in this repo's own operation (frequency inferred, not measured). Author must follow the comment pagination before deciding a marker is absent.

fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The destructive ref lifecycle has unresolved concurrency and API-rate-limit risks.

Review details

Suppressed comments (1)

.github/scripts/archive_stale_branches.py:394

  • [verified] The delete is leased only against the original ref. After archive/date/name is created at sha, another writer can move or delete that ordinary branch before _finish_archive; this code will still delete the original and leave no archive of that commit. Author must make archive refs immutable/protected or use an atomic compare-and-swap protocol that verifies the archive before deleting the source.
    reason = still_exempt(api, name)
    if reason:
        return f"archived {name} -> {target}; original kept, {reason}"
    if api.delete_branch(name, sha):
        return f"archived {name} -> {target}"
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Slash-containing branch names are mishandled, and pre-existing same-SHA archive refs can be incorrectly adopted and deleted.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 Medium severity

Open (3)

Weekly, off until STALE_BRANCHES_ARCHIVE is 'true'. A branch with no commits
for 30 days is copied to archive/<date>/<name> and its ref removed; 30 days
later a deletion notice is posted; 14 days after that the archive ref is
deleted. 74 days end to end, restorable at any stage with
git push origin archive/<date>/<name>:<name>, which both bot comments print.

No stored state: the archive date is in the ref name, the notice date is the
bot's notice comment. Deleting that comment opts a branch out. Only refs this
workflow made are managed -- the bot's archiving comment naming the ref is the
provenance -- and markers name their ref, so two branches on one commit cannot
share a clock.

Deletion is a leased git push (--force-with-lease), the only server-side
compare-and-swap available; protection and open-PR head/base membership are
re-checked immediately before it. Exemptions are the checked-in
.github/stale-branch-exemptions.txt, consulted at every stage against the
original name, so a line added later rescues an already-archived branch. The
job runs the policy from the default branch only, and --max-actions caps a run
at 50 so the ~700 branches already past 30 days drain over weeks.

Verified against a fake repository: staleness, notice and deletion thresholds
either side of the boundary; strangers' archive-shaped refs and impossible
dates ignored; a collaborator's pasted notice ignored; two refs on one commit
kept apart; a branch that moved, or became a PR base, mid-run left alone; a
push failure or an unexpected 422 leaves the branch intact and the job red;
restore commands survive shell metacharacters in a ref name.
Copilot AI review requested due to automatic review settings September 22, 2026 12:59
@Boss2002n
Boss2002n force-pushed the satya/stale_branch_archive branch from 5a5cdd2 to 3f592e8 Compare September 22, 2026 12:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Branch encoding, restoration, opt-out, and comment pagination bugs can prevent or repeat destructive lifecycle actions.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Medium severity

Open (4)

Copilot AI lite review requested due to automatic review settings October 7, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved lifecycle, opt-out, pagination, path-handling, and fork-PR exemption issues remain.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (4)

@rahulbatra85

Copy link
Copy Markdown
Contributor

LGTM to except do you want to address copilot comments?

@Boss2002n
Boss2002n merged commit 991bf62 into main Oct 8, 2026
@Boss2002n
Boss2002n deleted the satya/stale_branch_archive branch October 8, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants