@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.
Files changed (69) 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.md +73 -0
  7. package/sdlc/HOST_ADAPTER.md +127 -0
  8. package/sdlc/SKILLS.md +137 -0
  9. package/sdlc/STACK_ADAPTER.md +130 -0
  10. package/sdlc/ai-rules/INSTRUCTIONS-SDLC.md +172 -0
  11. package/sdlc/ai-rules/README.md +103 -0
  12. package/sdlc/ai-rules/SDLC_RULES.md +584 -0
  13. package/sdlc/ai-rules/claude/CLAUDE.md +192 -0
  14. package/sdlc/ai-rules/cursor/.cursorrules +167 -0
  15. package/sdlc/ai-rules/windsurf/.windsurfrules +167 -0
  16. package/sdlc/article.md +219 -0
  17. package/sdlc/files/_common/0-project-setup.md +410 -0
  18. package/sdlc/files/_common/1-plan-requirement.md +381 -0
  19. package/sdlc/files/_common/2-implement-and-test.md +276 -0
  20. package/sdlc/files/_common/3-compile-evidence.md +603 -0
  21. package/sdlc/files/_common/4-submit-for-review.md +362 -0
  22. package/sdlc/files/_common/5-deploy-main.md +251 -0
  23. package/sdlc/files/_common/Periodic_Security_Review_Schedule.md +169 -0
  24. package/sdlc/files/_common/README_TEMPLATE.md +441 -0
  25. package/sdlc/files/_common/Test_Architecture.md +461 -0
  26. package/sdlc/files/_common/Test_Plan_TEMPLATE.md +311 -0
  27. package/sdlc/files/_common/Test_Policy.md +277 -0
  28. package/sdlc/files/_common/Test_Strategy.md +359 -0
  29. package/sdlc/files/_common/github/ISSUE_TEMPLATE/bug.yml +75 -0
  30. package/sdlc/files/_common/github/ISSUE_TEMPLATE/config.yml +11 -0
  31. package/sdlc/files/_common/github/ISSUE_TEMPLATE/requirement.yml +75 -0
  32. package/sdlc/files/_common/github/ISSUE_TEMPLATE/task.yml +48 -0
  33. package/sdlc/files/_common/github/pull_request_template.md +69 -0
  34. package/sdlc/files/_common/implementing-an-sdlc-issue.md +413 -0
  35. package/sdlc/files/_common/scripts/derive-release-version.sh +40 -0
  36. package/sdlc/files/_common/scripts/derive-release-version.test.sh +98 -0
  37. package/sdlc/files/_common/scripts/submit-for-uat-review.sh +162 -0
  38. package/sdlc/files/_common/scripts/validate-commits.sh +83 -0
  39. package/sdlc/files/_common/scripts/validate-compliance-artifacts.sh +202 -0
  40. package/sdlc/files/_common/scripts/validate-compliance-artifacts.test.sh +202 -0
  41. package/sdlc/files/_common/skills/_schema/skill.schema.json +36 -0
  42. package/sdlc/files/_common/skills/e2e-test-engineer/SKILL.md +254 -0
  43. package/sdlc/files/_common/skills/e2e-test-engineer/references/bootstrap.md +244 -0
  44. package/sdlc/files/_common/skills/e2e-test-engineer/references/evidence.ts +40 -0
  45. package/sdlc/files/_common/skills/sdlc-implementer/SKILL.md +189 -0
  46. package/sdlc/files/_common/skills/sdlc-implementer/references/call-graph.md +64 -0
  47. package/sdlc/files/_common/skills/sdlc-implementer/references/change-request-loop.md +192 -0
  48. package/sdlc/files/_common/skills/sdlc-implementer/references/compliance-constraints.md +81 -0
  49. package/sdlc/files/ci/check-release-approval.yml.template +201 -0
  50. package/sdlc/files/ci/ci-status-fallback.yml.template +41 -0
  51. package/sdlc/files/ci/ci.yml.template +390 -0
  52. package/sdlc/files/ci/compliance-evidence.yml.template +161 -0
  53. package/sdlc/files/ci/compliance-validation.yml.template +34 -0
  54. package/sdlc/files/ci/post-deploy-prod.yml.template +159 -0
  55. package/sdlc/files/ci/python/ci.yml.template +335 -0
  56. package/sdlc/files/hosts/_schema/adapter.schema.json +103 -0
  57. package/sdlc/files/hosts/railway/adapter.json +32 -0
  58. package/sdlc/files/sdlc-config.example.json +74 -0
  59. package/sdlc/files/stacks/_schema/adapter.schema.json +151 -0
  60. package/sdlc/files/stacks/node/adapter.json +54 -0
  61. package/sdlc/files/stacks/node/hooks/.prettierrc.json +9 -0
  62. package/sdlc/files/stacks/node/hooks/commit-msg +7 -0
  63. package/sdlc/files/stacks/node/hooks/commitlint.config.mjs +64 -0
  64. package/sdlc/files/stacks/node/hooks/lint-staged.config.mjs +16 -0
  65. package/sdlc/files/stacks/node/hooks/pre-commit +13 -0
  66. package/sdlc/files/stacks/node/hooks/pre-push +15 -0
  67. package/sdlc/files/stacks/node/scripts/check-requirement-jsdoc.sh +54 -0
  68. package/sdlc/files/stacks/python/adapter.json +36 -0
  69. package/sdlc/files/stacks/python/hooks/.pre-commit-config.yaml +51 -0
@@ -0,0 +1,461 @@
1
+ # Test Architecture
2
+
3
+ **Document Type:** Architecture Standards | **Version:** 2.0 | **Effective Date:** March 2026 | **Review Cycle:** Annual
4
+
5
+ **Owner:** QA Team / Test Engineers | **Approved By:** Engineering Leadership
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ This document defines the technical standards for how Metasession builds and structures test infrastructure. It specifies mandatory tools, frameworks, directory structures, design patterns, code conventions, CI/CD pipeline configuration, environment setup, and artifact storage.
12
+
13
+ This document answers **"what we build tests with and how we structure the code."** For why we test and our governance commitments, see the Test Policy (`sdlc/files/Test_Policy.md` in DevAudit). For how we approach testing methodically, see the Test Strategy.
14
+
15
+ Individual products implement these standards as documented in product-specific Test Plans.
16
+
17
+ ---
18
+
19
+ ## Scope
20
+
21
+ These standards apply to all Metasession products, client engagements, and internal systems.
22
+
23
+ ---
24
+
25
+ ## 1. Architectural Principles
26
+
27
+ ### DRY (Don't Repeat Yourself)
28
+ - Reusable test utilities and helper functions across suites
29
+ - Shared fixtures and base classes
30
+ - Centralized configuration management
31
+ - Common assertion libraries and custom matchers
32
+
33
+ ### Isolation
34
+ - Each test runs independently without side effects
35
+ - Database state reset between test runs
36
+ - External dependencies mocked to prevent flakiness
37
+ - Parallel execution enabled without interference
38
+
39
+ ### Speed over Exhaustiveness
40
+ - Fast feedback prioritized (unit tests < 30 seconds)
41
+ - Parallelization and sharding for E2E suites
42
+ - Strategic test selection based on code changes
43
+ - Regression suites optimized for execution time
44
+
45
+ ### Traceability
46
+ - Tests linked to requirements via ticket IDs
47
+ - BDD feature files tagged with requirement references
48
+ - Automated requirement-test-result mapping
49
+
50
+ ---
51
+
52
+ ## 2. Test Pyramid Implementation
53
+
54
+ ### Unit Layer (Foundation)
55
+
56
+ | Attribute | Standard |
57
+ |---|---|
58
+ | Coverage | Minimum 70% for critical modules |
59
+ | Speed | Suite completes in < 30 seconds |
60
+ | Scope | Individual functions, methods, components in isolation |
61
+ | Mocking | External dependencies must be mocked |
62
+
63
+ ### Integration Layer (Middle)
64
+
65
+ | Attribute | Standard |
66
+ |---|---|
67
+ | Coverage | Minimum 80% of integration points |
68
+ | Scope | Component interactions, service integrations, API contracts |
69
+ | Data | In-memory databases or MSW for API mocking |
70
+
71
+ ### E2E Layer (Top)
72
+
73
+ | Attribute | Standard |
74
+ |---|---|
75
+ | Coverage | 100% of critical user paths |
76
+ | Scope | Complete user journeys from UI to database |
77
+ | Browser support | Chromium, Firefox, WebKit |
78
+ | BDD | playwright-bdd for acceptance criteria |
79
+
80
+ ### Additional Layers
81
+
82
+ | Layer | Standard |
83
+ |---|---|
84
+ | Security | SAST, SCA, DAST (see Section 3) |
85
+ | Performance | Load and stress testing before major releases |
86
+ | Accessibility | WCAG 2.1 AA for public-facing features |
87
+ | Visual regression | Optional, recommended for UI-heavy products |
88
+
89
+ ---
90
+
91
+ ## 3. Mandatory Tooling
92
+
93
+ ### Test Frameworks
94
+
95
+ | Purpose | Tool | Notes |
96
+ |---|---|---|
97
+ | Unit testing (TS/JS) | Jest or Vitest | Project chooses one |
98
+ | Unit testing (Python) | pytest | |
99
+ | Component testing | React Testing Library | |
100
+ | E2E testing | Playwright | Organizational standard |
101
+ | BDD integration | playwright-bdd | |
102
+ | API mocking | MSW (Mock Service Worker) | |
103
+ | HTTP mocking | Nock | Node.js environments |
104
+
105
+ ### Test Management
106
+
107
+ | Purpose | Tool |
108
+ |---|---|
109
+ | Test case management | Qase |
110
+ | CI/CD | GitHub Actions |
111
+ | Reporting | Playwright HTML Reporter, JUnit XML |
112
+
113
+ ### Security Testing
114
+
115
+ | Purpose | Tool | When |
116
+ |---|---|---|
117
+ | SAST (static analysis) | Semgrep and/or SonarQube | Every commit |
118
+ | SCA (dependency scanning) | Snyk | Every commit |
119
+ | Dependency updates | Dependabot | Continuous |
120
+ | DAST (dynamic testing) | OWASP ZAP | Periodic / pre-release |
121
+ | Supply chain analysis | Socket.dev | Optional, for enhanced analysis |
122
+
123
+ ### Performance Testing
124
+
125
+ | Purpose | Tool |
126
+ |---|---|
127
+ | Load testing | Artillery |
128
+ | Web performance | Lighthouse |
129
+
130
+ ### Development Tooling
131
+
132
+ | Purpose | Tool |
133
+ |---|---|
134
+ | Git hooks | Husky |
135
+ | Commit linting | commitlint (Conventional Commits) |
136
+ | Code linting | ESLint |
137
+ | Code formatting | Prettier |
138
+ | Containerization | Docker |
139
+
140
+ ---
141
+
142
+ ## 4. Project Structure
143
+
144
+ All products organize tests in a centralized `/tests` directory:
145
+
146
+ ```
147
+ /tests
148
+ /__tests__ # Unit tests (mirrors src structure)
149
+ /integration # Integration tests
150
+ /e2e # End-to-end tests
151
+ /playwright # Playwright test specs
152
+ /pages # Page Object Models (required)
153
+ /components # Component objects
154
+ /bdd # BDD feature files (Gherkin)
155
+ /performance # Performance tests
156
+ /visual # Visual regression tests (optional)
157
+ /accessibility # Accessibility tests
158
+ /setup # Test utilities & configuration
159
+ /fixtures # Test data fixtures
160
+ /mocks # Mock implementations
161
+ /utils # Helper utilities
162
+ /factories # Data factories
163
+ /config # Test framework configurations
164
+ /reports # Test reports (gitignored)
165
+ ```
166
+
167
+ ---
168
+
169
+ ## 5. Design Patterns
170
+
171
+ ### Page Object Model (Required for E2E)
172
+
173
+ All E2E tests must use the Page Object Model pattern:
174
+
175
+ - Page classes in `/tests/e2e/pages/`
176
+ - Component objects for reusable UI elements
177
+ - Locators defined as class properties
178
+ - Methods for user interactions
179
+ - No assertions in page objects — assertions belong in test files
180
+
181
+ ### Custom Fixtures (Required)
182
+
183
+ Products must implement:
184
+
185
+ - Authentication fixtures (login states, session management)
186
+ - Database seeding/cleanup fixtures
187
+ - Test data factories using Faker.js and Fishery
188
+
189
+ ### Shared Utilities (Required)
190
+
191
+ - Authentication helpers
192
+ - Date/time manipulation utilities
193
+ - Storage helpers (localStorage, cookies)
194
+ - Custom matchers and assertions
195
+
196
+ ---
197
+
198
+ ## 6. Test Data Management
199
+
200
+ ### Strategy by Test Level
201
+
202
+ | Test Level | Data Strategy | Rationale |
203
+ |---|---|---|
204
+ | Unit | Mocked data | Fast, predictable |
205
+ | Integration | In-memory DB or MSW | Isolated, controlled |
206
+ | E2E (local) | Test database (Docker) | Real behavior, containerized |
207
+ | E2E (CI) | Ephemeral database | Production-like, auto-provisioned |
208
+ | Staging | Dedicated staging DB | Production-equivalent, anonymized |
209
+
210
+ ### Data Factories (Required)
211
+
212
+ - Faker.js for realistic data generation
213
+ - Fishery for factory definitions
214
+ - Factories reusable across test types
215
+
216
+ ### GDPR Compliance (Mandatory)
217
+
218
+ - No production PII in non-production environments
219
+ - Synthetic data for all test scenarios
220
+ - Data masking when copying production data
221
+ - Automatic cleanup after execution
222
+ - Access controls on test databases
223
+
224
+ ---
225
+
226
+ ## 7. CI/CD Pipeline Standards
227
+
228
+ ### Required Pipeline Stages
229
+
230
+ All products implement these stages in order:
231
+
232
+ | Stage | Purpose | Exit Criteria |
233
+ |---|---|---|
234
+ | 1. Lint | ESLint + Prettier validation | 0 errors |
235
+ | 2. Type Check | Strict compilation | 0 errors |
236
+ | 3. Unit Tests | Component-level testing with coverage | Meets coverage target |
237
+ | 4. Security Scans | SAST + SCA | 0 high/critical findings |
238
+ | 5. Integration Tests | API and service validation | All pass |
239
+ | 6. E2E Tests | Full Playwright suite with parallelization | All critical paths pass |
240
+ | 7. Build | Production build verification | Succeeds |
241
+ | 8. Report | Artifact upload and status reporting | Artifacts stored |
242
+
243
+ PR cannot merge unless all stages pass.
244
+
245
+ ### Parallelization (Required)
246
+
247
+ - E2E tests sharded across minimum 4 workers
248
+ - Matrix strategy for multiple browsers (Chromium, Firefox, WebKit)
249
+
250
+ ### Release Pipeline
251
+
252
+ - Semantic versioning via Conventional Commits (release-please or equivalent)
253
+ - Changelog generated from commit messages
254
+ - GitHub releases with version tags
255
+ - Deployment pipeline triggered on merge to production branch
256
+
257
+ ### Git Hooks Configuration (Required)
258
+
259
+ Hook templates are provided in `sdlc/files/hooks/` in the DevAudit repository. Copy them into your project during setup (see `0-project-setup.md` Step 5c).
260
+
261
+ **Pre-commit** (`.husky/pre-commit` — template: `hooks/pre-commit`):
262
+ - Runs lint-staged on staged files (ESLint + Prettier)
263
+ - Blocks commit on failure
264
+
265
+ **Commit-msg** (`.husky/commit-msg` — template: `hooks/commit-msg`):
266
+ - Runs commitlint to validate Conventional Commits format
267
+ - Required format: `type(scope): description`
268
+ - Warns on missing `Ref: REQ-XXX` and `Co-Authored-By` trailers
269
+ - Configuration: `commitlint.config.mjs` (template: `hooks/commitlint.config.mjs`)
270
+
271
+ **Pre-push** (`.husky/pre-push` — template: `hooks/pre-push`):
272
+ - TypeScript compilation check (`tsc --noEmit`) as a fast gate
273
+ - Full test suite, SAST, and dependency audit run in CI — not in the pre-push hook (too slow for a local gate)
274
+ - Blocks push on TypeScript errors
275
+
276
+ **Setup:**
277
+ ```bash
278
+ npm install --save-dev husky @commitlint/cli @commitlint/config-conventional lint-staged
279
+ npx husky init
280
+ cp path/to/devaudit/sdlc/files/hooks/commit-msg .husky/commit-msg
281
+ cp path/to/devaudit/sdlc/files/hooks/pre-commit .husky/pre-commit
282
+ cp path/to/devaudit/sdlc/files/hooks/pre-push .husky/pre-push
283
+ chmod +x .husky/commit-msg .husky/pre-commit .husky/pre-push
284
+ cp path/to/devaudit/sdlc/files/hooks/commitlint.config.mjs commitlint.config.mjs
285
+ npm pkg set scripts.prepare="husky"
286
+ ```
287
+
288
+ ---
289
+
290
+ ## 8. Artifact Storage
291
+
292
+ | Artifact | Storage | Retention |
293
+ |---|---|---|
294
+ | Test results (HTML) | GitHub Actions artifacts | 90 days |
295
+ | Screenshots | GitHub Actions artifacts | 90 days |
296
+ | Videos | GitHub Actions artifacts | 90 days |
297
+ | Coverage reports | Codecov | Indefinite |
298
+ | JUnit XML | GitHub Actions + Qase | 90 days + Indefinite |
299
+ | Release artifacts | AWS S3 / Azure Blob | 3-7 years (compliance) |
300
+ | Security scans | Snyk + SonarQube dashboards | Indefinite |
301
+ | SAST evidence (JSON) | Project compliance directory | 3 years minimum |
302
+ | Dependency audits | Project compliance directory | 3 years minimum |
303
+
304
+ ### Flakiness Handling (Required)
305
+
306
+ - Retry strategy: 2 retries in CI, 0 locally
307
+ - Automatic quarantine detection for flaky tests
308
+ - Flaky tests create issues automatically
309
+ - Flaky tests addressed immediately or disabled with documented justification
310
+
311
+ ---
312
+
313
+ ## 9. File Naming & Code Style
314
+
315
+ ### Naming Conventions
316
+
317
+ | File Type | Pattern | Example |
318
+ |---|---|---|
319
+ | Unit tests | `*.test.ts`, `*.test.tsx` | `auth.test.ts` |
320
+ | Integration tests | `*.integration.test.ts` | `api.integration.test.ts` |
321
+ | E2E tests | `*.spec.ts` | `login.spec.ts` |
322
+ | BDD features | `*.feature` | `authentication.feature` |
323
+ | Page objects | `*Page.ts` (PascalCase) | `LoginPage.ts` |
324
+ | Accessibility | `*.a11y.test.ts` | `navigation.a11y.test.ts` |
325
+
326
+ ### ESLint Configuration
327
+
328
+ ```javascript
329
+ module.exports = {
330
+ extends: [
331
+ 'eslint:recommended',
332
+ 'plugin:@typescript-eslint/recommended',
333
+ 'plugin:playwright/recommended',
334
+ 'prettier',
335
+ ],
336
+ parser: '@typescript-eslint/parser',
337
+ plugins: ['@typescript-eslint', 'playwright'],
338
+ rules: {
339
+ 'playwright/no-skipped-test': 'warn',
340
+ 'playwright/no-focused-test': 'error',
341
+ 'playwright/valid-expect': 'error',
342
+ 'playwright/prefer-web-first-assertions': 'warn',
343
+ '@typescript-eslint/no-explicit-any': 'warn',
344
+ '@typescript-eslint/explicit-function-return-type': 'off',
345
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
346
+ },
347
+ overrides: [
348
+ {
349
+ files: ['*.test.ts', '*.test.tsx', '*.spec.ts'],
350
+ rules: {
351
+ '@typescript-eslint/no-explicit-any': 'off',
352
+ },
353
+ },
354
+ ],
355
+ };
356
+ ```
357
+
358
+ ### Prettier Configuration
359
+
360
+ ```json
361
+ {
362
+ "semi": true,
363
+ "trailingComma": "all",
364
+ "singleQuote": true,
365
+ "printWidth": 100,
366
+ "tabWidth": 2
367
+ }
368
+ ```
369
+
370
+ ### Test Code Style
371
+
372
+ - Descriptive test names (sentences, not code identifiers)
373
+ - Arrange-Act-Assert pattern
374
+ - Maximum 1 assertion concept per test
375
+ - No test interdependencies
376
+ - BDD scenarios use Given/When/Then structure
377
+ - Test code maintained to same quality standards as product code
378
+ - Code review required for all test automation changes
379
+
380
+ ---
381
+
382
+ ## 10. Environment Configuration
383
+
384
+ ### Environment Files
385
+
386
+ ```
387
+ .env.local # Local development (not committed)
388
+ .env.test # Test environment (committed, no secrets)
389
+ .env.staging # Staging (secrets in CI/CD only)
390
+ .env.production # Production (secrets in CI/CD only)
391
+ .env.example # Template for developers (committed)
392
+ ```
393
+
394
+ ### Secret Management
395
+
396
+ - All secrets in CI/CD platform secret storage (GitHub Actions Secrets)
397
+ - No secrets committed to version control
398
+ - Separate secrets per environment
399
+ - Rotation policy for sensitive credentials
400
+
401
+ ### Containerization
402
+
403
+ - Docker Compose for local test environment
404
+ - Health checks for all services
405
+ - Automatic cleanup of containers
406
+ - Consistent environment across local and CI
407
+
408
+ ---
409
+
410
+ ## 11. Coverage & Quality Thresholds
411
+
412
+ | Metric | Target |
413
+ |---|---|
414
+ | Unit test coverage (critical modules) | 70% minimum |
415
+ | Integration point coverage | 80% minimum |
416
+ | Critical user path E2E coverage | 100% |
417
+ | Security scan (high/critical) | 0 findings |
418
+ | Accessibility (public-facing) | WCAG 2.1 AA |
419
+
420
+ ### Quality Metrics (Required Tracking)
421
+
422
+ - Test coverage percentage by module
423
+ - Test execution time and trends
424
+ - Flaky test rate
425
+ - Bug escape rate (production defects not caught)
426
+ - Mean time to detect (MTTD)
427
+
428
+ ### Review Cadence
429
+
430
+ - **Monthly** — Test suite health check
431
+ - **Quarterly** — Architecture standards review
432
+ - **Ongoing** — Remove obsolete tests, update documentation
433
+
434
+ ---
435
+
436
+ ## Product-Specific Implementation
437
+
438
+ Each product creates a product-specific Test Plan that:
439
+
440
+ 1. Implements these organizational architecture standards
441
+ 2. Documents product-specific configurations (framework versions, database schemas, URLs)
442
+ 3. Provides practical examples for the product's stack
443
+ 4. Defines migration timelines for implementing standards (if not yet fully compliant)
444
+ 5. Lists product-specific test scenarios and critical paths
445
+
446
+ ---
447
+
448
+ ## Document Control
449
+
450
+ | Version | Date | Author | Changes |
451
+ |---|---|---|---|
452
+ | 1.0 | January 2026 | QA Team | Initial creation |
453
+ | 2.0 | March 2026 | QA Team | Clean boundary split — removed compliance/governance content (now in Policy), removed methodology content (now in Strategy). Architecture now owns tools, patterns, code standards, CI config only. Added security tooling table. |
454
+
455
+ **Next Review Date:** March 2027
456
+
457
+ **Related Documents:** Test Policy, Test Strategy, Periodic Security Review Schedule, Project Test Plans (in devaudit/sdlc/files/)
458
+
459
+ ---
460
+
461
+ **Architecture Status:** Approved | **Effective Date:** March 2026