CI: let only main's tip run open or close the pinned main-failure issue
User description
Runs on main finish out of order. On 2026-10-13 the tip's green run 38437403981 (c67fd996) closed #3099 at 17:27Z, and the older d3fda691 run 38434332110 finished at 17:33Z and reopened it for a failure main no longer had.
Change: main-failure-routing reads main's current tip (repos.getBranch) before touching any issue. If the run's github.sha is not the tip, it logs and returns, whether the run was red or green. A superseded run still shows red or green in its own checks. It just doesn't speak for main. Fails open: if the tip can't be read, it routes as before, so an alert is never lost.
Trade-off: a green re-run of a superseded commit no longer closes the issue. Only the tip's run does.
Tests: tests/ci-main-failure-routing.test.ts now pins the tip comparison, its position before any issue read, close or reopen, and the fail-open path. 22/22 pass locally. Non-blocking follow-up. Auto-merge is not enabled.
Summary by cubic
Prevents stale runs on main from opening, closing, or reopening the pinned main-failure issue when they finish after a newer run has already routed. Runs finish out of order: on 2026-10-13 the tip's green run closed #3099, then an older red run reopened it minutes later.
main-failure-routing now records the commit each run routes as a stamp in the issue body and orders by it: a run whose commit is behind the last routed one stands down, and one ahead speaks, so a merge streak can't suppress alerts. No concurrency group is used — that would keep the pending job in run-finish order and could cancel a newer commit's routing — instead the stamp is re-read right before each write so the check and the mutation can't interleave. It fails open: if the ordering can't be read, it routes as before so an alert is never lost.
Bug Fixes
- A superseded green run no longer closes the issue; only the newest run to report does.
- Pins the clock in the team-calendar give-away test; it otherwise flips to the urgent path from 14 Oct 2026 and fails on every run.
- Tests execute the script against a
compareCommitsmock, covering the fail-open path, the merge-streak case, and the re-check-before-write block.
CodeAnt-AI Description
Prevent stale CI runs from changing the main-failure issue
What Changed
- Runs older than the commit already recorded on the issue no longer reopen, update, or close it.
- Green runs record their commit even when the issue is already closed, preventing an older failure from reopening it.
- A run can still report a failure if no newer commit has been routed; if commit ordering cannot be checked, the alert still routes.
Impact
✅ Fewer stale main-failure alerts
✅ Green main stays clear of older failure reports
✅ Alerts retained during rapid merges
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.