@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,130 @@
|
|
|
1
|
+
# Stack adapter contract
|
|
2
|
+
|
|
3
|
+
A stack adapter teaches the Metasession SDLC how to run quality gates and place hooks for one language / package-manager combination — `node`, `python`, `go`, `rust`, etc. Each adapter is a single directory under `sdlc/files/stacks/` containing:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
sdlc/files/stacks/<name>/
|
|
7
|
+
├── adapter.json ← the manifest (validated against the schema)
|
|
8
|
+
├── hooks/ ← git-hook files placed in consumers
|
|
9
|
+
└── scripts/ ← stack-specific helper scripts
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The manifest is the contract. The directory contents are referenced from the manifest by filename.
|
|
13
|
+
|
|
14
|
+
The schema lives at [`sdlc/files/stacks/_schema/adapter.schema.json`](./files/stacks/_schema/adapter.schema.json) (JSON Schema draft-07). The validator is `scripts/validate-adapter.cjs`; CI runs `node scripts/validate-adapter.cjs --all` on every push to `develop`.
|
|
15
|
+
|
|
16
|
+
## Required fields
|
|
17
|
+
|
|
18
|
+
### Identity
|
|
19
|
+
|
|
20
|
+
| Field | Type | Purpose |
|
|
21
|
+
| --------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `name` | string (`[a-z0-9][a-z0-9-]{0,31}`) | Identifier matching the parent directory and the `stack` key in consumer `sdlc-config.json`. |
|
|
23
|
+
| `description` | string | One-line human summary. |
|
|
24
|
+
| `manifest_file` | string | The dependency manifest the consuming project carries — `package.json`, `pyproject.toml`, `go.mod`. |
|
|
25
|
+
|
|
26
|
+
### Quality-gate commands
|
|
27
|
+
|
|
28
|
+
Every adapter declares six commands. Each must be runnable from the consumer's repo root. Exit-code semantics are part of the contract — downstream evaluation code (CI workflow templates, evidence-upload script) relies on them.
|
|
29
|
+
|
|
30
|
+
> **Note (v1.23.0 transitional state).** The six commands and `evidence_paths` are declared in every adapter manifest, but `sdlc/files/ci/*.template` still has the Node values hardcoded for back-compat. Substituting these fields into the templates is Phase 4 of the polyglot architecture umbrella (portal repo issue #287, internal tracker); until then, changing the values in a Node adapter has no effect on generated workflows. A new (e.g. Python) adapter will land alongside the substitution refactor so the field becomes load-bearing the moment it's first different from Node.
|
|
31
|
+
|
|
32
|
+
| Field | Exit-0 means | Exit non-0 means |
|
|
33
|
+
| ------------ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
34
|
+
| `install` | dependencies fetched | fetch failed (network, registry auth) |
|
|
35
|
+
| `type_check` | 0 type errors | at least one type error |
|
|
36
|
+
| `sast` | scanner ran successfully | scanner crashed; **findings don't fail this command** — they are evaluated separately against `sast_baseline` |
|
|
37
|
+
| `dep_audit` | scanner ran successfully | scanner crashed; **findings don't fail this command** — they are evaluated separately against `accepted_dep_risks` |
|
|
38
|
+
| `test` | every test passed | at least one test failed |
|
|
39
|
+
| `build` | deployable artifact produced | build failed |
|
|
40
|
+
|
|
41
|
+
The distinction between `sast` / `dep_audit` (scanner-ran-cleanly) and `type_check` / `test` / `build` (gate-passed) is deliberate: it lets the templates report richer status — "scanner crashed" vs. "findings above baseline" — without conflating the two.
|
|
42
|
+
|
|
43
|
+
### Evidence paths
|
|
44
|
+
|
|
45
|
+
| Field | Type | Purpose |
|
|
46
|
+
| -------------------------- | ------ | ----------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `evidence_paths.sast` | string | Repo-relative path the `sast` command writes its JSON output to. |
|
|
48
|
+
| `evidence_paths.dep_audit` | string | Repo-relative path the `dep_audit` command writes its JSON output to. |
|
|
49
|
+
| `evidence_paths.test` | string | Repo-relative path the `test` command writes its results to (JUnit XML, Playwright JSON, etc.). |
|
|
50
|
+
|
|
51
|
+
The compliance-evidence upload workflow reads these to know what to publish to DevAudit. Adapters MUST write to these exact paths; consumers MUST NOT override them in `sdlc-config.json` (an override would break evidence visibility).
|
|
52
|
+
|
|
53
|
+
### Hooks
|
|
54
|
+
|
|
55
|
+
| Field | Type | Purpose |
|
|
56
|
+
| ------------------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `hook_framework` | enum (`husky`, `pre-commit`, `lefthook`, `cargo-husky`) | Which git-hooks framework the consumer uses. |
|
|
58
|
+
| `hook_install_dir` | string | Directory the framework manages (`.husky`, `.git/hooks`). Sync only writes hooks if the directory already exists in the consumer — projects opt in by bootstrapping the framework. |
|
|
59
|
+
| `hooks` | string[] | Hook filenames placed under `hook_install_dir/`. Each must exist at `sdlc/files/stacks/<name>/hooks/<filename>`. |
|
|
60
|
+
| `hook_config_files` | string[] | Framework config files placed at the consumer's repo root — `commitlint.config.mjs` for husky+commitlint, `.pre-commit-config.yaml` for pre-commit. |
|
|
61
|
+
|
|
62
|
+
### Runtime setup
|
|
63
|
+
|
|
64
|
+
| Field | Type | Purpose |
|
|
65
|
+
| ---------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `runtime_setup.action` | string (`<owner>/<repo>@v<N>`) | GitHub Actions reference that installs the language runtime — `actions/setup-node@v4`, `actions/setup-python@v5`. |
|
|
67
|
+
| `runtime_setup.with` | object | `with:` inputs for the action. Token substitution applies — e.g. `{ "node-version": "{{NODE_VERSION}}" }` pulls `node_version` from `sdlc-config.json` at sync time. |
|
|
68
|
+
|
|
69
|
+
## Optional fields
|
|
70
|
+
|
|
71
|
+
| Field | Type | Purpose |
|
|
72
|
+
| --------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `stack_scripts` | string[] | Stack-specific helpers copied to the consumer's `scripts/` directory. Each must exist at `sdlc/files/stacks/<name>/scripts/<filename>`. |
|
|
74
|
+
| `required_dev_dependencies` | string[] | Dev-time deps the adapter expects to be present. Sync may auto-install or warn. |
|
|
75
|
+
| `config_keys.required` | string[] | `sdlc-config.json` keys this stack consumes. Sync refuses if a required key is missing. |
|
|
76
|
+
| `config_keys.defaults` | object | Fallback values for keys that may be omitted from `sdlc-config.json`. |
|
|
77
|
+
|
|
78
|
+
## Consumer config: `working_directory`
|
|
79
|
+
|
|
80
|
+
For projects where the stack's dependency manifest (e.g. `pyproject.toml`, `package.json`) lives in a subdirectory rather than at the repo root, set `working_directory` in `sdlc-config.json`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"stack": "python",
|
|
85
|
+
"working_directory": "mission-control-api",
|
|
86
|
+
"source_dirs": "src/ tests/",
|
|
87
|
+
...
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Behaviour when set:
|
|
92
|
+
|
|
93
|
+
- The Python `ci.yml` template's `quality-gates` job applies `defaults.run.working-directory: <value>` so every `run:` step starts there. `pip install -e ".[dev]"`, `pytest`, `pip-audit`, `python -m build` all resolve correctly.
|
|
94
|
+
- `source_dirs` becomes relative to `working_directory` (e.g. `src/ tests/` resolves to `mission-control-api/src/ mission-control-api/tests/` on disk; ruff/mypy/semgrep see the right files).
|
|
95
|
+
- `actions/upload-artifact` paths are workspace-rooted by GHA design and are auto-prefixed with `working_directory/` so the uploaded paths match where the gate steps wrote them.
|
|
96
|
+
- The downstream `upload-evidence` job downloads with `path: .` (workspace root) so file paths round-trip identically.
|
|
97
|
+
|
|
98
|
+
Default: `"."` (repo root). Omitting the field is equivalent to setting `"."` — no behavioural change for projects with root-level manifests.
|
|
99
|
+
|
|
100
|
+
Currently honoured by: **Python `ci.yml` template** (Phase 4 onwards). The Node `ci.yml` template doesn't substitute these tokens yet — Node consumers don't typically need it. Symmetric Node support can be added when a Node monorepo first needs it.
|
|
101
|
+
|
|
102
|
+
## Adding a new stack
|
|
103
|
+
|
|
104
|
+
See the step-by-step walkthrough: **[docs/adding-a-stack.md](../docs/adding-a-stack.md)** — uses the Python adapter as the worked example. The high-level shape is:
|
|
105
|
+
|
|
106
|
+
1. **Create the directory** `sdlc/files/stacks/<name>/` (`<name>` must satisfy the regex above).
|
|
107
|
+
2. **Author `adapter.json`** with every required field. Use `stacks/node/adapter.json` or `stacks/python/adapter.json` as a worked example.
|
|
108
|
+
3. **Add hooks and scripts** referenced from the manifest. The validator does not check their existence yet; the sync script will fail at the consumer end if a referenced file is missing.
|
|
109
|
+
4. **Author the per-stack `ci.yml.template`** at `sdlc/files/ci/<name>/ci.yml.template`. Stack-agnostic workflows (compliance-validation, check-release-approval, post-deploy-prod, compliance-evidence, ci-status-fallback) are shared at `sdlc/files/ci/` — no per-stack override needed for those.
|
|
110
|
+
5. **Run the validator:** `node scripts/validate-adapter.cjs sdlc/files/stacks/<name>/adapter.json`. Fix any errors before opening a PR.
|
|
111
|
+
6. **First consumer**: validate the adapter against at least one real project before merging. The Python adapter (Phase 4 of #287) was validated against META-AGENT, not against a fresh skeleton.
|
|
112
|
+
|
|
113
|
+
## Evolution
|
|
114
|
+
|
|
115
|
+
This contract is not frozen. If a new stack discovers a missing field — say, a separate `lint` command — open a PR that:
|
|
116
|
+
|
|
117
|
+
1. Adds the field to the schema (`additionalProperties: false` means new fields must be schema-declared first).
|
|
118
|
+
2. Updates this document.
|
|
119
|
+
3. Adds the field to every existing adapter (default values where reasonable).
|
|
120
|
+
4. Updates the validator and its unit tests.
|
|
121
|
+
|
|
122
|
+
Backward-incompatible changes (renaming or removing a required field) need a v1.24.0-level version bump and a migration note for consumers.
|
|
123
|
+
|
|
124
|
+
## Why JSON Schema (not Zod, not a TypeScript interface)
|
|
125
|
+
|
|
126
|
+
- **Tooling.** Every IDE that speaks JSON Schema (which is every modern one) gets autocomplete and inline validation as you edit an adapter manifest.
|
|
127
|
+
- **Language-neutral.** A future Python-only consumer can validate the same schema with `jsonschema` without pulling in Node.
|
|
128
|
+
- **Stable artifact.** `adapter.schema.json` is a versioned file in the repo. A TypeScript type is implementation detail.
|
|
129
|
+
|
|
130
|
+
The validator currently uses `ajv` (already a transitive dep), but the schema would be re-usable from any JSON-Schema-aware tool.
|
|
@@ -0,0 +1,172 @@
|
|
|
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` for GitHub's own mergeability signal.
|
|
141
|
+
2. If ANY required check is `fail` or `pending`, do NOT use happy-path language. Instead report:
|
|
142
|
+
- Each failing check by name, with its error (from `gh run view <RUN> --log-failed` if needed)
|
|
143
|
+
- Each pending check by name
|
|
144
|
+
- The concrete fix you are about to apply, or a specific question for the developer
|
|
145
|
+
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".
|
|
146
|
+
4. If `gh` itself fails (auth, rate limit, network): report "status unknown — gh call failed", never assume green.
|
|
147
|
+
5. Only when every required check is `pass` AND the PR is mergeable may you say "awaiting review" or "awaiting approval".
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
This rule applies any time you summarise PR state in chat, not only at the final handoff.
|
|
152
|
+
|
|
153
|
+
### Review Policy (Risk-Tiered)
|
|
154
|
+
|
|
155
|
+
- **LOW risk:** CI provides independent verification. Self-merge is permitted after all CI checks pass.
|
|
156
|
+
- **MEDIUM/HIGH risk:** A second human reviewer MUST approve before merge. Self-merge is NOT permitted.
|
|
157
|
+
|
|
158
|
+
### Rules (NEVER break these)
|
|
159
|
+
|
|
160
|
+
- NEVER code without a GitHub Issue and requirement entry for tracked changes
|
|
161
|
+
- NEVER push without all four gates passing
|
|
162
|
+
- NEVER self-merge a MEDIUM or HIGH risk PR — a second human reviewer MUST approve
|
|
163
|
+
- NEVER use `--no-verify` to skip hooks
|
|
164
|
+
- NEVER commit secrets (.env, credentials, API keys)
|
|
165
|
+
- NEVER commit binary/JSON evidence to git — upload to DevAudit instead
|
|
166
|
+
- NEVER create a PR to main without UAT verification passing first (if UAT configured)
|
|
167
|
+
- NEVER push directly to main — always develop → PR → main
|
|
168
|
+
- NEVER skip Co-Authored-By when AI generates code
|
|
169
|
+
- NEVER proceed past a WAIT CHECKPOINT without developer confirmation
|
|
170
|
+
- 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`
|
|
171
|
+
- ALWAYS commit compliance markdown to git (RTM, test-scope, implementation-plan, security-summary, release tickets)
|
|
172
|
+
- ALWAYS use merge commits (not squash) for develop → main
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# SDLC AI Rules
|
|
2
|
+
|
|
3
|
+
Drop-in instruction files that enforce the Metasession SDLC compliance process through AI coding assistants. When added to a project, the AI assistant will guide developers through the SDLC workflow on every code change.
|
|
4
|
+
|
|
5
|
+
## What These Rules Do
|
|
6
|
+
|
|
7
|
+
- **Ask which GitHub Issue a change is for** before writing any code
|
|
8
|
+
- **Create issues when needed** via `gh issue create`
|
|
9
|
+
- **Guide requirement planning** (RTM entry with issue reference, risk classification, test scope)
|
|
10
|
+
- **Enforce commit conventions** (Ref: REQ-XXX, Co-Authored-By tags)
|
|
11
|
+
- **Run compliance gates** before pushing (TypeScript, SAST, dependencies, E2E)
|
|
12
|
+
- **Compile evidence** after implementation (security summary, release ticket)
|
|
13
|
+
- **Block anti-patterns** (pushing to main, skipping hooks, committing secrets)
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
AI agent config files use a **single source of truth** pattern. The sync script generates pointer files that reference `INSTRUCTIONS.md`, where the SDLC rules live as the canonical source.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Automatic setup via sync script (recommended)
|
|
21
|
+
devaudit update v1.5.0 ../your-project
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This generates:
|
|
25
|
+
- `.cursorrules` → pointer to `INSTRUCTIONS.md`
|
|
26
|
+
- `.windsurfrules` → pointer to `INSTRUCTIONS.md`
|
|
27
|
+
- `CLAUDE.md` → preserves project header, adds pointer to `INSTRUCTIONS.md`
|
|
28
|
+
- `GEMINI.md` → pointer to `INSTRUCTIONS.md`
|
|
29
|
+
- `INSTRUCTIONS.md` → SDLC rules appended/replaced from `INSTRUCTIONS-SDLC.md`
|
|
30
|
+
|
|
31
|
+
### Manual setup (if not using sync script)
|
|
32
|
+
|
|
33
|
+
Copy `INSTRUCTIONS-SDLC.md` content into your project's `INSTRUCTIONS.md`, then create pointer files for each agent tool.
|
|
34
|
+
|
|
35
|
+
## Source Files
|
|
36
|
+
|
|
37
|
+
| File | Purpose |
|
|
38
|
+
|------|---------|
|
|
39
|
+
| `INSTRUCTIONS-SDLC.md` | Canonical SDLC rules — synced into consuming project `INSTRUCTIONS.md` |
|
|
40
|
+
| `SDLC_RULES.md` | Full SDLC rules with detailed explanations (reference) |
|
|
41
|
+
| `claude/CLAUDE.md` | Legacy Claude-specific format (superseded by pointer pattern) |
|
|
42
|
+
| `cursor/.cursorrules` | Legacy Cursor format (superseded by pointer pattern) |
|
|
43
|
+
| `windsurf/.windsurfrules` | Legacy Windsurf format (superseded by pointer pattern) |
|
|
44
|
+
|
|
45
|
+
## Prerequisites
|
|
46
|
+
|
|
47
|
+
Projects using these rules must have:
|
|
48
|
+
|
|
49
|
+
1. **GitHub CLI (`gh`) installed and authenticated** — used to fetch and create issues:
|
|
50
|
+
```bash
|
|
51
|
+
gh auth status # verify you're logged in
|
|
52
|
+
```
|
|
53
|
+
2. **SDLC workflow files copied into the project** as `SDLC/` — the AI rules reference these files for detailed steps, templates, and checklists:
|
|
54
|
+
```bash
|
|
55
|
+
cp -r path/to/devaudit/sdlc/files/ SDLC/
|
|
56
|
+
```
|
|
57
|
+
3. **Git hooks configured** (Husky + Commitlint + lint-staged) — enforces commit conventions and pre-push gates locally:
|
|
58
|
+
```bash
|
|
59
|
+
# Install dependencies
|
|
60
|
+
npm install --save-dev husky @commitlint/cli @commitlint/config-conventional lint-staged
|
|
61
|
+
npx husky init
|
|
62
|
+
|
|
63
|
+
# Copy hook templates
|
|
64
|
+
cp path/to/devaudit/sdlc/files/hooks/commit-msg .husky/commit-msg
|
|
65
|
+
cp path/to/devaudit/sdlc/files/hooks/pre-commit .husky/pre-commit
|
|
66
|
+
cp path/to/devaudit/sdlc/files/hooks/pre-push .husky/pre-push
|
|
67
|
+
chmod +x .husky/commit-msg .husky/pre-commit .husky/pre-push
|
|
68
|
+
cp path/to/devaudit/sdlc/files/hooks/commitlint.config.mjs commitlint.config.mjs
|
|
69
|
+
```
|
|
70
|
+
4. **Validation scripts** (optional, for CI enforcement):
|
|
71
|
+
```bash
|
|
72
|
+
cp path/to/devaudit/sdlc/files/scripts/*.sh scripts/
|
|
73
|
+
chmod +x scripts/*.sh
|
|
74
|
+
```
|
|
75
|
+
5. A `compliance/` directory with `RTM.md` (Part B must include the `Issue` column)
|
|
76
|
+
6. A `compliance/evidence/` directory
|
|
77
|
+
7. A `compliance/pending-releases/` directory
|
|
78
|
+
8. A permanent `develop` branch with protected `main`
|
|
79
|
+
|
|
80
|
+
Use `SDLC/0-project-setup.md` to initialise items 2-8 in a new project.
|
|
81
|
+
|
|
82
|
+
The AI rules act as guardrails and summaries. The `SDLC/` workflow files contain the full detailed procedures. The AI assistant will read the relevant workflow file at each stage.
|
|
83
|
+
|
|
84
|
+
## Syncing SDLC Updates to Consuming Projects
|
|
85
|
+
|
|
86
|
+
When SDLC templates are updated in DevAudit, propagate changes to consuming projects using the sync script:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# From DevAudit root. Pass one path per active consumer.
|
|
90
|
+
devaudit update v1.1.0 ../wawagardenbar-app
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Only `wawagardenbar-app` is an active consumer as of 2026-05-19; META-AGENT / META-ATS / META-JOBS onboarding attempts were reverted (see [docs/consuming-projects.md](../../docs/consuming-projects.md)). The sync command accepts multiple consumer paths when more projects come back online.
|
|
94
|
+
|
|
95
|
+
This:
|
|
96
|
+
1. Tags DevAudit as `sdlc-v1.1.0` and pushes the tag
|
|
97
|
+
2. Copies SDLC files, hooks, scripts, and CI templates to each project
|
|
98
|
+
3. Generates AI agent pointer files (.cursorrules, .windsurfrules, CLAUDE.md, GEMINI.md) referencing `INSTRUCTIONS.md`
|
|
99
|
+
4. Appends/replaces the SDLC section in `INSTRUCTIONS.md` from `INSTRUCTIONS-SDLC.md`
|
|
100
|
+
5. Updates tag references in consuming project CI workflows
|
|
101
|
+
6. Reports what was synced — review the diff before committing
|
|
102
|
+
|
|
103
|
+
See the CLI sync (`devaudit update`, `cli/src/update/`) for full details.
|