Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions core/aidlc-common/stages/construction/build-and-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ support_agents:
mode: inline
produces:
- build-instructions
- unit-test-instructions
- integration-test-instructions
- performance-test-instructions
- security-test-instructions
Expand All @@ -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:
Expand All @@ -36,7 +37,7 @@ scopes:
- security-patch
- workshop
inputs: ALL code generation outputs across all units
outputs: aidlc-docs/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)
outputs: aidlc-docs/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)
---

# Build and Test
Expand All @@ -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 `aidlc-docs/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 `aidlc-docs/construction/*/code-generation/unit-test-instructions.md` and `aidlc-docs/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.

### Step 3: Generate Build Instructions

Expand All @@ -66,15 +67,12 @@ Create `aidlc-docs/construction/build-and-test/build-instructions.md`:

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 generated.

**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
Expand Down Expand Up @@ -104,7 +102,7 @@ Create `aidlc-docs/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 each unit's `unit-test-instructions.md` (under `aidlc-docs/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 `aidlc-docs/construction/build-and-test/test-results.md` with:
- Build status (success/failure + output)
Expand Down Expand Up @@ -154,7 +152,7 @@ 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}`).

Expand Down
32 changes: 26 additions & 6 deletions core/aidlc-common/stages/construction/code-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reviewer_max_iterations: 2
for_each: unit-of-work
produces:
- code-generation-plan
- unit-test-instructions
- code-summary
consumes:
- artifact: business-logic-model
Expand Down Expand Up @@ -48,7 +49,7 @@ scopes:
- security-patch
- workshop
inputs: ALL prior design artifacts for this unit
outputs: application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, code-summary.md)
outputs: application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, unit-test-instructions.md, code-summary.md)
---

# Code Generation
Expand Down Expand Up @@ -129,7 +130,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 `aidlc-docs/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."
Expand All @@ -142,24 +160,25 @@ 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 `aidlc-docs/construction/{unit-name}/code-generation/code-summary.md` documenting:
- Files created/modified
- Key implementation decisions
- Test coverage summary
- Any deviations from the plan

### Step 6: Update State
### Step 7: Update State

Update `aidlc-docs/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:

Expand All @@ -182,7 +201,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
`aidlc-docs/`); the planning + summary artefacts (`code-generation-plan.md`,
`code-summary.md`) live under `aidlc-docs/construction/<unit>/code-generation/`.
`unit-test-instructions.md`, `code-summary.md`) live under
`aidlc-docs/construction/<unit>/code-generation/`.

The imported sensors check the code outputs:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ support_agents:
mode: inline
produces:
- build-instructions
- unit-test-instructions
- integration-test-instructions
- performance-test-instructions
- security-test-instructions
Expand All @@ -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:
Expand All @@ -36,7 +37,7 @@ scopes:
- security-patch
- workshop
inputs: ALL code generation outputs across all units
outputs: aidlc-docs/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)
outputs: aidlc-docs/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)
---

# Build and Test
Expand All @@ -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 `aidlc-docs/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 `aidlc-docs/construction/*/code-generation/unit-test-instructions.md` and `aidlc-docs/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.

### Step 3: Generate Build Instructions

Expand All @@ -66,15 +67,12 @@ Create `aidlc-docs/construction/build-and-test/build-instructions.md`:

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 generated.

**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
Expand Down Expand Up @@ -104,7 +102,7 @@ Create `aidlc-docs/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 each unit's `unit-test-instructions.md` (under `aidlc-docs/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 `aidlc-docs/construction/build-and-test/test-results.md` with:
- Build status (success/failure + output)
Expand Down Expand Up @@ -154,7 +152,7 @@ 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}`).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reviewer_max_iterations: 2
for_each: unit-of-work
produces:
- code-generation-plan
- unit-test-instructions
- code-summary
consumes:
- artifact: business-logic-model
Expand Down Expand Up @@ -48,7 +49,7 @@ scopes:
- security-patch
- workshop
inputs: ALL prior design artifacts for this unit
outputs: application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, code-summary.md)
outputs: application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, unit-test-instructions.md, code-summary.md)
---

# Code Generation
Expand Down Expand Up @@ -129,7 +130,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 `aidlc-docs/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."
Expand All @@ -142,24 +160,25 @@ 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 `aidlc-docs/construction/{unit-name}/code-generation/code-summary.md` documenting:
- Files created/modified
- Key implementation decisions
- Test coverage summary
- Any deviations from the plan

### Step 6: Update State
### Step 7: Update State

Update `aidlc-docs/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:

Expand All @@ -182,7 +201,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
`aidlc-docs/`); the planning + summary artefacts (`code-generation-plan.md`,
`code-summary.md`) live under `aidlc-docs/construction/<unit>/code-generation/`.
`unit-test-instructions.md`, `code-summary.md`) live under
`aidlc-docs/construction/<unit>/code-generation/`.

The imported sensors check the code outputs:

Expand Down
10 changes: 7 additions & 3 deletions dist/claude/.claude/tools/data/stage-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@
"for_each": "unit-of-work",
"produces": [
"code-generation-plan",
"unit-test-instructions",
"code-summary"
],
"consumes": [
Expand Down Expand Up @@ -1911,7 +1912,7 @@
"reviewer": "aidlc-architecture-reviewer-agent",
"reviewer_max_iterations": 2,
"inputs": "ALL prior design artifacts for this unit",
"outputs": "application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, code-summary.md)",
"outputs": "application code + aidlc-docs/construction/{unit-name}/code-generation/ (code-generation-plan.md, unit-test-instructions.md, code-summary.md)",
"rules_in_context": [
{
"path": ".claude/rules/aidlc-org.md",
Expand Down Expand Up @@ -1957,7 +1958,6 @@
"mode": "inline",
"produces": [
"build-instructions",
"unit-test-instructions",
"integration-test-instructions",
"performance-test-instructions",
"security-test-instructions",
Expand All @@ -1969,6 +1969,10 @@
"artifact": "code-generation-plan",
"required": true
},
{
"artifact": "unit-test-instructions",
"required": true
},
{
"artifact": "code-summary",
"required": true
Expand All @@ -1993,7 +1997,7 @@
"workshop"
],
"inputs": "ALL code generation outputs across all units",
"outputs": "aidlc-docs/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)",
"outputs": "aidlc-docs/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)",
"rules_in_context": [
{
"path": ".claude/rules/aidlc-org.md",
Expand Down
Loading