Skip to content

Commit a5d5e62

Browse files
Merge branch 'main' into fix/zoo-gateway-models-session-cache
2 parents d8df7e3 + 13cb03a commit a5d5e62

59 files changed

Lines changed: 3264 additions & 343 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/label-pr-review-state.yml‎

Lines changed: 95 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,19 @@ jobs:
262262
263263
// A queue-superseded shard leaves no other trace in the logs.
264264
core.info(`Concurrency group: ${process.env.CONCURRENCY_GROUP}`);
265+
// Turn labels reconcile exclusively among themselves: exactly one
266+
// can be true. has-conflicts is deliberately NOT in this group
267+
// (issue #2089) — whether the branch has conflicts is an
268+
// independent fact that can coexist with any turn. It is managed
269+
// only by reconcileConflictFlag below: set on a known dirty read,
270+
// removed on a known read that is not dirty, untouched while
271+
// mergeability is unknown.
265272
const stateLabels = [
266273
'awaiting-author',
267274
'awaiting-coderabbit',
268275
'awaiting-ready',
269276
'awaiting-maintainer',
270277
'awaiting-review', // Legacy label removed during reconciliation.
271-
'has-conflicts',
272278
];
273279
const labelDefinitions = [
274280
{
@@ -364,9 +370,13 @@ jobs:
364370
}
365371
}
366372
367-
// Strips stateLabels from a PR, optionally keeping one desired label.
368-
// Callers skip this entirely while mergeability is unknown (see the
369-
// hoisted check below), so no keep-list is needed.
373+
// Strips stateLabels (turn labels) from a PR, optionally keeping
374+
// one desired label. Callers skip this entirely while mergeability
375+
// is unknown (see the hoisted check below), so no keep-list is
376+
// needed. has-conflicts lives outside this group: it is the
377+
// independent conflict flag managed by reconcileConflictFlag, so
378+
// turn-label reconciliation — including the outer failure cleanup
379+
// — never strips or sets it.
370380
// Stale-clock labels are owned by the stale step below and are never
371381
// touched here: stripping one on a transient CI or mergeability flap
372382
// would erase a live warning and restart its close grace (issue #2076).
@@ -415,6 +425,50 @@ jobs:
415425
}
416426
}
417427
428+
// Reconciles the independent has-conflicts flag (issue #2089).
429+
// `present` is a mergeability fact, so callers pass a known read
430+
// only: true for a known dirty read, false for a known read that
431+
// is not dirty. While mergeability is unknown no caller runs, so
432+
// the flag freezes together with the turn labels. A conflicted PR
433+
// must never sit in the maintainer queue, so every conflict
434+
// branch pairs this call with reconcileLabels(pr, 'awaiting-author').
435+
async function reconcileConflictFlag(pr, present) {
436+
if (isReadOnlyRun && isForkPR(pr)) {
437+
core.info(`PR #${pr.number}: fork PR on a read-only run — skipping label mutation`);
438+
return;
439+
}
440+
const hasLabel = pr.labels.some(label => label.name === 'has-conflicts');
441+
if (present === hasLabel) return;
442+
try {
443+
if (present) {
444+
await github.rest.issues.addLabels({
445+
owner, repo, issue_number: pr.number, labels: ['has-conflicts'],
446+
});
447+
if (!pr.labels.some(label => label.name === 'has-conflicts')) {
448+
pr.labels.push({ name: 'has-conflicts' });
449+
}
450+
} else {
451+
await github.rest.issues.removeLabel({
452+
owner, repo, issue_number: pr.number, name: 'has-conflicts',
453+
});
454+
pr.labels = pr.labels.filter(label => label.name !== 'has-conflicts');
455+
}
456+
} catch (err) {
457+
if (err.status === 404 && !present) {
458+
pr.labels = pr.labels.filter(label => label.name !== 'has-conflicts');
459+
return;
460+
}
461+
// The flag already decided this run's label state, so a
462+
// failed flag write must fail closed: mark the wrapper
463+
// error so the outer cleanup keeps the current state
464+
// labels exactly like the unknown-mergeability freeze
465+
// instead of stripping them.
466+
const error = new Error(`Could not reconcile has-conflicts label: ${err.message}`);
467+
error.preserveStateLabels = true;
468+
throw error;
469+
}
470+
}
471+
418472
async function findReviewGuide(pr) {
419473
const comments = await github.paginate(github.rest.issues.listComments, {
420474
owner, repo, issue_number: pr.number, per_page: 100,
@@ -772,10 +826,18 @@ jobs:
772826
}
773827
774828
if (prDetail.mergeable === false && prDetail.mergeable_state === 'dirty') {
775-
core.info(`PR #${pr.number}: has merge conflicts — labeling has-conflicts`);
829+
core.info(
830+
`PR #${pr.number}: has merge conflicts — ` +
831+
'labeling has-conflicts and awaiting-author'
832+
);
776833
await updateReviewGate(pr, 'conflict', false);
777834
await setCodeRabbitReviewActive(pr, false);
778-
await reconcileLabels(pr, 'has-conflicts');
835+
// Conflicts are an independent flag, and a conflicted PR
836+
// always owes the author action (issue #2089): set the
837+
// flag and force the awaiting-author turn label — never
838+
// has-conflicts alone, and never a maintainer-queue label.
839+
await reconcileConflictFlag(pr, true);
840+
await reconcileLabels(pr, 'awaiting-author');
779841
await reconcileCommunityApproval(pr, 'remove');
780842
await updateReviewGuide(pr, 'conflict', existingGuide);
781843
continue;
@@ -787,15 +849,17 @@ jobs:
787849
// `mergeable_state: "unknown"`, GitHub has not finished computing
788850
// the answer, so it says nothing about conflicts and nothing about
789851
// whose turn it is. This run then changes NO state label for the
790-
// PR: every state-label reconcile below is skipped. Acting on
852+
// PR: every state-label reconcile below is skipped, and the
853+
// has-conflicts flag freezes with the turn labels. Acting on
791854
// unknown previously let the normal reconcile swap labels (for
792855
// example has-conflicts to awaiting-author and back on the next
793856
// run's `dirty` read), which flapped labels on unchanged PRs.
794857
// Known-dirty never reaches here (the conflict check above
795-
// handles it first); known-clean reconciles normally. The
796-
// awaiting-maintainer branch below still refetches mergeability
797-
// before the maintainer handoff, because a push between this
798-
// fetch and labeling can change the answer; a known read there
858+
// handles it first); a known read that is not dirty removes
859+
// the flag in the branches below. The awaiting-maintainer
860+
// branch below still refetches mergeability before the
861+
// maintainer handoff, because a push between this fetch and
862+
// labeling can change the answer; a known read there
799863
// re-enables the final reconcile.
800864
let mergeabilityUnknown =
801865
prDetail.mergeable === null || prDetail.mergeable_state === 'unknown';
@@ -907,8 +971,11 @@ jobs:
907971
// mean a conflicting PR got no merge-ref CI run — not that its
908972
// conflicts went away. Unknown mergeability changes no state
909973
// label in this run, so this branch keeps every existing state
910-
// label (has-conflicts included) instead of stripping them; a
911-
// later run with a known read reconciles them.
974+
// label (the has-conflicts flag included) instead of stripping
975+
// them; a later run with a known read reconciles them. On a
976+
// known read the branch got here only because the PR is not
977+
// dirty (the conflict check handles dirty first), so the
978+
// conflict flag is removed along with the turn labels.
912979
if (ciPending || ciFailed) {
913980
core.info(
914981
`PR #${pr.number}: CI ${ciPending ? 'pending' : 'failed'} — ` +
@@ -919,6 +986,7 @@ jobs:
919986
await updateReviewGate(pr, ciPending ? 'ci-pending' : 'ci-failed', false);
920987
await setCodeRabbitReviewActive(pr, false);
921988
if (!mergeabilityUnknown) {
989+
await reconcileConflictFlag(pr, false);
922990
await reconcileLabels(pr, null);
923991
}
924992
await reconcileCommunityApproval(pr, 'remove');
@@ -1147,10 +1215,18 @@ jobs:
11471215
const headChanged = Boolean(latestPrDetail.head?.sha) &&
11481216
latestPrDetail.head.sha !== pr.head.sha;
11491217
if (latestPrDetail.mergeable === false && latestPrDetail.mergeable_state === 'dirty') {
1150-
core.info(`PR #${pr.number}: has merge conflicts — labeling has-conflicts`);
1218+
core.info(
1219+
`PR #${pr.number}: has merge conflicts — ` +
1220+
'labeling has-conflicts and awaiting-author'
1221+
);
11511222
await updateReviewGate(pr, 'conflict', false);
11521223
await setCodeRabbitReviewActive(pr, false);
1153-
await reconcileLabels(pr, 'has-conflicts');
1224+
// Same invariant as the first conflict branch (issue
1225+
// #2089): the flag plus the awaiting-author turn label,
1226+
// so a conflicted PR can never land in the maintainer
1227+
// queue this run was about to grant.
1228+
await reconcileConflictFlag(pr, true);
1229+
await reconcileLabels(pr, 'awaiting-author');
11541230
await reconcileCommunityApproval(pr, 'remove');
11551231
await updateReviewGuide(pr, 'conflict', existingGuide);
11561232
continue;
@@ -1212,6 +1288,10 @@ jobs:
12121288
await updateReviewGuide(pr, phase, existingGuide);
12131289
}
12141290
if (!mergeabilityUnknown) {
1291+
// The read that re-enabled this reconcile is known and not
1292+
// dirty (the conflict branches handle dirty first), so the
1293+
// conflict flag comes off whenever the turn labels reconcile.
1294+
await reconcileConflictFlag(pr, false);
12151295
await reconcileLabels(pr, desiredLabel);
12161296
}
12171297
await reconcileCommunityApproval(pr, communityDecision);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Weekly release kickoff
2+
3+
# Kicks off the weekly Zoo Code release. The message pings one maintainer per
4+
# week as a reminder to review and approve the release PR, tag the release
5+
# branch, and approve the marketplace-production deployment, then @mentions
6+
# zoomote as the visible cue of who cuts the release. Webhook-posted mentions
7+
# do not trigger Roomote (confirmed by test), so the release prep (release PR
8+
# per .roo/commands/release.md, posted in the release channel) runs from the
9+
# separate Roomote automation at the same time.
10+
#
11+
# Requires two repo secrets:
12+
# - DISCORD_RELEASE_WEBHOOK_URL: Discord webhook for the channel that receives
13+
# the kickoff message. The job fails (noisily) if it is unset.
14+
# - DISCORD_RELEASE_MAINTAINERS: space-separated Discord user mentions in the
15+
# <@USER_ID> form, for example "<@123456789012345678> <@987654321098765432>".
16+
# Use numeric user IDs, not @handles. Only the <@USER_ID> form pings the user.
17+
# The rotation pings one maintainer per week, anchored to 2026-07-17 (same
18+
# anchor as the previous rotation). If the secret is unset, the message uses
19+
# a generic "Maintainers" greeting.
20+
#
21+
# The zoomote Discord user ID is not sensitive, so it is hardcoded below
22+
# instead of stored as a secret.
23+
24+
on:
25+
schedule:
26+
# Friday at 7:00pm ET (23:00 UTC during daylight saving time).
27+
# This fixed UTC cron fires at 6:00pm ET while the US is on EST.
28+
- cron: "0 23 * * 5"
29+
workflow_dispatch:
30+
31+
permissions: {}
32+
33+
concurrency:
34+
group: release-kickoff
35+
# A re-run produces an identical message, so cancel a stale/duplicate run
36+
# rather than risk posting twice.
37+
cancel-in-progress: true
38+
39+
jobs:
40+
kickoff:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Post release kickoff to Discord
44+
env:
45+
DISCORD_RELEASE_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
46+
DISCORD_RELEASE_MAINTAINERS: ${{ secrets.DISCORD_RELEASE_MAINTAINERS }}
47+
ZOOMOTE_MENTION: "<@1527781613927399614>"
48+
run: |
49+
set -euo pipefail
50+
read -r -a maintainers <<< "${DISCORD_RELEASE_MAINTAINERS:-}"
51+
if [ ${#maintainers[@]} -eq 0 ]; then
52+
on_deck="Maintainers"
53+
else
54+
anchor_date="2026-07-17"
55+
seconds_since_anchor=$(($(date -u +%s) - $(date -u -d "$anchor_date" +%s)))
56+
weeks_since_anchor=$((seconds_since_anchor / 604800))
57+
on_deck="${maintainers[$((weeks_since_anchor % ${#maintainers[@]}))]}"
58+
fi
59+
60+
message=$(cat <<EOF
61+
**Weekly release kickoff**
62+
63+
${on_deck} — reminder: you are on deck for this week's release. When the release PR is up:
64+
65+
1. Review and approve the release PR.
66+
2. Tag the release branch tip (\`v[version]\`) to trigger the Marketplace publish workflow.
67+
3. Approve the deployment when the \`marketplace-production\` environment requests it.
68+
4. After publishing succeeds, add the release PR to the merge queue.
69+
70+
${ZOOMOTE_MENTION} prepare this week's Zoo Code release per \`.roo/commands/release.md\` and post the release PR in this channel.
71+
72+
Avoid merging or rebasing the release branch before publishing, so the approved tag keeps the intended commit SHA.
73+
74+
More detail: https://discord.com/channels/1497384592494297201/1498024845945081999/1512914847124291667
75+
EOF
76+
)
77+
78+
payload=$(jq -n --arg content "$message" '{content: $content, allowed_mentions: {parse: ["users"]}}')
79+
curl --fail-with-body --silent --show-error \
80+
--header 'Content-Type: application/json' \
81+
--data "$payload" \
82+
"$DISCORD_RELEASE_WEBHOOK_URL"
83+
84+
- name: Notify on failure
85+
if: failure()
86+
env:
87+
DISCORD_RELEASE_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
88+
run: |
89+
set -euo pipefail
90+
payload=$(jq -nc --arg content "⚠️ release-kickoff workflow failed — see the Actions runs." '{content: $content}')
91+
curl --fail-with-body --silent --show-error \
92+
--header 'Content-Type: application/json' \
93+
--data "$payload" \
94+
"$DISCORD_RELEASE_WEBHOOK_URL" || true

0 commit comments

Comments
 (0)