From ee0f4308ddc681558fd85a9efd99ca8eae88a3a5 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 30 Sep 2026 16:48:54 -0700 Subject: [PATCH 1/2] Narrow the Unattended Picker's Promotion Stop and Worker Decision Read (#2185) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Narrows two over-broad matches in the `unattended-handoff` skill. - **The picker's promotion STOP** now fires only on an open `decision` issue stating, in its body or in a comment on it, that it blocks the open develop -> main pull request. That is the wording "Parking" step 2 already requires. Before, it fired on any issue that named the promotion, so a lesson citing it stopped every `main` or `release` run. The step also names its read, `--json number,body,comments` under the full-page check, because `gh issue view --comments` prints no body when run without a terminal. - **A resuming worker** follows only the decision issue the parking comment names as what the lane waits on. It neither follows nor parks on a lesson issue the same comment names. "Parking" step 3 now requires the comment to keep the two apart. Out of scope, by the maintainer's choice after five local review passes (4, 2, 4, 4 and 1 findings): - The adopted-lesson stall in the Auto-Resolvable test is now decision #2183, since the picker has no readable signal for it. - The multi-parking-comment, interrupted-park and open-promotion gaps are filed as #2184. Closes on promotion: #1812 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- .agents/skills/unattended-handoff/SKILL.md | 20 ++++++++++++------- .../.source-digests/unattended-handoff | 2 +- .../skills/unattended-handoff/SKILL.md | 20 ++++++++++++------- .github/skills/unattended-handoff/SKILL.md | 20 ++++++++++++------- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.agents/skills/unattended-handoff/SKILL.md b/.agents/skills/unattended-handoff/SKILL.md index 7fd62266d..63ea4f609 100644 --- a/.agents/skills/unattended-handoff/SKILL.md +++ b/.agents/skills/unattended-handoff/SKILL.md @@ -160,9 +160,12 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an ## The Picker -1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue names - the open develop -> main pull request, return `STOP` before picking anything, since every worker - this run dispatched would meet that same decision after merging its own work to develop. +1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue states, + in its body or in a comment on it, that it blocks the open develop -> main pull request, as + "Parking" step 2 has it state, return `STOP` before picking anything, since every worker + this run dispatched would meet that same decision after merging its own work to develop. Read + them with `gh issue list --repo "/" --label decision --state open --limit 100 + --json number,body,comments` under step 2's full-page check. 2. **Read the open handoffs** with labels and update times, `gh issue list --repo "/" --label handoff --state open --limit 100 --json number,title,labels,updatedAt`, since `handoff.py tracks` prints neither. Where it returns as many rows as the limit, the list may be truncated, so @@ -194,8 +197,10 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an read its comments with `gh issue view "" --repo "/" --comments`, since `resume` prints only the body and a parked lane's state is in its parking comment. A lane handed back by an attended session has a closed predecessor holding that comment, so read the predecessor's - comments too. Where either names a decision issue, read the answer recorded there and follow it, - since it is what unblocked the lane. Re-derive live state rather than trusting any of them, per + comments too. Where the parking comment names the decision issue the lane waits on, read the + answer recorded there and follow it, since it is what unblocked the lane. A lesson issue the + comment also names, per step 6, is its own work rather than this lane's, so the worker neither + follows it nor parks on it. Re-derive live state rather than trusting any of them, per `session-handoff` "Resuming". 2. **Isolate** in a worktree of its own, per `repo-worktree`, on the branch the handoff names or on `feature/`. @@ -245,8 +250,9 @@ interruption part way leaves the work findable rather than lost. answered. 3. **Comment the state on the handoff**, filing any lesson first per worker step 6 so the comment can name it: what is done, the branch and pull request, whether the worktree was left standing, - what remains, and the decision issue it now waits on. This comment is what the next session on - the lane resumes from, so it is complete enough to continue with no other context. + what remains, and the decision issue it now waits on, named as that apart from any lesson issue + the comment also names. This comment is what the next session on the lane resumes from, so it + is complete enough to continue with no other context. 4. **Label the handoff `blocked`**, per `GOVERNANCE.md` "Durable Knowledge and Self-Improvement". The picker skips it from then on, and the attended session takes it first. diff --git a/.claude-plugin/fleet-skills/.source-digests/unattended-handoff b/.claude-plugin/fleet-skills/.source-digests/unattended-handoff index 336cf1363..9a513e9f8 100644 --- a/.claude-plugin/fleet-skills/.source-digests/unattended-handoff +++ b/.claude-plugin/fleet-skills/.source-digests/unattended-handoff @@ -1 +1 @@ -1a69a9029eef4d65 +0429cd90c8d7ea9a diff --git a/.claude-plugin/fleet-skills/skills/unattended-handoff/SKILL.md b/.claude-plugin/fleet-skills/skills/unattended-handoff/SKILL.md index 7fd62266d..63ea4f609 100644 --- a/.claude-plugin/fleet-skills/skills/unattended-handoff/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/unattended-handoff/SKILL.md @@ -160,9 +160,12 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an ## The Picker -1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue names - the open develop -> main pull request, return `STOP` before picking anything, since every worker - this run dispatched would meet that same decision after merging its own work to develop. +1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue states, + in its body or in a comment on it, that it blocks the open develop -> main pull request, as + "Parking" step 2 has it state, return `STOP` before picking anything, since every worker + this run dispatched would meet that same decision after merging its own work to develop. Read + them with `gh issue list --repo "/" --label decision --state open --limit 100 + --json number,body,comments` under step 2's full-page check. 2. **Read the open handoffs** with labels and update times, `gh issue list --repo "/" --label handoff --state open --limit 100 --json number,title,labels,updatedAt`, since `handoff.py tracks` prints neither. Where it returns as many rows as the limit, the list may be truncated, so @@ -194,8 +197,10 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an read its comments with `gh issue view "" --repo "/" --comments`, since `resume` prints only the body and a parked lane's state is in its parking comment. A lane handed back by an attended session has a closed predecessor holding that comment, so read the predecessor's - comments too. Where either names a decision issue, read the answer recorded there and follow it, - since it is what unblocked the lane. Re-derive live state rather than trusting any of them, per + comments too. Where the parking comment names the decision issue the lane waits on, read the + answer recorded there and follow it, since it is what unblocked the lane. A lesson issue the + comment also names, per step 6, is its own work rather than this lane's, so the worker neither + follows it nor parks on it. Re-derive live state rather than trusting any of them, per `session-handoff` "Resuming". 2. **Isolate** in a worktree of its own, per `repo-worktree`, on the branch the handoff names or on `feature/`. @@ -245,8 +250,9 @@ interruption part way leaves the work findable rather than lost. answered. 3. **Comment the state on the handoff**, filing any lesson first per worker step 6 so the comment can name it: what is done, the branch and pull request, whether the worktree was left standing, - what remains, and the decision issue it now waits on. This comment is what the next session on - the lane resumes from, so it is complete enough to continue with no other context. + what remains, and the decision issue it now waits on, named as that apart from any lesson issue + the comment also names. This comment is what the next session on the lane resumes from, so it + is complete enough to continue with no other context. 4. **Label the handoff `blocked`**, per `GOVERNANCE.md` "Durable Knowledge and Self-Improvement". The picker skips it from then on, and the attended session takes it first. diff --git a/.github/skills/unattended-handoff/SKILL.md b/.github/skills/unattended-handoff/SKILL.md index 7fd62266d..63ea4f609 100644 --- a/.github/skills/unattended-handoff/SKILL.md +++ b/.github/skills/unattended-handoff/SKILL.md @@ -160,9 +160,12 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an ## The Picker -1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue names - the open develop -> main pull request, return `STOP` before picking anything, since every worker - this run dispatched would meet that same decision after merging its own work to develop. +1. **Check the promotion first** under `main` or `release`. Where an open `decision` issue states, + in its body or in a comment on it, that it blocks the open develop -> main pull request, as + "Parking" step 2 has it state, return `STOP` before picking anything, since every worker + this run dispatched would meet that same decision after merging its own work to develop. Read + them with `gh issue list --repo "/" --label decision --state open --limit 100 + --json number,body,comments` under step 2's full-page check. 2. **Read the open handoffs** with labels and update times, `gh issue list --repo "/" --label handoff --state open --limit 100 --json number,title,labels,updatedAt`, since `handoff.py tracks` prints neither. Where it returns as many rows as the limit, the list may be truncated, so @@ -194,8 +197,10 @@ does not qualify, since skipping one costs nothing and a guess costs a revert an read its comments with `gh issue view "" --repo "/" --comments`, since `resume` prints only the body and a parked lane's state is in its parking comment. A lane handed back by an attended session has a closed predecessor holding that comment, so read the predecessor's - comments too. Where either names a decision issue, read the answer recorded there and follow it, - since it is what unblocked the lane. Re-derive live state rather than trusting any of them, per + comments too. Where the parking comment names the decision issue the lane waits on, read the + answer recorded there and follow it, since it is what unblocked the lane. A lesson issue the + comment also names, per step 6, is its own work rather than this lane's, so the worker neither + follows it nor parks on it. Re-derive live state rather than trusting any of them, per `session-handoff` "Resuming". 2. **Isolate** in a worktree of its own, per `repo-worktree`, on the branch the handoff names or on `feature/`. @@ -245,8 +250,9 @@ interruption part way leaves the work findable rather than lost. answered. 3. **Comment the state on the handoff**, filing any lesson first per worker step 6 so the comment can name it: what is done, the branch and pull request, whether the worktree was left standing, - what remains, and the decision issue it now waits on. This comment is what the next session on - the lane resumes from, so it is complete enough to continue with no other context. + what remains, and the decision issue it now waits on, named as that apart from any lesson issue + the comment also names. This comment is what the next session on the lane resumes from, so it + is complete enough to continue with no other context. 4. **Label the handoff `blocked`**, per `GOVERNANCE.md` "Durable Knowledge and Self-Improvement". The picker skips it from then on, and the attended session takes it first. From 15b7e6aa9a45bc29d19e93e69ea53fb4468b8c4d Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 30 Sep 2026 18:35:53 -0700 Subject: [PATCH 2/2] Skip the Overview's Changes Narrative When Vetting Metadata Labels (#2188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `scripts/pr_review.py status` exited 43 (`UNRECOGNIZED_REVIEWER_OUTPUT`) on a clean Copilot review whose `ccr-overview-v2` overview lists its changes as bold-led bullets inside the collapsed `What changed in this PR` block. `LABEL_LINE` vetted each of those narrative bullets as a metadata label. A develop -> main promotion's overview takes that list form, so every such promotion stopped on this refusal. - **`mask_narrative`** walks the `
` tags with an explicit stack. A closed block counts as narrative only where its own content opens on a `` naming `What changed in this PR`. Only that block's own content is blanked, with offsets and line boundaries kept, and a block nested inside it is still read. `unrecognized_in` then scans the masked body line by line, exactly as it scanned the unmasked one, so every label develop reported outside the narrative is still reported, in the same order. - **Ten tests:** - the narrative skip; - a label beside the narrative, and one in `Review details`, still reported; - an outer block's nested summary, a bare first line, a nested block, a nested narrative, 600 levels of nesting, and body order. Run against the commit that preceded each test's own fix, each fails. Against the real body that surfaced this, the new reader reports no unrecognized shape. - **`DETAILS_TAG` is unchanged.** A widened close spelling was tried and reverted after review showed it matching literal text and swallowing a following section heading. Six local review passes ran on this change, finding 4, 4, 2, 4, 4 and 1 issue. The maintainer chose to land it once a pass found nothing worse than develop on the markup Copilot produces. What was left out is filed: - #2187: nonstandard close spellings, a `
` opener, the order of a label that appears twice, and a missing test for an unclosed narrative. - #2186: `details_spans` duplicating the text before an unclosed block, which predates this change. Closes on promotion: #2182 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- scripts/pr_review.py | 37 +++++++++++++++++-- tests/test_pr_review.py | 80 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 2 deletions(-) diff --git a/scripts/pr_review.py b/scripts/pr_review.py index afa1608d5..afe17bf15 100755 --- a/scripts/pr_review.py +++ b/scripts/pr_review.py @@ -517,11 +517,12 @@ def strip_fences( "### Human review recommended", "### Suppressed comments (N)", } +NARRATIVE_SUMMARY = "What changed in this PR" VETTED_SUMMARIES = { "Pull request overview", "Open (N)", "Resolved since last review (N)", - "What changed in this PR", + NARRATIVE_SUMMARY, "Show a summary per file", "File summaries", "Review details", @@ -2203,7 +2204,8 @@ def unrecognized_in(body: str) -> list[str]: return [] plain = CODE_SPAN.sub(" ", strip_fences(body or "")) headings = [normal(ln) for ln in plain.splitlines() if MARKDOWN_HEADING.match(ln)] - labels = [normal(m.group(1)) for m in map(LABEL_LINE.match, plain.splitlines()) if m] + lines = mask_narrative(plain).splitlines() + labels = [normal(m.group(1)) for m in map(LABEL_LINE.match, lines) if m] found = [f"heading: {h}" for h in dict.fromkeys(headings) if unvetted(h, VETTED_HEADINGS)] found += [ f"summary: {marker}" @@ -2623,6 +2625,37 @@ def details_spans(body: str) -> tuple[list[tuple[int, int]], list[tuple[int, int return regions, leftover +def mask_narrative(text: str) -> str: + """The text with each narrative block's own content blanked, offsets and lines left alone. + + A narrative block is one whose own summary opens it and names `NARRATIVE_SUMMARY`. A block + nested inside it keeps its content, and an unclosed block is never blanked, so a label it + holds is still read wherever it sits. + """ + stack: list[tuple[int, int, list[tuple[int, int]]]] = [] + blank: list[tuple[int, int]] = [] + for m in DETAILS_TAG.finditer(text): + if not m.group().startswith(" None: self.assertIn("**Changes:**", overview_v2()) self.assertEqual([], pr_review.unrecognized_in(overview_v2())) + def narrated(self) -> str: + """The format with its changes narrative led by bold phrases, as live bodies carry it.""" + led = ( + "**Changes:**\n- **Gadget sync (#4321):** Bumps the gadget pins.\n" + "- **Verification:** Every pin lands on the same version.\n" + ) + body = overview_v2().replace("**Changes:**\n- Narrow the reader.\n", led) + self.assertIn("Gadget sync", body, "the narrative this case rewrites has moved") + return body + + def test_a_bold_lead_in_the_changes_narrative_is_not_a_metadata_label(self) -> None: + """Each narrative bullet naming its change in bold read as an unknown label and blocked.""" + self.assertEqual([], pr_review.unrecognized_in(self.narrated())) + + def test_a_bold_lead_outside_the_changes_narrative_is_still_vetted(self) -> None: + """The narrative is skipped as a block, so the same bullet beside it still reports.""" + body = self.narrated().replace( + "\n\n
", "\n- **Sprocket tuning:** x\n\n
", 1 + ) + self.assertIn("Sprocket tuning", body, "the anchor this case inserts at has moved") + self.assertEqual(["metadata label: Sprocket tuning"], pr_review.unrecognized_in(body)) + + def test_a_bullet_in_the_review_details_block_is_still_vetted(self) -> None: + """Only the narrative is skipped, and the first format states its metadata inside a block.""" + body = closer_look().replace( + "- **Files reviewed:**", "- **Confidence:** high\n- **Files reviewed:**" + ) + self.assertEqual(["metadata label: Confidence"], pr_review.unrecognized_in(body)) + + def test_a_block_whose_own_summary_is_unread_is_not_taken_for_a_nested_narrative(self) -> None: + """A region reads as narrative from its own opening summary, never a nested one.""" + body = self.narrated() + ( + "\n
\nReview details\n\n- **Confidence:** high\n\n" + "
\nWhat changed in this PR\n\n" + "- **Gadget (#1):** x\n
\n
\n" + ) + self.assertIn("metadata label: Confidence", pr_review.unrecognized_in(body)) + + def test_a_bare_narrative_line_is_not_a_narrative_summary(self) -> None: + """A region opening on plain text naming the narrative carries no summary to skip it by.""" + body = self.narrated() + ( + "\n
\nWhat changed in this PR\n- **Confidence:** high\n
\n" + ) + self.assertIn("metadata label: Confidence", pr_review.unrecognized_in(body)) + + def test_a_block_nested_in_the_narrative_is_still_vetted(self) -> None: + """Only the narrative's own lines are skipped, and a block inside it reads as any other.""" + body = self.narrated() + ( + "\n
\nWhat changed in this PR\n\n" + "- **Gadget (#1):** x\n\n
\nReview details\n\n" + "- **Confidence:** high\n
\n
\n" + ) + self.assertEqual(["metadata label: Confidence"], pr_review.unrecognized_in(body)) + + def test_a_narrative_nested_in_another_block_is_still_skipped(self) -> None: + """The narrative is found at any depth, so wrapping it does not bring the refusal back.""" + body = self.narrated() + ( + "\n
\nPull request overview\n\n
\n" + "What changed in this PR\n\n" + "- **Gadget (#1):** x\n
\n
\n" + ) + self.assertEqual([], pr_review.unrecognized_in(body)) + + def test_a_deeply_nested_body_is_read_without_exhausting_the_stack(self) -> None: + """Nesting depth is bounded only by the body size, so the walk holds no call per level.""" + body = ( + self.narrated() + "\n" + "
\n" * 600 + "- **Deep:** x\n" + "
\n" * 600 + ) + self.assertEqual(["metadata label: Deep"], pr_review.unrecognized_in(body)) + + def test_unvetted_labels_are_listed_in_body_order(self) -> None: + """The narrative is blanked in place, so a label inside a block keeps its position.""" + body = self.narrated() + ( + "\n
\nReview details\n\n- **Aaa:** x\n
\n\n" + "- **Bbb:** x\n" + ) + self.assertEqual( + ["metadata label: Aaa", "metadata label: Bbb"], pr_review.unrecognized_in(body) + ) + def test_an_unknown_section_in_the_format_still_stops_the_loop(self) -> None: """The vetted lists reach a section introduced as a heading or a ``.