@akjamie/agentic-sdlc 1.4.0 → 1.5.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
@@ -15,24 +15,28 @@
15
15
 
16
16
  ---
17
17
 
18
- ## ⚡ The Dilemma: "Vibe Coding" vs. "Enterprise Bureaucracy"
18
+ ## ⚡ The AI Software Engineering Bottleneck Shift
19
19
 
20
- Autonomous AI coding agents (Claude Code, Cursor, OpenCode, Codex) are transforming software delivery. But engineering leads face a frustrating dilemma:
20
+ AI coding agents (Claude Code, Cursor, OpenCode, Codex) write hundreds of lines of code in seconds. However, as code generation cost approaches zero, the engineering bottleneck shifts to **three predictable modes of failure in real-world codebases**:
21
21
 
22
22
  ```
23
- UNGOVERNED "VIBE CODING" RIGID "ALWAYS TWO-PR" FRAMEWORKS
24
- (Chaos & Silent Drift) (Suffocating Bureaucracy)
25
- ┌───────────────────────────┐ ┌───────────────────────────┐
26
- │ 💥 Hallucinated contracts │ │ 🐌 2 PRs for a 1-line doc │
27
- │ 💥 Code shipped w/o tests │ VS │ 🐌 45-min review for typo │
28
- │ 💥 Agents rewrite specs │ │ 🐌 Dev velocity tanks │
29
- │ 💥 Self-grading exams │ │ 🐌 Agents circumvent tool │
30
- └───────────────────────────┘ └───────────────────────────┘
23
+ HOW AUTONOMOUS AI AGENTS DRIFT IN PRODUCTION
24
+ ┌───────────────────────────┐ ┌───────────────────────────┐ ┌───────────────────────────┐
25
+ │ 1. Guessing on Ambiguity │ │ 2. Reward-Hacking Exams │ │ 3. Review Fatigue Chaos │
26
+ ├───────────────────────────┤ ├───────────────────────────┤ ├───────────────────────────┤
27
+ │ Agents guess architecture │ │ When tests or edge cases │ │ Tech Leads are flooded │
28
+ │ and schema assumptions │ │ fail, agents weaken test │ │ with 500-line AI diffs │
29
+ │ silently across 15 files │ │ assertions or modify specs│ │ lacking verified intent, │
30
+ │ instead of clarifying. │ │ to force green builds. │ │ tests, or rationale. │
31
+ └───────────────────────────┘ └───────────────────────────┘ └───────────────────────────┘
31
32
  ```
32
33
 
34
+ > **Why prompts alone (`AGENTS.md`, `CLAUDE.md`) cannot fix this:**
35
+ > Prompts are **suggestions**, not gates. An autonomous agent under token pressure will prioritize getting code written over adherence to instructions. True governance requires **deterministic exit-coded gates and independent verification agents**.
36
+
33
37
  ### The Solution: Adaptive Dual-Track SDLC (`asdlc`)
34
38
 
35
- `agentic-sdlc` bridges this gap with an **Intelligent, Neuro-Symbolic Governance Plane**:
39
+ `agentic-sdlc` bridges this gap with an **Intelligent, Adaptive Governance Plane**:
36
40
  - 🚀 **Frictionless Agility for Routine Work (L0 / L1)**: Pure test additions, documentation updates, and bounded local refactors run in a streamlined **Single-PR** mode with automated validation and zero red tape.
37
41
  - 🛡️ **Ironclad Rigor for High-Impact Changes (L2 / L3)**: Cross-boundary APIs (Spring Boot, FastAPI, Go, NestJS), database schemas, security tokens, and constitutional rules enforce **Dual-PR Spec-First** contracts with human sign-off.
38
42
  - 🤝 **Humane In-Place Scope Escalation**: If scope unexpectedly expands during implementation, the system **never punishes the engineer** by ripping their Git branch apart. It maintains the single PR in-place, revokes auto-merge, and routes to a Tech Lead for human review.
@@ -41,7 +45,7 @@ Autonomous AI coding agents (Claude Code, Cursor, OpenCode, Codex) are transform
41
45
 
42
46
  ## 🧭 Adaptive Risk-Tiered Governance (L0–L3)
43
47
 
44
- Every change evaluated by `asdlc` is continuously assessed along its lifecycle across 5 orthogonal risk vectors (Intent, Architecture/API, Security/Data, AST Topology, and Test/Doc Semantics).
48
+ Every change evaluated by `asdlc` is continuously assessed along its lifecycle across core risk vectors (Task Intent, Security/Data Boundaries, and AST Topology/Architecture).
45
49
 
46
50
  ```mermaid
47
51
  flowchart TD
@@ -63,7 +67,7 @@ flowchart TD
63
67
  T_L2 --> DP1["Spec PR to main<br/>(asdlc pr spec)"]
64
68
  T_L3 --> DP1
65
69
  DP1 --> G_SPEC["CI Spec Review & Human TL Approval"]
66
- G_SPEC --> S_LOCK["approvedSha Cryptographic Lock<br/>(asdlc approve)"]
70
+ G_SPEC --> S_LOCK["approvedSha Git SHA Lock<br/>(asdlc approve)"]
67
71
  S_LOCK --> DP2["Implementation Unlocked<br/>(asdlc apply)"]
68
72
  DP2 --> DP3["Task-Level TDD Red-Green Loop<br/>(asdlc test)"]
69
73
  DP3 --> PR_IMPL["Implementation PR to main<br/>(Human Tech Lead Final Gate)"]
@@ -102,12 +106,12 @@ flowchart TD
102
106
 
103
107
  ## 🛡️ Non-Negotiable Engineering Invariants
104
108
 
105
- Enterprise teams rely on deterministic code, not agent compliance or prompt enthusiasm. Every invariant is backed by cryptographic proofs or exit-coded engines:
109
+ Enterprise teams rely on deterministic code, not agent compliance or prompt enthusiasm. Every invariant is backed by Git-anchored proofs, hash-chain integrity, or exit-coded engines:
106
110
 
107
111
  | # | Enterprise Invariant | How `asdlc` Enforces It | Failure Mode |
108
112
  | :-: | :--- | :--- | :--- |
109
113
  | **1** | **No Apply Before Spec Approval (L2/L3)** | `asdlc apply` physically inspects path-limited Git history for `approvedSha` on `main`. | 🚫 **Hard Refusal** — Zero production code allowed without an approved spec. |
110
- | **2** | **Cryptographic Anti-Tamper (`spec-tamper`)** | Implementation diffs must NOT modify locked spec files once approved on `main`. | 🚫 **Instant Rejection** — Agents cannot alter requirements to make failing tests pass. |
114
+ | **2** | **Git-Anchored Anti-Tamper (`spec-tamper`)** | Implementation diffs must NOT modify locked spec files once approved on `main`. | 🚫 **Instant Rejection** — Agents cannot alter requirements to make failing tests pass. |
111
115
  | **3** | **Anti-Gaming Hash Chain** | Every level transition is sealed in an append-only, SHA-256 hash-chained `risk-history.jsonl`. | 🚫 **Integrity Breach** — Manual downgrades (`L2 -> L1`) are detected and blocked. |
112
116
  | **4** | **AI Classifier Invariant Defense** | AI semantic classifier output is validated against hard mathematical expectations. | 🚫 **Evasion Shield** — Prompts claiming a `DROP TABLE` is "just a test" are vetoed to L3. |
113
117
  | **5** | **Zero Untested Code (`test-presence`)** | Any change touching production source code (`src/**`, `app/**`) requires test diffs. | 🚫 **Rejection** — Stops AI "code dumps" without corresponding test coverage. |
@@ -140,7 +144,7 @@ Enterprise teams rely on deterministic code, not agent compliance or prompt enth
140
144
  │ ├─ assess/ Neuro-symbolic risk evaluation & hash-chain history │
141
145
  │ ├─ speclint/ R0–R8 BDD/AC linting & scenario coverage traceability │
142
146
  │ ├─ graphify/ Knowledge graph & code AST topology discovery │
143
- │ └─ verify/ 12 cryptographic & structural quality gates │
147
+ │ └─ verify/ 12 deterministic & structural quality gates │
144
148
  └────────────────────────────────────────────────────────────────────────┘
145
149
  ```
146
150
 
@@ -220,11 +224,11 @@ asdlc pr user-auth main
220
224
  | [`asdlc-new`](assets/skills/asdlc-new/SKILL.md) | Scaffolds change, queries AST hubs, runs conversational anti-fatigue `grill-me`. |
221
225
  | [`asdlc-lint`](assets/skills/asdlc-lint/SKILL.md) | Enforces deterministic BDD GIVEN/WHEN/THEN and R5 scenario-to-AC coverage. |
222
226
  | [`asdlc-pr`](assets/skills/asdlc-pr/SKILL.md) | Smart PR dispatcher: automatically handles Spec PR vs. Implementation PR. |
223
- | [`asdlc-approve`](assets/skills/asdlc-approve/SKILL.md) | Stamps cryptographic `specSha` lock upon Spec PR merge. |
227
+ | [`asdlc-approve`](assets/skills/asdlc-approve/SKILL.md) | Stamps Git `specSha` lock upon Spec PR merge. |
224
228
  | [`asdlc-apply`](assets/skills/asdlc-apply/SKILL.md) | Strict task-level TDD engine (`Red -> Green -> Refactor -> Evidence -> Converge`). |
225
229
  | [`asdlc-verify`](assets/skills/asdlc-verify/SKILL.md) | Pre-flight audit across 12 gates (test presence, evidence, tamper guard, schema). |
226
- | [`asdlc-spec-review`](assets/skills/asdlc-spec-review/SKILL.md) | CI-triggered 6-dimensional spec review before human lead approval. |
227
- | [`asdlc-impl-review`](assets/skills/asdlc-impl-review/SKILL.md) | CI-triggered Player ≠ Referee implementation reviewer with Anthropic convergence rules. |
230
+ | [`asdlc-spec-review`](assets/skills/asdlc-spec-review/SKILL.md) | Independent review agent: 6-dimensional spec review before human lead approval. |
231
+ | [`asdlc-impl-review`](assets/skills/asdlc-impl-review/SKILL.md) | Independent review agent: Player ≠ Referee verification with test execution and Anthropic convergence rules. |
228
232
  | [`asdlc-archive`](assets/skills/asdlc-archive/SKILL.md) | Syncs specs to living catalog, refreshes AST graph, and updates system status. |
229
233
  | [`asdlc-doctor`](assets/skills/asdlc-doctor/SKILL.md) | 12-invariant diagnostic engine with 1-click automated remediation (`--fix`). |
230
234
  | [`asdlc-status`](assets/skills/asdlc-status/SKILL.md) | Real-time change lifecycle dashboard and next actionable command guidance. |
@@ -239,7 +243,7 @@ Every implementation diff must pass the 12 deterministic gates in `asdlc verify`
239
243
  flowchart TD
240
244
  V["<b>asdlc verify &lt;ID&gt;</b><br/>Deterministic Implementation Gatekeeper"]
241
245
 
242
- subgraph TIER1 ["Tier 1 · Cryptographic & Contract Integrity"]
246
+ subgraph TIER1 ["Tier 1 · Contract & Hash-Chain Integrity"]
243
247
  G_APPROVED["<b>approved-spec</b><br/>Matches commit on main"]
244
248
  G_TAMPER["<b>spec-tamper</b><br/>Zero spec modifications in Impl PR"]
245
249
  G_LEVEL["<b>level-integrity</b><br/>Hash-chain tamper check"]
@@ -319,7 +323,7 @@ Explore the complete documentation in the [`docs/`](docs/) directory:
319
323
  - ⏱️ [**30-Minute Getting Started Guide**](docs/getting-started.md): Frictionless step-by-step tutorial from install to first Spec PR.
320
324
  - 📐 [**Spec Format & Lint Reference**](docs/spec-format.md): Human-readable guide to R0–R8 lint rules with pass/fail examples.
321
325
  - 🌐 [**Quickstart Guide (Bilingual)**](docs/quickstart.md): End-to-end walkthrough covering the complete 7-stage lifecycle.
322
- - 🏛️ [**System Architecture & Whitepaper**](docs/about.md): Why Agentic SDLC, L0–L3 governance, and cryptographic anti-tamper proofs.
326
+ - 🏛️ [**System Architecture & Whitepaper**](docs/about.md): Why Agentic SDLC, L0–L3 governance, and Git SHA anti-tamper locks.
323
327
  - 🩺 [**Environment Doctor Manual**](docs/doctor.md): Diagnostic reference for all 12 health checks and `--fix` automated healing.
324
328
  - ⌨️ [**CLI Command Reference**](docs/usage.md): Full flag, option, and exit code reference for all `asdlc` commands.
325
329
  - 📖 [**Standard Glossary**](docs/glossary.md): Authoritative lexicon for living specs, spec SHAs, and architectural god nodes.
@@ -3,7 +3,7 @@ name: asdlc-approve
3
3
  description: "Stage 4: Lock approvedSha and transition change to READY_FOR_IMPL"
4
4
  ---
5
5
 
6
- # /asdlc-approve - Approve Spec & Cryptographic Lock
6
+ # /asdlc-approve - Approve Spec & Git SHA Lock
7
7
 
8
8
  Lock the approved specification state and unlock implementation for the change.
9
9
 
@@ -16,6 +16,6 @@ asdlc approve <CHANGE_ID>
16
16
  ## Behavior
17
17
 
18
18
  1. Evaluates human lead approval (or PR merge commit on target branch).
19
- 2. Computes and locks cryptographic `approvedSha` for the spec files.
19
+ 2. Computes and locks the Git-anchored `approvedSha` snapshot for the spec files.
20
20
  3. Stamps `review.md` with `verdict: APPROVE` and `specSha`.
21
21
  4. Transitions change state to `READY_FOR_IMPL`.
@@ -199,6 +199,7 @@
199
199
  "properties": {
200
200
  "level": { "type": "string", "enum": ["L0", "L1", "L2", "L3"] },
201
201
  "confidence": { "type": "string", "enum": ["high", "medium", "low"] },
202
+ "evaluator_mode": { "type": "string", "enum": ["agent_native", "llm_classifier", "heuristic_seed"] },
202
203
  "evidence": {
203
204
  "type": "array",
204
205
  "items": {
@@ -207,7 +208,7 @@
207
208
  "additionalProperties": false,
208
209
  "properties": {
209
210
  "id": { "type": "string" },
210
- "kind": { "type": "string", "enum": ["repository_fact", "task_statement", "scanner_result", "rule_hit", "reviewer_finding"] },
211
+ "kind": { "type": "string", "enum": ["repository_fact", "task_statement", "scanner_result", "rule_hit", "reviewer_finding", "semantic_intent", "topology_centrality"] },
211
212
  "signal": { "type": "string", "enum": ["hard", "soft"] },
212
213
  "summary": { "type": "string" },
213
214
  "source": { "type": "string" },
@@ -25,7 +25,7 @@ Before editing any implementation or test code, run the apply guard:
25
25
  asdlc apply <CHANGE_ID> [--auto-pr] [--target-branch <ref>]
26
26
  ```
27
27
 
28
- `asdlc apply` deterministically verifies cryptographic preconditions:
28
+ `asdlc apply` deterministically verifies Git-anchored preconditions:
29
29
  1. **Target Branch Approved Commit (`approvedSha`)**: Confirms that a commit touching the locked paths (`proposal.md` and `specs/**`) is physically merged into the target branch (`main` or `origin/main`).
30
30
  2. **Change State Machine (`ready_for_impl`)**: Confirms `.openspec.yaml` has been transitioned to `status: ready_for_impl` (via `asdlc approve <ID>`).
31
31
  3. **Spec Fingerprint Integrity (`specSha`)**: Verifies that the declared `specSha` in `.openspec.yaml` exactly matches the `approvedSha` on the protected branch.
@@ -13,7 +13,7 @@ This skill executes **Stage 4 (Approve)** of the Agentic SDLC. It transitions a
13
13
 
14
14
  `asdlc approve` is **branch-agnostic**. It does not enforce a rigid branching dogma, nor does it require selecting artificial "modes".
15
15
 
16
- In enterprise environments (whether using `feature -> staging -> main`, trunk-based, or multi-level git flow), **Approve** represents a single cryptographic gate:
16
+ In enterprise environments (whether using `feature -> staging -> main`, trunk-based, or multi-level git flow), **Approve** represents a single Git-anchored tamper-detection gate:
17
17
 
18
18
  ```text
19
19
  [Stage 2: Grilling / Proposal]
@@ -6,10 +6,10 @@ aliases:
6
6
  - code-review-asdlc
7
7
  ---
8
8
 
9
- # /asdlc:impl-review — CI-Triggered Independent Implementation Reviewer
9
+ # /asdlc:impl-review — Independent Implementation Review Agent
10
10
 
11
- This skill executes **independent AI implementation review**, triggered by CI when a PR carries the `asdlc:impl-review` label.
12
- It posts its findings as a **markdown PR comment** via the GitHub API so the human lead sees them inline on the PR.
11
+ This skill executes **independent AI implementation review**, executed by an independent reviewer agent (either triggered on PR or invoked locally on a change ID).
12
+ It evaluates the code against approved specifications, test evidence, and production safety.
13
13
 
14
14
  It applies the **Player ≠ Referee** principle: the reviewing agent MUST NOT be the agent that authored the implementation.
15
15
 
@@ -19,21 +19,23 @@ Drawing from Anthropic's engineering practices for scaling AI code reviews, this
19
19
  1. **Convergence Protocol**: Review loops must converge, not thrash. Capped at **3 rounds** max; re-reviews inspect **incremental diffs only**.
20
20
  2. **Defect Attribution**: Clearly separates defects introduced by this PR (`[Blocker: Introduced]`) from pre-existing legacy issues (`[Tech Debt: Pre-existing]`). Pre-existing flaws **never block** the PR.
21
21
  3. **Repository Contract (`REVIEW.md`)**: Respects repository-defined domain rules, failure modes, and ignore paths from the trusted base branch over generic AI opinions.
22
- 4. **Risk-Based Tiering**: Scrutiny scales with the change's risk profile (Tier 1 Docs/Style, Tier 2 Standard, Tier 3 Critical/Auth/Billing). Highest-risk file sets the PR tier.
23
- 5. **Class-of-Bug Grouping**: Defect patterns are grouped into singular findings rather than fragmented into line-by-line spam.
24
- 6. **Structural & Actionable Findings**: Every finding provides explicit Location, Defect, Impact, and Action Required for instant clarity to both AI agents and human leads.
22
+ 4. **Mandatory Acceptance Test Verification (`asdlc test`)**: Reviewer mandates that `asdlc test <CHANGE_ID>` has executed and all mapped AC assertions pass before issuing approval.
23
+ 5. **Risk-Based Tiering**: Scrutiny scales with the change's risk profile (Tier 1 Docs/Style, Tier 2 Standard, Tier 3 Critical/Auth/Billing). Highest-risk file sets the PR tier.
24
+ 6. **Class-of-Bug Grouping**: Defect patterns are grouped into singular findings rather than fragmented into line-by-line spam.
25
+ 7. **Structural & Actionable Findings**: Every finding provides explicit Location, Defect, Impact, and Action Required for instant clarity to both AI agents and human leads.
25
26
 
26
27
  > [!IMPORTANT]
27
28
  > **Scope**: Reviews *implementation conformance and code quality* — spec adherence, test rigor, architecture, and production safety.
28
- > Requires `asdlc verify <CHANGE_ID>` to have passed (12 gates) before this review is meaningful.
29
- > Does NOT re-run `asdlc verify`. Does NOT review spec intent — that is `asdlc-spec-review`.
30
- > Output is a **PR comment**, not a local file.
29
+ > Requires `asdlc test <CHANGE_ID>` and `asdlc verify <CHANGE_ID>` to have passed before this review can issue an APPROVE verdict.
30
+ > Does NOT review spec intent — that is `asdlc-spec-review`.
31
31
 
32
32
  ---
33
33
 
34
- ## Trigger
34
+ ## Invocation & Triggers
35
35
 
36
- This skill is invoked by CI when a PR is labeled `asdlc:impl-review`. The typical invocation in a GitHub Actions workflow or Jenkinsfile:
36
+ This skill can be invoked:
37
+ 1. **Locally by an independent agent**: `/asdlc:impl-review <CHANGE_ID>`
38
+ 2. **Automatically on PRs** carrying the `asdlc:impl-review` label via PR automation workflows:
37
39
 
38
40
  ```yaml
39
41
  # GitHub Actions example
@@ -40,7 +40,10 @@ The CLI:
40
40
  - **Default (conversational)**: Runs high-signal, recommendation-led `grill-me` (1 material decision at a time).
41
41
  - **`--batch-grill`**: Evaluates the entire design tree and presents the active frontier in structured batches.
42
42
  - **`--no-grill`**: Bypasses interactive grilling for self-evident fixes and pre-aligned tasks.
43
- 5. **Technical Design Auto-Detection**: If the requirement touches UI/UX, frontend, APIs, services, databases, or architecture (or if `--design` is passed), seeds `design.md` with enterprise-grade technical design scaffolding.
43
+ 5. **Agent-Native Semantic Grounding**:
44
+ - As an AI agent in an active reasoning session, evaluate the true architectural and security intent of the requirement.
45
+ - If the requirement touches APIs, schemas, or destructive operations, record your agent evaluation into `openspec/changes/<SLUG>/.agent-assess.json` (e.g. `{"classification":"api_contract","rationale":"..."}`). The governance engine reads this alongside Graphify AST hubs to enforce accurate risk tiers without developer gaming.
46
+ 6. **Technical Design Auto-Detection**: If the requirement touches UI/UX, frontend, APIs, services, databases, or architecture (or if `--design` is passed), seeds `design.md` with enterprise-grade technical design scaffolding.
44
47
 
45
48
  > [!IMPORTANT]
46
49
  > **NO PAUSE / CONTINUOUS EXECUTION**: Do NOT stop after `asdlc new` to ask the author "Should I start grilling?".
@@ -131,7 +134,7 @@ Once `## Open questions` in `clarifications.md` is empty, author the change docu
131
134
  4. **Review Provenance (Player $\ne$ Referee)**:
132
135
  - The authoring agent MUST NOT approve its own spec.
133
136
  - Do NOT stamp `review.md` with self-approval.
134
- - Independent AI review (`asdlc:spec-review`) is executed automatically on the Spec PR by CI.
137
+ - Independent AI review (`asdlc:spec-review`) is executed by an independent review agent (locally or via PR automation).
135
138
  - Formal approval is given by the human lead via PR merge or `asdlc approve <SLUG>`.
136
139
 
137
140
  ### Step 5: Transition to Lint
@@ -5,10 +5,10 @@ aliases:
5
5
  - spec-review
6
6
  ---
7
7
 
8
- # /asdlc:spec-review — CI-Triggered Independent Spec Reviewer
8
+ # /asdlc:spec-review — Independent Spec Review Agent
9
9
 
10
- This skill executes **independent AI spec review**, triggered by CI when a PR carries the `asdlc:spec-review` label.
11
- It posts its findings as a **markdown PR comment** via the GitHub API so the human TL sees them inline on the PR.
10
+ This skill executes **independent AI spec review**, executed by an independent reviewer agent (either triggered on PR or invoked locally on a change ID).
11
+ It evaluates the specification and provides clear review findings so the human Tech Lead can make informed approval decisions.
12
12
 
13
13
  It applies the **Player ≠ Referee** principle: the reviewing agent MUST NOT be the agent that authored the spec.
14
14
 
@@ -16,13 +16,15 @@ It applies the **Player ≠ Referee** principle: the reviewing agent MUST NOT be
16
16
  > **Scope**: Reviews *intent* — BDD quality, logical consistency, architectural soundness, AC testability.
17
17
  > Does NOT re-run `asdlc lint` (deterministic structural checks are already gated by `asdlc pr`).
18
18
  > Does NOT review implementation code — that is `asdlc-impl-review`.
19
- > Output is a **PR comment**, not a local file.
19
+ > Output can be posted as a PR comment or reported locally.
20
20
 
21
21
  ---
22
22
 
23
- ## Trigger
23
+ ## Invocation & Triggers
24
24
 
25
- This skill is invoked by CI when a PR is labeled `asdlc:spec-review`. The typical invocation in a GitHub Actions workflow or Jenkinsfile:
25
+ This skill can be invoked:
26
+ 1. **Locally by an independent agent**: `/asdlc:spec-review <CHANGE_ID>`
27
+ 2. **Automatically on PRs** carrying the `asdlc:spec-review` label via PR automation workflows:
26
28
 
27
29
  ```yaml
28
30
  # GitHub Actions example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akjamie/agentic-sdlc",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Enterprise Agentic SDLC governance CLI: a 7-stage spec-driven flow on top of OpenSpec + Graphify, enforced by CI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,18 +1,18 @@
1
1
  /**
2
- * AI Semantic Classifier with Strict Expectation & Invariant Validation (Specification §2.2 & §5.3)
2
+ * Agent-Native Semantic Evaluation with Strict Expectation & Invariant Validation (Specification §2.2 & §5.3)
3
3
  *
4
4
  * Design principle:
5
- * Path patterns and filename suffixes are only few-shot examples, NOT hardcoded dogma.
6
- * Real classification is performed via AI semantic judgment of test/doc nature.
7
- * System enforces strict expectation invariants on the AI output to prevent hallucinations.
5
+ * Classification is performed natively by the executing AI Agent within its live reasoning session,
6
+ * supplemented by environment hooks and validated baseline heuristics.
7
+ * The system enforces strict expectation invariants on the semantic output to prevent hallucinations.
8
8
  */
9
9
 
10
10
  import { execSync } from 'node:child_process';
11
- import { CANONICAL_DESTRUCTIVE_PATTERN } from './rules/builtin.js';
11
+ import { CANONICAL_DESTRUCTIVE_PATTERN, isTestOrDocFile, isChangeMetadataFile } from './rules/builtin.js';
12
12
 
13
13
  export const AI_CLASSIFICATION_SCHEMA = {
14
14
  type: 'object',
15
- required: ['is_pure_test', 'is_pure_doc', 'classification', 'rationale'],
15
+ required: ['is_pure_test', 'is_pure_doc', 'classification', 'rationale', 'evaluator_mode'],
16
16
  properties: {
17
17
  is_pure_test: { type: 'boolean' },
18
18
  is_pure_doc: { type: 'boolean' },
@@ -20,6 +20,7 @@ export const AI_CLASSIFICATION_SCHEMA = {
20
20
  contains_api_changes: { type: 'boolean' },
21
21
  classification: { type: 'string', enum: ['test_only', 'doc_only', 'api_contract', 'internal_code', 'destructive', 'governance_plane'] },
22
22
  confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
23
+ evaluator_mode: { type: 'string', enum: ['agent_native', 'llm_classifier', 'heuristic_seed'] },
23
24
  rationale: { type: 'string' }
24
25
  }
25
26
  };
@@ -67,39 +68,69 @@ export function validateAIClassificationExpectation(aiOutput, { changedFiles = [
67
68
  };
68
69
  }
69
70
 
71
+ // Invariant 3: Production source code files cannot be disguised as pure test or doc
72
+ // Exclude per-change SDLC metadata artifacts (openspec/changes/<id>/*) which accompany every branch
73
+ const substantiveFiles = normFiles.filter((f) => !isChangeMetadataFile(f));
74
+ const touchesProductionCode = substantiveFiles.some((f) => !isTestOrDocFile(f));
75
+ if (touchesProductionCode && (aiOutput.is_pure_test || aiOutput.is_pure_doc)) {
76
+ return {
77
+ ok: false,
78
+ error: 'Invariant violation: changes touching production source files cannot be classified as pure test or doc',
79
+ override: { is_pure_test: false, is_pure_doc: false, classification: 'internal_code' }
80
+ };
81
+ }
82
+
70
83
  return { ok: true, validated: aiOutput };
71
84
  }
72
85
 
73
86
  /**
74
87
  * Semantic evaluation entrypoint:
75
- * Invokes AI classifier if available, or uses validated few-shot seed heuristic as offline fallback.
88
+ * Grounded in Agent session reasoning, environment model hooks, or validated heuristic baseline.
76
89
  */
77
- export function judgeChangeSemantics({ requirement = '', changedFiles = [], repoRoot = null } = {}) {
90
+ export function judgeChangeSemantics({ requirement = '', changedFiles = [], repoRoot = null, agentContext = null } = {}) {
78
91
  const req = String(requirement || '').toLowerCase();
79
92
  const normFiles = (changedFiles || []).map((f) => f.replace(/\\/g, '/'));
80
93
 
81
- // If environment has an AI classification provider command configured, invoke it (P1-1)
82
94
  let rawAiOutput = null;
83
- const classifierCmd = process.env.ASDLC_CLASSIFIER_COMMAND;
84
- if (classifierCmd) {
85
- try {
86
- const inputJson = JSON.stringify({ requirement: req, changedFiles: normFiles });
87
- const stdout = execSync(classifierCmd, {
88
- input: inputJson,
89
- encoding: 'utf8',
90
- timeout: 5000,
91
- env: { ...process.env, ASDLC_INPUT_JSON: inputJson }
92
- });
93
- const parsed = JSON.parse(stdout.trim());
94
- if (parsed && typeof parsed === 'object') {
95
- rawAiOutput = parsed;
95
+
96
+ // 1. Direct Agent-Native Evaluation:
97
+ // When running inside an AI coding agent session, accept verified semantic reasoning from the agent
98
+ if (agentContext && typeof agentContext === 'object') {
99
+ rawAiOutput = {
100
+ is_pure_test: Boolean(agentContext.is_pure_test),
101
+ is_pure_doc: Boolean(agentContext.is_pure_doc),
102
+ contains_destructive_ops: Boolean(agentContext.contains_destructive_ops || CANONICAL_DESTRUCTIVE_PATTERN.test(req)),
103
+ contains_api_changes: Boolean(agentContext.contains_api_changes),
104
+ classification: agentContext.classification || (agentContext.is_pure_test ? 'test_only' : (agentContext.is_pure_doc ? 'doc_only' : 'internal_code')),
105
+ confidence: agentContext.confidence || 'high',
106
+ evaluator_mode: 'agent_native',
107
+ rationale: agentContext.rationale || 'Evaluated natively by executing AI Agent in active session'
108
+ };
109
+ }
110
+
111
+ // 2. External Provider Command (if configured via environment hook)
112
+ if (!rawAiOutput) {
113
+ const classifierCmd = process.env.ASDLC_CLASSIFIER_COMMAND;
114
+ if (classifierCmd) {
115
+ try {
116
+ const inputJson = JSON.stringify({ requirement: req, changedFiles: normFiles });
117
+ const stdout = execSync(classifierCmd, {
118
+ input: inputJson,
119
+ encoding: 'utf8',
120
+ timeout: 5000,
121
+ env: { ...process.env, ASDLC_INPUT_JSON: inputJson }
122
+ });
123
+ const parsed = JSON.parse(stdout.trim());
124
+ if (parsed && typeof parsed === 'object') {
125
+ rawAiOutput = { ...parsed, evaluator_mode: 'llm_classifier' };
126
+ }
127
+ } catch {
128
+ // Fallback to baseline heuristic on timeout or execution failure
96
129
  }
97
- } catch {
98
- // Fallback to validated heuristic seed on timeout or command failure
99
130
  }
100
131
  }
101
132
 
102
- // Few-shot baseline seed for offline / local test fallback
133
+ // 3. Validated baseline heuristic seed (deterministic fallback for standalone CLI execution)
103
134
  if (!rawAiOutput) {
104
135
  const hasProductionTarget = /\b(create|add|implement|build)\b.*\b(api|endpoint|service|table|database|schema|handler|router)\b/i.test(req);
105
136
  const hasDestructiveAction = CANONICAL_DESTRUCTIVE_PATTERN.test(req);
@@ -125,36 +156,42 @@ export function judgeChangeSemantics({ requirement = '', changedFiles = [], repo
125
156
  /^license$/i
126
157
  ];
127
158
 
128
- const allTestFiles = normFiles.length > 0 && normFiles.every((f) => testPatternSamples.some((p) => p.test(f)));
129
- const allDocFiles = normFiles.length > 0 && normFiles.every((f) => docPatternSamples.some((p) => p.test(f)));
159
+ const substantiveFiles = normFiles.filter((f) => !isChangeMetadataFile(f));
160
+ const allTestFiles = substantiveFiles.length > 0 && substantiveFiles.every((f) => testPatternSamples.some((p) => p.test(f)));
161
+ const allDocFiles = substantiveFiles.length > 0 && substantiveFiles.every((f) => docPatternSamples.some((p) => p.test(f)));
130
162
 
131
- const isPureTest = allTestFiles || (normFiles.length === 0 && isTestIntent);
132
- const isPureDoc = allDocFiles || (normFiles.length === 0 && isDocIntent);
163
+ const isPureTest = allTestFiles || (substantiveFiles.length === 0 && isTestIntent);
164
+ const isPureDoc = allDocFiles || (substantiveFiles.length === 0 && isDocIntent);
133
165
 
134
166
  rawAiOutput = {
135
167
  is_pure_test: isPureTest,
136
168
  is_pure_doc: isPureDoc,
137
169
  contains_destructive_ops: CANONICAL_DESTRUCTIVE_PATTERN.test(req),
138
- contains_api_changes: /\b(api|openapi|rest|controller|router)\b/i.test(req),
170
+ contains_api_changes: false,
139
171
  classification: isPureTest ? 'test_only' : (isPureDoc ? 'doc_only' : 'internal_code'),
140
172
  confidence: 'high',
173
+ evaluator_mode: 'heuristic_seed',
141
174
  rationale: isPureTest
142
- ? 'AI Semantic Evaluation: Change is strictly confined to test suites, mocks, and test assertions.'
143
- : (isPureDoc ? 'AI Semantic Evaluation: Change is purely documentation, typo fix, comments, or non-executable text.' : 'General code change')
175
+ ? 'Deterministic Heuristic Baseline: Change is strictly confined to test suites, mocks, and test assertions.'
176
+ : (isPureDoc ? 'Deterministic Heuristic Baseline: Change is purely documentation, typo fix, comments, or non-executable text.' : 'Deterministic Heuristic Baseline: General code change')
144
177
  };
178
+ } else {
179
+ rawAiOutput.evaluator_mode = rawAiOutput.evaluator_mode || 'llm_classifier';
145
180
  }
146
181
 
147
182
  // Mandatory expectation check
148
183
  const check = validateAIClassificationExpectation(rawAiOutput, { changedFiles, requirement });
149
184
  if (!check.ok) {
185
+ const mode = rawAiOutput?.evaluator_mode || 'heuristic_seed';
150
186
  if (check.override) {
151
- return { ...rawAiOutput, ...check.override, confidence: 'medium', invariant_override: true, rejection_reason: check.error };
187
+ return { ...rawAiOutput, ...check.override, evaluator_mode: mode, confidence: 'medium', invariant_override: true, rejection_reason: check.error };
152
188
  }
153
189
  return {
154
190
  is_pure_test: false,
155
191
  is_pure_doc: false,
156
192
  classification: 'internal_code',
157
193
  confidence: 'low',
194
+ evaluator_mode: mode,
158
195
  rationale: `AI output failed expectation verification: ${check.error}`
159
196
  };
160
197
  }
@@ -1,4 +1,4 @@
1
- import { LEVEL_RANK, DEFAULT_GOVERNANCE, L0_DETERMINISTIC_PATTERNS } from './rules/builtin.js';
1
+ import { LEVEL_RANK, DEFAULT_GOVERNANCE, L0_DETERMINISTIC_PATTERNS, isChangeMetadataFile } from './rules/builtin.js';
2
2
  import { judgeChangeSemantics } from './ai_judge.js';
3
3
 
4
4
  /**
@@ -57,12 +57,14 @@ export function decideAssessment({
57
57
  );
58
58
 
59
59
  const req = v1.requirement || '';
60
- const aiJudgment = judgeChangeSemantics({ requirement: req, changedFiles });
60
+ const aiJudgment = v1.aiJudgment || judgeChangeSemantics({ requirement: req, changedFiles });
61
61
 
62
62
  if (!hasMandatoryHumanReview && maxRank <= 1) {
63
- if (changedFiles.length > 0) {
64
- const norm = changedFiles.map((f) => f.replace(/\\/g, '/'));
65
- const allDoc = norm.every((f) => L0_DETERMINISTIC_PATTERNS.some((p) => p.test(f)));
63
+ const substantiveFiles = changedFiles
64
+ .map((f) => f.replace(/\\/g, '/'))
65
+ .filter((f) => !isChangeMetadataFile(f));
66
+ if (substantiveFiles.length > 0) {
67
+ const allDoc = substantiveFiles.every((f) => L0_DETERMINISTIC_PATTERNS.some((p) => p.test(f)));
66
68
  if (allDoc || aiJudgment.is_pure_doc || aiJudgment.is_pure_test) {
67
69
  calculatedLevel = 'L0';
68
70
  }
@@ -114,7 +116,7 @@ export function decideAssessment({
114
116
  } else if (highestRank > baseRank) {
115
117
  direction = 'same';
116
118
  triggers.push(`Level remains escalated at ${finalLevel} above baseline ${baselineLevel}`);
117
- if (stage === 'impl') {
119
+ if (stage === 'impl' && (previous?.reason_codes || []).includes('ESCALATED_IN_IMPL')) {
118
120
  reason_codes.push('ESCALATED_IN_IMPL');
119
121
  }
120
122
  } else {
@@ -38,6 +38,7 @@ export function assess({
38
38
 
39
39
  // If requirement is empty or for spec stage, load proposal.md and design.md from change dir
40
40
  let effectiveReq = requirement || '';
41
+ let agentContext = null;
41
42
  if (repoRoot && changeId) {
42
43
  try {
43
44
  const cdir = changeDir(repoRoot, changeId);
@@ -46,13 +47,21 @@ export function assess({
46
47
  const propText = fs.readFileSync(propPath, 'utf8');
47
48
  effectiveReq = `${effectiveReq}\n${propText}`.trim();
48
49
  }
50
+
51
+ // Check if change contains agent assessment context (.agent-assess.json or .openspec.yaml assessment)
52
+ const agentCtxPath = path.join(cdir, '.agent-assess.json');
53
+ if (fs.existsSync(agentCtxPath)) {
54
+ try {
55
+ agentContext = JSON.parse(fs.readFileSync(agentCtxPath, 'utf8'));
56
+ } catch { /* ignore parse error */ }
57
+ }
49
58
  } catch { /* ignore read failure */ }
50
59
  }
51
60
 
52
61
  // 1. Evaluate Three Risk Vectors
53
- const v1 = evaluateV1Intent({ requirement: effectiveReq, changedFiles, changeType });
62
+ const v1 = evaluateV1Intent({ requirement: effectiveReq, changedFiles, changeType, agentContext });
54
63
  const v2 = evaluateV2Security({ requirement: effectiveReq, changedFiles, repoRoot });
55
- const v3 = evaluateV3Topology({ requirement: effectiveReq, changedFiles, repoRoot });
64
+ const v3 = evaluateV3Topology({ requirement: effectiveReq, changedFiles, repoRoot, changeId });
56
65
 
57
66
  // Inferred or provided Change Type
58
67
  const effectiveType = changeType || v1.inferredType || 'change';
@@ -101,6 +110,7 @@ export function assess({
101
110
  v1_intent: {
102
111
  level: v1.level,
103
112
  confidence: v1.confidence,
113
+ evaluator_mode: v1.evaluator_mode || 'heuristic_seed',
104
114
  evidence: v1.evidence,
105
115
  unresolved: v1.unresolved,
106
116
  mandatory_human_review: v1.mandatory_human_review,
@@ -161,7 +171,7 @@ export function assess({
161
171
  confidence: 'low'
162
172
  },
163
173
  vectors: {
164
- v1_intent: { level: 'L2', confidence: 'low', evidence: [], unresolved: [err.message], mandatory_human_review: true, no_signal: false },
174
+ v1_intent: { level: 'L2', confidence: 'low', evaluator_mode: 'heuristic_seed', evidence: [], unresolved: [err.message], mandatory_human_review: true, no_signal: false },
165
175
  v2_security: { level: 'L2', confidence: 'low', evidence: [], unresolved: [err.message], mandatory_human_review: true, no_signal: false },
166
176
  v3_topology: { level: 'L2', confidence: 'low', evidence: [], unresolved: [err.message], mandatory_human_review: true, no_signal: false }
167
177
  },
@@ -1,5 +1,5 @@
1
1
  export const HARNESS_RULES_VERSION = '2026.10.0';
2
- export const ENGINE_VERSION = '1.4.0';
2
+ export const ENGINE_VERSION = '1.5.0';
3
3
 
4
4
  export const RISK_LEVELS = {
5
5
  L0: 'L0',
@@ -181,6 +181,11 @@ export const TEST_AND_DOC_PATTERNS = [
181
181
  /(^|\/)assets\/(?:images|media|icons|fonts)\//i
182
182
  ];
183
183
 
184
+ export function isChangeMetadataFile(filePath = '') {
185
+ const norm = String(filePath).replace(/\\/g, '/');
186
+ return /(^|\/)openspec\/changes\/[^/]+\//i.test(norm);
187
+ }
188
+
184
189
  export function isTestOrDocFile(filePath = '') {
185
190
  const norm = String(filePath).replace(/\\/g, '/');
186
191
  if (
@@ -84,6 +84,11 @@ export function validateRecordSchema(record) {
84
84
  errors.push('status defaulted requires non-null defaulted_cause');
85
85
  }
86
86
 
87
+ const evalMode = record.vectors?.v1_intent?.evaluator_mode;
88
+ if (evalMode !== undefined && !['agent_native', 'llm_classifier', 'heuristic_seed'].includes(evalMode)) {
89
+ errors.push(`Invalid v1_intent.evaluator_mode: ${evalMode}`);
90
+ }
91
+
87
92
  if (record.hash && computeRecordHash(record) !== record.hash) {
88
93
  errors.push(`Hash mismatch: computed ${computeRecordHash(record)} vs declared ${record.hash}`);
89
94
  }
@@ -115,7 +120,7 @@ export function validateChainInvariants(records = []) {
115
120
  errors.push(`Record at index ${i} has seq ${rec.seq}, expected ${expectedSeq}`);
116
121
  }
117
122
 
118
- // Cryptographic content hash integrity (P1-3)
123
+ // SHA-256 content hash chain integrity (P1-3)
119
124
  const computed = computeRecordHash(rec);
120
125
  if (rec.hash && computed !== rec.hash) {
121
126
  errors.push(`Record ${rec.seq} hash mismatch: computed ${computed} vs declared ${rec.hash}`);