Skip to content

feat(plan): rewrite plan-level.yaml for platform-native PR review (P7b-i-d) - #89

Merged
PolyphonyRequiem merged 1 commit into
mainfrom
sdlc/plan-level-rewrite
May 6, 2026
Merged

feat(plan): rewrite plan-level.yaml for platform-native PR review (P7b-i-d)#89
PolyphonyRequiem merged 1 commit into
mainfrom
sdlc/plan-level-rewrite

Conversation

@PolyphonyRequiem

Copy link
Copy Markdown
Owner

Summary

Phase 3 P7b-i-d. Rewrites plan-level.yaml from v1.0.1 to v2.0.0, replacing in-workflow LLM-verdict planning loop (technical_reviewer / readability_reviewer / review_router / plan_approval) with the platform-native PR-review flow built on the substrate verbs from P7b-i-a / b / c plus the four prior plan/branch/pr verbs.

This is the consumer flip for everything Phase 3 has been building toward.

Lifecycle

depth_guard -> guidance_loader -> root_resolver -> type_loader
            -> ancestor_chain -> state_detector
              |
              +-- not_started      -> architect -> write_plan -> ensure_plan_branch
              |                     -> commit_and_push -> open_plan_pr
              |                     -> plan_reviewer (advisory)
              |                     -> poll_status (single-shot)
              +-- awaiting_review  -> poll_status
              +-- stale_generation -> architect (re-author)
              +-- merged_unseeded  -> seeder -> child_router (recurse)
              +-- complete         -> child_router (recurse only)
              +-- closed_unmerged  -> blocked exit

poll_status:
  approved + no parent change -> merge_plan_pr -> seeder
  approved + parent change    -> parent_change_blocked_exit (P8 stub)
  changes_requested           -> revise_counter -> architect (cap 5)
  pending                     -> pending_review_gate
  merged                      -> seeder
  closed                      -> closed_unmerged_gate

Design decisions

Tracks files/p7-design-doc.md:

ID Decision
Q1 plan path = plans/plan-{item_id}.md (handled by write-plan verb)
Q2 single advisory plan_reviewer + human approval (option 2)
Q3 DEVIATION -- in-workflow human_gate for pending (option a) instead of exit-with-pending (option b). polyphony-full's outer state_detector still uses the OLD single-string phase model and would infinite-loop on awaiting_review. Switch to (b) lands with Phase 2c YAML migration.
Q4 root_resolver derives root_id once via polyphony root resolve; all downstream verbs read root_resolver.output.resolved_root_id
Q5 plan_reviewer is a script agent calling gh pr review --comment once and returning
Q6 revise loop capped at 5 with revise_cap_gate escalation
Q7 blocked exits via human_gate Markdown (no per-workflow output schema yet)
Q8 requests_parent_change: true rejected with honest "P8 not implemented" gate

Preserved from v1

  • Architect output schema ({plan, children, open_questions, summary}) -- existing architect-plan-level.md prompt unchanged
  • open_questions policy machinery (open_questions_policy / _counter / _answer_counter / _gate)
  • Recursive child planning via plan_children_group for_each
  • depth_guard with cap 6
  • All gates: depth_exceeded_gate, open_questions_gate, plan_children_summary_gate

Substrate verbs consumed

All shipped in prior PRs (#83, #85, #86, #88 + earlier P7b-i-a/b/c):

  • polyphony root resolve
  • polyphony plan derive-ancestor-chain
  • polyphony plan detect-state
  • polyphony plan write-plan
  • polyphony plan commit-and-push
  • polyphony plan seed-children
  • polyphony plan next-child
  • polyphony branch ensure-plan
  • polyphony pr open-plan-pr
  • polyphony pr poll-status
  • polyphony pr merge-plan-pr
  • polyphony policy resolve --domain open_questions

Drive-by build fix

PR #88 (P7b-i-c detect-state) added IGitClient and IGhClient to the PlanCommands constructor but didn't update PlanCommandsWritePlanTests.CreateCommand(). Main has been red since that merge. This PR brings the suite back to 1809/1809 green.

Validation

Check Result
dotnet test 1809/1809 pass (was: build break on main)
lint-plan-level.ps1 10/10 checks pass
lint-plan-level.Tests.ps1 5/5 Pester tests pass
lint-strict-undefined.ps1 10 workflows scanned clean
lint-type-agnostic.ps1 -Surface all 42 files scanned clean
lint-root-routing.ps1 7 phases / 3 sub-workflows validated

Out of scope

  • lint-implement-pg.ps1 expects claude-opus-4.7-1m-internal but YAML has claude-opus-4.6 / claude-opus-4.7. Same failure on main; tracked separately.
  • P8 scope renegotiation (requests_parent_change) -- gates with honest error
  • P9 ancestor cascade (stale_generation post-merge) -- gates with stub
  • P10 audit/UX polish -- not started

Next steps after merge

  1. Smoke-test on a real ADO work item (single-level plan first; then depth-2)
  2. P8 -- requests_parent_change cascade
  3. P9 -- ancestor cascade auto-rebase
  4. Migrate polyphony-full's state_detector to requirement+disposition shape (Phase 2c) so we can flip Q3 to option b

…b-i-d)

Phase 3 P7b-i-d. Replaces v1.0.1's in-workflow LLM-verdict planning loop
(technical_reviewer / readability_reviewer / review_router / plan_approval)
with the platform-native PR-review flow built on the substrate verbs
shipped in P7b-i-a / P7b-i-b / P7b-i-c (and the four prior plan/branch/pr
verbs).

Lifecycle per invocation:
  1. depth_guard -> guidance_loader -> root_resolver -> type_loader
  2. ancestor_chain -> state_detector
  3. State-driven routes:
       not_started      -> architect -> write_plan -> ensure_plan_branch
                           -> commit_and_push -> open_plan_pr
                           -> plan_reviewer (advisory comment)
                           -> poll_status (single-shot)
       awaiting_review  -> poll_status
       stale_generation -> architect (re-author)
       merged_unseeded  -> seeder -> child_router (recurse)
       complete         -> child_router (recurse only)
       closed_unmerged  -> blocked exit
  4. poll_status routes by review state:
       approved (no parent change)  -> merge_plan_pr -> seeder
       approved + parent change     -> parent_change_blocked_exit (P8 stub)
       changes_requested            -> revise_counter -> architect (cap 5)
       pending                      -> pending_review_gate
       merged                       -> seeder
       closed                       -> closed_unmerged_gate

Key design decisions (per files/p7-design-doc.md):
- Q1 plan path:        plans/plan-{item_id}.md (handled by write-plan verb)
- Q2 reviewer:         single advisory plan_reviewer + human approval (option 2)
- Q3 pending review:   in-workflow human_gate (option a) -- DEVIATES from
                       design default (option b exit-with-pending) because
                       polyphony-full's state_detector still uses the OLD
                       single-string phase model and would infinite-loop
                       on awaiting_review. Switch to (b) lands with Phase 2c.
- Q4 root_id thread:   root_resolver derives once via 'root resolve'; all
                       downstream verbs read root_resolver.output.resolved_root_id
- Q5 review posting:   plan_reviewer is a script agent calling
                       'gh pr review --comment' once and returning
- Q6 revise loop:      capped at 5 iterations with revise_cap_gate
- Q7 output shape:     blocked exits use human_gate; reviewer-driven outputs
                       surface via gate Markdown
- Q8 parent change:    refused at this PR; honest 'P8 not implemented' gate

Architect output schema unchanged ({plan, children, open_questions, summary})
so the existing architect-plan-level.md prompt continues to work.

Open-questions policy (open_questions_policy / open_questions_counter /
open_questions_answer_counter / open_questions_gate) preserved verbatim
from v1.

Recursion preserved: plan_children_group for_each invokes ./plan-level.yaml
per plannable child with depth+1.

All error sites have explicit human_gate fallbacks (root_resolver_error_gate,
type_loader_error_gate, state_detector_error_gate, write_plan_error_gate,
ensure_branch_error_gate, commit_error_gate, open_pr_error_gate,
poll_error_gate, merge_error_gate, stale_generation_gate,
parent_change_blocked_exit, closed_unmerged_gate).

Drive-by: fix pre-existing build break in
PlanCommandsWritePlanTests.CreateCommand() -- it was missing IGitClient and
IGhClient args added to PlanCommands ctor in P7b-i-c (#88). Main has been
red since that merge; this PR brings the C# suite back to 1809/1809 green.

Validation:
- dotnet test: 1809/1809 pass (was: build break on main)
- lint-plan-level.ps1: 10/10 checks pass
- lint-plan-level.Tests.ps1: 5/5 Pester tests pass
- lint-strict-undefined.ps1: 10 workflows scanned clean
- lint-type-agnostic.ps1 -Surface all: 42 files scanned clean
- lint-root-routing.ps1: 7 phases / 3 sub-workflows validated

Pre-existing failure NOT addressed by this PR:
- lint-implement-pg.ps1 expects claude-opus-4.7-1m-internal but YAML has
  claude-opus-4.6 / claude-opus-4.7. Same failure on main. Tracked
  separately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PolyphonyRequiem
PolyphonyRequiem merged commit c00f95e into main May 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant