Skip to content

Commit 321cc6b

Browse files
feat(agents): add BLOCKING gate for automatic ADR review (#467)
* feat(agents): add BLOCKING gate for automatic ADR review Ensure adr-review skill is ALWAYS triggered when ADRs are created/updated: ## Changes - architect.md: Add ADR Creation/Update Protocol (BLOCKING) section - orchestrator.md: Add ADR Review Enforcement rule (#4) and detection patterns - AGENTS.md: Add global ADR Review Requirement with enforcement table - adr-review SKILL.md: Update with MANDATORY triggers and anti-patterns ## Enforcement Flow 1. Architect signals orchestrator: "MANDATORY: invoke adr-review" 2. Orchestrator detects signal and invokes adr-review skill 3. Workflow continues only after adr-review completes ## Background Session 91 discovered ADR-021 was created without automatic adr-review. The skill documentation was aspirational, not enforced. This fix adds explicit blocking gates to ensure 100% compliance. Addresses P1 follow-up from Session 91 (#357) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs(session): update Session 92 log with outcome and limitation note 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(agents): update templates and regenerate platform agents Update shared templates with ADR Review Enforcement: - templates/agents/architect.shared.md: Add BLOCKING gate - templates/agents/orchestrator.shared.md: Add ADR Review Enforcement Regenerate all platform-specific agent files (36 files). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: rjmurillo[bot] <rjmurillo-bot@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bdcdf62 commit 321cc6b

File tree

11 files changed

+379
-8
lines changed

11 files changed

+379
-8
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Session 92: ADR Review Auto-Trigger Fix
2+
3+
**Date**: 2025-12-27
4+
**Branch**: `feat/adr-review-auto-trigger`
5+
**Issue**: Follow-up from Session 91 (P1 action item)
6+
7+
## Outcome
8+
9+
**Status**: SUCCESS - PR #467 created
10+
11+
## Objective
12+
13+
Ensure adr-review skill is ALWAYS triggered automatically when an ADR is created or updated, regardless of which agent performs the operation.
14+
15+
## Customer Impact (Working Backwards)
16+
17+
**Before**: Users must manually request ADR review after architect creates ADRs (discovered in Session 91 with ADR-021).
18+
19+
**After**: ADR review is automatic - architect signals orchestrator with MANDATORY routing, orchestrator enforces the gate.
20+
21+
**Result**: All ADRs receive multi-agent validation without manual intervention.
22+
23+
## Implementation Plan
24+
25+
Based on analysis at `.agents/analysis/adr-review-trigger-fix.md`:
26+
27+
| Change | File | Purpose |
28+
|--------|------|---------|
29+
| 1 | `src/claude/architect.md` | Add BLOCKING gate to handoff protocol |
30+
| 2 | `src/claude/orchestrator.md` | Add ADR Review Enforcement section |
31+
| 3 | `AGENTS.md` | Add global ADR Review Requirement |
32+
| 4 | `.claude/skills/adr-review/SKILL.md` | Update with MANDATORY enforcement language |
33+
34+
## Limitation Note
35+
36+
The user correctly identified that this fix is a workaround, not a fundamental solution:
37+
38+
**Root Cause**: Claude Code skills are **pull-based**, not **push-based**. There's no automatic skill invocation based on file operations or context detection.
39+
40+
**Why This Matters**: The skill documentation said "triggers on...when architect creates ADR" but this was aspirational documentation, not implemented behavior.
41+
42+
**This Fix**: Adds explicit BLOCKING gates in agent prompts so they signal and invoke the skill manually.
43+
44+
**True Solution** (out of scope): Would require Claude Code framework changes:
45+
46+
- Event-driven skill invocation
47+
- File pattern matching for automatic activation
48+
- Push-based skill triggering
49+
50+
## Protocol Compliance
51+
52+
### Session End Checklist
53+
54+
| Step | Status | Evidence |
55+
|------|--------|----------|
56+
| [x] Session log created | PASS | This file |
57+
| [x] All changes committed | PASS | 4d61706 |
58+
| [x] PR created | PASS | #467 |
59+
| [ ] HANDOFF context stored | Pending | |
60+
| [x] Markdownlint run | PASS | 0 errors in changed files |
61+
| [ ] Validation script | Pending | |
62+
63+
## References
64+
65+
- [Session 91 Analysis](/.agents/analysis/adr-review-trigger-fix.md) - Root cause and fix design
66+
- [Session 91 Log](/.agents/sessions/2025-12-27-session-91-issue-357-quality-gate-prompts.md) - Discovery context

.claude/skills/adr-review/SKILL.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,37 @@ Multi-agent debate pattern for rigorous ADR validation. Orchestrates 6 specializ
1111

1212
## When to Use
1313

14-
- User requests ADR review ("review this ADR", "validate this decision")
15-
- Architect creates or updates an ADR
16-
- Orchestrator detects ADR file changes
17-
- Strategic decisions require multi-perspective validation
14+
**MANDATORY Triggers** (automatic, non-negotiable):
15+
16+
- Architect creates or updates an ADR and signals orchestrator
17+
- ANY agent creates or updates a file matching `.agents/architecture/ADR-*.md`
18+
- Orchestrator detects ADR creation/update signal from agent output
19+
20+
**User-Initiated Triggers** (manual):
21+
22+
- User explicitly requests ADR review ("review this ADR", "validate this decision")
23+
- User requests multi-perspective validation for strategic decisions
24+
25+
**Enforcement**:
26+
27+
The architect agent is configured to ALWAYS signal orchestrator with MANDATORY routing when ADR files are created/updated. Orchestrator is configured to BLOCK workflow continuation until adr-review completes.
28+
29+
**Scope**:
30+
31+
- Primary location: `.agents/architecture/ADR-*.md`
32+
- Secondary location: `docs/architecture/ADR-*.md` (if project uses this structure)
33+
34+
**Anti-Pattern**:
35+
36+
- Architect routes to planner without adr-review
37+
- Orchestrator proceeds to next agent without invoking adr-review
38+
- User must manually request adr-review after ADR creation
39+
40+
**Correct Pattern**:
41+
42+
- Architect signals orchestrator: "MANDATORY: invoke adr-review"
43+
- Orchestrator invokes adr-review skill
44+
- Workflow continues only after adr-review completes
1845

1946
## Agent Roles
2047

AGENTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,46 @@ analyst → high-level-advisor → independent-thinker → critic → roadmap
852852

853853
---
854854

855+
### ADR Review Requirement (MANDATORY)
856+
857+
**Rule**: ALL ADRs created or updated MUST trigger the adr-review skill before workflow continues.
858+
859+
**Scope**: Applies to ADR files matching `.agents/architecture/ADR-*.md` and `docs/architecture/ADR-*.md`
860+
861+
**Enforcement**:
862+
863+
| Agent | Responsibility |
864+
|-------|----------------|
865+
| **architect** | Signal MANDATORY routing to orchestrator when ADR created/updated |
866+
| **orchestrator** | Detect signal and invoke adr-review skill before routing to next agent |
867+
| **implementer** | If creating ADR, signal MANDATORY routing to orchestrator |
868+
| **All agents** | Do NOT bypass adr-review by directly routing to next agent |
869+
870+
**Blocking Gate**:
871+
872+
```text
873+
IF ADR created/updated:
874+
1. Agent returns to orchestrator with MANDATORY routing signal
875+
2. Orchestrator invokes adr-review skill
876+
3. adr-review completes (may take multiple rounds)
877+
4. Orchestrator routes to next agent only after adr-review PASS
878+
879+
VIOLATION: Routing to next agent without adr-review is a protocol violation.
880+
```
881+
882+
**Skill Invocation**:
883+
884+
```bash
885+
# Orchestrator invokes adr-review skill
886+
Skill(skill="adr-review", args="[path to ADR file]")
887+
```
888+
889+
**Rationale**: All ADRs benefit from multi-agent validation (architect, critic, independent-thinker, security, analyst, high-level-advisor) coordinated by adr-review skill.
890+
891+
**Related**: See `.claude/skills/adr-review/SKILL.md` for debate protocol details.
892+
893+
---
894+
855895
### Planner – Implementation Planning
856896

857897
**Role**: Turns epics into concrete, implementation-ready plans. Orchestrates impact analysis consultations for multi-domain changes.

src/claude/architect.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,31 @@ mcp__cloudmcp-manager__memory-create_entities
442442

443443
**As a subagent, you CANNOT delegate**. Return results to orchestrator.
444444

445-
When review is complete:
445+
### ADR Creation/Update Protocol (BLOCKING)
446+
447+
When you create or update an ADR file matching `.agents/architecture/ADR-*.md`:
448+
449+
1. Save ADR to `.agents/architecture/ADR-NNNN-[title].md`
450+
2. Update architecture changelog if needed
451+
3. Store decision in memory
452+
4. Return to orchestrator with **MANDATORY routing**:
453+
454+
```text
455+
ADR created/updated: [path to ADR file]
456+
457+
MANDATORY: Orchestrator MUST invoke adr-review skill before proceeding.
458+
459+
Command:
460+
Skill(skill="adr-review", args="[path to ADR file]")
461+
462+
Rationale: All ADRs require multi-agent validation per adr-review protocol.
463+
```
464+
465+
**BLOCKING REQUIREMENT**: You MUST NOT recommend routing to any other agent (planner, implementer, etc.) until adr-review completes. Orchestrator is responsible for enforcing this gate.
466+
467+
### Non-ADR Review Handoff
468+
469+
When review is complete and NO ADR was created/updated:
446470

447471
1. Save findings to `.agents/architecture/`
448472
2. Update architecture changelog if decisions made

src/claude/orchestrator.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,40 @@ Assess complexity BEFORE selecting agents:
663663
1. **Security agent ALWAYS for**: Files matching `**/Auth/**`, `.githooks/*`, `*.env*`
664664
2. **QA agent ALWAYS after**: Any implementer changes
665665
3. **Critic agent BEFORE**: Multi-domain implementations
666+
4. **adr-review skill ALWAYS after**: ADR creation/update (see below)
667+
668+
### ADR Review Enforcement (BLOCKING)
669+
670+
When ANY agent returns output indicating ADR creation/update:
671+
672+
**Detection Pattern**:
673+
674+
- Agent output contains: "ADR created/updated: .agents/architecture/ADR-*.md"
675+
- Agent output contains: "MANDATORY: Orchestrator MUST invoke adr-review"
676+
677+
**Enforcement**:
678+
679+
```text
680+
BLOCKING GATE: ADR Review Required
681+
682+
1. Verify ADR file exists at specified path
683+
2. Invoke adr-review skill:
684+
685+
Skill(skill="adr-review", args="[ADR file path]")
686+
687+
3. Wait for adr-review completion
688+
4. Only after adr-review completes, route to next agent per original plan
689+
690+
DO NOT route to next agent until adr-review completes.
691+
```
692+
693+
**Failure Handling**:
694+
695+
| Condition | Action |
696+
|-----------|--------|
697+
| ADR file not found | Report error to user, halt workflow |
698+
| adr-review skill unavailable | Report error to user, document gap, proceed with warning |
699+
| adr-review fails | Review failure output, decide to retry or escalate to user |
666700

667701
### Consistency Checkpoint (Pre-Critic)
668702

src/copilot-cli/architect.agent.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,33 @@ mcp__cloudmcp-manager__memory-create_entities
382382

383383
## Handoff Protocol
384384

385-
When review is complete:
385+
**As a subagent, you CANNOT delegate**. Return results to orchestrator.
386+
387+
### ADR Creation/Update Protocol (BLOCKING)
388+
389+
When you create or update an ADR file matching `.agents/architecture/ADR-*.md`:
390+
391+
1. Save ADR to `.agents/architecture/ADR-NNNN-[title].md`
392+
2. Update architecture changelog if needed
393+
3. Store decision in memory
394+
4. Return to orchestrator with **MANDATORY routing**:
395+
396+
```text
397+
ADR created/updated: [path to ADR file]
398+
399+
MANDATORY: Orchestrator MUST invoke adr-review skill before proceeding.
400+
401+
Command:
402+
Skill(skill="adr-review", args="[path to ADR file]")
403+
404+
Rationale: All ADRs require multi-agent validation per adr-review protocol.
405+
```
406+
407+
**BLOCKING REQUIREMENT**: You MUST NOT recommend routing to any other agent (planner, implementer, etc.) until adr-review completes. Orchestrator is responsible for enforcing this gate.
408+
409+
### Non-ADR Review Handoff
410+
411+
When review is complete and NO ADR was created/updated:
386412

387413
1. Save findings to `.agents/architecture/`
388414
2. Update architecture changelog if decisions made

src/copilot-cli/orchestrator.agent.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,40 @@ Assess complexity BEFORE selecting agents:
590590
1. **Security agent ALWAYS for**: Files matching `**/Auth/**`, `.githooks/*`, `*.env*`
591591
2. **QA agent ALWAYS after**: Any implementer changes
592592
3. **Critic agent BEFORE**: Multi-domain implementations
593+
4. **adr-review skill ALWAYS after**: ADR creation/update (see below)
594+
595+
### ADR Review Enforcement (BLOCKING)
596+
597+
When ANY agent returns output indicating ADR creation/update:
598+
599+
**Detection Pattern**:
600+
601+
- Agent output contains: "ADR created/updated: .agents/architecture/ADR-*.md"
602+
- Agent output contains: "MANDATORY: Orchestrator MUST invoke adr-review"
603+
604+
**Enforcement**:
605+
606+
```text
607+
BLOCKING GATE: ADR Review Required
608+
609+
1. Verify ADR file exists at specified path
610+
2. Invoke adr-review skill:
611+
612+
Skill(skill="adr-review", args="[ADR file path]")
613+
614+
3. Wait for adr-review completion
615+
4. Only after adr-review completes, route to next agent per original plan
616+
617+
DO NOT route to next agent until adr-review completes.
618+
```
619+
620+
**Failure Handling**:
621+
622+
| Condition | Action |
623+
|-----------|--------|
624+
| ADR file not found | Report error to user, halt workflow |
625+
| adr-review skill unavailable | Report error to user, document gap, proceed with warning |
626+
| adr-review fails | Review failure output, decide to retry or escalate to user |
593627

594628
## Consistency Checkpoint (Pre-Critic)
595629

src/vs-code-agents/architect.agent.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,33 @@ mcp__cloudmcp-manager__memory-create_entities
382382

383383
## Handoff Protocol
384384

385-
When review is complete:
385+
**As a subagent, you CANNOT delegate**. Return results to orchestrator.
386+
387+
### ADR Creation/Update Protocol (BLOCKING)
388+
389+
When you create or update an ADR file matching `.agents/architecture/ADR-*.md`:
390+
391+
1. Save ADR to `.agents/architecture/ADR-NNNN-[title].md`
392+
2. Update architecture changelog if needed
393+
3. Store decision in memory
394+
4. Return to orchestrator with **MANDATORY routing**:
395+
396+
```text
397+
ADR created/updated: [path to ADR file]
398+
399+
MANDATORY: Orchestrator MUST invoke adr-review skill before proceeding.
400+
401+
Command:
402+
Skill(skill="adr-review", args="[path to ADR file]")
403+
404+
Rationale: All ADRs require multi-agent validation per adr-review protocol.
405+
```
406+
407+
**BLOCKING REQUIREMENT**: You MUST NOT recommend routing to any other agent (planner, implementer, etc.) until adr-review completes. Orchestrator is responsible for enforcing this gate.
408+
409+
### Non-ADR Review Handoff
410+
411+
When review is complete and NO ADR was created/updated:
386412

387413
1. Save findings to `.agents/architecture/`
388414
2. Update architecture changelog if decisions made

src/vs-code-agents/orchestrator.agent.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,40 @@ Assess complexity BEFORE selecting agents:
590590
1. **Security agent ALWAYS for**: Files matching `**/Auth/**`, `.githooks/*`, `*.env*`
591591
2. **QA agent ALWAYS after**: Any implementer changes
592592
3. **Critic agent BEFORE**: Multi-domain implementations
593+
4. **adr-review skill ALWAYS after**: ADR creation/update (see below)
594+
595+
### ADR Review Enforcement (BLOCKING)
596+
597+
When ANY agent returns output indicating ADR creation/update:
598+
599+
**Detection Pattern**:
600+
601+
- Agent output contains: "ADR created/updated: .agents/architecture/ADR-*.md"
602+
- Agent output contains: "MANDATORY: Orchestrator MUST invoke adr-review"
603+
604+
**Enforcement**:
605+
606+
```text
607+
BLOCKING GATE: ADR Review Required
608+
609+
1. Verify ADR file exists at specified path
610+
2. Invoke adr-review skill:
611+
612+
Skill(skill="adr-review", args="[ADR file path]")
613+
614+
3. Wait for adr-review completion
615+
4. Only after adr-review completes, route to next agent per original plan
616+
617+
DO NOT route to next agent until adr-review completes.
618+
```
619+
620+
**Failure Handling**:
621+
622+
| Condition | Action |
623+
|-----------|--------|
624+
| ADR file not found | Report error to user, halt workflow |
625+
| adr-review skill unavailable | Report error to user, document gap, proceed with warning |
626+
| adr-review fails | Review failure output, decide to retry or escalate to user |
593627

594628
## Consistency Checkpoint (Pre-Critic)
595629

0 commit comments

Comments
 (0)