maxsimcli 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  <purpose>
2
- Execute a phase prompt (PLAN.md) and create the outcome summary (SUMMARY.md).
2
+ Execute a phase plan (loaded from GitHub issue comment or local PLAN.md) and post the outcome summary as a GitHub comment. Per-task board transitions keep the project board current throughout execution.
3
3
  </purpose>
4
4
 
5
5
  <required_reading>
@@ -29,24 +29,40 @@ Load execution context (paths only to minimize orchestrator context):
29
29
  INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init execute-phase "${PHASE}")
30
30
  ```
31
31
 
32
- Extract from init JSON: `executor_model`, `commit_docs`, `phase_dir`, `phase_number`, `plans`, `summaries`, `incomplete_plans`, `state_path`, `config_path`.
32
+ Extract from init JSON: `executor_model`, `commit_docs`, `phase_dir`, `phase_number`, `plans`, `summaries`, `incomplete_plans`, `state_path`, `config_path`, `phase_issue_number`, `task_mappings`.
33
33
 
34
34
  If `.planning/` missing: error.
35
35
  </step>
36
36
 
37
- <step name="identify_plan">
37
+ <step name="load_plan_from_github">
38
+
39
+ ## Plan Loading -- GitHub First
40
+
41
+ When the orchestrator passes `github_context` (phase_issue_number and plan_comment_body), use it directly:
42
+
43
+ 1. The plan content is in `plan_comment_body` passed from the orchestrator. Parse it in memory -- do NOT read a local PLAN.md file.
44
+ 2. Extract frontmatter fields: `wave`, `autonomous`, `objective`, `requirements`, `task_mappings`, `gap_closure`.
45
+ 3. Extract the task list and verification criteria from the comment body.
46
+
47
+ **External edit detection (WIRE-06):** Before beginning execution, check if the plan comment was modified since the orchestrator read it:
48
+
49
+ ```
50
+ mcp_detect_external_edits(issue_number: phase_issue_number)
51
+ ```
52
+
53
+ If external edits detected: warn user and offer to re-read the plan before proceeding.
54
+
55
+ **Fallback -- no GitHub context:**
56
+
57
+ If no `phase_issue_number` or `plan_comment_body` was passed:
58
+
38
59
  ```bash
39
60
  # Use plans/summaries from INIT JSON, or list files
40
61
  ls .planning/phases/XX-name/*-PLAN.md 2>/dev/null | sort
41
62
  ls .planning/phases/XX-name/*-SUMMARY.md 2>/dev/null | sort
42
63
  ```
43
64
 
44
- Find first PLAN without matching SUMMARY. Decimal phases supported (`01.1-hotfix/`):
45
-
46
- ```bash
47
- PHASE=$(echo "$PLAN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
48
- # config settings can be fetched via maxsim-tools config-get if needed
49
- ```
65
+ Find first PLAN without matching SUMMARY. Decimal phases supported (`01.1-hotfix/`).
50
66
 
51
67
  <if mode="yolo">
52
68
  Auto-approve: `⚡ Execute {phase}-{plan}-PLAN.md [Plan X of Y for Phase Z]` → parse_segments.
@@ -65,7 +81,12 @@ PLAN_START_EPOCH=$(date +%s)
65
81
  </step>
66
82
 
67
83
  <step name="parse_segments">
84
+
85
+ Identify checkpoint type from plan content:
86
+
68
87
  ```bash
88
+ # If plan loaded from GitHub comment, scan comment body for checkpoint markers
89
+ # If plan loaded from local file:
69
90
  grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
70
91
  ```
71
92
 
@@ -73,13 +94,13 @@ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
73
94
 
74
95
  | Checkpoints | Pattern | Execution |
75
96
  |-------------|---------|-----------|
76
- | None | A (autonomous) | Single subagent: full plan + SUMMARY + commit |
97
+ | None | A (autonomous) | Single subagent: full plan + post SUMMARY comment + commit |
77
98
  | Verify-only | B (segmented) | Segments between checkpoints. After none/human-verify → SUBAGENT. After decision/human-action → MAIN |
78
99
  | Decision | C (main) | Execute entirely in main context |
79
100
 
80
- **Pattern A:** init_agent_tracking → spawn Task(subagent_type="executor", model=executor_model) with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report.
101
+ **Pattern A:** init_agent_tracking → spawn Task(subagent_type="executor", model=executor_model) with prompt: execute plan (content from GitHub comment or local path), autonomous, all tasks + post SUMMARY comment + commit, follow deviation/auth rules, move task sub-issues on board as each task starts/completes, report: plan name, tasks, summary comment URL, commit hash → track agent_id → wait → update tracking → report.
81
102
 
82
- **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, create SUMMARY, commit. See segment_execution.
103
+ **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, post SUMMARY as GitHub comment, commit. See segment_execution.
83
104
 
84
105
  **Pattern C:** Execute in main using standard flow (step name="execute").
85
106
 
@@ -110,25 +131,26 @@ Pattern B only (verify-only checkpoints). Skip for A/C.
110
131
 
111
132
  1. Parse segment map: checkpoint locations and types
112
133
  2. Per segment:
113
- - Subagent route: spawn executor for assigned tasks only. Prompt: task range, plan path, read full plan for context, execute assigned tasks, track deviations, NO SUMMARY/commit. Track via agent protocol.
134
+ - Subagent route: spawn executor for assigned tasks only. Prompt: task range, plan content (from GitHub comment or local path), read full plan for context, execute assigned tasks, track deviations, move task sub-issues to "In Progress" when started and "Done" when completed, NO SUMMARY/commit. Track via agent protocol.
114
135
  - Main route: execute tasks using standard flow (step name="execute")
115
- 3. After ALL segments: aggregate files/deviations/decisions → create SUMMARY.md → commit → self-check:
136
+ 3. After ALL segments: aggregate files/deviations/decisions → post SUMMARY as GitHub comment (mcp_post_comment with type=summary) → commit → self-check:
116
137
  - Verify key-files.created exist on disk with `[ -f ]`
117
138
  - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
118
- - Append `## Self-Check: PASSED` or `## Self-Check: FAILED` to SUMMARY
139
+ - Check for `## Self-Check: PASSED` or `## Self-Check: FAILED` and append to summary comment body
119
140
 
120
141
  **Known Claude Code bug (classifyHandoffIfNeeded):** If any segment agent reports "failed" with `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a real failure. Run spot-checks; if they pass, treat as successful.
142
+ </step>
121
143
 
144
+ <step name="load_prompt">
122
145
 
146
+ The plan content IS the execution instructions. Follow exactly. If plan references CONTEXT.md: honor user's vision throughout.
123
147
 
148
+ When plan was loaded from a GitHub comment (github_context passed): the plan content is already in memory from the load_plan_from_github step.
124
149
 
125
- </step>
126
-
127
- <step name="load_prompt">
150
+ When plan is loaded from a local file (fallback):
128
151
  ```bash
129
152
  cat .planning/phases/XX-name/{phase}-{plan}-PLAN.md
130
153
  ```
131
- This IS the execution instructions. Follow exactly. If plan references CONTEXT.md: honor user's vision throughout.
132
154
  </step>
133
155
 
134
156
  <step name="pre_execution_gates">
@@ -137,7 +159,7 @@ Validate requirements before execution. These gates ensure spec-driven developme
137
159
  **Gate G1: Requirement Existence** — All requirement IDs from the plan's frontmatter must exist in REQUIREMENTS.md.
138
160
 
139
161
  ```bash
140
- # Extract requirement IDs from plan frontmatter
162
+ # Extract requirement IDs from plan frontmatter (in memory if loaded from GitHub, or from file)
141
163
  REQ_IDS=$(grep "^requirements:" "$PLAN_PATH" | sed 's/requirements:\s*\[//;s/\]//;s/,/ /g;s/"//g;s/'\''//g' | tr -s ' ')
142
164
  if [ -n "$REQ_IDS" ]; then
143
165
  G1_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify requirement-existence $REQ_IDS)
@@ -172,7 +194,7 @@ fi
172
194
  node ~/.claude/maxsim/bin/maxsim-tools.cjs phases list --type summaries --raw
173
195
  # Extract the second-to-last summary from the JSON result
174
196
  ```
175
- If previous SUMMARY has unresolved "Issues Encountered" or "Next Phase Readiness" blockers: AskUserQuestion(header="Previous Issues", options: "Proceed anyway" | "Address first" | "Review previous").
197
+ If previous phase has unresolved issues (check summary comments on phase issue or local SUMMARY.md "Issues Encountered" / "Next Phase Readiness" blockers): AskUserQuestion(header="Previous Issues", options: "Proceed anyway" | "Address first" | "Review previous").
176
198
  </step>
177
199
 
178
200
  <step name="execute">
@@ -180,8 +202,32 @@ Deviations are normal — handle via rules below.
180
202
 
181
203
  1. Read @context files from prompt
182
204
  2. Per task:
205
+
206
+ **Before starting each task (WIRE-04 board transition):**
207
+ - Look up the task's sub-issue number from `task_mappings` in the GitHub context.
208
+ - Move the task sub-issue to "In Progress":
209
+ ```
210
+ mcp_move_issue(issue_number: task_sub_issue_number, status: "In Progress")
211
+ ```
212
+
183
213
  - `type="auto"`: if `tdd="true"` → TDD execution. Implement with deviation rules + auth gates. Verify done criteria. Commit (see task_commit). Track hash for Summary.
184
214
  - `type="checkpoint:*"`: STOP → checkpoint_protocol → wait for user → continue only after confirmation.
215
+
216
+ **After each task completes successfully (WIRE-04 board transition):**
217
+ - Post task completion details on the task sub-issue:
218
+ ```
219
+ mcp_post_completion(
220
+ issue_number: task_sub_issue_number,
221
+ commit_sha: TASK_COMMIT,
222
+ files_changed: [list of files modified by this task]
223
+ )
224
+ ```
225
+ - Close the task sub-issue and move to "Done":
226
+ ```
227
+ mcp_close_issue(issue_number: task_sub_issue_number)
228
+ mcp_move_issue(issue_number: task_sub_issue_number, status: "Done")
229
+ ```
230
+
185
231
  3. Run `<verification>` checks
186
232
  4. Confirm `<success_criteria>` met
187
233
  5. Document deviations in Summary
@@ -337,6 +383,16 @@ Orchestrator parses → presents to user → spawns fresh continuation with your
337
383
 
338
384
  <step name="verification_failure_gate">
339
385
  If verification fails: STOP. Present: "Verification failed for Task [X]: [name]. Expected: [criteria]. Actual: [result]." Options: Retry | Skip (mark incomplete) | Stop (investigate). If skipped → SUMMARY "Issues Encountered".
386
+
387
+ **On review failure (WIRE-07):** If the task sub-issue was already moved to "Done", reopen and move back:
388
+ ```
389
+ mcp_reopen_issue(issue_number: task_sub_issue_number)
390
+ mcp_move_issue(issue_number: task_sub_issue_number, status: "In Progress")
391
+ mcp_post_comment(
392
+ issue_number: task_sub_issue_number,
393
+ body: "## Review Failure\n\nVerification failed for this task. Moving back to In Progress.\n\n**Reason:** {failure details}\n**Action needed:** {what needs to be fixed}"
394
+ )
395
+ ```
340
396
  </step>
341
397
 
342
398
  <step name="record_completion_time">
@@ -358,31 +414,54 @@ fi
358
414
  </step>
359
415
 
360
416
  <step name="generate_user_setup">
361
- ```bash
362
- grep -A 50 "^user_setup:" .planning/phases/XX-name/{phase}-{plan}-PLAN.md | head -50
363
- ```
417
+ If plan frontmatter contains a `user_setup` field: create `{phase}-USER-SETUP.md` using template `~/.claude/maxsim/templates/user-setup.md`. Per service: env vars table, account setup checklist, dashboard config, local dev notes, verification commands. Status "Incomplete". Set `USER_SETUP_CREATED=true`. If empty/missing: skip.
364
418
 
365
- If user_setup exists: create `{phase}-USER-SETUP.md` using template `~/.claude/maxsim/templates/user-setup.md`. Per service: env vars table, account setup checklist, dashboard config, local dev notes, verification commands. Status "Incomplete". Set `USER_SETUP_CREATED=true`. If empty/missing: skip.
419
+ Also post a reminder comment on the phase issue:
420
+ ```
421
+ mcp_post_comment(
422
+ issue_number: phase_issue_number,
423
+ body: "## User Setup Required\n\nThis plan created a USER-SETUP.md with manual steps needed before proceeding.\n\n**File:** {phase}-USER-SETUP.md\n**Services:** {list of services requiring setup}"
424
+ )
425
+ ```
366
426
  </step>
367
427
 
368
428
  <step name="create_summary">
369
- Create `{phase}-{plan}-SUMMARY.md` at `.planning/phases/XX-name/`. Use `~/.claude/maxsim/templates/summary.md`.
370
429
 
371
- **Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (**MUST** copy `requirements` array from PLAN.md frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date).
430
+ ## Post Summary as GitHub Comment (WIRE-02)
372
431
 
373
- Title: `# Phase [X] Plan [Y]: [Name] Summary`
432
+ Do NOT write a local SUMMARY.md file to `.planning/phases/`. Instead, build the summary content in memory and post it as a GitHub comment.
374
433
 
375
- One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
434
+ Build summary content using the same structure as `~/.claude/maxsim/templates/summary.md`:
376
435
 
377
- Include: duration, start/end times, task count, file count.
436
+ **Content to include:**
437
+ - `<!-- maxsim:type=summary -->` HTML marker at the top (required for detection)
438
+ - Frontmatter: phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (MUST copy `requirements` array from plan frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date)
439
+ - Title: `# Phase [X] Plan [Y]: [Name] Summary`
440
+ - One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
441
+ - Duration, start/end times, task count, file count
442
+ - Next: more plans → "Ready for {next-plan}" | last → "Phase complete, ready for transition"
443
+ - Deviations section (required, even if "None")
444
+ - Review Cycle section (added after review cycle completes)
445
+ - Self-Check result
378
446
 
379
- Next: more plans "Ready for {next-plan}" | last → "Phase complete, ready for transition".
447
+ Post to the phase issue:
448
+ ```
449
+ mcp_post_comment(
450
+ issue_number: phase_issue_number,
451
+ type: "summary",
452
+ body: {summary_content}
453
+ )
454
+ ```
455
+
456
+ Record the comment URL/ID as `SUMMARY_COMMENT_ID` for future reference.
457
+
458
+ **Fallback (no GitHub integration):** Write `{phase}-{plan}-SUMMARY.md` to `.planning/phases/XX-name/` as before.
380
459
  </step>
381
460
 
382
461
  <step name="review_cycle">
383
462
  ## Execute-Review-Simplify-Review Cycle
384
463
 
385
- After implementation is complete and SUMMARY.md is created, run the full review cycle before proceeding. All four stages must pass before the plan is considered done.
464
+ After implementation is complete and summary is drafted (not yet posted), run the full review cycle before posting. All four stages must pass before the plan is considered done.
386
465
 
387
466
  ### Retry Counter Initialization
388
467
 
@@ -424,8 +503,8 @@ Task(
424
503
  </objective>
425
504
 
426
505
  <plan_spec>
427
- Plan file: {phase_dir}/{phase}-{plan}-PLAN.md
428
- Summary file: {phase_dir}/{phase}-{plan}-SUMMARY.md
506
+ Plan content: {plan_content_in_memory or plan file path: {phase_dir}/{phase}-{plan}-PLAN.md}
507
+ Summary content: {summary_content_in_memory}
429
508
  </plan_spec>
430
509
 
431
510
  <task_specs>
@@ -433,11 +512,11 @@ Task(
433
512
  </task_specs>
434
513
 
435
514
  <files_modified>
436
- {List all files created/modified during execution from SUMMARY.md key-files}
515
+ {List all files created/modified during execution from summary key-files}
437
516
  </files_modified>
438
517
 
439
518
  <instructions>
440
- 1. Read the plan file and extract every task requirement
519
+ 1. Read the plan content and extract every task requirement
441
520
  2. For each requirement, verify the implementation exists and matches the spec
442
521
  3. Check that nothing was added beyond scope
443
522
  4. Report: PASS (all requirements met) or FAIL (list unmet requirements)
@@ -448,7 +527,7 @@ Task(
448
527
 
449
528
  3. **If PASS:** Set `SPEC_RESULT="PASS"`, record `SPEC_STAGE_END=$(date +%s)`, proceed to Stage 2.
450
529
 
451
- 4. **If FAIL and SPEC_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Fix the unmet requirements identified by the verifier, re-stage and commit fixes (`fix({phase}-{plan}): address spec review findings`), update SUMMARY.md, then loop back to step 1.
530
+ 4. **If FAIL and SPEC_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Fix the unmet requirements identified by the verifier, re-stage and commit fixes (`fix({phase}-{plan}): address spec review findings`), update summary content in memory, then loop back to step 1.
452
531
 
453
532
  5. **If FAIL and SPEC_ATTEMPTS >= MAX_REVIEW_ATTEMPTS:** Escalate to user:
454
533
 
@@ -463,14 +542,14 @@ The spec review has failed 3 times. This may indicate a fundamental mismatch bet
463
542
 
464
543
  **Options:**
465
544
  1. Fix manually and type "retry" to re-run spec review (resets attempt counter)
466
- 2. Type "override" to skip spec review (will be flagged in SUMMARY.md)
545
+ 2. Type "override" to skip spec review (will be flagged in summary)
467
546
  3. Type "abort" to stop execution
468
547
  ```
469
548
 
470
549
  Wait for user response:
471
550
  - **"retry":** Reset `SPEC_ATTEMPTS=0`, loop back to step 1.
472
551
  - **"override":** Set `SPEC_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `SPEC_STAGE_END=$(date +%s)`, proceed to Stage 2.
473
- - **"abort":** Stop execution, create partial SUMMARY.md with review status.
552
+ - **"abort":** Stop execution, post partial summary with review status.
474
553
 
475
554
  ---
476
555
 
@@ -499,7 +578,7 @@ Task(
499
578
  </objective>
500
579
 
501
580
  <files_modified>
502
- {List all files created/modified during execution from SUMMARY.md key-files}
581
+ {List all files created/modified during execution from summary key-files}
503
582
  </files_modified>
504
583
 
505
584
  <instructions>
@@ -529,14 +608,26 @@ The code review has been blocked 3 times. Remaining issues may require architect
529
608
 
530
609
  **Options:**
531
610
  1. Fix manually and type "retry" to re-run code review (resets attempt counter)
532
- 2. Type "override" to skip code review (will be flagged in SUMMARY.md)
611
+ 2. Type "override" to skip code review (will be flagged in summary)
533
612
  3. Type "abort" to stop execution
534
613
  ```
535
614
 
536
615
  Wait for user response:
537
616
  - **"retry":** Reset `CODE_ATTEMPTS=0`, loop back to step 1.
538
617
  - **"override":** Set `CODE_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `CODE_STAGE_END=$(date +%s)`, proceed to Stage 3.
539
- - **"abort":** Stop execution, create partial SUMMARY.md with review status.
618
+ - **"abort":** Stop execution, post partial summary with review status.
619
+
620
+ **On review failure -- reopen affected task sub-issues (WIRE-07):**
621
+
622
+ If the code review identifies failures tied to specific tasks, and those task sub-issues were already closed:
623
+ ```
624
+ mcp_reopen_issue(issue_number: task_sub_issue_number)
625
+ mcp_move_issue(issue_number: task_sub_issue_number, status: "In Progress")
626
+ mcp_post_comment(
627
+ issue_number: task_sub_issue_number,
628
+ body: "## Code Review Failure\n\nThis task's code review was blocked. Moving back to In Progress.\n\n**Blocking issues:**\n{list of blocker/high issues from verifier}"
629
+ )
630
+ ```
540
631
 
541
632
  ---
542
633
 
@@ -572,7 +663,7 @@ Task(
572
663
  </objective>
573
664
 
574
665
  <files_to_review>
575
- {List all files created/modified during execution from SUMMARY.md key-files}
666
+ {List all files created/modified during execution from summary key-files}
576
667
  </files_to_review>
577
668
 
578
669
  <instructions>
@@ -602,7 +693,7 @@ Task(
602
693
  </objective>
603
694
 
604
695
  <files_to_review>
605
- {List all files created/modified during execution from SUMMARY.md key-files}
696
+ {List all files created/modified during execution from summary key-files}
606
697
  </files_to_review>
607
698
 
608
699
  <instructions>
@@ -632,7 +723,7 @@ Task(
632
723
  </objective>
633
724
 
634
725
  <files_to_review>
635
- {List all files created/modified during execution from SUMMARY.md key-files}
726
+ {List all files created/modified during execution from summary key-files}
636
727
  </files_to_review>
637
728
 
638
729
  <instructions>
@@ -669,7 +760,7 @@ Task(
669
760
  </findings>
670
761
 
671
762
  <files_to_review>
672
- {List all files created/modified during execution from SUMMARY.md key-files}
763
+ {List all files created/modified during execution from summary key-files}
673
764
  </files_to_review>
674
765
 
675
766
  <instructions>
@@ -699,14 +790,14 @@ The simplify stage has been blocked 3 times. Remaining issues require architectu
699
790
 
700
791
  **Options:**
701
792
  1. Fix manually and type "retry" to re-run simplify (resets attempt counter)
702
- 2. Type "override" to skip simplify (will be flagged in SUMMARY.md)
793
+ 2. Type "override" to skip simplify (will be flagged in summary)
703
794
  3. Type "abort" to stop execution
704
795
  ```
705
796
 
706
797
  Wait for user response:
707
798
  - **"retry":** Reset `SIMPLIFY_ATTEMPTS=0`, re-run 3 reviewers.
708
799
  - **"override":** Set `SIMPLIFY_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `SIMPLIFY_STAGE_END=$(date +%s)`, skip Stage 4. Set `FINAL_RESULT="N/A"`.
709
- - **"abort":** Stop execution, create partial SUMMARY.md with review status.
800
+ - **"abort":** Stop execution, post partial summary with review status.
710
801
 
711
802
  ---
712
803
 
@@ -774,14 +865,14 @@ The final review has been blocked 3 times after simplification changes.
774
865
 
775
866
  **Options:**
776
867
  1. Fix manually and type "retry" to re-run final review (resets attempt counter)
777
- 2. Type "override" to skip final review (will be flagged in SUMMARY.md)
868
+ 2. Type "override" to skip final review (will be flagged in summary)
778
869
  3. Type "abort" to stop execution
779
870
  ```
780
871
 
781
872
  Wait for user response:
782
873
  - **"retry":** Reset `FINAL_ATTEMPTS=0`, loop back to step 1.
783
874
  - **"override":** Set `FINAL_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `FINAL_STAGE_END=$(date +%s)`, proceed to review cycle tracking.
784
- - **"abort":** Stop execution, create partial SUMMARY.md with review status.
875
+ - **"abort":** Stop execution, post partial summary with review status.
785
876
 
786
877
  ---
787
878
 
@@ -802,7 +893,7 @@ SIMPLIFY_DURATION=$(( SIMPLIFY_STAGE_END - SIMPLIFY_STAGE_START )) # or "N/A" i
802
893
  FINAL_DURATION=$(( FINAL_STAGE_END - FINAL_STAGE_START )) # or "N/A" if skipped
803
894
  ```
804
895
 
805
- Record review results in SUMMARY.md under a `## Review Cycle` section:
896
+ Add review cycle results to the summary content in memory (under a `## Review Cycle` section):
806
897
  ```markdown
807
898
  ## Review Cycle
808
899
 
@@ -817,26 +908,36 @@ Record review results in SUMMARY.md under a `## Review Cycle` section:
817
908
  **Escalations:** {REVIEW_ESCALATIONS} ({REVIEW_ESCALATION_DETAILS or "None"})
818
909
  ```
819
910
 
820
- Update the SUMMARY.md commit after the review cycle completes:
911
+ Now post the complete summary (with review cycle included) to GitHub:
912
+ ```
913
+ mcp_post_comment(
914
+ issue_number: phase_issue_number,
915
+ type: "summary",
916
+ body: {complete_summary_content_including_review_cycle}
917
+ )
918
+ ```
919
+
920
+ After posting, commit any review-cycle metadata:
821
921
  ```bash
822
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): add review cycle results" --files {phase_dir}/{phase}-{plan}-SUMMARY.md
922
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): add review cycle results" --files .planning/STATE.md .planning/ROADMAP.md
823
923
  ```
824
924
  </step>
825
925
 
826
926
  <step name="evidence_gate">
827
- **Gate G6: Evidence Completeness** — SUMMARY.md must have evidence for each requirement.
927
+ **Gate G6: Evidence Completeness** — Summary must have evidence for each requirement.
828
928
 
829
- After the review cycle and before committing metadata, validate that the SUMMARY.md contains requirement evidence for all requirements in the plan's frontmatter.
929
+ After the review cycle and before finalizing, validate that the summary content contains requirement evidence for all requirements in the plan's frontmatter.
830
930
 
831
931
  ```bash
832
932
  if [ -n "$REQ_IDS" ]; then
833
- SUMMARY_PATH=".planning/phases/XX-name/{phase}-{plan}-SUMMARY.md"
834
- G6_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify evidence-completeness "$SUMMARY_PATH" $REQ_IDS)
933
+ # Write summary content to a temp file for verification
934
+ echo "$SUMMARY_CONTENT" > /tmp/summary-check.md
935
+ G6_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify evidence-completeness "/tmp/summary-check.md" $REQ_IDS)
835
936
  G6_VALID=$(echo "$G6_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).valid))")
836
937
  if [ "$G6_VALID" != "true" ]; then
837
938
  G6_MISSING=$(echo "$G6_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).missing_evidence.join(', ')))")
838
939
  echo "GATE G6: Missing requirement evidence for: $G6_MISSING"
839
- echo "Add Requirement Evidence rows to SUMMARY.md for these requirements before proceeding."
940
+ echo "Add Requirement Evidence rows to summary for these requirements before posting."
840
941
  # Present as warning with instruction to fix — executor should add evidence
841
942
  fi
842
943
  fi
@@ -861,10 +962,10 @@ node ~/.claude/maxsim/bin/maxsim-tools.cjs state record-metric \
861
962
  </step>
862
963
 
863
964
  <step name="extract_decisions_and_issues">
864
- From SUMMARY: Extract decisions and add to STATE.md:
965
+ From summary content: Extract decisions and add to STATE.md:
865
966
 
866
967
  ```bash
867
- # Add each decision from SUMMARY key-decisions
968
+ # Add each decision from summary key-decisions
868
969
  # Prefer file inputs for shell-safe text (preserves `$`, `*`, etc. exactly)
869
970
  node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision \
870
971
  --phase "${PHASE}" --summary-file "${DECISION_TEXT_FILE}" --rationale-file "${RATIONALE_FILE}"
@@ -887,32 +988,63 @@ Keep STATE.md under 150 lines.
887
988
  </step>
888
989
 
889
990
  <step name="issues_review_gate">
890
- If SUMMARY "Issues Encountered" ≠ "None": yolo → log and continue. Interactive → present issues, wait for acknowledgment.
991
+ If summary "Issues Encountered" ≠ "None": yolo → log and continue. Interactive → present issues, wait for acknowledgment.
891
992
  </step>
892
993
 
893
994
  <step name="update_roadmap">
894
995
  ```bash
895
996
  node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap update-plan-progress "${PHASE}"
896
997
  ```
897
- Counts PLAN vs SUMMARY files on disk. Updates progress table row with correct count and status (`In Progress` or `Complete` with date).
998
+ Counts completed task sub-issues (or PLAN vs SUMMARY files in fallback mode) on disk. Updates progress table row with correct count and status (`In Progress` or `Complete` with date).
898
999
  </step>
899
1000
 
900
1001
  <step name="update_requirements">
901
- Mark completed requirements from the PLAN.md frontmatter `requirements:` field:
1002
+ Mark completed requirements from the plan's frontmatter `requirements:` field:
902
1003
 
903
1004
  ```bash
904
1005
  node ~/.claude/maxsim/bin/maxsim-tools.cjs requirements mark-complete ${REQ_IDS}
905
1006
  ```
906
1007
 
907
- Extract requirement IDs from the plan's frontmatter (e.g., `requirements: [AUTH-01, AUTH-02]`). If no requirements field, skip.
1008
+ Extract requirement IDs from the plan frontmatter (e.g., `requirements: [AUTH-01, AUTH-02]`). If no requirements field, skip.
908
1009
  </step>
909
1010
 
910
1011
  <step name="git_commit_metadata">
911
1012
  Task code already committed per-task. Commit plan metadata:
912
1013
 
913
1014
  ```bash
914
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): complete [plan-name] plan" --files .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
1015
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): complete [plan-name] plan" --files .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
1016
+ ```
1017
+
1018
+ Note: No local SUMMARY.md is committed -- summary was posted to GitHub as a comment.
1019
+ </step>
1020
+
1021
+ <step name="post_verification_to_github">
1022
+
1023
+ ## Post Verification Results as GitHub Comment
1024
+
1025
+ If the plan includes verification criteria (from `<verification>` section of plan content):
1026
+
1027
+ Build verification results content in memory with `<!-- maxsim:type=verification -->` marker.
1028
+
915
1029
  ```
1030
+ mcp_post_comment(
1031
+ issue_number: phase_issue_number,
1032
+ type: "verification",
1033
+ body: "<!-- maxsim:type=verification -->\n## Plan {plan_number} Verification\n\n{verification_results}\n\n**Status:** {passed|failed}\n**Timestamp:** {ISO timestamp}"
1034
+ )
1035
+ ```
1036
+
1037
+ If the plan includes UAT criteria (from `<uat>` section):
1038
+
1039
+ ```
1040
+ mcp_post_comment(
1041
+ issue_number: phase_issue_number,
1042
+ type: "uat",
1043
+ body: "<!-- maxsim:type=uat -->\n## Plan {plan_number} UAT\n\n{uat_criteria_and_results}\n\n**Status:** {pending|passed|failed}\n**Timestamp:** {ISO timestamp}"
1044
+ )
1045
+ ```
1046
+
1047
+ **Fallback (no GitHub integration):** Write VERIFICATION.md and UAT.md to the phase directory as before.
916
1048
  </step>
917
1049
 
918
1050
  <step name="update_codebase_map">
@@ -933,6 +1065,14 @@ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "" --files .planning/codebase/
933
1065
  <step name="offer_next">
934
1066
  If `USER_SETUP_CREATED=true`: display `⚠️ USER SETUP REQUIRED` with path + env/config tasks at TOP.
935
1067
 
1068
+ Check completion by querying the phase issue's task sub-issues:
1069
+ ```
1070
+ mcp_list_sub_issues(issue_number: phase_issue_number)
1071
+ ```
1072
+
1073
+ Count open vs closed sub-issues. Map closed count to plans complete.
1074
+
1075
+ Fallback (no GitHub):
936
1076
  ```bash
937
1077
  ls -1 .planning/phases/[current-phase-dir]/*-PLAN.md 2>/dev/null | wc -l
938
1078
  ls -1 .planning/phases/[current-phase-dir]/*-SUMMARY.md 2>/dev/null | wc -l
@@ -940,9 +1080,9 @@ ls -1 .planning/phases/[current-phase-dir]/*-SUMMARY.md 2>/dev/null | wc -l
940
1080
 
941
1081
  | Condition | Route | Action |
942
1082
  |-----------|-------|--------|
943
- | summaries < plans | **A: More plans** | Find next PLAN without SUMMARY. Yolo: auto-continue. Interactive: show next plan, suggest `/maxsim:execute {phase}`. STOP here. |
944
- | summaries = plans, current < highest phase | **B: Phase done** | Show completion, suggest `/maxsim:plan {Z+1}`. |
945
- | summaries = plans, current = highest phase | **C: Milestone done** | Show banner, suggest `/maxsim:progress`. |
1083
+ | open task sub-issues remain | **A: More plans** | Find next incomplete plan (by open sub-issues or missing summary comment). Yolo: auto-continue. Interactive: show next plan, suggest `/maxsim:execute {phase}`. STOP here. |
1084
+ | all sub-issues closed, current < highest phase | **B: Phase done** | Show completion, suggest `/maxsim:plan {Z+1}`. |
1085
+ | all sub-issues closed, current = highest phase | **C: Milestone done** | Show banner, suggest `/maxsim:progress`. |
946
1086
 
947
1087
  All routes: `/clear` first for fresh context.
948
1088
  </step>
@@ -951,10 +1091,13 @@ All routes: `/clear` first for fresh context.
951
1091
 
952
1092
  <success_criteria>
953
1093
 
954
- - All tasks from PLAN.md completed
1094
+ - All tasks from plan completed
955
1095
  - All verifications pass
956
1096
  - USER-SETUP.md generated if user_setup in frontmatter
957
- - SUMMARY.md created with substantive content
1097
+ - Summary posted as GitHub comment with `<!-- maxsim:type=summary -->` marker (not written to local SUMMARY.md)
1098
+ - Verification and UAT posted as GitHub comments with appropriate type markers
1099
+ - Task sub-issues moved: In Progress when started, Done when completed (WIRE-04)
1100
+ - On review failure: task sub-issues reopened and moved back to In Progress (WIRE-07)
958
1101
  - STATE.md updated (position, decisions, issues, session)
959
1102
  - ROADMAP.md updated
960
1103
  - If codebase map exists: map updated with execution changes (or skipped if no significant changes)