diff --git a/.claude/commands/mgw/init.md b/.claude/commands/mgw/init.md index b589ded..b901eb0 100644 --- a/.claude/commands/mgw/init.md +++ b/.claude/commands/mgw/init.md @@ -199,6 +199,15 @@ If exists → report "PR template already exists, skipping." ```bash gh label create "bug" --description "Something isn't working" --color "d73a4a" --force gh label create "enhancement" --description "New feature or improvement" --color "a2eeef" --force + +# MGW pipeline labels +gh label create "mgw:triaged" --description "Issue triaged and ready for pipeline" --color "0e8a16" --force +gh label create "mgw:needs-info" --description "Blocked — needs more detail or clarification" --color "e4e669" --force +gh label create "mgw:needs-security-review" --description "Blocked — requires security review" --color "d93f0b" --force +gh label create "mgw:discussing" --description "Under discussion — not yet approved" --color "c5def5" --force +gh label create "mgw:approved" --description "Discussion complete — approved for execution" --color "0e8a16" --force +gh label create "mgw:in-progress" --description "Pipeline actively executing" --color "1d76db" --force +gh label create "mgw:blocked" --description "Pipeline blocked by stakeholder comment" --color "b60205" --force ``` `--force` updates existing labels without error. @@ -218,6 +227,7 @@ gh label create "enhancement" --description "New feature or improvement" --color Issue templates ${created|exists} PR template ${created|exists} GitHub labels synced + MGW pipeline labels synced (7 labels) Ready to use: /mgw:issues Browse issues @@ -235,5 +245,6 @@ Ready to use: - [ ] Issue templates created (bug + enhancement) - [ ] PR template created - [ ] GitHub labels ensured (bug, enhancement) +- [ ] MGW pipeline labels ensured (7 mgw:* labels) - [ ] Setup report shown diff --git a/.claude/commands/mgw/issue.md b/.claude/commands/mgw/issue.md index 8167638..5a9c3ac 100644 --- a/.claude/commands/mgw/issue.md +++ b/.claude/commands/mgw/issue.md @@ -201,10 +201,129 @@ Return a structured report: ``` + +**Evaluate triage quality gates:** + +After the analysis agent returns, evaluate three quality gates against the triage report +and the original issue data. This determines whether the issue can proceed to pipeline +execution or requires additional information/review. + +Initialize gate result: +``` +gate_result = { + "status": "passed", + "blockers": [], + "warnings": [], + "missing_fields": [] +} +``` + +**Gate 1: Validity** +``` +if triage.validity == "invalid": + gate_result.blockers.push("Validity gate failed: issue could not be confirmed against codebase") + gate_result.status = "blocked" +``` + +**Gate 2: Security** +``` +if triage.security_risk == "high": + gate_result.blockers.push("Security gate: high-risk issue requires security review before execution") + gate_result.status = "blocked" +``` + +**Gate 3: Detail Sufficiency** +Evaluate the original issue body (not the triage report): +``` +BODY_LENGTH = len(issue_body.strip()) +HAS_AC = issue has acceptance criteria field filled OR body contains "- [ ]" checklist items +IS_FEATURE = "enhancement" in issue_labels OR issue template is feature_request + +if BODY_LENGTH < 200: + gate_result.blockers.push("Insufficient detail: issue body is ${BODY_LENGTH} characters (minimum 200)") + gate_result.missing_fields.push("Expand issue description with more detail") + gate_result.status = "blocked" + +if IS_FEATURE and not HAS_AC: + gate_result.blockers.push("Feature requests require acceptance criteria") + gate_result.missing_fields.push("Add acceptance criteria (checklist of testable conditions)") + gate_result.status = "blocked" +``` + +**Gate warnings (non-blocking):** +``` +if triage.security_risk == "medium": + gate_result.warnings.push("Medium security risk — consider review before execution") + +if triage.scope.size == "large" and gsd_route != "gsd:new-milestone": + gate_result.warnings.push("Large scope detected but not routed to new-milestone") +``` + +Set `gate_result.status = "passed"` if no blockers. Store gate_result for state file. + + + +**Post immediate triage feedback to GitHub:** + +This step posts a comment on the GitHub issue IMMEDIATELY during /mgw:issue, not +deferred to /mgw:run. This gives stakeholders visibility into triage results as +soon as they happen. + +Generate timestamp: +```bash +TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") +``` + +**If gates blocked (gate_result.status == "blocked"):** + +Build gate table rows from gate_result.blockers: +``` +GATE_TABLE_ROWS = gate_result.blockers formatted as "| ${blocker} | Blocked |" rows +``` + +Build missing fields list from gate_result.missing_fields: +``` +MISSING_FIELDS_LIST = gate_result.missing_fields formatted as "- ${field}" list +``` + +Use the "Gate Blocked Comment" template from @~/.claude/commands/mgw/workflows/github.md. +Post comment and apply label: +```bash +# Use remove_mgw_labels_and_apply pattern from github.md +# For validity failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# For security failures: +# pipeline_stage = "needs-security-review", label = "mgw:needs-security-review" +# For detail failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# If multiple blockers, use the highest-severity label (security > detail > validity) +``` + +**If gates passed (gate_result.status == "passed"):** + +Use the "Gate Passed Comment" template from @~/.claude/commands/mgw/workflows/github.md. + +Populate template variables: +``` +SCOPE_SIZE = triage.scope.size +FILE_COUNT = triage.scope.file_count +SYSTEM_LIST = triage.scope.systems joined with ", " +VALIDITY = triage.validity +SECURITY_RISK = triage.security_notes +gsd_route = recommended route +ROUTE_REASONING = triage reasoning +``` + +Post comment and apply label: +```bash +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:triaged" 2>/dev/null +``` + + **Present triage report to user:** -Display the analysis agent's report verbatim, then: +Display the analysis agent's report verbatim, then display gate results: ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -213,18 +332,48 @@ Display the analysis agent's report verbatim, then: Recommended route: ${recommended_route} Reasoning: ${reasoning} +``` + +Then display gate results: -Options: - 1) Accept recommendation → proceed with ${recommended_route} - 2) Override route → choose different GSD entry point - 3) Reject → issue is invalid or out of scope +``` +${if gate_result.status == "blocked":} + GATES: BLOCKED + ${for blocker in gate_result.blockers:} + - ${blocker} + ${end} + + ${if gate_result.missing_fields:} + Missing information: + ${for field in gate_result.missing_fields:} + - ${field} + ${end} + ${end} + + The issue needs updates before pipeline execution. + Options: + 1) Wait for updates → issue stays in needs-info/needs-security-review + 2) Override → proceed despite gate failures (adds acknowledgment to state) + 3) Reject → issue is invalid or out of scope + +${else:} + GATES: PASSED ${if gate_result.warnings: '(with warnings)'} + ${for warning in gate_result.warnings:} + - Warning: ${warning} + ${end} + + Options: + 1) Accept recommendation → proceed with ${recommended_route} + 2) Override route → choose different GSD entry point + 3) Reject → issue is invalid or out of scope +${end} ``` ``` AskUserQuestion( header: "Triage Decision", - question: "Accept recommendation (1), override (2), or reject (3)?", - followUp: "If overriding, specify: quick, quick --full, or new-milestone" + question: "${gate_result.status == 'blocked' ? 'Override gates (1), wait for updates (2), or reject (3)?' : 'Accept recommendation (1), override (2), or reject (3)?'}", + followUp: "${gate_result.status == 'blocked' ? 'Override will log acknowledgment. Wait keeps issue in blocked state.' : 'If overriding, specify: quick, quick --full, or new-milestone'}" ) ``` @@ -232,7 +381,7 @@ AskUserQuestion( **Write issue state file:** -If accepted or overridden (not rejected): +If accepted, overridden, or gates blocked but user overrides (not rejected, not "wait"): Generate slug from title using gsd-tools: ```bash @@ -246,8 +395,13 @@ Populate: - triage: from analysis report - triage.last_comment_count: from $COMMENT_COUNT (captured in fetch_issue step) - triage.last_comment_at: from $LAST_COMMENT_AT (captured in fetch_issue step, null if no comments) +- triage.gate_result: from gate_result evaluation (status, blockers, warnings, missing_fields) - gsd_route: confirmed or overridden route -- pipeline_stage: "triaged" +- pipeline_stage: set based on gate outcome: + - Gates blocked + validity failure (and not overridden): `"needs-info"` + - Gates blocked + security failure (and not overridden): `"needs-security-review"` + - Gates blocked + user overrides: `"triaged"` (with override_log entry noting acknowledged gate failures) + - Gates passed: `"triaged"` - All other fields: defaults (empty arrays, null) Also add branch cross-ref: @@ -260,7 +414,7 @@ Add to linked_branches if not main/master. **Offer next steps:** -If accepted/overridden: +If accepted/overridden (gates passed): ``` Issue #${ISSUE_NUMBER} triaged and tracked in .mgw/active/${filename}. @@ -269,6 +423,25 @@ Next steps: → /mgw:update ${ISSUE_NUMBER} — Post triage comment to GitHub ``` +If gates blocked and user chose "wait" (no state file written): +``` +Issue #${ISSUE_NUMBER} is blocked pending more information. +A comment has been posted to GitHub explaining what's needed. + +When the issue is updated: + → /mgw:issue ${ISSUE_NUMBER} — Re-triage with updated context +``` + +If gates blocked and user overrode: +``` +Issue #${ISSUE_NUMBER} triaged with gate override. Tracked in .mgw/active/${filename}. + +Note: Gate failures acknowledged. Override logged in state. + +Next steps: + → /mgw:run ${ISSUE_NUMBER} — Start autonomous pipeline +``` + If rejected: ``` Issue #${ISSUE_NUMBER} rejected. No state file created. @@ -285,7 +458,12 @@ Consider closing or commenting on the issue with your reasoning. - [ ] Analysis agent spawned and returned structured report - [ ] Scope, validity, security, conflicts all assessed - [ ] GSD route recommended with reasoning +- [ ] Triage gates evaluated (validity, security, detail sufficiency) +- [ ] Gate result stored in state file +- [ ] Triage comment posted IMMEDIATELY to GitHub +- [ ] Blocked issues get appropriate mgw: label (mgw:needs-info or mgw:needs-security-review) +- [ ] Passed issues get mgw:triaged label - [ ] User confirms, overrides, or rejects -- [ ] State file written to .mgw/active/ (if accepted) with comment tracking fields +- [ ] State file written to .mgw/active/ (if accepted) with comment tracking fields and gate_result - [ ] Next steps offered diff --git a/.claude/commands/mgw/review.md b/.claude/commands/mgw/review.md index 2e1bb12..9a930e1 100644 --- a/.claude/commands/mgw/review.md +++ b/.claude/commands/mgw/review.md @@ -124,25 +124,32 @@ Classify each comment (and the overall batch) into ONE of: Examples: 'Don't work on this yet', 'Hold off', 'Blocked by external dependency', 'Wait for design review'. +- **resolution** — Comment indicates a previously identified blocker or issue has been resolved. + Examples: 'The dependency has been updated', 'Security review complete — approved', + 'Added the missing acceptance criteria', 'Updated the issue with more detail', + 'Fixed the blocking issue in #42'. + If ANY comment in the batch is blocking, overall classification is blocking. -If ANY comment is material (and none blocking), overall classification is material. +If ANY comment is resolution (and none blocking), overall classification is resolution. +If ANY comment is material (and none blocking/resolution), overall classification is material. Otherwise, informational. Return ONLY valid JSON: { - \"classification\": \"material|informational|blocking\", + \"classification\": \"material|informational|blocking|resolution\", \"reasoning\": \"Brief explanation of why this classification was chosen\", \"per_comment\": [ { \"author\": \"username\", \"snippet\": \"first 100 chars of comment\", - \"classification\": \"material|informational|blocking\" + \"classification\": \"material|informational|blocking|resolution\" } ], \"new_requirements\": [\"list of new requirements if material, empty array otherwise\"], - \"blocking_reason\": \"reason if blocking, empty string otherwise\" + \"blocking_reason\": \"reason if blocking, empty string otherwise\", + \"resolved_blocker\": \"description of what was resolved, empty string otherwise\" } ", @@ -216,6 +223,27 @@ AskUserQuestion( ``` If block: update `pipeline_stage = "blocked"` and `triage.last_comment_count` in state. If override: update `triage.last_comment_count` only, keep pipeline_stage. + +**If resolution:** +``` +AskUserQuestion( + header: "Blocker Resolution Detected", + question: "A previous blocker appears to be resolved. Re-triage this issue?", + options: [ + { label: "Re-triage", description: "Run /mgw:issue to re-analyze with updated context" }, + { label: "Acknowledge", description: "Update comment count, keep current pipeline stage" }, + { label: "Ignore", description: "Don't update state" } + ] +) +``` +If re-triage: + - Update `triage.last_comment_count` + - Suggest: "Run `/mgw:issue ${ISSUE_NUMBER}` to re-triage with the resolved context." + - If pipeline_stage is "blocked" or "needs-info" or "needs-security-review", note: + "Re-triage will re-evaluate gates and may unblock the pipeline." +If acknowledge: + - Update `triage.last_comment_count` + - Keep current pipeline_stage @@ -228,4 +256,5 @@ If override: update `triage.last_comment_count` only, keep pipeline_stage. - [ ] Classification presented to user with per-comment breakdown - [ ] User chose action (acknowledge/re-triage/block/ignore) - [ ] State file updated according to user choice +- [ ] Resolution classification type supported with re-triage prompt diff --git a/.claude/commands/mgw/run.md b/.claude/commands/mgw/run.md index bebfe1e..7a6a780 100644 --- a/.claude/commands/mgw/run.md +++ b/.claude/commands/mgw/run.md @@ -78,6 +78,34 @@ If state file exists → load it. Check pipeline_stage: - "planning" / "executing" → resume from where we left off - "blocked" → "Pipeline for #${ISSUE_NUMBER} is blocked by a stakeholder comment. Review the issue comments, resolve the blocker, then re-run." - "pr-created" / "done" → "Pipeline already completed for #${ISSUE_NUMBER}. Run /mgw:sync to reconcile." + - "needs-info" → Check for --force flag in $ARGUMENTS: + If --force NOT present: + ``` + Pipeline for #${ISSUE_NUMBER} is blocked by triage gate (needs-info). + The issue requires more detail before execution can begin. + + To override: /mgw:run ${ISSUE_NUMBER} --force + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage after updating the issue) + ``` + STOP. + If --force present: + Log warning: "MGW: WARNING — Overriding needs-info gate for #${ISSUE_NUMBER}. Proceeding with --force." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. + - "needs-security-review" → Check for --security-ack flag in $ARGUMENTS: + If --security-ack NOT present: + ``` + Pipeline for #${ISSUE_NUMBER} requires security review. + This issue was flagged as high security risk during triage. + + To acknowledge and proceed: /mgw:run ${ISSUE_NUMBER} --security-ack + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage) + ``` + STOP. + If --security-ack present: + Log warning: "MGW: WARNING — Acknowledging security risk for #${ISSUE_NUMBER}. Proceeding with --security-ack." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. @@ -119,6 +147,13 @@ cd "${WORKTREE_DIR}" Update state (at `${REPO_ROOT}/.mgw/active/`): add branch to linked_branches. Add cross-ref (at `${REPO_ROOT}/.mgw/cross-refs.json`): issue → branch. +**Apply in-progress label:** +```bash +# Use remove_mgw_labels_and_apply pattern from github.md +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:triaged" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:in-progress" 2>/dev/null +``` + **PATH CONVENTION for remaining steps:** - File operations, git commands, and agent work use **relative paths** (CWD = worktree) - `.mgw/` state operations use **absolute paths**: `${REPO_ROOT}/.mgw/` @@ -212,14 +247,34 @@ Return ONLY valid JSON: | Classification | Action | |---------------|--------| | **informational** | Log: "MGW: ${NEW_COUNT} new comment(s) reviewed — informational, continuing." Update `triage.last_comment_count` in state file. Continue pipeline. | -| **material** | Log: "MGW: Material comment(s) detected — scope may have changed." Update state: add new_requirements to triage context. Update `triage.last_comment_count`. Re-read issue body for updated requirements. Continue with enriched context (pass new_requirements to planner). | -| **blocking** | Log: "MGW: Blocking comment detected — pipeline paused." Update state: `pipeline_stage = "blocked"`. Post comment on issue: `> **MGW** . \`pipeline-blocked\` . Blocked by stakeholder comment. Reason: ${blocking_reason}`. Stop pipeline execution. | +| **material** | Log: "MGW: Material comment(s) detected — scope may have changed." Update state: add new_requirements to triage context. Update `triage.last_comment_count`. Re-read issue body for updated requirements. Continue with enriched context (pass new_requirements to planner). Check for security keywords in material comments (see below). | +| **blocking** | Log: "MGW: Blocking comment detected — pipeline paused." Update state: `pipeline_stage = "blocked"`. Apply mgw:blocked label. Post comment on issue: `> **MGW** . \`pipeline-blocked\` . Blocked by stakeholder comment. Reason: ${blocking_reason}`. Stop pipeline execution. | + +**Security keyword check for material comments:** +```bash +SECURITY_KEYWORDS="security|vulnerability|CVE|exploit|injection|XSS|CSRF|auth bypass" +if echo "$NEW_COMMENTS" | grep -qiE "$SECURITY_KEYWORDS"; then + # Add warning to gate_result and prompt user + echo "MGW: Security-related comment detected. Re-triage recommended." + # Prompt: "Security-related comment detected. Re-triage recommended. Continue or re-triage?" +fi +``` + +**When blocking comment detected — apply label:** +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:blocked" 2>/dev/null +``` If no new comments detected, continue normally. -**Post structured triage comment on issue:** +**Post work-starting comment on issue:** + +Note: The triage gate evaluation and triage-complete/triage-blocked comment are now +posted IMMEDIATELY during /mgw:issue. This step posts a separate work-starting +notification when pipeline execution actually begins in run.md. Gather enrichment data from triage state: ```bash @@ -227,8 +282,6 @@ SCOPE_SIZE="${triage.scope.size}" # small|medium|large FILE_COUNT="${triage.scope.file_count}" SYSTEM_LIST="${triage.scope.systems}" FILE_LIST="${triage.scope.files}" -VALIDITY="${triage.validity}" -SECURITY_RISK="${triage.security_notes}" CONFLICTS="${triage.conflicts}" ROUTE_REASONING="${triage.route_reasoning}" TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") @@ -248,21 +301,19 @@ for m in p['milestones']: fi ``` -Post the triage comment directly (no sub-agent — guarantees it happens): +Post the work-starting comment directly (no sub-agent — guarantees it happens): ```bash -TRIAGE_BODY=$(cat < **MGW** · \`triage-complete\` · ${TIMESTAMP} +WORK_STARTING_BODY=$(cat < **MGW** · \`work-starting\` · ${TIMESTAMP} > ${MILESTONE_CONTEXT} -### Triage Complete +### Work Starting | | | |---|---| -| **Scope** | ${SCOPE_SIZE} — ${FILE_COUNT} files across ${SYSTEM_LIST} | -| **Validity** | ${VALIDITY} | -| **Security** | ${SECURITY_RISK} | | **Route** | \`${gsd_route}\` — ${ROUTE_REASONING} | +| **Scope** | ${SCOPE_SIZE} — ${FILE_COUNT} files across ${SYSTEM_LIST} | | **Conflicts** | ${CONFLICTS} | Work begins on branch \`${BRANCH_NAME}\`. @@ -276,7 +327,7 @@ ${FILE_LIST as bullet points} COMMENTEOF ) -gh issue comment ${ISSUE_NUMBER} --body "$TRIAGE_BODY" 2>/dev/null || true +gh issue comment ${ISSUE_NUMBER} --body "$WORK_STARTING_BODY" 2>/dev/null || true ``` Log comment in state file (at `${REPO_ROOT}/.mgw/active/`). @@ -504,7 +555,45 @@ EXECUTOR_MODEL=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs resolve-model gs VERIFIER_MODEL=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs resolve-model gsd-verifier --raw) ``` -1. **Create milestone:** Use `gsd-tools init new-milestone` to gather context, then attempt autonomous roadmap creation from issue data: +1. **Discussion phase trigger for large-scope issues:** + +If the issue was triaged with large scope and `gsd_route == "gsd:new-milestone"`, post +a scope proposal comment and set the discussing stage before proceeding to phase execution: + +```bash +DISCUSS_TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") + +# Build scope breakdown from triage data +SCOPE_SIZE="${triage.scope.size}" +SCOPE_BREAKDOWN="${triage.scope.files formatted as table rows}" +PHASE_COUNT="TBD (determined by roadmapper)" + +# Post scope proposal comment using template from github.md +# Use Scope Proposal Comment template from @~/.claude/commands/mgw/workflows/github.md +``` + +Set pipeline_stage to "discussing" and apply "mgw:discussing" label: +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:discussing" 2>/dev/null +``` + +Present to user: +``` +AskUserQuestion( + header: "Scope Proposal Posted", + question: "A scope proposal has been posted to GitHub. Proceed with autonomous roadmap creation, or wait for stakeholder feedback?", + options: [ + { label: "Proceed", description: "Continue with roadmap creation now" }, + { label: "Wait", description: "Pipeline paused until stakeholder approves scope" } + ] +) +``` + +If wait: stop here. User will re-run /mgw:run after scope is approved. +If proceed: apply "mgw:approved" label and continue. + +2. **Create milestone:** Use `gsd-tools init new-milestone` to gather context, then attempt autonomous roadmap creation from issue data: ```bash MILESTONE_INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs init new-milestone 2>/dev/null) @@ -536,29 +625,166 @@ VERIFIER_MODEL=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs resolve-model gs Update pipeline_stage to "planning" (at `${REPO_ROOT}/.mgw/active/`). 2. **If resuming with pipeline_stage = "planning" and ROADMAP.md exists:** - Read ROADMAP.md to find phases. For each phase: + Discover phases from ROADMAP and run the full per-phase GSD lifecycle: - a. Spawn discuss + plan via task agents (following gsd:plan-phase workflow) - b. Spawn executor(s) via task agents (following gsd:execute-phase workflow) - c. Spawn verifier - d. Post phase update comment directly (no sub-agent): + ```bash + ROADMAP_ANALYSIS=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs roadmap analyze) + # Parse ROADMAP_ANALYSIS JSON for list of phases: + # Each phase has: phase_number, phase_name, phase_slug + PHASE_LIST=$(echo "$ROADMAP_ANALYSIS" | python3 -c " + import json, sys + data = json.load(sys.stdin) + for p in data.get('phases', []): + print(f\"{p['number']}|{p['name']}|{p.get('slug', '')}\") + ") + ``` + + For each phase in order: + + **a. Scaffold phase directory, then init:** + + `init plan-phase` requires the phase directory to exist before it can locate it. + Use `scaffold phase-dir` first (which creates the directory from ROADMAP data), + then call `init plan-phase` to get planner/checker model assignments. + + ```bash + # Generate slug from phase name (lowercase, hyphens, no special chars) + PHASE_SLUG=$(echo "${PHASE_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//') + + # Scaffold creates the directory and returns the path + SCAFFOLD=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs scaffold phase-dir --phase "${PHASE_NUMBER}" --name "${PHASE_SLUG}") + phase_dir=$(echo "$SCAFFOLD" | python3 -c "import json,sys; print(json.load(sys.stdin)['directory'])") + + # Now init plan-phase can find the directory for model resolution + PHASE_INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs init plan-phase "${PHASE_NUMBER}") + # Parse PHASE_INIT JSON for: planner_model, checker_model + ``` + + **b. Spawn planner agent (gsd:plan-phase):** + ``` + Task( + prompt=" + + - ./CLAUDE.md (Project instructions -- if exists, follow all guidelines) + - .agents/skills/ (Project skills -- if dir exists, list skills, read SKILL.md for each, follow relevant rules) + - .planning/ROADMAP.md (Phase definitions and requirements) + - .planning/STATE.md (If exists -- project state) + + + You are the GSD planner. Plan phase ${PHASE_NUMBER}: ${PHASE_NAME}. + + Read and follow the plan-phase workflow: + @~/.claude/get-shit-done/workflows/plan-phase.md + + Phase directory: ${phase_dir} + Phase number: ${PHASE_NUMBER} + + Create PLAN.md file(s) in the phase directory. Each plan must have: + - Frontmatter with phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves + - Objective, context, tasks, verification, success criteria, output sections + - Each task with files, action, verify, done fields + + Commit the plan files when done. + ", + subagent_type="gsd-planner", + model="${PLANNER_MODEL}", + description="Plan phase ${PHASE_NUMBER}: ${PHASE_NAME}" + ) + ``` + + **c. Verify plans exist:** + ```bash + PLAN_COUNT=$(ls ${phase_dir}/*-PLAN.md 2>/dev/null | wc -l) + if [ "$PLAN_COUNT" -eq 0 ]; then + echo "ERROR: No plans created for phase ${PHASE_NUMBER}. Skipping phase execution." + # Post error comment and continue to next phase + gh issue comment ${ISSUE_NUMBER} --body "> **MGW** \`phase-error\` Phase ${PHASE_NUMBER} planning produced no plans. Skipping." 2>/dev/null || true + continue + fi + ``` + + **d. Init execute-phase and spawn executor agent (gsd:execute-phase):** + ```bash + EXEC_INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs init execute-phase "${PHASE_NUMBER}") + # Parse EXEC_INIT JSON for: executor_model, verifier_model, phase_dir, plans, incomplete_plans, plan_count + ``` + ``` + Task( + prompt=" + + - ./CLAUDE.md (Project instructions -- if exists, follow all guidelines) + - .agents/skills/ (Project skills -- if dir exists, list skills, read SKILL.md for each, follow relevant rules) + - ${phase_dir}/*-PLAN.md (Plans to execute) + + + You are the GSD executor. Execute all plans for phase ${PHASE_NUMBER}: ${PHASE_NAME}. + + Read and follow the execute-phase workflow: + @~/.claude/get-shit-done/workflows/execute-phase.md + + Phase: ${PHASE_NUMBER} + Phase directory: ${phase_dir} + + Execute each plan's tasks in wave order. For each plan: + 1. Execute all tasks + 2. Commit each task atomically + 3. Create SUMMARY.md in the phase directory + + Do NOT update ROADMAP.md or STATE.md directly -- those are managed by GSD tools. + ", + subagent_type="gsd-executor", + model="${EXECUTOR_MODEL}", + description="Execute phase ${PHASE_NUMBER}: ${PHASE_NAME}" + ) + ``` + + **e. Spawn verifier agent (gsd:verify-phase):** + ``` + Task( + prompt=" + + - ./CLAUDE.md (Project instructions -- if exists, follow all guidelines) + - .agents/skills/ (Project skills -- if dir exists, list skills, read SKILL.md for each, follow relevant rules) + - ${phase_dir}/*-PLAN.md (Plans with must_haves) + - ${phase_dir}/*-SUMMARY.md (Execution summaries) + + + Verify phase ${PHASE_NUMBER}: ${PHASE_NAME} goal achievement. + + Read and follow the verify-phase workflow: + @~/.claude/get-shit-done/workflows/verify-phase.md + + Phase: ${PHASE_NUMBER} + Phase directory: ${phase_dir} + + Check must_haves from plan frontmatter against actual codebase. + Create VERIFICATION.md in the phase directory. + ", + subagent_type="gsd-verifier", + model="${VERIFIER_MODEL}", + description="Verify phase ${PHASE_NUMBER}: ${PHASE_NAME}" + ) + ``` + + **f. Post phase-complete comment directly (no sub-agent):** ```bash PHASE_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + VERIFICATION_STATUS=$(grep -m1 "^## " "${phase_dir}/"*-VERIFICATION.md 2>/dev/null | head -1 || echo "Verification complete") PHASE_BODY=$(cat < **MGW** · \`phase-complete\` · ${PHASE_TIMESTAMP} > ${MILESTONE_CONTEXT} -### Phase ${phase_num} Complete — ${phase_name} +### Phase ${PHASE_NUMBER} Complete — ${PHASE_NAME} -${brief_summary_from_executor} +Execution complete. See ${phase_dir} for plans, summaries, and verification. -**Verification:** ${verification_status} +**Verification:** ${VERIFICATION_STATUS} COMMENTEOF ) gh issue comment ${ISSUE_NUMBER} --body "$PHASE_BODY" 2>/dev/null || true ``` - After all phases complete → update pipeline_stage to "verifying" (at `${REPO_ROOT}/.mgw/active/`). + After ALL phases complete → update pipeline_stage to "verifying" (at `${REPO_ROOT}/.mgw/active/`). @@ -780,6 +1006,11 @@ rmdir "${REPO_ROOT}/.worktrees/issue" 2>/dev/null rmdir "${REPO_ROOT}/.worktrees" 2>/dev/null ``` +Remove in-progress label at completion: +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +``` + Extract one-liner summary for concise comment: ```bash ONE_LINER=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs summary-extract "${gsd_artifacts_path}/*SUMMARY*" --fields one_liner --raw 2>/dev/null || echo "") @@ -846,14 +1077,20 @@ Next: - [ ] Issue number validated and state loaded (or triage run first) +- [ ] Pipeline refuses needs-info without --force +- [ ] Pipeline refuses needs-security-review without --security-ack - [ ] Isolated worktree created (.worktrees/ gitignored) +- [ ] mgw:in-progress label applied during execution - [ ] Pre-flight comment check performed (new comments classified before execution) -- [ ] Structured triage comment posted on issue (scope, route, files, security) +- [ ] mgw:blocked label applied when blocking comments detected +- [ ] Work-starting comment posted on issue (route, scope, branch) - [ ] GSD pipeline executed in worktree (quick or milestone route) +- [ ] New-milestone route triggers discussion phase with mgw:discussing label - [ ] Execution-complete comment posted on issue (commits, changes, test status) - [ ] PR created with summary, milestone context, testing procedures, cross-refs - [ ] Structured PR-ready comment posted on issue (PR link, pipeline summary) - [ ] Worktree cleaned up, user returned to main workspace +- [ ] mgw:in-progress label removed at completion - [ ] State file updated through all pipeline stages - [ ] User prompted to run /mgw:sync after merge diff --git a/.claude/commands/mgw/workflows/github.md b/.claude/commands/mgw/workflows/github.md index f28ecc6..ffdca03 100644 --- a/.claude/commands/mgw/workflows/github.md +++ b/.claude/commands/mgw/workflows/github.md @@ -79,6 +79,114 @@ Used during repo initialization to ensure standard labels exist. gh label create "$LABEL_NAME" --description "$DESCRIPTION" --color "$HEX_COLOR" --force ``` +## Label Lifecycle Operations + +### MGW Pipeline Labels +Seven labels for pipeline stage tracking. Created by init.md, managed by issue.md and run.md. + +| Label | Color | Description | +|-------|-------|-------------| +| `mgw:triaged` | `0e8a16` | Issue triaged and ready for pipeline | +| `mgw:needs-info` | `e4e669` | Blocked — needs more detail or clarification | +| `mgw:needs-security-review` | `d93f0b` | Blocked — requires security review | +| `mgw:discussing` | `c5def5` | Under discussion — not yet approved | +| `mgw:approved` | `0e8a16` | Discussion complete — approved for execution | +| `mgw:in-progress` | `1d76db` | Pipeline actively executing | +| `mgw:blocked` | `b60205` | Pipeline blocked by stakeholder comment | + +### Remove MGW Labels and Apply New +Used when transitioning pipeline stages. Removes all `mgw:*` pipeline labels, then applies the target label. +```bash +# Remove all mgw: pipeline labels from issue, then apply new one +remove_mgw_labels_and_apply() { + local ISSUE_NUMBER="$1" + local NEW_LABEL="$2" + + # Get current labels + CURRENT_LABELS=$(gh issue view "$ISSUE_NUMBER" --json labels --jq '.labels[].name' 2>/dev/null) + + # Remove any mgw: pipeline labels + for LABEL in $CURRENT_LABELS; do + case "$LABEL" in + mgw:triaged|mgw:needs-info|mgw:needs-security-review|mgw:discussing|mgw:approved|mgw:in-progress|mgw:blocked) + gh issue edit "$ISSUE_NUMBER" --remove-label "$LABEL" 2>/dev/null + ;; + esac + done + + # Apply new label + if [ -n "$NEW_LABEL" ]; then + gh issue edit "$ISSUE_NUMBER" --add-label "$NEW_LABEL" 2>/dev/null + fi +} +``` + +## Triage Comment Templates + +### Gate Blocked Comment +Posted immediately during /mgw:issue when triage gates fail. +```bash +GATE_BLOCKED_BODY=$(cat < **MGW** . \`triage-blocked\` . ${TIMESTAMP} + +### Triage: Action Required + +| Gate | Result | +|------|--------| +${GATE_TABLE_ROWS} + +**What's needed:** +${MISSING_FIELDS_LIST} + +Please update the issue with the required information, then re-run \`/mgw:issue ${ISSUE_NUMBER}\`. +COMMENTEOF +) +gh issue comment ${ISSUE_NUMBER} --body "$GATE_BLOCKED_BODY" 2>/dev/null || true +``` + +### Gate Passed Comment +Posted immediately during /mgw:issue when all triage gates pass. +```bash +GATE_PASSED_BODY=$(cat < **MGW** . \`triage-complete\` . ${TIMESTAMP} + +### Triage Complete + +| | | +|---|---| +| **Scope** | ${SCOPE_SIZE} -- ${FILE_COUNT} files across ${SYSTEM_LIST} | +| **Validity** | ${VALIDITY} | +| **Security** | ${SECURITY_RISK} | +| **Route** | \`${gsd_route}\` -- ${ROUTE_REASONING} | +| **Gates** | All passed | + +Ready for pipeline execution. +COMMENTEOF +) +gh issue comment ${ISSUE_NUMBER} --body "$GATE_PASSED_BODY" 2>/dev/null || true +``` + +### Scope Proposal Comment +Posted when new-milestone route triggers discussion phase. +```bash +SCOPE_PROPOSAL_BODY=$(cat < **MGW** . \`scope-proposal\` . ${TIMESTAMP} + +### Scope Proposal: Discussion Requested + +This issue was triaged as **${SCOPE_SIZE}** scope requiring the \`new-milestone\` route. + +**Proposed breakdown:** +${SCOPE_BREAKDOWN} + +**Estimated phases:** ${PHASE_COUNT} + +Please review and confirm scope, or suggest changes. Once approved, run \`/mgw:run ${ISSUE_NUMBER}\` to begin execution. +COMMENTEOF +) +gh issue comment ${ISSUE_NUMBER} --body "$SCOPE_PROPOSAL_BODY" 2>/dev/null || true +``` + ## Milestone Operations ### Create Milestone @@ -272,3 +380,6 @@ Release is created as draft — user reviews and publishes manually. | Batch Operations | state.md (staleness detection) | | Rate Limit | milestone.md | | Release Operations | milestone.md | +| Label Lifecycle | issue.md, run.md, init.md | +| Triage Comment Templates | issue.md | +| Scope Proposal Template | run.md (new-milestone discussion) | diff --git a/.claude/commands/mgw/workflows/state.md b/.claude/commands/mgw/workflows/state.md index 34ff37f..112d3cd 100644 --- a/.claude/commands/mgw/workflows/state.md +++ b/.claude/commands/mgw/workflows/state.md @@ -206,11 +206,17 @@ File: `.mgw/active/-.json` "security_notes": "", "conflicts": [], "last_comment_count": 0, - "last_comment_at": null + "last_comment_at": null, + "gate_result": { + "status": "passed|blocked", + "blockers": [], + "warnings": [], + "missing_fields": [] + } }, "gsd_route": null, "gsd_artifacts": { "type": null, "path": null }, - "pipeline_stage": "new|triaged|planning|executing|verifying|pr-created|done", + "pipeline_stage": "new|triaged|needs-info|needs-security-review|discussing|approved|planning|executing|verifying|pr-created|done|failed|blocked", "comments_posted": [], "linked_pr": null, "linked_issues": [], @@ -218,6 +224,33 @@ File: `.mgw/active/-.json` } ``` +## Stage Flow Diagram + +``` +new --> triaged (triage passes all gates) +new --> needs-info (validity=invalid OR insufficient detail) +new --> needs-security-review (security=high) + +needs-info --> triaged (re-triage after info provided) +needs-security-review --> triaged (re-triage after security ack) + +triaged --> discussing (new-milestone route, large scope) +triaged --> approved (discussion complete, ready for execution) +triaged --> planning (direct route, skip discussion) + +discussing --> approved (stakeholder approval) +approved --> planning + +planning --> executing +executing --> verifying +verifying --> pr-created +pr-created --> done + +Any stage --> blocked (blocking comment detected) +blocked --> triaged (re-triage after blocker resolved) +Any stage --> failed (unrecoverable error) +``` + ## Slug Generation Use gsd-tools for consistent slug generation: @@ -327,3 +360,4 @@ Only advance if ALL issues in current milestone completed successfully. | Cross-refs schema | link.md, run.md, pr.md, sync.md | | Slug generation | issue.md, run.md | | Project state | milestone.md, next.md, ask.md | +| Gate result schema | issue.md (populate), run.md (validate) | diff --git a/.github/ISSUE_TEMPLATE/architecture_refactor.yml b/.github/ISSUE_TEMPLATE/architecture_refactor.yml new file mode 100644 index 0000000..42b8a52 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/architecture_refactor.yml @@ -0,0 +1,114 @@ +name: Architecture Refactor +description: Propose an architectural change or system refactoring +labels: ["refactor"] +body: + - type: textarea + id: bluf + attributes: + label: BLUF + description: Bottom Line Up Front -- one sentence summary of the refactor + placeholder: "Migrate from file-based state to SQLite for concurrent access support" + validations: + required: true + + - type: textarea + id: current-state + attributes: + label: Current State + description: How the system works today. Include architecture decisions, file paths, and pain points. + placeholder: | + - State stored in `.mgw/active/*.json` files + - No locking mechanism for concurrent access + - JSON parsing on every read + validations: + required: true + + - type: textarea + id: target-state + attributes: + label: Target State + description: How the system should work after this refactor. Be specific about the new architecture. + placeholder: | + - State stored in `.mgw/state.db` (SQLite) + - WAL mode for concurrent readers + - Typed schema with migrations + validations: + required: true + + - type: textarea + id: migration-strategy + attributes: + label: Migration Strategy + description: How to get from current state to target state. Include phasing if needed. + placeholder: | + 1. Add SQLite dependency and schema + 2. Create migration tool for existing JSON files + 3. Update state.md patterns to use SQLite + 4. Deprecate JSON file access + validations: + required: true + + - type: textarea + id: risk-areas + attributes: + label: Risk Areas + description: Where could this go wrong? What are the highest-risk changes? + placeholder: | + - Data loss during migration if JSON files are malformed + - Performance regression on large state files + validations: + required: true + + - type: textarea + id: breaking-changes + attributes: + label: Breaking Changes + description: What existing behavior or interfaces will change? + placeholder: | + - `.mgw/active/*.json` file format changes + - Commands that directly read JSON will need updating + validations: + required: true + + - type: textarea + id: acceptance-criteria + attributes: + label: Acceptance Criteria + description: Specific conditions that define 'done' + placeholder: | + - [ ] All existing state operations work with new backend + - [ ] Migration tool handles all existing JSON formats + - [ ] No performance regression on typical workloads + validations: + required: true + + - type: dropdown + id: scope-estimate + attributes: + label: Scope Estimate + options: + - Small (1-2 files) + - Medium (3-8 files) + - Large (9+ files or new system) + validations: + required: false + + - type: textarea + id: whats-involved + attributes: + label: What's Involved + description: Files, systems, and dependencies affected + placeholder: | + | File | What Changes | + |------|-------------| + | `.claude/commands/mgw/workflows/state.md` | New SQLite patterns | + validations: + required: false + + - type: input + id: related-issues + attributes: + label: Related Issues + placeholder: "#42, #43" + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e80b0fa..9267639 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -70,3 +70,54 @@ body: render: shell validations: required: false + + - type: textarea + id: acceptance-criteria + attributes: + label: Acceptance Criteria + description: Specific conditions that must be true for the fix to be considered complete + placeholder: "- [ ] User is returned to main branch after pipeline completion\n- [ ] Worktree is fully cleaned up" + validations: + required: false + + - type: dropdown + id: scope-estimate + attributes: + label: Scope Estimate + description: Rough estimate of the work involved + options: + - Small (1-2 files) + - Medium (3-8 files) + - Large (9+ files or new system) + validations: + required: false + + - type: checkboxes + id: security-impact + attributes: + label: Security Impact + description: Does this bug have security implications? + options: + - label: Touches authentication/authorization + - label: Involves user data handling + - label: Affects input validation/sanitization + - label: Involves external API calls + - label: No security impact + + - type: textarea + id: whats-involved + attributes: + label: What's Involved + description: Files and systems that need changes (helps triage) + placeholder: "| File | What Changes |\n|------|-------------|\n| `commands/run.md` | Fix worktree cleanup logic |" + validations: + required: false + + - type: input + id: related-issues + attributes: + label: Related Issues + description: Other issues related to this bug + placeholder: "#42, #43" + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 353a458..7f57040 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -49,3 +49,75 @@ body: description: Design references, related issues, screenshots, or workflow context validations: required: false + + - type: textarea + id: acceptance-criteria + attributes: + label: Acceptance Criteria + description: Specific, testable conditions that define 'done' for this feature + placeholder: "- [ ] New command `/mgw:init` creates .mgw/ directory\n- [ ] GitHub templates are generated\n- [ ] .gitignore entries added" + validations: + required: true + + - type: dropdown + id: scope-estimate + attributes: + label: Scope Estimate + options: + - Small (1-2 files) + - Medium (3-8 files) + - Large (9+ files or new system) + validations: + required: false + + - type: dropdown + id: priority + attributes: + label: Priority + description: How urgent is this feature? + options: + - Nice to have + - Should have + - Must have + - Critical + validations: + required: false + + - type: checkboxes + id: security-impact + attributes: + label: Security Impact + description: Does this feature have security implications? + options: + - label: Touches authentication/authorization + - label: Involves user data handling + - label: Affects input validation/sanitization + - label: Involves external API calls + - label: No security impact + + - type: textarea + id: whats-involved + attributes: + label: What's Involved + description: Files, systems, and estimated scope of changes + placeholder: "| File | What Changes |\n|------|-------------|\n| `commands/init.md` | New command implementation |" + validations: + required: false + + - type: textarea + id: non-functional + attributes: + label: Non-Functional Requirements + description: Performance, scalability, accessibility, or other non-functional concerns + placeholder: "- Should complete in under 30 seconds\n- Must work offline (except GitHub API calls)" + validations: + required: false + + - type: input + id: related-issues + attributes: + label: Related Issues + description: Other issues related to this feature + placeholder: "#42, #43" + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 330aa63..c4db56b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,8 +5,17 @@ Closes # +## Milestone Context + + +| | | +|---|---| +| **Milestone** | | +| **Phase** | | +| **Dependencies** | | + ## Changes - + ### Commands - @@ -14,7 +23,45 @@ Closes # ### Workflows - +### Templates +- + +## Design Decisions + + +| Decision | Rationale | +|----------|-----------| +| | | + +## Security & Performance + + +- **Security:** +- **Performance:** + +## Artifacts + + +| File | Change Type | Description | +|------|------------|-------------| +| | | | + +## Breaking Changes + + +- [ ] + ## Test Plan - [ ] + +## Cross-References + + +- + +## Checklist +- [ ] Source commands/ match deployed .claude/commands/mgw/ +- [ ] New labels documented in github.md +- [ ] State schema changes reflected in state.md diff --git a/.github/labeler.yml b/.github/labeler.yml index f37373f..fc73573 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -28,3 +28,12 @@ github-config: - changed-files: - any-glob-to-any-file: - '.github/**' + +triage-pipeline: + - changed-files: + - any-glob-to-any-file: + - 'commands/issue.md' + - 'commands/run.md' + - 'commands/review.md' + - '.claude/commands/mgw/workflows/state.md' + - '.claude/commands/mgw/workflows/github.md' diff --git a/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-PLAN.md b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-PLAN.md new file mode 100644 index 0000000..197b671 --- /dev/null +++ b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-PLAN.md @@ -0,0 +1,1111 @@ +--- +phase: quick-2 +plan: 01 +type: execute +wave: 1 +depends_on: [] +files_modified: + - .claude/commands/mgw/workflows/state.md + - .claude/commands/mgw/workflows/github.md + - commands/init.md + - .claude/commands/mgw/init.md + - .github/ISSUE_TEMPLATE/bug_report.yml + - .github/ISSUE_TEMPLATE/feature_request.yml + - .github/ISSUE_TEMPLATE/architecture_refactor.yml + - .github/PULL_REQUEST_TEMPLATE.md + - .github/labeler.yml + - commands/issue.md + - .claude/commands/mgw/issue.md + - commands/run.md + - .claude/commands/mgw/run.md + - commands/review.md + - .claude/commands/mgw/review.md +autonomous: true +requirements: [TRIAGE-GATES, TEMPLATES, PIPELINE-VALIDATION, COMMENT-CLASSIFICATION, STATE-LABELS] + +must_haves: + truths: + - "Triage agent evaluates quality gates (validity, security, detail sufficiency) and blocks on failure" + - "validity=invalid issues get pipeline_stage=needs-info, mgw:needs-info label, and structured comment" + - "security=high issues get pipeline_stage=needs-security-review, label, and comment" + - "Insufficient detail (body < 200 chars, no AC on features) results in needs-info" + - "Triage comment is posted IMMEDIATELY during /mgw:issue (not deferred to /mgw:run)" + - "/mgw:run on needs-info without --force refuses to execute" + - "/mgw:run on needs-security-review without --security-ack refuses to execute" + - "bug_report.yml includes acceptance criteria, scope estimate, security checkboxes, whats-involved, related issues" + - "feature_request.yml includes acceptance criteria (required), scope estimate, priority, security, whats-involved, non-functional, related issues" + - "architecture_refactor.yml template exists with current state, target state, migration strategy, risk areas, breaking changes" + - "PR template has milestone context table, design decisions, security/performance, artifacts table, breaking changes, cross-references" + - "review.md supports resolution classification type with re-triage prompt" + - "7 new MGW pipeline labels defined in github.md and created by init.md" + - "state.md has new pipeline stages: needs-info, needs-security-review, discussing, approved" + - "state.md triage schema includes gate_result with passed, blockers, warnings, missing_fields" + artifacts: + - path: ".claude/commands/mgw/workflows/state.md" + provides: "Extended pipeline stages and gate_result schema" + contains: "needs-info" + - path: ".claude/commands/mgw/workflows/github.md" + provides: "Label ops, triage gate comment template, scope proposal template" + contains: "mgw:needs-info" + - path: ".github/ISSUE_TEMPLATE/architecture_refactor.yml" + provides: "NEW architecture refactor issue template" + contains: "architecture_refactor" + - path: ".github/PULL_REQUEST_TEMPLATE.md" + provides: "Redesigned PR template with 10 sections" + contains: "Milestone Context" + - path: "commands/issue.md" + provides: "Triage gates and immediate GitHub feedback" + contains: "evaluate_gates" + - path: "commands/run.md" + provides: "Pipeline validation gates" + contains: "needs-info" + - path: "commands/review.md" + provides: "Resolution classification" + contains: "resolution" + key_links: + - from: "commands/issue.md" + to: ".claude/commands/mgw/workflows/state.md" + via: "gate_result schema reference" + pattern: "gate_result" + - from: "commands/issue.md" + to: ".claude/commands/mgw/workflows/github.md" + via: "triage gate comment template" + pattern: "triage.*gate.*comment" + - from: "commands/run.md" + to: ".claude/commands/mgw/workflows/state.md" + via: "pipeline_stage validation" + pattern: "needs-info|needs-security-review" + - from: "commands/init.md" + to: ".claude/commands/mgw/workflows/github.md" + via: "label definitions" + pattern: "mgw:" +--- + + +Implement bidirectional triage quality gates with AI-optimized templates for the MGW pipeline. + +Purpose: Close six gaps in MGW's linear pipeline: (1) no gates preventing invalid/insecure issues from executing, (2) no immediate triage feedback on GitHub, (3) no discussion phase for large scope, (4) weak issue templates, (5) weak PR template, (6) no engagement loops for resolved blockers. + +Output: Extended state schema, 7 new pipeline labels, enhanced issue/PR templates, triage gate evaluation in issue.md, pipeline validation in run.md, resolution classification in review.md, synced deployed copies. + + + +@~/.claude/get-shit-done/workflows/execute-plan.md +@~/.claude/get-shit-done/templates/summary.md + + + +@.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-PLAN.md + +Source files (commands/ is source of truth, .claude/commands/mgw/ are deployed copies): +@commands/issue.md +@commands/run.md +@commands/review.md +@commands/init.md +@.claude/commands/mgw/workflows/state.md +@.claude/commands/mgw/workflows/github.md +@.github/ISSUE_TEMPLATE/bug_report.yml +@.github/ISSUE_TEMPLATE/feature_request.yml +@.github/PULL_REQUEST_TEMPLATE.md +@.github/labeler.yml + + + + + + Task 1: Extend state schema, GitHub label/comment operations, and init bootstrapper + + .claude/commands/mgw/workflows/state.md + .claude/commands/mgw/workflows/github.md + commands/init.md + .claude/commands/mgw/init.md + + +**state.md changes:** + +1. Extend the `pipeline_stage` enum in the Issue State Schema section. Current value: + ``` + "pipeline_stage": "new|triaged|planning|executing|verifying|pr-created|done" + ``` + Change to: + ``` + "pipeline_stage": "new|triaged|needs-info|needs-security-review|discussing|approved|planning|executing|verifying|pr-created|done|failed|blocked" + ``` + (The `failed` and `blocked` already appear in the Project State section's valid stages list but not in the Issue State Schema enum -- unify them.) + +2. Add `gate_result` to the triage object in the Issue State Schema. After the existing `last_comment_at` field, add: + ```json + "gate_result": { + "status": "passed|blocked", + "blockers": [], + "warnings": [], + "missing_fields": [] + } + ``` + +3. Add a new section "## Stage Flow Diagram" after the Issue State Schema section: + ``` + ## Stage Flow Diagram + + ``` + new --> triaged (triage passes all gates) + new --> needs-info (validity=invalid OR insufficient detail) + new --> needs-security-review (security=high) + + needs-info --> triaged (re-triage after info provided) + needs-security-review --> triaged (re-triage after security ack) + + triaged --> discussing (new-milestone route, large scope) + triaged --> approved (discussion complete, ready for execution) + triaged --> planning (direct route, skip discussion) + + discussing --> approved (stakeholder approval) + approved --> planning + + planning --> executing + executing --> verifying + verifying --> pr-created + pr-created --> done + + Any stage --> blocked (blocking comment detected) + blocked --> triaged (re-triage after blocker resolved) + Any stage --> failed (unrecoverable error) + ``` + ``` + +4. Update the Consumers table at the bottom to add entries for the new gate_result field: + Add row: `| Gate result schema | issue.md (populate), run.md (validate) |` + +**github.md changes:** + +1. Add a new section "## Label Lifecycle Operations" after the existing "### Manage Labels" subsection. Add: + + ```markdown + ## Label Lifecycle Operations + + ### MGW Pipeline Labels + Seven labels for pipeline stage tracking. Created by init.md, managed by issue.md and run.md. + + | Label | Color | Description | + |-------|-------|-------------| + | `mgw:triaged` | `0e8a16` | Issue triaged and ready for pipeline | + | `mgw:needs-info` | `e4e669` | Blocked — needs more detail or clarification | + | `mgw:needs-security-review` | `d93f0b` | Blocked — requires security review | + | `mgw:discussing` | `c5def5` | Under discussion — not yet approved | + | `mgw:approved` | `0e8a16` | Discussion complete — approved for execution | + | `mgw:in-progress` | `1d76db` | Pipeline actively executing | + | `mgw:blocked` | `b60205` | Pipeline blocked by stakeholder comment | + + ### Remove MGW Labels and Apply New + Used when transitioning pipeline stages. Removes all `mgw:*` pipeline labels, then applies the target label. + ```bash + # Remove all mgw: pipeline labels from issue, then apply new one + remove_mgw_labels_and_apply() { + local ISSUE_NUMBER="$1" + local NEW_LABEL="$2" + + # Get current labels + CURRENT_LABELS=$(gh issue view "$ISSUE_NUMBER" --json labels --jq '.labels[].name' 2>/dev/null) + + # Remove any mgw: pipeline labels + for LABEL in $CURRENT_LABELS; do + case "$LABEL" in + mgw:triaged|mgw:needs-info|mgw:needs-security-review|mgw:discussing|mgw:approved|mgw:in-progress|mgw:blocked) + gh issue edit "$ISSUE_NUMBER" --remove-label "$LABEL" 2>/dev/null + ;; + esac + done + + # Apply new label + if [ -n "$NEW_LABEL" ]; then + gh issue edit "$ISSUE_NUMBER" --add-label "$NEW_LABEL" 2>/dev/null + fi + } + ``` + ``` + +2. Add a new section "## Triage Comment Templates" after Label Lifecycle Operations: + + ```markdown + ## Triage Comment Templates + + ### Gate Blocked Comment + Posted immediately during /mgw:issue when triage gates fail. + ```bash + GATE_BLOCKED_BODY=$(cat < **MGW** . \`triage-blocked\` . ${TIMESTAMP} + + ### Triage: Action Required + + | Gate | Result | + |------|--------| + ${GATE_TABLE_ROWS} + + **What's needed:** + ${MISSING_FIELDS_LIST} + + Please update the issue with the required information, then re-run \`/mgw:issue ${ISSUE_NUMBER}\`. + COMMENTEOF + ) + gh issue comment ${ISSUE_NUMBER} --body "$GATE_BLOCKED_BODY" 2>/dev/null || true + ``` + + ### Gate Passed Comment + Posted immediately during /mgw:issue when all triage gates pass. + ```bash + GATE_PASSED_BODY=$(cat < **MGW** . \`triage-complete\` . ${TIMESTAMP} + + ### Triage Complete + + | | | + |---|---| + | **Scope** | ${SCOPE_SIZE} -- ${FILE_COUNT} files across ${SYSTEM_LIST} | + | **Validity** | ${VALIDITY} | + | **Security** | ${SECURITY_RISK} | + | **Route** | \`${gsd_route}\` -- ${ROUTE_REASONING} | + | **Gates** | All passed | + + Ready for pipeline execution. + COMMENTEOF + ) + gh issue comment ${ISSUE_NUMBER} --body "$GATE_PASSED_BODY" 2>/dev/null || true + ``` + + ### Scope Proposal Comment + Posted when new-milestone route triggers discussion phase. + ```bash + SCOPE_PROPOSAL_BODY=$(cat < **MGW** . \`scope-proposal\` . ${TIMESTAMP} + + ### Scope Proposal: Discussion Requested + + This issue was triaged as **${SCOPE_SIZE}** scope requiring the \`new-milestone\` route. + + **Proposed breakdown:** + ${SCOPE_BREAKDOWN} + + **Estimated phases:** ${PHASE_COUNT} + + Please review and confirm scope, or suggest changes. Once approved, run \`/mgw:run ${ISSUE_NUMBER}\` to begin execution. + COMMENTEOF + ) + gh issue comment ${ISSUE_NUMBER} --body "$SCOPE_PROPOSAL_BODY" 2>/dev/null || true + ``` + ``` + +3. Update the Consumers table to add new entries: + Add rows: + - `| Label Lifecycle | issue.md, run.md, init.md |` + - `| Triage Comment Templates | issue.md |` + - `| Scope Proposal Template | run.md (new-milestone discussion) |` + +**init.md changes:** + +1. In the `ensure_labels` step, add 7 new MGW pipeline label creation commands after the existing `bug` and `enhancement` labels: + + ```bash + # MGW pipeline labels + gh label create "mgw:triaged" --description "Issue triaged and ready for pipeline" --color "0e8a16" --force + gh label create "mgw:needs-info" --description "Blocked — needs more detail or clarification" --color "e4e669" --force + gh label create "mgw:needs-security-review" --description "Blocked — requires security review" --color "d93f0b" --force + gh label create "mgw:discussing" --description "Under discussion — not yet approved" --color "c5def5" --force + gh label create "mgw:approved" --description "Discussion complete — approved for execution" --color "0e8a16" --force + gh label create "mgw:in-progress" --description "Pipeline actively executing" --color "1d76db" --force + gh label create "mgw:blocked" --description "Pipeline blocked by stakeholder comment" --color "b60205" --force + ``` + +2. Update the report step to include the new labels in the status display: + ``` + MGW pipeline labels synced (7 labels) + ``` + +3. Update success_criteria to add: `- [ ] MGW pipeline labels ensured (7 mgw:* labels)` + +4. After writing commands/init.md, copy it to .claude/commands/mgw/init.md (deployed copy). + + + grep -q "needs-info" .claude/commands/mgw/workflows/state.md && \ + grep -q "needs-security-review" .claude/commands/mgw/workflows/state.md && \ + grep -q "gate_result" .claude/commands/mgw/workflows/state.md && \ + grep -q "Stage Flow Diagram" .claude/commands/mgw/workflows/state.md && \ + grep -q "mgw:needs-info" .claude/commands/mgw/workflows/github.md && \ + grep -q "remove_mgw_labels_and_apply" .claude/commands/mgw/workflows/github.md && \ + grep -q "Gate Blocked Comment" .claude/commands/mgw/workflows/github.md && \ + grep -q "Scope Proposal Comment" .claude/commands/mgw/workflows/github.md && \ + grep -q "mgw:triaged" commands/init.md && \ + grep -q "mgw:blocked" commands/init.md && \ + diff commands/init.md .claude/commands/mgw/init.md && \ + echo "PASS" || echo "FAIL" + + + - state.md pipeline_stage enum includes needs-info, needs-security-review, discussing, approved + - state.md triage schema has gate_result object (status, blockers, warnings, missing_fields) + - state.md has stage flow diagram showing all transitions + - github.md has 7 MGW pipeline label definitions in a table + - github.md has remove_mgw_labels_and_apply function + - github.md has triage gate comment templates (blocked + passed) + - github.md has scope proposal comment template + - init.md ensure_labels creates all 7 mgw:* labels + - Deployed copy .claude/commands/mgw/init.md matches source + + + + + Task 2: Redesign GitHub issue and PR templates + + .github/ISSUE_TEMPLATE/bug_report.yml + .github/ISSUE_TEMPLATE/feature_request.yml + .github/ISSUE_TEMPLATE/architecture_refactor.yml + .github/PULL_REQUEST_TEMPLATE.md + .github/labeler.yml + + +**bug_report.yml -- Add 5 new fields to the existing template:** + +Keep existing fields (bluf, mgw-version, runtime, description, reproduction-steps, expected-behavior, error-logs). Add the following NEW fields after the existing ones: + +1. `acceptance-criteria` (textarea, required: false): + - label: "Acceptance Criteria" + - description: "Specific conditions that must be true for the fix to be considered complete" + - placeholder: "- [ ] User is returned to main branch after pipeline completion\n- [ ] Worktree is fully cleaned up" + +2. `scope-estimate` (dropdown, required: false): + - label: "Scope Estimate" + - description: "Rough estimate of the work involved" + - options: ["Small (1-2 files)", "Medium (3-8 files)", "Large (9+ files or new system)"] + +3. `security-impact` (checkboxes): + - label: "Security Impact" + - description: "Does this bug have security implications?" + - options: + - label: "Touches authentication/authorization" + - label: "Involves user data handling" + - label: "Affects input validation/sanitization" + - label: "Involves external API calls" + - label: "No security impact" + +4. `whats-involved` (textarea, required: false): + - label: "What's Involved" + - description: "Files and systems that need changes (helps triage)" + - placeholder: "| File | What Changes |\n|------|-------------|\n| `commands/run.md` | Fix worktree cleanup logic |" + +5. `related-issues` (input, required: false): + - label: "Related Issues" + - description: "Other issues related to this bug" + - placeholder: "#42, #43" + +**feature_request.yml -- Add 7 new fields:** + +Keep existing fields (bluf, problem-motivation, proposed-solution, alternatives-considered, context). Add NEW fields: + +1. `acceptance-criteria` (textarea, required: true): + - label: "Acceptance Criteria" + - description: "Specific, testable conditions that define 'done' for this feature" + - placeholder: "- [ ] New command `/mgw:init` creates .mgw/ directory\n- [ ] GitHub templates are generated\n- [ ] .gitignore entries added" + +2. `scope-estimate` (dropdown, required: false): + - label: "Scope Estimate" + - options: ["Small (1-2 files)", "Medium (3-8 files)", "Large (9+ files or new system)"] + +3. `priority` (dropdown, required: false): + - label: "Priority" + - description: "How urgent is this feature?" + - options: ["Nice to have", "Should have", "Must have", "Critical"] + +4. `security-impact` (checkboxes): + - label: "Security Impact" + - description: "Does this feature have security implications?" + - options: + - label: "Touches authentication/authorization" + - label: "Involves user data handling" + - label: "Affects input validation/sanitization" + - label: "Involves external API calls" + - label: "No security impact" + +5. `whats-involved` (textarea, required: false): + - label: "What's Involved" + - description: "Files, systems, and estimated scope of changes" + - placeholder: "| File | What Changes |\n|------|-------------|\n| `commands/init.md` | New command implementation |" + +6. `non-functional` (textarea, required: false): + - label: "Non-Functional Requirements" + - description: "Performance, scalability, accessibility, or other non-functional concerns" + - placeholder: "- Should complete in under 30 seconds\n- Must work offline (except GitHub API calls)" + +7. `related-issues` (input, required: false): + - label: "Related Issues" + - description: "Other issues related to this feature" + - placeholder: "#42, #43" + +**architecture_refactor.yml -- NEW FILE:** + +Create `.github/ISSUE_TEMPLATE/architecture_refactor.yml`: +```yaml +name: Architecture Refactor +description: Propose an architectural change or system refactoring +labels: ["refactor"] +body: + - type: textarea + id: bluf + attributes: + label: BLUF + description: Bottom Line Up Front -- one sentence summary of the refactor + placeholder: "Migrate from file-based state to SQLite for concurrent access support" + validations: + required: true + + - type: textarea + id: current-state + attributes: + label: Current State + description: How the system works today. Include architecture decisions, file paths, and pain points. + placeholder: | + - State stored in `.mgw/active/*.json` files + - No locking mechanism for concurrent access + - JSON parsing on every read + validations: + required: true + + - type: textarea + id: target-state + attributes: + label: Target State + description: How the system should work after this refactor. Be specific about the new architecture. + placeholder: | + - State stored in `.mgw/state.db` (SQLite) + - WAL mode for concurrent readers + - Typed schema with migrations + validations: + required: true + + - type: textarea + id: migration-strategy + attributes: + label: Migration Strategy + description: How to get from current state to target state. Include phasing if needed. + placeholder: | + 1. Add SQLite dependency and schema + 2. Create migration tool for existing JSON files + 3. Update state.md patterns to use SQLite + 4. Deprecate JSON file access + validations: + required: true + + - type: textarea + id: risk-areas + attributes: + label: Risk Areas + description: Where could this go wrong? What are the highest-risk changes? + placeholder: | + - Data loss during migration if JSON files are malformed + - Performance regression on large state files + validations: + required: true + + - type: textarea + id: breaking-changes + attributes: + label: Breaking Changes + description: What existing behavior or interfaces will change? + placeholder: | + - `.mgw/active/*.json` file format changes + - Commands that directly read JSON will need updating + validations: + required: true + + - type: textarea + id: acceptance-criteria + attributes: + label: Acceptance Criteria + description: Specific conditions that define 'done' + placeholder: | + - [ ] All existing state operations work with new backend + - [ ] Migration tool handles all existing JSON formats + - [ ] No performance regression on typical workloads + validations: + required: true + + - type: dropdown + id: scope-estimate + attributes: + label: Scope Estimate + options: + - Small (1-2 files) + - Medium (3-8 files) + - Large (9+ files or new system) + validations: + required: false + + - type: textarea + id: whats-involved + attributes: + label: What's Involved + description: Files, systems, and dependencies affected + placeholder: | + | File | What Changes | + |------|-------------| + | `.claude/commands/mgw/workflows/state.md` | New SQLite patterns | + validations: + required: false + + - type: input + id: related-issues + attributes: + label: Related Issues + placeholder: "#42, #43" + validations: + required: false +``` + +**PULL_REQUEST_TEMPLATE.md -- Full redesign with 10 sections:** + +Replace the existing 3-section template with: +```markdown +## Summary + + +- + +Closes # + +## Milestone Context + + +| | | +|---|---| +| **Milestone** | | +| **Phase** | | +| **Dependencies** | | + +## Changes + + +### Commands +- + +### Workflows +- + +### Templates +- + +## Design Decisions + + +| Decision | Rationale | +|----------|-----------| +| | | + +## Security & Performance + + +- **Security:** +- **Performance:** + +## Artifacts + + +| File | Change Type | Description | +|------|------------|-------------| +| | | | + +## Breaking Changes + + +- [ ] + +## Test Plan + + +- [ ] + +## Cross-References + + +- + +## Checklist +- [ ] Source commands/ match deployed .claude/commands/mgw/ +- [ ] New labels documented in github.md +- [ ] State schema changes reflected in state.md +``` + +**labeler.yml -- Add triage-pipeline rule:** + +Add a new label rule at the end of the file: +```yaml +triage-pipeline: + - changed-files: + - any-glob-to-any-file: + - 'commands/issue.md' + - 'commands/run.md' + - 'commands/review.md' + - '.claude/commands/mgw/workflows/state.md' + - '.claude/commands/mgw/workflows/github.md' +``` + + + test -f .github/ISSUE_TEMPLATE/architecture_refactor.yml && \ + grep -q "acceptance-criteria" .github/ISSUE_TEMPLATE/bug_report.yml && \ + grep -q "scope-estimate" .github/ISSUE_TEMPLATE/bug_report.yml && \ + grep -q "security-impact" .github/ISSUE_TEMPLATE/bug_report.yml && \ + grep -q "whats-involved" .github/ISSUE_TEMPLATE/bug_report.yml && \ + grep -q "related-issues" .github/ISSUE_TEMPLATE/bug_report.yml && \ + grep -q "acceptance-criteria" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "scope-estimate" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "priority" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "security-impact" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "whats-involved" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "non-functional" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "related-issues" .github/ISSUE_TEMPLATE/feature_request.yml && \ + grep -q "current-state" .github/ISSUE_TEMPLATE/architecture_refactor.yml && \ + grep -q "migration-strategy" .github/ISSUE_TEMPLATE/architecture_refactor.yml && \ + grep -q "breaking-changes" .github/ISSUE_TEMPLATE/architecture_refactor.yml && \ + grep -q "Milestone Context" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "Design Decisions" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "Security & Performance" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "Artifacts" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "Breaking Changes" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "Cross-References" .github/PULL_REQUEST_TEMPLATE.md && \ + grep -q "triage-pipeline" .github/labeler.yml && \ + echo "PASS" || echo "FAIL" + + + - bug_report.yml has 5 new fields: acceptance-criteria, scope-estimate, security-impact, whats-involved, related-issues + - feature_request.yml has 7 new fields: acceptance-criteria (required), scope-estimate, priority, security-impact, whats-involved, non-functional, related-issues + - architecture_refactor.yml is a NEW file with: bluf, current-state, target-state, migration-strategy, risk-areas, breaking-changes, acceptance-criteria, scope-estimate, whats-involved, related-issues + - PULL_REQUEST_TEMPLATE.md redesigned with 10 sections: Summary, Milestone Context, Changes, Design Decisions, Security and Performance, Artifacts, Breaking Changes, Test Plan, Cross-References, Checklist + - labeler.yml has triage-pipeline rule covering issue.md, run.md, review.md, state.md, github.md + + + + + Task 3: Implement triage gates, pipeline validation, resolution classification, and sync deployed copies + + commands/issue.md + .claude/commands/mgw/issue.md + commands/run.md + .claude/commands/mgw/run.md + commands/review.md + .claude/commands/mgw/review.md + + +**commands/issue.md -- Add triage gates and immediate GitHub feedback:** + +1. Add a NEW step `evaluate_gates` between the existing `spawn_analysis` step and `present_report` step: + +```xml + +**Evaluate triage quality gates:** + +After the analysis agent returns, evaluate three quality gates against the triage report +and the original issue data. This determines whether the issue can proceed to pipeline +execution or requires additional information/review. + +**Gate 1: Validity** +``` +if triage.validity == "invalid": + gate_result.blockers.push("Validity gate failed: issue could not be confirmed against codebase") + gate_result.status = "blocked" +``` + +**Gate 2: Security** +``` +if triage.security_risk == "high": + gate_result.blockers.push("Security gate: high-risk issue requires security review before execution") + gate_result.status = "blocked" +``` + +**Gate 3: Detail Sufficiency** +Evaluate the original issue body (not the triage report): +``` +BODY_LENGTH = len(issue_body.strip()) +HAS_AC = issue has acceptance criteria field filled OR body contains "- [ ]" checklist items +IS_FEATURE = "enhancement" in issue_labels OR issue template is feature_request + +if BODY_LENGTH < 200: + gate_result.blockers.push("Insufficient detail: issue body is ${BODY_LENGTH} characters (minimum 200)") + gate_result.missing_fields.push("Expand issue description with more detail") + +if IS_FEATURE and not HAS_AC: + gate_result.blockers.push("Feature requests require acceptance criteria") + gate_result.missing_fields.push("Add acceptance criteria (checklist of testable conditions)") +``` + +**Gate warnings (non-blocking):** +``` +if triage.security_risk == "medium": + gate_result.warnings.push("Medium security risk — consider review before execution") + +if triage.scope.size == "large" and gsd_route != "gsd:new-milestone": + gate_result.warnings.push("Large scope detected but not routed to new-milestone") +``` + +Set `gate_result.status = "passed"` if no blockers. Store gate_result for state file. + +``` + +2. Add a NEW step `post_triage_github` immediately after `evaluate_gates` and before `present_report`: + +```xml + +**Post immediate triage feedback to GitHub:** + +This step posts a comment on the GitHub issue IMMEDIATELY during /mgw:issue, not +deferred to /mgw:run. This gives stakeholders visibility into triage results as +soon as they happen. + +Generate timestamp: +```bash +TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") +``` + +**If gates blocked (gate_result.status == "blocked"):** + +Build gate table rows from gate_result.blockers. +Build missing fields list from gate_result.missing_fields. + +Use the "Gate Blocked Comment" template from @~/.claude/commands/mgw/workflows/github.md. +Post comment and apply label: +```bash +# Use remove_mgw_labels_and_apply pattern from github.md +# For validity failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# For security failures: +# pipeline_stage = "needs-security-review", label = "mgw:needs-security-review" +# For detail failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# If multiple blockers, use the highest-severity label (security > detail > validity) +``` + +**If gates passed (gate_result.status == "passed"):** + +Use the "Gate Passed Comment" template from @~/.claude/commands/mgw/workflows/github.md. +Post comment and apply label: +```bash +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:triaged" 2>/dev/null +``` + +``` + +3. Modify the `present_report` step to display gate results after the triage report: + +After the existing report display, add gate result display: +``` +${if gate_result.status == "blocked":} + GATES: BLOCKED + ${for blocker in gate_result.blockers:} + - ${blocker} + ${end} + + ${if gate_result.missing_fields:} + Missing information: + ${for field in gate_result.missing_fields:} + - ${field} + ${end} + ${end} + + The issue needs updates before pipeline execution. + Options: + 1) Wait for updates → issue stays in needs-info/needs-security-review + 2) Override → proceed despite gate failures (adds acknowledgment to state) + 3) Reject → issue is invalid or out of scope + +${else:} + GATES: PASSED ${if gate_result.warnings: '(with warnings)'} + ${for warning in gate_result.warnings:} + - Warning: ${warning} + ${end} + + Options: + 1) Accept recommendation → proceed with ${recommended_route} + 2) Override route → choose different GSD entry point + 3) Reject → issue is invalid or out of scope +${end} +``` + +Update the AskUserQuestion to handle the blocked scenario: +``` +AskUserQuestion( + header: "Triage Decision", + question: "${gate_result.status == 'blocked' ? 'Override gates (1), wait for updates (2), or reject (3)?' : 'Accept recommendation (1), override (2), or reject (3)?'}", + followUp: "${gate_result.status == 'blocked' ? 'Override will log acknowledgment. Wait keeps issue in blocked state.' : 'If overriding, specify: quick, quick --full, or new-milestone'}" +) +``` + +4. Modify `write_state` step to: + - Store `gate_result` in the triage object + - Set `pipeline_stage` based on gate result: + - Gates blocked + validity failure: `"needs-info"` + - Gates blocked + security failure: `"needs-security-review"` + - Gates blocked + user overrides: `"triaged"` (with override acknowledgment logged) + - Gates passed: `"triaged"` (same as current behavior) + +5. Modify `offer_next` step: + - If gates blocked and user chose "wait": report the blocked status and suggest updating the issue, no state file written + - If gates blocked and user overrode: proceed as normal but log override in state + - If gates passed: same as current behavior + +6. Update `success_criteria` to add: + ``` + - [ ] Triage gates evaluated (validity, security, detail sufficiency) + - [ ] Gate result stored in state file + - [ ] Triage comment posted IMMEDIATELY to GitHub + - [ ] Blocked issues get appropriate mgw: label + - [ ] Passed issues get mgw:triaged label + ``` + +**commands/run.md -- Add pipeline validation gates:** + +1. Modify the `validate_and_load` step. After loading the state file and checking pipeline_stage, add NEW gate validation checks before proceeding: + +After the existing stage checks (triaged, planning, executing, blocked, pr-created, done), add: +``` + - "needs-info" → Check for --force flag in $ARGUMENTS: + If --force NOT present: + "Pipeline for #${ISSUE_NUMBER} is blocked by triage gate (needs-info). + The issue requires more detail before execution can begin. + + To override: /mgw:run ${ISSUE_NUMBER} --force + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage after updating the issue)" + STOP. + If --force present: + Log warning: "MGW: WARNING — Overriding needs-info gate for #${ISSUE_NUMBER}. Proceeding with --force." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. + + - "needs-security-review" → Check for --security-ack flag in $ARGUMENTS: + If --security-ack NOT present: + "Pipeline for #${ISSUE_NUMBER} requires security review. + This issue was flagged as high security risk during triage. + + To acknowledge and proceed: /mgw:run ${ISSUE_NUMBER} --security-ack + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage)" + STOP. + If --security-ack present: + Log warning: "MGW: WARNING — Acknowledging security risk for #${ISSUE_NUMBER}. Proceeding with --security-ack." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. +``` + +2. In the `create_worktree` step, after worktree creation succeeds, add label application: +```bash +# Apply in-progress label +# Use remove_mgw_labels_and_apply pattern from github.md +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:triaged" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:in-progress" 2>/dev/null +``` + +3. In the `preflight_comment_check` step, add security keyword detection to the material classification: +After the existing comment classification, if classification is "material", also check: +``` +# Check for security keywords in material comments +SECURITY_KEYWORDS="security|vulnerability|CVE|exploit|injection|XSS|CSRF|auth bypass" +if echo "$NEW_COMMENTS" | grep -qiE "$SECURITY_KEYWORDS"; then + gate_result.warnings.push("Material comment contains security keywords — consider re-triage") + # Prompt user: "Security-related comment detected. Re-triage recommended. Continue or re-triage?" +fi +``` + +Also update the blocking classification handling to apply the "mgw:blocked" label: +```bash +# When blocking comment detected: +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:blocked" 2>/dev/null +``` + +4. For the `execute_gsd_milestone` step (new-milestone route), add a discussion phase trigger: +After step 1 (Create milestone), if the route is new-milestone, add: +``` +# Post scope proposal comment using template from github.md +# Set pipeline_stage to "discussing" +# Apply "mgw:discussing" label +# Wait for user approval before proceeding to phase execution +``` + +5. Modify the `post_triage_update` step: change comment tag from `triage-complete` to `work-starting` since triage comment is now posted during /mgw:issue. Update the header to "### Work Starting" instead of "### Triage Complete". + +6. In the `cleanup_and_complete` step, add label cleanup: +```bash +# Remove in-progress label at completion +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +``` + +7. Update success_criteria to add: + ``` + - [ ] Pipeline refuses needs-info without --force + - [ ] Pipeline refuses needs-security-review without --security-ack + - [ ] mgw:in-progress label applied during execution + - [ ] mgw:in-progress label removed at completion + - [ ] mgw:blocked label applied when blocking comments detected + - [ ] New-milestone route triggers discussion phase + ``` + +**commands/review.md -- Add resolution classification:** + +1. In the `classify_comments` step, add "resolution" as a fourth classification type in the classification_rules: + +Update the classification_rules section to add: +``` +- **resolution** — Comment indicates a previously identified blocker or issue has been resolved. + Examples: 'The dependency has been updated', 'Security review complete — approved', + 'Added the missing acceptance criteria', 'Updated the issue with more detail', + 'Fixed the blocking issue in #42'. +``` + +Update the priority logic: +``` +If ANY comment in the batch is blocking, overall classification is blocking. +If ANY comment is resolution (and none blocking), overall classification is resolution. +If ANY comment is material (and none blocking/resolution), overall classification is material. +Otherwise, informational. +``` + +Update the output_format JSON to include resolution fields: +```json +{ + "classification": "material|informational|blocking|resolution", + "reasoning": "Brief explanation", + "per_comment": [...], + "new_requirements": [], + "blocking_reason": "", + "resolved_blocker": "description of what was resolved, empty string otherwise" +} +``` + +2. In the `present_and_act` step, add a new block for resolution classification: + +``` +**If resolution:** +``` +AskUserQuestion( + header: "Blocker Resolution Detected", + question: "A previous blocker appears to be resolved. Re-triage this issue?", + options: [ + { label: "Re-triage", description: "Run /mgw:issue to re-analyze with updated context" }, + { label: "Acknowledge", description: "Update comment count, keep current pipeline stage" }, + { label: "Ignore", description: "Don't update state" } + ] +) +``` +If re-triage: + - Update `triage.last_comment_count` + - Suggest: "Run `/mgw:issue ${ISSUE_NUMBER}` to re-triage with the resolved context." + - If pipeline_stage is "blocked" or "needs-info" or "needs-security-review", note: "Re-triage will re-evaluate gates and may unblock the pipeline." +If acknowledge: + - Update `triage.last_comment_count` + - Keep current pipeline_stage +``` + +3. Update success_criteria to add: `- [ ] Resolution classification type supported with re-triage prompt` + +**After all source files are updated, sync deployed copies:** + +Copy each modified source command to its deployed location: +```bash +cp commands/issue.md .claude/commands/mgw/issue.md +cp commands/run.md .claude/commands/mgw/run.md +cp commands/review.md .claude/commands/mgw/review.md +``` + +Verify each copy matches: +```bash +diff commands/issue.md .claude/commands/mgw/issue.md +diff commands/run.md .claude/commands/mgw/run.md +diff commands/review.md .claude/commands/mgw/review.md +``` + + + grep -q "evaluate_gates" commands/issue.md && \ + grep -q "post_triage_github" commands/issue.md && \ + grep -q "gate_result" commands/issue.md && \ + grep -q "needs-info" commands/run.md && \ + grep -q "needs-security-review" commands/run.md && \ + grep -q "\-\-force" commands/run.md && \ + grep -q "\-\-security-ack" commands/run.md && \ + grep -q "mgw:in-progress" commands/run.md && \ + grep -q "resolution" commands/review.md && \ + grep -q "resolved_blocker" commands/review.md && \ + diff commands/issue.md .claude/commands/mgw/issue.md && \ + diff commands/run.md .claude/commands/mgw/run.md && \ + diff commands/review.md .claude/commands/mgw/review.md && \ + echo "PASS" || echo "FAIL" + + + - issue.md has evaluate_gates step between spawn_analysis and present_report + - issue.md has post_triage_github step that posts comment IMMEDIATELY + - issue.md evaluate_gates checks validity, security (high), and detail sufficiency (body < 200 chars, no AC on features) + - issue.md present_report shows gate results and offers override option + - issue.md write_state stores gate_result and sets pipeline_stage based on gate outcome + - issue.md applies mgw:needs-info, mgw:needs-security-review, or mgw:triaged label + - run.md refuses needs-info without --force flag + - run.md refuses needs-security-review without --security-ack flag + - run.md applies mgw:in-progress label during execution + - run.md applies mgw:blocked label on blocking comments + - run.md removes mgw:in-progress label at completion + - run.md new-milestone route triggers discussion phase with mgw:discussing label + - run.md post_triage_update changed to work-starting (triage comment now in issue.md) + - run.md preflight_comment_check detects security keywords in material comments + - review.md supports "resolution" classification type + - review.md offers re-triage prompt when resolution detected + - All 3 source commands synced to .claude/commands/mgw/ deployed copies + + + + + + +Run all verification commands in sequence: + +```bash +# Task 1: State and GitHub workflow foundations +grep -q "needs-info" .claude/commands/mgw/workflows/state.md +grep -q "gate_result" .claude/commands/mgw/workflows/state.md +grep -q "Stage Flow Diagram" .claude/commands/mgw/workflows/state.md +grep -q "mgw:needs-info" .claude/commands/mgw/workflows/github.md +grep -q "remove_mgw_labels_and_apply" .claude/commands/mgw/workflows/github.md +grep -q "mgw:triaged" commands/init.md +diff commands/init.md .claude/commands/mgw/init.md + +# Task 2: GitHub templates +test -f .github/ISSUE_TEMPLATE/architecture_refactor.yml +grep -q "acceptance-criteria" .github/ISSUE_TEMPLATE/bug_report.yml +grep -q "acceptance-criteria" .github/ISSUE_TEMPLATE/feature_request.yml +grep -q "Milestone Context" .github/PULL_REQUEST_TEMPLATE.md +grep -q "triage-pipeline" .github/labeler.yml + +# Task 3: Pipeline logic +grep -q "evaluate_gates" commands/issue.md +grep -q "post_triage_github" commands/issue.md +grep -q "\-\-force" commands/run.md +grep -q "\-\-security-ack" commands/run.md +grep -q "resolution" commands/review.md +diff commands/issue.md .claude/commands/mgw/issue.md +diff commands/run.md .claude/commands/mgw/run.md +diff commands/review.md .claude/commands/mgw/review.md +``` + + + +- state.md pipeline_stage enum extended with 4 new stages (needs-info, needs-security-review, discussing, approved) +- state.md triage schema has gate_result object +- state.md has stage flow diagram +- github.md defines 7 MGW pipeline labels with lifecycle operations +- github.md has 3 comment templates (gate blocked, gate passed, scope proposal) +- init.md creates 7 mgw:* labels +- bug_report.yml has 5 new fields +- feature_request.yml has 7 new fields +- architecture_refactor.yml exists as new template +- PR template redesigned with 10 sections +- labeler.yml has triage-pipeline rule +- issue.md evaluates 3 quality gates and posts immediate feedback +- run.md validates gate status with --force and --security-ack overrides +- run.md manages mgw:in-progress and mgw:blocked labels +- review.md supports resolution classification with re-triage prompt +- All source commands/ synced to .claude/commands/mgw/ deployed copies + + + +After completion, create `.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-SUMMARY.md` + diff --git a/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-SUMMARY.md b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-SUMMARY.md new file mode 100644 index 0000000..4c250fa --- /dev/null +++ b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-SUMMARY.md @@ -0,0 +1,154 @@ +--- +phase: quick-2 +plan: 01 +subsystem: triage-pipeline +tags: [triage, gates, labels, templates, pipeline-validation] +dependency_graph: + requires: [] + provides: [triage-gate-evaluation, pipeline-gate-validation, resolution-classification, mgw-pipeline-labels, ai-optimized-templates] + affects: [issue.md, run.md, review.md, init.md, state.md, github.md, github-templates] +tech_stack: + added: [] + patterns: [gate-evaluation, label-lifecycle, immediate-github-feedback, resolution-classification] +key_files: + created: + - .github/ISSUE_TEMPLATE/architecture_refactor.yml + modified: + - .claude/commands/mgw/workflows/state.md + - .claude/commands/mgw/workflows/github.md + - commands/init.md + - .claude/commands/mgw/init.md + - .github/ISSUE_TEMPLATE/bug_report.yml + - .github/ISSUE_TEMPLATE/feature_request.yml + - .github/PULL_REQUEST_TEMPLATE.md + - .github/labeler.yml + - commands/issue.md + - .claude/commands/mgw/issue.md + - commands/run.md + - .claude/commands/mgw/run.md + - commands/review.md + - .claude/commands/mgw/review.md +decisions: + - "Triage comments posted IMMEDIATELY during /mgw:issue rather than deferred to /mgw:run — gives stakeholders instant visibility" + - "Gate severity order: security > detail > validity for label selection on multiple blockers" + - "run.md post_triage_update renamed to work-starting to avoid confusion with triage comment from issue.md" + - "resolution classification added as 4th type alongside material/informational/blocking" + - "Discussion phase for new-milestone route is opt-in (user can proceed or wait for stakeholder approval)" +metrics: + duration: "~45 minutes" + completed: "2026-02-27T20:31:24Z" + tasks_completed: 3 + tasks_total: 3 + files_modified: 13 + files_created: 1 +--- + +# Phase Quick-2 Plan 01: Bidirectional Triage Gates with AI-Optimized Templates Summary + +Bidirectional triage quality gates with immediate GitHub feedback, 7 MGW pipeline labels, AI-optimized issue/PR templates, gate validation in run.md, and resolution classification in review.md. + +## What Was Built + +### Task 1: State Schema, GitHub Labels, and Init Bootstrapper + +**state.md extensions:** +- Extended `pipeline_stage` enum from 7 to 13 values, adding: `needs-info`, `needs-security-review`, `discussing`, `approved`, `failed`, `blocked` +- Added `gate_result` object to triage schema with `status`, `blockers`, `warnings`, `missing_fields` fields +- Added Stage Flow Diagram section documenting all valid stage transitions + +**github.md additions:** +- New "Label Lifecycle Operations" section with 7 MGW pipeline label definitions (color-coded table) +- `remove_mgw_labels_and_apply()` bash function for atomic label transitions +- Three comment templates: Gate Blocked, Gate Passed, Scope Proposal + +**init.md updates:** +- 7 `mgw:*` label creation commands in `ensure_labels` step +- Updated report to show "MGW pipeline labels synced (7 labels)" +- Added success criteria for label bootstrapping + +### Task 2: GitHub Issue and PR Templates + +**bug_report.yml** — 5 new fields added: +- `acceptance-criteria` (textarea) — fix completion conditions +- `scope-estimate` (dropdown) — Small/Medium/Large +- `security-impact` (checkboxes) — auth, data, validation, API, none +- `whats-involved` (textarea) — files table +- `related-issues` (input) — issue references + +**feature_request.yml** — 7 new fields added: +- `acceptance-criteria` (textarea, **required**) — testable done conditions +- `scope-estimate` (dropdown) +- `priority` (dropdown) — Nice to have / Should have / Must have / Critical +- `security-impact` (checkboxes) +- `whats-involved` (textarea) +- `non-functional` (textarea) — performance/scalability requirements +- `related-issues` (input) + +**architecture_refactor.yml** — NEW template with 10 fields: +- `bluf`, `current-state`, `target-state`, `migration-strategy`, `risk-areas`, `breaking-changes`, `acceptance-criteria`, `scope-estimate`, `whats-involved`, `related-issues` + +**PULL_REQUEST_TEMPLATE.md** — Redesigned from 3 to 10 sections: +- Summary, Milestone Context, Changes, Design Decisions, Security & Performance, Artifacts, Breaking Changes, Test Plan, Cross-References, Checklist + +**labeler.yml** — Added `triage-pipeline` rule covering issue.md, run.md, review.md, state.md, github.md + +### Task 3: Triage Gates, Pipeline Validation, Resolution Classification + +**commands/issue.md** — 2 new steps, 3 modified steps: +- NEW `evaluate_gates` step: evaluates 3 gates (validity, security, detail sufficiency) after analysis agent returns +- NEW `post_triage_github` step: posts immediate GitHub comment (blocked or passed) and applies appropriate `mgw:` label +- Modified `present_report`: displays gate results with override/wait/reject flow +- Modified `write_state`: stores `gate_result`, sets `pipeline_stage` based on gate outcome +- Modified `offer_next`: handles wait/override/accepted flows separately + +**commands/run.md** — multiple steps extended: +- `validate_and_load`: refuses `needs-info` without `--force`, refuses `needs-security-review` without `--security-ack` +- `create_worktree`: applies `mgw:in-progress` label after worktree creation +- `preflight_comment_check`: added security keyword detection for material comments; applies `mgw:blocked` label when blocking detected +- `post_triage_update` renamed to `work-starting` (triage comment now lives in issue.md) +- `execute_gsd_milestone`: discussion phase trigger for new-milestone route with scope proposal comment and `mgw:discussing` label +- `cleanup_and_complete`: removes `mgw:in-progress` label at completion + +**commands/review.md** — resolution classification: +- Added `resolution` as 4th classification type to `classify_comments` rules +- Updated priority logic: blocking > resolution > material > informational +- Updated JSON output format to include `resolved_blocker` field +- Added `present_and_act` block for resolution: offers re-triage, acknowledge, or ignore + +**Deployed copies synced:** All 3 source commands synced to `.claude/commands/mgw/` + +## Commits + +| Hash | Description | +|------|-------------| +| `e3fa0c3` | feat(quick-2): extend state schema, add MGW pipeline labels and triage comment templates | +| `9e90754` | feat(quick-2): redesign GitHub issue and PR templates with triage-optimized fields | +| `4659c73` | feat(quick-2): implement triage gates, pipeline validation, and resolution classification | + +## Deviations from Plan + +None — plan executed exactly as written. + +## Self-Check: PASSED + +Files verified: +- `.claude/commands/mgw/workflows/state.md` — FOUND +- `.claude/commands/mgw/workflows/github.md` — FOUND +- `commands/init.md` — FOUND +- `.claude/commands/mgw/init.md` — FOUND (matches source) +- `.github/ISSUE_TEMPLATE/bug_report.yml` — FOUND +- `.github/ISSUE_TEMPLATE/feature_request.yml` — FOUND +- `.github/ISSUE_TEMPLATE/architecture_refactor.yml` — FOUND (new) +- `.github/PULL_REQUEST_TEMPLATE.md` — FOUND +- `.github/labeler.yml` — FOUND +- `commands/issue.md` — FOUND +- `.claude/commands/mgw/issue.md` — FOUND (matches source) +- `commands/run.md` — FOUND +- `.claude/commands/mgw/run.md` — FOUND (matches source) +- `commands/review.md` — FOUND +- `.claude/commands/mgw/review.md` — FOUND (matches source) + +Commits verified: +- `e3fa0c3` — FOUND +- `9e90754` — FOUND +- `4659c73` — FOUND diff --git a/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-VERIFICATION.md b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-VERIFICATION.md new file mode 100644 index 0000000..1a6adb5 --- /dev/null +++ b/.planning/quick/2-feat-bidirectional-triage-gates-with-ai-/2-VERIFICATION.md @@ -0,0 +1,113 @@ +--- +phase: quick-2 +verified: 2026-02-27T21:00:00Z +status: passed +score: 15/15 must-haves verified +--- + +# Phase Quick-2: Bidirectional Triage Gates with AI-Optimized Templates — Verification Report + +**Phase Goal:** Add enforced triage quality gates, immediate GitHub feedback during /mgw:issue, AI-optimized issue/PR templates, and bidirectional stakeholder engagement loops to the MGW pipeline. +**Verified:** 2026-02-27T21:00:00Z +**Status:** passed +**Re-verification:** No — initial verification + +## Goal Achievement + +### Observable Truths + +| # | Truth | Status | Evidence | +|---|-------|--------|----------| +| 1 | Triage agent evaluates quality gates (validity, security, detail sufficiency) and blocks on failure | VERIFIED | `evaluate_gates` step in commands/issue.md lines 204-262 implements all three gates with blocker logic | +| 2 | validity=invalid issues get pipeline_stage=needs-info, mgw:needs-info label, and structured comment | VERIFIED | issue.md post_triage_github step (lines 265-320) applies mgw:needs-info label; write_state sets pipeline_stage=needs-info (lines 381-411) | +| 3 | security=high issues get pipeline_stage=needs-security-review, label, and comment | VERIFIED | issue.md post_triage_github step references needs-security-review; write_state routes security failures to that stage | +| 4 | Insufficient detail (body < 200 chars, no AC on features) results in needs-info | VERIFIED | Gate 3 in evaluate_gates explicitly checks BODY_LENGTH < 200 and IS_FEATURE without HAS_AC (lines 238-251) | +| 5 | Triage comment is posted IMMEDIATELY during /mgw:issue (not deferred to /mgw:run) | VERIFIED | post_triage_github step is step 5 of issue.md process; run.md post_triage_update renamed to work-starting with explicit note that triage comment now lives in issue.md (line 273-275) | +| 6 | /mgw:run on needs-info without --force refuses to execute | VERIFIED | run.md validate_and_load lines 81-93: checks --force flag, stops with error message if not present | +| 7 | /mgw:run on needs-security-review without --security-ack refuses to execute | VERIFIED | run.md validate_and_load lines 95-108: checks --security-ack flag, stops with error message if not present | +| 8 | bug_report.yml includes acceptance criteria, scope estimate, security checkboxes, whats-involved, related issues | VERIFIED | All 5 fields present: acceptance-criteria (line 75), scope-estimate (line 83), security-impact checkboxes (line 95), whats-involved (line 107), related-issues (line 116) | +| 9 | feature_request.yml includes acceptance criteria (required), scope estimate, priority, security, whats-involved, non-functional, related issues | VERIFIED | All 7 fields present: acceptance-criteria required=true (line 54), scope-estimate (line 62), priority dropdown (line 73), security-impact checkboxes (line 86), whats-involved (line 98), non-functional (line 107), related-issues (line 116) | +| 10 | architecture_refactor.yml template exists with current state, target state, migration strategy, risk areas, breaking changes | VERIFIED | File exists at .github/ISSUE_TEMPLATE/architecture_refactor.yml with all required fields (current-state, target-state, migration-strategy, risk-areas, breaking-changes, plus acceptance-criteria, scope-estimate, whats-involved, related-issues) | +| 11 | PR template has milestone context table, design decisions, security/performance, artifacts table, breaking changes, cross-references | VERIFIED | All 6 sections verified in PULL_REQUEST_TEMPLATE.md: Milestone Context (line 8), Design Decisions (line 29), Security & Performance (line 36), Artifacts table (line 42), Breaking Changes (line 49), Cross-References (line 59) | +| 12 | review.md supports resolution classification type with re-triage prompt | VERIFIED | review.md classify_comments includes resolution as 4th type (line 127); present_and_act has resolution branch with re-triage/acknowledge/ignore options (lines 227-245); resolved_blocker in JSON output (line 152) | +| 13 | 7 new MGW pipeline labels defined in github.md and created by init.md | VERIFIED | github.md Label Lifecycle Operations table lists all 7 labels; init.md ensure_labels step creates all 7 with gh label create commands (lines 203-211) | +| 14 | state.md has new pipeline stages: needs-info, needs-security-review, discussing, approved | VERIFIED | pipeline_stage enum in state.md schema includes all 4 new stages plus failed and blocked (line 219); Stage Flow Diagram documents valid transitions (lines 227-252) | +| 15 | state.md triage schema includes gate_result with passed, blockers, warnings, missing_fields | VERIFIED | gate_result object defined in schema (lines 210-215) with status: "passed|blocked", blockers, warnings, missing_fields arrays | + +**Score:** 15/15 truths verified + +### Required Artifacts + +| Artifact | Provides | Status | Details | +|----------|----------|--------|---------| +| `.claude/commands/mgw/workflows/state.md` | Extended pipeline stages and gate_result schema | VERIFIED | Contains needs-info in pipeline_stage enum; gate_result schema; Stage Flow Diagram section | +| `.claude/commands/mgw/workflows/github.md` | Label ops, triage gate comment templates, scope proposal template | VERIFIED | 7 MGW pipeline labels table; remove_mgw_labels_and_apply function; Gate Blocked/Passed/Scope Proposal templates | +| `.github/ISSUE_TEMPLATE/architecture_refactor.yml` | NEW architecture refactor issue template | VERIFIED | 114-line template with all required fields | +| `.github/PULL_REQUEST_TEMPLATE.md` | Redesigned PR template with 10 sections | VERIFIED | 68-line template with all required sections | +| `commands/issue.md` | Triage gates and immediate GitHub feedback | VERIFIED | evaluate_gates and post_triage_github steps present and substantive | +| `commands/run.md` | Pipeline validation gates | VERIFIED | needs-info and needs-security-review gate checks in validate_and_load | +| `commands/review.md` | Resolution classification | VERIFIED | resolution as 4th classification type with re-triage prompt | +| `commands/init.md` | 7 MGW label bootstrapping | VERIFIED | ensure_labels step creates all 7 mgw:* labels; report shows "synced (7 labels)" | + +### Key Link Verification + +| From | To | Via | Status | Details | +|------|----|-----|--------|---------| +| commands/issue.md | workflows/state.md | gate_result schema reference | VERIFIED | issue.md evaluate_gates step builds gate_result object matching state.md schema | +| commands/issue.md | workflows/github.md | triage gate comment templates | VERIFIED | post_triage_github references "Gate Blocked Comment" and "Gate Passed Comment" templates from github.md | +| commands/run.md | workflows/state.md | pipeline_stage validation | VERIFIED | validate_and_load checks pipeline_stage for needs-info and needs-security-review before execution | +| commands/init.md | workflows/github.md | label definitions | VERIFIED | init.md ensure_labels creates labels matching github.md Label Lifecycle Operations table | + +### Deployed Copy Sync + +| Source | Deployed | Status | +|--------|----------|--------| +| commands/issue.md | .claude/commands/mgw/issue.md | IDENTICAL (diff exit 0) | +| commands/run.md | .claude/commands/mgw/run.md | IDENTICAL (diff exit 0) | +| commands/review.md | .claude/commands/mgw/review.md | IDENTICAL (diff exit 0) | +| commands/init.md | .claude/commands/mgw/init.md | IDENTICAL (diff exit 0) | + +### Requirements Coverage + +| Requirement | Description | Status | Evidence | +|-------------|-------------|--------|----------| +| TRIAGE-GATES | evaluate_gates and post_triage_github steps in issue.md | SATISFIED | evaluate_gates step implements validity, security, detail gates; post_triage_github posts immediate comment | +| TEMPLATES | AI-optimized issue/PR templates | SATISFIED | bug_report.yml, feature_request.yml extended; architecture_refactor.yml created; PULL_REQUEST_TEMPLATE.md redesigned | +| PIPELINE-VALIDATION | run.md gate enforcement | SATISFIED | validate_and_load blocks on needs-info without --force and needs-security-review without --security-ack | +| COMMENT-CLASSIFICATION | resolution type in review.md | SATISFIED | review.md adds resolution as 4th classification with re-triage prompt | +| STATE-LABELS | 7 MGW labels, extended stages, gate_result schema | SATISFIED | state.md extended; github.md defines 7 labels; init.md bootstraps them | + +### Anti-Patterns Found + +No TODO/FIXME/placeholder patterns detected in modified files. No empty implementations found. All steps in commands contain substantive logic appropriate for an AI-directed workflow document format. + +### Commits Verified + +| Hash | Description | Verified | +|------|-------------|---------| +| e3fa0c3 | feat(quick-2): extend state schema, add MGW pipeline labels and triage comment templates | EXISTS | +| 9e90754 | feat(quick-2): redesign GitHub issue and PR templates with triage-optimized fields | EXISTS | +| 4659c73 | feat(quick-2): implement triage gates, pipeline validation, and resolution classification | EXISTS | + +### Human Verification Required + +None — all acceptance criteria are verifiable by reading the command documents. The commands define procedures for Claude Code to execute; actual runtime behavior depends on LLM execution context rather than compiled code, so there is no programmatic execution path to test. The documents are complete and internally consistent. + +### Summary + +All 15 must-haves verified. The implementation is complete: + +- Triage gates (validity, security, detail sufficiency) are implemented in issue.md with three distinct gate evaluations +- Immediate GitHub feedback is wired: post_triage_github step posts comments and applies labels during /mgw:issue, not deferred to /mgw:run +- Pipeline validation blocks execution on needs-info without --force and needs-security-review without --security-ack +- All three GitHub issue templates are substantive: bug_report.yml and feature_request.yml extended with required triage fields, architecture_refactor.yml created fresh +- PR template redesigned from 3 to 10 sections covering all required areas +- Resolution classification added as 4th type in review.md with re-triage offer +- 7 MGW pipeline labels defined in github.md and bootstrapped by init.md +- state.md extended with 6 new pipeline stages and gate_result schema with Stage Flow Diagram +- All source commands synced to deployed .claude/commands/mgw/ copies (diff exit 0 on all four) + +--- + +_Verified: 2026-02-27T21:00:00Z_ +_Verifier: Claude (gsd-verifier)_ diff --git a/commands/init.md b/commands/init.md index b589ded..b901eb0 100644 --- a/commands/init.md +++ b/commands/init.md @@ -199,6 +199,15 @@ If exists → report "PR template already exists, skipping." ```bash gh label create "bug" --description "Something isn't working" --color "d73a4a" --force gh label create "enhancement" --description "New feature or improvement" --color "a2eeef" --force + +# MGW pipeline labels +gh label create "mgw:triaged" --description "Issue triaged and ready for pipeline" --color "0e8a16" --force +gh label create "mgw:needs-info" --description "Blocked — needs more detail or clarification" --color "e4e669" --force +gh label create "mgw:needs-security-review" --description "Blocked — requires security review" --color "d93f0b" --force +gh label create "mgw:discussing" --description "Under discussion — not yet approved" --color "c5def5" --force +gh label create "mgw:approved" --description "Discussion complete — approved for execution" --color "0e8a16" --force +gh label create "mgw:in-progress" --description "Pipeline actively executing" --color "1d76db" --force +gh label create "mgw:blocked" --description "Pipeline blocked by stakeholder comment" --color "b60205" --force ``` `--force` updates existing labels without error. @@ -218,6 +227,7 @@ gh label create "enhancement" --description "New feature or improvement" --color Issue templates ${created|exists} PR template ${created|exists} GitHub labels synced + MGW pipeline labels synced (7 labels) Ready to use: /mgw:issues Browse issues @@ -235,5 +245,6 @@ Ready to use: - [ ] Issue templates created (bug + enhancement) - [ ] PR template created - [ ] GitHub labels ensured (bug, enhancement) +- [ ] MGW pipeline labels ensured (7 mgw:* labels) - [ ] Setup report shown diff --git a/commands/issue.md b/commands/issue.md index 8167638..5a9c3ac 100644 --- a/commands/issue.md +++ b/commands/issue.md @@ -201,10 +201,129 @@ Return a structured report: ``` + +**Evaluate triage quality gates:** + +After the analysis agent returns, evaluate three quality gates against the triage report +and the original issue data. This determines whether the issue can proceed to pipeline +execution or requires additional information/review. + +Initialize gate result: +``` +gate_result = { + "status": "passed", + "blockers": [], + "warnings": [], + "missing_fields": [] +} +``` + +**Gate 1: Validity** +``` +if triage.validity == "invalid": + gate_result.blockers.push("Validity gate failed: issue could not be confirmed against codebase") + gate_result.status = "blocked" +``` + +**Gate 2: Security** +``` +if triage.security_risk == "high": + gate_result.blockers.push("Security gate: high-risk issue requires security review before execution") + gate_result.status = "blocked" +``` + +**Gate 3: Detail Sufficiency** +Evaluate the original issue body (not the triage report): +``` +BODY_LENGTH = len(issue_body.strip()) +HAS_AC = issue has acceptance criteria field filled OR body contains "- [ ]" checklist items +IS_FEATURE = "enhancement" in issue_labels OR issue template is feature_request + +if BODY_LENGTH < 200: + gate_result.blockers.push("Insufficient detail: issue body is ${BODY_LENGTH} characters (minimum 200)") + gate_result.missing_fields.push("Expand issue description with more detail") + gate_result.status = "blocked" + +if IS_FEATURE and not HAS_AC: + gate_result.blockers.push("Feature requests require acceptance criteria") + gate_result.missing_fields.push("Add acceptance criteria (checklist of testable conditions)") + gate_result.status = "blocked" +``` + +**Gate warnings (non-blocking):** +``` +if triage.security_risk == "medium": + gate_result.warnings.push("Medium security risk — consider review before execution") + +if triage.scope.size == "large" and gsd_route != "gsd:new-milestone": + gate_result.warnings.push("Large scope detected but not routed to new-milestone") +``` + +Set `gate_result.status = "passed"` if no blockers. Store gate_result for state file. + + + +**Post immediate triage feedback to GitHub:** + +This step posts a comment on the GitHub issue IMMEDIATELY during /mgw:issue, not +deferred to /mgw:run. This gives stakeholders visibility into triage results as +soon as they happen. + +Generate timestamp: +```bash +TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") +``` + +**If gates blocked (gate_result.status == "blocked"):** + +Build gate table rows from gate_result.blockers: +``` +GATE_TABLE_ROWS = gate_result.blockers formatted as "| ${blocker} | Blocked |" rows +``` + +Build missing fields list from gate_result.missing_fields: +``` +MISSING_FIELDS_LIST = gate_result.missing_fields formatted as "- ${field}" list +``` + +Use the "Gate Blocked Comment" template from @~/.claude/commands/mgw/workflows/github.md. +Post comment and apply label: +```bash +# Use remove_mgw_labels_and_apply pattern from github.md +# For validity failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# For security failures: +# pipeline_stage = "needs-security-review", label = "mgw:needs-security-review" +# For detail failures: +# pipeline_stage = "needs-info", label = "mgw:needs-info" +# If multiple blockers, use the highest-severity label (security > detail > validity) +``` + +**If gates passed (gate_result.status == "passed"):** + +Use the "Gate Passed Comment" template from @~/.claude/commands/mgw/workflows/github.md. + +Populate template variables: +``` +SCOPE_SIZE = triage.scope.size +FILE_COUNT = triage.scope.file_count +SYSTEM_LIST = triage.scope.systems joined with ", " +VALIDITY = triage.validity +SECURITY_RISK = triage.security_notes +gsd_route = recommended route +ROUTE_REASONING = triage reasoning +``` + +Post comment and apply label: +```bash +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:triaged" 2>/dev/null +``` + + **Present triage report to user:** -Display the analysis agent's report verbatim, then: +Display the analysis agent's report verbatim, then display gate results: ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -213,18 +332,48 @@ Display the analysis agent's report verbatim, then: Recommended route: ${recommended_route} Reasoning: ${reasoning} +``` + +Then display gate results: -Options: - 1) Accept recommendation → proceed with ${recommended_route} - 2) Override route → choose different GSD entry point - 3) Reject → issue is invalid or out of scope +``` +${if gate_result.status == "blocked":} + GATES: BLOCKED + ${for blocker in gate_result.blockers:} + - ${blocker} + ${end} + + ${if gate_result.missing_fields:} + Missing information: + ${for field in gate_result.missing_fields:} + - ${field} + ${end} + ${end} + + The issue needs updates before pipeline execution. + Options: + 1) Wait for updates → issue stays in needs-info/needs-security-review + 2) Override → proceed despite gate failures (adds acknowledgment to state) + 3) Reject → issue is invalid or out of scope + +${else:} + GATES: PASSED ${if gate_result.warnings: '(with warnings)'} + ${for warning in gate_result.warnings:} + - Warning: ${warning} + ${end} + + Options: + 1) Accept recommendation → proceed with ${recommended_route} + 2) Override route → choose different GSD entry point + 3) Reject → issue is invalid or out of scope +${end} ``` ``` AskUserQuestion( header: "Triage Decision", - question: "Accept recommendation (1), override (2), or reject (3)?", - followUp: "If overriding, specify: quick, quick --full, or new-milestone" + question: "${gate_result.status == 'blocked' ? 'Override gates (1), wait for updates (2), or reject (3)?' : 'Accept recommendation (1), override (2), or reject (3)?'}", + followUp: "${gate_result.status == 'blocked' ? 'Override will log acknowledgment. Wait keeps issue in blocked state.' : 'If overriding, specify: quick, quick --full, or new-milestone'}" ) ``` @@ -232,7 +381,7 @@ AskUserQuestion( **Write issue state file:** -If accepted or overridden (not rejected): +If accepted, overridden, or gates blocked but user overrides (not rejected, not "wait"): Generate slug from title using gsd-tools: ```bash @@ -246,8 +395,13 @@ Populate: - triage: from analysis report - triage.last_comment_count: from $COMMENT_COUNT (captured in fetch_issue step) - triage.last_comment_at: from $LAST_COMMENT_AT (captured in fetch_issue step, null if no comments) +- triage.gate_result: from gate_result evaluation (status, blockers, warnings, missing_fields) - gsd_route: confirmed or overridden route -- pipeline_stage: "triaged" +- pipeline_stage: set based on gate outcome: + - Gates blocked + validity failure (and not overridden): `"needs-info"` + - Gates blocked + security failure (and not overridden): `"needs-security-review"` + - Gates blocked + user overrides: `"triaged"` (with override_log entry noting acknowledged gate failures) + - Gates passed: `"triaged"` - All other fields: defaults (empty arrays, null) Also add branch cross-ref: @@ -260,7 +414,7 @@ Add to linked_branches if not main/master. **Offer next steps:** -If accepted/overridden: +If accepted/overridden (gates passed): ``` Issue #${ISSUE_NUMBER} triaged and tracked in .mgw/active/${filename}. @@ -269,6 +423,25 @@ Next steps: → /mgw:update ${ISSUE_NUMBER} — Post triage comment to GitHub ``` +If gates blocked and user chose "wait" (no state file written): +``` +Issue #${ISSUE_NUMBER} is blocked pending more information. +A comment has been posted to GitHub explaining what's needed. + +When the issue is updated: + → /mgw:issue ${ISSUE_NUMBER} — Re-triage with updated context +``` + +If gates blocked and user overrode: +``` +Issue #${ISSUE_NUMBER} triaged with gate override. Tracked in .mgw/active/${filename}. + +Note: Gate failures acknowledged. Override logged in state. + +Next steps: + → /mgw:run ${ISSUE_NUMBER} — Start autonomous pipeline +``` + If rejected: ``` Issue #${ISSUE_NUMBER} rejected. No state file created. @@ -285,7 +458,12 @@ Consider closing or commenting on the issue with your reasoning. - [ ] Analysis agent spawned and returned structured report - [ ] Scope, validity, security, conflicts all assessed - [ ] GSD route recommended with reasoning +- [ ] Triage gates evaluated (validity, security, detail sufficiency) +- [ ] Gate result stored in state file +- [ ] Triage comment posted IMMEDIATELY to GitHub +- [ ] Blocked issues get appropriate mgw: label (mgw:needs-info or mgw:needs-security-review) +- [ ] Passed issues get mgw:triaged label - [ ] User confirms, overrides, or rejects -- [ ] State file written to .mgw/active/ (if accepted) with comment tracking fields +- [ ] State file written to .mgw/active/ (if accepted) with comment tracking fields and gate_result - [ ] Next steps offered diff --git a/commands/review.md b/commands/review.md index 2e1bb12..9a930e1 100644 --- a/commands/review.md +++ b/commands/review.md @@ -124,25 +124,32 @@ Classify each comment (and the overall batch) into ONE of: Examples: 'Don't work on this yet', 'Hold off', 'Blocked by external dependency', 'Wait for design review'. +- **resolution** — Comment indicates a previously identified blocker or issue has been resolved. + Examples: 'The dependency has been updated', 'Security review complete — approved', + 'Added the missing acceptance criteria', 'Updated the issue with more detail', + 'Fixed the blocking issue in #42'. + If ANY comment in the batch is blocking, overall classification is blocking. -If ANY comment is material (and none blocking), overall classification is material. +If ANY comment is resolution (and none blocking), overall classification is resolution. +If ANY comment is material (and none blocking/resolution), overall classification is material. Otherwise, informational. Return ONLY valid JSON: { - \"classification\": \"material|informational|blocking\", + \"classification\": \"material|informational|blocking|resolution\", \"reasoning\": \"Brief explanation of why this classification was chosen\", \"per_comment\": [ { \"author\": \"username\", \"snippet\": \"first 100 chars of comment\", - \"classification\": \"material|informational|blocking\" + \"classification\": \"material|informational|blocking|resolution\" } ], \"new_requirements\": [\"list of new requirements if material, empty array otherwise\"], - \"blocking_reason\": \"reason if blocking, empty string otherwise\" + \"blocking_reason\": \"reason if blocking, empty string otherwise\", + \"resolved_blocker\": \"description of what was resolved, empty string otherwise\" } ", @@ -216,6 +223,27 @@ AskUserQuestion( ``` If block: update `pipeline_stage = "blocked"` and `triage.last_comment_count` in state. If override: update `triage.last_comment_count` only, keep pipeline_stage. + +**If resolution:** +``` +AskUserQuestion( + header: "Blocker Resolution Detected", + question: "A previous blocker appears to be resolved. Re-triage this issue?", + options: [ + { label: "Re-triage", description: "Run /mgw:issue to re-analyze with updated context" }, + { label: "Acknowledge", description: "Update comment count, keep current pipeline stage" }, + { label: "Ignore", description: "Don't update state" } + ] +) +``` +If re-triage: + - Update `triage.last_comment_count` + - Suggest: "Run `/mgw:issue ${ISSUE_NUMBER}` to re-triage with the resolved context." + - If pipeline_stage is "blocked" or "needs-info" or "needs-security-review", note: + "Re-triage will re-evaluate gates and may unblock the pipeline." +If acknowledge: + - Update `triage.last_comment_count` + - Keep current pipeline_stage @@ -228,4 +256,5 @@ If override: update `triage.last_comment_count` only, keep pipeline_stage. - [ ] Classification presented to user with per-comment breakdown - [ ] User chose action (acknowledge/re-triage/block/ignore) - [ ] State file updated according to user choice +- [ ] Resolution classification type supported with re-triage prompt diff --git a/commands/run.md b/commands/run.md index 88c1932..7a6a780 100644 --- a/commands/run.md +++ b/commands/run.md @@ -78,6 +78,34 @@ If state file exists → load it. Check pipeline_stage: - "planning" / "executing" → resume from where we left off - "blocked" → "Pipeline for #${ISSUE_NUMBER} is blocked by a stakeholder comment. Review the issue comments, resolve the blocker, then re-run." - "pr-created" / "done" → "Pipeline already completed for #${ISSUE_NUMBER}. Run /mgw:sync to reconcile." + - "needs-info" → Check for --force flag in $ARGUMENTS: + If --force NOT present: + ``` + Pipeline for #${ISSUE_NUMBER} is blocked by triage gate (needs-info). + The issue requires more detail before execution can begin. + + To override: /mgw:run ${ISSUE_NUMBER} --force + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage after updating the issue) + ``` + STOP. + If --force present: + Log warning: "MGW: WARNING — Overriding needs-info gate for #${ISSUE_NUMBER}. Proceeding with --force." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. + - "needs-security-review" → Check for --security-ack flag in $ARGUMENTS: + If --security-ack NOT present: + ``` + Pipeline for #${ISSUE_NUMBER} requires security review. + This issue was flagged as high security risk during triage. + + To acknowledge and proceed: /mgw:run ${ISSUE_NUMBER} --security-ack + To review: /mgw:issue ${ISSUE_NUMBER} (re-triage) + ``` + STOP. + If --security-ack present: + Log warning: "MGW: WARNING — Acknowledging security risk for #${ISSUE_NUMBER}. Proceeding with --security-ack." + Update state: pipeline_stage = "triaged", add override_log entry. + Continue pipeline. @@ -119,6 +147,13 @@ cd "${WORKTREE_DIR}" Update state (at `${REPO_ROOT}/.mgw/active/`): add branch to linked_branches. Add cross-ref (at `${REPO_ROOT}/.mgw/cross-refs.json`): issue → branch. +**Apply in-progress label:** +```bash +# Use remove_mgw_labels_and_apply pattern from github.md +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:triaged" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:in-progress" 2>/dev/null +``` + **PATH CONVENTION for remaining steps:** - File operations, git commands, and agent work use **relative paths** (CWD = worktree) - `.mgw/` state operations use **absolute paths**: `${REPO_ROOT}/.mgw/` @@ -212,14 +247,34 @@ Return ONLY valid JSON: | Classification | Action | |---------------|--------| | **informational** | Log: "MGW: ${NEW_COUNT} new comment(s) reviewed — informational, continuing." Update `triage.last_comment_count` in state file. Continue pipeline. | -| **material** | Log: "MGW: Material comment(s) detected — scope may have changed." Update state: add new_requirements to triage context. Update `triage.last_comment_count`. Re-read issue body for updated requirements. Continue with enriched context (pass new_requirements to planner). | -| **blocking** | Log: "MGW: Blocking comment detected — pipeline paused." Update state: `pipeline_stage = "blocked"`. Post comment on issue: `> **MGW** . \`pipeline-blocked\` . Blocked by stakeholder comment. Reason: ${blocking_reason}`. Stop pipeline execution. | +| **material** | Log: "MGW: Material comment(s) detected — scope may have changed." Update state: add new_requirements to triage context. Update `triage.last_comment_count`. Re-read issue body for updated requirements. Continue with enriched context (pass new_requirements to planner). Check for security keywords in material comments (see below). | +| **blocking** | Log: "MGW: Blocking comment detected — pipeline paused." Update state: `pipeline_stage = "blocked"`. Apply mgw:blocked label. Post comment on issue: `> **MGW** . \`pipeline-blocked\` . Blocked by stakeholder comment. Reason: ${blocking_reason}`. Stop pipeline execution. | + +**Security keyword check for material comments:** +```bash +SECURITY_KEYWORDS="security|vulnerability|CVE|exploit|injection|XSS|CSRF|auth bypass" +if echo "$NEW_COMMENTS" | grep -qiE "$SECURITY_KEYWORDS"; then + # Add warning to gate_result and prompt user + echo "MGW: Security-related comment detected. Re-triage recommended." + # Prompt: "Security-related comment detected. Re-triage recommended. Continue or re-triage?" +fi +``` + +**When blocking comment detected — apply label:** +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:blocked" 2>/dev/null +``` If no new comments detected, continue normally. -**Post structured triage comment on issue:** +**Post work-starting comment on issue:** + +Note: The triage gate evaluation and triage-complete/triage-blocked comment are now +posted IMMEDIATELY during /mgw:issue. This step posts a separate work-starting +notification when pipeline execution actually begins in run.md. Gather enrichment data from triage state: ```bash @@ -227,8 +282,6 @@ SCOPE_SIZE="${triage.scope.size}" # small|medium|large FILE_COUNT="${triage.scope.file_count}" SYSTEM_LIST="${triage.scope.systems}" FILE_LIST="${triage.scope.files}" -VALIDITY="${triage.validity}" -SECURITY_RISK="${triage.security_notes}" CONFLICTS="${triage.conflicts}" ROUTE_REASONING="${triage.route_reasoning}" TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") @@ -248,21 +301,19 @@ for m in p['milestones']: fi ``` -Post the triage comment directly (no sub-agent — guarantees it happens): +Post the work-starting comment directly (no sub-agent — guarantees it happens): ```bash -TRIAGE_BODY=$(cat < **MGW** · \`triage-complete\` · ${TIMESTAMP} +WORK_STARTING_BODY=$(cat < **MGW** · \`work-starting\` · ${TIMESTAMP} > ${MILESTONE_CONTEXT} -### Triage Complete +### Work Starting | | | |---|---| -| **Scope** | ${SCOPE_SIZE} — ${FILE_COUNT} files across ${SYSTEM_LIST} | -| **Validity** | ${VALIDITY} | -| **Security** | ${SECURITY_RISK} | | **Route** | \`${gsd_route}\` — ${ROUTE_REASONING} | +| **Scope** | ${SCOPE_SIZE} — ${FILE_COUNT} files across ${SYSTEM_LIST} | | **Conflicts** | ${CONFLICTS} | Work begins on branch \`${BRANCH_NAME}\`. @@ -276,7 +327,7 @@ ${FILE_LIST as bullet points} COMMENTEOF ) -gh issue comment ${ISSUE_NUMBER} --body "$TRIAGE_BODY" 2>/dev/null || true +gh issue comment ${ISSUE_NUMBER} --body "$WORK_STARTING_BODY" 2>/dev/null || true ``` Log comment in state file (at `${REPO_ROOT}/.mgw/active/`). @@ -504,7 +555,45 @@ EXECUTOR_MODEL=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs resolve-model gs VERIFIER_MODEL=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs resolve-model gsd-verifier --raw) ``` -1. **Create milestone:** Use `gsd-tools init new-milestone` to gather context, then attempt autonomous roadmap creation from issue data: +1. **Discussion phase trigger for large-scope issues:** + +If the issue was triaged with large scope and `gsd_route == "gsd:new-milestone"`, post +a scope proposal comment and set the discussing stage before proceeding to phase execution: + +```bash +DISCUSS_TIMESTAMP=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs current-timestamp --raw 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ") + +# Build scope breakdown from triage data +SCOPE_SIZE="${triage.scope.size}" +SCOPE_BREAKDOWN="${triage.scope.files formatted as table rows}" +PHASE_COUNT="TBD (determined by roadmapper)" + +# Post scope proposal comment using template from github.md +# Use Scope Proposal Comment template from @~/.claude/commands/mgw/workflows/github.md +``` + +Set pipeline_stage to "discussing" and apply "mgw:discussing" label: +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +gh issue edit ${ISSUE_NUMBER} --add-label "mgw:discussing" 2>/dev/null +``` + +Present to user: +``` +AskUserQuestion( + header: "Scope Proposal Posted", + question: "A scope proposal has been posted to GitHub. Proceed with autonomous roadmap creation, or wait for stakeholder feedback?", + options: [ + { label: "Proceed", description: "Continue with roadmap creation now" }, + { label: "Wait", description: "Pipeline paused until stakeholder approves scope" } + ] +) +``` + +If wait: stop here. User will re-run /mgw:run after scope is approved. +If proceed: apply "mgw:approved" label and continue. + +2. **Create milestone:** Use `gsd-tools init new-milestone` to gather context, then attempt autonomous roadmap creation from issue data: ```bash MILESTONE_INIT=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs init new-milestone 2>/dev/null) @@ -917,6 +1006,11 @@ rmdir "${REPO_ROOT}/.worktrees/issue" 2>/dev/null rmdir "${REPO_ROOT}/.worktrees" 2>/dev/null ``` +Remove in-progress label at completion: +```bash +gh issue edit ${ISSUE_NUMBER} --remove-label "mgw:in-progress" 2>/dev/null +``` + Extract one-liner summary for concise comment: ```bash ONE_LINER=$(node ~/.claude/get-shit-done/bin/gsd-tools.cjs summary-extract "${gsd_artifacts_path}/*SUMMARY*" --fields one_liner --raw 2>/dev/null || echo "") @@ -983,14 +1077,20 @@ Next: - [ ] Issue number validated and state loaded (or triage run first) +- [ ] Pipeline refuses needs-info without --force +- [ ] Pipeline refuses needs-security-review without --security-ack - [ ] Isolated worktree created (.worktrees/ gitignored) +- [ ] mgw:in-progress label applied during execution - [ ] Pre-flight comment check performed (new comments classified before execution) -- [ ] Structured triage comment posted on issue (scope, route, files, security) +- [ ] mgw:blocked label applied when blocking comments detected +- [ ] Work-starting comment posted on issue (route, scope, branch) - [ ] GSD pipeline executed in worktree (quick or milestone route) +- [ ] New-milestone route triggers discussion phase with mgw:discussing label - [ ] Execution-complete comment posted on issue (commits, changes, test status) - [ ] PR created with summary, milestone context, testing procedures, cross-refs - [ ] Structured PR-ready comment posted on issue (PR link, pipeline summary) - [ ] Worktree cleaned up, user returned to main workspace +- [ ] mgw:in-progress label removed at completion - [ ] State file updated through all pipeline stages - [ ] User prompted to run /mgw:sync after merge