feat: add design-decision-gate agentic workflow for ADR enforcement#25323
feat: add design-decision-gate agentic workflow for ADR enforcement#25323
Conversation
…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 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>
Created
The |
|
@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>
Done in commit
|
| --- | ||
| 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: |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
@copilot trigger on labeled and ready-for-review
There was a problem hiding this comment.
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.
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8d7ecb6a-941e-42a8-83e7-54007e6e0085 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot remove opened, synchronize events in on pull_request |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3d10aa34-cdd3-48de-81bc-3cc65fc559f3 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in commit types: [labeled, ready_for_review] |
There was a problem hiding this comment.
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-writersub-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, butmkdir:*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:*"totools.bashor remove themkdirstep 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-writertemplate 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 theadr-writerstructure (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
| 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. | ||
|
|
There was a problem hiding this comment.
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
| | 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 | | ||
|
|
There was a problem hiding this comment.
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.
| ### 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)" | ||
| ``` |
There was a problem hiding this comment.
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.
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>
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.mdEngine: Claude
Triggers
implementation(always enforces)No ADR path
docs/adr/on the PR branchREQUEST_CHANGESreview to prevent mergeADR present path
APPROVEif aligned;REQUEST_CHANGESwith specific divergences if notSafe outputs used:
add-comment,push-to-pull-request-branch,submit-pull-request-reviewSub Agent:
.github/agents/adr-writer.agent.mdA dedicated
adr-writersub 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)
Part 2 — Normative Specification (RFC 2119)
Additional agent capabilities:
docs/adr/NNNN-kebab-case-title.mdwith sequential numbering