@metasession.co/devaudit-cli 0.1.1 → 0.1.2

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.
Files changed (70) hide show
  1. package/README.md +13 -10
  2. package/dist/index.js +17 -5
  3. package/dist/index.js.map +1 -1
  4. package/package.json +9 -5
  5. package/scripts/upload-evidence.sh +225 -0
  6. package/sdlc/.claude/settings.local.json +11 -0
  7. package/sdlc/CLAUDE.md +73 -0
  8. package/sdlc/HOST_ADAPTER.md +127 -0
  9. package/sdlc/SKILLS.md +137 -0
  10. package/sdlc/STACK_ADAPTER.md +130 -0
  11. package/sdlc/ai-rules/INSTRUCTIONS-SDLC.md +172 -0
  12. package/sdlc/ai-rules/README.md +103 -0
  13. package/sdlc/ai-rules/SDLC_RULES.md +584 -0
  14. package/sdlc/ai-rules/claude/CLAUDE.md +192 -0
  15. package/sdlc/ai-rules/cursor/.cursorrules +167 -0
  16. package/sdlc/ai-rules/windsurf/.windsurfrules +167 -0
  17. package/sdlc/article.md +219 -0
  18. package/sdlc/files/_common/0-project-setup.md +410 -0
  19. package/sdlc/files/_common/1-plan-requirement.md +381 -0
  20. package/sdlc/files/_common/2-implement-and-test.md +276 -0
  21. package/sdlc/files/_common/3-compile-evidence.md +603 -0
  22. package/sdlc/files/_common/4-submit-for-review.md +362 -0
  23. package/sdlc/files/_common/5-deploy-main.md +251 -0
  24. package/sdlc/files/_common/Periodic_Security_Review_Schedule.md +169 -0
  25. package/sdlc/files/_common/README_TEMPLATE.md +441 -0
  26. package/sdlc/files/_common/Test_Architecture.md +461 -0
  27. package/sdlc/files/_common/Test_Plan_TEMPLATE.md +311 -0
  28. package/sdlc/files/_common/Test_Policy.md +277 -0
  29. package/sdlc/files/_common/Test_Strategy.md +359 -0
  30. package/sdlc/files/_common/github/ISSUE_TEMPLATE/bug.yml +75 -0
  31. package/sdlc/files/_common/github/ISSUE_TEMPLATE/config.yml +11 -0
  32. package/sdlc/files/_common/github/ISSUE_TEMPLATE/requirement.yml +75 -0
  33. package/sdlc/files/_common/github/ISSUE_TEMPLATE/task.yml +48 -0
  34. package/sdlc/files/_common/github/pull_request_template.md +69 -0
  35. package/sdlc/files/_common/implementing-an-sdlc-issue.md +413 -0
  36. package/sdlc/files/_common/scripts/derive-release-version.sh +40 -0
  37. package/sdlc/files/_common/scripts/derive-release-version.test.sh +98 -0
  38. package/sdlc/files/_common/scripts/submit-for-uat-review.sh +162 -0
  39. package/sdlc/files/_common/scripts/validate-commits.sh +83 -0
  40. package/sdlc/files/_common/scripts/validate-compliance-artifacts.sh +202 -0
  41. package/sdlc/files/_common/scripts/validate-compliance-artifacts.test.sh +202 -0
  42. package/sdlc/files/_common/skills/_schema/skill.schema.json +36 -0
  43. package/sdlc/files/_common/skills/e2e-test-engineer/SKILL.md +254 -0
  44. package/sdlc/files/_common/skills/e2e-test-engineer/references/bootstrap.md +244 -0
  45. package/sdlc/files/_common/skills/e2e-test-engineer/references/evidence.ts +40 -0
  46. package/sdlc/files/_common/skills/sdlc-implementer/SKILL.md +189 -0
  47. package/sdlc/files/_common/skills/sdlc-implementer/references/call-graph.md +64 -0
  48. package/sdlc/files/_common/skills/sdlc-implementer/references/change-request-loop.md +192 -0
  49. package/sdlc/files/_common/skills/sdlc-implementer/references/compliance-constraints.md +81 -0
  50. package/sdlc/files/ci/check-release-approval.yml.template +201 -0
  51. package/sdlc/files/ci/ci-status-fallback.yml.template +41 -0
  52. package/sdlc/files/ci/ci.yml.template +390 -0
  53. package/sdlc/files/ci/compliance-evidence.yml.template +161 -0
  54. package/sdlc/files/ci/compliance-validation.yml.template +34 -0
  55. package/sdlc/files/ci/post-deploy-prod.yml.template +159 -0
  56. package/sdlc/files/ci/python/ci.yml.template +335 -0
  57. package/sdlc/files/hosts/_schema/adapter.schema.json +103 -0
  58. package/sdlc/files/hosts/railway/adapter.json +32 -0
  59. package/sdlc/files/sdlc-config.example.json +74 -0
  60. package/sdlc/files/stacks/_schema/adapter.schema.json +151 -0
  61. package/sdlc/files/stacks/node/adapter.json +54 -0
  62. package/sdlc/files/stacks/node/hooks/.prettierrc.json +9 -0
  63. package/sdlc/files/stacks/node/hooks/commit-msg +7 -0
  64. package/sdlc/files/stacks/node/hooks/commitlint.config.mjs +64 -0
  65. package/sdlc/files/stacks/node/hooks/lint-staged.config.mjs +16 -0
  66. package/sdlc/files/stacks/node/hooks/pre-commit +13 -0
  67. package/sdlc/files/stacks/node/hooks/pre-push +15 -0
  68. package/sdlc/files/stacks/node/scripts/check-requirement-jsdoc.sh +54 -0
  69. package/sdlc/files/stacks/python/adapter.json +36 -0
  70. package/sdlc/files/stacks/python/hooks/.pre-commit-config.yaml +51 -0
@@ -0,0 +1,192 @@
1
+ # SDLC Compliance — Paste the section below into your project's CLAUDE.md
2
+
3
+ ## SDLC Compliance Process (MANDATORY)
4
+
5
+ This project follows the Metasession SDLC framework. These rules are MANDATORY and OVERRIDE default behaviour.
6
+
7
+ ### SDLC Workflow Files
8
+
9
+ Detailed workflow instructions are in this project's `SDLC/` directory. **Read the relevant workflow file before executing each stage:**
10
+
11
+ | Stage | File | When to read |
12
+ |-------|------|-------------|
13
+ | 0 | `SDLC/0-project-setup.md` | One-time project initialisation |
14
+ | 1 | `SDLC/1-plan-requirement.md` | Starting a new feature or tracked change |
15
+ | 2 | `SDLC/2-implement-and-test.md` | Writing and testing code |
16
+ | 3 | `SDLC/3-compile-evidence.md` | After implementation, before PR |
17
+ | 4 | `SDLC/4-submit-for-review.md` | Creating the PR to main |
18
+ | 5 | `SDLC/5-deploy-main.md` | After PR approval, deploying |
19
+
20
+ When a workflow step requires detailed commands or templates, **read the full workflow file** rather than relying on the summary below. The files contain exact commands, templates, and checklists.
21
+
22
+ Tier 1 reference documents (policy, strategy, architecture) are also in `SDLC/` if present, or in the DevAudit repository at `sdlc/files/`.
23
+
24
+ ### Before ANY Code Change
25
+
26
+ 1. Ask: **"Which GitHub Issue is this for?"** before writing code. Fetch it with `gh issue view NNN`.
27
+ 2. If no issue exists: ask if one should be created. When creating via `gh issue create`, ALWAYS append the SDLC checklist to the body (see below).
28
+ 3. If new requirement needed: **read `SDLC/1-plan-requirement.md`** and follow it to create RTM entry (with issue reference), evidence directory, and test-scope.md BEFORE implementing.
29
+ 4. If trivial (typo/formatting): proceed without requirement but use conventional commit format.
30
+ 5. Verify `develop` branch: `git branch --show-current` — never implement on `main`.
31
+
32
+ ### For ALL Code Changes (including bug fixes)
33
+
34
+ Even if a change doesn't need a REQ entry:
35
+ 1. **Review existing tests** that cover the changed code
36
+ 2. **Update or add tests BEFORE committing**
37
+ 3. **Run all gates locally** — do not push without verifying no regressions
38
+ 4. If the change affects financial calculations, user-facing data, or access control — it needs a REQ entry regardless of size
39
+
40
+ **What needs a REQ entry:** New features → always. Bug fixes affecting financial data, user-facing behaviour, access control → always. Internal logic bug fixes → only if MEDIUM/HIGH risk. Typos, formatting, dependency bumps → never.
41
+
42
+ ### Creating GitHub Issues
43
+
44
+ When creating an issue via `gh issue create`, ALWAYS append this to the body:
45
+ ```
46
+ ## SDLC Checklist
47
+ - [ ] Requirement: RTM entry created (or confirmed trivial)
48
+ - [ ] Planning: test-scope.md and test-plan.md created (or confirmed trivial)
49
+ - [ ] Tests: existing tests reviewed, tests updated/added
50
+ - [ ] Gates: all pass locally (tsc, semgrep, audit, playwright)
51
+ - [ ] Evidence: compiled and uploaded (if tracked requirement)
52
+ ```
53
+
54
+ ### Requirement Planning (do this BEFORE coding)
55
+
56
+ **Read `SDLC/1-plan-requirement.md` for full details.** Summary:
57
+
58
+ 1. Confirm GitHub Issue `#NNN` exists (create if needed via `gh issue create`).
59
+ 2. Get next REQ ID: `grep -oP 'REQ-\d+' compliance/RTM.md | sort -t- -k2 -n | tail -1`
60
+ 3. Classify risk (use issue labels as input): LOW (internal, no auth) / MEDIUM (PII, user-facing, APIs) / HIGH (security, payments, RBAC). AI involvement raises risk by one level.
61
+ 4. Add to `compliance/RTM.md` Part B: `| REQ-XXX | #NNN | [RISK] | compliance/evidence/REQ-XXX/ | DRAFT | -- | -- |`
62
+ 5. **MEDIUM/HIGH risk:** Create `compliance/evidence/REQ-XXX/implementation-plan.md` — document approach, files, architecture decisions. **WAIT CHECKPOINT:** Present the plan to the developer. Do NOT proceed until approved.
63
+ 6. Create `compliance/evidence/REQ-XXX/test-scope.md` with acceptance criteria (derived from the implementation plan for MEDIUM/HIGH).
64
+ 7. **WAIT CHECKPOINT:** Present the test scope to the developer. Do NOT proceed until confirmed.
65
+ 8. Create `compliance/evidence/REQ-XXX/test-plan.md` — map acceptance criteria to specific tests, list tests to add/update/remove. Distinguish unit tests (TDD, before implementation) from E2E tests (after implementation).
66
+ 9. **WAIT CHECKPOINT:** Present the test plan to the developer. Do NOT proceed until confirmed.
67
+ 10. Create `compliance/evidence/REQ-XXX/ai-use-note.md` if AI is involved.
68
+ 11. Commit plan: `compliance: [REQ-XXX] define requirement, test scope, and test plan`
69
+
70
+ ### During Implementation
71
+
72
+ **Read `SDLC/2-implement-and-test.md` for full details.** Summary:
73
+
74
+ - **Before coding:** Verify ALL exist: `ls compliance/evidence/REQ-XXX/test-scope.md` AND `ls compliance/evidence/REQ-XXX/test-plan.md`. If either is missing, STOP and run planning workflow first. For MEDIUM/HIGH also verify `implementation-plan.md` exists.
75
+ - **Phase 1 — Unit tests (TDD):** Write unit tests before implementation. Tests should initially fail. **CHECKPOINT:** Unit test coverage matches test plan.
76
+ - **Phase 2 — Implementation:** Write the code. Unit tests should now pass. **CHECKPOINT:** All unit tests green.
77
+ - **Phase 3 — E2E tests:** Write E2E tests against the working implementation. **CHECKPOINT:** All E2E tests green.
78
+ - **Phase 4 — All gates:** Run full gate suite (TypeScript, SAST, dep audit, all tests, build). **CHECKPOINT:** All gates green, push to develop.
79
+ - Every commit: conventional format with `Ref: REQ-XXX` and `Co-Authored-By` for AI.
80
+ - Add `@requirement REQ-XXX` JSDoc headers to modified files.
81
+ - Log AI prompts in `compliance/evidence/REQ-XXX/ai-prompts.md` for MEDIUM/HIGH risk.
82
+
83
+ ### Before Pushing
84
+
85
+ Run ALL gates — every one must pass:
86
+ ```bash
87
+ npx tsc --noEmit # 0 errors
88
+ semgrep scan --config auto src/ # 0 high/critical
89
+ npm audit --audit-level=high # 0 vulnerabilities
90
+ npx playwright test # all pass
91
+ ```
92
+
93
+ **Verify test plan tests are written:** For tracked requirements, check that every test file referenced in `compliance/evidence/REQ-XXX/test-plan.md` exists and passes. If `test-plan.md` lists tests that haven't been written yet, **STOP** — write and run the tests before pushing.
94
+
95
+ ### After Pushing: WAIT — Confirm CI Green
96
+
97
+ ```bash
98
+ gh run list --branch develop --limit 1
99
+ ```
100
+
101
+ Do NOT proceed to evidence compilation or PR creation until CI is green. If CI fails, fix locally and re-push.
102
+
103
+ ### Evidence Storage Rule
104
+
105
+ **Markdown stays in git. Binary/JSON evidence goes to DevAudit portal.**
106
+
107
+ Upload to DevAudit (NEVER commit to git):
108
+ - E2E results (JSON), screenshots (PNG/JPG), SAST results (JSON), dependency audit (JSON), unit test output (TXT), test reports (HTML)
109
+
110
+ ```bash
111
+ ./scripts/upload-evidence.sh [PROJECT_SLUG] REQ-XXX [type] [file]
112
+ ```
113
+
114
+ Keep in git (small markdown, needs PR review):
115
+ - `compliance/RTM.md`, `test-scope.md`, `security-summary.md`, `ai-use-note.md`, `ai-prompts.md`, release tickets
116
+
117
+ ### After Implementation
118
+
119
+ **Read `SDLC/3-compile-evidence.md` for full details, including release ticket template.** Summary:
120
+
121
+ 1. Confirm CI is green before compiling evidence: `gh run list --branch develop --limit 1`
122
+ 2. Generate `compliance/evidence/REQ-XXX/test-execution-summary.md` — gate results, test changes, coverage against test plan, links to evidence in DevAudit
123
+ 3. Upload binary/JSON evidence to DevAudit portal
124
+ 4. Create `compliance/evidence/REQ-XXX/security-summary.md` (in git)
125
+ 5. Update RTM status to `TESTED - PENDING SIGN-OFF`
126
+ 6. Create `compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md` (use template from workflow file). If the change requires post-deploy actions (data migrations, backfill scripts), document them in the release ticket's Post-Deploy Actions section with exact commands
127
+ 7. Commit compliance markdown locally (do NOT push yet — batch with UAT results):
128
+ ```bash
129
+ git add compliance/RTM.md compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md \
130
+ compliance/evidence/REQ-XXX/test-scope.md \
131
+ compliance/evidence/REQ-XXX/test-plan.md \
132
+ compliance/evidence/REQ-XXX/test-execution-summary.md \
133
+ compliance/evidence/REQ-XXX/security-summary.md \
134
+ compliance/evidence/REQ-XXX/ai-use-note.md
135
+ git commit -m "compliance: [REQ-XXX] evidence compiled - awaiting review"
136
+ ```
137
+ 8. **WAIT CHECKPOINT:** Confirm CI + UAT deployment complete before UAT verification. Do NOT test against a stale deployment.
138
+ 9. **Verify on UAT** (if configured) — health check, smoke test, feature verification. Record in `security-summary.md`. Commit locally. Do NOT create a PR until UAT is green.
139
+ 10. **Push all compliance commits** in a single push: `git push origin develop`
140
+ 11. **Verify release in DevAudit** — CI auto-creates releases and links evidence. Check that a release exists with the current version (date-based: `v{YYYY}.{MM}.{DD}` or `v{YYYY}.{MM}.{DD}.{N}` for multiple releases on the same day) and evidence is linked.
141
+
142
+ ### Pre-Flight Checklist (Before Creating PR)
143
+
144
+ **Do NOT create the PR until ready to merge.** Every push to `develop` while a PR is open triggers duplicate CI runs. The PR is the merge request, not the development workspace.
145
+
146
+ Before creating a PR, verify ALL of the following:
147
+ - [ ] All development and iteration is complete
148
+ - [ ] CI green on develop (not stale): `gh run list --branch develop --limit 1`
149
+ - [ ] Working tree clean: `git status`
150
+ - [ ] UAT verification passed (if configured)
151
+ - [ ] DevAudit UAT approval granted
152
+ - [ ] For tracked requirements: test-scope.md complete, implementation-plan.md exists (MEDIUM/HIGH), RTM is `TESTED - PENDING SIGN-OFF`, release ticket created, evidence uploaded
153
+
154
+ If any item fails, resolve it before proceeding. Read `SDLC/4-submit-for-review.md` for full PR creation steps.
155
+
156
+ ### Status Reporting (MANDATORY before handing off)
157
+
158
+ Before describing a PR as "awaiting review", "waiting on reviewers", "ready to merge", "Stage 4/5 requires human action", or any other happy-path language, you MUST:
159
+
160
+ 1. Run `gh pr checks <PR>` and capture the full output, and `gh pr view <PR> --json mergeable,mergeStateStatus` for GitHub's own mergeability signal.
161
+ 2. If ANY required check is `fail` or `pending`, do NOT use happy-path language. Instead report:
162
+ - Each failing check by name, with its error (from `gh run view <RUN> --log-failed` if needed)
163
+ - Each pending check by name
164
+ - The concrete fix you are about to apply, or a specific question for the developer
165
+ 3. If `mergeStateStatus` is anything other than `CLEAN` or `BLOCKED` (blocked only by required-reviewer approval), treat it as an open issue and investigate before claiming "ready".
166
+ 4. If `gh` itself fails (auth, rate limit, network): report "status unknown — gh call failed", never assume green.
167
+ 5. Only when every required check is `pass` AND the PR is mergeable may you say "awaiting review" or "awaiting approval".
168
+
169
+ **Why this rule exists:** A summary like "awaiting UAT + 2 reviewers" reads to the developer as "nothing to do but approve." If a required check is red, that summary is a lie by omission — the PR cannot merge regardless of what the reviewer does, and the reviewer wastes time (or worse, ships bad state) on the basis of that false signal.
170
+
171
+ This rule applies any time you summarise PR state in chat, not only at the final handoff.
172
+
173
+ ### Review Policy (Risk-Tiered)
174
+
175
+ - **LOW risk:** CI provides independent verification. Self-merge is permitted after all CI checks pass.
176
+ - **MEDIUM/HIGH risk:** A second human reviewer MUST approve before merge. Self-merge is NOT permitted.
177
+
178
+ ### Rules (NEVER break these)
179
+
180
+ - NEVER code without a GitHub Issue and requirement entry for tracked changes
181
+ - NEVER push without all four gates passing
182
+ - NEVER self-merge a MEDIUM or HIGH risk PR — a second human reviewer MUST approve
183
+ - NEVER use `--no-verify` to skip hooks
184
+ - NEVER commit secrets (.env, credentials, API keys)
185
+ - NEVER commit binary/JSON evidence to git — upload to DevAudit instead
186
+ - NEVER create a PR to main without UAT verification passing first (if UAT configured)
187
+ - NEVER push directly to main — always develop → PR → main
188
+ - NEVER skip Co-Authored-By when AI generates code
189
+ - NEVER proceed past a WAIT CHECKPOINT without developer confirmation
190
+ - NEVER describe a PR as "awaiting review" or "ready to merge" without first running `gh pr checks <PR>` and confirming every required check is `pass`
191
+ - ALWAYS commit compliance markdown to git (RTM, test-scope, implementation-plan, security-summary, release tickets)
192
+ - ALWAYS use merge commits (not squash) for develop → main
@@ -0,0 +1,167 @@
1
+ ## SDLC Compliance Process (MANDATORY)
2
+
3
+ This project follows the Metasession SDLC framework. These rules are MANDATORY and OVERRIDE default behaviour.
4
+
5
+ ### SDLC Workflow Files
6
+
7
+ Detailed workflow instructions are in this project's `SDLC/` directory. Read the relevant workflow file before executing each stage:
8
+
9
+ - Stage 0: `SDLC/0-project-setup.md` — One-time project initialisation
10
+ - Stage 1: `SDLC/1-plan-requirement.md` — Starting a new feature or tracked change
11
+ - Stage 2: `SDLC/2-implement-and-test.md` — Writing and testing code
12
+ - Stage 3: `SDLC/3-compile-evidence.md` — After implementation, before PR
13
+ - Stage 4: `SDLC/4-submit-for-review.md` — Creating the PR to main
14
+ - Stage 5: `SDLC/5-deploy-main.md` — After PR approval, deploying
15
+
16
+ When a workflow step requires detailed commands or templates, read the full workflow file rather than relying on the summary below.
17
+
18
+ ### Before ANY Code Change
19
+
20
+ 1. Ask: "Which GitHub Issue is this for?" before writing code. Fetch it with `gh issue view NNN`.
21
+ 2. If no issue exists: ask if one should be created. When creating via `gh issue create`, ALWAYS append the SDLC checklist to the body (see below).
22
+ 3. If new requirement needed: read `SDLC/1-plan-requirement.md` and follow it BEFORE implementing.
23
+ 4. If trivial (typo/formatting): proceed without requirement but use conventional commit format.
24
+ 5. Verify `develop` branch: `git branch --show-current` — never implement on `main`.
25
+
26
+ ### For ALL Code Changes (including bug fixes)
27
+
28
+ Even if a change doesn't need a REQ entry:
29
+ 1. Review existing tests that cover the changed code
30
+ 2. Update or add tests BEFORE committing
31
+ 3. Run all gates locally — do not push without verifying no regressions
32
+ 4. If the change affects financial calculations, user-facing data, or access control — it needs a REQ entry regardless of size
33
+
34
+ What needs a REQ entry: New features → always. Bug fixes affecting financial data, user-facing behaviour, access control → always. Internal logic → only if MEDIUM/HIGH risk. Typos, formatting, dependency bumps → never.
35
+
36
+ ### Creating GitHub Issues
37
+
38
+ When creating an issue via `gh issue create`, ALWAYS append this to the body:
39
+
40
+ ## SDLC Checklist
41
+ - [ ] Requirement: RTM entry created (or confirmed trivial)
42
+ - [ ] Planning: test-scope.md and test-plan.md created (or confirmed trivial)
43
+ - [ ] Tests: existing tests reviewed, tests updated/added
44
+ - [ ] Gates: all pass locally (tsc, semgrep, audit, playwright)
45
+ - [ ] Evidence: compiled and uploaded (if tracked requirement)
46
+
47
+ ### Requirement Planning (do this BEFORE coding)
48
+
49
+ Read `SDLC/1-plan-requirement.md` for full details. Summary:
50
+
51
+ 1. Confirm GitHub Issue `#NNN` exists (create if needed via `gh issue create`).
52
+ 2. Get next REQ ID: `grep -oP 'REQ-\d+' compliance/RTM.md | sort -t- -k2 -n | tail -1`
53
+ 3. Classify risk (use issue labels as input): LOW (internal, no auth) / MEDIUM (PII, user-facing, APIs) / HIGH (security, payments, RBAC). AI involvement raises risk by one level.
54
+ 4. Add to `compliance/RTM.md` Part B: `| REQ-XXX | #NNN | [RISK] | compliance/evidence/REQ-XXX/ | DRAFT | -- | -- |`
55
+ 5. **MEDIUM/HIGH risk:** Create `compliance/evidence/REQ-XXX/implementation-plan.md` — document approach, files, architecture decisions. **WAIT CHECKPOINT:** Present the plan to the developer. Do NOT proceed until approved.
56
+ 6. Create `compliance/evidence/REQ-XXX/test-scope.md` with acceptance criteria (derived from the implementation plan for MEDIUM/HIGH).
57
+ 7. **WAIT CHECKPOINT:** Present the test scope to the developer. Do NOT proceed until confirmed.
58
+ 8. Create `compliance/evidence/REQ-XXX/test-plan.md` — map acceptance criteria to specific tests, list tests to add/update/remove. Distinguish unit tests (TDD, before implementation) from E2E tests (after implementation).
59
+ 9. **WAIT CHECKPOINT:** Present the test plan to the developer. Do NOT proceed until confirmed.
60
+ 10. Create `compliance/evidence/REQ-XXX/ai-use-note.md` if AI is involved.
61
+ 11. Commit plan: `compliance: [REQ-XXX] define requirement, test scope, and test plan`
62
+
63
+ ### During Implementation
64
+
65
+ Read `SDLC/2-implement-and-test.md` for full details. Summary:
66
+
67
+ - **Before coding:** Verify ALL exist: `ls compliance/evidence/REQ-XXX/test-scope.md` AND `ls compliance/evidence/REQ-XXX/test-plan.md`. If either is missing, STOP and run planning workflow first. For MEDIUM/HIGH also verify `implementation-plan.md` exists.
68
+ - **Phase 1 — Unit tests (TDD):** Write unit tests before implementation. Tests should initially fail. **CHECKPOINT:** Unit test coverage matches test plan.
69
+ - **Phase 2 — Implementation:** Write the code. Unit tests should now pass. **CHECKPOINT:** All unit tests green.
70
+ - **Phase 3 — E2E tests:** Write E2E tests against the working implementation. **CHECKPOINT:** All E2E tests green.
71
+ - **Phase 4 — All gates:** Run full gate suite (TypeScript, SAST, dep audit, all tests, build). **CHECKPOINT:** All gates green, push to develop.
72
+ - Every commit: conventional format with `Ref: REQ-XXX` and `Co-Authored-By` for AI.
73
+ - Add `@requirement REQ-XXX` JSDoc headers to modified files.
74
+ - Log AI prompts in `compliance/evidence/REQ-XXX/ai-prompts.md` for MEDIUM/HIGH risk.
75
+
76
+ ### Before Pushing
77
+
78
+ Run ALL gates — every one must pass:
79
+ ```
80
+ npx tsc --noEmit # 0 errors
81
+ semgrep scan --config auto src/ # 0 high/critical
82
+ npm audit --audit-level=high # 0 vulnerabilities
83
+ npx playwright test # all pass
84
+ ```
85
+
86
+ **Verify test plan tests are written:** For tracked requirements, check that every test file referenced in `compliance/evidence/REQ-XXX/test-plan.md` exists and passes. If `test-plan.md` lists tests that haven't been written yet, STOP — write and run the tests before pushing.
87
+
88
+ ### After Pushing: WAIT — Confirm CI Green
89
+
90
+ ```
91
+ gh run list --branch develop --limit 1
92
+ ```
93
+
94
+ Do NOT proceed to evidence compilation or PR creation until CI is green. If CI fails, fix locally and re-push.
95
+
96
+ ### Evidence Storage Rule
97
+
98
+ Markdown stays in git. Binary/JSON evidence goes to DevAudit portal.
99
+
100
+ Upload to DevAudit (NEVER commit to git):
101
+ - E2E results (JSON), screenshots (PNG/JPG), SAST results (JSON), dependency audit (JSON), unit test output (TXT), test reports (HTML)
102
+
103
+ Keep in git (small markdown, needs PR review):
104
+ - compliance/RTM.md, test-scope.md, security-summary.md, ai-use-note.md, ai-prompts.md, release tickets
105
+
106
+ ### After Implementation
107
+
108
+ Read `SDLC/3-compile-evidence.md` for full details, including release ticket template. Summary:
109
+
110
+ 1. Confirm CI is green before compiling evidence: `gh run list --branch develop --limit 1`
111
+ 2. Generate `compliance/evidence/REQ-XXX/test-execution-summary.md` — gate results, test changes, coverage against test plan
112
+ 3. Upload binary/JSON evidence to DevAudit portal
113
+ 4. Create `compliance/evidence/REQ-XXX/security-summary.md` (in git)
114
+ 5. Update RTM status to `TESTED - PENDING SIGN-OFF`
115
+ 6. Create `compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md` (use template from workflow file). If the change requires post-deploy actions (data migrations, backfill scripts), document them in the release ticket's Post-Deploy Actions section with exact commands
116
+ 7. Commit compliance markdown locally (do NOT push yet — batch with UAT results)
117
+ 8. **WAIT CHECKPOINT:** Confirm CI + UAT deployment complete before UAT verification.
118
+ 9. **Verify on UAT** (if configured) — health check, smoke test, feature verification. Record in `security-summary.md`. Commit locally. Do NOT create a PR until UAT is green.
119
+ 10. **Push all compliance commits** in a single push: `git push origin develop`
120
+ 11. **Verify release in DevAudit** — CI auto-creates releases and links evidence. Check that a release exists with the current version (date-based: `v{YYYY}.{MM}.{DD}` or `v{YYYY}.{MM}.{DD}.{N}` for multiple releases on the same day) and evidence is linked.
121
+
122
+ ### Pre-Flight Checklist (Before Creating PR)
123
+
124
+ **Do NOT create the PR until ready to merge.** Every push to `develop` while a PR is open triggers duplicate CI runs. The PR is the merge request, not the development workspace.
125
+
126
+ Before creating a PR, verify ALL of the following:
127
+ - [ ] All development and iteration is complete
128
+ - [ ] CI green on develop (not stale): `gh run list --branch develop --limit 1`
129
+ - [ ] Working tree clean: `git status`
130
+ - [ ] UAT verification passed (if configured)
131
+ - [ ] DevAudit UAT approval granted
132
+ - [ ] For tracked requirements: test-scope.md complete, implementation-plan.md exists (MEDIUM/HIGH), RTM is `TESTED - PENDING SIGN-OFF`, release ticket created, evidence uploaded
133
+
134
+ If any item fails, resolve it before proceeding.
135
+
136
+ ### Status Reporting (MANDATORY before handing off)
137
+
138
+ Before describing a PR as "awaiting review", "waiting on reviewers", "ready to merge", "Stage 4/5 requires human action", or any other happy-path language, you MUST:
139
+
140
+ 1. Run `gh pr checks <PR>` and capture the full output, and `gh pr view <PR> --json mergeable,mergeStateStatus`.
141
+ 2. If ANY required check is `fail` or `pending`, do NOT use happy-path language. Instead report each failing check by name with its error, each pending check by name, and the concrete fix you are about to apply.
142
+ 3. If `mergeStateStatus` is anything other than `CLEAN` or `BLOCKED` (blocked only by required-reviewer approval), investigate before claiming ready.
143
+ 4. If `gh` itself fails: report "status unknown — gh call failed", never assume green.
144
+ 5. Only when every required check is `pass` AND the PR is mergeable may you say "awaiting review" or "awaiting approval".
145
+
146
+ A summary like "awaiting UAT + 2 reviewers" reads to the developer as "nothing to do but approve." If a required check is red, that summary is a lie by omission — the PR cannot merge regardless of what the reviewer does.
147
+
148
+ ### Review Policy (Risk-Tiered)
149
+
150
+ - **LOW risk:** CI provides independent verification. Self-merge is permitted after all CI checks pass.
151
+ - **MEDIUM/HIGH risk:** A second human reviewer MUST approve before merge. Self-merge is NOT permitted.
152
+
153
+ ### Rules (NEVER break these)
154
+
155
+ - NEVER code without a GitHub Issue and requirement entry for tracked changes
156
+ - NEVER push without all four gates passing
157
+ - NEVER self-merge a MEDIUM or HIGH risk PR — a second human reviewer MUST approve
158
+ - NEVER use `--no-verify` to skip hooks
159
+ - NEVER commit secrets (.env, credentials, API keys)
160
+ - NEVER commit binary/JSON evidence to git — upload to DevAudit instead
161
+ - NEVER create a PR to main without UAT verification passing first (if UAT configured)
162
+ - NEVER push directly to main — always develop → PR → main
163
+ - NEVER skip Co-Authored-By when AI generates code
164
+ - NEVER proceed past a WAIT CHECKPOINT without developer confirmation
165
+ - NEVER describe a PR as "awaiting review" or "ready to merge" without first running `gh pr checks <PR>` and confirming every required check is `pass`
166
+ - ALWAYS commit compliance markdown to git (RTM, test-scope, implementation-plan, security-summary, release tickets)
167
+ - ALWAYS use merge commits (not squash) for develop → main
@@ -0,0 +1,167 @@
1
+ ## SDLC Compliance Process (MANDATORY)
2
+
3
+ This project follows the Metasession SDLC framework. These rules are MANDATORY and OVERRIDE default behaviour.
4
+
5
+ ### SDLC Workflow Files
6
+
7
+ Detailed workflow instructions are in this project's `SDLC/` directory. Read the relevant workflow file before executing each stage:
8
+
9
+ - Stage 0: `SDLC/0-project-setup.md` — One-time project initialisation
10
+ - Stage 1: `SDLC/1-plan-requirement.md` — Starting a new feature or tracked change
11
+ - Stage 2: `SDLC/2-implement-and-test.md` — Writing and testing code
12
+ - Stage 3: `SDLC/3-compile-evidence.md` — After implementation, before PR
13
+ - Stage 4: `SDLC/4-submit-for-review.md` — Creating the PR to main
14
+ - Stage 5: `SDLC/5-deploy-main.md` — After PR approval, deploying
15
+
16
+ When a workflow step requires detailed commands or templates, read the full workflow file rather than relying on the summary below.
17
+
18
+ ### Before ANY Code Change
19
+
20
+ 1. Ask: "Which GitHub Issue is this for?" before writing code. Fetch it with `gh issue view NNN`.
21
+ 2. If no issue exists: ask if one should be created. When creating via `gh issue create`, ALWAYS append the SDLC checklist to the body (see below).
22
+ 3. If new requirement needed: read `SDLC/1-plan-requirement.md` and follow it BEFORE implementing.
23
+ 4. If trivial (typo/formatting): proceed without requirement but use conventional commit format.
24
+ 5. Verify `develop` branch: `git branch --show-current` — never implement on `main`.
25
+
26
+ ### For ALL Code Changes (including bug fixes)
27
+
28
+ Even if a change doesn't need a REQ entry:
29
+ 1. Review existing tests that cover the changed code
30
+ 2. Update or add tests BEFORE committing
31
+ 3. Run all gates locally — do not push without verifying no regressions
32
+ 4. If the change affects financial calculations, user-facing data, or access control — it needs a REQ entry regardless of size
33
+
34
+ What needs a REQ entry: New features → always. Bug fixes affecting financial data, user-facing behaviour, access control → always. Internal logic → only if MEDIUM/HIGH risk. Typos, formatting, dependency bumps → never.
35
+
36
+ ### Creating GitHub Issues
37
+
38
+ When creating an issue via `gh issue create`, ALWAYS append this to the body:
39
+
40
+ ## SDLC Checklist
41
+ - [ ] Requirement: RTM entry created (or confirmed trivial)
42
+ - [ ] Planning: test-scope.md and test-plan.md created (or confirmed trivial)
43
+ - [ ] Tests: existing tests reviewed, tests updated/added
44
+ - [ ] Gates: all pass locally (tsc, semgrep, audit, playwright)
45
+ - [ ] Evidence: compiled and uploaded (if tracked requirement)
46
+
47
+ ### Requirement Planning (do this BEFORE coding)
48
+
49
+ Read `SDLC/1-plan-requirement.md` for full details. Summary:
50
+
51
+ 1. Confirm GitHub Issue `#NNN` exists (create if needed via `gh issue create`).
52
+ 2. Get next REQ ID: `grep -oP 'REQ-\d+' compliance/RTM.md | sort -t- -k2 -n | tail -1`
53
+ 3. Classify risk (use issue labels as input): LOW (internal, no auth) / MEDIUM (PII, user-facing, APIs) / HIGH (security, payments, RBAC). AI involvement raises risk by one level.
54
+ 4. Add to `compliance/RTM.md` Part B: `| REQ-XXX | #NNN | [RISK] | compliance/evidence/REQ-XXX/ | DRAFT | -- | -- |`
55
+ 5. **MEDIUM/HIGH risk:** Create `compliance/evidence/REQ-XXX/implementation-plan.md` — document approach, files, architecture decisions. **WAIT CHECKPOINT:** Present the plan to the developer. Do NOT proceed until approved.
56
+ 6. Create `compliance/evidence/REQ-XXX/test-scope.md` with acceptance criteria (derived from the implementation plan for MEDIUM/HIGH).
57
+ 7. **WAIT CHECKPOINT:** Present the test scope to the developer. Do NOT proceed until confirmed.
58
+ 8. Create `compliance/evidence/REQ-XXX/test-plan.md` — map acceptance criteria to specific tests, list tests to add/update/remove. Distinguish unit tests (TDD, before implementation) from E2E tests (after implementation).
59
+ 9. **WAIT CHECKPOINT:** Present the test plan to the developer. Do NOT proceed until confirmed.
60
+ 10. Create `compliance/evidence/REQ-XXX/ai-use-note.md` if AI is involved.
61
+ 11. Commit plan: `compliance: [REQ-XXX] define requirement, test scope, and test plan`
62
+
63
+ ### During Implementation
64
+
65
+ Read `SDLC/2-implement-and-test.md` for full details. Summary:
66
+
67
+ - **Before coding:** Verify ALL exist: `ls compliance/evidence/REQ-XXX/test-scope.md` AND `ls compliance/evidence/REQ-XXX/test-plan.md`. If either is missing, STOP and run planning workflow first. For MEDIUM/HIGH also verify `implementation-plan.md` exists.
68
+ - **Phase 1 — Unit tests (TDD):** Write unit tests before implementation. Tests should initially fail. **CHECKPOINT:** Unit test coverage matches test plan.
69
+ - **Phase 2 — Implementation:** Write the code. Unit tests should now pass. **CHECKPOINT:** All unit tests green.
70
+ - **Phase 3 — E2E tests:** Write E2E tests against the working implementation. **CHECKPOINT:** All E2E tests green.
71
+ - **Phase 4 — All gates:** Run full gate suite (TypeScript, SAST, dep audit, all tests, build). **CHECKPOINT:** All gates green, push to develop.
72
+ - Every commit: conventional format with `Ref: REQ-XXX` and `Co-Authored-By` for AI.
73
+ - Add `@requirement REQ-XXX` JSDoc headers to modified files.
74
+ - Log AI prompts in `compliance/evidence/REQ-XXX/ai-prompts.md` for MEDIUM/HIGH risk.
75
+
76
+ ### Before Pushing
77
+
78
+ Run ALL gates — every one must pass:
79
+ ```
80
+ npx tsc --noEmit # 0 errors
81
+ semgrep scan --config auto src/ # 0 high/critical
82
+ npm audit --audit-level=high # 0 vulnerabilities
83
+ npx playwright test # all pass
84
+ ```
85
+
86
+ **Verify test plan tests are written:** For tracked requirements, check that every test file referenced in `compliance/evidence/REQ-XXX/test-plan.md` exists and passes. If `test-plan.md` lists tests that haven't been written yet, STOP — write and run the tests before pushing.
87
+
88
+ ### After Pushing: WAIT — Confirm CI Green
89
+
90
+ ```
91
+ gh run list --branch develop --limit 1
92
+ ```
93
+
94
+ Do NOT proceed to evidence compilation or PR creation until CI is green. If CI fails, fix locally and re-push.
95
+
96
+ ### Evidence Storage Rule
97
+
98
+ Markdown stays in git. Binary/JSON evidence goes to DevAudit portal.
99
+
100
+ Upload to DevAudit (NEVER commit to git):
101
+ - E2E results (JSON), screenshots (PNG/JPG), SAST results (JSON), dependency audit (JSON), unit test output (TXT), test reports (HTML)
102
+
103
+ Keep in git (small markdown, needs PR review):
104
+ - compliance/RTM.md, test-scope.md, security-summary.md, ai-use-note.md, ai-prompts.md, release tickets
105
+
106
+ ### After Implementation
107
+
108
+ Read `SDLC/3-compile-evidence.md` for full details, including release ticket template. Summary:
109
+
110
+ 1. Confirm CI is green before compiling evidence: `gh run list --branch develop --limit 1`
111
+ 2. Generate `compliance/evidence/REQ-XXX/test-execution-summary.md` — gate results, test changes, coverage against test plan
112
+ 3. Upload binary/JSON evidence to DevAudit portal
113
+ 4. Create `compliance/evidence/REQ-XXX/security-summary.md` (in git)
114
+ 5. Update RTM status to `TESTED - PENDING SIGN-OFF`
115
+ 6. Create `compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md` (use template from workflow file). If the change requires post-deploy actions (data migrations, backfill scripts), document them in the release ticket's Post-Deploy Actions section with exact commands
116
+ 7. Commit compliance markdown locally (do NOT push yet — batch with UAT results)
117
+ 8. **WAIT CHECKPOINT:** Confirm CI + UAT deployment complete before UAT verification.
118
+ 9. **Verify on UAT** (if configured) — health check, smoke test, feature verification. Record in `security-summary.md`. Commit locally. Do NOT create a PR until UAT is green.
119
+ 10. **Push all compliance commits** in a single push: `git push origin develop`
120
+ 11. **Verify release in DevAudit** — CI auto-creates releases and links evidence. Check that a release exists with the current version (date-based: `v{YYYY}.{MM}.{DD}` or `v{YYYY}.{MM}.{DD}.{N}` for multiple releases on the same day) and evidence is linked.
121
+
122
+ ### Pre-Flight Checklist (Before Creating PR)
123
+
124
+ **Do NOT create the PR until ready to merge.** Every push to `develop` while a PR is open triggers duplicate CI runs. The PR is the merge request, not the development workspace.
125
+
126
+ Before creating a PR, verify ALL of the following:
127
+ - [ ] All development and iteration is complete
128
+ - [ ] CI green on develop (not stale): `gh run list --branch develop --limit 1`
129
+ - [ ] Working tree clean: `git status`
130
+ - [ ] UAT verification passed (if configured)
131
+ - [ ] DevAudit UAT approval granted
132
+ - [ ] For tracked requirements: test-scope.md complete, implementation-plan.md exists (MEDIUM/HIGH), RTM is `TESTED - PENDING SIGN-OFF`, release ticket created, evidence uploaded
133
+
134
+ If any item fails, resolve it before proceeding.
135
+
136
+ ### Status Reporting (MANDATORY before handing off)
137
+
138
+ Before describing a PR as "awaiting review", "waiting on reviewers", "ready to merge", "Stage 4/5 requires human action", or any other happy-path language, you MUST:
139
+
140
+ 1. Run `gh pr checks <PR>` and capture the full output, and `gh pr view <PR> --json mergeable,mergeStateStatus`.
141
+ 2. If ANY required check is `fail` or `pending`, do NOT use happy-path language. Instead report each failing check by name with its error, each pending check by name, and the concrete fix you are about to apply.
142
+ 3. If `mergeStateStatus` is anything other than `CLEAN` or `BLOCKED` (blocked only by required-reviewer approval), investigate before claiming ready.
143
+ 4. If `gh` itself fails: report "status unknown — gh call failed", never assume green.
144
+ 5. Only when every required check is `pass` AND the PR is mergeable may you say "awaiting review" or "awaiting approval".
145
+
146
+ A summary like "awaiting UAT + 2 reviewers" reads to the developer as "nothing to do but approve." If a required check is red, that summary is a lie by omission — the PR cannot merge regardless of what the reviewer does.
147
+
148
+ ### Review Policy (Risk-Tiered)
149
+
150
+ - **LOW risk:** CI provides independent verification. Self-merge is permitted after all CI checks pass.
151
+ - **MEDIUM/HIGH risk:** A second human reviewer MUST approve before merge. Self-merge is NOT permitted.
152
+
153
+ ### Rules (NEVER break these)
154
+
155
+ - NEVER code without a GitHub Issue and requirement entry for tracked changes
156
+ - NEVER push without all four gates passing
157
+ - NEVER self-merge a MEDIUM or HIGH risk PR — a second human reviewer MUST approve
158
+ - NEVER use `--no-verify` to skip hooks
159
+ - NEVER commit secrets (.env, credentials, API keys)
160
+ - NEVER commit binary/JSON evidence to git — upload to DevAudit instead
161
+ - NEVER create a PR to main without UAT verification passing first (if UAT configured)
162
+ - NEVER push directly to main — always develop → PR → main
163
+ - NEVER skip Co-Authored-By when AI generates code
164
+ - NEVER proceed past a WAIT CHECKPOINT without developer confirmation
165
+ - NEVER describe a PR as "awaiting review" or "ready to merge" without first running `gh pr checks <PR>` and confirming every required check is `pass`
166
+ - ALWAYS commit compliance markdown to git (RTM, test-scope, implementation-plan, security-summary, release tickets)
167
+ - ALWAYS use merge commits (not squash) for develop → main