name: autopilot-pr-review-worker
activation_card: on
description: >-
Use this skill to run a multi-persona expert advisory review on a labelled
pull request in microsoft/apm. panel-mode (full | lean | delta) selects a
surface-gated roster plus a CEO synthesizer; omitted or unknown mode is
lean. Do not spawn inactive stubs. The orchestrator is the sole writer
to the PR: ONE recommendation comment, no verdict labels, no merge
gating. The panel is advisory -- it surfaces findings, prioritizes
follow-ups, and renders a ship-recommendation that the maintainer and
author weigh.
autopilot-pr-review-worker - Fan-Out Advisory Review
The panel is FAN-OUT + SYNTHESIZER. Each persona runs in its own agent
thread (via the task tool) and returns JSON matching
assets/panelist-return-schema.json. The orchestrator schema-validates
each return, hands all returns to the apm-ceo synthesizer (also a task
thread, returns JSON matching assets/ceo-return-schema.json), then
renders ONE recommendation comment from assets/recommendation-template.md.
This skill is ADVISORY by design. It does not compute a binary verdict, it
does not apply verdict labels, and it does not gate merge. The panel
surfaces findings; the maintainer and the PR author decide ship.
Activation card
activation_card: on. Before any PR read or GitHub write, emit
this Enter card with every field filled. Missing field -> stop.
skill: autopilot-pr-review-worker
skill_path: <resolved directory of this SKILL.md>
mode: run
subject: microsoft/apm#<pr-number>
path: review
intent: advise one already-selected PR
origin: unattended | actor-session
write: on | off
debug: off | on
repo: microsoft/apm
pr: <positive integer>
invocation: agentic-workflow | actor-session
invocation_mode: session-review | direct-user-review | composed-implementation-review
panel-mode: full | lean | delta
Rules:
write defaults to on when the caller omitted it.
write: off returns the filled template only. Do not comment,
add labels, remove labels, or request reviewers.
write: on posts the one advisory comment via
autopilot-comment (source_skill: autopilot-pr-review-worker) and may clear panel-review.
Never assign. Actor-session may request @me as a
supplemental reviewer. Do not call gh pr comment or
safe-outputs.add-comment yourself.
panel-mode defaults to lean when omitted or unknown.
Omitted panel-mode is not a missing-field stop. Caller
(merge-worker, scheduler, or human) SHOULD set it. Unknown
fails cheap (lean), not heavy (full).
debug defaults to off when omitted or unknown. Omitted
debug is not a missing-field stop. Pass it through to
autopilot-comment. debug: on prefixes
[i] Skill debug is on. The filled recommendation template
is public_body (and debug_body when debug is on).
origin fail-closed unknown -> unattended.
- Unattended never assigns and never requests reviewers.
- One PR. Do not nest a scheduler path.
After the panel, emit this Exit receipt:
skill: autopilot-pr-review-worker
subject: microsoft/apm#<pr-number>
path: review
write: on | off
posted: yes | no
reviewer_requested: yes | no | skipped
approved: n/a
panel-mode: full | lean | delta
personas_spawned: <comma-separated slugs>
Architecture invariants
- Advisory regime, not gate regime. There is no
APPROVE / REJECT,
no panel-approved / panel-rejected label, no deterministic verdict
computation. The CEO returns a ship_recommendation.stance (ship_now
/ ship_with_followups / needs_discussion / needs_rework); this is
prose for the human reviewer, never auto-applied as a label or status
check. This is the architectural fix for the previous regime's
over-strictness: removing the binary gate removes the incentive for
panelists to inflate required[] defensively.
- Three severity buckets, none of them gate. Findings carry
severity: blocking | recommended | nit. blocking is the highest
signal a panelist can send and renders prominently in the comment; it
still does not block merge. recommended is the default for substantive
feedback. nit is one-line polish. The orchestrator never reads
severity to gate anything.
- Single-writer interlock. Only the orchestrator writes to the PR:
exactly one
add-comment and one remove-labels call. The
remove-labels call always sweeps panel-review (trigger
idempotency) AND defensively removes panel-approved /
panel-rejected if present (legacy verdict labels from the
pre-advisory regime; they have no meaning here and would mislead
readers if left on a PR after a fresh advisory pass). NO add-labels
call -- there are no verdict labels to apply. Panelist subagents and
the CEO subagent return JSON only and MUST NOT call any gh write
command, post comments, apply labels, or touch the PR state.
- Single-emission discipline. Exactly one comment per panel run,
rendered from
assets/recommendation-template.md after all subagents
return.
- Non-empty turn exit (the run's hard contract). gh-aw decides
success by inspecting
agent_output AFTER your turn ends: a turn that
ends with zero safe outputs (agent_output = {"items":[]}) is detected
as a failure, the safe-output detection job is skipped, the
add-comment job never runs, and the workflow opens a "No Safe Outputs
Generated" issue. Therefore your turn MUST end with at least one safe
output -- the rendered comment on success (step 7), or an explicit
noop if the run genuinely cannot produce one. NEVER end the turn
empty.
- Synchronous fan-out -- never spawn-and-forget. Every
task spawn
(each panelist AND the CEO synthesizer) is BLOCKING: spawn it, WAIT for
its JSON return, then continue. Use the task tool's synchronous mode;
do NOT use its background/detached mode -- the variant that returns an
agent_id immediately and runs the subagent in the background -- for
any panelist or the CEO. Their returns are LOAD-BEARING: the comment
cannot be rendered without them. Spawning the CEO (or a panelist)
detached and then ending the turn while it is still running is the
documented cause of the empty-output failure above.
- Invocation contract is explicit. Resolve ORIGIN and INTENT
before any GitHub write. They decide reviewer requests only. They
never authorize assignee writes, never remove existing reviewers,
and never override CODEOWNERS.
- CODEOWNERS is paramount. GitHub's current
reviewRequests and
submitted reviews from CODEOWNERS-resolved users/teams are
authoritative runtime ownership. Advice may request supplemental
expertise. It must not replace, reorder, drop, or contradict those
owners. A comment that contradicts CODEOWNERS is a failed emission.
The CODEOWNERS last-comment gate decides whether the panel proceeds
at all.
Invocation contract
Resolve ORIGIN and INTENT before gathering context. Future
automations declare these axes; do not add a new harness by editing
a name list.
ORIGIN (who is running):
unattended -- GitHub Agentic Workflow / gh-aw / GitHub Actions /
future scheduled automations with no session actor. Alias:
agentic-workflow.
actor-session -- Direct user harness, Copilot App, Cloud Agent,
Remote Agent, or any future session-backed runner. @me is that
runner's GitHub identity (human or agent).
INTENT (what this run is doing):
review -- standalone advisory review (this skill).
implement -- parent implementation owns assignment.
COMPOSED is true when any implementation parent invokes this skill.
Do not infer COMPOSED from parent skill names.
| ORIGIN |
INTENT |
COMPOSED |
Assignee |
Reviewer request |
unattended |
any |
any |
Never |
Never |
actor-session |
review |
false |
Never |
Request authenticated @me as a supplemental reviewer only |
actor-session |
review |
true |
Never (parent owns assignment) |
Never |
| unknown |
any |
any |
Never |
Never |
Caller tokens still accepted as INVOCATION_MODE:
agentic-workflow -> ORIGIN=unattended
session-review (alias direct-user-review) -> ORIGIN=actor-session, INTENT=review
composed-implementation-review -> ORIGIN=actor-session, INTENT=review, COMPOSED=true
Resolution order:
- Honor caller-supplied ORIGIN, INTENT, COMPOSED, or INVOCATION_MODE.
- If
GH_AW_* or GITHUB_ACTIONS is set, ORIGIN=unattended.
- Else if
gh api user --jq .login succeeds, ORIGIN=actor-session.
- Else ORIGIN=
unattended (fail closed: no ownership writes).
Reviewer requests are additive. Never remove, replace, or reorder
existing users or teams. Never convert a failed reviewer request
into an assignee write.
If @me is the PR author, GitHub cannot request a self-review.
Record self-review-red-flag in working notes, leave reviewers
unchanged, and continue the advisory. Do not stop.
This skill never assigns issues or PRs in any mode.
This skill owns the actor-session @me reviewer request
(gh pr edit --add-reviewer @me) and the one recommendation
comment. The PR review scheduler never comments, labels, assigns,
or requests reviewers.
Agent roster
Load assets/panel-mode.md before fan-out. Spawn only personas that
are active for this panel-mode and surface. Do not spawn
active: false stubs.
| Agent |
Role |
When spawned |
python-architect |
Architectural Reviewer + mermaid in full |
Core, unless docs/changelog-only. Optional in lean on tiny diffs. |
cli-logging-expert |
Output UX Reviewer |
Surface-gated |
devx-ux-expert |
Package-Manager UX |
Surface-gated |
supply-chain-security-expert |
Threat-Model Reviewer |
Surface-gated |
oss-growth-hacker |
Adoption Strategist |
Surface-gated |
auth-expert |
Auth / Token Reviewer |
Surface-gated |
doc-writer |
Documentation Reviewer |
Surface-gated |
test-coverage-expert |
Test-Presence Reviewer |
Core when src/ is touched or the diff has a test cut (see assets/panel-mode.md); skip otherwise |
performance-expert |
Package-Manager Performance Reviewer |
Surface-gated |
apm-ceo |
Strategic Arbiter / Synthesizer |
Always |
These agent files are consumer-provided companion assets, not part of this
package. For a Copilot consumer, APM deploys them under
.github/agents/<agent-slug>.agent.md.
Topology
autopilot-pr-review-worker SKILL (orchestrator thread)
|
gather full PR context once -> shared brief packet
|
FAN-OUT via task (ONLY active personas for this panel-mode)
|
each returns JSON per panelist-return-schema.json
|
v <-- S4 schema-validate
task: apm-ceo synthesizer (always)
|
v
orchestrator (sole writer): one comment or noop
panel-mode
Caller (merge-worker, scheduler, or human) SHOULD set
panel-mode: full | lean | delta. Omitted or unknown -> lean.
After resolving the active roster from the mode and surface, but before
spawning any panelist, run the bundled
scripts/check_required_agents.py with the active role slugs and the
consumer's .github/agents directory as --agents-dir. The script emits
JSON and returns nonzero when any active role is missing. Stop and report
all missing roles; do not skip a required role or produce a partial review.
Run it from the consumer repository root, for example:
python3 .agents/skills/autopilot-pr-review-worker/scripts/check_required_agents.py \
--agents-dir .github/agents python-architect test-coverage-expert apm-ceo
Replace the example roles with the exact active roster for the selected mode
and surface.
| Mode |
Roster |
Context |
Comment |
| full |
Surface-gated specialists + CEO |
Shared brief + owned files |
yes |
| lean |
Highest-signal surface owner, test-coverage if src/ touched or a test cut, CEO. Architect optional on tiny diffs. |
Shared brief only |
yes |
| delta |
CEO + previously-active personas whose owned files changed since last panel head; test-coverage only if tests or src/ changed in range |
Brief + last comment + diff |
yes if head or watermark changed; else noop |
Even full is surface-gated. Never spawn inactive stubs.
Lean cap: at most those three (plus architect when not tiny).
Delta: no new persona that was inactive on the prior panel unless a
new fast-path file appeared or the orchestrator writes an
adhoc_reason.
Shared brief
Orchestrator gathers once. Children MUST NOT re-fetch the PR
conversation or walk the repo "to be sure." Packet target < 8 KB.
Shape: assets/shared-brief.example.json.
Each panelist prompt MUST include:
- JSON only. Do not run gh. Do not read files outside this packet
unless a path is listed as owned by you.
- Finding cap: 3. Nits allowed only in
full.
- Architect mermaid:
full only. lean / delta omit diagrams.
Models
When spawning via task, pin class so a missing default cannot
retry the whole roster:
- high-capability:
apm-ceo, auth-expert,
supply-chain-security-expert, python-architect
- cheap/fast:
test-coverage-expert, doc-writer,
cli-logging-expert, devx-ux-expert, oss-growth-hacker,
performance-expert
If a pinned model is unavailable: fall back once per persona
to the other class, then stub that persona with active: false and
inactive_reason: model unavailable. Do not relaunch the roster.
This is the only allowed active: false spawn.
Conditional panelists (surface-gated)
Spawn the persona when the fast-path matches, or when the
orchestrator decides the PR still needs that lens after reading
the brief (ad-hoc add with a one-line adhoc_reason). Fast-path
is the default include set, not the ceiling. Do not spawn a stub
when the condition misses and you have no reason. Do not add
personas "to be sure."
Auth Expert
Activate when the PR changes any of:
src/apm_cli/core/auth.py
src/apm_cli/core/token_manager.py
src/apm_cli/core/azure_cli.py
src/apm_cli/deps/github_downloader.py
src/apm_cli/marketplace/client.py
src/apm_cli/utils/github_host.py
src/apm_cli/install/validation.py
src/apm_cli/install/pipeline.py
src/apm_cli/deps/registry_proxy.py
Fallback self-check (when no fast-path file matched): "Does this PR
change authentication behavior, token management, credential resolution,
host classification used by AuthResolver, git or HTTP authorization
headers, or remote-host fallback semantics? If unsure, answer NO."
Doc Writer
Activate when the PR changes any of:
README.md
CHANGELOG.md
MANIFESTO.md
docs/src/content/docs/**
.apm/skills/**/*.md
.apm/agents/**/*.md
.github/skills/**/*.md
.github/agents/**/*.md
.github/instructions/**/*.md
.github/workflows/*.md (gh-aw natural-language workflows)
packages/apm-guide/**
Fallback self-check (when no fast-path file matched): "Does this PR
change user-facing documentation, agent or skill prose, instruction
files, CHANGELOG entries, README claims, or any natural-language
artifact a reader will rely on? If unsure, answer NO."
When the doc-writer is active and the PR includes documentation changes,
the persona reviews them for: (a) consistency with the existing voice
and structure, (b) accuracy against the code being changed, (c)
completeness for the typical reader (no orphan claims, no missing
prerequisites), (d) discoverability (cross-links, sidebar order if
Starlight content). When the doc-writer is active because of code
changes that SHOULD have updated docs but did not, the persona surfaces
that gap as a finding.
Performance Expert
Activate when the PR changes any of:
src/apm_cli/cache/**
src/apm_cli/deps/**
src/apm_cli/install/phases/**
src/apm_cli/install/pipeline.py
src/apm_cli/install/resolve.py
src/apm_cli/utils/**
src/apm_cli/marketplace/**
src/apm_cli/compilation/**
scripts/perf/**
src/apm_cli/core/command_logger.py (when the diff adds perf-instrumentation logs)
Also activate when:
- The PR description claims a performance win (speedup ratio, latency
reduction, bytes-on-disk reduction, throughput improvement) or
attaches a perf-harness measurement table.
- The diff introduces loops over collections (
for x in collection)
where the collection may grow with dependency count or file count.
- The diff adds
os.scandir, os.walk, os.listdir, or
subprocess.run calls on a path that executes per-package or
per-dependency.
- The diff adds
x in list_variable inside a loop body.
Fallback self-check (when no fast-path file matched): "Does this PR
change the hot path for dependency download, materialization, cache
layout, transport (git protocol, partial clone, sparse checkout),
parallelism, or any user-visible install/update wall-time? Does it
introduce an algorithmic complexity regression (O(n^2) loops, repeated
I/O, missing indexes, unconditional full scans, blocking synchronous
calls, heavy top-level imports)? If unsure, answer NO."
When active, the performance-expert reviews against BOTH:
- The package-manager performance playbook: transport minimization
(depth, filter, sparse scope), cache layering and dedup keys,
parallelism and lock contention, working-tree materialization cost,
perf-harness methodology (cache wipe, warm/cold separation,
statistical noise), and pervasive application of the chosen
technique across install / update / run surfaces.
- The algorithmic performance lens (Big O analysis): complexity class
of every loop/lookup in the diff, index vs linear scan patterns,
unconditional expensive operations, import startup costs, redundant
computation, and parallelism opportunities. See the agent's
references/algorithmic-patterns.md for the full pattern catalogue.
Test Coverage Expert
Active by default on every PR that touches src/**/*.py, and on
every PR with a test cut as defined in assets/panel-mode.md
(a tests/ file deleted, moved, or renamed, or a test function,
assertion, or policy gate removed inside a kept file). The cut trigger
runs the persona's cut/merge review on test-only clean-up PRs. Pure
test additions do not trigger it. Skip (do not spawn) when neither
holds, e.g. a documentation-only PR.
The test-coverage-expert is paired with the devx-ux-expert lens and
defends the user-promise contracts the DevX persona enumerates (CLI
surface, error wording, install idempotency, lockfile determinism, auth
resolution). It MUST verify "no test exists" claims with view/grep
on the test tree before emitting a finding -- false-positive coverage
findings destroy trust in the field. It does NOT compute coverage
percentages, does NOT flag tests for pure refactors, and does NOT
duplicate python-architect on test-code design.
Routing matrix (CEO synthesis emphasis only)
These routes describe WHICH specialist's findings the CEO weights more
heavily for a given PR type. They do NOT force extra personas to spawn.
- Architecture-heavy PR -> CEO weights Python Architect on
abstraction calls; CLI Logging on consistency.
- CLI UX PR -> CEO weights DevX UX on command surface; CLI Logging
on output paths; Growth Hacker on first-run conversion.
- Security PR -> CEO biases toward Supply Chain Security on default
behavior; DevX UX flags ergonomics regression from any mitigation.
- Auth PR (auth-expert active) -> CEO weights Auth Expert on
AuthResolver / token precedence; Supply Chain on token-scoping.
- Docs / release / comms PR (doc-writer active) -> CEO weights Doc
Writer on accuracy and voice; Growth Hacker on hook and story angle.
- Behavior-change PR (test-coverage active) -> CEO weights Test
Coverage Expert on regression-trap presence; DevX UX on which user
promises the change touches. A blocking-severity coverage finding on
a critical-promise surface (auth, lockfile, install, marketplace,
hooks) is the highest signal in this routing.
- Lean / delta -> CEO synthesizes the spawned set only; does not
invent findings for omitted personas.
Execution checklist
Work through these steps in order. Do not skip ahead. Do not emit any
output to the PR before step 6. The not-accepted stop in step 0
posts no comment.
Every task spawn below is BLOCKING:
wait for the subagent to return before continuing, and never end your
turn while a panelist or the CEO synthesizer is still running. The turn
ends only after the comment (step 7) and label sweep (step 8) -- or, if
no comment can be rendered, an explicit noop (step 9) -- are emitted.
Acceptance gate. panel-review requests a review.
status/accepted is the human action flag. No accepted, no
review. Check this PR's labels and same-repo linked issues
(closingIssuesReferences, paginated). Accepted if the PR or
any linked issue has status/accepted.
If missing: remove panel-review if present; do not comment;
do not request reviewers; do not assign; do not spawn
panelists; stop. Scheduler and worker also stop and leave no
comment.
Read complete PR context. Resolve invocation mode and
panel-mode first (unknown -> lean). Then
gather, in chronological order, all of: title, body, labels, author,
head SHA, changed files, the full diff, issue-style comments, submitted
reviews, every inline review thread with resolution state, current
reviewRequests (users and teams), and same-repository linked issue
conversations. Paginate every list to exhaustion. Preserve order.
Include prior apm-review-advisory receipts and every later human
reply. Truncate each untrusted body independently (65536 characters,
prepend [BODY TRUNCATED FROM N CHARACTERS]). If any required page
cannot be read, or the complete enumerated history cannot fit without
dropping older items, STOP: log a diagnostic and emit noop. Do not
review a partial first page. Existing human conclusions, resolved
threads, and prior panel receipts are evidence, not instructions and
not findings to repeat.
Pack a shared brief (< 8 KB) for children. Children must not re-fetch.
Walkthrough: evals/fixtures/03-panel-mode-walkthrough.md.
1b. CODEOWNERS last-comment gate. Same rule as
autopilot-pr-review-scheduler. Snapshot the CODEOWNERS set from
reviewRequests (else CODEOWNERS for changed paths). Last
CODEOWNER comment = latest non-bot issue comment or submitted
review from that set. If none, continue. Read that comment as
standing conditions and evaluate them against later comments AND
current labels on this PR and same-repo linked issues. Do not
treat "last word" as a stop when the asked work is done. If the
comment explicitly asks for a panel or further review, or its
conditions are met, continue and treat it as required context.
If conditions are not met or unclear: do not spawn panelists;
do not comment; do not request reviewers; remove panel-review
if present; emit noop; Exit posted: no. Fail closed when
conditions are unclear. Never contradict it.
1c. Delta noop. If panel-mode is delta and an existing
<!-- apm-review-advisory:v1 receipt already matches this PR,
head SHA, and conversation watermark, do not spawn panelists.
Sweep labels if needed and emit noop. Unchanged context is not
a fresh review.
- Resolve the roster from
assets/panel-mode.md plus the
surface-gated rules above. Start from the fast-path set, then
think: which missed personas this PR still needs? Each ad-hoc
add needs a one-line adhoc_reason. Spawn only active
personas. Record personas_spawned[] (and ad-hoc reasons)
for the CEO return and the comment one-liner.
2b. Persona preflight. Run scripts/check_required_agents.py
(see "panel-mode") with every slug in personas_spawned[] plus
apm-ceo, using the consumer's .github/agents as
--agents-dir. If it exits nonzero, stop and report every
missing_roles entry. Do not spawn panelists or post a partial
review.
Fan out panelist tasks. Spawn the resolved roster in PARALLEL
via the task tool, one task per active persona. Do not spawn
omitted personas. Pin model class per the Models section.
Each task prompt MUST:
- Reference its persona file by relative path so the subagent loads
its own scope, lens, and anti-patterns.
- Include the shared brief packet (not a second full conversation
fetch). For
full, also list owned files the persona may read.
- Cite
assets/panelist-return-schema.json and require the subagent
to emit JSON matching that schema as its FINAL message.
- Cap findings at 3. Nits only in
full.
- Ask
python-architect for extras.diagrams in full only.
- State the calibrated severity contract: "Use
severity: blocking
ONLY for correctness regressions, security/auth bypasses, or
architectural faults that compound, with explicit rationale.
Default substantive feedback to recommended. Use nit for
one-line polish. The panel is advisory; nothing you return blocks
merge -- pick the severity that honestly matches your signal
strength."
- Restate the output contract: NO
gh write commands, NO posting
comments, NO label changes, NO touching PR state. JSON return only.
S4 schema gate. When each panelist task returns, parse the JSON
and validate against assets/panelist-return-schema.json. On
validation failure:
- Re-spawn that ONE panelist with an explicit error message pointing
at the violated rule.
- Maximum two re-spawn attempts per panelist. If still malformed,
synthesize a placeholder
{persona: "<slug>", active: true, summary: "Schema failure -- see extras.", findings: [], extras: {schema_failure: "<reason>"}}
and surface the failure in the CEO arbitration prompt.
Spawn the CEO synthesizer task. Pass the spawned panelist JSON
returns (omitted personas are inactive; do not invent stub JSON)
to a task invocation that loads
.github/agents/apm-ceo.agent.md. Run it as a BLOCKING task and WAIT
for its JSON return -- do NOT spawn it detached (background mode that
returns an agent_id) and do NOT end your turn while it runs. Its
return is required to render the comment; ending the turn here is the
exact cause of the "No Safe Outputs Generated" failure. The prompt
MUST:
- Provide spawned panelist returns as structured input.
- Ask for: headline, arbitration prose, principle alignment (only
applicable principles), curated recommended_followups (prioritized
by signal, NOT a re-listing of every finding), ship_recommendation
(stance + prose), optional
panel_mode and personas_spawned.
- Cite
assets/ceo-return-schema.json and require JSON return.
- Restate the contract: the panel is advisory. The CEO does NOT pick
a verdict label. The
ship_recommendation.stance is prose for the
human reviewer, not a gate. NO gh write commands.
Validate the CEO return against assets/ceo-return-schema.json. On
failure, re-spawn once with the violation cited.
Resolve the notification audience and apply invocation-mode
reviewer policy. The advisory comment must surface in the inboxes
of the people who will act on it. Run:
gh pr view <PR_NUMBER> --json author,reviewRequests,headRefOid
Build notify_audience as the deduplicated list:
- the PR author's
@login (always included);
- every requested reviewer's
@login (these are the
CODEOWNERS-resolved reviewers GitHub auto-requested for the
touched paths, plus any explicitly-requested human reviewers);
- every requested team's
@org/team-slug (CODEOWNERS team
entries).
Filter out:
- bot logins (login ending in
[bot] or matching
dependabot|github-actions|copilot-pull-request-reviewer);
- the orchestrator's own identity (avoid self-ping).
Cap the final list at 6 handles to avoid notification noise (PR
author + up to 5 reviewers/teams). If the cap trims, prefer team
handles over individual logins. Pass the resulting list to the
template renderer as notify_audience.
Snapshot reviewRequests BEFORE any reviewer write. Those users
and teams are the CODEOWNERS-derived ownership set for this PR.
If ORIGIN is actor-session, INTENT is review, and COMPOSED is
not true, requesting @me as a supplemental reviewer is a hard
gate and the public signal of which user is running the review.
If @me is not the PR author and is not already a requested
reviewer, request @me (gh pr edit --add-reviewer @me) and
verify. If GitHub rejects the request, record the limitation,
leave reviewers unchanged, and continue. Never assign the PR.
Never remove an existing reviewer. If @me is the PR author,
record self-review-red-flag and skip the request.
If ORIGIN is unattended or unknown, or COMPOSED is true, do not
request reviewers and do not assign.
This step replaces the maintainer-notification signal that the
pre-advisory verdict labels carried. It is the only mechanism by
which a fresh panel pass announces itself.
Render or no-op the comment. Compute conversation_watermark
from the latest comment id, latest review id, and head SHA. If an
existing <!-- apm-review-advisory:v1 receipt already matches this
PR, head SHA, and watermark, do not post another advisory: sweep
labels if needed and emit noop. Unchanged context is not a fresh
review.
Otherwise load assets/recommendation-template.md, fill the
placeholders from the panelist + CEO JSON, and emit exactly ONE
comment via autopilot-comment. Prepend this receipt line
(ASCII, HTML comment) as receipt:
<!-- apm-review-advisory:v1 target=pr#<N> head=<sha> watermark=<watermark> -->
Filling rules:
- Set
panel_mode_line to
panel-mode=<mode>; personas=<comma slugs> from the spawned
roster. Omit if empty.
- The per-persona summary table renders ONLY active panelists, one
row per persona, with finding counts by severity and the persona's
summary field.
- The mermaid diagrams come from
python-architect.extras.diagrams
in full only. If absent, render nothing (do NOT invent
diagrams). lean and delta omit diagrams.
- The recommended follow-ups list renders the CEO's curated subset,
not every finding. Full per-persona findings collapse at the bottom.
- Follow-ups are fixes for THIS PR, not new issues. Review follow-ups
are fixed and folded into the PR where they were found (or a
successor PR in the same lane if that PR already merged); never
recommend filing a follow-up issue. Only design or scope decisions
explicitly made by a maintainer (a human) may be tracked as
issues.
- NEVER render the words "Verdict", "APPROVE", "REJECT", "blocked",
"merge gate", or any equivalent. The panel is advisory.
- Reconcile with prior panel receipts and later human replies.
Repeat neither resolved threads nor already-accepted follow-ups
as if they were new. Name the material delta since the last
advisory.
- Ownership consistency gate (fail closed):
notify_audience,
follow-up prose, and suggested next actions must preserve every
CODEOWNERS-derived user and team from the pre-write
reviewRequests snapshot. If the rendered comment would drop,
replace, or contradict those owners, re-render once. If it still
contradicts, emit noop with a diagnostic. Never post a
conflicting public comment.
Sweep labels via safe-outputs.remove-labels. The list MUST be
[panel-review, panel-approved, panel-rejected] -- always all three,
regardless of which are currently on the PR. panel-review is the
re-run idempotency reset; the other two are LEGACY VERDICT LABELS
from the pre-advisory regime that have no meaning under the advisory
contract and would mislead readers if left on a freshly-reviewed PR.
safe-outputs.remove-labels is idempotent on missing labels, so
sweeping all three on every run is safe and self-healing. NO
verdict labels are applied.
Guarantee a non-empty exit. Your final action this turn MUST be a
safe output. In the normal path that is the single add-comment from
step 7 (the remove-labels sweep alone does NOT count -- it is not
the run's required output). An intentional noop from step 7 is a
valid exit when context is unchanged, a required history page could
not be read, or the CODEOWNERS consistency gate failed. Before
ending the turn, confirm step 7 actually issued add-comment or
noop and it did not error. If, after
every subagent has returned, you genuinely cannot render a comment
(e.g. a fatal upstream error), call noop so the run records an
intentional no-action rather than an empty agent_output. Ending the
turn with zero safe outputs is a FAILURE, not a success -- see the
"Non-empty turn exit" architecture invariant.
Output contract (non-negotiable)
- At most ONE comment per panel run, rendered from
assets/recommendation-template.md, unless step 7 elects noop
because the conversation watermark and head SHA are unchanged, a
required context page could not be read, or the CODEOWNERS
consistency gate failed. The safe-outputs.add-comment.max: 2 is a
fail-soft ceiling; the discipline lives here.
- Exactly ONE
remove-labels call sweeping
[panel-review, panel-approved, panel-rejected].
- NO
add-labels call. The advisory regime has no verdict to encode.
- Subagents (panelists + CEO) NEVER write to PR state, NEVER call
gh pr comment, NEVER call gh pr edit --add-label. They return JSON.
The orchestrator is the sole writer.
- Never invent new top-level template sections or drop existing ones.
Gotchas
- Roster invariant. The frontmatter description, the roster table,
assets/panel-mode.md, the recommendation template, and the JSON
schema MUST agree on the persona set. If you change one, change all
in the same edit. Omitted persona = inactive. Do not spawn
active: false stubs except model-unavailable.
- Calibrated severity discipline. The advisory regime relies on
panelists honestly distinguishing
blocking from recommended. If a
panelist marks everything blocking, the comment becomes noisy and
the maintainer learns to ignore the field. The panelist prompts state
the contract explicitly; the CEO arbitration prose is the safety
valve when a panelist over-flags.
- Mermaid diagrams are
full only. In full, python-architect
supplies extras.diagrams.class_diagram,
extras.diagrams.component, and the OPTIONAL
extras.diagrams.sequence. lean and delta omit diagrams.
The template renders nothing when they are missing -- it does NOT
invent diagrams.
- Mermaid
classDiagram :::cssClass shorthand gotcha. GitHub's
mermaid renderer rejects :::cssClass appended to relationship
lines (e.g. A *-- B:::touched); use standalone
class Name:::cssClass declarations instead. Authority:
python-architect.agent.md:146-154.
- Doc-writer detects DRIFT, not just edits. When the PR changes
user-facing code that SHOULD have updated docs but did not, doc-writer
surfaces that as a finding. The conditional rule above is necessary
but not sufficient -- doc-writer reasons about doc consistency given
the diff, not just whether doc files were touched.
- False-negative auth gotcha. Auth regressions can be introduced
from non-auth files that change the inputs to auth -- host
classification, dependency parsing, clone URL construction, HTTP
authorization headers, or call sites that bypass
AuthResolver. If
a diff changes how a remote host, org, token source, or fallback path
is selected and you are not certain it is auth-neutral, activate
auth-expert as active: true.
- Test-coverage probe is mandatory. The test-coverage-expert MUST
verify "no test exists for X" via
view/grep on the tests/ tree
before emitting a finding. A false-positive coverage finding (test
exists but persona claimed it does not) destroys maintainer trust in
the field. The persona scope file enforces this; the orchestrator
passes the diff and trusts the persona to probe.
- Subagent write enforcement is contract-based, not sandbox-based.
Tool permissions are workflow-scoped, not subagent-scoped, so every
spawned task technically inherits the same
gh toolset. The
"subagents must not write" rule is enforced by the prompt contract in
each .agent.md plus the safe-outputs.add-comment.max: 2
fail-soft. If a subagent ever tries to post a comment, the cap
catches it.
- Empty-safe-output failure (background spawn-and-forget). The single
most common way this panel "succeeds" yet posts nothing is spawning the
CEO synthesizer (or a panelist) as a background/detached task and then
ending the turn while it is still running. The harness exits with
agent_output = {"items":[]}, gh-aw skips safe-output detection, the
add-comment job never runs, and the workflow opens a "No Safe Outputs
Generated" issue. Every task spawn MUST be awaited to completion, and
the turn MUST end with a safe output -- the comment, or an explicit
noop. See the "Synchronous fan-out" and "Non-empty turn exit"
architecture invariants and step 9.
- No verdict-label reset workflow. The previous regime had a
companion workflow
pr-panel-label-reset.yml that stripped verdict
labels on every push. The advisory regime has no verdict labels to
strip; that workflow is removed.
1---2name: autopilot-pr-review-worker3description: Use this skill to run a multi-persona expert advisory review on a labelled pull request in microsoft/apm. panel-mode (full | lean | delta) selects a surface-gat4---5---6name: autopilot-pr-review-worker7activation_card: on8description: >-9 Use this skill to run a multi-persona expert advisory review on a labelled10 pull request in microsoft/apm. panel-mode (full | lean | delta) selects a11 surface-gated roster plus a CEO synthesizer; omitted or unknown mode is12 lean. Do not spawn inactive stubs. The orchestrator is the sole writer13 to the PR: ONE recommendation comment, no verdict labels, no merge14 gating. The panel is advisory -- it surfaces findings, prioritizes15 follow-ups, and renders a ship-recommendation that the maintainer and16 author weigh.17---1819# autopilot-pr-review-worker - Fan-Out Advisory Review2021The panel is FAN-OUT + SYNTHESIZER. Each persona runs in its own agent22thread (via the `task` tool) and returns JSON matching23`assets/panelist-return-schema.json`. The orchestrator schema-validates24each return, hands all returns to the apm-ceo synthesizer (also a task25thread, returns JSON matching `assets/ceo-return-schema.json`), then26renders ONE recommendation comment from `assets/recommendation-template.md`.2728This skill is ADVISORY by design. It does not compute a binary verdict, it29does not apply verdict labels, and it does not gate merge. The panel30surfaces findings; the maintainer and the PR author decide ship.3132## Activation card3334`activation_card: on`. Before any PR read or GitHub write, emit35this Enter card with every field filled. Missing field -> stop.3637```text38skill: autopilot-pr-review-worker39skill_path: <resolved directory of this SKILL.md>40mode: run41subject: microsoft/apm#<pr-number>42path: review43intent: advise one already-selected PR44origin: unattended | actor-session45write: on | off46debug: off | on47repo: microsoft/apm48pr: <positive integer>49invocation: agentic-workflow | actor-session50invocation_mode: session-review | direct-user-review | composed-implementation-review51panel-mode: full | lean | delta52```5354Rules:5556- `write` defaults to `on` when the caller omitted it.57- `write: off` returns the filled template only. Do not comment,58 add labels, remove labels, or request reviewers.59- `write: on` posts the one advisory comment via60 `autopilot-comment` (`source_skill:61 autopilot-pr-review-worker`) and may clear `panel-review`.62 Never assign. Actor-session may request `@me` as a63 supplemental reviewer. Do not call `gh pr comment` or64 `safe-outputs.add-comment` yourself.65- `panel-mode` defaults to `lean` when omitted or unknown.66 Omitted `panel-mode` is not a missing-field stop. Caller67 (merge-worker, scheduler, or human) SHOULD set it. Unknown68 fails cheap (`lean`), not heavy (`full`).69- `debug` defaults to `off` when omitted or unknown. Omitted70 `debug` is not a missing-field stop. Pass it through to71 `autopilot-comment`. `debug: on` prefixes72 `[i] Skill debug is on.` The filled recommendation template73 is `public_body` (and `debug_body` when debug is on).74- `origin` fail-closed unknown -> `unattended`.75- Unattended never assigns and never requests reviewers.76- One PR. Do not nest a scheduler path.7778After the panel, emit this Exit receipt:7980```text81skill: autopilot-pr-review-worker82subject: microsoft/apm#<pr-number>83path: review84write: on | off85posted: yes | no86reviewer_requested: yes | no | skipped87approved: n/a88panel-mode: full | lean | delta89personas_spawned: <comma-separated slugs>90```9192## Architecture invariants9394- **Advisory regime, not gate regime.** There is no `APPROVE` / `REJECT`,95 no `panel-approved` / `panel-rejected` label, no deterministic verdict96 computation. The CEO returns a `ship_recommendation.stance` (`ship_now`97 / `ship_with_followups` / `needs_discussion` / `needs_rework`); this is98 prose for the human reviewer, never auto-applied as a label or status99 check. This is the architectural fix for the previous regime's100 over-strictness: removing the binary gate removes the incentive for101 panelists to inflate `required[]` defensively.102- **Three severity buckets, none of them gate.** Findings carry103 `severity: blocking | recommended | nit`. `blocking` is the highest104 signal a panelist can send and renders prominently in the comment; it105 still does not block merge. `recommended` is the default for substantive106 feedback. `nit` is one-line polish. The orchestrator never reads107 severity to gate anything.108- **Single-writer interlock.** Only the orchestrator writes to the PR:109 exactly one `add-comment` and one `remove-labels` call. The110 `remove-labels` call always sweeps `panel-review` (trigger111 idempotency) AND defensively removes `panel-approved` /112 `panel-rejected` if present (legacy verdict labels from the113 pre-advisory regime; they have no meaning here and would mislead114 readers if left on a PR after a fresh advisory pass). NO `add-labels`115 call -- there are no verdict labels to apply. Panelist subagents and116 the CEO subagent return JSON only and MUST NOT call any `gh` write117 command, post comments, apply labels, or touch the PR state.118- **Single-emission discipline.** Exactly one comment per panel run,119 rendered from `assets/recommendation-template.md` after all subagents120 return.121- **Non-empty turn exit (the run's hard contract).** gh-aw decides122 success by inspecting `agent_output` AFTER your turn ends: a turn that123 ends with zero safe outputs (`agent_output = {"items":[]}`) is detected124 as a failure, the safe-output detection job is skipped, the125 `add-comment` job never runs, and the workflow opens a "No Safe Outputs126 Generated" issue. Therefore your turn MUST end with at least one safe127 output -- the rendered comment on success (step 7), or an explicit128 `noop` if the run genuinely cannot produce one. NEVER end the turn129 empty.130- **Synchronous fan-out -- never spawn-and-forget.** Every `task` spawn131 (each panelist AND the CEO synthesizer) is BLOCKING: spawn it, WAIT for132 its JSON return, then continue. Use the `task` tool's synchronous mode;133 do NOT use its background/detached mode -- the variant that returns an134 `agent_id` immediately and runs the subagent in the background -- for135 any panelist or the CEO. Their returns are LOAD-BEARING: the comment136 cannot be rendered without them. Spawning the CEO (or a panelist)137 detached and then ending the turn while it is still running is the138 documented cause of the empty-output failure above.139- **Invocation contract is explicit.** Resolve ORIGIN and INTENT140 before any GitHub write. They decide reviewer requests only. They141 never authorize assignee writes, never remove existing reviewers,142 and never override CODEOWNERS.143- **CODEOWNERS is paramount.** GitHub's current `reviewRequests` and144 submitted reviews from CODEOWNERS-resolved users/teams are145 authoritative runtime ownership. Advice may request supplemental146 expertise. It must not replace, reorder, drop, or contradict those147 owners. A comment that contradicts CODEOWNERS is a failed emission.148 The CODEOWNERS last-comment gate decides whether the panel proceeds149 at all.150151## Invocation contract152153Resolve ORIGIN and INTENT before gathering context. Future154automations declare these axes; do not add a new harness by editing155a name list.156157ORIGIN (who is running):158159- `unattended` -- GitHub Agentic Workflow / gh-aw / GitHub Actions /160 future scheduled automations with no session actor. Alias:161 `agentic-workflow`.162- `actor-session` -- Direct user harness, Copilot App, Cloud Agent,163 Remote Agent, or any future session-backed runner. `@me` is that164 runner's GitHub identity (human or agent).165166INTENT (what this run is doing):167168- `review` -- standalone advisory review (this skill).169- `implement` -- parent implementation owns assignment.170171COMPOSED is true when any implementation parent invokes this skill.172Do not infer COMPOSED from parent skill names.173174| ORIGIN | INTENT | COMPOSED | Assignee | Reviewer request |175|--------|--------|----------|----------|------------------|176| `unattended` | any | any | Never | Never |177| `actor-session` | `review` | false | Never | Request authenticated `@me` as a supplemental reviewer only |178| `actor-session` | `review` | true | Never (parent owns assignment) | Never |179| unknown | any | any | Never | Never |180181Caller tokens still accepted as `INVOCATION_MODE`:182183- `agentic-workflow` -> ORIGIN=`unattended`184- `session-review` (alias `direct-user-review`) -> ORIGIN=`actor-session`, INTENT=`review`185- `composed-implementation-review` -> ORIGIN=`actor-session`, INTENT=`review`, COMPOSED=true186187Resolution order:1881891. Honor caller-supplied ORIGIN, INTENT, COMPOSED, or INVOCATION_MODE.1902. If `GH_AW_*` or `GITHUB_ACTIONS` is set, ORIGIN=`unattended`.1913. Else if `gh api user --jq .login` succeeds, ORIGIN=`actor-session`.1924. Else ORIGIN=`unattended` (fail closed: no ownership writes).193194Reviewer requests are additive. Never remove, replace, or reorder195existing users or teams. Never convert a failed reviewer request196into an assignee write.197198If `@me` is the PR author, GitHub cannot request a self-review.199Record `self-review-red-flag` in working notes, leave reviewers200unchanged, and continue the advisory. Do not stop.201202This skill never assigns issues or PRs in any mode.203204This skill owns the actor-session `@me` reviewer request205(`gh pr edit --add-reviewer @me`) and the one recommendation206comment. The PR review scheduler never comments, labels, assigns,207or requests reviewers.208209## Agent roster210211Load `assets/panel-mode.md` before fan-out. Spawn only personas that212are active for this `panel-mode` and surface. Do not spawn213`active: false` stubs.214215| Agent | Role | When spawned |216|-------|------|----------------|217| `python-architect` | Architectural Reviewer + mermaid in `full` | Core, unless docs/changelog-only. Optional in `lean` on tiny diffs. |218| `cli-logging-expert` | Output UX Reviewer | Surface-gated |219| `devx-ux-expert` | Package-Manager UX | Surface-gated |220| `supply-chain-security-expert` | Threat-Model Reviewer | Surface-gated |221| `oss-growth-hacker` | Adoption Strategist | Surface-gated |222| `auth-expert` | Auth / Token Reviewer | Surface-gated |223| `doc-writer` | Documentation Reviewer | Surface-gated |224| `test-coverage-expert` | Test-Presence Reviewer | Core when `src/` is touched or the diff has a test cut (see `assets/panel-mode.md`); skip otherwise |225| `performance-expert` | Package-Manager Performance Reviewer | Surface-gated |226| `apm-ceo` | Strategic Arbiter / Synthesizer | Always |227228These agent files are consumer-provided companion assets, not part of this229package. For a Copilot consumer, APM deploys them under230`.github/agents/<agent-slug>.agent.md`.231232## Topology233234```235 autopilot-pr-review-worker SKILL (orchestrator thread)236 |237 gather full PR context once -> shared brief packet238 |239 FAN-OUT via task (ONLY active personas for this panel-mode)240 |241 each returns JSON per panelist-return-schema.json242 |243 v <-- S4 schema-validate244 task: apm-ceo synthesizer (always)245 |246 v247 orchestrator (sole writer): one comment or noop248```249250## panel-mode251252Caller (merge-worker, scheduler, or human) SHOULD set253`panel-mode: full | lean | delta`. Omitted or unknown -> `lean`.254255After resolving the active roster from the mode and surface, but before256spawning any panelist, run the bundled257`scripts/check_required_agents.py` with the active role slugs and the258consumer's `.github/agents` directory as `--agents-dir`. The script emits259JSON and returns nonzero when any active role is missing. Stop and report260all missing roles; do not skip a required role or produce a partial review.261Run it from the consumer repository root, for example:262263```bash264python3 .agents/skills/autopilot-pr-review-worker/scripts/check_required_agents.py \265 --agents-dir .github/agents python-architect test-coverage-expert apm-ceo266```267268Replace the example roles with the exact active roster for the selected mode269and surface.270271| Mode | Roster | Context | Comment |272|------|--------|---------|---------|273| full | Surface-gated specialists + CEO | Shared brief + owned files | yes |274| lean | Highest-signal surface owner, test-coverage if `src/` touched or a test cut, CEO. Architect optional on tiny diffs. | Shared brief only | yes |275| delta | CEO + previously-active personas whose owned files changed since last panel head; test-coverage only if tests or `src/` changed in range | Brief + last comment + diff | yes if head or watermark changed; else noop |276277Even `full` is surface-gated. Never spawn inactive stubs.278279Lean cap: at most those three (plus architect when not tiny).280Delta: no new persona that was inactive on the prior panel unless a281new fast-path file appeared or the orchestrator writes an282`adhoc_reason`.283284## Shared brief285286Orchestrator gathers **once**. Children MUST NOT re-fetch the PR287conversation or walk the repo "to be sure." Packet target < 8 KB.288Shape: `assets/shared-brief.example.json`.289290Each panelist prompt MUST include:291292- JSON only. Do not run gh. Do not read files outside this packet293 unless a path is listed as owned by you.294- Finding cap: 3. Nits allowed only in `full`.295- Architect mermaid: `full` only. `lean` / `delta` omit diagrams.296297## Models298299When spawning via `task`, pin class so a missing default cannot300retry the whole roster:301302- high-capability: `apm-ceo`, `auth-expert`,303 `supply-chain-security-expert`, `python-architect`304- cheap/fast: `test-coverage-expert`, `doc-writer`,305 `cli-logging-expert`, `devx-ux-expert`, `oss-growth-hacker`,306 `performance-expert`307308If a pinned model is unavailable: fall back **once** per persona309to the other class, then stub that persona with `active: false` and310`inactive_reason: model unavailable`. Do not relaunch the roster.311This is the only allowed `active: false` spawn.312313## Conditional panelists (surface-gated)314315Spawn the persona when the fast-path matches, or when the316orchestrator decides the PR still needs that lens after reading317the brief (ad-hoc add with a one-line `adhoc_reason`). Fast-path318is the default include set, not the ceiling. Do not spawn a stub319when the condition misses and you have no reason. Do not add320personas "to be sure."321322### Auth Expert323324Activate when the PR changes any of:325- `src/apm_cli/core/auth.py`326- `src/apm_cli/core/token_manager.py`327- `src/apm_cli/core/azure_cli.py`328- `src/apm_cli/deps/github_downloader.py`329- `src/apm_cli/marketplace/client.py`330- `src/apm_cli/utils/github_host.py`331- `src/apm_cli/install/validation.py`332- `src/apm_cli/install/pipeline.py`333- `src/apm_cli/deps/registry_proxy.py`334335Fallback self-check (when no fast-path file matched): "Does this PR336change authentication behavior, token management, credential resolution,337host classification used by `AuthResolver`, git or HTTP authorization338headers, or remote-host fallback semantics? If unsure, answer NO."339340### Doc Writer341342Activate when the PR changes any of:343- `README.md`344- `CHANGELOG.md`345- `MANIFESTO.md`346- `docs/src/content/docs/**`347- `.apm/skills/**/*.md`348- `.apm/agents/**/*.md`349- `.github/skills/**/*.md`350- `.github/agents/**/*.md`351- `.github/instructions/**/*.md`352- `.github/workflows/*.md` (gh-aw natural-language workflows)353- `packages/apm-guide/**`354355Fallback self-check (when no fast-path file matched): "Does this PR356change user-facing documentation, agent or skill prose, instruction357files, CHANGELOG entries, README claims, or any natural-language358artifact a reader will rely on? If unsure, answer NO."359360When the doc-writer is active and the PR includes documentation changes,361the persona reviews them for: (a) consistency with the existing voice362and structure, (b) accuracy against the code being changed, (c)363completeness for the typical reader (no orphan claims, no missing364prerequisites), (d) discoverability (cross-links, sidebar order if365Starlight content). When the doc-writer is active because of code366changes that SHOULD have updated docs but did not, the persona surfaces367that gap as a finding.368369### Performance Expert370371Activate when the PR changes any of:372- `src/apm_cli/cache/**`373- `src/apm_cli/deps/**`374- `src/apm_cli/install/phases/**`375- `src/apm_cli/install/pipeline.py`376- `src/apm_cli/install/resolve.py`377- `src/apm_cli/utils/**`378- `src/apm_cli/marketplace/**`379- `src/apm_cli/compilation/**`380- `scripts/perf/**`381- `src/apm_cli/core/command_logger.py` (when the diff adds perf-instrumentation logs)382383Also activate when:384- The PR description claims a performance win (speedup ratio, latency385 reduction, bytes-on-disk reduction, throughput improvement) or386 attaches a perf-harness measurement table.387- The diff introduces loops over collections (`for x in collection`)388 where the collection may grow with dependency count or file count.389- The diff adds `os.scandir`, `os.walk`, `os.listdir`, or390 `subprocess.run` calls on a path that executes per-package or391 per-dependency.392- The diff adds `x in list_variable` inside a loop body.393394Fallback self-check (when no fast-path file matched): "Does this PR395change the hot path for dependency download, materialization, cache396layout, transport (git protocol, partial clone, sparse checkout),397parallelism, or any user-visible install/update wall-time? Does it398introduce an algorithmic complexity regression (O(n^2) loops, repeated399I/O, missing indexes, unconditional full scans, blocking synchronous400calls, heavy top-level imports)? If unsure, answer NO."401402When active, the performance-expert reviews against BOTH:4031. The package-manager performance playbook: transport minimization404 (depth, filter, sparse scope), cache layering and dedup keys,405 parallelism and lock contention, working-tree materialization cost,406 perf-harness methodology (cache wipe, warm/cold separation,407 statistical noise), and pervasive application of the chosen408 technique across install / update / run surfaces.4092. The algorithmic performance lens (Big O analysis): complexity class410 of every loop/lookup in the diff, index vs linear scan patterns,411 unconditional expensive operations, import startup costs, redundant412 computation, and parallelism opportunities. See the agent's413 `references/algorithmic-patterns.md` for the full pattern catalogue.414415### Test Coverage Expert416417**Active by default on every PR that touches `src/**/*.py`, and on418every PR with a test cut** as defined in `assets/panel-mode.md`419(a `tests/` file deleted, moved, or renamed, or a test function,420assertion, or policy gate removed inside a kept file). The cut trigger421runs the persona's cut/merge review on test-only clean-up PRs. Pure422test additions do not trigger it. Skip (do not spawn) when neither423holds, e.g. a documentation-only PR.424425The test-coverage-expert is paired with the devx-ux-expert lens and426defends the user-promise contracts the DevX persona enumerates (CLI427surface, error wording, install idempotency, lockfile determinism, auth428resolution). It MUST verify "no test exists" claims with `view`/`grep`429on the test tree before emitting a finding -- false-positive coverage430findings destroy trust in the field. It does NOT compute coverage431percentages, does NOT flag tests for pure refactors, and does NOT432duplicate python-architect on test-code design.433434## Routing matrix (CEO synthesis emphasis only)435436These routes describe WHICH specialist's findings the CEO weights more437heavily for a given PR type. They do NOT force extra personas to spawn.438439- **Architecture-heavy PR** -> CEO weights Python Architect on440 abstraction calls; CLI Logging on consistency.441- **CLI UX PR** -> CEO weights DevX UX on command surface; CLI Logging442 on output paths; Growth Hacker on first-run conversion.443- **Security PR** -> CEO biases toward Supply Chain Security on default444 behavior; DevX UX flags ergonomics regression from any mitigation.445- **Auth PR** (auth-expert active) -> CEO weights Auth Expert on446 AuthResolver / token precedence; Supply Chain on token-scoping.447- **Docs / release / comms PR** (doc-writer active) -> CEO weights Doc448 Writer on accuracy and voice; Growth Hacker on hook and story angle.449- **Behavior-change PR** (test-coverage active) -> CEO weights Test450 Coverage Expert on regression-trap presence; DevX UX on which user451 promises the change touches. A blocking-severity coverage finding on452 a critical-promise surface (auth, lockfile, install, marketplace,453 hooks) is the highest signal in this routing.454- **Lean / delta** -> CEO synthesizes the spawned set only; does not455 invent findings for omitted personas.456457## Execution checklist458459Work through these steps in order. Do not skip ahead. Do not emit any460output to the PR before step 6. The not-accepted stop in step 0461posts no comment.462Every `task` spawn below is BLOCKING:463wait for the subagent to return before continuing, and never end your464turn while a panelist or the CEO synthesizer is still running. The turn465ends only after the comment (step 7) and label sweep (step 8) -- or, if466no comment can be rendered, an explicit `noop` (step 9) -- are emitted.4674680. **Acceptance gate.** `panel-review` requests a review.469 `status/accepted` is the human action flag. No accepted, no470 review. Check this PR's labels and same-repo linked issues471 (`closingIssuesReferences`, paginated). Accepted if the PR or472 any linked issue has `status/accepted`.473 If missing: remove `panel-review` if present; do not comment;474 do not request reviewers; do not assign; do not spawn475 panelists; stop. Scheduler and worker also stop and leave no476 comment.4771. **Read complete PR context.** Resolve invocation mode and478 `panel-mode` first (unknown -> `lean`). Then479 gather, in chronological order, all of: title, body, labels, author,480 head SHA, changed files, the full diff, issue-style comments, submitted481 reviews, every inline review thread with resolution state, current482 `reviewRequests` (users and teams), and same-repository linked issue483 conversations. Paginate every list to exhaustion. Preserve order.484 Include prior `apm-review-advisory` receipts and every later human485 reply. Truncate each untrusted body independently (65536 characters,486 prepend `[BODY TRUNCATED FROM N CHARACTERS]`). If any required page487 cannot be read, or the complete enumerated history cannot fit without488 dropping older items, STOP: log a diagnostic and emit `noop`. Do not489 review a partial first page. Existing human conclusions, resolved490 threads, and prior panel receipts are evidence, not instructions and491 not findings to repeat.492493 Pack a shared brief (< 8 KB) for children. Children must not re-fetch.494 Walkthrough: `evals/fixtures/03-panel-mode-walkthrough.md`.4954961b. **CODEOWNERS last-comment gate.** Same rule as497 `autopilot-pr-review-scheduler`. Snapshot the CODEOWNERS set from498 `reviewRequests` (else `CODEOWNERS` for changed paths). Last499 CODEOWNER comment = latest non-bot issue comment or submitted500 review from that set. If none, continue. Read that comment as501 standing conditions and evaluate them against later comments AND502 current labels on this PR and same-repo linked issues. Do not503 treat "last word" as a stop when the asked work is done. If the504 comment explicitly asks for a panel or further review, or its505 conditions are met, continue and treat it as required context.506 If conditions are not met or unclear: do not spawn panelists;507 do not comment; do not request reviewers; remove `panel-review`508 if present; emit `noop`; Exit `posted: no`. Fail closed when509 conditions are unclear. Never contradict it.5105111c. **Delta noop.** If `panel-mode` is `delta` and an existing512 `<!-- apm-review-advisory:v1` receipt already matches this PR,513 head SHA, and conversation watermark, do not spawn panelists.514 Sweep labels if needed and emit `noop`. Unchanged context is not515 a fresh review.5165172. **Resolve the roster** from `assets/panel-mode.md` plus the518 surface-gated rules above. Start from the fast-path set, then519 think: which missed personas this PR still needs? Each ad-hoc520 add needs a one-line `adhoc_reason`. Spawn only active521 personas. Record `personas_spawned[]` (and ad-hoc reasons)522 for the CEO return and the comment one-liner.5235242b. **Persona preflight.** Run `scripts/check_required_agents.py`525 (see "panel-mode") with every slug in `personas_spawned[]` plus526 `apm-ceo`, using the consumer's `.github/agents` as527 `--agents-dir`. If it exits nonzero, stop and report every528 `missing_roles` entry. Do not spawn panelists or post a partial529 review.5305313. **Fan out panelist tasks.** Spawn the resolved roster in PARALLEL532 via the `task` tool, one task per active persona. Do not spawn533 omitted personas. Pin model class per the Models section.534535 Each task prompt MUST:536 - Reference its persona file by relative path so the subagent loads537 its own scope, lens, and anti-patterns.538 - Include the shared brief packet (not a second full conversation539 fetch). For `full`, also list owned files the persona may read.540 - Cite `assets/panelist-return-schema.json` and require the subagent541 to emit JSON matching that schema as its FINAL message.542 - Cap findings at 3. Nits only in `full`.543 - Ask `python-architect` for `extras.diagrams` in `full` only.544 - State the calibrated severity contract: "Use `severity: blocking`545 ONLY for correctness regressions, security/auth bypasses, or546 architectural faults that compound, with explicit rationale.547 Default substantive feedback to `recommended`. Use `nit` for548 one-line polish. The panel is advisory; nothing you return blocks549 merge -- pick the severity that honestly matches your signal550 strength."551 - Restate the output contract: NO `gh` write commands, NO posting552 comments, NO label changes, NO touching PR state. JSON return only.5535544. **S4 schema gate.** When each panelist task returns, parse the JSON555 and validate against `assets/panelist-return-schema.json`. On556 validation failure:557 - Re-spawn that ONE panelist with an explicit error message pointing558 at the violated rule.559 - Maximum two re-spawn attempts per panelist. If still malformed,560 synthesize a placeholder561 `{persona: "<slug>", active: true, summary: "Schema failure -- see562 extras.", findings: [], extras: {schema_failure: "<reason>"}}`563 and surface the failure in the CEO arbitration prompt.5645655. **Spawn the CEO synthesizer task.** Pass the spawned panelist JSON566 returns (omitted personas are inactive; do not invent stub JSON)567 to a `task` invocation that loads568 `.github/agents/apm-ceo.agent.md`. Run it as a BLOCKING task and WAIT569 for its JSON return -- do NOT spawn it detached (background mode that570 returns an `agent_id`) and do NOT end your turn while it runs. Its571 return is required to render the comment; ending the turn here is the572 exact cause of the "No Safe Outputs Generated" failure. The prompt573 MUST:574 - Provide spawned panelist returns as structured input.575 - Ask for: headline, arbitration prose, principle alignment (only576 applicable principles), curated recommended_followups (prioritized577 by signal, NOT a re-listing of every finding), ship_recommendation578 (stance + prose), optional `panel_mode` and `personas_spawned`.579 - Cite `assets/ceo-return-schema.json` and require JSON return.580 - Restate the contract: the panel is advisory. The CEO does NOT pick581 a verdict label. The `ship_recommendation.stance` is prose for the582 human reviewer, not a gate. NO `gh` write commands.583584 Validate the CEO return against `assets/ceo-return-schema.json`. On585 failure, re-spawn once with the violation cited.5865876. **Resolve the notification audience and apply invocation-mode588 reviewer policy.** The advisory comment must surface in the inboxes589 of the people who will act on it. Run:590591 ```592 gh pr view <PR_NUMBER> --json author,reviewRequests,headRefOid593 ```594595 Build `notify_audience` as the deduplicated list:596 - the PR author's `@login` (always included);597 - every requested reviewer's `@login` (these are the598 CODEOWNERS-resolved reviewers GitHub auto-requested for the599 touched paths, plus any explicitly-requested human reviewers);600 - every requested team's `@org/team-slug` (CODEOWNERS team601 entries).602603 Filter out:604 - bot logins (login ending in `[bot]` or matching605 `dependabot|github-actions|copilot-pull-request-reviewer`);606 - the orchestrator's own identity (avoid self-ping).607608 Cap the final list at 6 handles to avoid notification noise (PR609 author + up to 5 reviewers/teams). If the cap trims, prefer team610 handles over individual logins. Pass the resulting list to the611 template renderer as `notify_audience`.612613 Snapshot `reviewRequests` BEFORE any reviewer write. Those users614 and teams are the CODEOWNERS-derived ownership set for this PR.615616 If ORIGIN is `actor-session`, INTENT is `review`, and COMPOSED is617 not true, requesting `@me` as a supplemental reviewer is a hard618 gate and the public signal of which user is running the review.619 If `@me` is not the PR author and is not already a requested620 reviewer, request `@me` (`gh pr edit --add-reviewer @me`) and621 verify. If GitHub rejects the request, record the limitation,622 leave reviewers unchanged, and continue. Never assign the PR.623 Never remove an existing reviewer. If `@me` is the PR author,624 record `self-review-red-flag` and skip the request.625626 If ORIGIN is `unattended` or unknown, or COMPOSED is true, do not627 request reviewers and do not assign.628629 This step replaces the maintainer-notification signal that the630 pre-advisory verdict labels carried. It is the only mechanism by631 which a fresh panel pass announces itself.6326337. **Render or no-op the comment.** Compute `conversation_watermark`634 from the latest comment id, latest review id, and head SHA. If an635 existing `<!-- apm-review-advisory:v1` receipt already matches this636 PR, head SHA, and watermark, do not post another advisory: sweep637 labels if needed and emit `noop`. Unchanged context is not a fresh638 review.639640 Otherwise load `assets/recommendation-template.md`, fill the641 placeholders from the panelist + CEO JSON, and emit exactly ONE642 comment via `autopilot-comment`. Prepend this receipt line643 (ASCII, HTML comment) as `receipt`:644645 `<!-- apm-review-advisory:v1 target=pr#<N> head=<sha> watermark=<watermark> -->`646647 Filling rules:648 - Set `panel_mode_line` to649 `panel-mode=<mode>; personas=<comma slugs>` from the spawned650 roster. Omit if empty.651 - The per-persona summary table renders ONLY active panelists, one652 row per persona, with finding counts by severity and the persona's653 `summary` field.654 - The mermaid diagrams come from `python-architect.extras.diagrams`655 in `full` only. If absent, render nothing (do NOT invent656 diagrams). `lean` and `delta` omit diagrams.657 - The recommended follow-ups list renders the CEO's curated subset,658 not every finding. Full per-persona findings collapse at the bottom.659 - Follow-ups are fixes for THIS PR, not new issues. Review follow-ups660 are fixed and folded into the PR where they were found (or a661 successor PR in the same lane if that PR already merged); never662 recommend filing a follow-up issue. Only design or scope decisions663 explicitly made by a maintainer (a human) may be tracked as664 issues.665 - NEVER render the words "Verdict", "APPROVE", "REJECT", "blocked",666 "merge gate", or any equivalent. The panel is advisory.667 - Reconcile with prior panel receipts and later human replies.668 Repeat neither resolved threads nor already-accepted follow-ups669 as if they were new. Name the material delta since the last670 advisory.671 - Ownership consistency gate (fail closed): `notify_audience`,672 follow-up prose, and suggested next actions must preserve every673 CODEOWNERS-derived user and team from the pre-write674 `reviewRequests` snapshot. If the rendered comment would drop,675 replace, or contradict those owners, re-render once. If it still676 contradicts, emit `noop` with a diagnostic. Never post a677 conflicting public comment.6786798. **Sweep labels** via `safe-outputs.remove-labels`. The list MUST be680 `[panel-review, panel-approved, panel-rejected]` -- always all three,681 regardless of which are currently on the PR. `panel-review` is the682 re-run idempotency reset; the other two are LEGACY VERDICT LABELS683 from the pre-advisory regime that have no meaning under the advisory684 contract and would mislead readers if left on a freshly-reviewed PR.685 `safe-outputs.remove-labels` is idempotent on missing labels, so686 sweeping all three on every run is safe and self-healing. NO687 verdict labels are applied.6886899. **Guarantee a non-empty exit.** Your final action this turn MUST be a690 safe output. In the normal path that is the single `add-comment` from691 step 7 (the `remove-labels` sweep alone does NOT count -- it is not692 the run's required output). An intentional `noop` from step 7 is a693 valid exit when context is unchanged, a required history page could694 not be read, or the CODEOWNERS consistency gate failed. Before695 ending the turn, confirm step 7 actually issued `add-comment` or696 `noop` and it did not error. If, after697 every subagent has returned, you genuinely cannot render a comment698 (e.g. a fatal upstream error), call `noop` so the run records an699 intentional no-action rather than an empty `agent_output`. Ending the700 turn with zero safe outputs is a FAILURE, not a success -- see the701 "Non-empty turn exit" architecture invariant.702703## Output contract (non-negotiable)704705- At most ONE comment per panel run, rendered from706 `assets/recommendation-template.md`, unless step 7 elects `noop`707 because the conversation watermark and head SHA are unchanged, a708 required context page could not be read, or the CODEOWNERS709 consistency gate failed. The `safe-outputs.add-comment.max: 2` is a710 fail-soft ceiling; the discipline lives here.711- Exactly ONE `remove-labels` call sweeping712 `[panel-review, panel-approved, panel-rejected]`.713- NO `add-labels` call. The advisory regime has no verdict to encode.714- Subagents (panelists + CEO) NEVER write to PR state, NEVER call `gh715 pr comment`, NEVER call `gh pr edit --add-label`. They return JSON.716 The orchestrator is the sole writer.717- Never invent new top-level template sections or drop existing ones.718719## Gotchas720721- **Roster invariant.** The frontmatter description, the roster table,722 `assets/panel-mode.md`, the recommendation template, and the JSON723 schema MUST agree on the persona set. If you change one, change all724 in the same edit. Omitted persona = inactive. Do not spawn725 `active: false` stubs except model-unavailable.726- **Calibrated severity discipline.** The advisory regime relies on727 panelists honestly distinguishing `blocking` from `recommended`. If a728 panelist marks everything `blocking`, the comment becomes noisy and729 the maintainer learns to ignore the field. The panelist prompts state730 the contract explicitly; the CEO arbitration prose is the safety731 valve when a panelist over-flags.732- **Mermaid diagrams are `full` only.** In `full`, python-architect733 supplies `extras.diagrams.class_diagram`,734 `extras.diagrams.component`, and the OPTIONAL735 `extras.diagrams.sequence`. `lean` and `delta` omit diagrams.736 The template renders nothing when they are missing -- it does NOT737 invent diagrams.738- **Mermaid `classDiagram` `:::cssClass` shorthand gotcha.** GitHub's739 mermaid renderer rejects `:::cssClass` appended to relationship740 lines (e.g. `A *-- B:::touched`); use standalone741 `class Name:::cssClass` declarations instead. Authority:742 `python-architect.agent.md:146-154`.743- **Doc-writer detects DRIFT, not just edits.** When the PR changes744 user-facing code that SHOULD have updated docs but did not, doc-writer745 surfaces that as a finding. The conditional rule above is necessary746 but not sufficient -- doc-writer reasons about doc consistency given747 the diff, not just whether doc files were touched.748- **False-negative auth gotcha.** Auth regressions can be introduced749 from non-auth files that change the inputs to auth -- host750 classification, dependency parsing, clone URL construction, HTTP751 authorization headers, or call sites that bypass `AuthResolver`. If752 a diff changes how a remote host, org, token source, or fallback path753 is selected and you are not certain it is auth-neutral, activate754 auth-expert as `active: true`.755- **Test-coverage probe is mandatory.** The test-coverage-expert MUST756 verify "no test exists for X" via `view`/`grep` on the `tests/` tree757 before emitting a finding. A false-positive coverage finding (test758 exists but persona claimed it does not) destroys maintainer trust in759 the field. The persona scope file enforces this; the orchestrator760 passes the diff and trusts the persona to probe.761- **Subagent write enforcement is contract-based, not sandbox-based.**762 Tool permissions are workflow-scoped, not subagent-scoped, so every763 spawned task technically inherits the same `gh` toolset. The764 "subagents must not write" rule is enforced by the prompt contract in765 each `.agent.md` plus the `safe-outputs.add-comment.max: 2`766 fail-soft. If a subagent ever tries to post a comment, the cap767 catches it.768- **Empty-safe-output failure (background spawn-and-forget).** The single769 most common way this panel "succeeds" yet posts nothing is spawning the770 CEO synthesizer (or a panelist) as a background/detached task and then771 ending the turn while it is still running. The harness exits with772 `agent_output = {"items":[]}`, gh-aw skips safe-output detection, the773 `add-comment` job never runs, and the workflow opens a "No Safe Outputs774 Generated" issue. Every `task` spawn MUST be awaited to completion, and775 the turn MUST end with a safe output -- the comment, or an explicit776 `noop`. See the "Synchronous fan-out" and "Non-empty turn exit"777 architecture invariants and step 9.778- **No verdict-label reset workflow.** The previous regime had a779 companion workflow `pr-panel-label-reset.yml` that stripped verdict780 labels on every push. The advisory regime has no verdict labels to781 strip; that workflow is removed.