@muggleai/works 5.32.0-staging.283 → 5.32.0-staging.285

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/{chunk-NTEBYUCA.js → chunk-AEJM2CBK.js} +17 -7
  3. package/dist/{chunk-CGKARU5D.js → chunk-TM6IZEKH.js} +8 -5
  4. package/dist/cli.js +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  7. package/dist/plugin/.codex-mcp.json +1 -1
  8. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  9. package/dist/plugin/.cursor-plugin/plugin.json +1 -1
  10. package/dist/plugin/.mcp.json +1 -1
  11. package/dist/plugin/scripts/pr-watch-arm.sh +10 -2
  12. package/dist/plugin/scripts/pr-watch-events.sh +14 -1
  13. package/dist/plugin/scripts/pr-watch-fetch.sh +1 -0
  14. package/dist/plugin/scripts/pr-watch-floors.sh +21 -8
  15. package/dist/plugin/scripts/pr-watch-loop.sh +16 -1
  16. package/dist/plugin/scripts/pr-watch-state.jq +26 -2
  17. package/dist/plugin/scripts/pr-watch-verdict.mjs +6 -1
  18. package/dist/plugin/skills/_shared/pr-followup-helpers/classify.md +12 -0
  19. package/dist/plugin/skills/_shared/pr-followup-helpers/echo-skip.md +1 -0
  20. package/dist/plugin/skills/_shared/session-state-writes.md +1 -1
  21. package/dist/plugin/skills/_shared/telemetry-events/pr-followup-tick.md +1 -1
  22. package/dist/plugin/skills/_shared/vcs/github/conversation-comments.md +22 -0
  23. package/dist/plugin/skills/_shared/vcs/github/top-level-comment.md +2 -2
  24. package/dist/plugin/skills/_shared/vcs/github.md +1 -0
  25. package/dist/plugin/skills/do/address-reviews.md +20 -12
  26. package/dist/plugin/skills/do/input-routing.md +1 -1
  27. package/dist/plugin/skills/do/open-prs/forward.md +1 -1
  28. package/dist/plugin/skills/do/per-comment-replies.md +8 -1
  29. package/dist/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  30. package/dist/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -5
  31. package/dist/plugin/skills/muggle-pr-followup/auto-track.md +1 -1
  32. package/dist/plugin/skills/muggle-pr-followup/bootstrap.md +3 -1
  33. package/dist/plugin/skills/muggle-pr-followup/contract.md +8 -4
  34. package/dist/plugin/skills/muggle-pr-followup/output-templates/inline-reply.md +12 -0
  35. package/dist/plugin/skills/muggle-pr-followup/state-schemas.md +7 -2
  36. package/dist/release-manifest.json +3 -3
  37. package/dist/{src-LYOBYPFZ.js → src-KNX6CG4Z.js} +1 -1
  38. package/package.json +1 -1
  39. package/plugin/.claude-plugin/plugin.json +1 -1
  40. package/plugin/.codex-mcp.json +1 -1
  41. package/plugin/.codex-plugin/plugin.json +1 -1
  42. package/plugin/.cursor-plugin/plugin.json +1 -1
  43. package/plugin/.mcp.json +1 -1
  44. package/plugin/scripts/pr-watch-arm.sh +10 -2
  45. package/plugin/scripts/pr-watch-events.sh +14 -1
  46. package/plugin/scripts/pr-watch-fetch.sh +1 -0
  47. package/plugin/scripts/pr-watch-floors.sh +21 -8
  48. package/plugin/scripts/pr-watch-loop.sh +16 -1
  49. package/plugin/scripts/pr-watch-state.jq +26 -2
  50. package/plugin/scripts/pr-watch-verdict.mjs +6 -1
  51. package/plugin/skills/_shared/pr-followup-helpers/classify.md +12 -0
  52. package/plugin/skills/_shared/pr-followup-helpers/echo-skip.md +1 -0
  53. package/plugin/skills/_shared/session-state-writes.md +1 -1
  54. package/plugin/skills/_shared/telemetry-events/pr-followup-tick.md +1 -1
  55. package/plugin/skills/_shared/vcs/github/conversation-comments.md +22 -0
  56. package/plugin/skills/_shared/vcs/github/top-level-comment.md +2 -2
  57. package/plugin/skills/_shared/vcs/github.md +1 -0
  58. package/plugin/skills/do/address-reviews.md +20 -12
  59. package/plugin/skills/do/input-routing.md +1 -1
  60. package/plugin/skills/do/open-prs/forward.md +1 -1
  61. package/plugin/skills/do/per-comment-replies.md +8 -1
  62. package/plugin/skills/muggle-pr-followup/SKILL.md +1 -1
  63. package/plugin/skills/muggle-pr-followup/arm-watcher.md +5 -5
  64. package/plugin/skills/muggle-pr-followup/auto-track.md +1 -1
  65. package/plugin/skills/muggle-pr-followup/bootstrap.md +3 -1
  66. package/plugin/skills/muggle-pr-followup/contract.md +8 -4
  67. package/plugin/skills/muggle-pr-followup/output-templates/inline-reply.md +12 -0
  68. package/plugin/skills/muggle-pr-followup/state-schemas.md +7 -2
@@ -33,15 +33,28 @@ watch_read_slot_value() {
33
33
  printf '%s' "$value"
34
34
  }
35
35
 
36
- # Writes <slot>/watch-reported.env: the newest review and comment ids and the
37
- # unresolved threads a loop's last poll saw — every one of them either reported
38
- # or already floored — and the red head, rebase key and blocked digest it
39
- # reported, with the block (`blocked_for`, that block's watermark digest) the
40
- # digest was reported under.
36
+ # True when the slot file carries `key` at all, empty or not. Tells a floor
37
+ # written as zero from one a watch armed before that floor existed never wrote.
38
+ watch_slot_has_key() {
39
+ local slot="$1" file_name="$2" key="$3" line
40
+ [ -f "${slot}/${file_name}" ] || return 1
41
+ while IFS= read -r line || [ -n "$line" ]; do
42
+ case "$line" in
43
+ "${key}="*) return 0 ;;
44
+ esac
45
+ done < "${slot}/${file_name}"
46
+ return 1
47
+ }
48
+
49
+ # Writes <slot>/watch-reported.env: the newest review, thread-comment and
50
+ # conversation-comment ids and the unresolved threads a loop's last poll saw —
51
+ # every one of them either reported or already floored — and the red head,
52
+ # rebase key and blocked digest it reported, with the block (`blocked_for`, that
53
+ # block's watermark digest) the digest was reported under.
41
54
  watch_record_reported() {
42
- local slot="$1" review="$2" comment="$3" threads="$4" ci_red="$5" rebase="$6" blocked_digest="$7" blocked_for="$8"
43
- printf 'REV=%s\nCOM=%s\nTHREADS="%s"\nCIRED="%s"\nREBASED="%s"\nBLOCKED_CIDIGEST="%s"\nBLOCKED_FOR="%s"\n' \
44
- "$review" "$comment" "$threads" "$ci_red" "$rebase" "$blocked_digest" "$blocked_for" \
55
+ local slot="$1" review="$2" comment="$3" conversation="$4" threads="$5" ci_red="$6" rebase="$7" blocked_digest="$8" blocked_for="$9"
56
+ printf 'REV=%s\nCOM=%s\nCONV=%s\nTHREADS="%s"\nCIRED="%s"\nREBASED="%s"\nBLOCKED_CIDIGEST="%s"\nBLOCKED_FOR="%s"\n' \
57
+ "$review" "$comment" "$conversation" "$threads" "$ci_red" "$rebase" "$blocked_digest" "$blocked_for" \
45
58
  > "${slot}/${MUGGLE_PR_WATCH_REPORTED_FILE}"
46
59
  }
47
60
 
@@ -95,6 +95,7 @@ read_reported() {
95
95
  }
96
96
  reported_review=$(read_reported REV)
97
97
  reported_comment=$(read_reported COM)
98
+ reported_conversation=$(read_reported CONV)
98
99
  reported_threads=$(read_reported THREADS)
99
100
  floor_ci_red=$(read_reported CIRED)
100
101
  floor_rebase=$(read_reported REBASED)
@@ -154,6 +155,7 @@ while :; do
154
155
 
155
156
  watermark_review=$(read_watermark REV)
156
157
  watermark_comment=$(read_watermark COM)
158
+ watermark_conversation=$(read_watermark CONV)
157
159
  watermark_threads=$(read_watermark THREADS)
158
160
  watermark_ci_red=$(read_watermark CIRED)
159
161
  watermark_rebase=$(read_watermark REBASED)
@@ -188,6 +190,7 @@ while :; do
188
190
  failed_checks="${STATE_FIELDS[8]-}"
189
191
  ci_digest="${STATE_FIELDS[9]-}"
190
192
  ci_red_key="$(watch_ci_red_key "$head_sha" "${STATE_FIELDS[10]-}")"
193
+ latest_conversation="${STATE_FIELDS[11]-}"
191
194
 
192
195
  if [ "$pr_state" = "MERGED" ] || [ "$pr_state" = "CLOSED" ]; then
193
196
  echo "TERMINAL pr=$pr_number state=$pr_state"
@@ -209,6 +212,17 @@ while :; do
209
212
  watch_wake_review "$pr_number" "$latest_review" "$(higher_id "$watermark_review" "$reported_review")" && has_reported=1
210
213
  watch_wake_comment "$pr_number" "$latest_comment" "$(higher_id "$watermark_comment" "$reported_comment")" && has_reported=1
211
214
 
215
+ # A watermark armed before conversation comments were watched has no CONV
216
+ # floor, and reading that as zero would report every human comment the PR
217
+ # ever had. Such a slot floors at this loop's first read until a re-arm
218
+ # seeds the key from its drain.
219
+ if ! watch_slot_has_key "$slot" watch-watermark.env CONV; then
220
+ legacy_conversation_floor="${legacy_conversation_floor:-${latest_conversation:-0}}"
221
+ watermark_conversation="$legacy_conversation_floor"
222
+ fi
223
+ watch_wake_conversation_comment "$pr_number" "$latest_conversation" \
224
+ "$(higher_id "$watermark_conversation" "$reported_conversation")" && has_reported=1
225
+
212
226
  if [ -n "$unresolved_threads" ]; then
213
227
  IFS=';' read -ra thread_ids <<< "$unresolved_threads"
214
228
  for thread_id in "${thread_ids[@]}"; do
@@ -265,7 +279,8 @@ while :; do
265
279
 
266
280
  if [ -n "$has_reported" ]; then
267
281
  watch_record_reported "$slot" "$(higher_id "$latest_review" "$reported_review")" \
268
- "$(higher_id "$latest_comment" "$reported_comment")" "$unresolved_threads" \
282
+ "$(higher_id "$latest_comment" "$reported_comment")" \
283
+ "$(higher_id "$latest_conversation" "$reported_conversation")" "$unresolved_threads" \
269
284
  "$floor_ci_red" "$floor_rebase" "$floor_blocked_digest" "$floor_blocked_for"
270
285
  exit 0
271
286
  fi
@@ -6,7 +6,7 @@
6
6
  # Field order is the contract pr-watch-loop.sh reads positionally:
7
7
  # state, headRefOid, base-tip, mergeable, latest-review, latest-comment,
8
8
  # unresolved-thread-ids, pending-checks, failed-checks, check-digest,
9
- # red-check-runs
9
+ # red-check-runs, latest-conversation-comment
10
10
  #
11
11
  # red-check-runs names each failed check with its run id (`name#id`, sorted).
12
12
  # A settle, a rerun or a comment-triggered re-check publishes a new run on the
@@ -19,9 +19,32 @@
19
19
  # from it stays equal to an escalated or floored key however far the base
20
20
  # advances, and the branch never wakes again. A deleted base branch projects as
21
21
  # an empty field rather than a missing one, so no later field shifts.
22
+ #
23
+ # latest-conversation-comment is the newest top-level PR comment (the
24
+ # Conversation tab) a human wrote. Last, so every earlier reader keeps its index.
22
25
 
23
26
  def loop_marked: ((.body // "") | contains("<!-- muggle-do:bot -->"));
24
27
 
28
+ # A body without its `>` quote lines. GitHub's quote-reply copies the quoted
29
+ # text's markdown, so a human answering one of muggle's posts carries muggle's
30
+ # visible signature inside the quote.
31
+ def unquoted_body: (.body // "") | split("\n") | map(select(test("^ *>") | not)) | join("\n");
32
+
33
+ # Anything muggle posts on the Conversation tab: loop replies and reminders,
34
+ # walkthrough and PR sections (each opens with a `<!-- muggle-` marker), and
35
+ # plain-signed notices, which carry only the visible signature link.
36
+ def muggle_posted:
37
+ loop_marked
38
+ or (unquoted_body | contains("<!-- muggle-"))
39
+ or (unquoted_body | contains("[Muggle Works](https://github.com/multiplex-ai/muggle-ai-works)"));
40
+
41
+ # GraphQL names a GitHub App by its bare login (`github-actions`) and types it
42
+ # Bot; the `[bot]` suffix is the REST spelling, kept for any author that has it.
43
+ def bot_authored:
44
+ (.author.__typename // "") == "Bot"
45
+ or ((.author.login // "") | endswith("[bot]"))
46
+ or (.author.login // "") == "github-actions";
47
+
25
48
  .data.repository.pullRequest as $pr
26
49
  | (($pr.commits.nodes[0].commit.statusCheckRollup.contexts.nodes) // []) as $contexts
27
50
  | ($contexts | map(
@@ -64,5 +87,6 @@ def loop_marked: ((.body // "") | contains("<!-- muggle-do:bot -->"));
64
87
  ($checks | map(select(.verdict == "PENDING")) | length),
65
88
  ($failedChecks | length),
66
89
  ($checks | sort_by(.name) | map(.name + ":" + .verdict) | join(",")),
67
- ($failedChecks | map(.name + "#" + (.runId | tostring)) | sort | join(","))
90
+ ($failedChecks | map(.name + "#" + (.runId | tostring)) | sort | join(",")),
91
+ ((($pr.comments.nodes // []) | map(select((muggle_posted | not) and (bot_authored | not)) | .databaseId) | max) // 0)
68
92
  ] | @tsv
@@ -60,6 +60,11 @@ function isRebaseBudgetExhausted(lastSeenEntry, maxCatchUpRebases) {
60
60
  const catchUpRebases = lastSeenEntry.catch_up_rebases;
61
61
  return maxCatchUpRebases !== null && typeof catchUpRebases === "number" && catchUpRebases >= maxCatchUpRebases;
62
62
  }
63
+ function hasEscalatedReviewFeedback(lastSeenEntry) {
64
+ return [lastSeenEntry.escalated_review_ids, lastSeenEntry.escalated_conversation_comment_ids].some(
65
+ (escalatedIds) => Array.isArray(escalatedIds) && escalatedIds.length > 0
66
+ );
67
+ }
63
68
 
64
69
  // src/pr-watch/armFloors.ts
65
70
  function resolveArmFloorEvidence(lastSeenEntry, headSha, rebaseKey, maxCatchUpRebases) {
@@ -114,7 +119,7 @@ function resolveWatchTickVerdict(lastSeenEntry, observation, preferences) {
114
119
  if (isRebaseKeyEscalated(lastSeenEntry, rebaseKey)) return "block-conflict-escalated" /* BlockConflictEscalated */;
115
120
  const isRedHeadOutOfAttempts = observation.ciBucket === "red" /* Red */ && isCiHeadBudgetSpent(lastSeenEntry, headSha);
116
121
  if (isCiHeadEscalated(lastSeenEntry, headSha) || isRedHeadOutOfAttempts) return "block-ci-escalated" /* BlockCiEscalated */;
117
- if ((lastSeenEntry.escalated_review_ids ?? []).length > 0) return "block-reviews-escalated" /* BlockReviewsEscalated */;
122
+ if (hasEscalatedReviewFeedback(lastSeenEntry)) return "block-reviews-escalated" /* BlockReviewsEscalated */;
118
123
  return "idle" /* Idle */;
119
124
  }
120
125
 
@@ -55,6 +55,18 @@ Reply shape (all replies for one review reference the same SHA):
55
55
 
56
56
  Escalate per the caller's procedure (add the review id to `escalated_review_ids`, emit one terminal message, pause the PR).
57
57
 
58
+ ## Conversation comments
59
+
60
+ A top-level PR comment (Conversation tab) is classified on its own, as a body-only review is, with one extra class. The Conversation tab carries talk that asks nothing of the PR, and escalating it would pause the PR over a "thanks".
61
+
62
+ | Class | Signal | Action |
63
+ | :---- | :----- | :----- |
64
+ | **actionable** | Same as a review: a concrete change or an answerable question about the PR. | Address in the round; reply with one top-level comment that quotes and links it. |
65
+ | **informational** | Asks nothing: thanks, LGTM, a status or merge-timing note, an exchange between other people. | No reply, no escalation; folded into `lastConversationCommentId`. |
66
+ | **ambiguous** | Addresses the PR but carries no actionable signal (the ambiguous table above). | Escalate: add the id to `escalated_conversation_comment_ids`. |
67
+
68
+ The self-loop pre-check does not apply: the watcher already drops every comment muggle posted, so none reaches classification.
69
+
58
70
  ## Borderline rule
59
71
 
60
72
  If you can paraphrase the review's intent as **"do X"** (X concrete) → actionable. Pick the best interpretation; dispatch.
@@ -6,5 +6,6 @@ Under the thread-state dispatch trigger this is **intrinsic** — there is no "a
6
6
 
7
7
  - **Line-comment threads.** A thread is actionable only when its newest comment lacks the loop marker `<!-- muggle-do:bot -->` (see [`loop-signature.md`](loop-signature.md)). After the loop replies, the newest comment is the loop's own and carries the marker, so the thread drops out of the actionable set on its own.
8
8
  - **Body-only reviews.** A loop reply always carries a line comment, so it is never body-only; the body-only check (no line comments, `id > lastBodyReviewId` — see [`../vcs/github/submitted-reviews.md`](../vcs/github/submitted-reviews.md)) excludes echoes structurally.
9
+ - **Conversation comments.** The loop answers a top-level PR comment with a top-level comment of its own, signed `--mode loop`. The watch's projection ([`../../../scripts/pr-watch-state.jq`](../../../scripts/pr-watch-state.jq)) drops every comment muggle posted — the loop marker, any other `<!-- muggle-` marker, or the visible signature outside a quote — and every bot author before taking the newest id, so the reply never lifts the conversation floor.
9
10
 
10
11
  Classify by the marker, never by `author.login` — under a shared account the loop posts as the PR author, so the login cannot tell echo from human.
@@ -18,5 +18,5 @@ If you script the rewrite instead of using the Write tool, any tool that replace
18
18
 
19
19
  ## Field map
20
20
 
21
- - `last_seen.json` — one object keyed by `"<owner>/<repo>#<n>"`. Mutate fields under that key: `idle_tick_count`, `cycles_completed` (counters), `last_pushed_sha`, `lastBodyReviewId` (scalars), `pushed_shas`, `escalated_review_ids`, `ci_escalated_shas`, `conflict_escalated_keys` (arrays), `ci_fix_attempts[<sha>]` (keyed by head SHA), `conflict_resolve_attempts[<head-sha>..<base-tip-sha>]` (keyed by the head/base-tip pair).
21
+ - `last_seen.json` — one object keyed by `"<owner>/<repo>#<n>"`. Mutate fields under that key: `idle_tick_count`, `cycles_completed` (counters), `last_pushed_sha`, `lastBodyReviewId`, `lastConversationCommentId` (scalars), `pushed_shas`, `escalated_review_ids`, `escalated_conversation_comment_ids`, `ci_escalated_shas`, `conflict_escalated_keys` (arrays), `ci_fix_attempts[<sha>]` (keyed by head SHA), `conflict_resolve_attempts[<head-sha>..<base-tip-sha>]` (keyed by the head/base-tip pair).
22
22
  - `prs.json` — a one-element array. Mutate `[0]`: `head_sha`, `state`.
@@ -24,7 +24,7 @@ One per watcher iteration (idle or not).
24
24
  }
25
25
  ```
26
26
 
27
- - `actionable_threads`: count of actionable items this tick — unresolved, non-outdated threads whose newest comment is unmarked, plus body-only reviews past `lastBodyReviewId` — **after** filtering by the escalated set.
27
+ - `actionable_threads`: count of actionable items this tick — unresolved, non-outdated threads whose newest comment is unmarked, plus body-only reviews past `lastBodyReviewId`, plus conversation comments past `lastConversationCommentId` — **after** filtering by the escalated sets.
28
28
  - `dispatched_review_ids`: owning review ids handed to `/muggle-do`. Empty when idle.
29
29
  - `rebase_needed`: true when the branch is behind its base (`behind_by > 0`) or conflicting (`mergeable == CONFLICTING`). `false` when reviews were dispatched (reviews preempt the mergeability check).
30
30
  - `dispatched_rebase`: true when this tick dispatched `/muggle-do` with a rebase directive.
@@ -0,0 +1,22 @@
1
+ # PR conversation comments
2
+
3
+ Top-level comments on the PR's Conversation tab — GitHub's issue comments, outside any review or thread. For the watcher's dispatch trigger and the address-reviews work set.
4
+
5
+ ```bash
6
+ gh api repos/<owner>/<repo>/issues/<n>/comments --paginate \
7
+ --jq '.[] | {id: .id, body: .body, author: .user.login, authorType: .user.type, createdAt: .created_at, url: .html_url}'
8
+ ```
9
+
10
+ A comment is **actionable** when all hold:
11
+
12
+ - `id > last_seen.lastConversationCommentId`
13
+ - `id` not in `last_seen.escalated_conversation_comment_ids`
14
+ - not posted by muggle: the body carries no `<!-- muggle-` marker (the loop marker `<!-- muggle-do:bot -->`, `<!-- muggle-works:signature -->`, the walkthrough and PR-section markers) and, outside its `>` quote lines, no visible Muggle Works signature link — see [`../../pr-followup-helpers/loop-signature.md`](../../pr-followup-helpers/loop-signature.md). A human quote-reply copies the quoted post's signature, so quoted lines never count.
15
+ - not a bot: `authorType` is not `Bot`, the login does not end in `[bot]`, and it is not `github-actions`
16
+ - `author` is in the resolved reviewer allow-list
17
+
18
+ The watch loop applies the same muggle and bot exclusions in `scripts/pr-watch-state.jq` (`muggle_posted`, `bot_authored`); that file is the definition, this list mirrors it.
19
+
20
+ Issue comments have no threading: GitHub offers no reply endpoint, and the loop never edits a human's comment. Each one is answered with its own loop-signed top-level PR comment that quotes and links it.
21
+
22
+ Issue-comment ids are a sequence of their own, separate from review and review-comment ids, which is why they keep their own watermark rather than sharing `lastBodyReviewId`.
@@ -1,10 +1,10 @@
1
1
  # Top-level PR comment
2
2
 
3
- For the resolve-reminder stage and any non-threaded notice.
3
+ For the resolve-reminder stage, replies to PR conversation comments, and any non-threaded notice.
4
4
 
5
5
  ```bash
6
6
  body="$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/sign-body.sh" --command <command> --mode <mode> < <draft-file>)"
7
7
  gh pr comment <pr-number> --repo <owner>/<repo> --body "$body"
8
8
  ```
9
9
 
10
- Sign per [`../post-signature.md`](../post-signature.md). A resolve-reminder takes `--mode loop`, so the loop recognises the reminder as its own on a later tick; a one-shot notice nothing needs to detect takes `--mode plain`.
10
+ Sign per [`../post-signature.md`](../post-signature.md). A resolve-reminder and a conversation-comment reply take `--mode loop`, so the loop recognises the reminder as its own on a later tick; a one-shot notice nothing needs to detect takes `--mode plain`.
@@ -15,6 +15,7 @@ Skills assume a working `gh auth status`. Auth errors surface verbatim from `gh`
15
15
  | [`branch-standing`](common/branch-standing.md) | Tool-agnostic conflict + out-of-date detection — dispatches to `pr-metadata` / `mr-metadata`. |
16
16
  | [`line-comments-for-review`](github/line-comments-for-review.md) | Pull a review's line comments — `/muggle-do` per-comment routing. |
17
17
  | [`unresolved-threads`](github/unresolved-threads.md) | GraphQL unresolved-thread state — watcher's dispatch trigger + resolve-reminder. |
18
+ | [`conversation-comments`](github/conversation-comments.md) | Top-level PR comments (Conversation tab) — watcher's dispatch trigger + address-reviews work set. |
18
19
  | [`reply-line-comment`](github/reply-line-comment.md) | POST a threaded reply on a line comment. |
19
20
  | [`top-level-comment`](github/top-level-comment.md) | POST a top-level PR comment — resolve-reminder + overflow. |
20
21
  | [`push-to-branch`](common/push-to-branch.md) | Signing-gated push + capture new SHA after address-reviews work. |
@@ -6,7 +6,7 @@ mandatoryStages:
6
6
 
7
7
  # Address-Reviews Orchestrator
8
8
 
9
- The entry procedure for `/muggle-do`'s **address-reviews** mode — invoked by the watcher loop ([`../muggle-pr-followup/contract.md`](../muggle-pr-followup/contract.md)) when new submitted reviews land on a PR. Orchestrates the cycle: read reviews → classify → execute work on actionables → escalate ambiguous → push and refresh PR → reply per comment → resolve-reminder → respawn watcher.
9
+ The entry procedure for `/muggle-do`'s **address-reviews** mode — invoked by the watcher loop ([`../muggle-pr-followup/contract.md`](../muggle-pr-followup/contract.md)) when new submitted reviews or PR conversation comments land on a PR. Orchestrates the cycle: read reviews → classify → execute work on actionables → escalate ambiguous → push and refresh PR → reply per comment → resolve-reminder → respawn watcher.
10
10
 
11
11
  ## Turn preamble
12
12
 
@@ -19,16 +19,17 @@ The entry procedure for `/muggle-do`'s **address-reviews** mode — invoked by t
19
19
  `$ARGUMENTS` carries:
20
20
  - PR URL: `<owner>/<repo>#<n>` derivable from the URL.
21
21
  - Session slug: `<slug>`.
22
- - Owning review ids: one or more integers (the reviews whose actionable threads or body-only feedback the watcher flagged).
22
+ - Owning review ids: zero or more integers (the reviews whose actionable threads or body-only feedback the watcher flagged).
23
+ - Conversation comment ids (GitHub only): zero or more integers after the keyword `conversation` — top-level PR comments the watcher flagged. At least one of the two lists is non-empty.
23
24
 
24
- Exact phrasing comes from the watcher's dispatch (see [`../muggle-pr-followup/contract.md`](../muggle-pr-followup/contract.md)). Parse all three out of the directive text.
25
+ Exact phrasing comes from the watcher's dispatch (see [`../muggle-pr-followup/contract.md`](../muggle-pr-followup/contract.md)). Parse all four out of the directive text.
25
26
 
26
27
  ## Inputs from disk
27
28
 
28
29
  Read from `~/.muggle-ai/muggle-do/sessions/<slug>/`:
29
30
 
30
31
  - `prs.json` — to locate the PR's local checkout path (the `repo` field maps to a configured local repo) and capture `head_sha_before`.
31
- - `last_seen.json` — for `pushed_shas[]` (used by the resolve-reminder stage) and to update `lastBodyReviewId`.
32
+ - `last_seen.json` — for `pushed_shas[]` (used by the resolve-reminder stage) and to update `lastBodyReviewId` and `lastConversationCommentId`.
32
33
  - `state.md` — for the cached `loop_user` login (used by resolve-reminder thread classification).
33
34
 
34
35
  ## Procedure
@@ -41,7 +42,7 @@ Before assembling work, rebase onto the latest default branch so the cycle addre
41
42
 
42
43
  Resolve the provider per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md), then assemble.
43
44
 
44
- **`github`** — two sources, combined into one batch (dedupe by comment id):
45
+ **`github`** — three sources, combined into one batch (dedupe by comment id within each id space):
45
46
 
46
47
  **(a) The dispatched reviews.** For each review id in the input:
47
48
 
@@ -50,7 +51,9 @@ Resolve the provider per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-
50
51
 
51
52
  **(b) Unaddressed comments on every unresolved thread.** Fetch unresolved threads per [`../_shared/vcs/github/unresolved-threads.md`](../_shared/vcs/github/unresolved-threads.md). For each thread classified **unaddressed human comment** — newest comment lacks the loop marker `<!-- muggle-do:bot -->` ([`loop-signature.md`](../_shared/pr-followup-helpers/loop-signature.md)) and post-dates the loop's last marked reply — add it to the batch — unresolved thread state, not any review-id watermark, is the authority here. This is how a human thread follow-up (a marker-less reply) gets addressed. **Exclude** comments whose review id is in `last_seen.escalated_review_ids` — paused awaiting the user, not re-work.
52
53
 
53
- Group (a) and (b) into one combined batch.
54
+ **(c) Conversation comments.** Fetch top-level PR comments per [`../_shared/vcs/github/conversation-comments.md`](../_shared/vcs/github/conversation-comments.md) and add every actionable one — past `last_seen.lastConversationCommentId`, not escalated, not muggle's own or a bot's, author in the allow-list. The dispatched conversation ids are a subset; a comment landing after the watcher's read is swept in the same way. Record the highest id this read returned as `conversation_snapshot_id` — the wave's snapshot for Step 5 and the watermark advance, captured before any reply is posted.
55
+
56
+ Group (a), (b) and (c) into one combined batch.
54
57
 
55
58
  **Claim each thread in the batch.** Claiming is what records that this round took the thread as work; the reply gate settles from claims, not from whether a push happened. Release the claims when the round ends. A claim whose holder died is not a claim — the entry reads unprocessed again and the next round re-claims it — so a crashed round leaves nothing to clean up.
56
59
 
@@ -65,6 +68,8 @@ Apply the classify rule in [`../_shared/pr-followup-helpers/classify.md`](../_sh
65
68
 
66
69
  Build two sets: `actionable_review_ids` and `ambiguous_review_ids`. Their union is the input list.
67
70
 
71
+ Classify each **conversation comment** on its own, as a body-only review, with one more outcome from [`classify.md`](../_shared/pr-followup-helpers/classify.md#conversation-comments): **informational** — nothing asked of the PR (thanks, approval, a status note, an exchange between other people). Build `actionable_conversation_ids`, `ambiguous_conversation_ids` and `informational_conversation_ids`. An informational comment gets no reply and no escalation; Step 5 folds it into the watermark.
72
+
68
73
  ### Step 3 — Handle ambiguous (if any)
69
74
 
70
75
  For each id in `ambiguous_review_ids`:
@@ -72,19 +77,21 @@ For each id in `ambiguous_review_ids`:
72
77
  1. Append it to `last_seen.escalated_review_ids` so the watcher won't re-dispatch it.
73
78
  2. Run `echo "MUGGLE_REPLY_SKIP: <comment-id> deferred to the user"` naming its comment ids (`gitlab`: discussion ids). An escalated thread is deferred, not answered, so the reply gate in [`per-comment-replies.md`](per-comment-replies.md) would otherwise hold the turn open waiting on a reply that is not coming. The deferral is recorded against those comments durably, so it still holds after this session ends; a marker naming no tracked comment falls back to a session-wide skip.
74
79
 
75
- Emit **one** terminal escalation message (not one per ambiguous review) per [`../muggle-pr-followup/output-templates/escalation.md`](../muggle-pr-followup/output-templates/escalation.md) (ambiguous template). The message lists every ambiguous review and its comments inline. Emit an event with `kind: "ambiguous-review"` per [`../_shared/telemetry-events/muggle-do-escalation.md`](../_shared/telemetry-events/muggle-do-escalation.md).
80
+ For each id in `ambiguous_conversation_ids`, append it to `last_seen.escalated_conversation_comment_ids`. No reply-skip marker is needed: the reply gate tracks review threads, not conversation comments.
76
81
 
77
- The user clarifies on GitHub by submitting a new review. The next watcher tick picks it up.
82
+ Emit **one** terminal escalation message (not one per ambiguous review or comment) per [`../muggle-pr-followup/output-templates/escalation.md`](../muggle-pr-followup/output-templates/escalation.md) (ambiguous template). The message lists every ambiguous review and its comments inline. Emit an event with `kind: "ambiguous-review"` per [`../_shared/telemetry-events/muggle-do-escalation.md`](../_shared/telemetry-events/muggle-do-escalation.md).
83
+
84
+ The user clarifies on GitHub by submitting a new review or a new conversation comment. The next watcher tick picks it up.
78
85
 
79
86
  ### Step 4 — Handle actionables (if any)
80
87
 
81
- If `actionable_review_ids` is empty, skip the rest of Step 4 and Step 5; proceed to Step 5.5 (resolve-reminder) then Step 6. Otherwise:
88
+ If `actionable_review_ids` and `actionable_conversation_ids` are both empty, skip the rest of Step 4, apply Step 5's watermark writes, then proceed to Step 5.5 (resolve-reminder) and Step 6. Otherwise:
82
89
 
83
90
  Before any edits, ensure the PR's branch workspace is the working directory. If `state.md` carries a `worktreePath` (forward-mode session), use it. Otherwise materialize the PR branch per [`../_shared/pr-branch-worktree.md`](../_shared/pr-branch-worktree.md) — the single owner of checking out a PR branch in isolation — so a bootstrap or auto-track watcher never edits the user's live checkout. If the resolved tree is dirty with unrelated work, escalate per Step 7 rather than editing it.
84
91
 
85
92
  #### 4a. Flatten the work
86
93
 
87
- The actionable reviews together carry a flat list of change items, one per line comment plus any directive in the review body. Each item is design, code logic, or test in nature; the cycle does **not** treat each item as a separate cycle iteration — it plans them together and runs the work **once** for the whole batch.
94
+ The actionable reviews and conversation comments together carry a flat list of change items, one per line comment plus any directive in a review body or conversation comment. Each item is design, code logic, or test in nature; the cycle does **not** treat each item as a separate cycle iteration — it plans them together and runs the work **once** for the whole batch.
88
95
 
89
96
  #### 4b. Apply design + code-logic changes
90
97
 
@@ -110,8 +117,7 @@ Invoke [`open-prs/update.md`](open-prs/update.md) (pass the PR URL + slug + exis
110
117
 
111
118
  #### 4g. Post per-comment inline replies
112
119
 
113
- Invoke [`per-comment-replies.md`](per-comment-replies.md) with the actionable reviews (`gitlab`: discussions) and the new SHA. One reply per comment, in its own thread, describing what was done for it. The reply is the whole of it — neither provider's threads get resolved by the loop.
114
-
120
+ Invoke [`per-comment-replies.md`](per-comment-replies.md) with the actionable reviews (`gitlab`: discussions), the actionable conversation comments, and the new SHA. One reply per comment, in its own thread, describing what was done for it; a conversation comment, which has no thread, gets one signed top-level comment that names it. The reply is the whole of it — neither provider's threads get resolved by the loop.
115
121
  (The resolve-reminder runs once per round in Step 5.5 below — not only after a push — so a round that pushed nothing still nudges addressed-but-unresolved threads.)
116
122
 
117
123
  ### Step 5 — Update session state
@@ -121,6 +127,7 @@ Apply each field write below as a whole-file rewrite (Read → change field →
121
127
  - `last_seen.cycles_completed` += 1
122
128
  - `last_seen.last_pushed_sha` = the new head SHA (update.md already wrote this; verify)
123
129
  - `last_seen.lastBodyReviewId` = max(body-only input review ids ∪ last_seen.lastBodyReviewId) — line-comment threads need no watermark; they fall out of the actionable set once the per-comment reply carries the loop marker.
130
+ - `last_seen.lastConversationCommentId` = max(`conversation_snapshot_id`, last_seen.lastConversationCommentId) — but never past an actionable conversation comment whose reply failed: stop just below the lowest such id, so the next tick re-dispatches it. Replied, informational and escalated comments are all handled. The slot's `CONV` floor in `watch-watermark.env` advances to the same value ([`../muggle-pr-followup/arm-watcher.md`](../muggle-pr-followup/arm-watcher.md)).
124
131
 
125
132
  ### Step 5.5 — Resolve-reminder (runs every round)
126
133
 
@@ -156,4 +163,5 @@ Do **not** push, do **not** post replies, do **not** run resolve-reminder. The c
156
163
 
157
164
  - One `/muggle-do` invocation = at most one push and one resolve-reminder, regardless of how many reviews are in the batch.
158
165
  - Every input review id ends up either handled (its thread answered with a loop-marked reply, or — for a body-only review — folded into `lastBodyReviewId`) or in `escalated_review_ids` (skipped) — never both, never neither.
166
+ - Every conversation comment in the batch ends up answered by exactly one loop-marked top-level comment, informational, or in `escalated_conversation_comment_ids` — and below `lastConversationCommentId` only once one of those holds.
159
167
  - The watcher is respawned exactly when the PR is still open at the end of the cycle.
@@ -2,7 +2,7 @@
2
2
 
3
3
  How `/muggle-do` resolves `$ARGUMENTS` to a mode. Modes 1–4 are programmatic — dispatched by the watcher — so never ask on those. A change-URL in modes 1–3 is either a GitHub PR (`github.com/.../pull/<n>`) or a GitLab MR (`<host>/.../-/merge_requests/<iid>`); provider is resolved via [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md). Inspect in order:
4
4
 
5
- 1. **Address-reviews** — a PR/MR URL **and** an address-reviews directive carrying review/discussion ids → [`address-reviews.md`](address-reviews.md). On GitHub these ids are integers ≥ 100000000; that magnitude is GitHub-specific lore, **not** a portable test. Under GitLab, tell this apart from other directives by the directive keyword plus the presence of discussion ids, never by id size.
5
+ 1. **Address-reviews** — a PR/MR URL **and** an address-reviews directive carrying review/discussion ids, conversation comment ids after the keyword `conversation`, or both → [`address-reviews.md`](address-reviews.md). On GitHub these ids are integers ≥ 100000000; that magnitude is GitHub-specific lore, **not** a portable test. Under GitLab, tell this apart from other directives by the directive keyword plus the presence of discussion ids, never by id size.
6
6
  2. **Fix-CI** — a PR/MR URL **and** a `fix ci` / `fix-ci` directive with failing check names (no review/discussion ids) → [`fix-ci.md`](fix-ci.md).
7
7
  3. **Rebase** — a PR/MR URL **and** a `rebase` directive (or legacy `resolve conflicts` / `resolve-conflicts`; no review/discussion ids, no check names) → [`resolve-conflicts.md`](resolve-conflicts.md). Rebases the branch onto its base whether it's merely behind or actually conflicting.
8
8
  4. **Post-merge cleanup** — a `cleanup` token and `slug=<slug>` (no PR URL, no review ids), optionally `state=<merged|closed>` (default `merged`) → [`cleanup.md`](cleanup.md).
@@ -90,7 +90,7 @@ Write `~/.muggle-ai/muggle-do/sessions/<slug>/prs.json` per [`../../muggle-pr-fo
90
90
  [{ "repo": "owner/repo", "number": 142, "url": "...", "head_sha": "...", "state": "open" }]
91
91
  ```
92
92
 
93
- Seed `~/.muggle-ai/muggle-do/sessions/<slug>/last_seen.json` per [`../../muggle-pr-followup/state-schemas.md`](../../muggle-pr-followup/state-schemas.md#last_seenjson) — empty-watermark shape with `pushed_shas: []`. Forward mode never has prior reviews to skip, so `lastBodyReviewId: 0`.
93
+ Seed `~/.muggle-ai/muggle-do/sessions/<slug>/last_seen.json` per [`../../muggle-pr-followup/state-schemas.md`](../../muggle-pr-followup/state-schemas.md#last_seenjson) — empty-watermark shape with `pushed_shas: []`. Forward mode never has prior reviews to skip, so `lastBodyReviewId: 0` and `lastConversationCommentId: 0`.
94
94
 
95
95
  **Do not** seed `cycle.json` or `requirements.md`. The watcher is a dumb pipe; `/muggle-do` reads reviews off GitHub.
96
96
 
@@ -7,6 +7,7 @@ This is **not** a top-level "summary reply on the review." Each comment thread g
7
7
  ## Inputs
8
8
 
9
9
  - `actionable_reviews` — the list of reviews classified actionable in `address-reviews.md` Step 2. On `gitlab`, these are the actionable **discussions** (no review envelope) — read each as a thread of notes.
10
+ - `actionable_conversation_comments` (GitHub only) — the conversation comments classified actionable in `address-reviews.md` Step 2, each with its id, author, body and `html_url`.
10
11
  - `new_sha` — the SHA `open-prs/update.md` just pushed.
11
12
  - The PR's owner, repo, number. On `gitlab`, the project ref and MR iid.
12
13
 
@@ -52,6 +53,12 @@ Re: review #<review_id> — addressed in <short-sha>: <one-line summary>.
52
53
 
53
54
  Posted per [`../_shared/vcs/github/top-level-comment.md`](../_shared/vcs/github/top-level-comment.md). Fires at most once per actionable review-with-no-line-comments. Does not fire if the review has line comments — Step 2 covers those.
54
55
 
56
+ ### Step 4 — Answer conversation comments (GitHub only)
57
+
58
+ A top-level PR comment ([`../_shared/vcs/github/conversation-comments.md`](../_shared/vcs/github/conversation-comments.md)) has no thread and no reply endpoint. Post **one** top-level comment per actionable conversation comment — never one comment answering several — using the conversation template in [`../muggle-pr-followup/output-templates/inline-reply.md`](../muggle-pr-followup/output-templates/inline-reply.md), which quotes and links the comment it answers. Sign with `--mode loop` through [`../_shared/vcs/github/top-level-comment.md`](../_shared/vcs/github/top-level-comment.md): the marker is what keeps the watch from waking on the reply. A comment that asked a question the round answered without a change is answered the same way, with no SHA.
59
+
60
+ Record each reply's outcome: a conversation comment whose reply failed is still unanswered, and [`address-reviews.md`](address-reviews.md) Step 5 keeps the watermark below it.
61
+
55
62
  ## Failure modes
56
63
 
57
64
  - `gh api` returns an error for an individual reply → log to `followup.log`, continue with the remaining comments. Do not abort the whole step over one failure; the push has already happened and other replies still need posting.
@@ -70,6 +77,6 @@ A thread the round deferred to the user instead of answering (the ambiguous esca
70
77
 
71
78
  ## Invariants
72
79
 
73
- - One reply per line comment (`gitlab`: per discussion). No per-review summary reply anywhere.
80
+ - One reply per line comment (`gitlab`: per discussion), and one top-level reply per actionable conversation comment. No per-review summary reply anywhere.
74
81
  - The loop never resolves a review thread, on either provider. A `PreToolUse` guardrail denies both calls.
75
82
  - Every reply body contains the new SHA's 7-char prefix (which push addressed it) and ends with the loop signature block — the `<!-- muggle-do:bot -->` marker, not the author login, is what identifies loop-authored comments.
@@ -55,7 +55,7 @@ Bootstrap accepts three optional trailing flags:
55
55
 
56
56
  - `--slug=<name>` — override the default `<repo>-pr<n>` slug
57
57
  - `--resume` — opt in to reusing an existing session slot (default is refuse on conflict)
58
- - `--forward-only` — pin `lastBodyReviewId` past existing **body-only** reviews (skip history on those). Line-comment threads are always picked up from live thread state, regardless of this flag.
58
+ - `--forward-only` — pin `lastBodyReviewId` past existing **body-only** reviews and `lastConversationCommentId` past existing conversation comments (skip history on those). Line-comment threads are always picked up from live thread state, regardless of this flag.
59
59
 
60
60
  ## Preferences
61
61
 
@@ -14,8 +14,8 @@ The same argument that forbids authoring a per-slot `watch.sh` applies to arming
14
14
 
15
15
  The `DRAIN` lines it prints, in the watch's output, are the outstanding work as of the arm. Review ids and threads the drain read are floored, so the loop will *not* tell you about those again. A stale branch or a red head is floored only when `last_seen.json` records a rebase or fix-ci cycle already attempted for that key or head ([`state-schemas.md`](state-schemas.md#watch-watermarkenv)); otherwise the drain line says `not floored: dispatch …` and the loop's first poll reports it as an event. A PR that spent its catch-up rebase budget is the exception: its drain line says the rebase is `held for the owner`, and nothing is dispatched — the tick would refuse it — until the owner raises [`maxCatchUpRebases`](../muggle-preferences/preference-gates/maxCatchUpRebases.md). Re-arming is never a way to set work aside — it neither handles nor silences anything. Steps 1-3 below are what the script does, and why.
16
16
 
17
- 1. **Drain.** Run one tick per [`contract.md`](contract.md). It acts on everything already outstanding — actionable threads (`gitlab`: discussions), body-only reviews past the watermark (GitHub-only — GitLab has no review envelope), a stale branch, red CI — and finalizes a terminal PR. If the tick dispatched a cycle, stop here: the cycle's exit path settles the watch when it finishes.
18
- 2. **Seed the watermark.** *(`pr-watch-arm.sh` does this; the reasoning is kept because the floors are subtle and wrong ones are quiet.)* Resolve the provider once per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md) — every fetch in this sequence uses that provider's recipes. Write the slot's watch watermark ([`state-schemas.md`](state-schemas.md#watch-watermarkenv)) to the ids the **drain itself read** — the max review-id and comment-id observed at the drain's own fetch (Step 1), snapshotted at that read. Never let the loop capture its own baseline — the arming session writes it; and **never** from a fresh fetch taken after the drain, which would include a comment that arrived after the drain read the wave and mark it seen unread. Seeded to the drain's floor, anything landing after that read stays above the watermark and the loop's first iteration surfaces it. Seed the CI floor (`CIRED`) from the same drain read: set it to the red key (`<head_sha>@<red-check-runs>`) only when the checks have **already settled red** at that read (no check pending, one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)) **and** fix-ci is finished with that head — it escalated, or spent the tick's per-head budget — and empty otherwise. A lone attempt does not floor: the count is written before the fix runs, so a cycle that recorded it and changed nothing would otherwise leave the red silent. Seed the rebase floor (`REBASED`) the same way, from the drain's branch-standing read per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md): the current `rebase_key` (`<head_sha>..<base_tip_sha>`) only when the drain found the branch behind or conflicting **and** a rebase attempt is recorded for that key, empty otherwise. An escalation entry alone never floors anything: one with no attempt behind it records a decision nobody acted on, and flooring it is how a re-arming session once kept a stale branch and a red head silent for a day ([`state-schemas.md`](state-schemas.md#watch-watermarkenv) names the fields). Seed the blocked-CI floor (`BLOCKED_CIDIGEST`) to the blocked fingerprint's `ci_digest` when arming while `last_seen.blocked` is already set, and empty otherwise — empty is the not-blocked state, in which the loop's blocked-resume probe stays dormant. Seed the rebase hold (`REBASE_HELD`) to `1` when `last_seen.json`'s `catch_up_rebases` has reached `maxCatchUpRebases` — the same check the tick's verdict blocks on — and empty otherwise: while it is set the loop raises no rebase wake on any base move. The script reads all four facts from `last_seen.json` through [`../../scripts/pr-watch-verdict.mjs`](../../scripts/pr-watch-verdict.mjs) `arm-floors`, and records what it found due in `watch-due.env` ([`state-schemas.md`](state-schemas.md#watch-dueenv)).
17
+ 1. **Drain.** Run one tick per [`contract.md`](contract.md). It acts on everything already outstanding — actionable threads (`gitlab`: discussions), body-only reviews past the watermark (GitHub-only — GitLab has no review envelope), conversation comments past theirs (GitHub-only), a stale branch, red CI — and finalizes a terminal PR. If the tick dispatched a cycle, stop here: the cycle's exit path settles the watch when it finishes.
18
+ 2. **Seed the watermark.** *(`pr-watch-arm.sh` does this; the reasoning is kept because the floors are subtle and wrong ones are quiet.)* Resolve the provider once per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md) — every fetch in this sequence uses that provider's recipes. Write the slot's watch watermark ([`state-schemas.md`](state-schemas.md#watch-watermarkenv)) to the ids the **drain itself read** — the max review-id, comment-id and human conversation-comment id (`CONV`) observed at the drain's own fetch (Step 1), snapshotted at that read. Never let the loop capture its own baseline — the arming session writes it; and **never** from a fresh fetch taken after the drain, which would include a comment that arrived after the drain read the wave and mark it seen unread. Seeded to the drain's floor, anything landing after that read stays above the watermark and the loop's first iteration surfaces it. Seed the CI floor (`CIRED`) from the same drain read: set it to the red key (`<head_sha>@<red-check-runs>`) only when the checks have **already settled red** at that read (no check pending, one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)) **and** fix-ci is finished with that head — it escalated, or spent the tick's per-head budget — and empty otherwise. A lone attempt does not floor: the count is written before the fix runs, so a cycle that recorded it and changed nothing would otherwise leave the red silent. Seed the rebase floor (`REBASED`) the same way, from the drain's branch-standing read per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md): the current `rebase_key` (`<head_sha>..<base_tip_sha>`) only when the drain found the branch behind or conflicting **and** a rebase attempt is recorded for that key, empty otherwise. An escalation entry alone never floors anything: one with no attempt behind it records a decision nobody acted on, and flooring it is how a re-arming session once kept a stale branch and a red head silent for a day ([`state-schemas.md`](state-schemas.md#watch-watermarkenv) names the fields). Seed the blocked-CI floor (`BLOCKED_CIDIGEST`) to the blocked fingerprint's `ci_digest` when arming while `last_seen.blocked` is already set, and empty otherwise — empty is the not-blocked state, in which the loop's blocked-resume probe stays dormant. Seed the rebase hold (`REBASE_HELD`) to `1` when `last_seen.json`'s `catch_up_rebases` has reached `maxCatchUpRebases` — the same check the tick's verdict blocks on — and empty otherwise: while it is set the loop raises no rebase wake on any base move. The script reads all four facts from `last_seen.json` through [`../../scripts/pr-watch-verdict.mjs`](../../scripts/pr-watch-verdict.mjs) `arm-floors`, and records what it found due in `watch-due.env` ([`state-schemas.md`](state-schemas.md#watch-dueenv)).
19
19
  3. **Dedup, then watch.** First read `<slot>/watch.pid` ([`state-schemas.md`](state-schemas.md#watchpid)): if it names a live process (`kill -0 "$pid"` succeeds) **and `owner.json` records this session**, a watcher already owns this slot — **skip arming, do not start a second**. This is what stops orphaned watchers from accumulating: the in-session task dying does not stop the OS loop it launched (on Windows a detached Git Bash loop keeps running and polling `gh` forever after the session ends), so checking a live task list is not enough — the PID lease is.
20
20
 
21
21
  **A live lease owned by a different session does not count as owned** — check it with `watcher_lease_is_foreign` from [`../../scripts/pr-watch-guards.sh`](../../scripts/pr-watch-guards.sh). A live PID proves the loop is running, never that anything is listening: an orphan left by a dead session keeps polling and keeps touching its heartbeat while its stdout is that session's closed pipe, so every liveness signal reads healthy and the events reach nobody. Skipping on the PID alone let such a corpse block this session from arming the PR for the whole lifetime cap — seven days, since the default moved off six hours. When the guard reports a foreign lease, kill that PID, delete `watch.pid`, and arm fresh; note it in the slot's `followup.log` so the reclaim is visible.
@@ -38,7 +38,7 @@ The `DRAIN` lines it prints, in the watch's output, are the outstanding work as
38
38
 
39
39
  **Never author a per-slot `watch.sh`.** The loop ships as [`../../scripts/pr-watch-loop.sh`](../../scripts/pr-watch-loop.sh), with its wake conditions in [`../../scripts/pr-watch-events.sh`](../../scripts/pr-watch-events.sh) and its state projection in [`../../scripts/pr-watch-state.jq`](../../scripts/pr-watch-state.jq); arming runs it and passes arguments. Writing the loop from this prose was how it drifted — each arm produced an independent derivation, and a derivation that quietly dropped a wake still ran, still heartbeat, still logged, and simply never fired for the signal it lost. Two slots on one machine ended up without the behind-base wake, which left their PRs unmergeable under watchers that looked healthy. The prose below says *why* each wake exists; the shipped files are the only definition of *what* fires. A slot holding a legacy generated `watch.sh` keeps it until re-armed, at which point the supersede guard retires the old loop.
40
40
 
41
- The task's description is `PR #<n> — <title>`. Description and command both matter: some task surfaces show one, some the other, and a slot-bearing command keeps the watch identifiable everywhere a raw script blob would not. One background task per PR at a time: it is the watch's visible handle, showing as a running task while the PR is polled, and replaced by a fresh one after each report. Its loop checks about every 60 seconds, re-reading the watermark and touching the slot's `watch-heartbeat` file each iteration — the liveness beacon that tells [`reconcile.md`](reconcile.md) a quiet watch is still alive; on a newer submitted review, a newer thread comment (`gitlab`: a newer discussion note), a thread newly unresolved (`gitlab`: discussion), **the head SHA's checks settling red** (no check pending and one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)), **the branch falling behind or conflicting with its base** (`behind_by > 0` or the conflict signal per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md)), or — **only while the watch is blocked** (`BLOCKED_CIDIGEST` non-empty) — **the head's CI digest changing in any way** (not just to red) — it prints one line per finding and **exits**, recording what it reported in `watch-reported.env` ([`state-schemas.md`](state-schemas.md#watch-reportedenv)) so no later loop reports the same occurrence again. The review and thread floors are monotonic ids; the other three are not. The CI-red floor is the **red key** — the head SHA plus each failed check's run id — because the check rollup is non-monotonic: it flips green↔red and resets on every push, so the key fires once per red verdict and a later push re-arms it on the new SHA. The run ids matter because a settled walkthrough comment or a rerun publishes a new run on the same head; when that run is red too, it is the verdict fix-ci is waiting on, and a head-only floor swallowed it. The rebase floor (`REBASED`) is the **`rebase_key`** — `<head_sha>..<base_tip_sha>` — because staleness is a function of both sides: keying on the pair fires once per newly-due pair and re-arms when either the head or the base moves, where a head-only key would wedge permanently the first time the base advances (the head cannot change while nobody pushes). A head whose checks are still **pending** is never a red wake, and a branch with `behind_by == 0` and `mergeable == UNKNOWN` is never a rebase wake: pending checks may yet go green and conflict state is still computing, and the tick would idle on either (Steps 5–6) regardless. The blocked-CI signal is different in kind — a **resume** probe, live only while the watch is blocked: it wakes on any move of the head's CI digest (the same bucket-plus-sorted-name/conclusion signature the blocked fingerprint records — [`blocked-tick.md`](blocked-tick.md)) away from `BLOCKED_CIDIGEST`, so a block waiting on a green pass, a rerun, or an external deploy check resumes as promptly as one waiting on red. Quiet iterations print nothing and cost nothing — no model tokens are spent while the watch is quiet.
41
+ The task's description is `PR #<n> — <title>`. Description and command both matter: some task surfaces show one, some the other, and a slot-bearing command keeps the watch identifiable everywhere a raw script blob would not. One background task per PR at a time: it is the watch's visible handle, showing as a running task while the PR is polled, and replaced by a fresh one after each report. Its loop checks about every 60 seconds, re-reading the watermark and touching the slot's `watch-heartbeat` file each iteration — the liveness beacon that tells [`reconcile.md`](reconcile.md) a quiet watch is still alive; on a newer submitted review, a newer thread comment (`gitlab`: a newer discussion note), a newer human conversation comment (`github`: a top-level PR comment muggle did not post and no bot wrote), a thread newly unresolved (`gitlab`: discussion), **the head SHA's checks settling red** (no check pending and one or more in the `fail` bucket per [`../_shared/vcs/common/ci-rollup.md`](../_shared/vcs/common/ci-rollup.md)), **the branch falling behind or conflicting with its base** (`behind_by > 0` or the conflict signal per [`../_shared/vcs/common/branch-standing.md`](../_shared/vcs/common/branch-standing.md)), or — **only while the watch is blocked** (`BLOCKED_CIDIGEST` non-empty) — **the head's CI digest changing in any way** (not just to red) — it prints one line per finding and **exits**, recording what it reported in `watch-reported.env` ([`state-schemas.md`](state-schemas.md#watch-reportedenv)) so no later loop reports the same occurrence again. The review, comment, conversation and thread floors are monotonic ids; the other three are not. The CI-red floor is the **red key** — the head SHA plus each failed check's run id — because the check rollup is non-monotonic: it flips green↔red and resets on every push, so the key fires once per red verdict and a later push re-arms it on the new SHA. The run ids matter because a settled walkthrough comment or a rerun publishes a new run on the same head; when that run is red too, it is the verdict fix-ci is waiting on, and a head-only floor swallowed it. The rebase floor (`REBASED`) is the **`rebase_key`** — `<head_sha>..<base_tip_sha>` — because staleness is a function of both sides: keying on the pair fires once per newly-due pair and re-arms when either the head or the base moves, where a head-only key would wedge permanently the first time the base advances (the head cannot change while nobody pushes). A head whose checks are still **pending** is never a red wake, and a branch with `behind_by == 0` and `mergeable == UNKNOWN` is never a rebase wake: pending checks may yet go green and conflict state is still computing, and the tick would idle on either (Steps 5–6) regardless. The blocked-CI signal is different in kind — a **resume** probe, live only while the watch is blocked: it wakes on any move of the head's CI digest (the same bucket-plus-sorted-name/conclusion signature the blocked fingerprint records — [`blocked-tick.md`](blocked-tick.md)) away from `BLOCKED_CIDIGEST`, so a block waiting on a green pass, a rerun, or an external deploy check resumes as promptly as one waiting on red. Quiet iterations print nothing and cost nothing — no model tokens are spent while the watch is quiet.
42
42
 
43
43
  Each poll also rewrites the slot's `watch-due.env` whenever the due work changes — the rebase key found due and the head whose checks settled red, or an empty file when neither — so the session's turn-end gate can see work the watch reported without a provider call ([`state-schemas.md`](state-schemas.md#watch-dueenv)).
44
44
 
@@ -56,9 +56,9 @@ The `DRAIN` lines it prints, in the watch's output, are the outstanding work as
56
56
  - No line — a newer arm superseded the loop, and that arm's loop owns the slot. Nothing to do.
57
57
 
58
58
  The wake turn runs the tick with `--wake=<event>` — the flag that tells routing's live-watcher gate this poll was prompted, not idle curiosity ([`SKILL.md`](SKILL.md#routing)) — and whatever cycle the tick produces runs **inline in the owning session** — never in a subagent. The session's full history is part of the cycle's context (decisions, review nuance, owner phrasing); a subagent only knows its briefing plus disk/provider state, and anything the briefing omits is silently missing from the cycle. The token cost of inline cycles is accepted — context beats cost. The tick still derives everything from live provider state; a terminal PR finalizes there while the loop exits on its own.
59
- **After a cycle** — advance the watermark to the **handled wave's snapshot**, in the same dispatched context that ran the cycle. Capture the max review-id and comment-id **at the start of handling** — the ids the cycle actually read when it derived the wave, before any reply is posted — and advance the watermark to exactly those. **Never** re-derive it from a live-max fetched after the replies land: a reviewer comment that arrives during the handling window — between reading the wave and posting the replies — lands below that post-reply max and is marked seen without ever being read. Snapshotting at the start-of-handling read keeps such a comment above the watermark, so the next tick surfaces it. That advance is also what stops the loop from reporting its own reply; a cycle that skips it leaves the watermark stale, and the next event is an echo.
59
+ **After a cycle** — advance the watermark to the **handled wave's snapshot**, in the same dispatched context that ran the cycle. Capture the max review-id, comment-id and conversation-comment id **at the start of handling** — the ids the cycle actually read when it derived the wave, before any reply is posted — and advance the watermark to exactly those. **Never** re-derive it from a live-max fetched after the replies land: a reviewer comment that arrives during the handling window — between reading the wave and posting the replies — lands below that post-reply max and is marked seen without ever being read. Snapshotting at the start-of-handling read keeps such a comment above the watermark, so the next tick surfaces it. That advance is also what stops the loop from reporting its own reply; a cycle that skips it leaves the watermark stale, and the next event is an echo.
60
60
 
61
- **Scan before advancing — a hard invariant.** Before writing the advanced watermark, confirm every unresolved review thread in the handled wave has been addressed: a reply posted, or an explicit deferral recorded. If any unresolved thread is still unaddressed, do **not** advance past it — leave its newest-comment id above the `COM` floor and its thread id out of the known-unresolved `THREADS` set, so the loop's next iteration wakes on it and the next tick re-surfaces it. The watermark only ever moves over threads that were actually handled.
61
+ **Scan before advancing — a hard invariant.** Before writing the advanced watermark, confirm every unresolved review thread in the handled wave has been addressed: a reply posted, or an explicit deferral recorded. If any unresolved thread is still unaddressed, do **not** advance past it — leave its newest-comment id above the `COM` floor and its thread id out of the known-unresolved `THREADS` set, so the loop's next iteration wakes on it and the next tick re-surfaces it. The watermark only ever moves over threads that were actually handled. Conversation comments follow the same rule: `CONV` advances only past a conversation comment the cycle replied to, folded as needing no reply, or escalated — an unaddressed one stays above it.
62
62
 
63
63
  Arm a fresh loop only when none is alive — judged by the `<slot>/watch.pid` lease (a live PID means a watcher already owns the slot), not by the in-session task list, since an orphaned OS loop outlives the session that launched it; the settle path never duplicates a running watch. The one exception is answering the slot's own loop ending (Step 3).
64
64
 
@@ -53,7 +53,7 @@ For each PR URL in the track list, run the [`bootstrap.md`](bootstrap.md) proced
53
53
  - **Existing slot → skip silently** (never the slot-conflict abort); add it to the *skipped* list.
54
54
  - **`caller = "auto-track"`** in the bootstrap telemetry event.
55
55
 
56
- Everything else is unchanged: URL parse, metadata + terminal-PR abort, slug, `lastBodyReviewId` 0 (line-comment threads are picked up live from thread state; body-only reviews from id 0), and the `prs.json`/`last_seen.json`/`cron.json`/`state.md` writes minus the pre-flight block.
56
+ Everything else is unchanged: URL parse, metadata + terminal-PR abort, slug, `lastBodyReviewId` 0 and `lastConversationCommentId` 0 (line-comment threads are picked up live from thread state; body-only reviews and conversation comments from id 0), and the `prs.json`/`last_seen.json`/`cron.json`/`state.md` writes minus the pre-flight block.
57
57
 
58
58
  ### Step 5 — Print the summary
59
59
 
@@ -57,6 +57,8 @@ Line-comment threads need no seeding — the watcher derives them from live thre
57
57
  - **Default (no `--forward-only`):** `lastBodyReviewId = 0`. The watcher picks up every existing body-only review on its first tick. Matches the common case — the user opened the PR, left feedback they want addressed, and is now bootstrapping.
58
58
  - **With `--forward-only`:** fetch reviews per [`../_shared/vcs/github/submitted-reviews.md`](../_shared/vcs/github/submitted-reviews.md), then take `max(id)`. Body-only reviews at or below that id are treated as already-handled. This no longer hides existing line-comment threads — those are always picked up from thread state.
59
59
 
60
+ `lastConversationCommentId`, the watermark for top-level PR comments (GitHub only), follows the same rule: `0` by default, and under `--forward-only` the highest comment id from [`../_shared/vcs/github/conversation-comments.md`](../_shared/vcs/github/conversation-comments.md).
61
+
60
62
  ### Step 6.5 — Resolve the validation context (skip when there's nothing to E2E)
61
63
 
62
64
  The only step that may prompt the user, and only when the PR has a testable surface. Run silent detection from [`../_shared/resolve-e2e-validation-context.md`](../_shared/resolve-e2e-validation-context.md) first. If it finds **no dev server / no testable surface** — a docs, config, skill, or library change, or a non-web repo — seed the watcher **poll-only**: no prompt, no `## Pre-flight answers` block, continue to Step 7 (same as [`auto-track`](auto-track.md)).
@@ -75,7 +77,7 @@ Write under `~/.muggle-ai/muggle-do/sessions/<slug>/`:
75
77
 
76
78
  **`prs.json`** — see [`state-schemas.md`](state-schemas.md#prsjson). One entry, `state` = `"open"`, `head_sha` from Step 2's `headRefOid`.
77
79
 
78
- **`last_seen.json`** — see [`state-schemas.md`](state-schemas.md#last_seenjson). One key (`"<owner>/<repo>#<n>"`), `lastBodyReviewId` from Step 6, `last_pushed_sha: null`, `idle_tick_count: 0`, `cycles_completed: 0`, `escalated_review_ids: []`, `pushed_shas: []`. Omit `blocked` — the watcher starts unblocked.
80
+ **`last_seen.json`** — see [`state-schemas.md`](state-schemas.md#last_seenjson). One key (`"<owner>/<repo>#<n>"`), `lastBodyReviewId` and `lastConversationCommentId` from Step 6, `last_pushed_sha: null`, `idle_tick_count: 0`, `cycles_completed: 0`, `escalated_review_ids: []`, `escalated_conversation_comment_ids: []`, `pushed_shas: []`. Omit `blocked` — the watcher starts unblocked.
79
81
 
80
82
  **`cron.json`** — see [`state-schemas.md`](state-schemas.md#cronjson). `cron_id: null` (bootstrap arms no cron; a tick running under one recorded by [`reconcile.md`](reconcile.md) self-records its id per [`record-cron-id.md`](record-cron-id.md)), `command: "/muggle:muggle-pr-followup <slug> <n>"`, `interval: "1m"`, `recorded_at: <now>`.
81
83
 
@@ -78,7 +78,7 @@ Run the resume gate per [`blocked-tick.md`](blocked-tick.md): recompute the fing
78
78
 
79
79
  ### Step 3 — Compute the actionable set from live thread state
80
80
 
81
- The watcher's dispatch trigger is **derived from current provider state**, not a stored review-id cursor — see the [thread-state baseline design](../../../../muggle-ai-brain/architecture/2026-06-06-pr-followup-thread-state-baseline-design.md). Resolve the provider per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md), then:
81
+ The watcher's dispatch trigger is **derived from current provider state**, not a stored review-id cursor (body-only reviews and conversation comments, which have no thread state, are the two narrow exceptions below) — see the [thread-state baseline design](../../../../muggle-ai-brain/architecture/2026-06-06-pr-followup-thread-state-baseline-design.md). Resolve the provider per [`../_shared/vcs/detect-vcs.md`](../_shared/vcs/detect-vcs.md), then:
82
82
 
83
83
  - **`github`** — two sources, unioned:
84
84
 
@@ -86,7 +86,9 @@ The watcher's dispatch trigger is **derived from current provider state**, not a
86
86
 
87
87
  **(b) Actionable body-only reviews — GitHub only.** A body-only review — a submitted `CHANGES_REQUESTED`/`COMMENTED` review with no line comments — has no thread to derive state from, so it keeps a narrow watermark. GitLab has no review envelope (feedback is always a discussion note), so this sub-branch is GitHub-only and has no GitLab analogue. Fetch submitted reviews per [`../_shared/vcs/github/submitted-reviews.md`](../_shared/vcs/github/submitted-reviews.md); a body-only review is actionable when `id > last_seen.lastBodyReviewId` **and** `id ∉ last_seen.escalated_review_ids`.
88
88
 
89
- Collect the **owning review ids** for dispatch: for each actionable thread, the owning review of its newest comment (`pullRequestReview.databaseId` from the query); plus every actionable body-only review id. The dedup'd union is the dispatch list.
89
+ **(c) Actionable conversation comments — GitHub only.** A top-level PR comment on the Conversation tab belongs to no review and no thread, so it keeps its own narrow watermark, like a body-only review. Fetch them per [`../_shared/vcs/github/conversation-comments.md`](../_shared/vcs/github/conversation-comments.md); one is actionable when `id > last_seen.lastConversationCommentId`, `id ∉ last_seen.escalated_conversation_comment_ids`, and muggle did not post it and no bot wrote it — the same exclusions the watch loop's projection applies. An entry with no `lastConversationCommentId` key predates this source: write the highest actionable id as its value (whole-file rewrite) and dispatch none of them ([`state-schemas.md`](state-schemas.md#last_seenjson)).
90
+
91
+ Collect the **owning review ids** for dispatch: for each actionable thread, the owning review of its newest comment (`pullRequestReview.databaseId` from the query); plus every actionable body-only review id. The dedup'd union is the dispatch list. Actionable conversation comment ids travel beside it as a second list: they are issue-comment ids, a different sequence, and never mix with review ids.
90
92
 
91
93
  - **`gitlab`** — single source. Fetch unresolved discussions per [`../_shared/vcs/gitlab/unresolved-discussions.md`](../_shared/vcs/gitlab/unresolved-discussions.md) (drop to [`../_shared/vcs/gitlab/mr-discussions.md`](../_shared/vcs/gitlab/mr-discussions.md) for the raw notes if a thread's classification needs them). A discussion is **actionable** when it is unresolved **and** its newest note lacks the loop marker `<!-- muggle-do:bot -->` — same marker classification, never `author.username`. There is no body-only watermark: discussion state is the sole authority. The dispatch list is the **discussion ids** of the actionable discussions.
92
94
 
@@ -100,13 +102,15 @@ The watcher does **not** classify. Classification, batching, replying, escalatio
100
102
  - PR URL (from `prs.json[0].url`)
101
103
  - Session slug (from the invocation arguments)
102
104
  - The dispatch ids from Step 3 (GitHub owning review ids / GitLab discussion ids), as a space-separated list
105
+ - GitHub: the actionable conversation comment ids from Step 3(c), after the keyword `conversation`; omitted when there are none
103
106
 
104
107
  Exact phrasing belongs to `/muggle-do`'s intent-routing. A reasonable shape is:
105
108
  ```
106
- /muggle-do address reviews <id1> <id2> ... on <pr-url> slug=<slug>
109
+ /muggle-do address reviews <id1> <id2> ... [conversation <cid1> <cid2> ...] on <pr-url> slug=<slug>
107
110
  ```
111
+ A wave of conversation comments alone dispatches with an empty review list: `address reviews conversation <cid1> on <pr-url> slug=<slug>`.
108
112
  4. Append a dispatching line to `followup.log` per [`output-templates/watcher-log.md`](output-templates/watcher-log.md).
109
- 5. Emit a `tick` event with `actionable_threads: <count>`, `dispatched_review_ids: [<id>, ...]`.
113
+ 5. Emit a `tick` event with `actionable_threads: <count>` (conversation comments included), `dispatched_review_ids: [<id>, ...]`.
110
114
  6. Exit. **Reviews preempt CI** — when there is actionable feedback, this tick dispatches address-reviews and never polls CI. The watcher is now stopped; the dev cycle owns the PR and restarts the watcher when it finishes. (The watcher also self-unschedules in Step 2, terminal.)
111
115
 
112
116
  ### Step 5 — No actionable feedback → read the branch's standing against its base