Skip to content

feat: add design-decision-gate agentic workflow for ADR enforcement#25323

Merged
pelikhan merged 6 commits intomainfrom
copilot/create-design-decision-gate-workflow
Apr 8, 2026
Merged

feat: add design-decision-gate agentic workflow for ADR enforcement#25323
pelikhan merged 6 commits intomainfrom
copilot/create-design-decision-gate-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Addresses the pattern where AI lowers the perceived cost of deferring design decisions, causing codebase drift. This workflow enforces explicit Architecture Decision Records (ADRs) before implementation PRs can merge.

Workflow: .github/workflows/design-decision-gate.md

Engine: Claude

Triggers

  • PR labeled implementation (always enforces)
  • PR marked as ready for review

No ADR path

  1. AI analyzes the PR diff to infer implicit design decisions
  2. Generates a draft ADR and commits it to docs/adr/ on the PR branch
  3. Posts a blocking comment explaining what to complete and how to link it
  4. Submits REQUEST_CHANGES review to prevent merge

ADR present path

  • AI verifies the implementation matches the stated decision
  • APPROVE if aligned; REQUEST_CHANGES with specific divergences if not

Safe outputs used: add-comment, push-to-pull-request-branch, submit-pull-request-review

Sub Agent: .github/agents/adr-writer.agent.md

A dedicated adr-writer sub agent is imported by the workflow and provides best-practice ADR writing capabilities. Each ADR is structured in two parts:

Part 1 — Narrative (Human-Friendly)

  • Context — the problem, constraints, and forces that motivated the decision (3–5 sentences)
  • Decision — active-voice statement of what was decided and why
  • Alternatives Considered — ≥2 genuine alternatives with honest rejection rationale
  • Consequences — real positive, negative, and neutral trade-offs

Part 2 — Normative Specification (RFC 2119)

  • Precise, testable requirements using MUST / SHOULD / MAY keywords per RFC 2119
  • Requirements grouped into named subsections by concern area
  • Ends with a Conformance paragraph defining what it means to satisfy the ADR

Additional agent capabilities:

  • Storage conventiondocs/adr/NNNN-kebab-case-title.md with sequential numbering
  • Status lifecycle — Draft → Proposed → Accepted → Deprecated/Superseded
  • Procedures for writing new ADRs from scratch, inferring implicit decisions from PR diffs, and verifying implementation alignment against existing ADRs

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
8 tasks
…25314)

Creates a new workflow that:
- Triggers on PRs labeled "implementation" or with >100 new lines in business logic dirs
- Detects missing ADRs and generates draft using AI analysis of PR diff
- Posts actionable comment guiding author to complete and commit the ADR
- Blocks merge until ADR is linked via REQUEST_CHANGES review
- Verifies implementation matches existing ADR when one is present
- ADRs stored as numbered Markdown files in /docs/adr/
- Configurable business logic paths via .design-gate.yml

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3d100092-4ec3-4509-8739-d270f7d79996

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Create design-decision-gate agentic workflow feat: add design-decision-gate agentic workflow for ADR enforcement Apr 8, 2026
Copilot AI requested a review from pelikhan April 8, 2026 15:04
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot create an "adr-writer" sub agent (.github/agents/...) that implements a best practice ADR writer. Store ADRs under the adr folder.

…e workflow

- Create .github/agents/adr-writer.agent.md with best-practice ADR writing guidelines
- Import the adr-writer agent into design-decision-gate.md workflow
- Agent covers Michael Nygard template, storage in docs/adr/, quality standards,
  procedures for writing new ADRs, analyzing PR diffs, and verifying ADR alignment

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/9efb58eb-3725-48ae-b7f6-0345c01a095e

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot create an "adr-writer" sub agent (.github/agents/...) that implements a best practice ADR writer. Store ADRs under the adr folder.

Created .github/agents/adr-writer.agent.md (commit 1d7adec) — a best-practice ADR writer sub agent that:

  • Follows the Michael Nygard template with all four required sections (Context, Decision, Alternatives Considered, Consequences)
  • Stores ADRs in docs/adr/ using sequentially numbered filenames (NNNN-kebab-case-title.md)
  • Covers status lifecycle (Draft → Proposed → Accepted → Deprecated/Superseded)
  • Includes procedures for writing from scratch, analyzing PR diffs to identify implicit decisions, and verifying implementation alignment against an existing ADR

The design-decision-gate.md workflow now imports this agent via imports: - ../agents/adr-writer.agent.md.

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot adrs should have a human friendly part, then a precise RFC2119/W3

Use Claude for AW

…Claude engine

- Split ADR template into Part 1 (human-friendly narrative) and Part 2 (RFC 2119
  normative specification) with Conformance section
- Add quality standards for normative keyword usage (MUST/SHOULD/MAY table)
- Update validation checklist to cover both parts
- Switch design-decision-gate workflow engine from copilot to claude

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/55fa048f-8615-473d-a9c7-6d0f6f8dc075

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot adrs should have a human friendly part, then a precise RFC2119/W3

Use Claude for AW

Done in commit d8e5e8e:

  • ADR template now has two explicit parts:
    • Part 1 — Narrative: human-friendly Context, Decision, Alternatives Considered, and Consequences sections
    • Part 2 — Normative Specification: RFC 2119 requirements (MUST/SHOULD/MAY in bold) grouped by concern area, with a Conformance paragraph
  • Writing quality standards updated with an RFC 2119 keyword usage table and rules for deriving normative statements from the narrative
  • Workflow engine changed from copilot to claude

---
description: Enforces Architecture Decision Records (ADRs) before implementation work can merge, detecting missing design decisions and generating draft ADRs using AI analysis
on:
pull_request:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot ready for review instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is ready for review. All changes are in three new files only:

  • .github/agents/adr-writer.agent.md — ADR writer sub agent with two-part template (narrative + RFC 2119 normative spec)
  • .github/workflows/design-decision-gate.md — workflow using Claude engine
  • .github/workflows/design-decision-gate.lock.yml — compiled lock file

description: Enforces Architecture Decision Records (ADRs) before implementation work can merge, detecting missing design decisions and generating draft ADRs using AI analysis
on:
pull_request:
types: [labeled, opened, synchronize]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot trigger on labeled and ready-for-review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit fd26b46. Added ready_for_review to the pull_request event types:

types: [labeled, opened, synchronize, ready_for_review]

The workflow will now also trigger when a draft PR is marked as ready for review.

Copilot AI requested a review from pelikhan April 8, 2026 16:50
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot remove opened, synchronize events in on pull_request

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot remove opened, synchronize events in on pull_request

Done in commit 382b27c. The pull_request triggers are now:

types: [labeled, ready_for_review]

@pelikhan pelikhan marked this pull request as ready for review April 8, 2026 17:04
Copilot AI review requested due to automatic review settings April 8, 2026 17:04
@pelikhan pelikhan merged commit 7896800 into main Apr 8, 2026
@pelikhan pelikhan deleted the copilot/create-design-decision-gate-workflow branch April 8, 2026 17:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an agentic workflow that gates implementation PRs on the presence of an Architecture Decision Record (ADR), with the ability to draft an ADR when missing and block merges via review status.

Changes:

  • Introduces a new “Design Decision Gate” agentic workflow definition and its compiled lock file.
  • Adds an adr-writer sub-agent defining ADR structure, numbering/storage conventions, and RFC 2119 normative requirements.
Show a summary per file
File Description
.github/workflows/design-decision-gate.md Source workflow instructions for ADR enforcement, ADR generation, and merge-blocking behavior
.github/workflows/design-decision-gate.lock.yml Compiled/locked workflow produced by gh-aw for execution
.github/agents/adr-writer.agent.md Sub-agent defining the ADR template, quality bar, and procedures

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (3)

.github/workflows/design-decision-gate.md:212

  • The instructions require running mkdir -p ${{ github.workspace }}/docs/adr, but mkdir:* is not included in the bash tool allowlist for this workflow. In strict tool mode this will fail and prevent ADR creation. Either add "mkdir:*" to tools.bash or remove the mkdir step and rely on an allowed mechanism to ensure the directory exists (e.g., create the directory via the edit tool or ensure the push-to-pull-request-branch handler creates parent dirs).
Use `push-to-pull-request-branch` to commit the draft ADR to `docs/adr/{NNNN}-{kebab-case-title}.md`.

Ensure the `docs/adr/` directory exists before writing:
```bash
mkdir -p ${{ github.workspace }}/docs/adr
**.github/workflows/design-decision-gate.md:172**
* The draft ADR template here only includes the 4-section Michael Nygard narrative, but this workflow imports `adr-writer.agent.md` and the PR description says ADRs must be two-part (Narrative + RFC2119 Normative Specification). As a result, the gate may generate ADR drafts that fail your own stated ADR standard and makes later “ADR present” verification ambiguous. Align this template (and the “ADR present” criteria) with the `adr-writer` template (incl. Part 2 + Conformance) or explicitly document that Part 2 is optional for this gate.

Generate a draft ADR file following the Michael Nygard template:

# ADR-{NNNN}: {Concise Decision Title}

**Date**: {YYYY-MM-DD}
**Status**: Draft

.github/workflows/design-decision-gate.md:140

  • “ADR Detection Criteria” defines an ADR as present if it contains the 4 Nygard sections, but the imported adr-writer template nests these under “Part 1 — Narrative” with ### Context/Decision/... headings and additionally requires a Part 2 RFC2119 section. If your detection is implemented as heading-based checks, this mismatch can cause false negatives. Consider updating the criteria to explicitly accept the adr-writer structure (Part 1 + Part 2) and be robust to heading levels (e.g., ## vs ###).
### ADR Detection Criteria

An ADR is considered **present** if it contains all four required sections from the Michael Nygard template:
1. **Context** — what is the situation and problem being addressed
2. **Decision** — what was decided and why
3. **Alternatives Considered** — what other options were evaluated
4. **Consequences** — what will happen as a result (positive and negative)
  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +67 to +74
First, decide whether this PR needs ADR enforcement. There are two trigger conditions:

### Condition A: "implementation" Label
If the event is `labeled` (`${{ github.event_name }} == 'pull_request'` and the PR now has the "implementation" label), enforcement is **always required** — proceed to Step 2. You can verify the label is present by fetching the PR's current labels using GitHub tools.

### Condition B: Code Volume in Business Logic Directories
If the PR was opened or synchronized (not labeled), you must check if >100 lines of new code exist in core business logic directories.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 1 Condition B refers to PR events being "opened or synchronized", but this workflow only triggers on pull_request types [labeled, ready_for_review]. As written, the "opened/synchronized" path is unreachable and the ready_for_review path (one of the declared triggers) isn’t covered by either Condition A or B, which can lead to inconsistent/no enforcement on ready-for-review events. Update the trigger types (e.g., include opened/synchronize) and/or rewrite Condition B to explicitly handle ready_for_review (and any other intended actions).

This issue also appears in the following locations of the same file:

  • line 134
  • line 165

Copilot uses AI. Check for mistakes.
Comment on lines +114 to +121
| Status | Meaning |
|--------|---------|
| `Draft` | Initial AI-generated or work-in-progress ADR; requires human review |
| `Proposed` | Under review by the team; not yet accepted |
| `Accepted` | The decision is in effect |
| `Deprecated` | The decision no longer applies but was not superseded |
| `Superseded by ADR-XXXX` | A newer ADR replaces this one |

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This “Status Values” table is not valid Markdown because each row starts with || instead of |, so it won’t render as a table in most viewers. Replace the double pipes with single pipes for the header, separator, and data rows.

Copilot uses AI. Check for mistakes.
Comment on lines +121 to +129
### 3b. Check for ADR Files on the PR Branch
```bash
find ${{ github.workspace }}/docs/adr -name "*.md" 2>/dev/null | sort | tail -5
```

If ADR files exist, read the most recent one:
```bash
cat "$(find ${{ github.workspace }}/docs/adr -name "*.md" 2>/dev/null | sort | tail -1)"
```
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several bash snippets rely on sort and tail (e.g., find ... | sort | tail -5), but sort:* and tail:* are not included in this workflow’s tools.bash allowlist. In strict tool mode the agent won’t be able to run these commands, which can break ADR discovery. Add "sort:*" and "tail:*" to the bash allowlist (or rewrite the commands using only allowed tools).

This issue also appears on line 207 of the same file.

Copilot uses AI. Check for mistakes.
github-actions bot added a commit that referenced this pull request Apr 8, 2026
Add entries to the examples documentation for the five new workflows
merged on 2026-04-08:

- Test Quality Sentinel (#25353): PR-triggered test quality analysis
- Approach Validator (#25354): label-triggered multi-agent approach review
- Design Decision Gate (#25323): ADR enforcement before implementation merges
- Refactoring Cadence (#25352): daily code health tracking with auto-issue
- Architecture Guardian (#25334): daily code structure violation detection

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Create "design-decision-gate" agentic workflow

3 participants