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. 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 ``.