Skip to content

Add retrospective enforcement gate to ADR-033 #618

@rjmurillo-bot

Description

@rjmurillo-bot

Summary

Add a routing-level enforcement gate (per ADR-033) that forces invocation of the retrospective agent at session end, milestones, and significant events.

Parent Story

#615 (Phase 2: SHOULD Skills)

Why Gate, Not Skill

Aspect Skill Approach Gate + Agent Approach
Problem addressed Format inconsistency Retrospective gets skipped entirely
Root cause Format drift Protocol bypass under pressure
Evidence Some retros missing phases PR #226: No retro despite major failure
ADR-033 alignment Wrong layer (skill-internal) Correct layer (routing-level)

The retrospective agent already works well when invoked. The failure mode is:

Retrospective doesn't happen at all - not that it happens poorly.

This is exactly the ADR-033 "Do Router" pattern:

"Over-routing is cheap. Under-routing compounds."

Gate Specification

Trigger Conditions

Trigger Detection Gate Action
Session end git push after session work Block until retrospective section exists
Milestone completion PR merge to main Block until retrospective for milestone
Significant event Major failure detected Force retrospective routing

Implementation

Add to Invoke-RoutingGates.ps1:

# Gate: Session End Retrospective
$SessionEndTriggers = @("git push")
$RequiresRetrospective = $SessionEndTriggers | Where-Object { $Command -like "*$_*" }

if ($RequiresRetrospective) {
    $SessionLog = Get-TodaySessionLog
    if ($SessionLog) {
        $Content = Get-Content $SessionLog.FullName -Raw
        
        # Check for retrospective section OR retrospective file reference
        $HasRetrospective = $Content -match "## Retrospective" -or 
                           $Content -match "\.agents/retrospective/"
        
        if (-not $HasRetrospective) {
            $Output = @{
                decision = "deny"
                reason = @"
RETROSPECTIVE GATE: Session retrospective required before push.

Run: Task(subagent_type='retrospective', prompt='Analyze this session for learnings')

Or document retrospective in session log with ## Retrospective section.
"@
            }
            $Output | ConvertTo-Json -Compress
            exit 0
        }
    }
}

Gate Bypass Conditions

Allow bypass when:

  • Session is documentation-only (no code changes)
  • Session is trivial (<10 minutes, single file change)
  • Retrospective file already exists for today
# Check for existing retrospective file
$RetroDir = ".agents/retrospective"
$Today = Get-Date -Format "yyyy-MM-dd"
$ExistingRetro = Get-ChildItem -Path $RetroDir -Filter "$Today*.md" -ErrorAction SilentlyContinue

if ($ExistingRetro) {
    # Retrospective already done today, allow push
    exit 0
}

Integration with ADR-033

This gate fits into the ADR-033 gate architecture:

flowchart TB
    subgraph Gates["PreToolUse Hook Layer"]
        G1["Gate: Session Protocol"]
        G2["Gate: QA Validation"]
        G3["Gate: Critic Review"]
        G4["Gate: ADR Existence"]
        G5["Gate: Retrospective"]
    end
    
    G5 -->|"git push"| Check{Retrospective exists?}
    Check -->|Yes| Allow[Allow push]
    Check -->|No| Block["Block + suggest retrospective agent"]
Loading

Acceptance Criteria

  • Gate added to Invoke-RoutingGates.ps1
  • Triggers on git push commands
  • Checks for retrospective section in session log OR retrospective file
  • Provides clear guidance message when blocked
  • Bypass logic for trivial sessions
  • Integration tested with deliberate violation

Definition of Done

  • Gate implemented in PowerShell (per ADR-005)
  • Hook configuration updated in .claude/settings.local.json
  • Gate documented in ADR-033 Implementation Notes
  • Test: Attempt git push without retrospective → blocked
  • Test: Attempt git push with retrospective → allowed

Relationship to Retrospective Agent

The retrospective AGENT remains unchanged:

  • 6-phase workflow (Data Gathering → Insights → Diagnosis → Decide → Extract → Close)
  • Five Whys, Fishbone, Force Field analysis
  • Atomicity scoring, SMART validation
  • Structured handoff output

This gate ENFORCES that the agent gets invoked, not changes what it does.

References

Metadata

Metadata

Assignees

Labels

agent-criticPlan validation agentagent-orchestratorTask coordination agentagent-qaTesting and verification agentagent-retrospectiveLearning extraction agentarea-infrastructureBuild, CI/CD, configurationarea-promptsAgent prompts and templatesarea-skillsSkills documentation and patternsarea-workflowsGitHub Actions workflowsdocumentationImprovements or additions to documentationenhancementNew feature or requestgateRouting-level enforcement gate (ADR-033)priority:P1Important: Affects user experience significantly, high business valueskill-conversionAgent to skill conversion worktaskTask-level work item under a story

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions