Skip to content

feat(diagnostics): add diagnostic capture hooks to mgw:run agent spawns#240

Merged
snipcodeit merged 6 commits intomainfrom
issue/231-add-diagnostic-capture-hooks-to-mgw-run
Mar 6, 2026
Merged

feat(diagnostics): add diagnostic capture hooks to mgw:run agent spawns#240
snipcodeit merged 6 commits intomainfrom
issue/231-add-diagnostic-capture-hooks-to-mgw-run

Conversation

@snipcodeit
Copy link
Owner

Summary

  • Added lib/diagnostic-hooks.cjs providing beforeAgentSpawn()/afterAgentSpawn() wrapper functions for non-blocking diagnostic capture around Task() agent spawns
  • Instrumented all 9 Task() agent spawns across the mgw:run pipeline (triage classifier, quick planner/checker/executor/verifier, milestone planner/executor/verifier, PR creator) with before/after diagnostic hooks
  • Documented the diagnostic hook pattern and all instrumented spawns in commands/workflows/gsd.md
  • All diagnostic operations are non-blocking: if capture fails, the pipeline logs a warning and continues normally

Closes #231

Milestone Context

  • Milestone: v8 — Agent Reliability & Failure Recovery
  • Phase: 44 — Agent Failure Taxonomy & Diagnostic Logging
  • Issue: 3 of 9 in milestone

Changes

lib/

  • lib/diagnostic-hooks.cjs (new) — Helper module with beforeAgentSpawn(), afterAgentSpawn(), wrapAgentSpawn(), generateDiagId(), and pendingCount(). Uses Map-based in-flight tracking, lazy-loads agent-diagnostics.cjs with graceful degradation.

commands/run/

  • commands/run/triage.md — Added diagnostic hooks around the comment classifier Task() spawn in preflight_comment_check
  • commands/run/execute.md — Added diagnostic hooks around 7 Task() spawns: planner, plan-checker, executor, verifier (quick route) and planner, executor, verifier (milestone route)
  • commands/run/pr-create.md — Added diagnostic hooks around the PR creation Task() spawn

commands/workflows/

  • commands/workflows/gsd.md — New "Diagnostic Capture Hooks" section documenting the pattern template, design principles, and a coverage table of all 9 instrumented spawns

Test Plan

  • node -e "require('./lib/diagnostic-hooks.cjs')" loads successfully
  • beforeAgentSpawn() returns a valid diagId handle
  • afterAgentSpawn() clears in-flight tracking (pendingCount returns 0)
  • Graceful degradation when agent-diagnostics.cjs is not present
  • Verify hooks execute without errors in a live pipeline run
  • Verify .mgw/diagnostics/ entries are written after agent spawns (requires Build structured diagnostic logger for agent executions #230 merged)

Stephen Miller and others added 6 commits March 6, 2026 00:55
…spawns

Provides beforeAgentSpawn()/afterAgentSpawn() helper functions that
wrap Task() agent spawns with diagnostic capture from
agent-diagnostics.cjs. All operations are non-blocking -- failures
log warnings and continue pipeline execution.

Closes part of #231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ge.md

Instruments the comment classifier Task() spawn in the
preflight_comment_check step with before/after diagnostic capture
hooks using lib/diagnostic-hooks.cjs.

Part of #231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e.md

Instruments 7 Task() agent spawns with before/after diagnostic capture:
- Quick route: planner, plan-checker, executor, verifier
- Milestone route: planner, executor, verifier

Each spawn gets a pre-spawn beforeAgentSpawn() call that records start
time and prompt hash, and a post-spawn afterAgentSpawn() call that
records exit reason and writes the diagnostic entry.

Part of #231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instruments the PR creation Task() agent spawn with before/after
diagnostic capture hooks using lib/diagnostic-hooks.cjs.

Part of #231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a Diagnostic Capture Hooks section to the shared GSD workflow
patterns documenting the before/after hook pattern, design principles,
and a table of all instrumented agent spawns across the pipeline.

Part of #231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added slash-commands Changes to slash command files core Changes to core library labels Mar 6, 2026
@snipcodeit snipcodeit merged commit f0f51ef into main Mar 6, 2026
4 of 5 checks passed
@snipcodeit snipcodeit deleted the issue/231-add-diagnostic-capture-hooks-to-mgw-run branch March 6, 2026 07:39
snipcodeit pushed a commit that referenced this pull request Mar 6, 2026
Resolve conflicts in command files: combine diagnostic hooks (from #240)
with criticality annotations (from #243). Both additions are complementary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
snipcodeit pushed a commit that referenced this pull request Mar 6, 2026
…ine-ex

Resolve conflicts in command files: combine checkpoint writes (from #244)
with diagnostic hooks and criticality annotations (from #240, #243).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core library slash-commands Changes to slash command files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add diagnostic capture hooks to mgw:run agent spawns

1 participant