@akjamie/agentic-sdlc 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,15 +1,21 @@
1
1
  # agentic-sdlc
2
2
 
3
- > **BLUF** — Enterprise-grade Agentic Software Development Lifecycle (SDLC) governance.
4
- > Seven stages take a feature from natural language intent to production, with governance
5
- > **enforced by deterministic gates**, not by hope. Built on [OpenSpec](https://openspec.dev)
6
- > and [Graphify](https://github.com/safishamsi/graphify); the governance plane is yours.
3
+ [![npm version](https://img.shields.io/npm/v/@akjamie/agentic-sdlc?color=6366f1&label=npm)](https://www.npmjs.com/package/@akjamie/agentic-sdlc)
4
+ [![license: MIT](https://img.shields.io/badge/license-MIT-10b981.svg)](LICENSE)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-38bdf8.svg)](https://nodejs.org/)
6
+ [![tests](https://img.shields.io/badge/tests-89%20passing-10b981.svg)](#development--verification)
7
+
8
+ > **Enterprise-grade Agentic SDLC governance.** Seven deterministic stages take a feature from natural-language intent to production — with every quality gate enforced by code, not by convention.
9
+ >
10
+ > Built on [OpenSpec](https://openspec.dev) and [Graphify](https://github.com/safishamsi/graphify).
11
+ > The spec is the authority. The gate is the law. Humans stay in control.
7
12
 
8
13
  ---
9
14
 
10
15
  ## Contents
11
16
 
12
17
  - [What problem this solves](#what-problem-this-solves)
18
+ - [Enterprise Quality Gates & Non-Negotiable Invariants](#-enterprise-quality-gates--non-negotiable-invariants)
13
19
  - [Three-Plane Architecture](#three-plane-architecture)
14
20
  - [Bundled Out-of-the-Box Skills](#bundled-out-of-the-box-skills)
15
21
  - [Install & Setup](#install--setup)
@@ -21,40 +27,153 @@
21
27
 
22
28
  ---
23
29
 
24
- ## What problem this solves
30
+ ## What Problem This Solves
31
+
32
+ Spec-driven development works — until you scale it past one team or turn AI agents loose on a production codebase.
33
+
34
+ OpenSpec manages spec documents, but it **enforces nothing** at runtime. Nothing stops an autonomous agent from:
25
35
 
26
- Spec-driven development works — until you scale it past one team or turn AI agents loose on production code. OpenSpec manages spec documents, but it **enforces nothing** at runtime. Nothing stops a developer or an autonomous agent from merging code that contradicts the approved spec, shipping without tests, or silently editing the spec after the fact.
36
+ - Writing code that contradicts the approved spec
37
+ - Shipping without tests
38
+ - Silently editing the spec after the fact to make failing tests pass
39
+ - Grading its own implementation (agent acts as both player and referee)
27
40
 
28
- `asdlc` closes that gap. It adds a deterministic governance plane *on top of* the engines:
41
+ `asdlc` closes every one of those gaps by adding a **deterministic governance plane** on top of the spec engine:
42
+
43
+ | What agents can't do | How `asdlc` enforces it |
44
+ | :--- | :--- |
45
+ | Write production code before spec approval | `asdlc apply` physically refuses via path-limited `git log` check |
46
+ | Silently alter an approved spec | `spec-tamper` gate computes and compares path-limited SHA |
47
+ | Ship code without tests | `test-presence` gate rejects diffs missing test changes |
48
+ | Write ACs not mapped to test files | `(test: <path>)` annotation required per AC |
49
+ | Self-certify their own implementation | CI runs independent `asdlc-impl-review` with fresh LLM context |
50
+ | Declare success without recorded test evidence | `tdd-evidence` gate validates actual test output logs |
29
51
 
30
- - **Intent-Driven Start**: Developers start with natural language requirements (`asdlc new "i want to build..."`), not artificial ticket IDs. Canonical slugs are automatically derived, and knowledge graph queries are seeded with real domain terms.
31
- - **High-Efficiency Batch Grilling**: A bundled interview engine (**`batch-grill-me`**) stress-tests the entire decision frontier in 1-2 structured batches with recommended defaults *before* writing specs. Decisions are recorded in `clarifications.md`.
32
- - **The Spec is the Authority**: Merged to the protected branch, the spec is immutable. If reality diverges during implementation, the Converge protocol halts affected work (`SPEC_GAP`) — you never silently mutate an approved spec.
33
- - **Enforced Task-Level TDD**: Unlocking implementation (`asdlc apply`) requires approved spec commits, while `asdlc verify` deterministically checks `test-presence` (rejects code changes without test changes in diff) and `tdd-evidence` (validates recorded test outputs).
34
- - **Player ≠ Referee**: Independent AI verification uses a different model and a fresh context than the authoring agent.
52
+ ### Five Core Principles
53
+
54
+ - **Intent-Driven Start** — `asdlc new "i want to build..."` derives a canonical slug; no artificial ticket IDs.
55
+ - **Conversational Grilling Before Specs** — high-signal **`grill-me`** interview (or **`batch-grill-me`** via `--batch-grill`) stress-tests the decision frontier *before* any spec is written, with strict anti-fatigue guardrails. Decisions are recorded in `clarifications.md`.
56
+ - **The Spec is Immutable** — once merged to the protected branch, the spec is locked. If reality diverges, the Converge protocol halts work (`SPEC_GAP`) and requires human re-approval via a fresh spec delta.
57
+ - **Enforced Task-Level TDD** — `asdlc apply` requires an approved spec commit; `asdlc verify` enforces `test-presence` and `tdd-evidence` on every diff.
58
+ - **Player ≠ Referee** — the authoring agent can never certify its own work; CI uses a separate model with fresh context.
59
+
60
+ ---
61
+
62
+ ## 🛡️ Enterprise Quality Gates & Non-Negotiable Invariants
63
+
64
+ These are the hard invariants enterprise engineering leads require when deploying autonomous agents on production repositories.
65
+ Every invariant is enforced by deterministic code — not by convention, documentation, or hope.
66
+
67
+ | # | Quality Gate | Enforcement | Failure Mode |
68
+ | :--: | :--- | :--- | :--- |
69
+ | **1** | **No Apply Before Spec PR Merge** | `asdlc apply <ID>` verifies path-limited Git commit (`approvedSha`) on `main` touching `proposal.md` + `specs/**` | 🚫 **Hard Refusal** — zero production code on unapproved drafts |
70
+ | **2** | **Cryptographic Anti-Tampering** (`spec-tamper`) | `asdlc verify` computes path-limited SHA of locked spec files in the impl diff against `approvedSha` | 🚫 **PR Rejection** — agents cannot move the goalposts to pass failing tests |
71
+ | **3** | **Full Scenario-to-AC Traceability** (`R5-scenario-coverage`) | `asdlc lint` enforces `scens.length <= acs.length` — every scenario needs ≥1 AC | 🚫 **Pre-flight Blocker** — prevents single happy-path ACs for complex scenario sets |
72
+ | **4** | **Deterministic AC Test Gate** (`asdlc test`) | Parses all `- [ ] ACn: ... (test: <path>)` mappings and executes real assertions via native runners | 🚫 **Dual Harness** — local TDD driver + independent CI gate; fake claims fail |
73
+ | **5** | **Player ≠ Referee Isolation** | CI impl review runs with fresh LLM context; independent of author agent `tasks.md` declarations | 🚫 **Audit Integrity** — authoring agents cannot grade their own exam |
74
+ | **6** | **Diff-Based Test Presence** (`test-presence`) | `asdlc verify` checks every `src/**` change is accompanied by `test/**` changes | 🚫 **Zero Untested Code** — shuts down AI "code dumps" with no test coverage |
75
+ | **7** | **Immutable Converge Protocol** (`SPEC_GAP`) | If implementation exposes invalid spec assumptions, agent must halt and file a `SPEC_GAP` report | 🚫 **Anti-Drift** — silent spec mutations blocked; human re-approves fresh delta |
76
+ | **8** | **Triple-Gated Trunk Merge** | Impl PR merge requires: ① CI AC Tests, ② AI Impl Review (Player ≠ Referee), ③ Human Tech Lead sign-off | 🚫 **Blast Radius Defense** — unreviewed agent code never reaches `main` |
35
77
 
36
78
  ---
37
79
 
38
80
  ## Three-Plane Architecture
39
81
 
82
+ The system is structured across three distinct planes, each with a clear responsibility boundary:
83
+
84
+ ```mermaid
85
+ flowchart TD
86
+ subgraph P3 ["PLANE 3 · Agentic IDE Surface (.agents/skills/ · Conversational & Autonomous)"]
87
+ direction TB
88
+ subgraph P3_STAGES ["Stage Workflow Skills (Ordered by SDLC Stage)"]
89
+ direction LR
90
+ SK_INIT["1 · asdlc-init<br/>Repo Scaffolding"] --> SK_NEW["2 · asdlc-new<br/>AST Explore + Grilling"]
91
+ SK_NEW --> SK_LINT["3 · asdlc-lint<br/>BDD & AC Quality"]
92
+ SK_LINT --> SK_APPLY["5 · asdlc-apply<br/>Task-Level TDD Engine"]
93
+ SK_APPLY --> SK_VERIFY["6 · asdlc-verify<br/>12-Gate Audit"]
94
+ SK_VERIFY --> SK_GATE["Stage 6.5 Impl Gate<br/>AI AC Test + AI Review + Human TL"]
95
+ SK_GATE --> SK_ARCHIVE["7 · asdlc-archive<br/>Living Spec Sync"]
96
+ end
97
+ subgraph P3_REVIEWS ["CI Reviewers & Orientation Skills"]
98
+ direction LR
99
+ SK_SPECREV["asdlc-spec-review<br/>Spec PR Evaluation"]
100
+ SK_IMPLREV["asdlc-impl-review<br/>Player ≠ Referee Impl Audit"]
101
+ SK_DOCTOR["asdlc-doctor<br/>Diagnostics & Auto-Fix"]
102
+ SK_STATUS["asdlc-status<br/>Change Dashboard"]
103
+ end
104
+ end
105
+
106
+ subgraph P2 ["PLANE 2 · Governance CLI & Hard CI Gates (bin/asdlc.js · Deterministic Exit Codes)"]
107
+ direction TB
108
+ subgraph P2_STAGES ["7-Stage Lifecycle CLI Commands"]
109
+ direction LR
110
+ CMD_INIT["init"] --> CMD_NEW["new"]
111
+ CMD_NEW --> CMD_LINT["lint"]
112
+ CMD_LINT --> CMD_PR1["pr (spec)"]
113
+ CMD_PR1 --> CMD_APPROVE["approve"]
114
+ CMD_APPROVE --> CMD_APPLY["apply"]
115
+ CMD_APPLY --> CMD_TEST["test"]
116
+ CMD_TEST --> CMD_VERIFY["verify"]
117
+ CMD_VERIFY --> CMD_PR2["pr (impl)"]
118
+ CMD_PR2 --> CMD_ARCHIVE["archive"]
119
+ end
120
+ subgraph P2_GATES ["Cryptographic & Hard Verification Engines"]
121
+ direction LR
122
+ G_LOCK["approvedSha Gate<br/>Commit Lock on main"]
123
+ G_TAMPER["spec-tamper Gate<br/>Anti-Cheat Tree Audit"]
124
+ G_COV["R5 Scenario Coverage<br/>Scenario = AC Traceability"]
125
+ G_RUNNER["asdlc test Runner<br/>(test: path) Execution"]
126
+ G_PRESENCE["test-presence Gate<br/>Code Diff = Test Diff"]
127
+ G_TRIPLE["Triple-Review Gate<br/>AI AC Test + AI Review + Human TL"]
128
+ end
129
+ end
130
+
131
+ subgraph P1 ["PLANE 1 · Core Library (src/lib/ · Pure Functions, Zero Side-Effects, 100% Tested)"]
132
+ direction LR
133
+ subgraph P1_GOV ["Spec & Governance Engine"]
134
+ direction TB
135
+ M_LINT["speclint.js · R0–R8 Rules"]
136
+ M_POLICY["policy.js · .sdlc/policy.yaml"]
137
+ M_SCHEMA["schema.js · Version Pinning"]
138
+ M_AGENTS["agents.js · AGENTS.md Refresh"]
139
+ end
140
+ subgraph P1_GRAPH ["AST & Repository Context"]
141
+ direction TB
142
+ M_GRAPH["graphify.js · Knowledge Topology"]
143
+ M_GIT["git.js · Path-Limited Queries"]
144
+ M_FS["fs.js · Safe File Primitives"]
145
+ M_PATHS["paths.js · Canonical Paths"]
146
+ end
147
+ subgraph P1_EXEC ["TDD & Gate Verification"]
148
+ direction TB
149
+ M_TDD["tdd.js · Evidence Parser"]
150
+ M_TEST["commands/test.js · Test Runner"]
151
+ M_PRTYPE["prtype.js · PR Classifier"]
152
+ M_EXEC["exec.js · Process Isolation"]
153
+ end
154
+ end
155
+
156
+ P3 ==>|"Invokes CLI commands with --json"| P2
157
+ P2 ==>|"Calls pure library functions"| P1
158
+
159
+ classDef p3Style fill:#1e1b4b,stroke:#6366f1,stroke-width:2px,color:#ffffff,rx:8px,ry:8px;
160
+ classDef p2Style fill:#0f172a,stroke:#0ea5e9,stroke-width:2px,color:#ffffff,rx:8px,ry:8px;
161
+ classDef p1Style fill:#022c22,stroke:#10b981,stroke-width:2px,color:#ffffff,rx:8px,ry:8px;
162
+ classDef subCard fill:#020617,stroke:#334155,stroke-width:1.5px,color:#94a3b8;
163
+ classDef nodeStyle fill:#1e293b,stroke:#475569,stroke-width:1px,color:#f8fafc,rx:6px,ry:6px;
164
+ classDef cmdStyle fill:#0f172a,stroke:#38bdf8,stroke-width:1px,color:#38bdf8,font-weight:bold,rx:4px,ry:4px;
165
+ classDef gateCard fill:#1e293b,stroke:#f59e0b,stroke-width:1px,color:#fef3c7,rx:6px,ry:6px;
166
+
167
+ class P3 p3Style;
168
+ class P2 p2Style;
169
+ class P1 p1Style;
170
+ class P3_STAGES,P3_REVIEWS,P2_STAGES,P2_GATES,P1_GOV,P1_GRAPH,P1_EXEC subCard;
171
+ class SK_INIT,SK_NEW,SK_LINT,SK_APPLY,SK_VERIFY,SK_GATE,SK_ARCHIVE,SK_SPECREV,SK_IMPLREV,SK_DOCTOR,SK_STATUS,M_LINT,M_POLICY,M_SCHEMA,M_AGENTS,M_GRAPH,M_GIT,M_FS,M_PATHS,M_TDD,M_TEST,M_PRTYPE,M_EXEC nodeStyle;
172
+ class CMD_INIT,CMD_NEW,CMD_LINT,CMD_PR1,CMD_APPROVE,CMD_APPLY,CMD_TEST,CMD_VERIFY,CMD_PR2,CMD_ARCHIVE cmdStyle;
173
+ class G_LOCK,G_TAMPER,G_COV,G_RUNNER,G_PRESENCE,G_TRIPLE gateCard;
40
174
  ```
41
- ┌─────────────────────────────────────────────────────────────────────────────┐
42
- │ PLANE 3: Agentic IDE Skills & Commands (.agents/skills, .claude/skills, ...)│
43
- │ ● asdlc:new ● asdlc:lint ● asdlc:review ● asdlc:apply ● asdlc:verify │
44
- │ ● Bundled Engines: grilling (batch-grill-me), asdlc-apply (TDD Red-Green) │
45
- └──────────────────────────────────────┬──────────────────────────────────────┘
46
- │ runs CLI with --json
47
- ┌──────────────────────────────────────▼──────────────────────────────────────┐
48
- │ PLANE 2: Governance CLI & CI Gate (asdlc init/new/lint/approve/apply/verify)│
49
- │ ● Path-limited approval evidence ● Deterministic BDD/AC linters │
50
- │ ● Diff-based test presence gate ● Schema version pin & override guard │
51
- └──────────────────────────────────────┬──────────────────────────────────────┘
52
- │ calls pure functions
53
- ┌──────────────────────────────────────▼──────────────────────────────────────┐
54
- │ PLANE 1: Core Library (src/lib/ — zero side-effects, fully unit-tested) │
55
- │ ● speclint ● tdd ● prtype ● policy ● graphify ● schema ● agents │
56
- └─────────────────────────────────────────────────────────────────────────────┘
57
- ```
175
+
176
+ > **Rule**: Core reads and validates — it never prints and rarely writes. CLI is the thin shell (parse → call core → format → exit code). Skills are conversational coordinators — they call the CLI, interpret output, and guide multi-step flows.
58
177
 
59
178
  For complete technical specifications of each plane, see [docs/architecture.md](docs/architecture.md).
60
179
 
@@ -62,18 +181,20 @@ For complete technical specifications of each plane, see [docs/architecture.md](
62
181
 
63
182
  ## Bundled Out-of-the-Box Skills
64
183
 
65
- `asdlc` does not assume or require external user-level skills to be pre-installed. All critical agent harnesses are **packaged inside `asdlc` and installed automatically upon `asdlc init`**:
184
+ `asdlc` ships all critical agent harnesses inside the package. They are installed automatically into `.agents/skills/` on `asdlc init` — no manual skill setup required.
66
185
 
67
- | Stage & Skill | Purpose & Behavior |
186
+ | **Stage & Skill** | **Purpose & Behavior** |
68
187
  | :--- | :--- |
69
188
  | **Stage 1 · Init**<br>[`asdlc-init`](assets/skills/asdlc-init/SKILL.md) | Bootstraps repository: OpenSpec, Graphify AST engine, governance schema, policies, git hooks, and agent skills. |
70
- | **Stage 2 · New**<br>[`asdlc-new`](assets/skills/asdlc-new/SKILL.md) | Grounds intent in Graphify AST queries, seeds `clarifications.md`, and runs bundled **`batch-grill-me`** interview. |
189
+ | **Stage 2 · New**<br>[`asdlc-new`](assets/skills/asdlc-new/SKILL.md) | Grounds intent in Graphify AST queries, seeds `clarifications.md`, runs conversational `grill-me` (or `--batch-grill`), and scaffolds `design.md` guided by `api-design` and `frontend-design`. |
190
+ | **API Design**<br>[`api-design`](assets/skills/api-design/SKILL.md) | Enforces enterprise RESTful standards: plural noun URLs, structured error envelopes (Stripe-style / RFC 7807), cursor pagination, `Idempotency-Key` headers, and rate-limiting resilience. |
191
+ | **UI/UX Design**<br>[`frontend-design`](assets/skills/frontend-design/SKILL.md) | Enforces Anthropic official `frontend-design` & Vercel Web Interface Guidelines: anti-AI slop, bespoke 4–6 hex palettes, typography pairings, hero moments, and 5 mandatory states. |
71
192
  | **Stage 3 · Spec PR**<br>[`asdlc-pr`](assets/skills/asdlc-pr/SKILL.md) | Enforces deterministic BDD/AC linting (R0–R8) and opens Spec PR (CLI → REST API → 1-click Web URL) with auto-labels. |
72
- | **Stage 3 · Spec AI Review**<br>[`asdlc-spec-review`](assets/skills/asdlc-spec-review/SKILL.md) | CI-triggered independent 6-dimension spec evaluation; posts structured markdown findings and traceability matrix as PR comments via `gh`. |
73
- | **Stage 4 · Approve (Optional)**<br>[`asdlc-approve`](assets/skills/asdlc-approve/SKILL.md) | *(Optional)* Explicit audit stamp after PR merge (`specSha` + `READY_FOR_IMPL`). Auto-recognized by `apply`. |
193
+ | **Stage 3.5 · Spec AI Review**<br>[`asdlc-spec-review`](assets/skills/asdlc-spec-review/SKILL.md) | CI-triggered independent 6-dimension spec evaluation; posts structured findings and traceability matrix as PR comments. |
194
+ | **Stage 4 · Approve**<br>[`asdlc-approve`](assets/skills/asdlc-approve/SKILL.md) | Explicit audit stamp after PR merge (`specSha` + `READY_FOR_IMPL`). Auto-recognized by `apply`. |
74
195
  | **Stage 5 · Apply**<br>[`asdlc-apply`](assets/skills/asdlc-apply/SKILL.md) | Path-isolated zero-diff guard; executes strict **Red -> Green -> Refactor -> Evidence -> Converge** TDD loop. |
75
196
  | **Stage 6 · Verify**<br>[`asdlc-verify`](assets/skills/asdlc-verify/SKILL.md) | 12-gate implementation verification: test presence, task evidence, AC test mapping, and independent AI verifier. |
76
- | **Stage 6.5 · Impl AI Review**<br>[`asdlc-impl-review`](assets/skills/asdlc-impl-review/SKILL.md) | CI-triggered independent implementation evaluation (AC conformance matrix, code quality, TDD evidence); posts markdown findings as PR comments via `gh`. |
197
+ | **Stage 6.5 · Impl AI Review**<br>[`asdlc-impl-review`](assets/skills/asdlc-impl-review/SKILL.md) | CI-triggered independent implementation reviewer incorporating Anthropic code review principles: anti-thrashing convergence (3-round cap, incremental diffs), repo-level `REVIEW.md` contracts, introduced-vs-preexisting defect attribution, and risk tiering; posts findings as PR comments via `gh`. |
77
198
  | **Stage 7 · Archive**<br>[`asdlc-archive`](assets/skills/asdlc-archive/SKILL.md) | Deliberate closeout: syncs specs to master catalog, refreshes code AST graph, and updates system status. |
78
199
  | **Diagnostics**<br>[`asdlc-doctor`](assets/skills/asdlc-doctor/SKILL.md) | Evaluates 12 toolchain/governance invariants; provides automated 1-click remediation (`--fix`). |
79
200
  | **Orientation**<br>[`asdlc-status`](assets/skills/asdlc-status/SKILL.md) | Shows change stage progress, active artifacts, next command, or full portfolio dashboard. |
@@ -82,114 +203,184 @@ For complete technical specifications of each plane, see [docs/architecture.md](
82
203
 
83
204
  ## Install & Setup
84
205
 
85
- `asdlc` supports multiple installation methods depending on your environment:
86
-
87
206
  ```bash
88
- # Option A: From npm registry (Recommended)
207
+ # Recommended: install from npm
89
208
  npm install -g @akjamie/agentic-sdlc
90
209
 
91
- # Option B: Directly from GitHub repository (npm v12+ requires --allow-git=all)
210
+ # Or directly from GitHub (npm ≥12 requires --allow-git=all)
92
211
  npm install -g --allow-git=all git+https://github.com/akjamie/agentic-sdlc.git
93
212
 
94
- # Option C: Local development repository
95
- npm install -g .
96
-
97
- # Initialize repository (installs OpenSpec engine, Graphify, policy, and bundled skills)
213
+ # Initialize a repository (installs OpenSpec, Graphify, policy, and bundled skills)
98
214
  asdlc init --ci jenkins
99
- ```
100
-
101
- Verify setup health at any time:
102
215
 
103
- ```bash
216
+ # Verify toolchain health at any time
104
217
  asdlc doctor
105
218
  ```
106
219
 
220
+ > **One-liner health check**: `asdlc doctor` evaluates 12 invariants across your toolchain and governance setup, with `--fix` for automated remediation.
221
+
107
222
  ---
108
223
 
109
224
  ## The Seven Stages
110
225
 
226
+ The lifecycle is divided into three phases. Human approval gates are explicit; the CI automation pipeline is non-bypassable.
227
+
111
228
  ```mermaid
112
- flowchart LR
113
- S1["1 · init<br/>setup + skills"] --> S2["2 · new<br/>intent + grill"]
114
- S2 --> S3["3 · spec pr<br/>lint + open Spec PR"]
115
- S3 --> S4["4 · approve (optional)<br/>audit check"]
116
- S4 --> S5["5 · apply<br/>TDD loop"]
117
- S5 --> S6["6 · verify<br/>12 gates (local)"]
118
- S6 --> PR2["Impl PR<br/>asdlc pr (CI AI Review)"]
119
- PR2 --> S7["7 · archive<br/>sync + graph"]
120
-
121
- style S1 fill:#e8f4fd,stroke:#2196f3
122
- style S2 fill:#e8f4fd,stroke:#2196f3
123
- style S3 fill:#e8f4fd,stroke:#2196f3
124
- style S4 fill:#fff3e0,stroke:#ff9800
125
- style S5 fill:#e8f5e9,stroke:#4caf50
126
- style S6 fill:#fff3e0,stroke:#ff9800
127
- style PR2 fill:#e8f5e9,stroke:#4caf50
128
- style S7 fill:#f3e5f5,stroke:#9c27b0
229
+ flowchart TD
230
+ subgraph PHASE1 ["Phase A · Specification & Alignment (Intent to Contract)"]
231
+ direction LR
232
+ S1["1 · init<br/><b>Toolchain Setup</b><br/>OpenSpec + Graphify"] --> S2["2 · new<br/><b>Scaffold + Batch-Grill-Me</b><br/>AST explore.md + clarifications.md"]
233
+ S2 --> S3["3 · lint<br/><b>BDD/AC Gate</b><br/>R0–R8 + Scenario Coverage"]
234
+ S3 --> PR1{{"<b>Spec PR (Stage 3.5)</b><br/>CI Spec AI Review"}}
235
+ PR1 -->|"Human TL Approves & Merges"| S4["4 · approve<br/><b>Cryptographic Lock</b><br/>approvedSha & ready_for_impl"]
236
+ end
237
+
238
+ subgraph PHASE2 ["Phase B · Implementation & Hard Gate TDD (Contract to Verified Code)"]
239
+ direction LR
240
+ S4 -.->|"Guarded Unlock"| S5["5 · apply<br/><b>Apply Guard Check</b><br/>Refuses unapproved specs"]
241
+ S5 --> S5_TDD["<b>TDD Red-Green Loop</b><br/>Red -> Green -> Refactor"]
242
+ S5_TDD --> S5_TEST["5.5 · test<br/><b>Acceptance Tests</b><br/>Runs mapped AC assertions"]
243
+ S5_TEST --> S6["6 · verify<br/><b>12 Local Gates</b><br/>spec-tamper + test-presence"]
244
+ S6 --> PR2{{"<b>Impl PR (Stage 6.5)</b><br/>asdlc pr (impl)"}}
245
+ end
246
+
247
+ subgraph PHASE_GATE ["Stage 6.5 Quality Gate · Triple-Verification Peer Review"]
248
+ direction LR
249
+ G_AC["<b>1 · CI Acceptance Test</b><br/>asdlc test --json"] --> G_AI["<b>2 · AI Impl Review</b><br/>Player ≠ Referee Audit"]
250
+ G_AI --> G_HUMAN{{"<b>3 · Human Final Review</b><br/>Tech Lead Sign-off"}}
251
+ end
252
+
253
+ subgraph PHASE3 ["Phase C · Closeout & Living Catalog (Trunk Archive)"]
254
+ direction LR
255
+ S7["7 · archive<br/><b>Living Spec Sync</b><br/>openspec/specs/ + AST Refresh"]
256
+ end
257
+
258
+ PR2 ==> G_AC
259
+ G_HUMAN -.->|"Approved & Merged to main"| S7
260
+
261
+ classDef stageBox fill:#0f172a,stroke:#38bdf8,stroke-width:1.5px,color:#f8fafc,rx:6px,ry:6px;
262
+ classDef prBox fill:#312e81,stroke:#a855f7,stroke-width:2px,color:#ffffff,rx:10px,ry:10px;
263
+ classDef lockBox fill:#451a03,stroke:#f59e0b,stroke-width:2px,color:#ffffff,rx:6px,ry:6px;
264
+ classDef closeBox fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff,rx:6px,ry:6px;
265
+ classDef gateBox fill:#1e293b,stroke:#f59e0b,stroke-width:1.5px,color:#fef3c7,rx:6px,ry:6px;
266
+ classDef humanBox fill:#4c1d95,stroke:#c084fc,stroke-width:2px,color:#ffffff,rx:10px,ry:10px;
267
+ classDef subStyle fill:#020617,stroke:#334155,stroke-width:1.5px,color:#94a3b8;
268
+
269
+ class S1,S2,S3,S5,S5_TDD,S5_TEST,S6 stageBox;
270
+ class PR1,PR2 prBox;
271
+ class G_AC,G_AI gateBox;
272
+ class G_HUMAN humanBox;
273
+ class S4 lockBox;
274
+ class S7 closeBox;
275
+ class PHASE1,PHASE2,PHASE_GATE,PHASE3 subStyle;
129
276
  ```
130
277
 
131
- | Stage & Command | Lifecycle Action & Governance Guard |
278
+ ### Stage Reference
279
+
280
+ | Stage & Command | What It Does |
132
281
  | :--- | :--- |
133
- | **1 · Init**<br>`asdlc init [--ci jenkins]` | Bootstraps OpenSpec + Graphify, governance schema, policy, and 8+ agent tools. |
134
- | **2 · New**<br>`asdlc new "<requirement>" [--design]` | Derives slug, auto-seeds `design.md` for UI/API systems, queries code graph, guides 3rd-party research with offline degradation, and interviews author via `batch-grill-me`. |
135
- | **3 · Spec PR**<br>`asdlc pr <ID> <targetBranch>` | Pre-flight BDD/AC and technical design linting (`asdlc lint`), attaches `asdlc:spec-review` label, triggers CI Spec AI Review before human approval. |
136
- | **4 · Approve (Optional)**<br>`asdlc approve <ID>` | *(Optional)* Explicit audit stamp after Spec PR merge. `asdlc apply` automatically detects merged PRs if skipped. |
137
- | **5 · Apply**<br>`asdlc apply <ID>` | Multi-tenant zero-diff guard; launches `/asdlc:apply` task-level TDD Red-Green engine guided by approved specs and `design.md`. |
138
- | **6 · Verify (Local)**<br>`asdlc verify <ID>` | Local pre-flight self-check across 12 deterministic gates (test-presence, tdd-evidence, AC mappings, external tests). |
139
- | **6.5 · Impl PR**<br>`asdlc pr <ID> <targetBranch>` | Pre-flight implementation verification, pushes impl branch, attaches `asdlc:impl-review` label, triggers CI Code AI Review before merge. |
140
- | **7 · Archive**<br>`asdlc archive <ID>` | Syncs delta to `openspec/specs/`, creates `AGENTS.md` if missing, refreshes knowledge graph, and updates `AGENTS.md` system status. |
282
+ | **1 · Init**<br>`asdlc init [--ci jenkins]` | Bootstraps OpenSpec + Graphify, governance schema, policy, and 8+ bundled agent skills. |
283
+ | **2 · New**<br>`asdlc new "<requirement>" [--batch-grill] [--no-grill]` | Derives slug, queries code AST graph, seeds `design.md` for UI/API systems, and interviews author (conversational `grill-me` or `--batch-grill`). |
284
+ | **3 · Spec PR**<br>`asdlc pr <ID> <branch>` | Runs `asdlc lint` (R0–R8 + `R5-scenario-coverage`), pushes spec branch, attaches `asdlc:spec-review` label, triggers CI Spec AI Review. |
285
+ | **4 · Approve**<br>`asdlc approve <ID>` | Spec PR merge to `main` **is** the approval: records path-limited `specSha` and sets `READY_FOR_IMPL`. CI mode auto-detects merged PRs. |
286
+ | **5 · Apply**<br>`asdlc apply <ID>` | **Hard guard**: verifies `approvedSha` on `main`, **refuses** unapproved specs, then launches the task-level TDD Red-Green loop. |
287
+ | **5.5 · Acceptance Tests**<br>`asdlc test <ID> [--json]` | Parses `- [ ] ACn: ... (test: <path>)` mappings and runs real assertions. Local TDD driver + deterministic CI gate. |
288
+ | **6 · Verify**<br>`asdlc verify <ID>` | 12-gate local pre-flight: `spec-tamper`, `test-presence`, `tdd-evidence`, AC mappings, task completion, schema, and more. |
289
+ | **6.5 · Impl PR**<br>`asdlc pr <ID> <branch>` | Runs `asdlc verify`, pushes impl branch, attaches `asdlc:impl-review`, triggers ① CI `asdlc test --json` + ② CI AI Impl Review (Player ≠ Referee). |
290
+ | **7 · Archive**<br>`asdlc archive <ID>` | After Tech Lead merges Impl PR to `main`: syncs specs to `openspec/specs/`, refreshes AST graph, updates `AGENTS.md` system status. |
141
291
 
142
292
  ### Dual-PR Governance & Label Dispatch
143
293
 
144
- `asdlc pr` automatically detects whether you are submitting a **Spec PR** (Stage 3) or an **Implementation PR** (Stage 6.5) based on lifecycle state, branch, and approval history — completely autonomous with zero extra flags:
294
+ `asdlc pr` auto-detects Spec vs. Implementation PR from lifecycle state — zero extra flags needed.
145
295
 
146
- | PR Phase | Trigger Moment & Pre-flight | PR Labels | CI Automation Trigger | Human Action |
296
+ | PR Type | Pre-flight Check | Labels Applied | CI Pipeline | Human Gate |
147
297
  | :--- | :--- | :--- | :--- | :--- |
148
- | **Spec PR** | After spec drafting; runs **`asdlc lint`** (0 blockers) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` + triggers **Spec AI Review** (clarity, BDD scenarios, architecture alignment) | TL / Domain Lead approves & merges |
149
- | **Impl PR** | After TDD implementation; runs **`asdlc verify`** (12 gates) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` + triggers **Code AI Review** (diff analysis, style, edge cases) | Lead / Peer reviews code & merges |
298
+ | **Spec PR** (Stage 3.5) | `asdlc lint` — 0 blockers, R5 coverage | `asdlc:spec-review` · `spec` | Spec AI Review (6 dimensions) | TL / Domain Lead approves & merges to `main` |
299
+ | **Impl PR** (Stage 6.5) | `asdlc verify` — 12 gates | `asdlc:impl-review` · `impl` | ① `asdlc test --json` (AC gate) → ② `asdlc-impl-review` (Player ≠ Referee) | Tech Lead verifies AI review + AC results, then approves & merges |
300
+
301
+ ### Utility Commands
150
302
 
151
- **Navigation, Diagnostics & Workspace Maintenance:**
152
- - `asdlc status <ID>`: Instant orientation on current stage and exact next command.
153
- - `asdlc doctor [--fix]`: Comprehensive toolchain and policy health diagnostics with auto-remediation.
154
- - `asdlc update`: Synchronizes repository SDLC state in seconds: refreshes repo-level agent skills (`.agents/skills`), rebuilds codebase AST knowledge graph (`graphify-out/` bound to `HEAD`), updates `AGENTS.md` system status & architectural hubs, and verifies git hooks. Fails fast with guidance if run outside an initialized repository.
155
- - `asdlc upgrade [--global]`: Upgrades the machine toolchain (`asdlc` CLI, OpenSpec engine, Graphify, managed schema) and automatically updates the current repository if inside one, or global user skills (`~/.agents`) with `--global`.
156
- - `asdlc skills list`: Lists all bundled skills available in agentic-sdlc.
157
- - `asdlc skills install --global`: One-click setup on CI Linux VMs to inject skills into global agent directories (`~/.agents`, `~/.opencode`, `~/.pi`, `~/.dsh`) without polluting developer workspaces.
303
+ | Command | Purpose |
304
+ | :--- | :--- |
305
+ | `asdlc status <ID>` | Instant orientation: current stage, active artifacts, exact next command. |
306
+ | `asdlc doctor [--fix]` | 12-invariant toolchain health check with automated remediation. |
307
+ | `asdlc update` | Refreshes `.agents/skills`, rebuilds AST graph at `HEAD`, updates `AGENTS.md` hubs and git hooks. |
308
+ | `asdlc upgrade [--global]` | Upgrades `asdlc` CLI, OpenSpec engine, Graphify, and managed schema. `--global` updates user-level skills. |
309
+ | `asdlc skills list` | Lists all bundled skills available in the package. |
310
+ | `asdlc skills install --global` | Injects skills into global agent dirs (`~/.agents`, `~/.opencode`, etc.) for CI VMs. |
158
311
 
159
312
  ---
160
313
 
161
314
  ## What `asdlc verify` Checks
162
315
 
163
- `asdlc verify` executes in local developer terminals and on CI (Jenkins) without drift:
316
+ `asdlc verify` runs identically in developer terminals and CI (Jenkins / GitHub Actions). It is deterministic and exit-coded — no drift between local and remote.
164
317
 
165
318
  ```mermaid
166
- flowchart TB
167
- V["asdlc verify"] --> C1["pr-type<br/>paths only discrimination"]
168
- V --> C2["artifacts<br/>proposal + review + tasks + explore + spec"]
169
- V --> C3["approved-spec<br/>git log verification on target branch"]
170
- V --> C3b["spec-tamper<br/>locked spec paths unmodified in impl PR"]
171
- V --> C4["flow-state<br/>READY_FOR_IMPL verification"]
172
- V --> C5["tasks-complete<br/>all checkboxes resolved"]
173
- V --> C6["test-presence<br/>code diff mandates test diff"]
174
- V --> C7["tdd-evidence<br/>verified task output annotations"]
175
- V --> C8["BDD + AC<br/>GIVEN/WHEN/THEN + AC→test mapping"]
176
- V --> C9["openspec validate<br/>--all --strict"]
177
- V --> C10["schema-managed<br/>central install + version pin"]
178
- V --> C11["external<br/>unit tests · contract · security"]
179
- V --> C12["AI verification<br/>independent referee model"]
319
+ flowchart TD
320
+ V["<b>asdlc verify &lt;ID&gt;</b><br/>Deterministic Implementation Gatekeeper"]
321
+
322
+ subgraph TIER1 ["Tier 1 · Cryptographic & Contract Integrity"]
323
+ G_APPROVED["<b>approved-spec</b><br/>Matches commit on main"]
324
+ G_TAMPER["<b>spec-tamper</b><br/>Zero spec modifications in Impl PR"]
325
+ G_STATE["<b>flow-state</b><br/>Status is READY_FOR_IMPL"]
326
+ G_ARTIFACTS["<b>artifacts</b><br/>proposal, tasks, spec delta present"]
327
+ end
328
+
329
+ subgraph TIER2 ["Tier 2 · Code & Test Fidelity (TDD Invariants)"]
330
+ G_PRESENCE["<b>test-presence</b><br/>Code changes mandate test changes"]
331
+ G_TDD["<b>tdd-evidence</b><br/>Recorded test execution logs"]
332
+ G_BDD["<b>BDD + AC Traceability</b><br/>GIVEN/WHEN/THEN + (test: path)"]
333
+ G_TASKS["<b>tasks-complete</b><br/>All tasks checked off in tasks.md"]
334
+ end
335
+
336
+ subgraph TIER3 ["Tier 3 · Engine & Environment Invariants"]
337
+ G_PR["<b>pr-type</b><br/>Path classification"]
338
+ G_OPENSPEC["<b>openspec validate</b><br/>Schema conformance --all --strict"]
339
+ G_SCHEMA["<b>schema-managed</b><br/>Central install + pinned version"]
340
+ G_EXTERNAL["<b>external tests</b><br/>Unit, integration, and security tests"]
341
+ end
342
+
343
+ subgraph TIER4 ["Tier 4 · Independent AI Review (CI Referee)"]
344
+ G_AI["<b>Player ≠ Referee AI Verification</b><br/>Independent model, fresh context, spec conformance audit"]
345
+ end
346
+
347
+ V --> TIER1
348
+ V --> TIER2
349
+ V --> TIER3
350
+ V --> TIER4
351
+
352
+ classDef rootStyle fill:#1e1b4b,stroke:#818cf8,stroke-width:2px,color:#ffffff,rx:8px,ry:8px;
353
+ classDef tierStyle fill:#020617,stroke:#334155,stroke-width:1.5px,color:#94a3b8;
354
+ classDef gateStyle fill:#0f172a,stroke:#0284c7,stroke-width:1px,color:#f1f5f9,rx:5px,ry:5px;
355
+ classDef aiStyle fill:#3b0764,stroke:#c084fc,stroke-width:1.5px,color:#fdf4ff,rx:6px,ry:6px;
356
+
357
+ class V rootStyle;
358
+ class TIER1,TIER2,TIER3,TIER4 tierStyle;
359
+ class G_APPROVED,G_TAMPER,G_STATE,G_ARTIFACTS,G_PRESENCE,G_TDD,G_BDD,G_TASKS,G_PR,G_OPENSPEC,G_SCHEMA,G_EXTERNAL gateStyle;
360
+ class G_AI aiStyle;
180
361
  ```
181
362
 
182
363
  ---
183
364
 
184
365
  ## Governance Principles
185
366
 
186
- 1. **Adopt the engines, own the governance plane.** OpenSpec and Graphify are adopted, not forked.
187
- 2. **Approval is git.** A merged spec PR *is* the human approval; the gate proves it with a path-limited `git log`.
188
- 3. **Fail-closed.** Any verification without an approved commit fails.
189
- 4. **Deterministic first.** Linters, diff analyzers, and schema validators are pure functions (no LLM jitter).
190
- 5. **Enforced TDD.** Implementation diffs touching production code without tests are rejected by `test-presence`.
191
- 6. **Ground specs in code.** Graphify AST queries ground specifications in real code structure.
192
- 7. **One front door.** Everything runs through `asdlc` — no raw escape hatches.
367
+ These are the design philosophy decisions behind the hard invariants — the *why* behind each gate:
368
+
369
+ 1. **Approval is Git, not process** — A merged Spec PR on the protected branch (`main`) *is* the human approval. `asdlc apply` proves it via path-limited `git log` and physically halts if the spec is unapproved. There is no approval bypass.
370
+
371
+ 2. **Cryptographic anti-tampering** — Once merged to the protected branch, the spec is locked. An Implementation PR that modifies any locked spec path is immediately rejected by `spec-tamper`, blocking the oldest agent trick in the book.
372
+
373
+ 3. **Deterministic acceptance testing** — Every requirement must carry test-mapped Acceptance Criteria (`ACn: ... (test: <path>)`). `asdlc test` runs real code assertions — both a local TDD driver and an independent CI gate that can't be faked.
374
+
375
+ 4. **Player ≠ Referee isolation** — The authoring agent cannot act as its own quality gate. CI independently runs the test runner and invokes a separate AI review model with fresh context. Authoring agents cannot grade their own exams.
376
+
377
+ 5. **Full scenario-to-AC coverage** — The spec linter (`R5-scenario-coverage`) enforces that every declared scenario has at least one corresponding Acceptance Criterion. You can't describe complex failure modes and then only test the happy path.
378
+
379
+ 6. **Enforced TDD via test presence** — Implementation diffs that touch production code (`src/**`) without corresponding test modifications (`test/**`) are rejected at the `test-presence` gate. No code without tests.
380
+
381
+ 7. **Specs grounded in code AST** — Graphify AST knowledge graph queries ground specifications in real code structure, architectural hubs, and module topology *before* drafting. Specs reflect the codebase, not aspirations.
382
+
383
+ 8. **One front door, fail-closed** — Everything routes through `asdlc` wrappers. There are no raw escape hatches. Any missing approval or broken invariant fails closed — never silently passes.
193
384
 
194
385
  ---
195
386
 
@@ -210,9 +401,11 @@ flowchart TB
210
401
 
211
402
  ```bash
212
403
  npm install
213
- npm test # 66 unit and integration tests (100% pass)
404
+ npm test # 89 unit and integration tests — 100% pass rate
214
405
  ```
215
406
 
407
+ The test suite covers the core governance library (`src/lib/`), all CLI commands, acceptance test execution, spec linting rules (R0–R8 + R5 scenario coverage), and verify gate logic (including `spec-tamper`, `test-presence`, and `tdd-evidence`).
408
+
216
409
  ---
217
410
 
218
411
  ## License