@metasession.co/devaudit-cli 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
- package/scripts/upload-evidence.sh +225 -0
- package/sdlc/CLAUDE.md +73 -0
- package/sdlc/HOST_ADAPTER.md +127 -0
- package/sdlc/SKILLS.md +137 -0
- package/sdlc/STACK_ADAPTER.md +130 -0
- package/sdlc/ai-rules/INSTRUCTIONS-SDLC.md +172 -0
- package/sdlc/ai-rules/README.md +103 -0
- package/sdlc/ai-rules/SDLC_RULES.md +584 -0
- package/sdlc/ai-rules/claude/CLAUDE.md +192 -0
- package/sdlc/ai-rules/cursor/.cursorrules +167 -0
- package/sdlc/ai-rules/windsurf/.windsurfrules +167 -0
- package/sdlc/article.md +219 -0
- package/sdlc/files/_common/0-project-setup.md +410 -0
- package/sdlc/files/_common/1-plan-requirement.md +381 -0
- package/sdlc/files/_common/2-implement-and-test.md +276 -0
- package/sdlc/files/_common/3-compile-evidence.md +603 -0
- package/sdlc/files/_common/4-submit-for-review.md +362 -0
- package/sdlc/files/_common/5-deploy-main.md +251 -0
- package/sdlc/files/_common/Periodic_Security_Review_Schedule.md +169 -0
- package/sdlc/files/_common/README_TEMPLATE.md +441 -0
- package/sdlc/files/_common/Test_Architecture.md +461 -0
- package/sdlc/files/_common/Test_Plan_TEMPLATE.md +311 -0
- package/sdlc/files/_common/Test_Policy.md +277 -0
- package/sdlc/files/_common/Test_Strategy.md +359 -0
- package/sdlc/files/_common/github/ISSUE_TEMPLATE/bug.yml +75 -0
- package/sdlc/files/_common/github/ISSUE_TEMPLATE/config.yml +11 -0
- package/sdlc/files/_common/github/ISSUE_TEMPLATE/requirement.yml +75 -0
- package/sdlc/files/_common/github/ISSUE_TEMPLATE/task.yml +48 -0
- package/sdlc/files/_common/github/pull_request_template.md +69 -0
- package/sdlc/files/_common/implementing-an-sdlc-issue.md +413 -0
- package/sdlc/files/_common/scripts/derive-release-version.sh +40 -0
- package/sdlc/files/_common/scripts/derive-release-version.test.sh +98 -0
- package/sdlc/files/_common/scripts/submit-for-uat-review.sh +162 -0
- package/sdlc/files/_common/scripts/validate-commits.sh +83 -0
- package/sdlc/files/_common/scripts/validate-compliance-artifacts.sh +202 -0
- package/sdlc/files/_common/scripts/validate-compliance-artifacts.test.sh +202 -0
- package/sdlc/files/_common/skills/_schema/skill.schema.json +36 -0
- package/sdlc/files/_common/skills/e2e-test-engineer/SKILL.md +254 -0
- package/sdlc/files/_common/skills/e2e-test-engineer/references/bootstrap.md +244 -0
- package/sdlc/files/_common/skills/e2e-test-engineer/references/evidence.ts +40 -0
- package/sdlc/files/_common/skills/sdlc-implementer/SKILL.md +189 -0
- package/sdlc/files/_common/skills/sdlc-implementer/references/call-graph.md +64 -0
- package/sdlc/files/_common/skills/sdlc-implementer/references/change-request-loop.md +192 -0
- package/sdlc/files/_common/skills/sdlc-implementer/references/compliance-constraints.md +81 -0
- package/sdlc/files/ci/check-release-approval.yml.template +201 -0
- package/sdlc/files/ci/ci-status-fallback.yml.template +41 -0
- package/sdlc/files/ci/ci.yml.template +390 -0
- package/sdlc/files/ci/compliance-evidence.yml.template +161 -0
- package/sdlc/files/ci/compliance-validation.yml.template +34 -0
- package/sdlc/files/ci/post-deploy-prod.yml.template +159 -0
- package/sdlc/files/ci/python/ci.yml.template +335 -0
- package/sdlc/files/hosts/_schema/adapter.schema.json +103 -0
- package/sdlc/files/hosts/railway/adapter.json +32 -0
- package/sdlc/files/sdlc-config.example.json +74 -0
- package/sdlc/files/stacks/_schema/adapter.schema.json +151 -0
- package/sdlc/files/stacks/node/adapter.json +54 -0
- package/sdlc/files/stacks/node/hooks/.prettierrc.json +9 -0
- package/sdlc/files/stacks/node/hooks/commit-msg +7 -0
- package/sdlc/files/stacks/node/hooks/commitlint.config.mjs +64 -0
- package/sdlc/files/stacks/node/hooks/lint-staged.config.mjs +16 -0
- package/sdlc/files/stacks/node/hooks/pre-commit +13 -0
- package/sdlc/files/stacks/node/hooks/pre-push +15 -0
- package/sdlc/files/stacks/node/scripts/check-requirement-jsdoc.sh +54 -0
- package/sdlc/files/stacks/python/adapter.json +36 -0
- package/sdlc/files/stacks/python/hooks/.pre-commit-config.yaml +51 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Define a new requirement in the RTM, classify risk, create implementation plan, generate test scope, and prepare for implementation
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Plan Requirement
|
|
6
|
+
|
|
7
|
+
**Pipeline Stage:** 1 of 5
|
|
8
|
+
**Next:** `2-implement-and-test.md`
|
|
9
|
+
**References:** Test Policy (`sdlc/files/Test_Policy.md` in DevAudit) (risk classification, AI governance), Test Strategy (risk matrix, testing depth, AI documentation)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
- New features, enhancements, or significant changes
|
|
16
|
+
- **Bug fixes that affect financial calculations, user-facing data, or access control**
|
|
17
|
+
- Work that needs formal traceability (security, payments, RBAC, data handling)
|
|
18
|
+
- Any change a stakeholder or auditor might ask "was this tested?"
|
|
19
|
+
|
|
20
|
+
**Skip this workflow** for trivial changes (typo fixes, formatting, dependency bumps) — go straight to `2-implement-and-test.md`.
|
|
21
|
+
|
|
22
|
+
**Even for trivial changes:** review existing tests for impact and run all gates locally before pushing.
|
|
23
|
+
|
|
24
|
+
## Steps
|
|
25
|
+
|
|
26
|
+
### Step 1: Identify the GitHub Issue
|
|
27
|
+
|
|
28
|
+
Every tracked change starts from a GitHub Issue. The issue provides the *what* and *why*; the RTM provides the compliance audit trail.
|
|
29
|
+
|
|
30
|
+
- If the user references an issue number (e.g., `#123`): fetch its title, description, and labels using `gh issue view 123`.
|
|
31
|
+
- If the user describes work without an issue: ask **"Is there a GitHub Issue for this, or should we create one?"**
|
|
32
|
+
- To create one: `gh issue create --title "[title]" --body "[description]" --label "[labels]"`
|
|
33
|
+
- Use issue labels to inform risk classification in Step 3 (e.g., `security`, `user-facing`, `internal`).
|
|
34
|
+
|
|
35
|
+
### Step 2: Determine the Next Requirement ID
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
grep -oP 'REQ-\d+' compliance/RTM.md | sort -t- -k2 -n | tail -1
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The next ID is one higher (e.g., if the last is REQ-007, use REQ-008).
|
|
42
|
+
|
|
43
|
+
### Step 3: Classify Risk Level
|
|
44
|
+
|
|
45
|
+
| Risk Level | Criteria |
|
|
46
|
+
|---|---|
|
|
47
|
+
| **Low** | Internal tools, no regulated data, no auth changes |
|
|
48
|
+
| **Medium** | Touches PII, user-facing features, API changes, new dependencies |
|
|
49
|
+
| **High** | Security, payments, RBAC, data handling, authentication |
|
|
50
|
+
|
|
51
|
+
AI involvement raises risk by one level when touching Medium or High categories. See Test Policy for the full risk matrix.
|
|
52
|
+
|
|
53
|
+
### Step 4: Add Entry to RTM
|
|
54
|
+
|
|
55
|
+
Open `compliance/RTM.md`, Part B. The issue provides full context; the RTM is a traceability index, not a content store.
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
| REQ-XXX | #NNN | [LOW/MEDIUM/HIGH] | compliance/evidence/REQ-XXX/ | DRAFT | -- | -- |
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The auditor reads one row and follows the links: Issue for context and rationale, evidence directory for test artifacts, PR for code changes.
|
|
62
|
+
|
|
63
|
+
### Step 5: Create Evidence Directory
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
mkdir -p compliance/evidence/REQ-XXX
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Step 6: Implementation Plan (MEDIUM/HIGH Risk — Required)
|
|
70
|
+
|
|
71
|
+
For MEDIUM and HIGH risk requirements, create an implementation plan before defining test scope. The implementation plan defines *what code changes are needed* — the test scope is then derived from it.
|
|
72
|
+
|
|
73
|
+
**Skip this step** for LOW risk requirements — proceed directly to Step 7.
|
|
74
|
+
|
|
75
|
+
**6a. Explore the codebase:**
|
|
76
|
+
- Understand existing patterns, models, services, and API routes relevant to the change
|
|
77
|
+
- Identify files that will be created, modified, or affected
|
|
78
|
+
|
|
79
|
+
**6b. Create the implementation plan:**
|
|
80
|
+
|
|
81
|
+
Create `compliance/evidence/REQ-XXX/implementation-plan.md`:
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
# Implementation Plan — REQ-XXX
|
|
85
|
+
|
|
86
|
+
**Requirement:** REQ-XXX
|
|
87
|
+
**GitHub Issue:** #NNN
|
|
88
|
+
**Risk Level:** [MEDIUM / HIGH]
|
|
89
|
+
**Date:** [YYYY-MM-DD]
|
|
90
|
+
|
|
91
|
+
## Approach
|
|
92
|
+
[1-3 sentences describing the overall approach]
|
|
93
|
+
|
|
94
|
+
## Files to Create
|
|
95
|
+
- `path/to/new-file.ts` — [purpose]
|
|
96
|
+
|
|
97
|
+
## Files to Modify
|
|
98
|
+
- `path/to/existing-file.ts` — [what changes and why]
|
|
99
|
+
|
|
100
|
+
## Architecture Decisions
|
|
101
|
+
- [Key decision 1 and rationale]
|
|
102
|
+
- [Key decision 2 and rationale]
|
|
103
|
+
|
|
104
|
+
## Dependencies
|
|
105
|
+
- [New packages needed, or "None"]
|
|
106
|
+
|
|
107
|
+
## Risks / Considerations
|
|
108
|
+
- [Anything that could go wrong or needs special attention]
|
|
109
|
+
|
|
110
|
+
## Post-Deploy Actions
|
|
111
|
+
- [Data migrations, backfill scripts, schema changes — or "None"]
|
|
112
|
+
- [If any: create script in `scripts/`, document exact command and target environment]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### WAIT CHECKPOINT: Implementation Plan Review
|
|
116
|
+
|
|
117
|
+
**Present the implementation plan to the developer.** Summarize:
|
|
118
|
+
- Approach and rationale
|
|
119
|
+
- Files to create/modify
|
|
120
|
+
- Architecture decisions
|
|
121
|
+
- Risks and dependencies
|
|
122
|
+
|
|
123
|
+
**Do NOT proceed** until the developer explicitly approves the plan. If the developer requests changes, update `implementation-plan.md` and re-present. For HIGH risk, this review is especially important — it's cheaper to change the plan than to refactor the code.
|
|
124
|
+
|
|
125
|
+
**6c. Commit the plan:**
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
git add compliance/evidence/REQ-XXX/implementation-plan.md
|
|
129
|
+
git commit -m "chore(compliance): [REQ-XXX] implementation plan
|
|
130
|
+
|
|
131
|
+
Ref: REQ-XXX
|
|
132
|
+
|
|
133
|
+
Co-Authored-By: [AI tool tag]"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### Step 7: Generate Test Scope
|
|
139
|
+
|
|
140
|
+
Create a test scope document proportional to the assessed risk level. For MEDIUM/HIGH risk, this is derived from the implementation plan — you now know what code is changing and can define what tests are needed.
|
|
141
|
+
|
|
142
|
+
This must exist **before implementation begins** — it is the evidence that testing was planned, not retroactively documented.
|
|
143
|
+
|
|
144
|
+
The AI generates this based on the risk classification, the implementation plan (if applicable), and the Test Strategy's risk-based testing depth matrix.
|
|
145
|
+
|
|
146
|
+
**For LOW risk:**
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
cat > compliance/evidence/REQ-XXX/test-scope.md << 'EOF'
|
|
150
|
+
# Test Scope — REQ-XXX
|
|
151
|
+
|
|
152
|
+
**Risk Level:** LOW
|
|
153
|
+
**Requirement:** [Brief description]
|
|
154
|
+
**GitHub Issue:** #NNN
|
|
155
|
+
**Date:** [YYYY-MM-DD]
|
|
156
|
+
|
|
157
|
+
## Test Approach
|
|
158
|
+
|
|
159
|
+
Standard gates apply. No additional testing beyond universal exit criteria.
|
|
160
|
+
|
|
161
|
+
- TypeScript compilation: 0 errors
|
|
162
|
+
- SAST scan: 0 high/critical findings
|
|
163
|
+
- Dependency audit: 0 high/critical vulnerabilities
|
|
164
|
+
- E2E suite: all pass
|
|
165
|
+
- CI independent verification: all PR checks pass
|
|
166
|
+
- Human code review via PR
|
|
167
|
+
|
|
168
|
+
## Acceptance Criteria
|
|
169
|
+
|
|
170
|
+
- [x] [Criterion 1 — what "done" looks like]
|
|
171
|
+
- [x] [Criterion 2]
|
|
172
|
+
EOF
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**For MEDIUM risk:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cat > compliance/evidence/REQ-XXX/test-scope.md << 'EOF'
|
|
179
|
+
# Test Scope — REQ-XXX
|
|
180
|
+
|
|
181
|
+
**Risk Level:** MEDIUM
|
|
182
|
+
**Requirement:** [Brief description]
|
|
183
|
+
**GitHub Issue:** #NNN
|
|
184
|
+
**Date:** [YYYY-MM-DD]
|
|
185
|
+
|
|
186
|
+
## Test Approach
|
|
187
|
+
|
|
188
|
+
Standard gates plus targeted verification.
|
|
189
|
+
|
|
190
|
+
**Universal gates (mandatory — verified locally AND in CI):**
|
|
191
|
+
- TypeScript compilation: 0 errors
|
|
192
|
+
- SAST scan: 0 high/critical findings
|
|
193
|
+
- Dependency audit: 0 high/critical vulnerabilities
|
|
194
|
+
- E2E suite: all pass (full suite local, unauthenticated subset in CI)
|
|
195
|
+
- Human code review via PR
|
|
196
|
+
|
|
197
|
+
**Additional testing required by risk level:**
|
|
198
|
+
- [ ] Access control: [which endpoints/roles need verification]
|
|
199
|
+
- [ ] Audit logging: [which actions must produce log entries]
|
|
200
|
+
- [ ] Dependency review: [if new packages, verify real/current/no CVEs]
|
|
201
|
+
- [ ] [Any other area-specific testing]
|
|
202
|
+
|
|
203
|
+
## Validation Approach
|
|
204
|
+
|
|
205
|
+
How we confirm this meets the business requirement:
|
|
206
|
+
- [e.g., "Verify public page displays new content correctly"]
|
|
207
|
+
- [e.g., "Confirm edits are visible to users within expected time"]
|
|
208
|
+
|
|
209
|
+
## Acceptance Criteria
|
|
210
|
+
|
|
211
|
+
- [ ] [Criterion 1]
|
|
212
|
+
- [ ] [Criterion 2]
|
|
213
|
+
- [ ] All additional testing items above pass
|
|
214
|
+
EOF
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**For HIGH risk:**
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
cat > compliance/evidence/REQ-XXX/test-scope.md << 'EOF'
|
|
221
|
+
# Test Scope — REQ-XXX
|
|
222
|
+
|
|
223
|
+
**Risk Level:** HIGH
|
|
224
|
+
**Requirement:** [Brief description]
|
|
225
|
+
**GitHub Issue:** #NNN
|
|
226
|
+
**Date:** [YYYY-MM-DD]
|
|
227
|
+
|
|
228
|
+
## Test Approach
|
|
229
|
+
|
|
230
|
+
Full verification and validation per Test Strategy high-risk requirements.
|
|
231
|
+
|
|
232
|
+
**Universal gates (mandatory — verified locally AND in CI):**
|
|
233
|
+
- TypeScript compilation: 0 errors
|
|
234
|
+
- SAST scan: 0 high/critical findings
|
|
235
|
+
- Dependency audit: 0 high/critical vulnerabilities
|
|
236
|
+
- E2E suite: all pass
|
|
237
|
+
- Human code review via PR
|
|
238
|
+
|
|
239
|
+
**Security testing (mandatory for HIGH):**
|
|
240
|
+
- [ ] Access control: [specific endpoints, roles, expected behaviors]
|
|
241
|
+
- [ ] Audit logging: [specific actions that must produce entries]
|
|
242
|
+
- [ ] Input validation: [boundary/injection testing needed]
|
|
243
|
+
- [ ] Error handling: [verify no sensitive data in error responses]
|
|
244
|
+
|
|
245
|
+
**Additional high-risk testing:**
|
|
246
|
+
- [ ] Independent review: [who will provide secondary review]
|
|
247
|
+
- [ ] Penetration testing consideration: [warranted? justification]
|
|
248
|
+
- [ ] Performance impact: [load/performance concerns]
|
|
249
|
+
- [ ] Regression scope: [areas needing manual verification beyond E2E]
|
|
250
|
+
|
|
251
|
+
## Validation Approach
|
|
252
|
+
|
|
253
|
+
How we confirm this meets the business requirement:
|
|
254
|
+
- [Specific user workflow to test end-to-end]
|
|
255
|
+
- [Business rule to validate]
|
|
256
|
+
- [Stakeholder sign-off needed? From whom?]
|
|
257
|
+
|
|
258
|
+
## AI Involvement (if applicable)
|
|
259
|
+
|
|
260
|
+
- AI tool: [tool name / none]
|
|
261
|
+
- Code categories AI will generate: [list]
|
|
262
|
+
- Elevated review required for: [security-sensitive files]
|
|
263
|
+
- Regeneration protocol: [will any components be regenerated?]
|
|
264
|
+
|
|
265
|
+
## Acceptance Criteria
|
|
266
|
+
|
|
267
|
+
- [ ] [Criterion 1]
|
|
268
|
+
- [ ] [Criterion 2]
|
|
269
|
+
- [ ] All security testing items pass
|
|
270
|
+
- [ ] All validation items confirmed
|
|
271
|
+
- [ ] Independent review completed (if required)
|
|
272
|
+
EOF
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### WAIT CHECKPOINT: Test Scope Review
|
|
276
|
+
|
|
277
|
+
**Present the test scope to the developer.** Summarize:
|
|
278
|
+
- Risk classification and rationale
|
|
279
|
+
- Test approach (which additional testing applies)
|
|
280
|
+
- Acceptance criteria
|
|
281
|
+
|
|
282
|
+
**Do NOT proceed** until the developer confirms the test scope is complete and correct. If the developer requests changes, update `test-scope.md` and re-present.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### Step 8: Create Test Plan
|
|
287
|
+
|
|
288
|
+
Create a test plan that maps acceptance criteria to specific tests. This documents what tests to add, update, or remove — evidence that testing was planned, not ad hoc.
|
|
289
|
+
|
|
290
|
+
The test plan is proportional to risk. For LOW risk, a brief plan is sufficient. For MEDIUM/HIGH, include non-functional testing and test data requirements.
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
cat > compliance/evidence/REQ-XXX/test-plan.md << 'EOF'
|
|
294
|
+
# Test Plan — REQ-XXX
|
|
295
|
+
|
|
296
|
+
**Requirement:** REQ-XXX
|
|
297
|
+
**Risk Level:** [LOW / MEDIUM / HIGH]
|
|
298
|
+
**GitHub Issue:** #NNN
|
|
299
|
+
**Date:** [YYYY-MM-DD]
|
|
300
|
+
|
|
301
|
+
## Tests to Add
|
|
302
|
+
- [ ] `e2e/[spec-file].spec.ts` — [what it tests]
|
|
303
|
+
- [ ] `__tests__/[test-file].test.ts` — [what it tests]
|
|
304
|
+
|
|
305
|
+
## Tests to Update
|
|
306
|
+
- [ ] `e2e/[existing-spec].spec.ts` — [what changes and why]
|
|
307
|
+
|
|
308
|
+
## Tests to Remove
|
|
309
|
+
- [ ] `e2e/[obsolete-spec].spec.ts` — [justification for removal]
|
|
310
|
+
- [or "None"]
|
|
311
|
+
|
|
312
|
+
## Functional Test Mapping
|
|
313
|
+
| Acceptance Criterion | Test File | Test Name |
|
|
314
|
+
|---------------------|-----------|-----------|
|
|
315
|
+
| [From test-scope.md] | [spec file] | [test name] |
|
|
316
|
+
|
|
317
|
+
## Non-Functional Tests (MEDIUM/HIGH)
|
|
318
|
+
- [ ] Security: [access control, input validation tests needed]
|
|
319
|
+
- [ ] Performance: [load/performance concerns]
|
|
320
|
+
- [ ] Accessibility: [if applicable]
|
|
321
|
+
- [or "Standard gates sufficient for LOW risk"]
|
|
322
|
+
|
|
323
|
+
## Test Data Requirements
|
|
324
|
+
- [Database seeding needed?]
|
|
325
|
+
- [Test fixtures to create?]
|
|
326
|
+
- [or "Existing test data sufficient"]
|
|
327
|
+
EOF
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### WAIT CHECKPOINT: Test Plan Review
|
|
331
|
+
|
|
332
|
+
**Present the test plan to the developer.** Summarize:
|
|
333
|
+
- Tests to add, update, and remove
|
|
334
|
+
- How acceptance criteria map to specific tests
|
|
335
|
+
- Any non-functional testing required
|
|
336
|
+
|
|
337
|
+
**Do NOT proceed** until the developer confirms the test plan is complete and correct. If the developer requests changes, update `test-plan.md` and re-present.
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
### Step 9: Update Requirements Document (If Applicable)
|
|
342
|
+
|
|
343
|
+
If the requirement modifies a documented feature, update the requirements document to reflect the intended change.
|
|
344
|
+
|
|
345
|
+
### Step 10: Document AI Use Intent (If Applicable)
|
|
346
|
+
|
|
347
|
+
If AI will generate code (Medium/High risk):
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
cat > compliance/evidence/REQ-XXX/ai-use-note.md << 'EOF'
|
|
351
|
+
# AI Use Record — REQ-XXX
|
|
352
|
+
|
|
353
|
+
**AI Tool:** [tool name]
|
|
354
|
+
**Planned AI Use:** [implementation / test generation / both / none]
|
|
355
|
+
**Risk Classification Impact:** [note if risk was raised due to AI involvement]
|
|
356
|
+
EOF
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
For Low risk, the `Co-Authored-By` commit tag is sufficient.
|
|
360
|
+
|
|
361
|
+
### Step 11: Commit
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
git add compliance/RTM.md compliance/evidence/REQ-XXX docs/REQUIREMENTS.md
|
|
365
|
+
git commit -m "compliance: [REQ-XXX] define requirement and test scope - [description] [RISK: LOW/MEDIUM/HIGH]
|
|
366
|
+
|
|
367
|
+
Ref: REQ-XXX
|
|
368
|
+
Closes: #NNN"
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## Output
|
|
372
|
+
|
|
373
|
+
- GitHub Issue `#NNN` identified or created as the origin of the change
|
|
374
|
+
- REQ-XXX in RTM with `DRAFT`, risk classification, and issue reference
|
|
375
|
+
- Implementation plan (MEDIUM/HIGH risk — approved by developer before test scope)
|
|
376
|
+
- Evidence directory with test scope and test plan (derived from implementation plan)
|
|
377
|
+
- AI use note (if applicable)
|
|
378
|
+
|
|
379
|
+
## Next Step
|
|
380
|
+
|
|
381
|
+
Proceed to `2-implement-and-test.md`. Refer back to `test-scope.md` during implementation.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Implement changes on develop, run all local gates (tests + security scans), commit with compliance-aware conventions
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Implement & Test
|
|
6
|
+
|
|
7
|
+
**Pipeline Stage:** 2 of 5
|
|
8
|
+
**Previous:** `1-plan-requirement.md` (if tracked) or start here for untracked changes
|
|
9
|
+
**Next:** `3-compile-evidence.md`
|
|
10
|
+
**References:** Test Strategy (`sdlc/files/Test_Strategy.md` in DevAudit) (security gates, AI methodology), Test Architecture (tooling), Test Plan (exit criteria)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- On the `develop` branch
|
|
17
|
+
- Dev server starts
|
|
18
|
+
- Database running locally
|
|
19
|
+
- Playwright browsers installed
|
|
20
|
+
- Test data seeded
|
|
21
|
+
- Semgrep installed
|
|
22
|
+
|
|
23
|
+
## Steps
|
|
24
|
+
|
|
25
|
+
### Step 0: Validate Planning Artifacts (Tracked Requirements)
|
|
26
|
+
|
|
27
|
+
Before writing any code, verify that the planning stage is complete:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# For tracked requirements — ALL planning artifacts MUST exist
|
|
31
|
+
ls compliance/evidence/REQ-XXX/test-scope.md
|
|
32
|
+
ls compliance/evidence/REQ-XXX/test-plan.md
|
|
33
|
+
grep 'REQ-XXX' compliance/RTM.md
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**If any file does not exist:** STOP. Run `1-plan-requirement.md` first. Do NOT proceed to implementation without a committed test scope and test plan.
|
|
37
|
+
|
|
38
|
+
For MEDIUM/HIGH risk, also verify:
|
|
39
|
+
```bash
|
|
40
|
+
# Implementation plan must exist (created during planning stage)
|
|
41
|
+
ls compliance/evidence/REQ-XXX/implementation-plan.md
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### Step 1: Verify Branch
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git branch --show-current
|
|
50
|
+
# Must output: develop
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If not: `git checkout develop && git pull origin develop`
|
|
54
|
+
|
|
55
|
+
### Step 2: Unit Tests (TDD)
|
|
56
|
+
|
|
57
|
+
Write or update unit tests **before** implementing the code. You know the expected interfaces and behaviour from the implementation plan and test plan.
|
|
58
|
+
|
|
59
|
+
**2a. Review the test plan:**
|
|
60
|
+
```bash
|
|
61
|
+
cat compliance/evidence/REQ-XXX/test-plan.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**2b. Write unit tests** listed in the "Tests to Add" section:
|
|
65
|
+
- New business logic → unit tests for services, utilities, validators
|
|
66
|
+
- New API endpoints → auth enforcement tests, response format tests
|
|
67
|
+
- Tests should initially **fail** (the implementation doesn't exist yet)
|
|
68
|
+
|
|
69
|
+
**2c. Update existing unit tests** listed in the "Tests to Update" section:
|
|
70
|
+
- API response shape changed? → Update assertions
|
|
71
|
+
- Business logic changed? → Update unit test expectations
|
|
72
|
+
|
|
73
|
+
**2d. Remove obsolete tests** listed in the "Tests to Remove" section (if any). Each removal must have a justification in the test plan.
|
|
74
|
+
|
|
75
|
+
### WAIT CHECKPOINT: Unit Test Coverage
|
|
76
|
+
|
|
77
|
+
Verify the unit tests cover the test plan:
|
|
78
|
+
```bash
|
|
79
|
+
cat compliance/evidence/REQ-XXX/test-plan.md
|
|
80
|
+
# Check: have all unit test items in "Tests to Add" been implemented?
|
|
81
|
+
# Check: have all unit test items in "Tests to Update" been addressed?
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Do NOT proceed** until unit test coverage matches the test plan. Tests are expected to fail at this point — that's correct (TDD).
|
|
85
|
+
|
|
86
|
+
### Step 3: Implement the Change
|
|
87
|
+
|
|
88
|
+
Write your code. For tracked requirements, add JSDoc headers:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
/**
|
|
92
|
+
* @requirement REQ-XXX - Brief description
|
|
93
|
+
*/
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**If AI is generating code (Medium/High risk):**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
echo "Prompt summary: [what you asked AI to generate]" >> compliance/evidence/REQ-XXX/ai-prompts.md
|
|
100
|
+
echo "Files generated: [list]" >> compliance/evidence/REQ-XXX/ai-prompts.md
|
|
101
|
+
echo "Date: $(date -I)" >> compliance/evidence/REQ-XXX/ai-prompts.md
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**If AI regenerates a component** (from scratch, not incremental edit):
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
echo "REGENERATION: [component] regenerated on $(date -I). Full retest required." >> compliance/evidence/REQ-XXX/ai-prompts.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Per Test Strategy: regeneration triggers full retest.
|
|
111
|
+
|
|
112
|
+
**MEDIUM/HIGH risk — AI prompt logging checkpoint:** Before committing AI-generated code, verify that `ai-prompts.md` has been updated with the prompt summary and files generated. If missing, create it now — this is a required artifact for MEDIUM/HIGH risk requirements with AI involvement.
|
|
113
|
+
|
|
114
|
+
### WAIT CHECKPOINT: Unit Tests Green
|
|
115
|
+
|
|
116
|
+
All unit tests must pass before proceeding:
|
|
117
|
+
```bash
|
|
118
|
+
npm test
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Do NOT proceed** until all unit tests are green.
|
|
122
|
+
|
|
123
|
+
### Step 4: E2E Tests
|
|
124
|
+
|
|
125
|
+
Write or update E2E tests **after** implementation. E2E tests need working UI/API to test against — writing Playwright tests against routes and selectors that don't exist is impractical.
|
|
126
|
+
|
|
127
|
+
> **Skill available:** invoke the **`e2e-test-engineer`** skill for this step (at `.claude/skills/e2e-test-engineer/SKILL.md`). It derives scenarios from the requirement's acceptance criteria, reconciles with the existing test pack (flags obsoletes — but never deletes without confirmation), runs the suite, and files defects for failures or missed ACs. Framework-agnostic (Playwright, Cypress, pytest-playwright, etc.) and tracker-agnostic (GitHub, Linear, Jira, etc.). For projects with no e2e suite yet, the skill also covers bootstrapping one. See [`sdlc/SKILLS.md`](../sdlc/SKILLS.md) for the full list of available skills.
|
|
128
|
+
|
|
129
|
+
**4a. Review the test plan for E2E items:**
|
|
130
|
+
```bash
|
|
131
|
+
cat compliance/evidence/REQ-XXX/test-plan.md
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**4b. Add new E2E tests** listed in the "Tests to Add" section:
|
|
135
|
+
- New pages → route protection tests (unauthenticated redirect)
|
|
136
|
+
- New user flows → Playwright tests for critical paths
|
|
137
|
+
- UI components changed? → Update selectors and expected content
|
|
138
|
+
|
|
139
|
+
**4c. Update existing E2E tests** listed in the "Tests to Update" section:
|
|
140
|
+
- New routes added? → Add them to route protection test arrays
|
|
141
|
+
- UI flow changed? → Update selectors and assertions
|
|
142
|
+
|
|
143
|
+
**4d. Remove obsolete E2E tests** listed in the "Tests to Remove" section (if any).
|
|
144
|
+
|
|
145
|
+
### WAIT CHECKPOINT: E2E Tests Green
|
|
146
|
+
|
|
147
|
+
All E2E tests must pass:
|
|
148
|
+
```bash
|
|
149
|
+
npx playwright test
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Do NOT proceed** until all E2E tests are green.
|
|
153
|
+
|
|
154
|
+
### Step 5: Stage Selectively
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
git diff --name-only
|
|
158
|
+
git add src/path/to/file.ts
|
|
159
|
+
|
|
160
|
+
# Safety check — no secrets staged
|
|
161
|
+
git diff --cached --name-only | grep -iE '\.env|secret|credential|\.auth|\.pem'
|
|
162
|
+
# Must return nothing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 6: Commit
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
git commit -m "$(cat <<'EOF'
|
|
169
|
+
type(scope): description
|
|
170
|
+
|
|
171
|
+
- Key change 1
|
|
172
|
+
- Key change 2
|
|
173
|
+
|
|
174
|
+
Ref: REQ-XXX
|
|
175
|
+
|
|
176
|
+
Co-Authored-By: [AI Tool Name] <noreply@provider.com>
|
|
177
|
+
EOF
|
|
178
|
+
)"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`, `compliance`, `security`
|
|
182
|
+
|
|
183
|
+
### Step 7: Run All Local Gates (Mandatory)
|
|
184
|
+
|
|
185
|
+
#### Gate 1: TypeScript
|
|
186
|
+
```bash
|
|
187
|
+
npx tsc --noEmit
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Gate 2: Security (SAST + Dependencies)
|
|
191
|
+
```bash
|
|
192
|
+
semgrep scan --config auto [SOURCE_DIR]/ --severity ERROR --severity WARNING
|
|
193
|
+
npm audit --audit-level=high
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If new dependencies added:
|
|
197
|
+
```bash
|
|
198
|
+
git diff origin/main -- package.json package-lock.json | grep '^\+'
|
|
199
|
+
npm audit
|
|
200
|
+
# Verify: real packages? Current versions? No CVEs? AI hallucinations?
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Gate 3: E2E Tests
|
|
204
|
+
```bash
|
|
205
|
+
npx playwright test
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Exit Criteria
|
|
209
|
+
|
|
210
|
+
| Gate | Threshold |
|
|
211
|
+
|---|---|
|
|
212
|
+
| TypeScript | 0 errors |
|
|
213
|
+
| SAST (high/critical) | 0 findings |
|
|
214
|
+
| Dependencies (high/critical) | 0 vulnerabilities |
|
|
215
|
+
| E2E tests | All pass |
|
|
216
|
+
| Severity-1 defects | 0 open |
|
|
217
|
+
|
|
218
|
+
For Medium/High risk, also verify access control and audit log tests pass (see Test Plan and test-scope.md).
|
|
219
|
+
|
|
220
|
+
**If SAST finds issues:**
|
|
221
|
+
```bash
|
|
222
|
+
echo "SAST finding: [rule-id] in [file] — [fixed/false-positive: reason]" >> compliance/evidence/REQ-XXX/sast-review.md
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Step 8: Push
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
git push origin develop
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
If rejected:
|
|
232
|
+
```bash
|
|
233
|
+
git pull --rebase origin develop
|
|
234
|
+
# Re-run ALL local gates after rebase
|
|
235
|
+
git push origin develop
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Pushing to `develop` triggers the full CI pipeline (TypeScript, SAST, dependency audit, E2E, build). All gate results are automatically uploaded to DevAudit tagged with the release version and `environment=uat`. The develop branch auto-deploys to the UAT environment (Railway staging). UAT will be formally reviewed and approved in DevAudit before a PR to main can be created.
|
|
239
|
+
|
|
240
|
+
### WAIT CHECKPOINT: Confirm CI Green
|
|
241
|
+
|
|
242
|
+
After pushing, wait for CI to complete before proceeding:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
gh run list --branch develop --limit 1
|
|
246
|
+
# Or watch in real time:
|
|
247
|
+
gh run watch
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Do NOT proceed** until CI is green. If CI fails, diagnose the failure, fix locally, re-run all local gates, and push again. Do not push repeatedly hoping CI will pass — fix the root cause.
|
|
251
|
+
|
|
252
|
+
### Step 9: Update Evidence
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
git status compliance/evidence/
|
|
256
|
+
git add compliance/evidence/
|
|
257
|
+
git commit -m "compliance: update test evidence"
|
|
258
|
+
git push origin develop
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Iteration
|
|
262
|
+
|
|
263
|
+
Repeat Steps 3-9. Every commit must leave all local gates green. Step 2 (implementation plan) is done once per requirement. Each push triggers full CI and auto-deploys to UAT.
|
|
264
|
+
|
|
265
|
+
## Output
|
|
266
|
+
|
|
267
|
+
- Code committed and pushed on `develop`
|
|
268
|
+
- All CI gates passing (TypeScript, SAST, dep audit, E2E, build)
|
|
269
|
+
- Evidence auto-uploaded to DevAudit (environment=uat)
|
|
270
|
+
- AI use documented (if applicable)
|
|
271
|
+
- UAT auto-deployed with latest changes
|
|
272
|
+
|
|
273
|
+
## Next Step
|
|
274
|
+
|
|
275
|
+
- **Tracked requirement:** `3-compile-evidence.md`
|
|
276
|
+
- **Untracked change:** `4-submit-for-review.md`
|