diff --git a/CHANGELOG.md b/CHANGELOG.md index c75037925..46dc6af55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## [2.2.2] - 2026-07-06 + +Move `unit-test-instructions` production from `build-and-test` to `code-generation` so the per-unit subagent generating code is guided by the same test instructions file that `build-and-test` later executes. Eliminates the duplication where test guidance was produced after code generation had already completed. + +* `unit-test-instructions` is now produced per-unit by `code-generation` (new Step 4) and consumed by `build-and-test` — previously `build-and-test` both produced and consumed it, creating it too late to guide the code-generation subagent. +* `build-and-test.produces[]` no longer includes `unit-test-instructions`; `build-and-test.consumes[]` now lists it as a required input from code-generation. +* The code-generation subagent delegation prompt now includes `unit-test-instructions.md` alongside `code-generation-plan.md`. + ## [2.2.1] - 2026-07-04 Stops help requests from accidentally creating intents. `/aidlc intent help` was parsed as "switch to an intent named help"; the failed switch died with an error inviting the agent to "describe what to build to start a new one", which a conductor mid-task read as an instruction and birthed an unwanted intent. Bare `/aidlc help` and `/aidlc -h` were worse: they fell into the freeform-description funnel and offered to birth an intent literally named "help" (or silently advanced the active stage). All help-shaped inputs now route to the help text. **Upgrade:** re-copy your `dist//` shell into the project. diff --git a/README.md b/README.md index 8330e9744..2473f733c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A native implementation of the **AI-DLC methodology** (AI-Driven Development Lif The methodology lives once, in a harness-neutral `core/`; each harness adds a thin surface that decides how it shows up on that harness. So you edit the methodology in one place, and every harness distribution is generated from it — no harness gets special treatment. (See [Repository layout](#repository-layout) for how the pieces fit together.) -![version](https://img.shields.io/badge/version-2.2.1-blue) +![version](https://img.shields.io/badge/version-2.2.2-blue) ![license](https://img.shields.io/badge/license-MIT--0-green) ![Kiro IDE](https://img.shields.io/badge/harness-Kiro%20IDE-orange) ![Kiro CLI](https://img.shields.io/badge/harness-Kiro%20CLI-orange) diff --git a/core/aidlc-common/stages/construction/build-and-test.md b/core/aidlc-common/stages/construction/build-and-test.md index 5b480de25..5c8e5b473 100644 --- a/core/aidlc-common/stages/construction/build-and-test.md +++ b/core/aidlc-common/stages/construction/build-and-test.md @@ -9,7 +9,6 @@ support_agents: mode: inline produces: - build-instructions - - unit-test-instructions - integration-test-instructions - performance-test-instructions - security-test-instructions @@ -18,6 +17,8 @@ produces: consumes: - artifact: code-generation-plan required: true + - artifact: unit-test-instructions + required: true - artifact: code-summary required: true requires_stage: @@ -36,7 +37,7 @@ scopes: - security-patch - workshop inputs: ALL code generation outputs across all units -outputs: build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) +outputs: build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) --- # Build and Test @@ -51,7 +52,7 @@ Load aidlc-quality-agent (lead) persona from `agents/aidlc-quality-agent.md` and ### Step 2: Analyze Testing Requirements -Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. +Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md` and per-unit test instructions from `/construction/*/code-generation/unit-test-instructions.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. ### Step 3: Generate Build Instructions @@ -64,17 +65,14 @@ Create `/construction/build-and-test/build-instructions.md`: ### Step 4-8: Generate Test Instructions (Strategy-Aware) -Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level: +Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level. -**Minimal strategy** — generate ONLY: -- `unit-test-instructions.md`: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. Skip all other test types. +**Minimal strategy** — no additional test instruction files are generated (unit tests are already covered per-unit by code-generation). **Standard strategy** — generate: -- `unit-test-instructions.md`: 5-8 tests per component, key behavior coverage - `integration-test-instructions.md`: Key boundary tests, cross-unit interaction **Comprehensive strategy** — generate all applicable: -- `unit-test-instructions.md`: 10-15 tests per component, thorough coverage - `integration-test-instructions.md`: Cross-unit interaction, external dependency handling - `performance-test-instructions.md` (IF NFR performance requirements exist): Load testing, benchmarks, regression detection - `security-test-instructions.md` (IF NFR security requirements exist): SAST/DAST, auth testing, injection testing @@ -104,7 +102,7 @@ Create `/construction/build-and-test/build-and-test-summary.md`: Attempt to execute the build and test commands documented in the instruction files: 1. **Build**: Run the build commands from `build-instructions.md` via Bash. Capture output. -2. **Unit tests**: Run the unit test command from `unit-test-instructions.md` via Bash. Capture pass/fail counts. +2. **Unit tests**: Run the unit test commands from the per-unit `unit-test-instructions.md` files (under `/construction/*/code-generation/`) via Bash. Capture pass/fail counts. 3. **Integration tests** (if applicable): Run integration test commands. Capture results. 4. **Report results**: Create or update `/construction/build-and-test/test-results.md` with: - Build status (success/failure + output) @@ -154,7 +152,8 @@ The imported sensors check those outputs: - **`required-sections`** verifies each instruction file contains the registry default (≥2 H2 headings). - **`upstream-coverage`** verifies the prose references the upstream - artefacts this stage consumes (`code-generation-plan`, `code-summary`). + artefacts this stage consumes (`code-generation-plan`, `unit-test-instructions`, + `code-summary`). - **`type-check`** runs against any TypeScript/TSX code touched as part of test generation (matches `**/*.{ts,tsx}`). diff --git a/core/aidlc-common/stages/construction/code-generation.md b/core/aidlc-common/stages/construction/code-generation.md index ec253d796..77b449324 100644 --- a/core/aidlc-common/stages/construction/code-generation.md +++ b/core/aidlc-common/stages/construction/code-generation.md @@ -12,6 +12,7 @@ for_each: unit-of-work workspace_requires: true produces: - code-generation-plan + - unit-test-instructions - code-summary consumes: - artifact: business-logic-model @@ -49,7 +50,7 @@ scopes: - security-patch - workshop inputs: ALL prior design artifacts for this unit -outputs: application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) +outputs: application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) --- # Code Generation @@ -133,7 +134,24 @@ Present a structured question to get plan approval before proceeding to generati - "Approve Plan" — proceed to code generation - "Request Changes" — revise the plan -### Step 4: PART 2 — Generation +### Step 4: Generate Unit Test Instructions + +Create `/construction/{unit-name}/code-generation/unit-test-instructions.md` based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + +- **Minimal strategy**: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. +- **Standard strategy**: 5-8 tests per component, key behavior coverage +- **Comprehensive strategy**: 10-15 tests per component, thorough coverage + +Include: +- Test framework setup and configuration +- How to run unit tests (commands, flags, filters) +- Expected coverage targets +- Mocking/stubbing guidance +- Test data management + +This file guides the subagent during code generation and is later consumed by build-and-test for execution. + +### Step 5: PART 2 — Generation Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -146,12 +164,13 @@ Include in the delegation prompt: - Design artifacts for the CURRENT UNIT ONLY (not all units) - A 1-2 line summary of each inception-phase artifact with its file path (requirements summary, stories summary, app design summary) — the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) +- The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes as completed The subagent generates all code, test files, and configuration artifacts in the workspace. -### Step 5: Generate Code Summary +### Step 6: Generate Code Summary After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -159,11 +178,11 @@ After subagent completes, create `/construction/{unit-name}/code-generat - Test coverage summary - Any deviations from the plan -### Step 6: Update State +### Step 7: Update State Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -### Step 7: Completion +### Step 8: Completion Present completion message and approval gate: @@ -186,7 +205,8 @@ Approval gate: strictly 2-option (Approve / Request Changes). This stage produces TypeScript/JavaScript code in the active Bolt worktree. Generated code lives at the workspace root (NEVER under the record dir); the planning + summary artefacts (`code-generation-plan.md`, -`code-summary.md`) live under `/construction/{unit-name}/code-generation/`. +`unit-test-instructions.md`, `code-summary.md`) live under +`/construction/{unit-name}/code-generation/`. The imported sensors check the code outputs: diff --git a/core/tools/aidlc-version.ts b/core/tools/aidlc-version.ts index 834a24531..9ea354589 100644 --- a/core/tools/aidlc-version.ts +++ b/core/tools/aidlc-version.ts @@ -1,4 +1,4 @@ // Hand-edited single source of truth for the AIDLC framework version. // Bumped in the same commit that adds the matching ## [N.N.N] heading // to CHANGELOG.md. Pinned by tests/unit/t68-version-changelog-sync.test.ts. -export const AIDLC_VERSION = "2.2.1"; +export const AIDLC_VERSION = "2.2.2"; diff --git a/dist/claude/.claude/aidlc-common/stages/construction/build-and-test.md b/dist/claude/.claude/aidlc-common/stages/construction/build-and-test.md index 033e3ad77..6947f62f2 100644 --- a/dist/claude/.claude/aidlc-common/stages/construction/build-and-test.md +++ b/dist/claude/.claude/aidlc-common/stages/construction/build-and-test.md @@ -9,7 +9,6 @@ support_agents: mode: inline produces: - build-instructions - - unit-test-instructions - integration-test-instructions - performance-test-instructions - security-test-instructions @@ -18,6 +17,8 @@ produces: consumes: - artifact: code-generation-plan required: true + - artifact: unit-test-instructions + required: true - artifact: code-summary required: true requires_stage: @@ -36,7 +37,7 @@ scopes: - security-patch - workshop inputs: ALL code generation outputs across all units -outputs: build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) +outputs: build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) --- # Build and Test @@ -51,7 +52,7 @@ Load aidlc-quality-agent (lead) persona from `agents/aidlc-quality-agent.md` and ### Step 2: Analyze Testing Requirements -Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. +Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md` and per-unit test instructions from `/construction/*/code-generation/unit-test-instructions.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. ### Step 3: Generate Build Instructions @@ -64,17 +65,14 @@ Create `/construction/build-and-test/build-instructions.md`: ### Step 4-8: Generate Test Instructions (Strategy-Aware) -Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level: +Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level. -**Minimal strategy** — generate ONLY: -- `unit-test-instructions.md`: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. Skip all other test types. +**Minimal strategy** — no additional test instruction files are generated (unit tests are already covered per-unit by code-generation). **Standard strategy** — generate: -- `unit-test-instructions.md`: 5-8 tests per component, key behavior coverage - `integration-test-instructions.md`: Key boundary tests, cross-unit interaction **Comprehensive strategy** — generate all applicable: -- `unit-test-instructions.md`: 10-15 tests per component, thorough coverage - `integration-test-instructions.md`: Cross-unit interaction, external dependency handling - `performance-test-instructions.md` (IF NFR performance requirements exist): Load testing, benchmarks, regression detection - `security-test-instructions.md` (IF NFR security requirements exist): SAST/DAST, auth testing, injection testing @@ -104,7 +102,7 @@ Create `/construction/build-and-test/build-and-test-summary.md`: Attempt to execute the build and test commands documented in the instruction files: 1. **Build**: Run the build commands from `build-instructions.md` via Bash. Capture output. -2. **Unit tests**: Run the unit test command from `unit-test-instructions.md` via Bash. Capture pass/fail counts. +2. **Unit tests**: Run the unit test commands from the per-unit `unit-test-instructions.md` files (under `/construction/*/code-generation/`) via Bash. Capture pass/fail counts. 3. **Integration tests** (if applicable): Run integration test commands. Capture results. 4. **Report results**: Create or update `/construction/build-and-test/test-results.md` with: - Build status (success/failure + output) @@ -154,7 +152,8 @@ The imported sensors check those outputs: - **`required-sections`** verifies each instruction file contains the registry default (≥2 H2 headings). - **`upstream-coverage`** verifies the prose references the upstream - artefacts this stage consumes (`code-generation-plan`, `code-summary`). + artefacts this stage consumes (`code-generation-plan`, `unit-test-instructions`, + `code-summary`). - **`type-check`** runs against any TypeScript/TSX code touched as part of test generation (matches `**/*.{ts,tsx}`). diff --git a/dist/claude/.claude/aidlc-common/stages/construction/code-generation.md b/dist/claude/.claude/aidlc-common/stages/construction/code-generation.md index 23256859f..aec9f4646 100644 --- a/dist/claude/.claude/aidlc-common/stages/construction/code-generation.md +++ b/dist/claude/.claude/aidlc-common/stages/construction/code-generation.md @@ -12,6 +12,7 @@ for_each: unit-of-work workspace_requires: true produces: - code-generation-plan + - unit-test-instructions - code-summary consumes: - artifact: business-logic-model @@ -49,7 +50,7 @@ scopes: - security-patch - workshop inputs: ALL prior design artifacts for this unit -outputs: application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) +outputs: application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) --- # Code Generation @@ -133,7 +134,24 @@ Present a structured question to get plan approval before proceeding to generati - "Approve Plan" — proceed to code generation - "Request Changes" — revise the plan -### Step 4: PART 2 — Generation +### Step 4: Generate Unit Test Instructions + +Create `/construction/{unit-name}/code-generation/unit-test-instructions.md` based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + +- **Minimal strategy**: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. +- **Standard strategy**: 5-8 tests per component, key behavior coverage +- **Comprehensive strategy**: 10-15 tests per component, thorough coverage + +Include: +- Test framework setup and configuration +- How to run unit tests (commands, flags, filters) +- Expected coverage targets +- Mocking/stubbing guidance +- Test data management + +This file guides the subagent during code generation and is later consumed by build-and-test for execution. + +### Step 5: PART 2 — Generation Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -146,12 +164,13 @@ Include in the delegation prompt: - Design artifacts for the CURRENT UNIT ONLY (not all units) - A 1-2 line summary of each inception-phase artifact with its file path (requirements summary, stories summary, app design summary) — the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) +- The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes as completed The subagent generates all code, test files, and configuration artifacts in the workspace. -### Step 5: Generate Code Summary +### Step 6: Generate Code Summary After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -159,11 +178,11 @@ After subagent completes, create `/construction/{unit-name}/code-generat - Test coverage summary - Any deviations from the plan -### Step 6: Update State +### Step 7: Update State Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -### Step 7: Completion +### Step 8: Completion Present completion message and approval gate: @@ -186,7 +205,8 @@ Approval gate: strictly 2-option (Approve / Request Changes). This stage produces TypeScript/JavaScript code in the active Bolt worktree. Generated code lives at the workspace root (NEVER under the record dir); the planning + summary artefacts (`code-generation-plan.md`, -`code-summary.md`) live under `/construction/{unit-name}/code-generation/`. +`unit-test-instructions.md`, `code-summary.md`) live under +`/construction/{unit-name}/code-generation/`. The imported sensors check the code outputs: diff --git a/dist/claude/.claude/tools/aidlc-version.ts b/dist/claude/.claude/tools/aidlc-version.ts index 834a24531..9ea354589 100644 --- a/dist/claude/.claude/tools/aidlc-version.ts +++ b/dist/claude/.claude/tools/aidlc-version.ts @@ -1,4 +1,4 @@ // Hand-edited single source of truth for the AIDLC framework version. // Bumped in the same commit that adds the matching ## [N.N.N] heading // to CHANGELOG.md. Pinned by tests/unit/t68-version-changelog-sync.test.ts. -export const AIDLC_VERSION = "2.2.1"; +export const AIDLC_VERSION = "2.2.2"; diff --git a/dist/claude/.claude/tools/data/stage-graph.json b/dist/claude/.claude/tools/data/stage-graph.json index 915e6b0cd..3c98392e0 100644 --- a/dist/claude/.claude/tools/data/stage-graph.json +++ b/dist/claude/.claude/tools/data/stage-graph.json @@ -1853,6 +1853,7 @@ "workspace_requires": true, "produces": [ "code-generation-plan", + "unit-test-instructions", "code-summary" ], "consumes": [ @@ -1913,7 +1914,7 @@ "reviewer": "aidlc-architecture-reviewer-agent", "reviewer_max_iterations": 2, "inputs": "ALL prior design artifacts for this unit", - "outputs": "application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", + "outputs": "application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", @@ -1959,7 +1960,6 @@ "mode": "inline", "produces": [ "build-instructions", - "unit-test-instructions", "integration-test-instructions", "performance-test-instructions", "security-test-instructions", @@ -1971,6 +1971,10 @@ "artifact": "code-generation-plan", "required": true }, + { + "artifact": "unit-test-instructions", + "required": true + }, { "artifact": "code-summary", "required": true @@ -1995,7 +1999,7 @@ "workshop" ], "inputs": "ALL code generation outputs across all units", - "outputs": "build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", + "outputs": "build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", diff --git a/dist/codex/.codex/aidlc-common/stages/construction/build-and-test.md b/dist/codex/.codex/aidlc-common/stages/construction/build-and-test.md index 3f8d1c66a..fccb8724d 100644 --- a/dist/codex/.codex/aidlc-common/stages/construction/build-and-test.md +++ b/dist/codex/.codex/aidlc-common/stages/construction/build-and-test.md @@ -9,7 +9,6 @@ support_agents: mode: inline produces: - build-instructions - - unit-test-instructions - integration-test-instructions - performance-test-instructions - security-test-instructions @@ -18,6 +17,8 @@ produces: consumes: - artifact: code-generation-plan required: true + - artifact: unit-test-instructions + required: true - artifact: code-summary required: true requires_stage: @@ -36,7 +37,7 @@ scopes: - security-patch - workshop inputs: ALL code generation outputs across all units -outputs: build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) +outputs: build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) --- # Build and Test @@ -51,7 +52,7 @@ Load aidlc-quality-agent (lead) persona from `agents/aidlc-quality-agent.md` and ### Step 2: Analyze Testing Requirements -Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. +Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md` and per-unit test instructions from `/construction/*/code-generation/unit-test-instructions.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. ### Step 3: Generate Build Instructions @@ -64,17 +65,14 @@ Create `/construction/build-and-test/build-instructions.md`: ### Step 4-8: Generate Test Instructions (Strategy-Aware) -Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level: +Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level. -**Minimal strategy** — generate ONLY: -- `unit-test-instructions.md`: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. Skip all other test types. +**Minimal strategy** — no additional test instruction files are generated (unit tests are already covered per-unit by code-generation). **Standard strategy** — generate: -- `unit-test-instructions.md`: 5-8 tests per component, key behavior coverage - `integration-test-instructions.md`: Key boundary tests, cross-unit interaction **Comprehensive strategy** — generate all applicable: -- `unit-test-instructions.md`: 10-15 tests per component, thorough coverage - `integration-test-instructions.md`: Cross-unit interaction, external dependency handling - `performance-test-instructions.md` (IF NFR performance requirements exist): Load testing, benchmarks, regression detection - `security-test-instructions.md` (IF NFR security requirements exist): SAST/DAST, auth testing, injection testing @@ -104,7 +102,7 @@ Create `/construction/build-and-test/build-and-test-summary.md`: Attempt to execute the build and test commands documented in the instruction files: 1. **Build**: Run the build commands from `build-instructions.md` via Bash. Capture output. -2. **Unit tests**: Run the unit test command from `unit-test-instructions.md` via Bash. Capture pass/fail counts. +2. **Unit tests**: Run the unit test commands from the per-unit `unit-test-instructions.md` files (under `/construction/*/code-generation/`) via Bash. Capture pass/fail counts. 3. **Integration tests** (if applicable): Run integration test commands. Capture results. 4. **Report results**: Create or update `/construction/build-and-test/test-results.md` with: - Build status (success/failure + output) @@ -154,7 +152,8 @@ The imported sensors check those outputs: - **`required-sections`** verifies each instruction file contains the registry default (≥2 H2 headings). - **`upstream-coverage`** verifies the prose references the upstream - artefacts this stage consumes (`code-generation-plan`, `code-summary`). + artefacts this stage consumes (`code-generation-plan`, `unit-test-instructions`, + `code-summary`). - **`type-check`** runs against any TypeScript/TSX code touched as part of test generation (matches `**/*.{ts,tsx}`). diff --git a/dist/codex/.codex/aidlc-common/stages/construction/code-generation.md b/dist/codex/.codex/aidlc-common/stages/construction/code-generation.md index 80338c225..a3760a8f3 100644 --- a/dist/codex/.codex/aidlc-common/stages/construction/code-generation.md +++ b/dist/codex/.codex/aidlc-common/stages/construction/code-generation.md @@ -12,6 +12,7 @@ for_each: unit-of-work workspace_requires: true produces: - code-generation-plan + - unit-test-instructions - code-summary consumes: - artifact: business-logic-model @@ -49,7 +50,7 @@ scopes: - security-patch - workshop inputs: ALL prior design artifacts for this unit -outputs: application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) +outputs: application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) --- # Code Generation @@ -133,7 +134,24 @@ Present a structured question to get plan approval before proceeding to generati - "Approve Plan" — proceed to code generation - "Request Changes" — revise the plan -### Step 4: PART 2 — Generation +### Step 4: Generate Unit Test Instructions + +Create `/construction/{unit-name}/code-generation/unit-test-instructions.md` based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + +- **Minimal strategy**: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. +- **Standard strategy**: 5-8 tests per component, key behavior coverage +- **Comprehensive strategy**: 10-15 tests per component, thorough coverage + +Include: +- Test framework setup and configuration +- How to run unit tests (commands, flags, filters) +- Expected coverage targets +- Mocking/stubbing guidance +- Test data management + +This file guides the subagent during code generation and is later consumed by build-and-test for execution. + +### Step 5: PART 2 — Generation Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -146,12 +164,13 @@ Include in the delegation prompt: - Design artifacts for the CURRENT UNIT ONLY (not all units) - A 1-2 line summary of each inception-phase artifact with its file path (requirements summary, stories summary, app design summary) — the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) +- The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes as completed The subagent generates all code, test files, and configuration artifacts in the workspace. -### Step 5: Generate Code Summary +### Step 6: Generate Code Summary After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -159,11 +178,11 @@ After subagent completes, create `/construction/{unit-name}/code-generat - Test coverage summary - Any deviations from the plan -### Step 6: Update State +### Step 7: Update State Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -### Step 7: Completion +### Step 8: Completion Present completion message and approval gate: @@ -186,7 +205,8 @@ Approval gate: strictly 2-option (Approve / Request Changes). This stage produces TypeScript/JavaScript code in the active Bolt worktree. Generated code lives at the workspace root (NEVER under the record dir); the planning + summary artefacts (`code-generation-plan.md`, -`code-summary.md`) live under `/construction/{unit-name}/code-generation/`. +`unit-test-instructions.md`, `code-summary.md`) live under +`/construction/{unit-name}/code-generation/`. The imported sensors check the code outputs: diff --git a/dist/codex/.codex/tools/aidlc-version.ts b/dist/codex/.codex/tools/aidlc-version.ts index 834a24531..9ea354589 100644 --- a/dist/codex/.codex/tools/aidlc-version.ts +++ b/dist/codex/.codex/tools/aidlc-version.ts @@ -1,4 +1,4 @@ // Hand-edited single source of truth for the AIDLC framework version. // Bumped in the same commit that adds the matching ## [N.N.N] heading // to CHANGELOG.md. Pinned by tests/unit/t68-version-changelog-sync.test.ts. -export const AIDLC_VERSION = "2.2.1"; +export const AIDLC_VERSION = "2.2.2"; diff --git a/dist/codex/.codex/tools/data/stage-graph.json b/dist/codex/.codex/tools/data/stage-graph.json index 1040cf96a..45bc36ea6 100644 --- a/dist/codex/.codex/tools/data/stage-graph.json +++ b/dist/codex/.codex/tools/data/stage-graph.json @@ -1853,6 +1853,7 @@ "workspace_requires": true, "produces": [ "code-generation-plan", + "unit-test-instructions", "code-summary" ], "consumes": [ @@ -1913,7 +1914,7 @@ "reviewer": "aidlc-architecture-reviewer-agent", "reviewer_max_iterations": 2, "inputs": "ALL prior design artifacts for this unit", - "outputs": "application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", + "outputs": "application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", @@ -1959,7 +1960,6 @@ "mode": "inline", "produces": [ "build-instructions", - "unit-test-instructions", "integration-test-instructions", "performance-test-instructions", "security-test-instructions", @@ -1971,6 +1971,10 @@ "artifact": "code-generation-plan", "required": true }, + { + "artifact": "unit-test-instructions", + "required": true + }, { "artifact": "code-summary", "required": true @@ -1995,7 +1999,7 @@ "workshop" ], "inputs": "ALL code generation outputs across all units", - "outputs": "build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", + "outputs": "build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", diff --git a/dist/kiro-ide/.kiro/aidlc-common/stages/construction/build-and-test.md b/dist/kiro-ide/.kiro/aidlc-common/stages/construction/build-and-test.md index 48592056d..1e2079307 100644 --- a/dist/kiro-ide/.kiro/aidlc-common/stages/construction/build-and-test.md +++ b/dist/kiro-ide/.kiro/aidlc-common/stages/construction/build-and-test.md @@ -9,7 +9,6 @@ support_agents: mode: inline produces: - build-instructions - - unit-test-instructions - integration-test-instructions - performance-test-instructions - security-test-instructions @@ -18,6 +17,8 @@ produces: consumes: - artifact: code-generation-plan required: true + - artifact: unit-test-instructions + required: true - artifact: code-summary required: true requires_stage: @@ -36,7 +37,7 @@ scopes: - security-patch - workshop inputs: ALL code generation outputs across all units -outputs: build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) +outputs: build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) --- # Build and Test @@ -51,7 +52,7 @@ Load aidlc-quality-agent (lead) persona from `agents/aidlc-quality-agent.md` and ### Step 2: Analyze Testing Requirements -Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. +Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md` and per-unit test instructions from `/construction/*/code-generation/unit-test-instructions.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. ### Step 3: Generate Build Instructions @@ -64,17 +65,14 @@ Create `/construction/build-and-test/build-instructions.md`: ### Step 4-8: Generate Test Instructions (Strategy-Aware) -Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level: +Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level. -**Minimal strategy** — generate ONLY: -- `unit-test-instructions.md`: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. Skip all other test types. +**Minimal strategy** — no additional test instruction files are generated (unit tests are already covered per-unit by code-generation). **Standard strategy** — generate: -- `unit-test-instructions.md`: 5-8 tests per component, key behavior coverage - `integration-test-instructions.md`: Key boundary tests, cross-unit interaction **Comprehensive strategy** — generate all applicable: -- `unit-test-instructions.md`: 10-15 tests per component, thorough coverage - `integration-test-instructions.md`: Cross-unit interaction, external dependency handling - `performance-test-instructions.md` (IF NFR performance requirements exist): Load testing, benchmarks, regression detection - `security-test-instructions.md` (IF NFR security requirements exist): SAST/DAST, auth testing, injection testing @@ -104,7 +102,7 @@ Create `/construction/build-and-test/build-and-test-summary.md`: Attempt to execute the build and test commands documented in the instruction files: 1. **Build**: Run the build commands from `build-instructions.md` via Bash. Capture output. -2. **Unit tests**: Run the unit test command from `unit-test-instructions.md` via Bash. Capture pass/fail counts. +2. **Unit tests**: Run the unit test commands from the per-unit `unit-test-instructions.md` files (under `/construction/*/code-generation/`) via Bash. Capture pass/fail counts. 3. **Integration tests** (if applicable): Run integration test commands. Capture results. 4. **Report results**: Create or update `/construction/build-and-test/test-results.md` with: - Build status (success/failure + output) @@ -154,7 +152,8 @@ The imported sensors check those outputs: - **`required-sections`** verifies each instruction file contains the registry default (≥2 H2 headings). - **`upstream-coverage`** verifies the prose references the upstream - artefacts this stage consumes (`code-generation-plan`, `code-summary`). + artefacts this stage consumes (`code-generation-plan`, `unit-test-instructions`, + `code-summary`). - **`type-check`** runs against any TypeScript/TSX code touched as part of test generation (matches `**/*.{ts,tsx}`). diff --git a/dist/kiro-ide/.kiro/aidlc-common/stages/construction/code-generation.md b/dist/kiro-ide/.kiro/aidlc-common/stages/construction/code-generation.md index 24424e530..70822cc67 100644 --- a/dist/kiro-ide/.kiro/aidlc-common/stages/construction/code-generation.md +++ b/dist/kiro-ide/.kiro/aidlc-common/stages/construction/code-generation.md @@ -12,6 +12,7 @@ for_each: unit-of-work workspace_requires: true produces: - code-generation-plan + - unit-test-instructions - code-summary consumes: - artifact: business-logic-model @@ -49,7 +50,7 @@ scopes: - security-patch - workshop inputs: ALL prior design artifacts for this unit -outputs: application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) +outputs: application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) --- # Code Generation @@ -133,7 +134,24 @@ Present a structured question to get plan approval before proceeding to generati - "Approve Plan" — proceed to code generation - "Request Changes" — revise the plan -### Step 4: PART 2 — Generation +### Step 4: Generate Unit Test Instructions + +Create `/construction/{unit-name}/code-generation/unit-test-instructions.md` based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + +- **Minimal strategy**: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. +- **Standard strategy**: 5-8 tests per component, key behavior coverage +- **Comprehensive strategy**: 10-15 tests per component, thorough coverage + +Include: +- Test framework setup and configuration +- How to run unit tests (commands, flags, filters) +- Expected coverage targets +- Mocking/stubbing guidance +- Test data management + +This file guides the subagent during code generation and is later consumed by build-and-test for execution. + +### Step 5: PART 2 — Generation Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -146,12 +164,13 @@ Include in the delegation prompt: - Design artifacts for the CURRENT UNIT ONLY (not all units) - A 1-2 line summary of each inception-phase artifact with its file path (requirements summary, stories summary, app design summary) — the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) +- The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes as completed The subagent generates all code, test files, and configuration artifacts in the workspace. -### Step 5: Generate Code Summary +### Step 6: Generate Code Summary After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -159,11 +178,11 @@ After subagent completes, create `/construction/{unit-name}/code-generat - Test coverage summary - Any deviations from the plan -### Step 6: Update State +### Step 7: Update State Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -### Step 7: Completion +### Step 8: Completion Present completion message and approval gate: @@ -186,7 +205,8 @@ Approval gate: strictly 2-option (Approve / Request Changes). This stage produces TypeScript/JavaScript code in the active Bolt worktree. Generated code lives at the workspace root (NEVER under the record dir); the planning + summary artefacts (`code-generation-plan.md`, -`code-summary.md`) live under `/construction/{unit-name}/code-generation/`. +`unit-test-instructions.md`, `code-summary.md`) live under +`/construction/{unit-name}/code-generation/`. The imported sensors check the code outputs: diff --git a/dist/kiro-ide/.kiro/tools/aidlc-version.ts b/dist/kiro-ide/.kiro/tools/aidlc-version.ts index 834a24531..9ea354589 100644 --- a/dist/kiro-ide/.kiro/tools/aidlc-version.ts +++ b/dist/kiro-ide/.kiro/tools/aidlc-version.ts @@ -1,4 +1,4 @@ // Hand-edited single source of truth for the AIDLC framework version. // Bumped in the same commit that adds the matching ## [N.N.N] heading // to CHANGELOG.md. Pinned by tests/unit/t68-version-changelog-sync.test.ts. -export const AIDLC_VERSION = "2.2.1"; +export const AIDLC_VERSION = "2.2.2"; diff --git a/dist/kiro-ide/.kiro/tools/data/stage-graph.json b/dist/kiro-ide/.kiro/tools/data/stage-graph.json index 3cf324185..2262a21fb 100644 --- a/dist/kiro-ide/.kiro/tools/data/stage-graph.json +++ b/dist/kiro-ide/.kiro/tools/data/stage-graph.json @@ -1853,6 +1853,7 @@ "workspace_requires": true, "produces": [ "code-generation-plan", + "unit-test-instructions", "code-summary" ], "consumes": [ @@ -1913,7 +1914,7 @@ "reviewer": "aidlc-architecture-reviewer-agent", "reviewer_max_iterations": 2, "inputs": "ALL prior design artifacts for this unit", - "outputs": "application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", + "outputs": "application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", @@ -1959,7 +1960,6 @@ "mode": "inline", "produces": [ "build-instructions", - "unit-test-instructions", "integration-test-instructions", "performance-test-instructions", "security-test-instructions", @@ -1971,6 +1971,10 @@ "artifact": "code-generation-plan", "required": true }, + { + "artifact": "unit-test-instructions", + "required": true + }, { "artifact": "code-summary", "required": true @@ -1995,7 +1999,7 @@ "workshop" ], "inputs": "ALL code generation outputs across all units", - "outputs": "build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", + "outputs": "build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", diff --git a/dist/kiro/.kiro/aidlc-common/stages/construction/build-and-test.md b/dist/kiro/.kiro/aidlc-common/stages/construction/build-and-test.md index 48592056d..1e2079307 100644 --- a/dist/kiro/.kiro/aidlc-common/stages/construction/build-and-test.md +++ b/dist/kiro/.kiro/aidlc-common/stages/construction/build-and-test.md @@ -9,7 +9,6 @@ support_agents: mode: inline produces: - build-instructions - - unit-test-instructions - integration-test-instructions - performance-test-instructions - security-test-instructions @@ -18,6 +17,8 @@ produces: consumes: - artifact: code-generation-plan required: true + - artifact: unit-test-instructions + required: true - artifact: code-summary required: true requires_stage: @@ -36,7 +37,7 @@ scopes: - security-patch - workshop inputs: ALL code generation outputs across all units -outputs: build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) +outputs: build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved) --- # Build and Test @@ -51,7 +52,7 @@ Load aidlc-quality-agent (lead) persona from `agents/aidlc-quality-agent.md` and ### Step 2: Analyze Testing Requirements -Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. +Read code generation outputs across all units from `/construction/*/code-generation/code-summary.md` and per-unit test instructions from `/construction/*/code-generation/unit-test-instructions.md`. Review NFR requirements across units (if they exist) to identify performance and security testing needs. Catalog all test types required. ### Step 3: Generate Build Instructions @@ -64,17 +65,14 @@ Create `/construction/build-and-test/build-instructions.md`: ### Step 4-8: Generate Test Instructions (Strategy-Aware) -Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level: +Consult the active test strategy from `aidlc-state.md` → `**Test Strategy**` (see stage-protocol.md §8 "Test Strategy"). Generate test instruction files based on the strategy level. -**Minimal strategy** — generate ONLY: -- `unit-test-instructions.md`: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. Skip all other test types. +**Minimal strategy** — no additional test instruction files are generated (unit tests are already covered per-unit by code-generation). **Standard strategy** — generate: -- `unit-test-instructions.md`: 5-8 tests per component, key behavior coverage - `integration-test-instructions.md`: Key boundary tests, cross-unit interaction **Comprehensive strategy** — generate all applicable: -- `unit-test-instructions.md`: 10-15 tests per component, thorough coverage - `integration-test-instructions.md`: Cross-unit interaction, external dependency handling - `performance-test-instructions.md` (IF NFR performance requirements exist): Load testing, benchmarks, regression detection - `security-test-instructions.md` (IF NFR security requirements exist): SAST/DAST, auth testing, injection testing @@ -104,7 +102,7 @@ Create `/construction/build-and-test/build-and-test-summary.md`: Attempt to execute the build and test commands documented in the instruction files: 1. **Build**: Run the build commands from `build-instructions.md` via Bash. Capture output. -2. **Unit tests**: Run the unit test command from `unit-test-instructions.md` via Bash. Capture pass/fail counts. +2. **Unit tests**: Run the unit test commands from the per-unit `unit-test-instructions.md` files (under `/construction/*/code-generation/`) via Bash. Capture pass/fail counts. 3. **Integration tests** (if applicable): Run integration test commands. Capture results. 4. **Report results**: Create or update `/construction/build-and-test/test-results.md` with: - Build status (success/failure + output) @@ -154,7 +152,8 @@ The imported sensors check those outputs: - **`required-sections`** verifies each instruction file contains the registry default (≥2 H2 headings). - **`upstream-coverage`** verifies the prose references the upstream - artefacts this stage consumes (`code-generation-plan`, `code-summary`). + artefacts this stage consumes (`code-generation-plan`, `unit-test-instructions`, + `code-summary`). - **`type-check`** runs against any TypeScript/TSX code touched as part of test generation (matches `**/*.{ts,tsx}`). diff --git a/dist/kiro/.kiro/aidlc-common/stages/construction/code-generation.md b/dist/kiro/.kiro/aidlc-common/stages/construction/code-generation.md index 24424e530..70822cc67 100644 --- a/dist/kiro/.kiro/aidlc-common/stages/construction/code-generation.md +++ b/dist/kiro/.kiro/aidlc-common/stages/construction/code-generation.md @@ -12,6 +12,7 @@ for_each: unit-of-work workspace_requires: true produces: - code-generation-plan + - unit-test-instructions - code-summary consumes: - artifact: business-logic-model @@ -49,7 +50,7 @@ scopes: - security-patch - workshop inputs: ALL prior design artifacts for this unit -outputs: application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) +outputs: application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved) --- # Code Generation @@ -133,7 +134,24 @@ Present a structured question to get plan approval before proceeding to generati - "Approve Plan" — proceed to code generation - "Request Changes" — revise the plan -### Step 4: PART 2 — Generation +### Step 4: Generate Unit Test Instructions + +Create `/construction/{unit-name}/code-generation/unit-test-instructions.md` based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + +- **Minimal strategy**: Requirement-driven unit tests (1 test per requirement, happy-path floor per component). ~5-15 tests total. +- **Standard strategy**: 5-8 tests per component, key behavior coverage +- **Comprehensive strategy**: 10-15 tests per component, thorough coverage + +Include: +- Test framework setup and configuration +- How to run unit tests (commands, flags, filters) +- Expected coverage targets +- Mocking/stubbing guidance +- Test data management + +This file guides the subagent during code generation and is later consumed by build-and-test for execution. + +### Step 5: PART 2 — Generation Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -146,12 +164,13 @@ Include in the delegation prompt: - Design artifacts for the CURRENT UNIT ONLY (not all units) - A 1-2 line summary of each inception-phase artifact with its file path (requirements summary, stories summary, app design summary) — the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) +- The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes as completed The subagent generates all code, test files, and configuration artifacts in the workspace. -### Step 5: Generate Code Summary +### Step 6: Generate Code Summary After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -159,11 +178,11 @@ After subagent completes, create `/construction/{unit-name}/code-generat - Test coverage summary - Any deviations from the plan -### Step 6: Update State +### Step 7: Update State Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -### Step 7: Completion +### Step 8: Completion Present completion message and approval gate: @@ -186,7 +205,8 @@ Approval gate: strictly 2-option (Approve / Request Changes). This stage produces TypeScript/JavaScript code in the active Bolt worktree. Generated code lives at the workspace root (NEVER under the record dir); the planning + summary artefacts (`code-generation-plan.md`, -`code-summary.md`) live under `/construction/{unit-name}/code-generation/`. +`unit-test-instructions.md`, `code-summary.md`) live under +`/construction/{unit-name}/code-generation/`. The imported sensors check the code outputs: diff --git a/dist/kiro/.kiro/tools/aidlc-version.ts b/dist/kiro/.kiro/tools/aidlc-version.ts index 834a24531..9ea354589 100644 --- a/dist/kiro/.kiro/tools/aidlc-version.ts +++ b/dist/kiro/.kiro/tools/aidlc-version.ts @@ -1,4 +1,4 @@ // Hand-edited single source of truth for the AIDLC framework version. // Bumped in the same commit that adds the matching ## [N.N.N] heading // to CHANGELOG.md. Pinned by tests/unit/t68-version-changelog-sync.test.ts. -export const AIDLC_VERSION = "2.2.1"; +export const AIDLC_VERSION = "2.2.2"; diff --git a/dist/kiro/.kiro/tools/data/stage-graph.json b/dist/kiro/.kiro/tools/data/stage-graph.json index 3cf324185..2262a21fb 100644 --- a/dist/kiro/.kiro/tools/data/stage-graph.json +++ b/dist/kiro/.kiro/tools/data/stage-graph.json @@ -1853,6 +1853,7 @@ "workspace_requires": true, "produces": [ "code-generation-plan", + "unit-test-instructions", "code-summary" ], "consumes": [ @@ -1913,7 +1914,7 @@ "reviewer": "aidlc-architecture-reviewer-agent", "reviewer_max_iterations": 2, "inputs": "ALL prior design artifacts for this unit", - "outputs": "application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", + "outputs": "application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", @@ -1959,7 +1960,6 @@ "mode": "inline", "produces": [ "build-instructions", - "unit-test-instructions", "integration-test-instructions", "performance-test-instructions", "security-test-instructions", @@ -1971,6 +1971,10 @@ "artifact": "code-generation-plan", "required": true }, + { + "artifact": "unit-test-instructions", + "required": true + }, { "artifact": "code-summary", "required": true @@ -1995,7 +1999,7 @@ "workshop" ], "inputs": "ALL code generation outputs across all units", - "outputs": "build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", + "outputs": "build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", diff --git a/docs/reference/04-stages/construction.md b/docs/reference/04-stages/construction.md index 2532d7549..b5e2c158d 100644 --- a/docs/reference/04-stages/construction.md +++ b/docs/reference/04-stages/construction.md @@ -569,7 +569,7 @@ share infrastructure resources. | support_agents | (none -- focused implementation) | | mode | subagent (Task tool subagent_type: aidlc-developer-agent) | | Inputs | ALL prior design artifacts for this unit | -| Outputs | application code (workspace root) + `/construction/{unit-name}/code-generation/` -- code-generation-plan.md, code-summary.md | +| Outputs | application code (workspace root) + `/construction/{unit-name}/code-generation/` -- code-generation-plan.md, unit-test-instructions.md, code-summary.md | ### Purpose @@ -654,9 +654,22 @@ This stage has a **two-part structure**: planning followed by generation. - "Approve Plan" -- proceed to code generation - "Request Changes" -- revise the plan -#### PART 2 -- Generation (Steps 4-7) +4. **Generate Unit Test Instructions** -- Create + `/construction/{unit-name}/code-generation/unit-test-instructions.md` + based on the active test strategy (stage-protocol.md §8 "Test Strategy"): + - **Minimal**: Requirement-driven unit tests (1 test per requirement, + happy-path floor per component). ~5-15 tests total. + - **Standard**: 5-8 tests per component, key behavior coverage + - **Comprehensive**: 10-15 tests per component, thorough coverage + + Include: test framework setup and configuration, how to run unit tests + (commands, flags, filters), expected coverage targets, mocking/stubbing + guidance, test data management. This file guides the subagent during code + generation and is later consumed by build-and-test for execution. + +#### PART 2 -- Generation (Steps 5-8) -4. **Generate Code** -- Before delegating, display to the user: +5. **Generate Code** -- Before delegating, display to the user: "Generating code for [N] plan steps. This may take several minutes depending on project complexity. I'll show a summary when complete." @@ -672,6 +685,7 @@ This stage has a **two-part structure**: planning followed by generation. (requirements summary, stories summary, app design summary) -- the subagent can Read specific files if it needs full content - The approved code-generation-plan.md (full content) + - The unit-test-instructions.md (full content) - Project workspace details (languages, frameworks, conventions from aidlc-state.md) - Instructions to execute each plan step sequentially and mark checkboxes @@ -682,7 +696,7 @@ This stage has a **two-part structure**: planning followed by generation. full content. The subagent generates all code, test files, and configuration artifacts in the workspace. -5. **Generate Code Summary** -- After subagent completes, create +6. **Generate Code Summary** -- After subagent completes, create `/construction/{unit-name}/code-generation/code-summary.md` documenting: - Files created/modified @@ -690,16 +704,17 @@ This stage has a **two-part structure**: planning followed by generation. - Test coverage summary - Any deviations from the plan -6. **Update State** -- Update `/aidlc-state.md`: mark Code +7. **Update State** -- Update `/aidlc-state.md`: mark Code Generation for {unit-name} as `[x]` completed and update "Current Status". -7. **Completion** -- Present completion message and approval gate. +8. **Completion** -- Present completion message and approval gate. ### Outputs | Artifact | Description | |---------------------------|---------------------------------------------------------------------| | code-generation-plan.md | Detailed plan with checkboxes, story traceability, step sequencing | +| unit-test-instructions.md | Test framework setup, run commands, coverage targets, mocking | | code-summary.md | Files created/modified, decisions, test coverage, plan deviations | | (application code) | All source code, tests, and config written to workspace root | @@ -745,7 +760,7 @@ Strictly 2-option: Approve / Request Changes. | support_agents | aidlc-devsecops-agent | | mode | inline | | Inputs | ALL code generation outputs across all units | -| Outputs | `/construction/build-and-test/` -- build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md, plus conditional test instruction files | +| Outputs | `/construction/build-and-test/` -- build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md, plus conditional test instruction files | ### Purpose @@ -758,6 +773,8 @@ testing expertise. - Code generation outputs across all units from `/construction/*/code-generation/code-summary.md` +- Per-unit test instructions from + `/construction/*/code-generation/unit-test-instructions.md` - NFR requirements across units (if they exist) for performance and security testing needs @@ -778,15 +795,7 @@ testing expertise. - Build verification steps - Troubleshooting common build issues -4. **Generate Unit Test Instructions** -- Create - `/construction/build-and-test/unit-test-instructions.md`: - - Test framework setup and configuration - - How to run unit tests (commands, flags, filters) - - Expected test coverage targets - - Mocking/stubbing guidance - - Test data management - -5. **Generate Integration Test Instructions** -- Create +4. **Generate Integration Test Instructions** -- Create `/construction/build-and-test/integration-test-instructions.md`: - Test environment prerequisites (databases, services, queues) - How to run integration tests @@ -794,7 +803,7 @@ testing expertise. - External dependency handling (stubs, test doubles, sandboxes) - Test data setup and teardown -6. **Generate Performance Test Instructions** (CONDITIONAL) -- IF NFR +5. **Generate Performance Test Instructions** (CONDITIONAL) -- IF NFR performance requirements exist for any unit, create `performance-test-instructions.md`: - Load testing tools and configuration @@ -803,7 +812,7 @@ testing expertise. - Stress and soak test procedures - Performance regression detection -7. **Generate Security Test Instructions** (CONDITIONAL) -- IF NFR security +6. **Generate Security Test Instructions** (CONDITIONAL) -- IF NFR security requirements exist for any unit, create `security-test-instructions.md`: - Security scanning tools (SAST, DAST, dependency audit) @@ -812,7 +821,7 @@ testing expertise. - Compliance verification steps - Vulnerability assessment procedures -8. **Generate Additional Test Types** (CONDITIONAL) -- As applicable based on +7. **Generate Additional Test Types** (CONDITIONAL) -- As applicable based on project architecture, create specifically named files: - **contract-test-instructions.md**: For microservice APIs -- consumer-driven contracts, schema validation, API compatibility @@ -823,7 +832,7 @@ testing expertise. All files go in `/construction/build-and-test/`. -9. **Generate Build and Test Summary** -- Create +8. **Generate Build and Test Summary** -- Create `/construction/build-and-test/build-and-test-summary.md`: - Overall build status and prerequisites - Test type inventory (which test types were generated) @@ -831,13 +840,13 @@ testing expertise. - Readiness assessment (build-ready, test-ready, deployment-ready) - Known limitations or outstanding items -10. **Execute Build and Tests** -- Attempt to execute the build and test +9. **Execute Build and Tests** -- Attempt to execute the build and test commands documented in the instruction files **via Bash**: a. **Build**: Run the build commands from build-instructions.md via Bash. Capture output. - b. **Unit tests**: Run the unit test command from - unit-test-instructions.md via Bash. Capture pass/fail counts. + b. **Unit tests**: Run the unit test commands from the per-unit + unit-test-instructions.md files via Bash. Capture pass/fail counts. c. **Integration tests** (if applicable): Run integration test commands. Capture results. d. **Report results**: Create or update @@ -859,18 +868,17 @@ testing expertise. **On success:** Update the Build and Test Summary with actual results (not just instructions). -11. **Update State** -- Update `/aidlc-state.md`: mark Build and +10. **Update State** -- Update `/aidlc-state.md`: mark Build and Test as `[x]` completed and update "Current Status". Mark CONSTRUCTION phase as complete. -12. **Completion** -- Present completion message and approval gate. +11. **Completion** -- Present completion message and approval gate. ### Outputs | Artifact | Description | Condition | |-----------------------------------|-----------------------------------------------------------------|--------------------| | build-instructions.md | Dependency install, env setup, build commands, troubleshooting | Always | -| unit-test-instructions.md | Test framework setup, run commands, coverage targets, mocking | Always | | integration-test-instructions.md | Prerequisites, cross-unit testing, external deps, data setup | Always | | performance-test-instructions.md | Load testing, NFR scenarios, baselines, stress/soak tests | If NFR perf exists | | security-test-instructions.md | SAST/DAST, auth testing, injection testing, compliance | If NFR sec exists | diff --git a/docs/reference/16-artifact-vocabulary.md b/docs/reference/16-artifact-vocabulary.md index 64239dbc9..228bc0b91 100644 --- a/docs/reference/16-artifact-vocabulary.md +++ b/docs/reference/16-artifact-vocabulary.md @@ -128,9 +128,10 @@ The canonical names are split so the two never collide on the wire: - `build-test-results` — emitted by `build-and-test`. Pairs with sibling names in that stage: `build-instructions`, - `unit-test-instructions`, `integration-test-instructions`, - `performance-test-instructions`, `security-test-instructions`, - `build-and-test-summary`. + `integration-test-instructions`, `performance-test-instructions`, + `security-test-instructions`, `build-and-test-summary`. +- `unit-test-instructions` is produced per-unit by `code-generation` + and consumed by `build-and-test`. - `load-test-results` — emitted by `performance-validation`. Pairs with `load-test-plan` already produced by the same stage. diff --git a/tests/fixtures/designer-export/export.json b/tests/fixtures/designer-export/export.json index 7244872c5..cc178a366 100644 --- a/tests/fixtures/designer-export/export.json +++ b/tests/fixtures/designer-export/export.json @@ -1854,6 +1854,7 @@ "workspace_requires": true, "produces": [ "code-generation-plan", + "unit-test-instructions", "code-summary" ], "consumes": [ @@ -1914,7 +1915,7 @@ "reviewer": "aidlc-architecture-reviewer-agent", "reviewer_max_iterations": 2, "inputs": "ALL prior design artifacts for this unit", - "outputs": "application code + code-generation-plan.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", + "outputs": "application code + code-generation-plan.md, unit-test-instructions.md, code-summary.md (under this stage's per-unit record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", @@ -1960,7 +1961,6 @@ "mode": "inline", "produces": [ "build-instructions", - "unit-test-instructions", "integration-test-instructions", "performance-test-instructions", "security-test-instructions", @@ -1972,6 +1972,10 @@ "artifact": "code-generation-plan", "required": true }, + { + "artifact": "unit-test-instructions", + "required": true + }, { "artifact": "code-summary", "required": true @@ -1996,7 +2000,7 @@ "workshop" ], "inputs": "ALL code generation outputs across all units", - "outputs": "build-instructions.md, unit-test-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", + "outputs": "build-instructions.md, integration-test-instructions.md, performance-test-instructions.md, security-test-instructions.md, build-and-test-summary.md, test-results.md (under this stage's record dir, engine-resolved)", "rules_in_context": [ { "path": "aidlc/spaces/default/memory/org.md", diff --git a/tests/unit/gen-coverage-registry.test.ts b/tests/unit/gen-coverage-registry.test.ts index 0e5302dba..fd8bb7f69 100644 --- a/tests/unit/gen-coverage-registry.test.ts +++ b/tests/unit/gen-coverage-registry.test.ts @@ -840,6 +840,7 @@ describe("mechanismsOf is body-derived (milestone 3)", () => { "unit/t18.test.ts", "unit/t19.test.ts", "unit/t20.test.ts", + "unit/t215-code-gen-unit-test-instructions-coverage.test.ts", "unit/t27.test.ts", "unit/t29.test.ts", "unit/t30-hook-session-end.test.ts", diff --git a/tests/unit/t186-foreach-per-unit-iteration.test.ts b/tests/unit/t186-foreach-per-unit-iteration.test.ts index 7f36eb873..185e5a38b 100644 --- a/tests/unit/t186-foreach-per-unit-iteration.test.ts +++ b/tests/unit/t186-foreach-per-unit-iteration.test.ts @@ -486,7 +486,7 @@ describe("t186 engine-driven per-unit for_each iteration (issue #368)", () => { // deadlock the multi-batch swarm, since the swarm re-emits batch 1 and never // advances). The guard is scoped to exclude the autonomous swarm, so the report // takes the normal forward path, not a per-unit-coverage error. - const CG_PRODUCES = ["code-generation-plan", "code-summary"]; + const CG_PRODUCES = ["code-generation-plan", "unit-test-instructions", "code-summary"]; test("13: autonomous multi-batch code-generation swarm is not blocked by the coverage guard", () => { const proj = seedProject("code-generation", "on"); // code-generation must be in-flight (not pending) for an approve to be valid; diff --git a/tests/unit/t215-code-gen-unit-test-instructions-coverage.test.ts b/tests/unit/t215-code-gen-unit-test-instructions-coverage.test.ts new file mode 100644 index 000000000..4360dcf01 --- /dev/null +++ b/tests/unit/t215-code-gen-unit-test-instructions-coverage.test.ts @@ -0,0 +1,167 @@ +// covers: subcommand:aidlc-orchestrate:next +// +// Regression test for PR #403: unit-test-instructions moved from +// build-and-test.produces[] to code-generation.produces[]. The per-unit +// iteration loop must treat a unit as UNCOVERED when unit-test-instructions.md +// is missing, even if code-generation-plan.md and code-summary.md exist. +// mechanism = cli (spawn aidlc-orchestrate.ts next). + +import { afterEach, describe, expect, test } from "bun:test"; +import { spawnSync } from "node:child_process"; +import { mkdirSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { + AIDLC_SRC, + cleanupTestProject, + createTestProject, + DEFAULT_RECORD_DIR, + DEFAULT_SPACE, + resetAidlcEnv, + seededRecordDir, + seededStateFile, +} from "../harness/fixtures.ts"; + +resetAidlcEnv(); + +const BUN = process.execPath; +const ORCH = join(AIDLC_SRC, "tools", "aidlc-orchestrate.ts"); +const RP = `aidlc/spaces/${DEFAULT_SPACE}/intents/${DEFAULT_RECORD_DIR}`; + +const CG_PRODUCES_FULL = ["code-generation-plan", "unit-test-instructions", "code-summary"]; +const CG_PRODUCES_MISSING_UTI = ["code-generation-plan", "code-summary"]; + +interface Directive { + kind?: string; + stage?: string; + unit?: string; + gate?: unknown; + produces?: string[]; + [k: string]: unknown; +} + +const tempDirs: string[] = []; +afterEach(() => { + while (tempDirs.length) cleanupTestProject(tempDirs.pop()); +}); + +function constructionStateAtCodeGen(): string { + return `# AI-DLC State Tracking + +## Project Information +- **Project**: unit-test-instructions coverage test +- **Project Type**: Greenfield +- **Scope**: feature +- **State Version**: 7 +- **Skeleton Stance**: on + +## Scope Configuration +- **Stages to Execute**: all +- **Stages to Skip**: none +- **Depth**: Standard +- **Test Strategy**: Standard + +## Stage Progress + +### CONSTRUCTION PHASE +- [x] functional-design — EXECUTE +- [x] nfr-requirements — EXECUTE +- [x] nfr-design — EXECUTE +- [x] infrastructure-design — EXECUTE +- [-] code-generation — EXECUTE +- [ ] build-and-test — EXECUTE + +### INCEPTION PHASE +- [-] application-design — EXECUTE + +## Current Status +- **Lifecycle Phase**: CONSTRUCTION +- **Current Stage**: code-generation +- **Status**: Running +`; +} + +function seedProject(): string { + const proj = createTestProject(); + tempDirs.push(proj); + writeFileSync(seededStateFile(proj), constructionStateAtCodeGen()); + return proj; +} + +function seedBoltDag(proj: string, units: string[]): void { + writeFileSync( + join(seededRecordDir(proj), "runtime-graph.json"), + JSON.stringify( + { + bolt_dag: { + units: units.map((name) => ({ name, depends_on: [] })), + batches: [units], + }, + }, + null, + 2, + ), + ); +} + +function coverUnit(proj: string, unit: string, producesNames: string[]): void { + const dir = join(seededRecordDir(proj), "construction", unit, "code-generation"); + mkdirSync(dir, { recursive: true }); + for (const name of producesNames) { + writeFileSync(join(dir, `${name}.md`), `# ${name} for ${unit}\n`); + } +} + +function runNext(proj: string): Directive { + const r = spawnSync(BUN, [ORCH, "next", "--project-dir", proj], { + encoding: "utf-8", + env: (() => { + const e = { ...process.env }; + delete e.AWS_AIDLC_DEFAULT_SCOPE; + return e; + })(), + }); + try { + return JSON.parse((r.stdout ?? "").trim()) as Directive; + } catch { + throw new Error( + `runNext did not emit parseable JSON. status=${r.status}\n${r.stdout}\n${r.stderr}`, + ); + } +} + +describe("t215 code-generation per-unit coverage requires unit-test-instructions (PR #403)", () => { + test("1: unit missing unit-test-instructions.md is NOT covered — engine re-emits that unit", () => { + const proj = seedProject(); + seedBoltDag(proj, ["alpha", "beta"]); + // Cover alpha with only plan + summary (missing unit-test-instructions) + coverUnit(proj, "alpha", CG_PRODUCES_MISSING_UTI); + const d = runNext(proj); + expect(d.kind).toBe("run-stage"); + expect(d.stage).toBe("code-generation"); + // Engine should re-emit alpha since it's not fully covered + expect(d.unit).toBe("alpha"); + }, 30000); + + test("2: unit with all three produces (including unit-test-instructions) IS covered — engine advances", () => { + const proj = seedProject(); + seedBoltDag(proj, ["alpha", "beta"]); + // Cover alpha with the full produces list + coverUnit(proj, "alpha", CG_PRODUCES_FULL); + const d = runNext(proj); + expect(d.kind).toBe("run-stage"); + expect(d.stage).toBe("code-generation"); + // Engine should advance to beta since alpha is fully covered + expect(d.unit).toBe("beta"); + }, 30000); + + test("3: produces path includes unit-test-instructions.md for the emitted unit", () => { + const proj = seedProject(); + seedBoltDag(proj, ["alpha", "beta"]); + const d = runNext(proj); + expect(d.kind).toBe("run-stage"); + expect(d.unit).toBe("alpha"); + expect(d.produces).toContain( + `${RP}/construction/alpha/code-generation/unit-test-instructions.md`, + ); + }, 30000); +});