@metasession.co/devaudit-cli 0.1.0 → 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 +23 -11
  2. package/dist/index.js +21 -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,189 @@
1
+ ---
2
+ name: sdlc-implementer
3
+ description: Take a GitHub issue end-to-end through the Metasession SDLC. Use when the user wants to implement a single GitHub issue as a complete SDLC cycle — Phase 1 (classify risk, write implementation plan, update RTM) through Phase 4 (open PR, request UAT review on the portal), then halt; and Phase 5 (merge, post-deploy smoke evidence, mark Released, or change-request loop) on resume. Trigger phrases — "implement issue #N under the SDLC", "run the SDLC for issue #N", "automate REQ-XXX from issue to release", "do the SDLC stages for [issue]". Resume phrase — "resume REQ-XXX". MUST delegate end-to-end and visual-regression test work to the e2e-test-engineer skill in Phase 2; never authors e2e tests directly. Do NOT use for partial work — for stage-1 planning only, run the manual walkthrough; for test work alone, invoke e2e-test-engineer directly.
4
+ tags: [sdlc, orchestration, compliance, automation]
5
+ ---
6
+
7
+ # SDLC implementer
8
+
9
+ Take a single GitHub issue end-to-end through the Metasession SDLC. One command runs Phase 1 through Phase 4 unattended (with a plan-approval pause for HIGH/CRITICAL risk); the human enters the loop at the UAT review gate on the portal. On resume, the skill runs Phase 5 — merge, post-deploy smoke evidence, mark the release Released, or address change-requests and re-submit for UAT re-review.
10
+
11
+ This is an **orchestration skill**. It drives Claude Code's native tools (`gh`, shell, the `devaudit` CLI, the portal API) through the framework's existing stage docs, and it **MUST invoke the [`e2e-test-engineer`](../e2e-test-engineer/SKILL.md) skill** for any end-to-end or visual-regression test work in Phase 2. It does not author e2e tests directly.
12
+
13
+ ## Scope
14
+
15
+ **In scope**
16
+
17
+ - Taking one GitHub issue from triage to merged-and-deployed, under the project's existing SDLC framework.
18
+ - Risk classification per [`Test_Policy.md`](../../Test_Policy.md) §Risk-Based Testing.
19
+ - Authoring `compliance/plans/REQ-XXX/implementation-plan.md` per the stage-1 template.
20
+ - Updating `compliance/RTM.md`.
21
+ - Implementation, unit/integration tests, quality gates.
22
+ - Evidence capture and upload to the portal via `devaudit push`.
23
+ - PR opening, UAT review request, change-request loop, merge, post-deploy verification, release finalisation.
24
+
25
+ **Out of scope**
26
+
27
+ - Issues that decompose into multiple requirements — refuse at Phase 1 and ask the user to split.
28
+ - Stage-1 planning in isolation — run the manual walkthrough instead.
29
+ - E2E or visual-regression test work in isolation — invoke `e2e-test-engineer` directly.
30
+ - Cross-issue refactors that touch multiple REQ-XXX scopes — these are out of the one-issue contract.
31
+ - Onboarding a new consumer — that's `devaudit install`, a different command entirely.
32
+
33
+ ## Sub-skill invocation contract
34
+
35
+ The orchestrator MUST invoke `e2e-test-engineer` for end-to-end and visual-regression test work in Phase 2. This is a hard contract:
36
+
37
+ - Never author e2e tests directly.
38
+ - Never transcribe `e2e-test-engineer`'s six-phase workflow into this skill's body.
39
+ - Call via the standard Claude Code Skill mechanism (`Skill(name: "e2e-test-engineer", …)`).
40
+
41
+ Unit-test and integration-test work stays with this skill until a counterpart unit-test skill ships. The full sub-skill call graph lives at [`references/call-graph.md`](./references/call-graph.md).
42
+
43
+ ## The workflow
44
+
45
+ Five phases. Phases 1–4 run in one Claude Code session; Phase 5 is invoked separately by the user after UAT.
46
+
47
+ ### Phase 1 — Plan (SDLC stage 1)
48
+
49
+ 1. **Fetch the issue.** `gh issue view <N>` — read the title, body, and all comments.
50
+ 2. **Classify risk** per `Test_Policy.md` §Risk-Based Testing. Emit a one-paragraph rationale citing the signals you used (auth surface, financial calc, data egress, RBAC, AI decisioning, etc.).
51
+ 3. **Assign REQ-XXX.** Inspect `compliance/RTM.md` for existing entries; take the next free number. If the issue references an existing REQ, use that instead.
52
+ 4. **Detect over-scoping.** If the issue spans clearly distinct deliverables (e.g. "build SAML SSO + reorganise the admin dashboard + migrate from Postgres 14 to 16"), halt with a clear message asking the user to split the issue into separate ones. Do not proceed past Phase 1.
53
+ 5. **Write the implementation plan.** Create `compliance/plans/REQ-XXX/implementation-plan.md` per the stage-1 template (sections: context, acceptance criteria, technical approach, security considerations, dependencies, test scope). For HIGH/CRITICAL also include: threat model (against STRIDE categories applicable to the touched surfaces), four-eyes attestation slot, rollback plan.
54
+ 6. **Update `compliance/RTM.md`** with the new entry: REQ-XXX, title, risk class, linked issue, linked test cases (placeholder).
55
+ 7. **Post plan summary as an issue comment.** Format: TL;DR; Risk class + signals; Acceptance criteria; Technical approach (one paragraph); Dependencies; Test scope.
56
+ 8. **Checkpoint** — pause for human approval **iff** risk class is HIGH or CRITICAL. LOW and MEDIUM pass through to Phase 2 automatically. The checkpoint can be forced on for all classes via the `--require-plan-approval` flag (or `DEVAUDIT_REQUIRE_PLAN_APPROVAL=1` env var) for orgs that want it always-on.
57
+
58
+ ### Phase 2 — Implement and test (SDLC stage 2)
59
+
60
+ 1. **Branch off `develop`.** `git checkout -b feat/REQ-XXX-<slug>`. The slug is a kebab-case fragment of the issue title (max 6 words).
61
+ 2. **Write failing tests first** per [`Test_Architecture.md`](../../Test_Architecture.md). Depth scales with risk class:
62
+ - LOW — unit tests on the changed function(s); no e2e required unless the change touches a user-facing flow.
63
+ - MEDIUM — unit + integration; e2e for any UI-facing change.
64
+ - HIGH — unit + integration + e2e for every user-visible path + at least one negative/abuse test.
65
+ - CRITICAL — HIGH plus targeted security tests (authz bypass attempts, input fuzzing where applicable).
66
+ 3. **For any e2e or visual-regression test work in this step, invoke `e2e-test-engineer`** — do not author e2e tests directly. The orchestrator passes the implementation plan + the diff so far to the e2e-test-engineer skill, which derives scenarios, reconciles with the existing pack, and runs the suite.
67
+ 4. **Implement against the plan.** Reference `compliance/plans/REQ-XXX/implementation-plan.md` as you go. Any deviation from the plan must be noted in the plan itself under a `## Plan deviation` section — never silently diverge.
68
+ 5. **Run all gates locally** before pushing:
69
+ - `npm run lint` (or stack-adapter equivalent)
70
+ - `npx tsc --noEmit` (or stack-adapter equivalent)
71
+ - `npx vitest run` (unit/integration)
72
+ - `npx playwright test` (e2e — delegated to `e2e-test-engineer`)
73
+ - `semgrep scan --config auto`
74
+ - `npm audit --audit-level=high` (or stack-adapter equivalent)
75
+ 6. **On gate failure**, iterate up to N=3 attempts. Each iteration: read the failure output, propose a fix, apply, re-run. On exhausted attempts, halt with the full failure output and surface to the human — never use `--no-verify`, `eslint-disable`, `@ts-expect-error`, `xfail`, or any other bypass.
76
+ 7. **Commit** using Conventional Commits with `Ref: REQ-XXX` trailer and `Co-Authored-By: Claude` trailer. One commit per logical step; never amend a commit that's already been pushed.
77
+ 8. **Push** to the feature branch. No PR yet — that happens in Phase 4.
78
+
79
+ ### Phase 3 — Compile evidence (SDLC stage 3)
80
+
81
+ 1. **Re-run the full test pack** with artefact capture:
82
+ - `npm run test:e2e -- --reporter=html` (produces `playwright-report/`)
83
+ - `npx vitest run --coverage` (produces `coverage/`)
84
+ 2. **Organise artefacts** under `compliance/evidence/REQ-XXX/` with date-prefixed naming:
85
+ ```
86
+ compliance/evidence/REQ-XXX/
87
+ ├── YYYY-MM-DD_e2e-results.json
88
+ ├── YYYY-MM-DD_playwright-report/
89
+ ├── YYYY-MM-DD_unit-coverage/
90
+ └── YYYY-MM-DD_screenshots/*.png
91
+ ```
92
+ 3. **Upload each artefact to the portal**:
93
+ ```bash
94
+ devaudit push <project-slug> REQ-XXX <evidence-type> <file> \
95
+ --release "v$(date +%Y.%m.%d)" --create-release-if-missing \
96
+ --environment uat --category testing \
97
+ --git-sha "$(git rev-parse HEAD)" \
98
+ --branch "$(git rev-parse --abbrev-ref HEAD)"
99
+ ```
100
+ Evidence types: `screenshot`, `e2e_result`, `test_report`, `audit_log`, `compliance_document`, `manual_upload`.
101
+ 4. **Verify uploads landed.** `gh api` or `curl` against `https://devaudit.metasession.co/projects/<slug>/requirements/REQ-XXX/evidence` should show every artefact.
102
+ 5. **Update `compliance/RTM.md`** with portal links for each evidence row.
103
+
104
+ ### Phase 4 — Submit for UAT review (SDLC stage 4)
105
+
106
+ 1. **Open the PR.** `gh pr create --base main --head <branch>`. PR body per the SDLC PR template (see [`.github/pull_request_template.md`](../../../../../.github/pull_request_template.md)):
107
+ - Closes #N
108
+ - REQ-XXX
109
+ - Risk: <class>
110
+ - Evidence: `https://devaudit.metasession.co/projects/<slug>/requirements/REQ-XXX`
111
+ - For HIGH/CRITICAL: Four-eyes attestation: `@<reviewer-username>`
112
+ - For HIGH/CRITICAL: Rollback plan: reference to `compliance/plans/REQ-XXX/implementation-plan.md` §Rollback
113
+ - Test plan
114
+ - SDLC checklist
115
+ 2. **Verify the UAT reviewer ≠ skill-trigger user** for HIGH/CRITICAL. If they match, halt with a configuration error: "HIGH/CRITICAL risk requires an independent UAT reviewer; the configured reviewer matches the trigger user — fix the four-eyes attestation slot in the implementation plan and re-run."
116
+ 3. **Apply labels** — `awaiting-uat-review`, `risk:<class>`.
117
+ 4. **Comment on the issue**: "Implementation complete. PR #M opened. Evidence on portal: <link>. UAT review requested. Resume with `resume REQ-XXX` once UAT approval is granted on the portal."
118
+ 5. **Hard stop.** Phase 4 ends here. Do not proceed to merge; the human's next action is reviewing on the portal.
119
+
120
+ ### Phase 5 — Finalise or change-request loop (SDLC stage 5)
121
+
122
+ Invoked separately by the user after UAT activity on the portal. Trigger: "resume REQ-XXX", "REQ-XXX UAT done", or just re-firing the skill on the same issue.
123
+
124
+ 1. **Read portal state.** `curl` `https://devaudit.metasession.co/api/projects/<slug>/releases/<version>` and inspect the approval status.
125
+
126
+ 2. **Branch on state:**
127
+
128
+ - **UAT approved** → run stage 5:
129
+ - `gh pr merge <M> --merge` (merge commit; `--squash` and `--rebase` are blocked by branch protection on SDLC repos and would break the audit trail).
130
+ - Watch `post-deploy-prod.yml` via `gh run watch` — block until the workflow reaches a terminal state.
131
+ - Verify production smoke evidence uploaded (`--environment production`) at `https://devaudit.metasession.co/projects/<slug>/releases/<version>`.
132
+ - Mark release as `Released` via portal API: `PATCH /releases/<version>` with `{"status": "released"}`.
133
+ - Comment on the issue: "Released. Production smoke evidence: <link>."
134
+ - Close the issue.
135
+ - If production smoke fails: do NOT mark as Released. File an `[INCIDENT]` defect issue, page the on-call per the project's incident playbook, follow the rollback plan from the implementation plan.
136
+
137
+ - **Changes requested** → run change-request loop:
138
+ - Fetch change-request comments from the PR (`gh pr view <M> --comments`) and from the portal release page.
139
+ - Add a new `## Change-request iteration N` section to `compliance/plans/REQ-XXX/implementation-plan.md` describing what changed and why.
140
+ - Re-run Phase 2 (implement + test) for the requested changes — same delegation to `e2e-test-engineer` for any e2e work.
141
+ - Re-run Phase 3 (evidence) for the new/changed artefacts only; existing evidence stays.
142
+ - Push to the same branch (no force-push). The PR auto-updates.
143
+ - Re-request UAT review on the portal: `POST /api/projects/<slug>/releases/<version>/approval-requests`.
144
+ - Comment on the issue: "Change requests addressed in commits <SHAs>. UAT re-review requested."
145
+ - Hard stop again. The portal's release-approval state has reset; UAT must explicitly re-approve.
146
+
147
+ - **Still pending UAT (no approval, no change-request)** → report "UAT review still pending on the portal at <link>" and stop. Do not act.
148
+
149
+ ## Compliance constraints
150
+
151
+ Hard rules — the skill's SKILL.md fails review if any of these are violated. Audited against ISO 29119, ISO 27001, SOC 2, GDPR, and the EU AI Act; details in [`references/compliance-constraints.md`](./references/compliance-constraints.md).
152
+
153
+ 1. **Never skip the UAT review gate** for any risk class. The portal enforces this server-side via `check-release-approval.yml`; do not attempt to merge with that check still red.
154
+ 2. **For HIGH/CRITICAL, the skill MUST NOT act as the UAT approver.** Check at Phase 4 that the configured UAT reviewer differs from the skill-trigger user; halt with a configuration error otherwise. (SOC 2 CC8 — segregation of duties.)
155
+ 3. **Plan checkpoint mandatory for HIGH/CRITICAL.** LOW/MEDIUM pass through Phase 1 automatically; HIGH/CRITICAL pause for human plan approval before code is written.
156
+ 4. **Change-request loop triggers full UAT re-review.** The portal's release-approval state resets when new commits land on the PR — respect it. Surface a "UAT re-review needed" comment; never rely on prior approval covering subsequent changes.
157
+ 5. **AI involvement disclosed on every commit** via `Co-Authored-By: Claude`. (ISO 27001 disclosure norms + EU AI Act Art. 13 transparency.)
158
+ 6. **All portal mutations through audit-logged APIs.** Use `devaudit push` and the standard portal-API endpoints — never a private back-channel.
159
+
160
+ Plus one process risk surfaced explicitly in the principles below (rubber-stamping at UAT). Not enforceable architecturally — the UAT reviewer is the load-bearing human.
161
+
162
+ ## Principles
163
+
164
+ **The UAT reviewer is the load-bearing human.** This skill makes it easy to produce many releases per day. The control regime depends on the UAT reviewer actually reading what they're approving. If the human approves without reviewing, the controls are formally satisfied but substantively broken — auditors will notice. Where possible, the UAT reviewer should be a different human from the skill-trigger user (mandatory for HIGH/CRITICAL).
165
+
166
+ **Never bypass a gate to ship faster.** No `--no-verify`. No `eslint-disable`. No `@ts-expect-error`. No `xfail`. No "we'll fix it in the next PR." If a gate is structurally wrong for this change, halt and surface the blocker — fix the gate, not the bypass.
167
+
168
+ **The implementation plan is the source of truth, not a one-shot artefact.** When implementation deviates from the plan (and it will), update the plan in place under a `## Plan deviation` section. The plan documents intent + reality; the RTM, the evidence, and the PR all reference it.
169
+
170
+ **Never close the issue until Phase 5 completes.** An issue closed at Phase 4 (PR opened) loses its tie to the release outcome. Closure is the signal that the change is Released; don't generate that signal prematurely.
171
+
172
+ **Never mark a release as Released without verifying production smoke evidence on the portal.** "The post-deploy workflow ran" is not the same as "production smoke evidence is on the portal." Verify the artefact landed before flipping the status.
173
+
174
+ **Confirm before destructive operations.** Force-pushing, branch deletion, tag deletion, `git reset --hard`, modifying CI/CD pipelines — all need explicit user sign-off when they arise mid-skill. The cost of confirming is a sentence; the cost of getting it wrong is real.
175
+
176
+ **Issue too big? Refuse at Phase 1.** If the issue spans multiple distinct deliverables, the right answer is "split this issue" — not "sub-divide into multiple REQs silently". Halt at Phase 1 with the proposed split for the user to confirm.
177
+
178
+ **Ambiguity is a question, not a guess.** If the issue is unclear about scope, acceptance criteria, or which subsystem is affected, ask. Implementing on guesses is worse than no implementation — it encodes the misunderstanding into evidence and the audit trail.
179
+
180
+ ## References
181
+
182
+ - [`references/compliance-constraints.md`](./references/compliance-constraints.md) — the six architectural constraints + the process risk, audited per framework.
183
+ - [`references/call-graph.md`](./references/call-graph.md) — sub-skill invocation map; what `sdlc-implementer` calls and when.
184
+ - [`references/change-request-loop.md`](./references/change-request-loop.md) — Phase 5 change-request flow in detail, including portal-state semantics.
185
+ - [`../e2e-test-engineer/SKILL.md`](../e2e-test-engineer/SKILL.md) — the test-work sub-skill this orchestrator delegates to.
186
+ - [`SKILLS.md`](../../../../SKILLS.md) — skill contract and conventions for the framework.
187
+ - Portal: `docs/implementing-an-sdlc-issue.md` — the user-facing walkthrough this skill automates. (Lives in the portal repo, currently private; the synced framework copy at `sdlc/files/_common/implementing-an-sdlc-issue.md` is the consumer-visible equivalent.)
188
+ - Portal: `docs/standards-coverage.md` — which SDLC artefacts satisfy which compliance clauses. (Same: portal repo, currently private.)
189
+ - [`metasession-dev/DevAudit-Installer#29`](https://github.com/metasession-dev/DevAudit-Installer/issues/29) — the umbrella issue tracking this skill's delivery.
@@ -0,0 +1,64 @@
1
+ # Sub-skill call graph
2
+
3
+ The `sdlc-implementer` skill is an orchestrator. It calls into other shipped skills rather than re-implementing their procedures. This document is the authoritative map of when and why each sub-skill is invoked.
4
+
5
+ ## Skills `sdlc-implementer` invokes today
6
+
7
+ ### `e2e-test-engineer` — Phase 2 (Implement and test)
8
+
9
+ **When**: Any time Phase 2's test-writing step needs end-to-end or visual-regression tests. The risk-class depth table (LOW / MEDIUM / HIGH / CRITICAL) determines whether e2e tests are needed; whenever they are, `e2e-test-engineer` writes them.
10
+
11
+ **Invocation**: `Skill(name: "e2e-test-engineer", input: { issue: "#N", req: "REQ-XXX", plan_path: "compliance/plans/REQ-XXX/implementation-plan.md", diff: <branch diff> })`.
12
+
13
+ **Hard contract** (per [`SKILL.md`](../SKILL.md) §Sub-skill invocation contract):
14
+
15
+ - The orchestrator never authors e2e tests directly.
16
+ - The orchestrator never transcribes `e2e-test-engineer`'s six-phase workflow into its own body.
17
+ - SKILL.md review for `sdlc-implementer` fails if e2e test-authoring logic is inlined.
18
+
19
+ **Why hard-contract**: `e2e-test-engineer` exists, works, and has been smoke-tested. Re-implementing its scenario-derivation logic inside an orchestrator would (a) drift over time, (b) double the maintenance burden, (c) miss the orchestrator-skill-pattern intended for the framework.
20
+
21
+ **What `sdlc-implementer` retains responsibility for in Phase 2**:
22
+
23
+ - Branching off `develop`.
24
+ - Risk-class-based depth selection (deciding _whether_ e2e is needed at all).
25
+ - Unit + integration test writing (these stay with the orchestrator until a counterpart unit-test skill ships).
26
+ - Running all gates (the orchestrator owns the gate execution; `e2e-test-engineer` may have already run the e2e portion).
27
+ - Iterating on gate failures up to N=3 attempts.
28
+ - Committing.
29
+ - Pushing.
30
+
31
+ ## Skills `sdlc-implementer` does NOT invoke
32
+
33
+ These were previously planned as atomic skills but were deprioritised. The orchestrator handles their slice directly, without calling out:
34
+
35
+ | Deprecated atomic skill | What the orchestrator does instead |
36
+ | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
37
+ | `risk-classifier` | Phase 1 step 2 — orchestrator reads `Test_Policy.md` directly and classifies risk, emitting the signals it used. |
38
+ | `commit-message-author` | Phase 2 step 7 — orchestrator generates the Conventional Commits message from the staged diff + branch name + RTM entry. |
39
+ | `compliance-evidence-author` | Phase 3 — orchestrator drives the test pack, organises artefacts, uploads via `devaudit push`, updates the RTM. |
40
+ | `sast-triager` | Phase 2 step 5 — `semgrep` runs as one of the gates; the orchestrator surfaces findings to the human at Phase 1 plan or halts in Phase 2. |
41
+ | `release-ticket-author` | Phase 4 step 1 — orchestrator drafts the PR body directly from the SDLC PR template + plan. |
42
+
43
+ If any of these surface in production as repeated pain (per [`SKILLS.md` §When to make a skill vs. when to keep something in a stage doc](../../../../SKILLS.md#when-to-make-a-skill-vs-when-to-keep-something-in-a-stage-doc)), they may be lifted into atomic skills later. The orchestrator would then delegate to them — same pattern as it does today for `e2e-test-engineer`.
44
+
45
+ ## Skills the orchestrator may invoke once they exist
46
+
47
+ Future expansion. Not committed; listed so the call graph is forward-readable.
48
+
49
+ - **`unit-test-engineer`** (planned via real-need driver) — would take over Phase 2's unit/integration test writing. The orchestrator's Phase 2 step 2 would invoke this skill the same way it invokes `e2e-test-engineer` today.
50
+ - **`incident-responder`** (planned via real-need driver) — would handle the "production smoke failed in Phase 5" branch. Today the orchestrator falls back to filing an `[INCIDENT]` issue + paging on-call per the project's playbook.
51
+
52
+ When/if these ship, the call graph in this file gets updated alongside the orchestrator's SKILL.md.
53
+
54
+ ## Skills that invoke `sdlc-implementer`
55
+
56
+ None. The orchestrator is a top-level entry point — it's invoked directly by the user ("implement issue #N under the SDLC") and runs the framework's stages. It is not designed to be a sub-skill of another orchestrator.
57
+
58
+ ## Invocation discipline
59
+
60
+ Three rules every orchestrator → sub-skill call should follow:
61
+
62
+ 1. **Pass the minimum context the sub-skill needs.** `e2e-test-engineer` needs the implementation plan + diff; it does not need the orchestrator's full state. Over-passing context bloats the sub-skill's working memory and slows it down.
63
+ 2. **Trust the sub-skill's return contract.** If `e2e-test-engineer` says it added 3 tests and they all pass, the orchestrator does not re-verify the assertion. The sub-skill is the authority for its slice.
64
+ 3. **Surface sub-skill failures to the human at the orchestrator level.** If `e2e-test-engineer` halts because the project's test framework can't be detected, that's an orchestrator-level halt — the user sees one clear "I couldn't proceed because…" message, not a stack of nested skill output.
@@ -0,0 +1,192 @@
1
+ # Phase 5 — change-request loop in detail
2
+
3
+ When UAT review at Phase 4 ends in "changes requested" instead of "approved", `sdlc-implementer` enters the change-request loop. This document is the long-form spec for that loop, the portal-state semantics it relies on, and the discipline that keeps re-iterations compliant.
4
+
5
+ The happy path (UAT approved → Phase 5 merge + finalise) is covered in [`SKILL.md` §Phase 5 — Finalise or change-request loop](../SKILL.md#phase-5--finalise-or-change-request-loop). This file goes deeper on the change-request branch.
6
+
7
+ ## Portal-state semantics
8
+
9
+ The portal's release-approval state machine for a release tied to REQ-XXX:
10
+
11
+ ```
12
+ draft
13
+ └─→ uat_review (CI registers the release on develop push)
14
+ ├─→ uat_approved (reviewer clicks Approve on the portal)
15
+ ├─→ uat_changes_requested (reviewer clicks Request Changes, leaves comments)
16
+ └─→ uat_rejected (rare — reviewer marks the release fundamentally broken)
17
+
18
+ └─ on new commits to the linked PR branch, state resets to uat_review
19
+ ```
20
+
21
+ Critical: **state resets to `uat_review` on new commits**. This is server-side, not skill-side — the portal watches the branch SHA and clears the approval state when the SHA advances after a `changes_requested` event. The skill must not work around this.
22
+
23
+ ## The change-request loop
24
+
25
+ When the user runs `> Resume REQ-XXX` and the portal state is `uat_changes_requested`, the skill executes:
26
+
27
+ ### Step 1 — Fetch the change-request comments
28
+
29
+ Two sources to read:
30
+
31
+ 1. **PR comments** — `gh pr view <M> --comments --json comments,reviews --jq '.comments[].body, .reviews[].body'`. Includes line-level review comments and top-level discussion.
32
+ 2. **Portal release-page comments** — `curl https://devaudit.metasession.co/api/projects/<slug>/releases/<version>/comments`. Includes any comments the UAT reviewer left on the release card itself.
33
+
34
+ Both sources matter: PR comments are usually code-level; portal comments are usually about-the-release-as-a-whole.
35
+
36
+ ### Step 2 — Categorise the requested changes
37
+
38
+ For each requested change, mark it as one of:
39
+
40
+ - **Must address** — the reviewer is asking for a specific code/test/doc change.
41
+ - **Question** — the reviewer is asking for clarification, not asking for a code change.
42
+ - **Out of scope** — the reviewer is asking for something this REQ doesn't intend to deliver.
43
+
44
+ For Questions: post a reply on the PR or portal explaining; do NOT change code.
45
+ For Out-of-scope items: post a reply proposing a follow-up issue; do NOT silently expand REQ-XXX.
46
+ For Must-address items: collect into a delta-plan section.
47
+
48
+ ### Step 3 — Add a delta-plan section to the implementation plan
49
+
50
+ Append a new section to `compliance/plans/REQ-XXX/implementation-plan.md`:
51
+
52
+ ```markdown
53
+ ## Change-request iteration N
54
+
55
+ **Reviewer**: @<username>
56
+ **Requested**: <YYYY-MM-DD>
57
+ **Iteration**: N
58
+
59
+ ### Requested changes
60
+
61
+ - [ ] <bullet per Must-address item, with link to the comment that prompted it>
62
+
63
+ ### Approach
64
+
65
+ <one-paragraph technical approach for addressing the items>
66
+
67
+ ### Test scope delta
68
+
69
+ <which existing tests need updates, which new tests are needed, whether the change touches any new acceptance criteria>
70
+
71
+ ### Plan deviations
72
+
73
+ <if the change reveals the original plan was wrong about something, note it here>
74
+ ```
75
+
76
+ This section is append-only — never rewrite a prior iteration's delta-plan section.
77
+
78
+ ### Step 4 — Re-run Phase 2 (Implement and test)
79
+
80
+ For the Must-address items only:
81
+
82
+ - Make the code changes
83
+ - Update existing tests or add new ones — **delegating any e2e/visual-regression test work to `e2e-test-engineer`** (the sub-skill invocation contract still applies in iteration N).
84
+ - Re-run all gates locally; gate-failure iteration cap (N=3 attempts) applies per gate.
85
+ - Commit with `Ref: REQ-XXX` + `Co-Authored-By: Claude` + a body that calls out the change-request iteration:
86
+
87
+ ```
88
+ fix(REQ-XXX): address UAT iteration N — <one-line summary>
89
+
90
+ Iteration N change-request items:
91
+ - <bullet, link to comment>
92
+ - <bullet, link to comment>
93
+
94
+ Ref: REQ-XXX
95
+ Co-Authored-By: Claude <noreply@anthropic.com>
96
+ ```
97
+
98
+ ### Step 5 — Re-run Phase 3 (Compile evidence) — partial
99
+
100
+ Re-run the test suite that the change affected. Capture new artefacts:
101
+
102
+ - New e2e results
103
+ - New unit coverage (if unit tests changed)
104
+ - New screenshots (if UI behaviour changed)
105
+
106
+ Upload via `devaudit push` **with `--iteration N`** so the portal records this evidence as iteration-tagged:
107
+
108
+ ```bash
109
+ devaudit push <slug> REQ-XXX <type> <file> \
110
+ --release "<version>" \
111
+ --environment uat --category testing \
112
+ --iteration N \
113
+ --git-sha "$(git rev-parse HEAD)"
114
+ ```
115
+
116
+ (If the `--iteration` flag doesn't exist on the consumer's `devaudit` CLI version, fall back to encoding the iteration into the filename: `compliance/evidence/REQ-XXX/YYYY-MM-DD_iter-N_<artefact>`. The portal renders it the same way.)
117
+
118
+ **Existing evidence stays.** Iteration N adds; it does not replace. The audit trail wants to see what each iteration's evidence looked like.
119
+
120
+ ### Step 6 — Push to the same branch
121
+
122
+ `git push` — no `--force`. The PR auto-updates.
123
+
124
+ The portal's release-approval state automatically resets to `uat_review` on the new SHA. Do not call the portal API to re-trigger this; the state machine handles it.
125
+
126
+ ### Step 7 — Re-request UAT review explicitly
127
+
128
+ Even though state has reset, the reviewer needs notification. Two actions:
129
+
130
+ 1. **Portal API**: `POST https://devaudit.metasession.co/api/projects/<slug>/releases/<version>/approval-requests` with `{"iteration": N, "summary": "Change-request iteration N addressed"}`. This notifies the reviewer on their portal dashboard.
131
+ 2. **PR comment**: post a summary comment on the PR linking to the new commits and the iteration-N evidence on the portal:
132
+
133
+ ```
134
+ Change-request iteration N addressed in <SHA>..<SHA>.
135
+
136
+ Items addressed:
137
+ - <bullet, link to original comment>
138
+ - <bullet, link to original comment>
139
+
140
+ Updated evidence: https://devaudit.metasession.co/projects/<slug>/requirements/REQ-XXX (filter by iteration N)
141
+
142
+ @<reviewer-username> — UAT re-review requested.
143
+ ```
144
+
145
+ ### Step 8 — Hard stop
146
+
147
+ The skill halts. The human's next move is reviewing the iteration N changes on the portal. The skill does NOT advance to merge.
148
+
149
+ ## Iteration discipline
150
+
151
+ A few rules that keep iteration N+1 distinguishable from iteration N:
152
+
153
+ - **One iteration per UAT cycle**, not one per commit. If the reviewer asks for three changes, address all three in iteration N, push once, request re-review once. Don't fire iteration boundaries per commit.
154
+ - **Cap at 5 iterations** as a heuristic. If a REQ goes through 5+ iterations without converging, the original plan was probably wrong — halt and ask the user whether to abandon the REQ, split it, or restart from a fresh plan.
155
+ - **Never rewrite the original plan's body** in response to iteration feedback. Use the delta-plan sections; the original plan stays as a historical record of what was first proposed.
156
+ - **Iteration commits are still SDLC-conformant.** Conventional Commits format, `Ref: REQ-XXX`, `Co-Authored-By: Claude`, all gates green locally. No exceptions because "it's just a fix to the previous iteration."
157
+
158
+ ## If the change-request is fundamentally a different REQ
159
+
160
+ Sometimes a reviewer's change-request is so large it constitutes a new requirement, not an iteration on this one. Examples:
161
+
162
+ - Reviewer asks for an entire new acceptance criterion that wasn't in the original issue.
163
+ - Reviewer asks for a refactor of a subsystem the REQ doesn't touch.
164
+ - Reviewer asks for backwards-compatibility for a deprecated path the REQ removes.
165
+
166
+ In these cases:
167
+
168
+ 1. Halt with a clear message: "This change-request expands scope beyond REQ-XXX as originally planned. Recommend filing a separate issue for <subject> and addressing only the in-scope items in iteration N of this REQ."
169
+ 2. Wait for the user to confirm the split.
170
+ 3. Address only the in-scope items in iteration N; the user opens the separate issue, which becomes a new `sdlc-implementer` invocation.
171
+
172
+ The principle: REQ-XXX has a defined scope at Phase 1. Iterations refine within scope. Iterations are not scope-creep windows.
173
+
174
+ ## If the change-request is a rejection
175
+
176
+ If the portal state is `uat_rejected` (not `uat_changes_requested`), the reviewer has marked the release fundamentally broken. The skill should:
177
+
178
+ 1. Halt the change-request loop. Do not attempt to address.
179
+ 2. Post on the issue: "UAT rejected this release. Awaiting user direction — options are to (a) close the PR and re-plan from scratch, (b) escalate the rejection to a different reviewer, or (c) appeal the rejection with new context."
180
+ 3. Wait for the user to decide. The skill does not unilaterally reopen, force-merge, or escalate.
181
+
182
+ ## Summary
183
+
184
+ The change-request loop preserves the controls a one-shot approval cycle would skip. Every iteration:
185
+
186
+ - Documents what the reviewer asked for.
187
+ - Documents what was changed and why.
188
+ - Captures fresh evidence tagged by iteration.
189
+ - Triggers an explicit UAT re-review on the portal.
190
+ - Maintains the full audit trail.
191
+
192
+ By doing so, even REQs that take five iterations to land have the same compliance posture as REQs that pass UAT on the first try.
@@ -0,0 +1,81 @@
1
+ # Compliance constraints (per framework)
2
+
3
+ The `sdlc-implementer` skill was audited against the five compliance frameworks DevAudit is designed to support. No framework breaks structurally; six architectural constraints + one process risk preserve the controls each framework expects. This document is the long-form audit.
4
+
5
+ The constraints are enforced in `SKILL.md` and in the smoke pass. Where applicable, the portal itself enforces them server-side as a defence-in-depth measure.
6
+
7
+ ## The six architectural constraints
8
+
9
+ ### 1. Never skip the UAT review gate
10
+
11
+ | | |
12
+ |---|---|
13
+ | **What** | The skill must not attempt to merge a PR while the `DevAudit Release Approval` check is red. |
14
+ | **Why (framework)** | ISO 27001 A.8.32 (Change management); SOC 2 CC8 (Change management); EU AI Act Art. 14 (Human oversight). The UAT gate is the load-bearing human-oversight checkpoint. |
15
+ | **Enforcement** | Portal-side via `check-release-approval.yml` workflow status check + branch protection. Skill-side: never call `gh pr merge` until the check is green. |
16
+ | **Failure mode if violated** | Merge bypasses human review entirely. Auditor's question "did a human approve this change?" cannot be answered with evidence. |
17
+
18
+ ### 2. For HIGH/CRITICAL, never act as the UAT approver
19
+
20
+ | | |
21
+ |---|---|
22
+ | **What** | The skill must verify at Phase 4 that the configured UAT reviewer (in `compliance/plans/REQ-XXX/implementation-plan.md` §Four-eyes attestation slot) differs from the skill-trigger user. If they match, halt. |
23
+ | **Why (framework)** | SOC 2 CC8.1 — segregation of duties; ISO 27001 A.5.15 (Access control — duty segregation). The change-author cannot also be the change-approver for higher-risk work. |
24
+ | **Enforcement** | Portal-side: the release-approval API rejects self-approval for MEDIUM/HIGH/CRITICAL risk classes. Skill-side: refuses to open the PR if the configured reviewer matches the trigger user. |
25
+ | **Failure mode if violated** | One human approves their own work. The four-eyes principle is paper-only. |
26
+
27
+ ### 3. Plan checkpoint mandatory for HIGH/CRITICAL
28
+
29
+ | | |
30
+ |---|---|
31
+ | **What** | At Phase 1 step 8, the skill pauses for human approval of the plan **iff** risk class is HIGH or CRITICAL. LOW/MEDIUM pass through automatically. Can be forced on for all classes via `--require-plan-approval` flag or `DEVAUDIT_REQUIRE_PLAN_APPROVAL=1` env var. |
32
+ | **Why (framework)** | EU AI Act Art. 14 (Human oversight for high-risk AI systems); SOC 2 CC3 (Risk assessment requires human judgement); ISO 29119 §6 (Test management — planning is a documented human step). For HIGH/CRITICAL work the plan IS the design — human review must precede code. |
33
+ | **Enforcement** | Skill-side. Phase 1 explicitly halts and waits for the human's "go" before Phase 2. |
34
+ | **Failure mode if violated** | Code is written + tests are designed + evidence is captured for a HIGH/CRITICAL change without a single human-checkpointed plan. Auditor cannot evidence the design step. |
35
+
36
+ ### 4. Change-request loop triggers full UAT re-review
37
+
38
+ | | |
39
+ |---|---|
40
+ | **What** | When new commits land on a PR after a UAT change-request, the portal's release-approval state resets. The skill respects the reset, surfaces a "UAT re-review needed" comment, and never assumes the prior approval still covers the new changes. |
41
+ | **Why (framework)** | ISO 27001 A.14.2.4 (Restrictions on changes to software packages — each change goes through controls); SOC 2 CC8.1 (Each change requires approval). Treating "approval given once, all subsequent commits inherit it" would make UAT a one-shot rubber-stamp. |
42
+ | **Enforcement** | Portal-side: the release-approval state machine resets on new commits to the linked branch. Skill-side: re-requests review explicitly via the portal API after each change-request iteration. |
43
+ | **Failure mode if violated** | Drive-by changes ship under cover of an old approval. The audit trail shows "approved once" — but the approved diff is not the diff that shipped. |
44
+
45
+ ### 5. AI involvement disclosed on every commit
46
+
47
+ | | |
48
+ |---|---|
49
+ | **What** | Every commit the skill creates carries a `Co-Authored-By: Claude <noreply@anthropic.com>` trailer (or equivalent for the specific Claude model in use). |
50
+ | **Why (framework)** | ISO 27001 — transparency norms; EU AI Act Art. 13 (Transparency and provision of information to deployers); GDPR Art. 22 (data subjects' right to know about automated decisions, where applicable). When an auditor traces a commit, the AI involvement must be visible. |
51
+ | **Enforcement** | Skill-side. Every `git commit` call includes the trailer. CI's `compliance-validation.yml` workflow can be configured to grep for `Co-Authored-By` on PRs labelled with the AI-touched marker; this is optional but recommended. |
52
+ | **Failure mode if violated** | AI-generated code is indistinguishable from human-authored code in the audit trail. Future-proofing against tightening AI-disclosure regulations breaks. |
53
+
54
+ ### 6. All portal mutations through audit-logged APIs
55
+
56
+ | | |
57
+ |---|---|
58
+ | **What** | The skill calls `devaudit push` and the standard portal HTTP APIs — never a database back-channel, never a service-role-key-equivalent that bypasses the audit log. |
59
+ | **Why (framework)** | ISO 27001 A.12.4 (Logging and monitoring); SOC 2 CC4 + CC7 (Monitoring activities + system operations). Every action that affects compliance state must produce an audit-log entry attributable to a human identity (the user whose PAT is in `DEVAUDIT_USER_TOKEN`). |
60
+ | **Enforcement** | Skill-side. All portal interaction goes through `devaudit push` or `curl`/`gh api` against the documented REST endpoints. |
61
+ | **Failure mode if violated** | Compliance-affecting actions land on the portal with no audit-log trail. Auditor's "who did this?" question is unanswerable. |
62
+
63
+ ## The one process risk
64
+
65
+ ### 7. Rubber-stamping at UAT
66
+
67
+ | | |
68
+ |---|---|
69
+ | **What** | If the UAT reviewer approves without actually reading the change, the controls are formally satisfied but substantively hollow. |
70
+ | **Why (framework)** | SOC 2 CC4.1 (Monitoring activities — the entity should detect this via its own QA sampling). Not enforced by any control mechanism; relies on human discipline. |
71
+ | **Enforcement** | Not architectural. Mitigations: the SKILL.md's Principles section names the UAT reviewer as "the load-bearing human"; the portal's UAT-review UI intentionally adds friction (no one-click approve from email); org policy should random-sample approvals for QA. |
72
+ | **Failure mode if violated** | Auditors detect approval velocity that doesn't match human reading time. Spot-checks reveal approvals on changes the approver couldn't articulate. Trust erodes. |
73
+
74
+ ## What's NOT a compliance break
75
+
76
+ Audited and cleared:
77
+
78
+ - **Audit log attribution** (ISO 27001 A.12.4): Actions flow through the user's tokens (`DEVAUDIT_USER_TOKEN`, `GH_TOKEN`); commits carry `Co-Authored-By`; UAT approval is a genuine human act recorded on the portal. The auditor's question "did this human review this?" is answered by the UAT-approval event on the portal, not by the commit signature.
79
+ - **GDPR Art. 22** (Automated decisions about data subjects): Doesn't apply. The skill makes technical decisions, not decisions about people. If the issue being implemented IS Art. 22 work (an algorithm that decides about data subjects), the implementation plan captures DPA/DPIA requirements at Phase 1 — same as today.
80
+ - **EU AI Act high-risk classification of the skill itself**: The skill is a productivity tool, not high-risk under Annex III. Art. 14 (Human oversight) is satisfied by the HIGH/CRITICAL plan checkpoint + the always-on UAT gate.
81
+ - **ISO 29119 test adequacy**: Human at UAT reviews test scope. Same caveat as #7 above — depends on UAT reviewer paying attention.