@codedrifters/configulator 0.0.353 → 0.0.355

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.
package/lib/index.js CHANGED
@@ -13777,7 +13777,36 @@ function renderIssueWorkerSkillBody(task, lines) {
13777
13777
  "",
13778
13778
  `Route matched issues to \`.claude/agents/${task.agent}.md\` and`,
13779
13779
  "execute its phase-specific workflow.",
13780
- "",
13780
+ ""
13781
+ );
13782
+ if (task.taskId === "worker-issue") {
13783
+ lines.push(
13784
+ "## Feedback-pull scan (runs before issue selection)",
13785
+ "",
13786
+ "Because you run autonomously (scheduled mode), **also scan for PRs",
13787
+ "needing feedback work before scanning the issue queue** \u2014 and",
13788
+ "prefer them. The pr-reviewer hands fixes off by applying a durable",
13789
+ "`review:needs-worker` marker on the PR (it cannot spawn you in",
13790
+ "session). Pull that marker instead of waiting for an explicit push:",
13791
+ "",
13792
+ "```bash",
13793
+ "gh pr list --state open --label 'review:needs-worker' \\",
13794
+ " --json number,labels,headRefName,updatedAt",
13795
+ "```",
13796
+ "",
13797
+ "If any open PR carries an unconsumed `review:needs-worker` fix-list,",
13798
+ "enter **feedback mode** for the highest-priority match (no explicit",
13799
+ "`feedback mode: PR #<n>` push required) and run the issue-worker's",
13800
+ "feedback-mode phases: apply the fix-list, push, write the",
13801
+ "worker-report comment, and **clear `review:needs-worker`** (leave",
13802
+ "`review:fixing` for the reviewer's confirm pass). Only when no PR",
13803
+ "needs a worker do you fall through to the issue-queue selection",
13804
+ "above. See the **Invocation Mode** and **Phase 1** sections of",
13805
+ "`.claude/agents/issue-worker.md` for the full contract.",
13806
+ ""
13807
+ );
13808
+ }
13809
+ lines.push(
13781
13810
  "## Recommended model",
13782
13811
  "",
13783
13812
  `**${capitalize(task.recommendedModel)}** \u2014 see`,
@@ -16123,15 +16152,31 @@ var issueWorkerSubAgent = {
16123
16152
  " **not** create a new branch and you do **not** open a new PR \u2014 you",
16124
16153
  " push additional commits to the same branch.",
16125
16154
  "",
16126
- "**You are in feedback mode if and only if the invocation prompt that",
16127
- "started this session contains the literal phrase `feedback mode: PR #<n>`",
16128
- "(where `<n>` is the PR number).** This mirrors the `scheduled mode` /",
16129
- "`non-interactive` string-match convention above. Otherwise, default to",
16130
- "normal mode.",
16155
+ "You enter feedback mode in one of **two** ways:",
16156
+ "",
16157
+ "1. **Pushed (explicit).** The invocation prompt that started this",
16158
+ " session contains the literal phrase `feedback mode: PR #<n>`",
16159
+ " (where `<n>` is the PR number). This mirrors the `scheduled",
16160
+ " mode` / `non-interactive` string-match convention above and works",
16161
+ " in both interactive and scheduled invocations (a human asks you",
16162
+ " to fix a PR, or the orchestrator hands one off as a stopgap).",
16163
+ "2. **Pulled (autonomous, scheduled only).** In **scheduled mode**,",
16164
+ " even without an explicit `feedback mode: PR #<n>` push, you also",
16165
+ " discover PRs needing feedback work by scanning open PRs for the",
16166
+ " durable `review:needs-worker` marker (see Phase 1). When you pick",
16167
+ " one up, you enter feedback mode for that PR autonomously. This is",
16168
+ " how the reviewer's pull-based hand-off completes without any",
16169
+ " depth-2 sub-agent spawn \u2014 the reviewer applies the marker, you",
16170
+ " pull it.",
16171
+ "",
16172
+ "Otherwise, default to normal mode. The explicit `feedback mode: PR",
16173
+ "#<n>` push path always wins: when present, work that PR and do not",
16174
+ "scan the queue.",
16131
16175
  "",
16132
16176
  "Interactive vs scheduled and normal vs feedback are independent axes.",
16133
16177
  "Feedback mode can run interactively (a human asks you to fix a PR) or",
16134
- "on a schedule (the pr-reviewer hands off the PR). The interactive",
16178
+ "on a schedule (autonomously pulled from the `review:needs-worker`",
16179
+ "queue, or pushed by the orchestrator). The interactive",
16135
16180
  "pause-before-commit rule (Phase 6) applies in either work mode.",
16136
16181
  "",
16137
16182
  "When in feedback mode, the per-phase behaviour changes as documented",
@@ -16139,12 +16184,13 @@ var issueWorkerSubAgent = {
16139
16184
  "",
16140
16185
  "| Phase | Normal mode | Feedback mode |",
16141
16186
  "|-------|-------------|---------------|",
16142
- "| 1. Select an Issue | Pick from queue or use provided issue number | **Skip.** Use the PR number from the invocation prompt. |",
16187
+ "| 1. Select an Issue | Pick from queue or use provided issue number | **Pushed:** use the PR number from the prompt. **Pulled (scheduled):** scan open PRs for `review:needs-worker`, pick the highest-priority match. Feedback PRs are preferred over fresh issues. |",
16143
16188
  "| 2. Claim the Issue | Toggle status labels on the issue | **Skip.** The issue is already `status:in-progress`. |",
16144
16189
  "| 3. Set Up | Checkout default branch, create new branch | Checkout the existing PR branch via `gh pr view` and `git checkout <headRefName>`. |",
16145
16190
  "| 4. Implement | Read issue AC, implement | Read most-recent reviewer-authored fix-list comment on the PR, parse JSON, apply each item. |",
16146
16191
  "| 5. Verify | Unchanged | Unchanged. |",
16147
16192
  "| 6. Commit and Push | Conventional commit, interactive pause | Commit message `fix(review): <summary> (PR #<n>)`. Pause behaviour unchanged. `git push` (no `-u`). |",
16193
+ "| 6.5. Complete the hand-off | n/a | Write the structured worker-report comment, then **clear `review:needs-worker`** (leave `review:fixing` for the reviewer's confirm pass). |",
16148
16194
  "| 7. Open a PR | Open a new PR | **Skip.** |",
16149
16195
  "| 8. Update Status | Set issue to `status:ready-for-review` | **Skip.** PR is still open; issue stays `status:in-progress`. |",
16150
16196
  "| 9. Branch Cleanup | Poll for merge, delete branch | **Skip.** Return control to the pr-reviewer without polling. |",
@@ -16154,9 +16200,40 @@ var issueWorkerSubAgent = {
16154
16200
  ...PROJECT_CONTEXT_READER_SECTION,
16155
16201
  "## Phase 1: Select an Issue",
16156
16202
  "",
16157
- "**Feedback mode:** Skip this phase entirely. Extract the PR number from",
16158
- "the `feedback mode: PR #<n>` phrase in your invocation prompt and use",
16159
- "it for the rest of the workflow.",
16203
+ "**Feedback mode (pushed):** When the invocation prompt contains an",
16204
+ "explicit `feedback mode: PR #<n>` phrase, skip the rest of this phase.",
16205
+ "Extract the PR number from that phrase and use it for the rest of the",
16206
+ "workflow. The explicit push always wins \u2014 do not scan the queue.",
16207
+ "",
16208
+ "**Feedback-pull discovery (scheduled mode, no explicit push).** Before",
16209
+ "scanning the issue queue, check for PRs needing feedback work. This is",
16210
+ "how the pr-reviewer's pull-based hand-off completes: the reviewer",
16211
+ "applies a durable `review:needs-worker` marker and exits; you discover",
16212
+ "it here. **Feedback PRs are preferred over fresh issues** \u2014 a queued",
16213
+ "fix-list is a half-finished unit of work and should land before a new",
16214
+ "one starts.",
16215
+ "",
16216
+ "Scan open PRs carrying the marker, sorted highest-priority first:",
16217
+ "",
16218
+ "```bash",
16219
+ "gh pr list --state open --label 'review:needs-worker' \\",
16220
+ " --json number,labels,headRefName,updatedAt",
16221
+ "```",
16222
+ "",
16223
+ "For each candidate, confirm it carries an **unconsumed** reviewer",
16224
+ "fix-list \u2014 a `review:needs-worker` label that the reviewer applied",
16225
+ "alongside a `## Reviewer: fix list for @issue-worker` comment whose",
16226
+ "` ```json fix-list ` block has not yet been applied by a worker",
16227
+ "(no newer worker-report comment from you). Pick the **highest-priority**",
16228
+ "match (use the linked issue's `priority:*` label; break ties by oldest",
16229
+ "`updatedAt`). Enter feedback mode for that PR **without** requiring an",
16230
+ "explicit `feedback mode: PR #<n>` push, and run Phases 3\u20136.5 against",
16231
+ "it. If no PR carries an unconsumed `review:needs-worker` marker, fall",
16232
+ "through to normal-mode issue selection below.",
16233
+ "",
16234
+ "(Interactive sessions do **not** auto-pull \u2014 a human who wants a",
16235
+ "specific PR fixed passes `feedback mode: PR #<n>` explicitly. The",
16236
+ "autonomous pull is scheduled-mode only.)",
16160
16237
  "",
16161
16238
  "**Normal mode:**",
16162
16239
  "If an issue number was provided in your instructions, use that issue.",
@@ -16510,6 +16587,47 @@ var issueWorkerSubAgent = {
16510
16587
  "git push -u origin <branch-name>",
16511
16588
  "```",
16512
16589
  "",
16590
+ "## Phase 6.5: Complete the Feedback Hand-off",
16591
+ "",
16592
+ "**Normal mode:** Skip this phase entirely.",
16593
+ "",
16594
+ "**Feedback mode:** After the fix commits are pushed (Phase 6), close",
16595
+ "the pull-based hand-off so the pr-reviewer's confirm pass can pick it",
16596
+ "up.",
16597
+ "",
16598
+ "1. **Write the structured worker-report comment** on the PR. It is",
16599
+ " the record the reviewer's confirm pass reads to react on source",
16600
+ " comments and re-evaluate AC/CI. Include: the PR number, the commit",
16601
+ " SHAs you pushed (or the rebased head SHA for a synthetic-rebase",
16602
+ " item), and a per-item outcome keyed by `comment_id` \u2014 `handled`",
16603
+ " or `failed` (with a short reason for each failure). This is the",
16604
+ " same structured report you would otherwise return to the caller in",
16605
+ " the pushed-feedback case; post it as a PR comment so a separate",
16606
+ " reviewer session can consume it.",
16607
+ "",
16608
+ " ```bash",
16609
+ " gh pr comment <pr-number> --body-file <worker-report-path>",
16610
+ " ```",
16611
+ "",
16612
+ "2. **Clear the `review:needs-worker` marker.** This signals the",
16613
+ " reviewer that the delegation has been consumed. Leave the",
16614
+ " `review:fixing` lease in place \u2014 the reviewer's confirm pass",
16615
+ " releases it after reacting and re-evaluating. Clearing the marker",
16616
+ " is what flips the PR into the lease-without-marker state the",
16617
+ " confirm pass keys on.",
16618
+ "",
16619
+ " ```bash",
16620
+ " gh pr edit <pr-number> --remove-label 'review:needs-worker'",
16621
+ " ```",
16622
+ "",
16623
+ "Do **not** remove `review:fixing` yourself, and do **not** re-enable",
16624
+ "auto-merge \u2014 both belong to the reviewer's confirm pass. If you could",
16625
+ "not apply any item (every item `failed`), still write the report and",
16626
+ "still clear `review:needs-worker`: the reviewer's confirm pass reacts",
16627
+ "`thinking_face` on the failed items and falls through to the",
16628
+ "human-required hand-off via `review:awaiting-human`. Leaving the",
16629
+ "marker applied on a total failure would wedge the PR.",
16630
+ "",
16513
16631
  "## Phase 7: Open a PR",
16514
16632
  "",
16515
16633
  "**Feedback mode:** Skip this phase entirely. The PR already exists; you",
@@ -16556,9 +16674,13 @@ var issueWorkerSubAgent = {
16556
16674
  "## Phase 9: Branch Cleanup",
16557
16675
  "",
16558
16676
  "**Feedback mode:** Skip this phase entirely. Do not poll the PR state",
16559
- "and do not delete the local branch. Return control to the pr-reviewer",
16560
- "with the structured report from Phase 4 (PR number, commit SHAs pushed,",
16561
- "items handled by `comment_id`, items that failed to apply).",
16677
+ "and do not delete the local branch. You have already posted the",
16678
+ "structured worker-report comment and cleared `review:needs-worker` in",
16679
+ "Phase 6.5 \u2014 the pr-reviewer's confirm pass picks up the hand-off from",
16680
+ "the lease-without-marker label state. Return control to the caller",
16681
+ "with the same structured report (PR number, commit SHAs pushed, items",
16682
+ "handled by `comment_id`, items that failed to apply) so a pushing",
16683
+ "orchestrator can log it.",
16562
16684
  "",
16563
16685
  "**Normal mode:**",
16564
16686
  "",
@@ -16626,7 +16748,24 @@ var issueWorkerSubAgent = {
16626
16748
  " with a `BLOCKED_ON_SCOPE` report if the classifier returns",
16627
16749
  " `large`. Never claim, branch, or implement a `large` issue \u2014",
16628
16750
  " the orchestrator must decompose it first. See the **Scope gate**",
16629
- " section in `CLAUDE.md` for the contract."
16751
+ " section in `CLAUDE.md` for the contract.",
16752
+ "15. **Prefer feedback PRs over fresh issues (scheduled mode).** When",
16753
+ " running autonomously, scan open PRs for the `review:needs-worker`",
16754
+ " marker **before** scanning the issue queue, and pick up the",
16755
+ " highest-priority unconsumed fix-list first. A half-finished PR",
16756
+ " should land before a new unit of work starts. The explicit",
16757
+ " `feedback mode: PR #<n>` push always overrides both scans.",
16758
+ "16. **Clear `review:needs-worker`, never `review:fixing`.** On",
16759
+ " completing a feedback hand-off (Phase 6.5), write the structured",
16760
+ " worker-report comment and remove **only** the",
16761
+ " `review:needs-worker` marker. The `review:fixing` lease belongs",
16762
+ " to the reviewer's confirm pass \u2014 never remove it yourself, and",
16763
+ " never re-enable auto-merge. Clear the marker even when every item",
16764
+ " failed, so a crashed delegation does not wedge the PR.",
16765
+ "17. **Auto-pull only in scheduled mode.** The autonomous",
16766
+ " `review:needs-worker` scan is scheduled-mode only. In an",
16767
+ " interactive session, never auto-pull a feedback PR \u2014 a human who",
16768
+ " wants one fixed passes `feedback mode: PR #<n>` explicitly."
16630
16769
  ].join("\n")
16631
16770
  };
16632
16771
  var ORCHESTRATOR_CONVENTIONS_PREAMBLE = [
@@ -18182,8 +18321,12 @@ var prReviewerSubAgent = {
18182
18321
  " conflicting files). The guards and classification are identical to",
18183
18322
  " the Phase 4 entry point.",
18184
18323
  "- **On the procedure returning `delegated`:** a rebase has been",
18185
- " delegated to `issue-worker`; stop this pass. A human re-invokes",
18186
- " the reviewer once the worker pushes the rebased branch.",
18324
+ " durably queued for `issue-worker` (the PR now carries",
18325
+ " `review:needs-worker` and the `review:fixing` lease); stop this",
18326
+ " pass. A top-level `issue-worker` session pulls the marker and",
18327
+ " pushes the rebased branch, then a follow-up reviewer pass confirms",
18328
+ " the result and releases the lease \u2014 no human re-invocation is",
18329
+ " required for the loop to complete.",
18187
18330
  "- **On the procedure returning `skipped` (a guard denied delegation",
18188
18331
  " or the guards failed):** fall back to the original hard reject \u2014",
18189
18332
  " post the merge-conflict rejection comment and stop. Use this",
@@ -18327,7 +18470,12 @@ var prReviewerSubAgent = {
18327
18470
  " `review:human-required` label, set `mode = human-required`.",
18328
18471
  "3. **Labels that force human** \u2014 if the PR carries any label listed",
18329
18472
  " under `human-required.labels-that-force-human` (e.g.",
18330
- " `priority:critical`), set `mode = human-required`.",
18473
+ " `review:human-required`), set `mode = human-required`. Evaluate",
18474
+ " the PR's **own** labels only \u2014 rules 1\u20133 never traverse the",
18475
+ " `Closes #N` link to read the linked issue's labels. `priority:*`",
18476
+ " and `status:*` are issue-triage labels for the orchestrator's",
18477
+ " scheduling queue, not merge-risk signals, and are never listed",
18478
+ " here.",
18331
18479
  "4. **Path globs** \u2014 if any file in the PR diff matches any glob in",
18332
18480
  " `human-required.paths`, set `mode = human-required`. Record the",
18333
18481
  " first matching path + glob pair as the reason.",
@@ -18599,14 +18747,20 @@ var prReviewerSubAgent = {
18599
18747
  "",
18600
18748
  "When the invocation guard above permits delegation **and** Phase 3.5",
18601
18749
  "queued one or more `in-scope` items, the reviewer hands the fix work",
18602
- "off to `issue-worker` in feedback mode. The reviewer never edits the",
18603
- "PR's branch itself.",
18604
- "",
18605
- "Run the steps below in order. Steps (a) through (g) apply in **both**",
18606
- "`auto-merge` and `human-required` review modes. Step (h) is",
18607
- "auto-merge-only \u2014 in `human-required` mode the reviewer skips it,",
18608
- "leaves `review:awaiting-human` applied, and lets the human own the",
18609
- "final merge.",
18750
+ "off to `issue-worker` via a **pull-based** marker. The reviewer never",
18751
+ "edits the PR's branch itself and never spawns `issue-worker` in",
18752
+ "session \u2014 it posts the fix-list, applies the `review:needs-worker`",
18753
+ "marker, holds the `review:fixing` lease across sessions, and exits.",
18754
+ "A top-level `issue-worker` session pulls the work; a later reviewer",
18755
+ "pass confirms it via the **Shared Procedure: Confirm a Completed",
18756
+ "Delegation**.",
18757
+ "",
18758
+ "Run steps (a) through (e) below in order. They apply in **both**",
18759
+ "`auto-merge` and `human-required` review modes \u2014 the mode-specific",
18760
+ "auto-merge decision is deferred to the confirm pass, which only",
18761
+ "re-enables auto-merge in `auto-merge` mode (in `human-required` mode",
18762
+ "the confirm pass leaves `review:awaiting-human` applied and lets the",
18763
+ "human own the final merge).",
18610
18764
  "",
18611
18765
  "#### a. Handle AC drift first",
18612
18766
  "",
@@ -18705,103 +18859,48 @@ var prReviewerSubAgent = {
18705
18859
  "(or `--body` if the body is short). Capture the resulting comment id",
18706
18860
  "in memory so Phase 4.5 can cite the fix-list URL in the sticky.",
18707
18861
  "",
18708
- "#### e. Invoke `issue-worker` in feedback mode",
18709
- "",
18710
- "Hand the fix work off to the `issue-worker` sub-agent. The invocation",
18711
- "prompt **must** contain the literal phrase `feedback mode: PR #<n>`",
18712
- "(with the actual PR number substituted) so the worker enters its",
18713
- "feedback-mode branch instead of selecting a new issue. The prompt",
18714
- "must also include the repository (`{{repository.owner}}/{{repository.name}}`)",
18715
- "and the PR number explicitly \u2014 do not rely on the worker inferring",
18716
- "either from context.",
18717
- "",
18718
- "Wait for the worker to return its structured report. The report",
18719
- "lists, per item, the `comment_id` and a status of `handled` or",
18720
- "`failed` (with a short failure reason for the latter). If the worker",
18721
- "errors out without returning a report, treat **every** item as failed",
18722
- "and proceed to step (f) so source comments still get a reaction.",
18723
- "",
18724
- "#### f. Process the worker's report",
18725
- "",
18726
- "For every item the worker reports:",
18862
+ "#### e. Apply the `review:needs-worker` marker and exit `delegated`",
18727
18863
  "",
18728
- "- **`handled`** \u2014 react `rocket` on the original source comment to",
18729
- " signal the accepted change has landed. Use the same comment",
18730
- " endpoint the comment originated from (`issues/comments/...` for",
18731
- " PR-level, `pulls/comments/...` for inline).",
18732
- "- **`failed`** \u2014 react `thinking_face` (`content=confused`) on the",
18733
- " original source comment **and** post a reply on the same thread",
18734
- " explaining why the fix could not be applied (cite the failure",
18735
- " reason returned by the worker).",
18864
+ "Hand the fix work off to `issue-worker` **by marker, not by spawn**.",
18865
+ "Do **not** invoke `issue-worker` via the `Agent` tool from this pass:",
18866
+ "the reviewer frequently runs at depth-1 (the orchestrator's PR sweep",
18867
+ "dispatches it as a sub-agent), and the runtime forbids a depth-1",
18868
+ "sub-agent from spawning a depth-2 sub-agent \u2014 an in-session dispatch",
18869
+ "would silently abort and the fix-list would never be consumed.",
18870
+ "Instead, apply the durable `review:needs-worker` marker so a",
18871
+ "top-level `issue-worker` session discovers the PR and pulls the",
18872
+ "fix-list:",
18736
18873
  "",
18737
18874
  "```bash",
18738
- "# Rocket reaction on a successfully handled PR-level comment",
18739
- "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<comment-id>/reactions \\",
18740
- " -X POST -f content=rocket",
18741
- "",
18742
- "# thinking_face + reply on a failed item",
18743
- "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<comment-id>/reactions \\",
18744
- " -X POST -f content=confused",
18745
- "gh pr comment <pr-number> --body '<failure explanation citing the worker report>'",
18746
- "```",
18747
- "",
18748
- "#### g. Release the `review:fixing` lease",
18749
- "",
18750
- "Remove the lease label so the PR is open for the next delegation",
18751
- "pass. Always run this step \u2014 even when the worker reported every",
18752
- "item as failed:",
18753
- "",
18754
- "```bash",
18755
- "gh pr edit <pr-number> --remove-label 'review:fixing'",
18875
+ "gh pr edit <pr-number> --add-label 'review:needs-worker'",
18756
18876
  "```",
18757
18877
  "",
18758
- "#### h. Conditionally re-enable auto-merge (auto-merge mode only)",
18759
- "",
18760
- "Re-enable squash auto-merge **only if all four** of the following",
18761
- "conditions hold. If any condition fails, leave auto-merge disabled",
18762
- "and let the next reviewer pass re-evaluate:",
18763
- "",
18764
- "1. The review mode decided in Phase 2.75 is still `auto-merge`",
18765
- " (re-evaluate against the current PR labels in case a maintainer",
18766
- " added `review:human-required` between passes).",
18767
- "2. **All** acceptance criteria are met against the **updated** diff",
18768
- " produced by the worker \u2014 re-run the Phase 3 comparison; do not",
18769
- " reuse the pre-delegation result.",
18770
- "3. **No** unresolved `thinking_face` reactions authored by the",
18771
- " reviewer remain on any PR comment \u2014 including the AC-drift",
18772
- " pushbacks added in step (a) and the failure pushbacks added in",
18773
- " step (f).",
18774
- "4. CI is green or still pending (any failing required check",
18775
- " disqualifies re-enablement). Resolve CI via the **CI",
18776
- " Verification** section, including the Actions-runs fallback on a",
18777
- " fine-grained-PAT 403.",
18778
- "",
18779
- "When all four hold, re-enable auto-merge with the same command used",
18780
- "in the auto-merge branch below:",
18781
- "",
18782
- "```bash",
18783
- "gh pr merge <pr-number> --auto --squash --delete-branch \\",
18784
- " --subject '<conventional-commit-title>' \\",
18785
- " --body '<extended-description>'",
18786
- "```",
18787
- "",
18788
- "In `human-required` mode, **skip step (h) entirely**. The",
18789
- "`review:awaiting-human` label stays applied (re-add it if a previous",
18790
- "step removed it), and the human reviewer owns the final merge",
18791
- "decision.",
18792
- "",
18793
- "#### i. Update the sticky summary",
18794
- "",
18795
- "After step (g) (and step (h) when applicable) completes, fall through",
18796
- "to Phase 4.5 to update the sticky `## Reviewer notes` comment with",
18797
- "the new state. Cite at minimum:",
18878
+ "Then **exit this pass returning `delegated`**, holding the",
18879
+ "`review:fixing` lease across sessions. Do **not** wait for the",
18880
+ "worker, do **not** process a report, and do **not** re-enable",
18881
+ "auto-merge in this pass. The worker applies the fix-list in its own",
18882
+ "top-level session, pushes, writes a structured worker-report comment,",
18883
+ "and clears `review:needs-worker`. A **subsequent** reviewer pass",
18884
+ "detects the lease-without-marker state and runs the **Shared",
18885
+ "Procedure: Confirm a Completed Delegation** below \u2014 that is where the",
18886
+ "`rocket` / `thinking_face` reactions, the AC/CI re-evaluation, the",
18887
+ "auto-merge re-enablement, and the `review:fixing` release happen.",
18888
+ "",
18889
+ "Before exiting, fall through to Phase 4.5 to update the sticky",
18890
+ "`## Reviewer notes` comment with the delegation state. Cite at",
18891
+ "minimum:",
18798
18892
  "",
18799
18893
  "- The fix-list comment URL produced in step (d).",
18800
- "- The commit SHAs the worker pushed (from its structured report).",
18801
- "- Per-item outcome (`handled` / `failed`) with the source comment URL.",
18802
- "- The auto-merge re-enablement decision and reason (which of the",
18803
- " four conditions, if any, blocked it).",
18804
- "- The next-step the human or the next reviewer pass should take.",
18894
+ "- That the PR now carries `review:needs-worker` and is awaiting a",
18895
+ " top-level `issue-worker` pass.",
18896
+ "- That `review:fixing` is held across sessions until a confirm pass",
18897
+ " releases it.",
18898
+ "- The next-step: a top-level `issue-worker` run pulls the fix-list,",
18899
+ " then a follow-up reviewer pass confirms.",
18900
+ "",
18901
+ "Per-item `handled` / `failed` outcomes, the pushed commit SHAs, and",
18902
+ "the auto-merge decision are recorded on the **confirm pass**, not",
18903
+ "here \u2014 this pass has not yet seen the worker's result.",
18805
18904
  "",
18806
18905
  "### If all acceptance criteria are met and CI is green",
18807
18906
  "",
@@ -18845,7 +18944,7 @@ var prReviewerSubAgent = {
18845
18944
  "when the mode is `human-required` and any of the following fired:",
18846
18945
  "",
18847
18946
  "- rule 2 (`review:human-required` label),",
18848
- "- rule 3 (any `labels-that-force-human` label such as `priority:critical`),",
18947
+ "- rule 3 (any `labels-that-force-human` label),",
18849
18948
  "- rule 4 (`human-required.paths` glob match), or",
18850
18949
  "- rule 5 (`human-required.issue-types` match).",
18851
18950
  "",
@@ -19233,28 +19332,37 @@ var prReviewerSubAgent = {
19233
19332
  " ```",
19234
19333
  " ```",
19235
19334
  "",
19236
- "4. **Invoke `issue-worker` in feedback mode** with the same prompt",
19237
- " shape used by the in-scope-fix flow: include the literal phrase",
19238
- " `feedback mode: PR #<n>` plus the repository identifier",
19239
- " (`{{repository.owner}}/{{repository.name}}`).",
19240
- "",
19241
- "5. **Process the worker's report** for the synthetic item using the",
19242
- " same logic as step (f) of the in-scope-fix flow \u2014 `handled` reacts",
19243
- " `rocket` on the fix-list comment; `failed` reacts `thinking_face`",
19244
- " and posts a reply citing the worker's failure reason.",
19245
- "",
19246
- "6. **Release the `review:fixing` lease** with",
19247
- " `gh pr edit <pr-number> --remove-label 'review:fixing'`. Always",
19248
- " run this step.",
19335
+ "4. **Apply the durable `review:needs-worker` marker** so a",
19336
+ " subsequent (top-level) `issue-worker` pass discovers the PR and",
19337
+ " pulls the fix-list. Do **not** spawn `issue-worker` yourself \u2014 the",
19338
+ " reviewer often runs at depth-1 (the orchestrator's PR sweep",
19339
+ " dispatches it as a sub-agent) where nested sub-agent spawning is",
19340
+ " forbidden, so an in-session `Agent` dispatch would silently abort.",
19341
+ " The hand-off is pull-based: the marker is the signal, the",
19342
+ " `review:fixing` lease (acquired in step 2) is held **across",
19343
+ " sessions** until the worker clears the marker and a later reviewer",
19344
+ " pass confirms.",
19249
19345
  "",
19250
- "7. **Do not re-enable auto-merge in the same pass.** After delegation,",
19251
- " exit and let a human re-invoke the reviewer. The next pass will",
19252
- " re-evaluate `mergeStateStatus` (or `mergeable`) against the",
19253
- " rebased branch and re-enable auto-merge through the normal flow.",
19346
+ " ```bash",
19347
+ " gh pr edit <pr-number> --add-label 'review:needs-worker'",
19348
+ " ```",
19254
19349
  "",
19255
- "Return `delegated` to the caller when delegation completes",
19256
- "(regardless of the worker's outcome \u2014 the delegation itself is the",
19257
- "action taken).",
19350
+ "5. **Exit returning `delegated`.** The delegation is complete for",
19351
+ " this pass: the fix-list is posted, the lease is held, and the",
19352
+ " marker is set. Do **not** wait for the worker, do **not** process",
19353
+ " a worker report, and do **not** re-enable auto-merge in this pass.",
19354
+ " The worker runs in its own top-level session; a **subsequent**",
19355
+ " reviewer pass detects the worker finished (PR carries",
19356
+ " `review:fixing` but **not** `review:needs-worker`), reacts on the",
19357
+ " source comment, re-evaluates AC/CI against the rebased branch,",
19358
+ " re-enables auto-merge, and releases the `review:fixing` lease. See",
19359
+ " the **Confirm pass** section below.",
19360
+ "",
19361
+ "Return `delegated` to the caller once the marker is applied and the",
19362
+ "fix-list posted \u2014 the delegation itself is the action taken. Unlike a",
19363
+ "merge, `delegated` does **not** imply the fix landed in this pass; it",
19364
+ "means the work is durably queued for the pull-based consumer and a",
19365
+ "later confirm pass will finish the loop.",
19258
19366
  "",
19259
19367
  "### Fallback",
19260
19368
  "",
@@ -19268,6 +19376,89 @@ var prReviewerSubAgent = {
19268
19376
  "gh pr comment <pr-number> --body 'Branch is BEHIND <default-branch> with conflicts. <short reason delegation was skipped \u2014 e.g. human-required mode, generated-file conflicts, or in-flight review:fixing lease>. A human (or the next reviewer pass after rebase) will need to resolve.'",
19269
19377
  "```",
19270
19378
  "",
19379
+ "## Shared Procedure: Confirm a Completed Delegation",
19380
+ "",
19381
+ "Delegation is **pull-based and spans sessions**: the reviewer that",
19382
+ "posts a fix-list never finishes the loop in the same pass. It posts",
19383
+ "the fix-list, acquires the `review:fixing` lease, applies the durable",
19384
+ "`review:needs-worker` marker, and exits returning `delegated`. A",
19385
+ "**separate** top-level `issue-worker` session then discovers the",
19386
+ "marker, applies the fix-list (an editorial fix or a rebase), pushes,",
19387
+ "writes a structured worker-report comment, and **clears**",
19388
+ "`review:needs-worker` \u2014 leaving `review:fixing` in place for the",
19389
+ "reviewer to release. The confirm pass below is how a later reviewer",
19390
+ "pass closes the loop. It runs in **both** delegation flows (the",
19391
+ "Phase 4 in-scope-fix flow and the Shared Conflict-Resolution",
19392
+ "Procedure) \u2014 the marker, not the flow, is what a confirm pass keys",
19393
+ "on.",
19394
+ "",
19395
+ "### Detecting a completed delegation",
19396
+ "",
19397
+ "Early in any reviewer pass (after Phase 2 gathers labels), inspect",
19398
+ "the PR's labels for the **lease-without-marker** state:",
19399
+ "",
19400
+ "- `review:fixing` is **present** (a delegation lease is held), **and**",
19401
+ "- `review:needs-worker` is **absent** (the worker cleared its marker",
19402
+ " on completion).",
19403
+ "",
19404
+ "When both hold, a delegation the previous pass kicked off has been",
19405
+ "consumed and pushed by the worker. Run the confirm steps below before",
19406
+ "proceeding with the rest of the pass.",
19407
+ "",
19408
+ "When **both** `review:fixing` and `review:needs-worker` are present,",
19409
+ "the delegation is still in flight (the worker has not yet picked it",
19410
+ "up or has not finished). Do **not** re-post the fix-list and do",
19411
+ "**not** re-acquire the lease \u2014 log the in-flight state to the sticky",
19412
+ "summary and exit; a later pass confirms once the worker clears the",
19413
+ "marker.",
19414
+ "",
19415
+ "### Confirm steps",
19416
+ "",
19417
+ "1. **Read the worker's report.** Find the most recent structured",
19418
+ " worker-report comment the `issue-worker` posted on the PR (it",
19419
+ " cites the pushed commit SHAs and a per-item `handled` / `failed`",
19420
+ " outcome keyed by `comment_id`). Use it to drive the reactions",
19421
+ " below \u2014 the same per-item logic the in-session report processing",
19422
+ " used to perform.",
19423
+ "2. **React on the source comments.** For each item:",
19424
+ " - **`handled`** \u2014 react `rocket` on the original source comment",
19425
+ " (the fix-list comment for a synthetic rebase item) to signal the",
19426
+ " accepted change has landed.",
19427
+ " - **`failed`** \u2014 react `thinking_face` (`content=confused`) on the",
19428
+ " source comment and post a reply citing the worker's failure",
19429
+ " reason.",
19430
+ "3. **Re-evaluate AC/CI against the rebased branch.** Re-run the Phase",
19431
+ " 3 acceptance-criteria comparison and the **CI Verification** check",
19432
+ " against the **updated** head SHA the worker pushed \u2014 do not reuse",
19433
+ " any pre-delegation result.",
19434
+ "4. **Conditionally re-enable auto-merge** under the same four",
19435
+ " conditions as the in-scope-fix flow's step (h): mode still",
19436
+ " `auto-merge`, all AC met against the updated diff, no unresolved",
19437
+ " `thinking_face` pushbacks, and CI green-or-pending.",
19438
+ "5. **Release the `review:fixing` lease** \u2014 always, even when an item",
19439
+ " failed:",
19440
+ "",
19441
+ " ```bash",
19442
+ " gh pr edit <pr-number> --remove-label 'review:fixing'",
19443
+ " ```",
19444
+ "",
19445
+ "6. **Update the sticky summary** with the per-item outcomes, the",
19446
+ " commit SHAs from the worker report, and the auto-merge decision.",
19447
+ "",
19448
+ "### Stale-lease reclaim",
19449
+ "",
19450
+ "A crashed worker must not wedge a PR forever. A `review:fixing` lease",
19451
+ "is **reclaimable** when it has no `review:needs-worker` companion",
19452
+ "**and** no consuming worker is making progress \u2014 i.e. the lease is",
19453
+ "older than the stale threshold (the same in-progress threshold the",
19454
+ "maintenance sweep applies, 72h by default) with no worker-report",
19455
+ "comment newer than the fix-list. The reclaim is wired into the",
19456
+ "maintenance sweep, not a reviewer pass: the sweep flags such a PR",
19457
+ "with `status:needs-attention` so a human clears the orphaned",
19458
+ "`review:fixing` lease and re-triggers the reviewer. See the",
19459
+ "**Stale-lease reclaim** subsection of the `pr-review-feedback-protocol`",
19460
+ "rule for the full lifecycle.",
19461
+ "",
19271
19462
  "## Phase 5: Branch Cleanup and Issue Closure Verification",
19272
19463
  "",
19273
19464
  "Skip this phase entirely when the review mode from Phase 2.75 is",
@@ -19331,7 +19522,7 @@ var prReviewerSubAgent = {
19331
19522
  "Linked issue: #<issue-number>",
19332
19523
  "Review mode: <auto-merge | human-required>",
19333
19524
  "Reason: <short explanation from Phase 2.75>",
19334
- "Verdict: AUTO_MERGE_ENABLED | AWAITING_HUMAN | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
19525
+ "Verdict: AUTO_MERGE_ENABLED | AWAITING_HUMAN | DELEGATED_TO_WORKER | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
19335
19526
  "",
19336
19527
  "Acceptance criteria:",
19337
19528
  " [x] <criterion> \u2014 <evidence>",
@@ -19343,12 +19534,22 @@ var prReviewerSubAgent = {
19343
19534
  " - Suggested: <items>",
19344
19535
  " - Nitpick: <items>",
19345
19536
  "",
19346
- "Action taken: <enable-auto-merge | label-awaiting-human | commented-on-the-pr | none>",
19537
+ "Action taken: <enable-auto-merge | label-awaiting-human | delegated-to-worker | confirmed-delegation | commented-on-the-pr | none>",
19347
19538
  "Branch updated: <yes | not needed | failed (<reason>) | delegated (PR #<n>) | n/a>",
19348
19539
  "Branch state: <merged | open | closed>",
19349
19540
  "Issue state: <closed | open>",
19350
19541
  "```",
19351
19542
  "",
19543
+ "**`DELEGATED_TO_WORKER` semantics.** This verdict means the reviewer",
19544
+ "posted a fix-list, applied the `review:needs-worker` marker, and",
19545
+ "exited holding the `review:fixing` lease \u2014 the fix-list is **durably",
19546
+ "queued** for a top-level `issue-worker` pass, but it has **not** yet",
19547
+ "been applied in this pass. `delegated` is never a terminal",
19548
+ "completion: the loop closes only when a top-level worker consumes the",
19549
+ "marker and a later reviewer confirm pass releases the lease. Likewise",
19550
+ "`Branch updated: delegated (PR #<n>)` records that a rebase was",
19551
+ "queued for the worker, not that the branch is already current.",
19552
+ "",
19352
19553
  "---",
19353
19554
  "",
19354
19555
  "## Rules",
@@ -19370,7 +19571,7 @@ var prReviewerSubAgent = {
19370
19571
  " to `human-required`, Phase 4 applies `review:awaiting-human` and",
19371
19572
  " exits. Even if every acceptance criterion is met and CI is green,",
19372
19573
  " `gh pr merge --auto` is forbidden in that mode.",
19373
- "6. **Never push commits to the PR's branch yourself.** The reviewer is a decision-maker and orchestrator, not an implementer. When in-scope review comments require code changes **and** the PR carries the `origin:issue-worker` label (or the invocation prompt explicitly allows human-authored PRs via `--allow-human-author`), delegate the fix by posting a fix-list comment on the PR and invoking `issue-worker` in feedback mode. You must never call `git commit`, `git push`, `git rebase`, or `gh pr edit` against the head branch from this agent \u2014 all branch mutations belong to `issue-worker`.",
19574
+ "6. **Never push commits to the PR's branch yourself.** The reviewer is a decision-maker and orchestrator, not an implementer. When in-scope review comments require code changes **and** the PR carries the `origin:issue-worker` label (or the invocation prompt explicitly allows human-authored PRs via `--allow-human-author`), delegate the fix **by marker, not by spawn**: post a fix-list comment on the PR, apply the `review:needs-worker` label, hold the `review:fixing` lease, and exit returning `delegated`. Do **not** invoke `issue-worker` via the `Agent` tool \u2014 the reviewer often runs at depth-1 where nested sub-agent spawning is forbidden, so an in-session dispatch would silently abort. A top-level `issue-worker` session pulls the marker and applies the fix; a later reviewer confirm pass releases the lease. You must never call `git commit`, `git push`, `git rebase`, or `gh pr edit` against the head branch from this agent \u2014 all branch mutations belong to `issue-worker`.",
19374
19575
  "7. **Do not implement code.** You review, decide, and orchestrate. If",
19375
19576
  " the PR needs code changes and delegation is not permitted by Rule",
19376
19577
  " #6, comment and stop \u2014 do not attempt to fix it yourself.",
@@ -19406,15 +19607,21 @@ var prReviewerSubAgent = {
19406
19607
  " in a way that satisfies the reviewer (who then replaces the",
19407
19608
  " `thinking_face` with `+1`), or by applying the `review:auto-ok`",
19408
19609
  " label as an explicit override.",
19409
- "14. **Never re-enable auto-merge while disputes or human-required",
19410
- " hand-offs are still in flight.** After delegating fixes via the",
19411
- " Phase 4 flow, the reviewer may only run `gh pr merge --auto`",
19412
- " again when **no** unresolved `thinking_face` reactions authored",
19413
- " by the reviewer remain on any PR comment **and** the",
19414
- " `review:awaiting-human` label is **not** present on the PR. Any",
19415
- " AC-drift pushback, any failed-fix pushback, and any human-required",
19416
- " hand-off all keep auto-merge disabled until the human resolves",
19417
- " the underlying state.",
19610
+ "14. **Never re-enable auto-merge while disputes, human-required",
19611
+ " hand-offs, or an in-flight delegation are still pending.** The",
19612
+ " auto-merge re-enable happens on the **confirm pass** (the Shared",
19613
+ " Procedure: Confirm a Completed Delegation), never on the pass",
19614
+ " that posts the fix-list. A confirm pass may only run",
19615
+ " `gh pr merge --auto` when the PR carries `review:fixing` but",
19616
+ " **not** `review:needs-worker` (the worker finished and cleared",
19617
+ " its marker), **and** **no** unresolved `thinking_face` reactions",
19618
+ " authored by the reviewer remain on any PR comment, **and** the",
19619
+ " `review:awaiting-human` label is **not** present. While",
19620
+ " `review:needs-worker` is still applied the delegation is",
19621
+ " unconsumed and auto-merge stays disabled. Any AC-drift pushback,",
19622
+ " any failed-fix pushback, and any human-required hand-off all keep",
19623
+ " auto-merge disabled until the human resolves the underlying",
19624
+ " state.",
19418
19625
  "15. **Restrict `gh pr update-branch` on `human-required` PRs.** The",
19419
19626
  " `update-branch` step is permitted when the review mode is",
19420
19627
  " `auto-merge`, **or** when the mode is `human-required` **and**",
@@ -19658,7 +19865,6 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19658
19865
  " insertions: 500",
19659
19866
  " labels-that-force-human:",
19660
19867
  ' - "review:human-required"',
19661
- ' - "priority:critical"',
19662
19868
  "",
19663
19869
  "auto-merge:",
19664
19870
  " labels-that-force-auto:",
@@ -19689,8 +19895,9 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19689
19895
  "2. **`review:human-required` label** \u2014 reserved force-human label;",
19690
19896
  " if present (and no force-auto label beat it in step 1), the mode",
19691
19897
  " is `human-required`.",
19692
- "3. **`human-required.labels-that-force-human`** \u2014 any listed label on",
19693
- " the PR (e.g. `priority:critical`) forces `human-required`.",
19898
+ "3. **`human-required.labels-that-force-human`** \u2014 if the PR",
19899
+ " carries any label listed here (e.g. `review:human-required`),",
19900
+ " the mode is `human-required`.",
19694
19901
  "4. **`human-required.paths`** \u2014 if any file in the PR diff matches",
19695
19902
  " any glob here, the mode is `human-required`. Matching uses",
19696
19903
  " standard glob semantics (`**` for recursive directories,",
@@ -19711,6 +19918,24 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19711
19918
  "7. **`default`** \u2014 applied only when no rule above matched",
19712
19919
  " (normally `auto-merge`).",
19713
19920
  "",
19921
+ "**Label-check scope.** All label checks in rules 1\u20133 evaluate",
19922
+ "the PR's **own** labels only. Never traverse the `Closes #N`",
19923
+ "link to read the linked issue's labels for a label rule. Rule 5",
19924
+ "is the only rule that reads the linked issue, and it reads the",
19925
+ "issue **type**, not its labels.",
19926
+ "",
19927
+ "**`priority:*` / `status:*` are not merge-risk signals.**",
19928
+ "`priority:*` and `status:*` are issue-triage labels consumed by",
19929
+ "the orchestrator for scheduling \u2014 `priority:*` sequences the",
19930
+ "work queue and `status:*` tracks workflow position. They say",
19931
+ "nothing about a PR's merge risk and must never appear in any",
19932
+ "`labels-that-force-*` list. Gating merge on `priority:critical`",
19933
+ "in particular inverts the intended behaviour: the most urgent",
19934
+ "work would wait the longest for a human merge. Merge risk is",
19935
+ "already covered by the path globs (rule 4), the",
19936
+ "`release` / `hotfix` issue-types (rule 5), and the size",
19937
+ "thresholds (rule 6).",
19938
+ "",
19714
19939
  "The `auto-merge.paths-exempt-from-size` carve-out exists so",
19715
19940
  "**doc-only PRs** that routinely exceed the 500-insertion size",
19716
19941
  "threshold (large migrations, bulk additions, refresh passes)",
@@ -19742,8 +19967,8 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19742
19967
  "The exception is keyed on the matched-rule index recorded in",
19743
19968
  "Phase 2.75. All other `human-required` triggers \u2014 rule 2",
19744
19969
  "(`review:human-required` label), rule 3 (any",
19745
- "`labels-that-force-human` label such as `priority:critical`),",
19746
- "rule 4 (`human-required.paths` glob match), and rule 5",
19970
+ "`labels-that-force-human` label), rule 4",
19971
+ "(`human-required.paths` glob match), and rule 5",
19747
19972
  "(`human-required.issue-types` match) \u2014 continue to block",
19748
19973
  "`update-branch` because each one signals a human reviewer who",
19749
19974
  "has explicit ownership of the branch's lifecycle.",
@@ -19892,20 +20117,36 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19892
20117
  "PR state. The sections below document the conventions humans need",
19893
20118
  "to read and drive that loop.",
19894
20119
  "",
19895
- "### Trigger Model: Human-Triggered, Single-Pass",
20120
+ "### Trigger Model: Single-Pass, Pull-Based Delegation",
19896
20121
  "",
19897
20122
  "Each reviewer pass runs exactly once and does not self-chain. A",
19898
- "human re-invokes `/review-pr <n>` (or `/review-prs`) whenever the",
19899
- "PR state changes enough to warrant another look \u2014 a new comment,",
19900
- "a new commit, a resolved pushback, a label flip. The reviewer",
19901
- "never reschedules itself and never loops back after handing off to",
19902
- "`issue-worker`: the worker's run is the terminal step of that",
19903
- "pass, and a human must re-invoke the reviewer to see the follow-up",
19904
- "reactions and the auto-merge re-enablement decision.",
19905
- "",
19906
- "This keeps the loop cheap to reason about: every agent action is",
19907
- "traceable to a specific human invocation, and there is no",
19908
- "background automation to pause or cancel.",
20123
+ "human (or a scheduled PR-review sweep) re-invokes",
20124
+ "`/review-pr <n>` (or `/review-prs`) whenever the PR state changes",
20125
+ "enough to warrant another look \u2014 a new comment, a new commit, a",
20126
+ "resolved pushback, a label flip, or a worker clearing the",
20127
+ "`review:needs-worker` marker. The reviewer never reschedules",
20128
+ "itself.",
20129
+ "",
20130
+ "Delegation is **pull-based, not push-based**. The reviewer does",
20131
+ "**not** spawn `issue-worker` in session \u2014 it frequently runs at",
20132
+ "depth-1 (the orchestrator's PR sweep dispatches it as a",
20133
+ "sub-agent), and the runtime forbids a depth-1 sub-agent from",
20134
+ "spawning a depth-2 sub-agent, so an in-session dispatch would",
20135
+ "silently abort. Instead the pass that decides to delegate posts a",
20136
+ "fix-list, applies the durable `review:needs-worker` marker, holds",
20137
+ "the `review:fixing` lease, and exits. A **separate** top-level",
20138
+ "`issue-worker` session discovers the marker, applies the",
20139
+ "fix-list, pushes, writes a worker-report comment, and clears",
20140
+ "`review:needs-worker`. A later reviewer pass then confirms the",
20141
+ "result and releases the lease. The worker's run is therefore",
20142
+ "**not** the terminal step of the delegating reviewer pass \u2014 the",
20143
+ "loop spans three passes (delegate \u2192 worker \u2192 confirm).",
20144
+ "",
20145
+ "This keeps the loop cheap to reason about: every step is",
20146
+ "traceable to a label state on the PR, and the producer",
20147
+ "(`pr-reviewer`, at any depth) never depends on a depth-2",
20148
+ "sub-agent spawn to reach the consumer (`issue-worker`, always",
20149
+ "top-level).",
19909
20150
  "",
19910
20151
  "### Reaction State Machine",
19911
20152
  "",
@@ -19987,6 +20228,60 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
19987
20228
  "report per-item outcomes and the reviewer can apply `rocket` or",
19988
20229
  "`thinking_face` to the correct source comment on the next pass.",
19989
20230
  "",
20231
+ "### Cross-Session `review:fixing` Lease Lifecycle",
20232
+ "",
20233
+ "Delegation hand-off is **pull-based and spans three passes**. Two",
20234
+ "labels coordinate it: the `review:fixing` lease (mutual exclusion)",
20235
+ "and the `review:needs-worker` marker (durable work signal). The",
20236
+ "lease is held **across sessions** \u2014 it is acquired by the",
20237
+ "reviewer pass that posts the fix-list and released only by a",
20238
+ "later reviewer confirm pass, never within a single pass.",
20239
+ "",
20240
+ "| Step | Actor | Labels after the step |",
20241
+ "|------|-------|-----------------------|",
20242
+ "| **1. Delegate** | `pr-reviewer` | Posts the fix-list, **acquires** `review:fixing`, **applies** `review:needs-worker`, exits `delegated`. PR carries both labels. |",
20243
+ "| **2. Consume** | `issue-worker` (top-level) | Discovers `review:needs-worker`, applies the fix-list, pushes, writes a worker-report comment, **clears** `review:needs-worker`. PR carries `review:fixing` only. |",
20244
+ "| **3. Confirm** | `pr-reviewer` | Detects `review:fixing` **without** `review:needs-worker`, reacts on source comments from the worker report, re-evaluates AC/CI, re-enables auto-merge (auto-merge mode), **releases** `review:fixing`. PR carries neither label. |",
20245
+ "",
20246
+ "Key invariants:",
20247
+ "",
20248
+ "- The producer (`pr-reviewer`) **never spawns** the consumer",
20249
+ " (`issue-worker`) in session. The reviewer can run at depth-1,",
20250
+ " where nested sub-agent spawning is forbidden; the marker is the",
20251
+ " hand-off, not an `Agent` dispatch.",
20252
+ "- The lease being held while `review:needs-worker` is still",
20253
+ " present means the delegation is **in flight** \u2014 a reviewer pass",
20254
+ " that sees both labels logs the in-flight state and exits without",
20255
+ " re-posting the fix-list or re-acquiring the lease.",
20256
+ "- The lease being held **without** `review:needs-worker` is the",
20257
+ " **confirm trigger** \u2014 exactly one delegation has been consumed",
20258
+ " and is awaiting confirmation.",
20259
+ "- `delegated` is never a terminal completion. A PR is only done",
20260
+ " when the confirm pass releases the lease and (in auto-merge",
20261
+ " mode) re-enables auto-merge.",
20262
+ "",
20263
+ "#### Stale-lease reclaim",
20264
+ "",
20265
+ "A crashed or never-launched worker must not wedge a PR by holding",
20266
+ "the lease forever. The **maintenance sweep** (not a reviewer pass)",
20267
+ "owns reclaim. A `review:fixing` lease is **reclaimable** when",
20268
+ "**both** hold:",
20269
+ "",
20270
+ "- The PR carries `review:fixing` but **not**",
20271
+ " `review:needs-worker` \u2014 there is no in-flight worker still",
20272
+ " expected to clear the marker, **yet**",
20273
+ "- No worker-report comment newer than the fix-list exists, **and**",
20274
+ " the fix-list comment is older than the stale in-progress",
20275
+ " threshold the maintenance sweep applies (72h by default).",
20276
+ "",
20277
+ "Together these mean a delegation was kicked off, the marker was",
20278
+ "consumed-or-dropped, but no worker result ever landed \u2014 the lease",
20279
+ "is orphaned. The maintenance sweep flags such a PR with",
20280
+ "`status:needs-attention` so a human clears the orphaned",
20281
+ "`review:fixing` label and re-triggers the reviewer; the sweep",
20282
+ "never silently force-releases the lease, mirroring the",
20283
+ "stale-issue policy of flagging rather than auto-resetting.",
20284
+ "",
19990
20285
  "### Sticky `## Reviewer notes` Comment",
19991
20286
  "",
19992
20287
  "Every PR has **one** canonical reviewer-notes comment. The",
@@ -20018,10 +20313,13 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
20018
20313
  "",
20019
20314
  "### Label Glossary",
20020
20315
  "",
20021
- "Five review-workflow labels drive the feedback loop. Consumers",
20022
- "that adopt this workflow are responsible for creating them in",
20023
- "their own repos (the same way they create `priority:*` and",
20024
- "`status:*` labels).",
20316
+ "Six review-workflow labels drive the feedback loop. They are",
20317
+ "**contributed by the pr-review bundle's label set** and auto-sync",
20318
+ "into every consumer's label registry \u2014 the same way the",
20319
+ "`type:*` / `priority:*` / `status:*` taxonomy ships. Consumers do",
20320
+ "**not** hand-declare them, so they survive a label sync run with",
20321
+ "`deleteOtherLabels: true` that would otherwise prune a",
20322
+ "locally-created label.",
20025
20323
  "",
20026
20324
  "| Label | Purpose |",
20027
20325
  "|-------|---------|",
@@ -20029,7 +20327,8 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
20029
20327
  "| `review:human-required` | Force human review regardless of what the policy would otherwise decide. The reviewer never enables auto-merge on a PR carrying this label. |",
20030
20328
  "| `review:auto-ok` | Force auto-merge regardless of what the policy would otherwise decide. **Also resolves outstanding `thinking_face` pushbacks** as an explicit maintainer override; the reviewer logs the override in the sticky summary. |",
20031
20329
  "| `review:awaiting-human` | Set by the reviewer when it completes its work on a `human-required` PR and is handing off the final merge decision. Cleared by a human (or by `review:auto-ok` flipping the PR back to `auto-merge` mode). |",
20032
- "| `review:fixing` | Short-lived lease held by the reviewer while an `issue-worker` feedback-mode delegation is mid-run. Released automatically at the end of Phase 4 step (g). Contention on this label means a prior delegation crashed without releasing it and needs human investigation. |",
20330
+ "| `review:fixing` | **Cross-session** delegation lease. Acquired by the reviewer pass that posts a fix-list; held across the worker's run; released only by a later reviewer **confirm** pass (PR carries `review:fixing` but not `review:needs-worker`). A lease held without `review:needs-worker` past the stale threshold with no worker report is orphaned and is flagged by the maintenance sweep for human reclaim. |",
20331
+ "| `review:needs-worker` | **Durable hand-off marker.** Applied by the reviewer alongside the fix-list so a top-level `issue-worker` session discovers the PR and pulls the work (the reviewer cannot spawn the worker in session \u2014 it may run at depth-1). Cleared by the worker when it finishes applying the fix-list, which is what triggers the reviewer's confirm pass. |",
20033
20332
  "",
20034
20333
  "### Reviewing Human-Authored PRs: the `--allow-human-author` Flag",
20035
20334
  "",
@@ -20091,7 +20390,12 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
20091
20390
  {
20092
20391
  name: "review:fixing",
20093
20392
  color: "D4C5F9",
20094
- description: "Short-lived lease while issue-worker applies feedback fixes"
20393
+ description: "Cross-session lease held from fix-list post until a confirm pass releases it"
20394
+ },
20395
+ {
20396
+ name: "review:needs-worker",
20397
+ color: "1D76DB",
20398
+ description: "Durable marker: a reviewer fix-list awaits a top-level issue-worker pass"
20095
20399
  }
20096
20400
  ]
20097
20401
  };