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
{{ message }}
Repository navigation
Commit bc98875
Browse filesBrowse the repository at this point in the historyBrowse files
fix(drift-sync): keep one rolling needs-human PR instead of a sibling per changeset
The changeset key dedups an identical family set only. While a decision
waited, every new or vanished family minted a new key, and the needs-human
step opened a new PR beside the one still open: #406/#409/#411/#412 were
open together (2026-09-02..09-08), and #475/#477/#481/#483/#484
(2026-09-22..10-02).
Now a run whose set differs is written onto the open rolling PR: its
commit is force-pushed (leased to the head that was inspected) onto that
PR's branch, and the body is rewritten with this run's markers and notes.
A new rolling PR lives on drift-needs-human/rolling-<date>-<run id>, a
branch with no changeset key, because a key there would go stale once
later runs rewrite the content.
The rolling PR is rewritten only when it is still open, was opened by the
drift bot (app/copilotkit-bot), and every commit on it is the bot's own.
A human's commit leaves it alone and opens no sibling. A PR that cannot
be read fails closed.
The tests replay two runs through the real step body: run 1's pushed
branch and created body become run 2's open PR.
# ---- THE ROLLING PR: UPDATE IT, DO NOT OPEN A SIBLING --------------------
1584
+
# Reached only after DUP (no open PR carries this key), REJECTED (no human
1585
+
# closed this key) and the no-new-commit return have all declined, so this
1586
+
# run's set is un-proposed. If the bot's rolling PR is open, this run's
1587
+
# commit goes onto ITS branch and its body is rewritten. Read from UNMERGED:
1588
+
# the listing audited complete above, which holds every OPEN PR. The OLDEST
1589
+
# open rolling PR opened by DRIFT_BOT_LOGIN is the one.
1590
+
if [ -z "${DRIFT_BOT_LOGIN:-}" ]; then
1591
+
echo "::error::DRIFT_BOT_LOGIN is not set, so this run cannot tell the drift bot's rolling PR from a human's — refusing to either rewrite one or open a sibling beside it."
| sort_by(.number) | .[0] // empty' 2>"$ROLLING_ERR")"; then
1601
+
echo "::error::selecting the open rolling needs-human PR FAILED, so this run cannot tell whether to update it instead of opening another — refusing to risk a duplicate: $(cat "$ROLLING_ERR" 2>/dev/null)"
# THE GUARD, read LIVE: still OPEN, opened by the drift bot, on its rolling
1609
+
# branch, and EVERY commit on it made by the bot's own git identity (the
1610
+
# gitcfg step's). A commit by anyone else means a human is working on it,
1611
+
# and force-pushing would destroy that work. Anything this run cannot read
1612
+
# fails CLOSED: neither a force-push nor a sibling.
1613
+
BOT_EMAIL="$(git config user.email || true)"
1614
+
if [ -z "$BOT_EMAIL" ]; then
1615
+
echo "::error::no git user.email is configured, so the drift bot's commits on PR #${R_NUMBER} cannot be told from a human's — refusing to rewrite it or open a sibling."
1616
+
exit 1
1617
+
fi
1618
+
if ! R_VIEW="$(gh pr view "$R_NUMBER" --json number,state,author,headRefName,headRefOid,commits 2>&1)"; then
1619
+
echo "::error::open rolling PR #${R_NUMBER} could not be read (${R_VIEW}), so this run neither force-pushes over it nor opens a sibling beside it — refusing."
1620
+
exit 1
1621
+
fi
1622
+
if ! R_VERDICT="$(printf '%s' "$R_VIEW" | jq -r --arg e "$BOT_EMAIL" --arg b "$R_BRANCH" '
1623
+
if ((.commits | type) != "array") or ((.commits | length) == 0)
1624
+
or ((.headRefOid // "") == "")
1625
+
then "unknown:it came back with no commit list or no head commit"
1626
+
elif .state != "OPEN" then "refuse:it is \(.state), not OPEN"
then "refuse:it carries a commit NOT made by the drift bot, so a human is working on it"
1633
+
else "ok" end' 2>&1)"; then
1634
+
echo "::error::open rolling PR #${R_NUMBER} came back unusable (${R_VERDICT}) — refusing to rewrite it or open a sibling."
1635
+
exit 1
1636
+
fi
1637
+
case "$R_VERDICT" in
1638
+
ok) ;;
1639
+
refuse:*)
1640
+
# No sibling either: that is the duplicate this exists to prevent. The
1641
+
# decision waits until a human merges or closes that PR, so the alert
1642
+
# names it: resolving it is the action that unblocks this changeset.
1643
+
echo "::warning::open needs-human PR #${R_NUMBER} is not the bot's to rewrite: ${R_VERDICT#refuse:}. So changeset ${CHANGESET_KEY} is NOT proposed this run — that PR is left alone and no sibling is opened. Merge or close #${R_NUMBER} and the next run proposes it."
1644
+
emit_pr "$R_NUMBER" "$R_URL"
1645
+
exit 0
1646
+
;;
1647
+
*)
1648
+
echo "::error::open rolling PR #${R_NUMBER} cannot be proven safe to rewrite (${R_VERDICT#unknown:}) — refusing to rewrite it or open a sibling."
echo "Pushed ${HEAD_SHA} onto rolling needs-human PR #${R_NUMBER}'s branch ${R_BRANCH}"
1659
+
if ! EDIT_ERR="$(gh pr edit "$R_NUMBER" --title "$PR_TITLE" --body-file "$PR_BODY_FILE" 2>&1)"; then
1660
+
echo "::error::pushed changeset ${CHANGESET_KEY} onto PR #${R_NUMBER}, but rewriting its body FAILED, so its markers still name the OLD changeset (the next run rewrites it again): ${EDIT_ERR}"
1661
+
exit 1
1662
+
fi
1663
+
echo "needs-human: updated rolling PR #${R_NUMBER} IN PLACE to changeset ${CHANGESET_KEY} — not opening a sibling"
1664
+
emit_pr "$R_NUMBER" "$R_URL"
1665
+
exit 0
1666
+
fi
1667
+
1518
1668
# A PER-NOTE OVERLAP IS REPORTED. IT DOES NOT DECIDE THE RUN.
1519
1669
#
1520
1670
# This loop used to `exit 0` the whole step on the FIRST note that some
@@ -1550,61 +1700,19 @@ jobs:
1550
1700
fi
1551
1701
done
1552
1702
1553
-
# Distinct branch (never collides with the ok-applied fix/drift-* branch).
1554
-
# The changeset key is the LAST segment on purpose: it is the
1555
-
# body-INDEPENDENT anchor the marker self-heal above uses to recognise this
1556
-
# PR again if a human ever deletes its body markers. Keep it last — the
0 commit comments