Skip to content

feat(skills): gate Ready on agent review and owner approval, and group reviewers in PEW - #1153

Merged
sbalabanov merged 1 commit into
mainfrom
skill/pew-grouping
Dec 1, 2026
Merged

sbalabanov merged 1 commit into
mainfrom
skill/pew-grouping

Conversation

@sbalabanov

@sbalabanov sbalabanov commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

A PR now leaves Draft only after its bound reviewer agent is satisfied and the owner approves the exact head. PEW shows where each PR stands in that gate, groups each reviewer under its implementer, and prints links as plain autolinks. The campaign ledger's schema is a single example in watch.md that the renderer validates and that its tests check.

Changes

Review before Ready (references/workflow.md, SKILL.md, references/watch.md)

  • Gate states. Each PR record carries a gate: agent_review → owner_review → owner_approved → ready, or escalated.
  • Agent review rounds. A round is one pass by the bound reviewer over one head, ending in a review_verdict (satisfied or changes_needed).
    • The reviewer posts its findings as a GitHub COMMENT review. Each comment is prefixed with the agent's name, because agents post under the owner's account.
    • The cap is parameters.agent_review_rounds (default 5). If the last allowed round ends in changes_needed, the PR escalates to the user.
  • Owner approval. Either an unedited top-level PR comment from the owner, owner-approved <sha>, or an approval in the user's own prompt message.
    • The approval is recorded with the full head SHA and its source. A push before Ready voids it.
    • Owner change requests get a reviewer pass that does not count toward the cap.
  • Draft-gated CI. CI first runs at Ready, so local_validation must pass on the head before the owner gate. Marking a PR Ready and then returning it to Draft is forbidden.
  • Ready and after. Ready requires owner_approved on the current head. After Ready, feedback and CI failures need no further owner approval.
  • Watch, merge and outreach. The watch's readiness action, the final merge gate and review outreach all check the gate.

PEW (scripts/pew.py)

  • Columns. The table has three columns: Agent / issue-work, PR / state / artifacts, Next step / last action. Each PR's state follows its link, as in <…/pull/N> 🟢 Ready · 🟢 pass, then come the artifacts, separated by ; .
  • PR state. Merged PRs show their state without CI. For open PRs, a gate token follows CI: 🧐 agent review N/M, ⛔, 🙋 owner review, 🙋 re-approval, or ✅ owner approved.
  • Rows. A bound reviewer's row sits directly below its implementer, and the pair ranks by its newest member. The reviewer row shows no PRs or PR state, only the reviewer's own artifacts. Its activity ends with 🧐 N passes, M comments, taken from review_history and omitted when there is none.
  • 🙋 rule. The implementer's row gets 🙋 whenever the gate waits for the owner. Footnotes flag a Ready PR without approval, and an owner gate without a satisfied verdict or a passing local validation on the current head.
  • Links. Links are bare autolinks without fragments: <https://github.com/OWNER/REPO/pull/N> and <file:///abs/path>. File paths are percent-encoded.
  • Icons. 🔨 marks implementers.
  • Author actions. Top-level author_actions render as 🙋 campaign: footnotes. An author_action gets a re-evaluate note when author_action_at is missing, or when one of the agent's PRs merged or closed after it.

Ledger schema (references/watch.md, scripts/pew.py)

  • Example. The schema is documented as one JSON example plus short field notes.
  • Validation. validate_ledger accepts exactly those shapes (including review_history entries' reviewer and comments), treating null the same as absent. Every recorded head must be a full 40-character SHA.
  • Doc-tied test. pew-test reads the example from watch.md and checks that it validates and renders. A table-driven test checks accepted and rejected values for every documented field.

Test Plan

  • ./tool/bazel test //.agents/skills/orchestrate-sdlc/... //.claude/skills/orchestrate-sdlc/... (the second path is the same skill loaded through the .claude/skills symlink), and make build
  • Render PEW locally (needs gh authenticated): ./tool/bazel run //.agents/skills/orchestrate-sdlc/scripts:pew -- --state <checkout>/.sdlc/campaign.json
  • make lint, make check-gazelle and make check-tidy on a staged tree.

🤖 Generated with Claude Code

@sbalabanov
sbalabanov force-pushed the skill/pew-grouping branch 2 times, most recently from fd7e0ce to e5b1c03 Compare December 1, 2026 00:40
@sbalabanov
sbalabanov marked this pull request as ready for review December 1, 2026 00:40
@sbalabanov
sbalabanov requested review from a team as code owners December 1, 2026 00:40
@sbalabanov
sbalabanov marked this pull request as draft December 1, 2026 02:01
@sbalabanov sbalabanov changed the title feat(skills): group reviewers with implementers and flag stale author actions in PEW feat(skills): gate Ready on agent review and owner approval, and group reviewers in PEW Dec 1, 2026

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] round 1/5: changes needed.

Reviewed 8e856b0 (full diff vs origin/main, focusing on the Review before Ready gate). ./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). A read-only live render is correct: reviewers are grouped, merged PRs show no CI, and #1153 shows 🧐 agent review 1/5 on both the implementer and reviewer rows with no stale 🙋. The ledger was unchanged.

The watch readiness fence, the merge gate and outreach all require the gate (owner_approved at the current head, or ready), so I found no code path to Ready without an approval record. Four must-fix findings are inline. Three concern how that approval record can be produced. A comment edited by a third party counts. A prompt approval does not name a SHA. The reviewer's satisfaction is inferred from thread state that the implementer controls. The fourth: PEW's head comparison accepts prefixes, including a 1-char head.

Nit not tied to a changed line: workflow.md:39 still lists "readiness" among standing user authorizations ("Standing authorization can cover subsequent updates"), and :97 allows campaign-level autonomous-action authorizations. State that no standing or campaign authorization bypasses Review before Ready, so the two rules cannot be read against each other.

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] round 2/5: changes needed.

Reviewed 5d25b96 (single commit vs origin/main; delta from 8e856b0 checked line by line). All 7 round-1 threads are correctly fixed and stay resolved:

  • edited approval comments are excluded (lastEditedAt null), with ID/URL/createdAt in ref;
  • a prompt approval binds to a named or last-shown head, must equal the current head, and counts only from the user's own message;
  • review_verdict drives the gate, thread state never does, and an unverified cap round escalates;
  • heads are full 40-char lowercase hex compared with ==;
  • plus the ready-on-Draft footnote, the ⛔ wording, top-level comments only, "never on GitHub", and authorizations never bypassing the gate.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results).

Two new must-fix findings are inline. (1) The verdict rule now contradicts step 4's "unless trivial" re-review exception. (2) The live read-only render fails outright, because the reviewer's GitHub review, now its normal deliverable, has no documented ledger home and was stored as a URL artifact that render_agent_row rejects. With that artifact removed from a copy of the ledger, the render is correct: grouped rows, 🧐 agent review 2/5 on #1153 for both rows, merged #1138 without CI, no stale 🙋. The ledger itself was not modified.

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] round 3/5: changes needed.

Reviewed 9dd3ec4 (delta from 5d25b96 checked line by line). All 3 round-2 threads are correctly fixed and stay resolved:

  • the trivial-change exception is gone, and every owner-requested push gets a non-counting verdict pass before returning to owner_review, so steps 2 and 4 now agree;
  • GitHub reviews live in review_verdict.ref and review_history, never artifacts, and PEW links the latest review on the reviewer row;
  • a round is one reviewer pass over one head, ending in its verdict.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). The live read-only render at this head works again and is correct: reviewer grouped under its implementer, 🧐 agent review 3/5 on #1153 for both rows, the round-2 review linked on the reviewer row, merged #1138 without CI, no stale 🙋. The ledger was unchanged.

One must-fix is inline: the documented shape of owner_approval.ref (comment ID, URL, createdAt) does not match the validator's string-only check, so recording a comment approval that way crashes PEW at the owner gate. It is a one-line doc or validator alignment. Two small nits are also inline.

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] round 4/5: satisfied.

Reviewed fb6cd87 (delta from 9dd3ec4 checked line by line). No must-fix findings.

  • Round-3 threads, all correctly fixed: owner_approval.ref is a string (the comment URL or the quoted prompt), and comment_created_at is its own field. Null counts as absent everywhere, including ref. A null review ref renders no link, and multi-PR reviewer links read #N review.
  • Docs-to-validator tie, verified by mutation: I edited a copy of the watch.md JSON example and ran pew_test. An object-shaped ref, a 7-char approval head, an unknown gate, and string reply IDs each fail the test; the unmodified example passes. Renaming the heading or dropping the block also fails, because documented_ledger raises. The data dependency resolves from runfiles under Bazel. The tie covers every field the renderer reads; see the one inline nit for keys it does not read.
  • Gate safety, re-checked end to end: approval binds to a full 40-char head compared with ==, comes from an unedited top-level owner comment or your own prompt, and recorded agent comment IDs never count. Any push before Ready voids it. Ready, the merge gate, and outreach all require the gate. A round is one verdict on one head, and the gate moves only on satisfied for the current head. Owner-requested pushes get non-counting verdict passes. At the cap the PR escalates.
  • No internal system names in the diff.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). The live read-only render at this head, on the migrated ledger (outreach, list-shaped reply_ids), validates and is correct: reviewer grouped under its implementer, 🧐 agent review 4/5 on #1153 for both rows, the round-3 review linked on the reviewer row, merged #1138 without CI, no stale 🙋. The ledger was unchanged.

@sbalabanov sbalabanov changed the title feat(skills): gate Ready on agent review and owner approval, and group reviewers in PEW feat(skills): gate Ready on agent review and owner approval, and pair reviewers in PEW Dec 1, 2026

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] owner-request pass (not counted): satisfied.

Reviewed 5080da9 against fb6cd87. No must-fix findings.

  • Pair rows (Option A):
    • render_group_row gives one row per implementer plus its bound reviewers. The agent cell reads 🔨 impl (model) · 🧐 rev (model) ISSUE.
    • Links merge with exact-string dedup, and PR numbers are deduplicated in order, so the state cell appears once.
    • Activity is impl next · last time · 🧐 rev last time. Working reviewers lead with 🧐 next · last time, then 🔨 and the implementer's activity, then idle reviewers.
    • 🙋 stays on each member's own segment. The owner-gate 🙋 goes only to the PR record's owner, so a reviewer never inherits it.
    • Unbound reviewers, archived-bound reviewers and lone agents render exactly as before, and the pair ranks by its newest member.
    • The table-driven tests cover idle vs working reviewers, several reviewers, link dedup, a null review ref, 🙋 placement, owner-gate marking, unbound/archived-bound reviewers, ranking and name ties.
  • SKILL.md matches the code, including the one documented drop: an idle bound reviewer's next_step.
  • watch.md: the narrowed sentence (keys the renderer reads; bookkeeping keys documented but unchecked) is accurate. I re-ran the mutation check on a copy: an object-shaped ref, an empty reviews and an unknown verdict in the example each fail pew_test, and the unmodified example passes.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). The live read-only render at this head shows one 🔨 skill-1-implementer-2 · 🧐 skill-1-reviewer-4 ⚙️ SKILL-1 row with merged links, #1138 🟣 Merged; #1153 🟡 Draft · ⚪ skipped · 🧐 agent review 4/5, and the working reviewer's segment leading. Merged #1138 shows no CI and there is no stale 🙋. The ledger was unchanged. Two small nits are inline.

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] owner-request pass (not counted): satisfied.

Reviewed 50b50f6 against 5080da9. No must-fix findings.

  • Link shapes, one code path:
    • PRs render as <url> using GitHub's URL verbatim, or a plain #N when the fetch failed.
    • Artifacts render as kind <file:///…>. Path.as_uri percent-encodes spaces, angle brackets, % and |, and the tests cover spaces and angle brackets.
    • Reviews render as review <https://…#pullrequestreview-N>. The PR number stays readable in the URL, so dropping the #N review label resolves my earlier nit.
    • test_links_are_bare_autolinks asserts that no ]( appears.
  • Escaping rule: validate_head_record rejects an https ref containing whitespace or </> for review_verdict, every review_history entry and owner_approval, and the documented-fields table covers accepted (%20) and rejected (space, <1>) values. Non-https refs (a quoted prompt) are unaffected and render no link.
  • The investigator-bound and unknown-bound reviewer cases are back, each expecting its own row.
  • SKILL.md (bare autolinks, percent-encoding, the rejected characters) and watch.md (review_verdict.ref constraint) match the code.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). The live read-only render at this head exits 0, and I checked its output mechanically: 17 <…> spans, every one a valid CommonMark absolute-URI autolink (a scheme of 2 to 32 characters, then no whitespace, controls or <>), no stray </> outside them, and no ](. Rows are correct: the implementer-reviewer pair row with merged links, merged #1138 without CI, and no stale 🙋. The ledger was unchanged. One hardening nit is inline.

@sbalabanov sbalabanov changed the title feat(skills): gate Ready on agent review and owner approval, and pair reviewers in PEW feat(skills): gate Ready on agent review and owner approval, and group reviewers in PEW Dec 1, 2026

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[skill-1-reviewer-4] owner-request pass (not counted): satisfied.

Reviewed 0a678e8 against 50b50f6. No must-fix findings and no nits.

  • No fragments: review URLs are no longer rendered. GitHub PR URLs have no fragment, and Path.as_uri percent-encodes # in artifact paths (new test: /a/v#2.md becomes <file:///a/v%232.md>). test_links_are_bare_autolinks_without_fragments asserts that no <…> contains #, and the documented-example test asserts that pullrequestreview never appears.
  • Option A reverted: render_agent_row renders one row per agent again, in agent_display_groups order. A bound reviewer sits directly below its implementer and the pair ranks by its newest member. A bound reviewer's links cell drops PR links and shows only its own artifacts, or is empty. Its state and activity cells are unchanged, and it does not inherit the implementer's owner-gate 🙋. Unbound reviewers and reviewers of archived, investigator or unknown agents keep standalone rows with their PR links. SKILL.md matches this, and the hidden-next_step exception is gone.
  • Artifacts render as the bare <file:///…> with no kind prefix, and paths are unchanged. There is no width logic and there are no per-PR rows.
  • Dropping the ref autolink check is sound: no rendering path reads any ref any more. review_verdict.ref, review_history[].ref, owner_approval.ref (including a quoted-prompt ref) and outreach[].ref appear in pew.py only in their string-or-null type checks. The watch.md text no longer claims the constraint.
  • The watch.md example still ties the docs to the validator. On a copy, an object-shaped approval ref or an unknown gate in the example fails pew_test, and the unmodified example passes.

./tool/bazel test //.agents/skills/orchestrate-sdlc/... passes all 3 targets (--nocache_test_results). The live read-only render at this head exits 0, and I checked it mechanically: 16 <…> spans, all valid CommonMark absolute-URI autolinks, none containing #, no stray </>, no ](, and 4 cells in every row. skill-1-reviewer-4's row sits directly below skill-1-implementer-2 with an empty links cell. Merged #1138 shows no CI and there is no stale 🙋. The ledger was unchanged.

@sbalabanov
sbalabanov marked this pull request as ready for review December 1, 2026 19:32
@sbalabanov
sbalabanov force-pushed the skill/pew-grouping branch 2 times, most recently from 7bb32de to 2b298da Compare December 1, 2026 20:38
…p reviewers in PEW

A PR now leaves Draft only after its bound reviewer is satisfied within a configurable round cap (default 5, escalating to the user at the cap), the implementer records passing local validation, and the owner approves the exact head on the PR or in the prompt. Ready triggers CI and outreach; later feedback and CI failures need no further owner approval. PEW shows the gate state and round count, puts 🙋 on the implementer whenever the gate waits for the owner, and flags Ready without recorded approval.

PEW also places each bound reviewer's row directly below its implementer and ranks the pair by its newest member, prints every link as a bare fragment-free autolink, shows a merged PR without CI, and uses 🔨 for implementers. Each author_action carries author_action_at, and PEW flags the 🙋 for re-evaluation when that time is missing or one of the agent's PRs merged or closed after it. The ledger schema is a single example in watch.md that the renderer's validator and tests both enforce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sbalabanov
sbalabanov merged commit 1eeb2ae into main Dec 1, 2026
21 checks passed
@sbalabanov
sbalabanov deleted the skill/pew-grouping branch December 1, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants