You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[drci] Re-render advisor comment until the verdict concludes (alt sentinel) (#8235)
## Problem
The inline AI advisor verdict line (#8202) has two render states under
each new/unclassified failure:
- **in-progress** — a bare `AI verdict:` line + badge image, and
- **concluded** — the line wrapped in `<details>` with the reasoning.
The badge **image** flips server-side the moment the verdict lands (the
`<img>` points at `/api/drci/advisorBadge`, which camo refetches). But
the concluded `<details>` **expand is comment-body text** — it only
appears when the Dr.CI comment is re-rendered.
The 15-min cron (`updateDrciComments`) only re-renders a PR that has
workflow activity in the last `NUM_MINUTES` (30) **or** whose comment
still shows `\d Pending` jobs. A verdict can land seconds *after* the
last render and the PR's CI then go quiet — so the comment stays stuck
on the in-progress line indefinitely. The `body === comment` idempotency
check is fine; it's just never reached, because the PR drops out of the
candidate set.
Observed live on pytorch/pytorch#188479: the verdict landed **44s
after** the comment's last render, and never expanded.
## Fix
Give the advisor `<img>` an `alt` that encodes the outcome:
- in-progress → `alt="AI verdict: pending"` (a sentinel),
- concluded → `alt="AI verdict: <label>"` (`related`, `not related`,
`probably not related`, …).
Then broaden the cron candidate query (`getPRsWithPendingJobInComment` →
`getPRsNeedingCommentRefresh`) to **also** keep open PRs whose comment
still carries the pending sentinel. They re-render every tick until the
verdict concludes; the moment it does, the alt changes (no longer
`pending`) and the PR **self-clears** from the set. Same open-PR +
1-month freshness guards as the existing `\d Pending` branch, so growth
is bounded the same way.
The query matches the **full `alt="AI verdict: pending"` attribute**,
not the bare phrase: advisor summaries are HTML-escaped, so a `"` in a
summary becomes `"` and can never reproduce the real double-quoted
attribute → no false-match. A single shared `ADVISOR_PENDING_ALT_ATTR`
constant drives both the emitted line and the query so they can't drift.
**Bonus:** the verdict outcome is now machine-readable text in the
comment (useful for AI agents reading the comment, or humans with images
off), not only inside the badge SVG.
## Notes
- Forward-looking: comments **already** stuck (rendered before this
change, with no `alt`) won't self-heal — they need a one-time
`@pytorchbot drci` nudge or they age out via the 1-month guard.
- Tests: `advisorBadge.test.ts` + `drci.test.ts` pass; `tsc --noEmit`
clean; lintrunner clean.
Co-authored-by: Ivan Zaitsev <izaitsevfb@meta.com>
0 commit comments