# 00. Directory Structure & File Naming Convention

## Objective

Define and standardize directory organization and file naming rules for all Artifacts generated in the QA Workflow. Ensures consistency, traceability, and maintainability across the project.

> **Important**: This document is the **mandatory reference** for the entire workflow. All generated Artifacts (Result, QA, TestCase) must strictly follow the rules defined here before executing any step in the workflow.

---

## 1. Directory Overview

```text
03.Testing/
├── 01.Testcases/
│   └── [functionId]/
│       └── [functionId]_TestCase.md                  ← Gate 4 tạo
└── 07.AI-Artifacts/
    └── [functionId]/
        ├── [functionId]_01_Requirement_Analysis_Result.md     ← Gate 1 tạo
        ├── [functionId]_01_Requirement_Analysis_QA.md         ← Gate 1 tạo (nếu có issue)
        ├── [functionId]_02_Test_Scenarios_Result.md           ← Gate 2 tạo
        ├── [functionId]_02_Scenario_Building_QA.md            ← Gate 2 tạo (nếu có issue)
        ├── [functionId]_03_Test_Cases_Draft_Result.md         ← Gate 3 tạo
        ├── [functionId]_03_Test_Design_QA.md                  ← Gate 3 tạo (nếu có issue)
        ├── [functionId]_04_Test_Cases_Final_Result.md         ← Gate 4 tạo (cùng TestCase)
        └── [functionId]_04_Test_Review_QA.md                  ← Gate 4 tạo
```

Example: `functionId = AD06` → root folder is `03.Testing/`

---

## 2. 07.AI-Artifacts/ Directory Rules

- **Root path**: `03.Testing/07.AI-Artifacts/[functionId]/`
- **Purpose**: Store all official result artifacts and QA tracking files generated at each workflow gate.

### 2.1. File Naming Convention

Files are placed under `03.Testing/07.AI-Artifacts/[functionId]/` with the `[functionId]` as prefix:

```
[functionId]_[step]_Result.md
[functionId]_[step]_QA.md
```

### 2.2. File Name Table by Gate

| Gate | Step Name | Result File Name | QA File Name (if issues) |
| :---: | :--- | :--- | :--- |
| **01** | `01_Requirement_Analysis` | `[functionId]_01_Requirement_Analysis_Result.md` | `[functionId]_01_Requirement_Analysis_QA.md` |
| **02** | `02_Test_Scenarios` | `[functionId]_02_Test_Scenarios_Result.md` | `[functionId]_02_Scenario_Building_QA.md` |
| **03** | `03_Test_Cases_Draft` | `[functionId]_03_Test_Cases_Draft_Result.md` | `[functionId]_03_Test_Design_QA.md` |
| **04** | `04_Test_Cases_Final` | `[functionId]_04_Test_Cases_Final_Result.md` | `[functionId]_04_Test_Review_QA.md` |

### 2.3. Full Path Examples

```
03.Testing/07.AI-Artifacts/AD06/AD06_01_Requirement_Analysis_Result.md
03.Testing/07.AI-Artifacts/AD06/AD06_01_Requirement_Analysis_QA.md
03.Testing/07.AI-Artifacts/AD06/AD06_02_Test_Scenarios_Result.md
03.Testing/07.AI-Artifacts/AD06/AD06_03_Test_Cases_Draft_Result.md
03.Testing/07.AI-Artifacts/AD06/AD06_04_Test_Cases_Final_Result.md
```

> QA files are only created when there are issues (Critical/Major block, or Minor carry-forward).

---

## 3. 01.Testcases/ Directory Rules

- **Root path**: `03.Testing/01.Testcases/[functionId]/`
- **Purpose**: Store the final test case artifact ready for execution. This file contains only the **test case tables** (not review summaries, findings, or coverage validation) and is generated **simultaneously** with `04_Test_Cases_Final_Result.md` at the end of Gate 4.

### 3.1. File Naming Convention

```
[functionId]_TestCase.md
```

### 3.2. Full Path Example

```
03.Testing/01.Testcases/AD06/AD06_TestCase.md
```

### 3.3. File Content

The TestCase file follows the **standard template** at `.claude/skills/test-skills/template/testcase-template.md` and **only includes**:

- **Section 1**: General Information (fill in functionId, creation date)
- **Section 2**: Test Execution Summary (reset to 0, waiting for execution)
- **Section 3**: Detailed Test Cases (all 5 groups and test case tables)

> **Does NOT include**: Review Summary, Review Findings, Coverage Validation (RTM), Sign-off Status — these belong in `04_Test_Cases_Final_Result.md` within `07.AI-Artifacts/[functionId]/`.

### 3.4. Generation Timing

The TestCase file is generated **simultaneously** with `04_Test_Cases_Final_Result.md` at the end of Gate 4, after all Critical/Major issues are resolved and the test case set has been signed off.

---

## 4. Full Artifact Matrix

| Gate | Description | Result Artifact | QA Artifact | TestCase Artifact |
| :---: | :--- | :--- | :--- | :--- |
| **01** | Requirement & Risk Analysis | `[fId]_01_Requirement_Analysis_Result.md` | `[fId]_01_Requirement_Analysis_QA.md` | — |
| **02** | Scenario Building | `[fId]_02_Test_Scenarios_Result.md` | `[fId]_02_Scenario_Building_QA.md` | — |
| **03** | Test Case Design | `[fId]_03_Test_Cases_Draft_Result.md` | `[fId]_03_Test_Design_QA.md` | — |
| **04** | Review & Optimization | `[fId]_04_Test_Cases_Final_Result.md` | `[fId]_04_Test_Review_QA.md` | `[fId]_TestCase.md` |

> `[fId]` = `[functionId]`

---

## 5. Additional Rules

### 5.1. Update Rule

- If a file already exists, **update and overwrite** with the latest content.
- **Do not create duplicate files** with version suffixes (e.g. `_v1`, `_v2`, `_final`, `_new`).

### 5.2. functionId Naming

- Use the **exact functionId** determined in Gate 1 Pre-flight (e.g. `AD06`, `AD10`, `LOGIN`).
- Valid examples: `AD06`, `AD10_Create_Product`, `LOGIN`, `ORD002`
- **Invalid**: `product`, `login`, `tag_feature` (custom names diverging from the functionId)
- The workflow **MUST** strictly require a `functionId` before starting.

### 5.3. Consistency Principle

- `07.AI-Artifacts/` and `01.Testcases/` artifacts for the same functionId **must all use the same functionId prefix** and be grouped in a `[functionId]` subfolder.
- This ensures fast cross-lookup and traceability.

---

## 6. Application Checklist

Before starting any workflow gate, verify:

- [ ] functionId has been confirmed in Gate 1 Pre-flight?
- [ ] Root folder `03.Testing/` exists?
- [ ] `07.AI-Artifacts/[functionId]/` subfolder exists?
- [ ] Result file name follows pattern `[functionId]_[step]_Result.md`?
- [ ] QA file name follows pattern `[functionId]_[step]_QA.md`?
- [ ] (After Gate 4) `01.Testcases/[functionId]/` subfolder exists?
- [ ] (After Gate 4) TestCase file name follows pattern `[functionId]_TestCase.md`?
- [ ] (After Gate 4) TestCase file contains only Section 1+2+3 per template (no review metadata)?
- [ ] No duplicate or incorrectly named files?

---

## 7. References

- `create-testcase-workflow.md` — Full 4-Gate QA workflow definition
- `.claude/skills/test-skills/template/testcase-template.md` — Standard test case template
- `.claude/skills/test-skills/rules/qa-writing-standards.md` — QA writing standards
