Skip to content

Commit e5b1c03

Browse files
sbalabanovclaude
andcommitted
feat(skills): group reviewers with implementers and flag stale author actions in PEW
PEW now places reviewer rows directly below the implementer they review and ranks the group by its newest member, shows a merged PR without CI, and uses 🔨 for implementers so they no longer resemble the 🧐 reviewer face. Each author_action carries author_action_at, and PEW flags the 🙋 for re-evaluation when that time is missing or any of the agent's PRs merged or closed after it. Campaign-level author actions get their own top-level ledger list and footnotes, and the skill tells the orchestrator to re-evaluate author_action when decisions resolve or PRs merge or close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b9cf5c6 commit e5b1c03

4 files changed

Lines changed: 201 additions & 21 deletions

File tree

‎.agents/skills/orchestrate-sdlc/SKILL.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ Never drop a field to save width. Keep the ledger's next-step and last-action ph
5656

5757
The script renders only what the ledger holds, so keeping these fields current is the orchestrator's duty (schema in [watch.md](references/watch.md)):
5858

59-
- `last_update` and `last_action` change on each meaningful work-item event: code changes, PR/check-state transitions, new/edited comments, agent responses, and new agent instructions. Read-only polls, unchanged snapshots, and `PEW` itself do not change them. Rows sort newest first, not by issue priority.
59+
- `last_update` and `last_action` change on each meaningful work-item event: code changes, PR/check-state transitions, new/edited comments, agent responses, and new agent instructions. Read-only polls, unchanged snapshots, and `PEW` itself do not change them. Rows sort newest first, not by issue priority; reviewer rows sit directly below the implementer they `review`, and the group ranks by its newest member.
6060
- `state` is `working` or `idle`, the only two displayed worker states. Dormant, waiting, blocked, and completed are explained in `next_step` text. Worker activity is independent of PR state.
61-
- `author_action` names what the change author running the orchestrator must do, such as reviewing a Draft or answering a pending decision, and adds `🙋` to the row. Other human reviewers are not operators: awaiting their approval or an unresolved review thread alone does not set it. Clear it after the author responds unless a further author action remains pending.
61+
- `author_action` names what the change author running the orchestrator must do, such as reviewing a Draft or answering a pending decision, and adds `🙋` to the row. Other human reviewers are not operators: awaiting their approval or an unresolved review thread alone does not set it. Re-evaluate it whenever the author answers, a decision it names is resolved, or one of the agent's PRs merges or closes: clear it, or narrow it to what is still pending, and set `author_action_at` to the time it was set or last re-evaluated. A decision tied to no agent's open work, such as deleting a retired worktree, goes in the top-level `author_actions` list, which renders as `🙋 campaign:` footnotes, never on an unrelated agent's row. The renderer flags a 🙋 for re-evaluation when `author_action_at` is missing or any of the agent's PRs merged or closed after it.
6262
- `artifacts` holds the latest final artifact of each kind (investigation report, implementation spec, review report), replaced when a new version is delivered, never a draft.
6363
- `model` is the concrete model; when it is unknown the row shows `model?`, and the orchestrator asks that agent once when it next reports.
6464

65-
Role icons are fixed identity, not state: 🔎 investigator, 🧑‍💻 implementer, 🧐 reviewer. CI is 🟢 `pass` only when every required check explicitly passed on the current head; skipped is not passing. `Ready` is not approval or merge eligibility, so the review decision appears in a footnote.
65+
Role icons are fixed identity, not state: 🔎 investigator, 🔨 implementer, 🧐 reviewer. CI is 🟢 `pass` only when every required check explicitly passed on the current head; skipped is not passing. A merged PR shows only 🟣 `Merged`, without CI. `Ready` is not approval or merge eligibility, so the review decision appears in a footnote.
6666

6767
Archived agents are omitted and counted in a footnote; retain their reports and transcripts. Merged implementer owners become eligible for archival only after one week from merge, with no active assignment, unresolved follow-up, or other/shared PR ownership; a bound reviewer is archived together with its implementer. Preserve their full historical record before removal; age alone never archives an active owner. Do not wake agents merely to list them; the one-off model question is the exception. `PEW` is read-only: it never grants mutation authority, restarts a watcher, or renews a watch window.
6868

‎.agents/skills/orchestrate-sdlc/references/watch.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
Keep one campaign ledger outside tracked files, at `.sdlc/campaign.json` in the main checkout (see Worktrees in [workflow.md](workflow.md)). The orchestrator is its writer; workers receive the absolute path and their operation/run IDs. Preserve the agent/issue/PR registry, permissions, exact heads/readiness/dependencies, feedback revisions and reply IDs, event cursors, retry budgets, and per-PR operation ownership. Keep tokens and other secrets out of it.
66

7-
Keep these records separate: `agents` is keyed by agent name, and each entry holds its agent ID, task, worktree path and branch, `reviews` (a reviewer's bound implementer name), and the fields the [PEW renderer](../scripts/pew.py) reads: `role` (`investigator`, `implementer`, or `reviewer`), `model` (concrete model name: spawn-time resolution, replaced by the agent's self-report), `issue` (issue ID), `prs` (PR numbers), `artifacts` (kind to `{"path": absolute path, "at": UTC delivery time}`), `state` (`working` or `idle`), `archived` (boolean), `next_step` and `last_action` (short phrases), `last_update` (UTC time of the last meaningful event), and `author_action` (the pending change-author action, or null); `prs` includes the current head, readiness, dependencies, and owner; `parameters` (`display_timezone` and any per-role models), `permissions`, `feedback`, `reply_ids`, `cursors`, `budgets`, and `operations` retain their corresponding evidence. Register watcher/receiver identities and verification evidence under `watch.runtime`, tagged with the current run ID.
7+
Keep these records separate: `agents` is keyed by agent name, and each entry holds its agent ID, task, worktree path and branch, and the fields the [PEW renderer](../scripts/pew.py) reads: `role` (`investigator`, `implementer`, or `reviewer`), `reviews` (a reviewer's bound implementer name), `model` (concrete model name: spawn-time resolution, replaced by the agent's self-report), `issue` (issue ID), `prs` (PR numbers), `artifacts` (kind to `{"path": absolute path, "at": UTC delivery time}`), `state` (`working` or `idle`), `archived` (boolean), `next_step` and `last_action` (short phrases), `last_update` (UTC time of the last meaningful event), `author_action` (the pending change-author action on that agent's work, or null), and `author_action_at` (UTC time it was set or last re-evaluated); top-level `author_actions` lists pending change-author actions tied to no agent's work; `prs` includes the current head, readiness, dependencies, and owner; `parameters` (`display_timezone` and any per-role models), `permissions`, `feedback`, `reply_ids`, `cursors`, `budgets`, and `operations` retain their corresponding evidence. Register watcher/receiver identities and verification evidence under `watch.runtime`, tagged with the current run ID.
88

9-
Record each agent's `last_update`, `last_action`, and `author_action`; waiting for other reviewers is not operator input. A new event or instruction changes that record; an unchanged poll or `PEW` does not. Store absolute UTC times; render all displayed event/deadline/status output using the ledger's `display_timezone` (see Skill parameters in `SKILL.md`) with date, time, and short timezone abbreviation. A display-timezone change never changes an absolute deadline or watch window. After one week from merge, an inactive implementer with no other/shared ownership or unresolved follow-up may leave the active ledger only after its complete record is preserved in history.
9+
Record each agent's `last_update`, `last_action`, `author_action`, and `author_action_at`, and campaign-level `author_actions`; waiting for other reviewers is not operator input. A new event or instruction changes that record; an unchanged poll or `PEW` does not. Store absolute UTC times; render all displayed event/deadline/status output using the ledger's `display_timezone` (see Skill parameters in `SKILL.md`) with date, time, and short timezone abbreviation. A display-timezone change never changes an absolute deadline or watch window. After one week from merge, an inactive implementer with no other/shared ownership or unresolved follow-up may leave the active ledger only after its complete record is preserved in history.
1010

1111
The control helper changes only the ledger's `watch`/`watch_history` fields and preserves other fields. It uses POSIX file locking and atomic replacement; use it from a POSIX checkout such as the repository's supported Linux environment. Run it through Bazel from the repository root:
1212

‎.agents/skills/orchestrate-sdlc/scripts/pew.py‎

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from worktree_control import sdlc_root
2323

24-
ROLE_ICONS = {"investigator": "🔎", "implementer": "🧑‍💻", "reviewer": "🧐"}
24+
ROLE_ICONS = {"investigator": "🔎", "implementer": "🔨", "reviewer": "🧐"}
2525
WORKING_ICON = "⚙️"
2626
AUTHOR_ICON = "🙋"
2727
UNKNOWN = "unknown"
@@ -76,7 +76,7 @@ def run_gh(cwd: Path, *args: str) -> str:
7676

7777
def gh_pr_fetcher(cwd: Path) -> PRFetcher:
7878
def fetch(number: str) -> dict:
79-
pr = json.loads(run_gh(cwd, "pr", "view", number, "--json", "url,state,isDraft,reviewDecision"))
79+
pr = json.loads(run_gh(cwd, "pr", "view", number, "--json", "url,state,isDraft,reviewDecision,mergedAt,closedAt"))
8080
pr["required_checks"] = json.loads(run_gh(cwd, "pr", "checks", number, "--required", "--json", "name,bucket") or "[]")
8181
pr["checks"] = json.loads(run_gh(cwd, "pr", "checks", number, "--json", "name,bucket") or "[]")
8282
return pr
@@ -113,6 +113,25 @@ def ci_marker(pr: dict | None) -> str:
113113
return f"{CI_MARKERS.get(verdict, '⚪')} {verdict}"
114114

115115

116+
def pr_state_entry(pr: dict | None) -> str:
117+
if pr is not None and pr.get("state") == "MERGED":
118+
return pr_marker(pr)
119+
return f"{pr_marker(pr)} · {ci_marker(pr)}"
120+
121+
122+
def author_action_reevaluation(agent: dict, prs: dict) -> str:
123+
if not agent.get("author_action_at"):
124+
return " (author_action_at missing: re-evaluate)"
125+
since = parse_timestamp(agent["author_action_at"])
126+
for number in agent.get("prs") or []:
127+
pr = prs[str(number)][0]
128+
# GitHub can record closedAt a second after mergedAt; an action set at the merge time must not look stale.
129+
ended = pr and pr.get("state") in ("MERGED", "CLOSED") and (pr.get("mergedAt") or pr.get("closedAt"))
130+
if ended and parse_timestamp(ended) > since:
131+
return " (PR merged or closed since: re-evaluate)"
132+
return ""
133+
134+
116135
def pr_footnotes(number: str, pr: dict | None, error: str | None) -> list[str]:
117136
if pr is None:
118137
return [f"#{number}: GitHub unavailable: {cell_text(error)}"]
@@ -141,7 +160,7 @@ def render_agent_row(name: str, agent: dict, prs: dict, now: datetime, zone: Zon
141160
links.append(f"[{cell_text(kind)}]({path.as_uri()})")
142161
second = " · ".join(links) or "—"
143162

144-
entries = [f"{pr_marker(prs[n][0])} · {ci_marker(prs[n][0])}" for n in numbers]
163+
entries = [pr_state_entry(prs[n][0]) for n in numbers]
145164
if len(numbers) > 1:
146165
entries = [f"#{n} {entry}" for n, entry in zip(numbers, entries)]
147166
third = "; ".join(entries) or "—"
@@ -166,11 +185,39 @@ def validate_ledger(state: dict) -> None:
166185
raise ValueError(f"agent {name}: prs must be a list")
167186
if not isinstance(agent.get("artifacts") or {}, dict):
168187
raise ValueError(f"agent {name}: artifacts must be an object keyed by kind")
188+
reviews = agent.get("reviews")
189+
if reviews is not None and not (isinstance(reviews, str) and reviews):
190+
raise ValueError(f"agent {name}: reviews must be an agent name or null")
191+
action_at = agent.get("author_action_at")
192+
if action_at is not None:
193+
if not isinstance(action_at, str):
194+
raise ValueError(f"agent {name}: author_action_at must be a UTC timestamp or null")
195+
parse_timestamp(action_at)
196+
actions = state.get("author_actions")
197+
if actions is not None and not (isinstance(actions, list) and all(isinstance(action, str) and action for action in actions)):
198+
raise ValueError("ledger author_actions must be a list of non-empty strings")
169199
watch = state.get("watch")
170200
if watch is not None and not (isinstance(watch, dict) and watch.get("phase") and watch.get("deadline_at")):
171201
raise ValueError("ledger watch must be null or an object with phase and deadline_at")
172202

173203

204+
def agent_display_order(active: dict) -> list[str]:
205+
def last_update_key(name: str) -> datetime:
206+
value = active[name].get("last_update")
207+
return parse_timestamp(value) if value else datetime.min.replace(tzinfo=timezone.utc)
208+
209+
bound = {
210+
name: agent["reviews"]
211+
for name, agent in active.items()
212+
if agent.get("role") == "reviewer" and active.get(agent.get("reviews"), {}).get("role") == "implementer"
213+
}
214+
groups = {name: [name] for name in active if name not in bound}
215+
for reviewer in sorted(sorted(bound), key=last_update_key, reverse=True):
216+
groups[bound[reviewer]].append(reviewer)
217+
leads = sorted(sorted(groups), key=lambda lead: max(last_update_key(member) for member in groups[lead]), reverse=True)
218+
return [member for lead in leads for member in groups[lead]]
219+
220+
174221
def render_pew(state: dict, now: datetime, fetch_pr: PRFetcher) -> str:
175222
validate_ledger(state)
176223
zone_name = (state.get("parameters") or {}).get("display_timezone")
@@ -193,17 +240,17 @@ def render_pew(state: dict, now: datetime, fetch_pr: PRFetcher) -> str:
193240
except (RuntimeError, OSError, ValueError) as error:
194241
prs[number] = (None, str(error))
195242

196-
def last_update_key(name: str) -> datetime:
197-
value = active[name].get("last_update")
198-
return parse_timestamp(value) if value else datetime.min.replace(tzinfo=timezone.utc)
199-
200-
order = sorted(sorted(active), key=last_update_key, reverse=True)
243+
order = agent_display_order(active)
201244

202245
local_now = now.astimezone(zone)
203246
lines = [f"PEW · {local_now.strftime('%Y-%m-%d %H:%M %Z')} · {watch_summary(state.get('watch'), now, zone)}", "", HEADER]
204247
lines += ["| " + " | ".join(render_agent_row(name, active[name], prs, now, zone)) + " |" for name in order]
205248

206-
notes = [f"{AUTHOR_ICON} {name}: {cell_text(active[name]['author_action'])}" for name in order if active[name].get("author_action")]
249+
notes = [f"{AUTHOR_ICON} campaign: {cell_text(action)}" for action in state.get("author_actions") or []]
250+
for name in order:
251+
if active[name].get("author_action"):
252+
reevaluate = author_action_reevaluation(active[name], prs)
253+
notes.append(f"{AUTHOR_ICON} {cell_text(name)}: {cell_text(active[name]['author_action'])}{reevaluate}")
207254
for number, (pr, error) in prs.items():
208255
notes += pr_footnotes(number, pr, error)
209256
archived = len(agents) - len(active)

0 commit comments

Comments
 (0)