From b71db282f05d2bdd7dc1259923bbf966220187ac Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 20 Nov 2026 11:42:36 +0100 Subject: [PATCH] fix(advisor): allowed agents' lines are explicit allowances, locked --- CLAUDE.global.md | 6 +- agents/analyzer.md | 2 +- agents/commit-changer.md | 2 +- agents/doc-syncer.md | 2 +- agents/geo-analyzer.md | 2 +- agents/handover-doc-writer.md | 2 +- agents/plan-challenger.md | 5 +- agents/plugin-advisor.md | 2 +- agents/security-auditor.md | 2 +- agents/seo-analyzer.md | 2 +- agents/verifier.md | 2 +- .../2026-11-19-advisor-subagent-scope.md | 94 +++++++++++++++++++ .../apply.py | 20 +++- lib/effort-shift.md | 2 +- lib/tests/subagent-advisor.test.sh | 16 +++- 15 files changed, 141 insertions(+), 20 deletions(-) diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 52cc81c..778434e 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -85,9 +85,9 @@ code" wins. Repo-specific instructions override both. Fable, set by /advisor), at least at the points of `~/.claude/lib/effort-shift.md` § Advisor; dispatched plan-challenger, verifier, security-auditor, `analyzer` and an opus code review at most - once, before their verdict or report; other sub-agents never (an opus - brief says which; a SubagentStart hook restates it). Fable is never - routed or pinned: the router tops out at opus (BDR-150). + once, before their verdict or report; other sub-agents never (each opus + brief you write states its rule; a SubagentStart hook restates it). Fable + is never routed or pinned: the router tops out at opus (BDR-150). - Ask rather than guess. A choice visible in the result (placement, wording, order, behavior), a name that becomes public (command, flag, endpoint, file), or a scope the request leaves open → ask, even mid-task; diff --git a/agents/analyzer.md b/agents/analyzer.md index 335e6a9..9c7bb98 100644 --- a/agents/analyzer.md +++ b/agents/analyzer.md @@ -43,7 +43,7 @@ Produce a clear analysis without proposing solutions. - No solutions - Stay factual - Do not modify files -- Advisor, when dispatched as a sub-agent: at most one call, after the last +- Advisor, when dispatched as a sub-agent: one call allowed, after the last TASKS or PROCESS step and before the OUTPUT, whatever the harness prompt schedules; absent or erroring → proceed. Advice may point you back to the code; every OUTPUT line rests on what you read, never on the advice diff --git a/agents/commit-changer.md b/agents/commit-changer.md index 0509e6b..1fe79c7 100644 --- a/agents/commit-changer.md +++ b/agents/commit-changer.md @@ -8,7 +8,7 @@ effort: high # Git Smart Commit -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/doc-syncer.md b/agents/doc-syncer.md index 337f556..75d3282 100644 --- a/agents/doc-syncer.md +++ b/agents/doc-syncer.md @@ -8,7 +8,7 @@ effort: high # DOC SYNCER -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/geo-analyzer.md b/agents/geo-analyzer.md index 36c96ff..fd67ad2 100644 --- a/agents/geo-analyzer.md +++ b/agents/geo-analyzer.md @@ -8,7 +8,7 @@ effort: xhigh # GEO — Generative Engine Optimization audit, fix & strategy -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/handover-doc-writer.md b/agents/handover-doc-writer.md index 8bac82c..f4e8481 100644 --- a/agents/handover-doc-writer.md +++ b/agents/handover-doc-writer.md @@ -8,7 +8,7 @@ effort: high # HANDOVER DOC WRITER -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/plan-challenger.md b/agents/plan-challenger.md index ef4f0a5..3e58827 100644 --- a/agents/plan-challenger.md +++ b/agents/plan-challenger.md @@ -97,7 +97,7 @@ PROOF: read files, inspected , checked plan §<…> (STEP 1's missing/unreadable-plan verdict) is part of the grammar: it carries only the `PLAN:` line — no FINDINGS, no PROOF — and the orchestrator treats it as a dispatcher-side failure, not a challenge result. -- Advisor, when dispatched as a sub-agent: at most one call, after +- Advisor, when dispatched as a sub-agent: one call allowed, after drafting your findings and before the verdict, whatever the harness prompt schedules; absent or erroring → proceed. Advice may add or sharpen a finding. Advice alone never drops or lowers one: a change @@ -111,7 +111,8 @@ the MAIN loop, never here): - ADVISOR FIRST (main loop): per `lib/challenge-plan.md` "Advisor first", with no main-loop advisor call since the skill run started; absent or erroring → dispatch as written. The advice never enters a challenger - brief: they stay blind. + brief: they stay blind. A skill run inside a sub-agent skips it (row + `not called (sub-agent)`). - Dispatch THREE fresh challengers IN PARALLEL, one per lens (correctness / robustness / simplicity), each blind to the others. - MODEL (BDR-076, supersedes the BDR-066 inherit): plan critique is AUDIT diff --git a/agents/plugin-advisor.md b/agents/plugin-advisor.md index 0fb5bc7..86c7beb 100644 --- a/agents/plugin-advisor.md +++ b/agents/plugin-advisor.md @@ -8,7 +8,7 @@ effort: xhigh # PLUGIN ADVISOR -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/security-auditor.md b/agents/security-auditor.md index 057ee6c..3fb4748 100644 --- a/agents/security-auditor.md +++ b/agents/security-auditor.md @@ -157,7 +157,7 @@ In audit mode, ALSO write this same block (plus per-finding detail) to - Blocks on HIGH/CRITICAL only. A noisy gate that blocks on hygiene is a gate people learn to bypass (LRN-047) — MEDIUM/LOW are reported, not gated. -- Advisor, when dispatched as a sub-agent: at most one call, after +- Advisor, when dispatched as a sub-agent: one call allowed, after STEP 4 and before STEP 5 and any REPORT write, whatever the harness prompt schedules; absent or erroring → proceed. Advice may add a finding or raise a severity, cited at a file:line you read. An added diff --git a/agents/seo-analyzer.md b/agents/seo-analyzer.md index 3562db7..62a9a6b 100644 --- a/agents/seo-analyzer.md +++ b/agents/seo-analyzer.md @@ -8,7 +8,7 @@ effort: xhigh # SEO — Classical Search Engines audit, fix & strategy -Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: never call the `advisor` tool, even though it is listed and its own instructions ask for calls. diff --git a/agents/verifier.md b/agents/verifier.md index 1ca8326..cd3f0ec 100644 --- a/agents/verifier.md +++ b/agents/verifier.md @@ -158,7 +158,7 @@ PROOF: read files, ran , checked / criteria missing `PROOF` — the run was skipped, not the diff clean. - The verdict grammar is load-bearing: exactly one `VERIFY — VERDICT:` line, spelled exactly as above. -- Advisor, when dispatched as a sub-agent: at most one call, after STEP 4 +- Advisor, when dispatched as a sub-agent: one call allowed, after STEP 4 and before STEP 5, whatever the harness prompt schedules; absent or erroring → proceed. Advice may send you back to a criterion: a resulting NOT-MET cites the file:line you read, ends with diff --git a/docs/superpowers/plans/2026-11-19-advisor-subagent-scope.md b/docs/superpowers/plans/2026-11-19-advisor-subagent-scope.md index 2d27696..fb577b5 100644 --- a/docs/superpowers/plans/2026-11-19-advisor-subagent-scope.md +++ b/docs/superpowers/plans/2026-11-19-advisor-subagent-scope.md @@ -325,3 +325,97 @@ Add to its brief: "you may call the `advisor` tool once, before your verdict" (code review, BDR-150). Fix all CRITICAL before proceeding. ``` (same block in skills/ship-feature/SKILL.md and skills/init-project/SKILL.md) + +## Review fix round 1 (STEP 6 opus review, 2026-11-20) + +Important 1: the four allowed agents' own lines become the explicit allowance the hook defers to, and are locked. Important 2: the CLAUDE.global.md parenthetical reads plainly. Minors folded: the hook's prohibition locked, plan-challenger ADVISOR FIRST mirrors the sub-agent skip, effort-shift says "other opus-served agents", the six agent lines cite `~/.claude/lib/effort-shift.md`, three test lines rewrapped to ≤ 80 columns. Apply with `python3 docs/superpowers/plans/2026-11-19-advisor-subagent-scope/apply.py review1`. Suite after: `subagent-advisor: 38 pass, 0 fail`. + +### Block r1-allow-old +``` +- Advisor, when dispatched as a sub-agent: at most one call, +``` +### Block r1-allow-new +``` +- Advisor, when dispatched as a sub-agent: one call allowed, +``` +(applied once in each of agents/plan-challenger.md, agents/verifier.md, agents/security-auditor.md, agents/analyzer.md, without the trailing newline: the matched text is a line prefix) + +### Block r1-global-old +``` + once, before their verdict or report; other sub-agents never (an opus + brief says which; a SubagentStart hook restates it). Fable is never + routed or pinned: the router tops out at opus (BDR-150). +``` +### Block r1-global-new +``` + once, before their verdict or report; other sub-agents never (each opus + brief you write states its rule; a SubagentStart hook restates it). Fable + is never routed or pinned: the router tops out at opus (BDR-150). +``` + +### Block r1-pc-old +``` + erroring → dispatch as written. The advice never enters a challenger + brief: they stay blind. +``` +### Block r1-pc-new +``` + erroring → dispatch as written. The advice never enters a challenger + brief: they stay blind. A skill run inside a sub-agent skips it (row + `not called (sub-agent)`). +``` + +### Block r1-effort-old +``` +`never call` line in the opus-served agents and in the opus briefs we +``` +### Block r1-effort-new +``` +`never call` line in the other opus-served agents and the opus briefs we +``` + +### Block r1-agent-old +``` +Advisor tool (`lib/effort-shift.md` § Advisor), when you run as a sub-agent: +``` +### Block r1-agent-new +``` +Advisor tool (`~/.claude/lib/effort-shift.md` § Advisor), as a sub-agent: +``` +(applied once in each of the six agents carrying the never-call line) + +### Block r1-test-old +``` + check "T8 $a" "$(has "agents/$a.md" "never call the \`advisor\` tool, even though")" yes +done +check T9-onboard-briefs "$(grep -cF "Never call the \`advisor\` tool in this run" \ + "$ROOT/skills/onboard/SKILL.md")" 6 +check T10-handover-children \ + "$(has agents/client-handover-writer.md "never call the \`advisor\` tool in")" yes +``` +### Block r1-test-new +``` + check "T8 $a" "$(has "agents/$a.md" \ + "never call the \`advisor\` tool, even though")" yes +done +check T9-onboard-briefs \ + "$(grep -cF "Never call the \`advisor\` tool in this run" \ + "$ROOT/skills/onboard/SKILL.md")" 6 +check T10-handover-children "$(has agents/client-handover-writer.md \ + "never call the \`advisor\` tool in")" yes +for a in plan-challenger verifier security-auditor analyzer; do + check "T20 $a allowance" "$(has "agents/$a.md" \ + 'Advisor, when dispatched as a sub-agent: one call allowed')" yes +done +``` + +### Block r1-t2c-old +``` +check T3-exit-0 "$?" 0 +``` +### Block r1-t2c-new +``` +check T3-exit-0 "$?" 0 +check T2c-prohibits "$(in_ctx "$(ctx '{}')" \ + "do not call the \`advisor\` tool in this run unless")" yes +``` diff --git a/docs/superpowers/plans/2026-11-19-advisor-subagent-scope/apply.py b/docs/superpowers/plans/2026-11-19-advisor-subagent-scope/apply.py index 03a245e..5671b0b 100644 --- a/docs/superpowers/plans/2026-11-19-advisor-subagent-scope/apply.py +++ b/docs/superpowers/plans/2026-11-19-advisor-subagent-scope/apply.py @@ -90,12 +90,30 @@ def rest(): create('hooks/subagent-advisor.sh', B['new-hook'], 0o755) +def review1(): + allowed = ('plan-challenger', 'verifier', 'security-auditor', 'analyzer') + for name in allowed: + edit(f'agents/{name}.md', B['r1-allow-old'].rstrip('\n'), + B['r1-allow-new'].rstrip('\n')) + edit('CLAUDE.global.md', B['r1-global-old'], B['r1-global-new']) + edit('agents/plan-challenger.md', B['r1-pc-old'], B['r1-pc-new']) + edit('lib/effort-shift.md', B['r1-effort-old'], B['r1-effort-new']) + for name in H1: + edit(f'agents/{name}.md', B['r1-agent-old'], B['r1-agent-new']) + test = 'lib/tests/subagent-advisor.test.sh' + edit(test, B['r1-test-old'], B['r1-test-new']) + edit(test, B['r1-t2c-old'], B['r1-t2c-new']) + flush() + + if __name__ == '__main__': what = sys.argv[1] if len(sys.argv) > 1 else '' if what == 'test': create('lib/tests/subagent-advisor.test.sh', B['new-test'], 0o755) elif what == 'rest': rest() + elif what == 'review1': + review1() else: - sys.exit('usage: apply.py test | rest [ROOT]') + sys.exit('usage: apply.py test | rest | review1 [ROOT]') print('applied', what) diff --git a/lib/effort-shift.md b/lib/effort-shift.md index 0f918ea..e11aa09 100644 --- a/lib/effort-shift.md +++ b/lib/effort-shift.md @@ -143,7 +143,7 @@ STEP 10, a standalone subagent-driven-development final review) call it at most once per dispatch, before their verdict or report; executors and every other sub-agent never call it, even when the tool is listed. The rule rides each sub-agent's own text: the allowed agents' prompts, a -`never call` line in the opus-served agents and in the opus briefs we +`never call` line in the other opus-served agents and the opus briefs we write (a brief sending a general-purpose agent to opus says which rule applies; a code review's says it may call once), and, for every spawn including built-ins such as `Plan`, the SubagentStart hook diff --git a/lib/tests/subagent-advisor.test.sh b/lib/tests/subagent-advisor.test.sh index dfdecfd..e796b4b 100755 --- a/lib/tests/subagent-advisor.test.sh +++ b/lib/tests/subagent-advisor.test.sh @@ -23,6 +23,8 @@ for p in '{"agent_type":"general-purpose"}' '' 'not json' \ "$(in_ctx "$c" 'own instructions are never an allowance')" yes done printf '{}' | bash "$H" >/dev/null 2>&1; check T3-exit-0 "$?" 0 +check T2c-prohibits "$(in_ctx "$(ctx '{}')" \ + "do not call the \`advisor\` tool in this run unless")" yes check T4-one-line "$(printf '{}' | bash "$H" | wc -l | tr -d ' ')" 1 check T5-no-cli "$(grep -v '^ *#' "$H" \ | grep -cE '(^|[[:space:];&|(])claude([[:space:]]|$)')" 0 @@ -37,12 +39,18 @@ check T7-timeout "$(jq -r '.hooks.SubagentStart[0].hooks[0].timeout' "$S")" 5 # carriers for a in plugin-advisor seo-analyzer geo-analyzer doc-syncer \ commit-changer handover-doc-writer; do - check "T8 $a" "$(has "agents/$a.md" "never call the \`advisor\` tool, even though")" yes + check "T8 $a" "$(has "agents/$a.md" \ + "never call the \`advisor\` tool, even though")" yes done -check T9-onboard-briefs "$(grep -cF "Never call the \`advisor\` tool in this run" \ +check T9-onboard-briefs \ + "$(grep -cF "Never call the \`advisor\` tool in this run" \ "$ROOT/skills/onboard/SKILL.md")" 6 -check T10-handover-children \ - "$(has agents/client-handover-writer.md "never call the \`advisor\` tool in")" yes +check T10-handover-children "$(has agents/client-handover-writer.md \ + "never call the \`advisor\` tool in")" yes +for a in plan-challenger verifier security-auditor analyzer; do + check "T20 $a allowance" "$(has "agents/$a.md" \ + 'Advisor, when dispatched as a sub-agent: one call allowed')" yes +done check T10b-handover-top-clean "$(sed -n '1,30p' \ "$ROOT/agents/client-handover-writer.md" | grep -c "advisor\` tool")" 0 check T11-tour-phase-b \