Skip to content

fix(ci): stop hourly prune from deleting the just-published release - #13266

Merged
AmethystLiang merged 2 commits into
mainfrom
fix-hourly-prune-self-delete
Aug 8, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
fix-hourly-prune-self-delete

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The hourly macOS pipeline (.github/workflows/hourly-mac-build.yml) has been publishing to stablyai/orca-hourly and then immediately deleting the release it just published.

Bug (publish-then-self-prune):

  1. HOURLY_RETAIN_COUNT=72 and the repo is already at 72 non-draft releases (at the cap).
  2. Nearly every non-draft release shares the same createdAt (2026-08-02T09:48:30Z), so sort_by(.createdAt) does not rank by recency.
  3. With tied createdAt, jq’s stable sort + reverse flips the default newest-first list, so the just-published release lands past the retain window.
  4. Prune then deletes it with --cleanup-tag. The job still exits 0.

Evidence: run 31276157806 published v1.4.177-hourly.202608082009 then logged Pruning v1.4.177-hourly.202608082009. That tag is now 404. Last surviving published hourly at diagnosis was v1.4.177-hourly.202608080021.

Fix

In the prune step:

  1. Sort by real recency — publishedAt (empty fallback), then tagName (…-hourly.YYYYMMDDHHMM) as a deterministic tie-break. Drafts still excluded from the retention count.
  2. Hard-guard the just-published tag with correct retain math — partition $TAG to the front of the sorted list before the retain slice so this run always has a seat in the keep window. (Excluding $TAG before the slice would permanently keep retain+1; skipping only in the delete loop under-prunes when sort is still wrong.)
  3. Belt-and-suspenders delete skip — if $TAG still appears in the stale list, log a ::warning:: and do not delete.
  4. Gate prune on publish_live success — only reshape retention after a live publish; failed runs leave pruning to the next successful one (draft cleanup stays on the failure path).
  5. Keep --cleanup-tag for genuinely stale releases.

Screenshots

No visual change.

Testing

  • Local gh/jq simulation against live stablyai/orca-hourly (72 non-draft releases)
    • publishedAt order keeps …202608080021 first
    • retain=72 → nothing pruned
    • retain=71 → only oldest by publishedAt pruned
    • buggy createdAt sort without protect reproduces self-delete of newest
    • force-front protect keeps newest out of stale even under buggy sort
    • synthetic partition cases: protect newest / mid / bad-order all keep protected tag and still prune
  • pnpm lint / pnpm typecheck / pnpm test / pnpm build — N/A (workflow YAML only)
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed — no unit harness for this inline workflow jq; verified with live API + synthetic jq fixtures instead of a permanent test package
  • Merge; confirm next Hourly macOS Dev Build run publishes a tag that remains listable (not pruned in the same run)

AI Review Report

Reviewed the branch end-to-end (workflow control flow, retain math, sort stability, GHA step gating, live API fields).

Main risks checked:

  • Self-delete of just-published tag at retain cap (root bug)
  • Retain-count drift from naive protect strategies
  • Draft vs non-draft counting
  • Prune running on failed publish / empty $TAG
  • publishedAt null / tied timestamps
  • Cross-platform: workflow runs on macOS Blacksmith runners only; shell is bash; no app UI, shortcuts, paths, or Electron platform branches touched

Flagged and fixed in follow-up commit:

  1. Loop-only skip under-prunes when sort is still wrong (keeps extras only when skip fires; does not force a correct oldest delete).
  2. Exclude-$TAG-before-slice permanently keeps retain+1 after every successful publish — rejected.
  3. Replaced with partition $TAG to front, then slice, plus warning skip as backup.
  4. Tightened step if to steps.publish_live.outcome == 'success'.

Verified as OK:

  • gh release list --json publishedAt is populated for all current non-draft hourlies
  • Default success() previously already skipped prune on hard failures; explicit publish gate is clearer and matches intent
  • No Windows/Linux app surface in this change

Security Audit

  • No new secrets, auth paths, or token scopes. Reuses existing hourly GitHub App install token (app_token_publish) already required for publish/delete.
  • $TAG is interpolated into a jq string after " escaping; tag values are pipeline-controlled (v*-hourly.YYYYMMDDHHMM), not user input.
  • Prune still requires write token to orca-hourly only; no change to stablyai/orca write permissions (contents: read at workflow level).
  • --cleanup-tag retained for intentional stale deletes only; just-published tag is protected.
  • No dependency, IPC, or path-traversal surface.

Notes

  • macOS-only scheduled workflow; no Linux/Windows client changes.
  • After merge, the next successful hourly cron is the real integration proof (tag must remain listable after the prune step logs).
  • Related: many historical hourlies share one createdAt from bulk import; do not reintroduce createdAt ordering for retention.
  • Out of scope: changing HOURLY_RETAIN_COUNT, re-publishing deleted hourlies, adhoc channel prune (uses age cutoff, not retain count).

Hourly prune sorted non-draft releases by createdAt, but nearly every
orca-hourly release shares one createdAt from bulk import. At the retain
cap, stable sort + reverse put the newest release past the window and
immediately deleted it with --cleanup-tag.

Sort by publishedAt (tagName as tie-break) and hard-skip the tag this run
just published so prune cannot self-delete.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The hourly Mac build workflow now prunes releases only after successful publication. It receives and protects the current release tag. It excludes draft releases. It sorts releases by publishedAt, with tagName as a deterministic tie-breaker. It skips the current tag during deletion. The workflow no longer uses should_build gating or createdAt ordering.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary fix: preventing hourly pruning from deleting the release published in the same run.
Description check ✅ Passed The description covers the required summary, screenshots, testing, AI review, security audit, and platform-specific notes with detailed verification.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Review found that skipping only in the delete loop under-prunes when sort
is wrong, and excluding TAG before the retain slice would permanently keep
retain+1 releases. Force this run's tag to the front of the sorted list
before slicing so it always has a retain seat and oldest builds still prune.
Also gate prune on publish_live success and warn if TAG still appears stale.
@AmethystLiang
AmethystLiang merged commit 05c3016 into main Aug 8, 2026
45 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#13266)

* fix(ci): stop hourly prune from deleting the just-published release

Hourly prune sorted non-draft releases by createdAt, but nearly every
orca-hourly release shares one createdAt from bulk import. At the retain
cap, stable sort + reverse put the newest release past the window and
immediately deleted it with --cleanup-tag.

Sort by publishedAt (tagName as tie-break) and hard-skip the tag this run
just published so prune cannot self-delete.

* fix(ci): harden hourly prune protect without retain+1 drift

Review found that skipping only in the delete loop under-prunes when sort
is wrong, and excluding TAG before the retain slice would permanently keep
retain+1 releases. Force this run's tag to the front of the sorted list
before slicing so it always has a retain seat and oldest builds still prune.
Also gate prune on publish_live success and warn if TAG still appears stale.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant