azcodr 1.5.2 → 2.0.0

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 (93) hide show
  1. package/.agents/hooks.json +42 -42
  2. package/.agents/hooks.json.example +42 -42
  3. package/.agents/mcp_config.json.example +29 -29
  4. package/.agents/scripts/safety_guard.sh +143 -34
  5. package/.agents/scripts/verify_completion.sh +90 -27
  6. package/.agents/skills/agentic-architect/SKILL.md +125 -125
  7. package/.agents/skills/agentic-architect/references/agents_md_template.md +62 -62
  8. package/.agents/skills/agentic-architect/references/refinement_workflow.md +32 -32
  9. package/.agents/skills/agentic-architect/references/skill_architecture_inquiry.md +63 -63
  10. package/.agents/skills/agentic-architect/references/skill_template.md +56 -56
  11. package/.agents/skills/agentic-architect/scripts/validate_agentic_configs.sh +402 -402
  12. package/.agents/skills/clean-code-refactor/SKILL.md +91 -91
  13. package/.agents/skills/clean-code-refactor/references/clean_code_smells.md +27 -27
  14. package/.agents/skills/clean-code-refactor/references/design_patterns_ts.md +65 -65
  15. package/.agents/skills/compliance-audit/SKILL.md +120 -120
  16. package/.agents/skills/compliance-audit/references/owasp_top10_controls.md +16 -16
  17. package/.agents/skills/compliance-audit/references/soc2_iso_controls.md +28 -28
  18. package/.agents/skills/lets-build/SKILL.md +173 -173
  19. package/.agents/skills/lets-build/references/architecture_interview_matrix.md +115 -115
  20. package/.agents/skills/lets-build/references/hexagonal_bootstrap_scaffolds.md +160 -160
  21. package/.agents/skills/lets-build/references/project_readme_template.md +79 -79
  22. package/.agents/skills/lets-build/scripts/bootstrap_workspace.sh +419 -255
  23. package/.agents/skills/product-analyst/SKILL.md +154 -154
  24. package/.agents/skills/product-analyst/references/backlog_ordering_techniques.md +107 -107
  25. package/.agents/skills/product-analyst/references/gherkin_patterns.md +46 -46
  26. package/.agents/skills/product-analyst/references/invest_checklist.md +38 -38
  27. package/.agents/skills/product-analyst/references/okr_alignment_guide.md +76 -76
  28. package/.agents/skills/product-analyst/references/smart_tasks.md +59 -59
  29. package/.agents/skills/relentless-questioner/SKILL.md +128 -128
  30. package/.agents/skills/relentless-questioner/references/adaptive_question_trees.md +102 -102
  31. package/.editorconfig +19 -19
  32. package/.github/workflows/ci.yml +167 -78
  33. package/.github/workflows/publish.yml +200 -0
  34. package/.gitignore +40 -25
  35. package/AGENTS.md +103 -102
  36. package/LICENSE +21 -21
  37. package/README.md +168 -165
  38. package/bin/azcodr.js +14 -228
  39. package/docs/knowledge/ubiquitous_language.md +31 -18
  40. package/docs/rules/agentic_configuration.md +259 -259
  41. package/docs/rules/api_architecture.md +179 -179
  42. package/docs/rules/authentication.md +76 -76
  43. package/docs/rules/authorization.md +75 -75
  44. package/docs/rules/caching.md +69 -69
  45. package/docs/rules/clean_code.md +62 -62
  46. package/docs/rules/cloud_native.md +41 -41
  47. package/docs/rules/cqrs.md +203 -203
  48. package/docs/rules/database_design.md +125 -125
  49. package/docs/rules/database_operations.md +69 -69
  50. package/docs/rules/design_patterns.md +98 -98
  51. package/docs/rules/devops_ci_cd.md +76 -76
  52. package/docs/rules/domain_driven_design.md +122 -122
  53. package/docs/rules/error_handling.md +54 -52
  54. package/docs/rules/feature_flags.md +59 -59
  55. package/docs/rules/frontend_architecture.md +157 -157
  56. package/docs/rules/multitenancy_architecture.md +98 -98
  57. package/docs/rules/product_ownership.md +127 -127
  58. package/docs/rules/project_management.md +49 -49
  59. package/docs/rules/relentless_questioning.md +52 -52
  60. package/docs/rules/requirements_engineering.md +98 -98
  61. package/docs/rules/security_compliance.md +53 -53
  62. package/docs/rules/server_driven_ui.md +88 -88
  63. package/docs/rules/test_driven_development.md +185 -185
  64. package/docs/rules/transactional_email.md +27 -27
  65. package/docs/rules/type_safety.md +65 -65
  66. package/docs/rules/ui_ux_architecture.md +150 -150
  67. package/docs/rules/workflow_state_machines.md +117 -117
  68. package/lib/cli-parse.js +51 -0
  69. package/lib/cli-target.js +109 -0
  70. package/lib/cli.js +180 -0
  71. package/lib/errors.js +28 -0
  72. package/lib/git.js +29 -0
  73. package/lib/guards.js +96 -0
  74. package/lib/index.d.ts +199 -134
  75. package/lib/index.js +5 -5
  76. package/lib/links.js +123 -0
  77. package/lib/permissions.js +44 -0
  78. package/lib/repo.js +90 -0
  79. package/lib/scaffold.js +238 -448
  80. package/memory.md +119 -36
  81. package/package.json +65 -62
  82. package/scripts/test_coverage.js +66 -38
  83. package/scripts/validate/adr.js +151 -0
  84. package/scripts/validate/io.js +84 -0
  85. package/scripts/validate/links.js +167 -0
  86. package/scripts/validate/parity.js +124 -0
  87. package/scripts/validate/root.js +184 -0
  88. package/scripts/validate/rules.js +44 -0
  89. package/scripts/validate/skills.js +96 -0
  90. package/scripts/validate/text.js +29 -0
  91. package/scripts/validate-cli.js +13 -0
  92. package/scripts/validate.js +140 -258
  93. package/.github/copilot-instructions.md +0 -1
@@ -1,98 +1,98 @@
1
- # Requirements Engineering, INVEST Stories & Gherkin Criteria
2
-
3
- > **Core Mandate:** Decompose business requirements into vertically sliced INVEST user stories, executable Gherkin acceptance criteria, and exhaustive edge case matrices, acknowledging that stories are conversation starters rather than full specification documents.
4
-
5
- ---
6
-
7
- ## 1. Are User Stories Requirements?
8
-
9
- In modern product engineering (per Scrum.org and XP principles), **user stories are NOT requirements**. Rather, a user story is one specific, highly effective technique used to *express, capture, and explore* user-centric requirements.
10
-
11
- ### Key Distinctions
12
- - **A Token for Conversation:** A user story is a "placeholder" or token promising a future conversation. It captures the essence, not every granular detail upfront.
13
- - **The "Pidgin Language" Bridge:** A pidgin language is a simplified common language that allows people with different native tongues to trade and work together. User stories act as a pidgin language bridging the business/customer perspective and the software engineering architecture without forcing either side to abandon their domain language.
14
- - **Ron Jeffries' 3 C's of User Stories:**
15
- 1. **Card:** The physical index card or digital ticket capturing the intent (`As a... I want to... So that...`).
16
- 2. **Conversation:** The collaborative discussion between Product Owner, stakeholders, and developers where details and trade-offs are co-created.
17
- 3. **Confirmation:** The executable acceptance criteria and automated tests that prove whether the story satisfies its intent.
18
-
19
- ### Non-Story Requirements
20
- Not all system requirements originate from an end-user persona or fit the user story syntax. High-integrity systems also require:
21
- - **System Invariants:** Core domain rules (e.g., "A transaction cannot be completed without a verified payment instrument").
22
- - **Non-Functional Requirements (NFRs):** Latency SLAs, encryption standards, concurrency limits, and accessibility compliance (WCAG 2.2 AA).
23
- - **Architectural Spikes:** Time-boxed exploratory investigations to resolve technical unknowns.
24
- - **Regulatory & Security Controls:** SOC 2 audit log immutability, GDPR data erasure rights, and OWASP Top 10 defenses.
25
-
26
- These requirements should be operationalized as explicit acceptance constraints, architectural fitness functions, or dedicated technical backlog items.
27
-
28
- ---
29
-
30
- ## 2. INVEST User Story Framework & Vertical Cake Slicing
31
-
32
- Ensure every user story satisfies Bill Wake's **INVEST** criteria:
33
-
34
- - **I - Independent:** Sliced vertically to minimize conceptual overlap. Can be scheduled, implemented, and released in any sequence without blocking peer stories.
35
- - **N - Negotiable:** Captures the core essence and problem space, not a rigid implementation contract. Specific details are co-created during pair programming and TDD.
36
- - **V - Valuable:** Delivers observable, direct benefit to the customer or business stakeholder.
37
- - **E - Estimable:** Well-understood and right-sized so the team can gauge complexity. Unknowns are resolved via prior time-boxed spikes.
38
- - **S - Small:** Sized to be completed within 1–2 development days. Small stories yield higher estimation accuracy and rapid feedback.
39
- - **T - Testable:** Accompanied by concrete pass/fail assertions. Non-functional requirements are operationalized into automated tests early.
40
-
41
- ### The Multi-Layer Cake Metaphor (Vertical Slicing)
42
- Think of a complete feature as a multi-layer cake:
43
- ```mermaid
44
- flowchart TD
45
- subgraph Cake["The Multi-Layer Cake (Vertical Slicing)"]
46
- direction TB
47
- L1["Presentation / UI Layer"]
48
- L2["Business Logic & Application Use Case"]
49
- L3["Domain Invariants & Entities"]
50
- L4["Persistence & Database Layer"]
51
- L1 --- L2 --- L3 --- L4
52
- end
53
-
54
- Slice["Vertical Cake Slice<br/>(Customer gets a taste of every layer)"]
55
- Slice --> L1
56
- Slice --> L2
57
- Slice --> L3
58
- Slice --> L4
59
- ```
60
- - **Horizontal Slicing (Anti-Pattern):** Implementing only the database schema or only the UI mock. A full database table has zero observable value to the customer without presentation and logic layers.
61
- - **Vertical Slicing (Golden Standard):** Slicing thin through all layers (UI ➔ API ➔ Domain ➔ DB). Even a minimal vertical slice provides working functionality that can be deployed, tested, and validated empirically.
62
-
63
- ---
64
-
65
- ## 3. Executable Gherkin Acceptance Criteria
66
-
67
- Draft concrete, actionable scenarios directly convertible into automated acceptance tests:
68
-
69
- ```gherkin
70
- Scenario: Successful Digital Agreement Execution
71
- Given an authenticated customer with an approved application
72
- And the agreement is in "PENDING_SIGNATURE" status
73
- When the customer provides their legal name "Alice Smith" and confirms agreement
74
- Then the response status is 200 OK
75
- And the agreement status transitions to "ACTIVE"
76
- And an execution audit record is persisted with timestamp, actorId, and IP address
77
- And a transactional confirmation notification is queued for delivery
78
- ```
79
-
80
- ### Writing Rules for Gherkin Scenarios
81
- - **Use Active Voice:** State explicit actor actions (`When the user clicks "Confirm Agreement"` rather than passive `When the button is clicked`).
82
- - **One Observable Behavior Per Scenario:** Focus each scenario on one specific state transition or business invariant.
83
- - **Cover Both Happy and Unhappy Paths:** Every feature must include positive paths and negative failure assertions.
84
-
85
- ---
86
-
87
- ## 4. Negative Scope & Edge Case Matrices
88
-
89
- - **Out-of-Scope (Non-Goals):** Explicitly document what will NOT be built in this increment to prevent scope creep and align expectations.
90
- - **Edge Case Matrix:** Map all potential failure states to standardized RFC 7807 problem details and HTTP status codes:
91
- - `400 Bad Request`: Schema validation failures, missing required fields.
92
- - `401 Unauthorized`: Missing or invalid session tokens.
93
- - `403 Forbidden`: Cross-tenant boundary violations, role privilege deficits.
94
- - `404 Not Found`: Resource non-existence (or masked enumeration).
95
- - `409 Conflict`: Duplicate unique constraints, state machine transition invalidity.
96
- - `422 Unprocessable Entity`: Semantic domain invariant violations.
97
- - `429 Too Many Requests`: Rate limiter token exhaustion.
98
- - `500 Internal Server Error`: Unhandled upstream infrastructure failures.
1
+ # Requirements Engineering, INVEST Stories & Gherkin Criteria
2
+
3
+ > **Core Mandate:** Decompose business requirements into vertically sliced INVEST user stories, executable Gherkin acceptance criteria, and exhaustive edge case matrices, acknowledging that stories are conversation starters rather than full specification documents.
4
+
5
+ ---
6
+
7
+ ## 1. Are User Stories Requirements?
8
+
9
+ In modern product engineering (per Scrum.org and XP principles), **user stories are NOT requirements**. Rather, a user story is one specific, highly effective technique used to *express, capture, and explore* user-centric requirements.
10
+
11
+ ### Key Distinctions
12
+ - **A Token for Conversation:** A user story is a "placeholder" or token promising a future conversation. It captures the essence, not every granular detail upfront.
13
+ - **The "Pidgin Language" Bridge:** A pidgin language is a simplified common language that allows people with different native tongues to trade and work together. User stories act as a pidgin language bridging the business/customer perspective and the software engineering architecture without forcing either side to abandon their domain language.
14
+ - **Ron Jeffries' 3 C's of User Stories:**
15
+ 1. **Card:** The physical index card or digital ticket capturing the intent (`As a... I want to... So that...`).
16
+ 2. **Conversation:** The collaborative discussion between Product Owner, stakeholders, and developers where details and trade-offs are co-created.
17
+ 3. **Confirmation:** The executable acceptance criteria and automated tests that prove whether the story satisfies its intent.
18
+
19
+ ### Non-Story Requirements
20
+ Not all system requirements originate from an end-user persona or fit the user story syntax. High-integrity systems also require:
21
+ - **System Invariants:** Core domain rules (e.g., "A transaction cannot be completed without a verified payment instrument").
22
+ - **Non-Functional Requirements (NFRs):** Latency SLAs, encryption standards, concurrency limits, and accessibility compliance (WCAG 2.2 AA).
23
+ - **Architectural Spikes:** Time-boxed exploratory investigations to resolve technical unknowns.
24
+ - **Regulatory & Security Controls:** SOC 2 audit log immutability, GDPR data erasure rights, and OWASP Top 10 defenses.
25
+
26
+ These requirements should be operationalized as explicit acceptance constraints, architectural fitness functions, or dedicated technical backlog items.
27
+
28
+ ---
29
+
30
+ ## 2. INVEST User Story Framework & Vertical Cake Slicing
31
+
32
+ Ensure every user story satisfies Bill Wake's **INVEST** criteria:
33
+
34
+ - **I - Independent:** Sliced vertically to minimize conceptual overlap. Can be scheduled, implemented, and released in any sequence without blocking peer stories.
35
+ - **N - Negotiable:** Captures the core essence and problem space, not a rigid implementation contract. Specific details are co-created during pair programming and TDD.
36
+ - **V - Valuable:** Delivers observable, direct benefit to the customer or business stakeholder.
37
+ - **E - Estimable:** Well-understood and right-sized so the team can gauge complexity. Unknowns are resolved via prior time-boxed spikes.
38
+ - **S - Small:** Sized to be completed within 1–2 development days. Small stories yield higher estimation accuracy and rapid feedback.
39
+ - **T - Testable:** Accompanied by concrete pass/fail assertions. Non-functional requirements are operationalized into automated tests early.
40
+
41
+ ### The Multi-Layer Cake Metaphor (Vertical Slicing)
42
+ Think of a complete feature as a multi-layer cake:
43
+ ```mermaid
44
+ flowchart TD
45
+ subgraph Cake["The Multi-Layer Cake (Vertical Slicing)"]
46
+ direction TB
47
+ L1["Presentation / UI Layer"]
48
+ L2["Business Logic & Application Use Case"]
49
+ L3["Domain Invariants & Entities"]
50
+ L4["Persistence & Database Layer"]
51
+ L1 --- L2 --- L3 --- L4
52
+ end
53
+
54
+ Slice["Vertical Cake Slice<br/>(Customer gets a taste of every layer)"]
55
+ Slice --> L1
56
+ Slice --> L2
57
+ Slice --> L3
58
+ Slice --> L4
59
+ ```
60
+ - **Horizontal Slicing (Anti-Pattern):** Implementing only the database schema or only the UI mock. A full database table has zero observable value to the customer without presentation and logic layers.
61
+ - **Vertical Slicing (Golden Standard):** Slicing thin through all layers (UI ➔ API ➔ Domain ➔ DB). Even a minimal vertical slice provides working functionality that can be deployed, tested, and validated empirically.
62
+
63
+ ---
64
+
65
+ ## 3. Executable Gherkin Acceptance Criteria
66
+
67
+ Draft concrete, actionable scenarios directly convertible into automated acceptance tests:
68
+
69
+ ```gherkin
70
+ Scenario: Successful Digital Agreement Execution
71
+ Given an authenticated customer with an approved application
72
+ And the agreement is in "PENDING_SIGNATURE" status
73
+ When the customer provides their legal name "Alice Smith" and confirms agreement
74
+ Then the response status is 200 OK
75
+ And the agreement status transitions to "ACTIVE"
76
+ And an execution audit record is persisted with timestamp, actorId, and IP address
77
+ And a transactional confirmation notification is queued for delivery
78
+ ```
79
+
80
+ ### Writing Rules for Gherkin Scenarios
81
+ - **Use Active Voice:** State explicit actor actions (`When the user clicks "Confirm Agreement"` rather than passive `When the button is clicked`).
82
+ - **One Observable Behavior Per Scenario:** Focus each scenario on one specific state transition or business invariant.
83
+ - **Cover Both Happy and Unhappy Paths:** Every feature must include positive paths and negative failure assertions.
84
+
85
+ ---
86
+
87
+ ## 4. Negative Scope & Edge Case Matrices
88
+
89
+ - **Out-of-Scope (Non-Goals):** Explicitly document what will NOT be built in this increment to prevent scope creep and align expectations.
90
+ - **Edge Case Matrix:** Map all potential failure states to standardized RFC 9457 problem details and HTTP status codes:
91
+ - `400 Bad Request`: Schema validation failures, missing required fields.
92
+ - `401 Unauthorized`: Missing or invalid session tokens.
93
+ - `403 Forbidden`: Cross-tenant boundary violations, role privilege deficits.
94
+ - `404 Not Found`: Resource non-existence (or masked enumeration).
95
+ - `409 Conflict`: Duplicate unique constraints, state machine transition invalidity.
96
+ - `422 Unprocessable Entity`: Semantic domain invariant violations.
97
+ - `429 Too Many Requests`: Rate limiter token exhaustion.
98
+ - `500 Internal Server Error`: Unhandled upstream infrastructure failures.
@@ -1,53 +1,53 @@
1
- # Application Security, Cryptography & Regulatory Compliance
2
-
3
- > **Core Mandate:** Enforce OWASP Top 10 security defenses, cryptographic rigor, token bucket rate limiting, SOC 2 Type II security controls, ISO/IEC 27001 standards, and GDPR data erasure rights.
4
-
5
- ---
6
-
7
- ## 1. OWASP Top 10 Application Security Defenses
8
-
9
- Production software must systematically eliminate OWASP Top 10 attack vectors:
10
-
11
- 1. **Injection Defense (SQL / Command / LDAP)**:
12
- - Always use parameterized queries and prepared statements. Never concatenate untrusted strings into database queries or shell command strings.
13
- 2. **Cross-Site Scripting (XSS)**:
14
- - Standardize on modern framework auto-escaping (React, Vue, Svelte). Strictly forbid `dangerouslySetInnerHTML` or `v-html` unless sanitized by a verified sanitizer (e.g. DOMPurify).
15
- 3. **Server-Side Request Forgery (SSRF)**:
16
- - When fetching URLs provided by users, validate hostnames against an explicit domain allowlist. Never make outbound requests to private RFC 1918 subnets (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) or cloud metadata endpoints (`169.254.169.254`).
17
- 4. **Security Misconfiguration & Headers**:
18
- - Enforce secure HTTP response headers:
19
- ```http
20
- Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
21
- X-Content-Type-Options: nosniff
22
- X-Frame-Options: DENY
23
- Content-Security-Policy: default-src 'self'; script-src 'self';
24
- ```
25
-
26
- ---
27
-
28
- ## 2. Cryptographic Standards & Rate Limiting
29
-
30
- ### Cryptographic Rigor
31
- - **Password Hashing**: Use **Argon2id** (minimum 64MB memory, 3 iterations) or **bcrypt** (work factor $\ge 12$). Never use SHA-256, SHA-1, or MD5 for password storage.
32
- - **Data Encryption at Rest**: Encrypt sensitive PII, access tokens, and secrets using **AES-256-GCM** or **ChaCha20-Poly1305** with authenticated encryption.
33
- - **Data in Transit**: Mandate **TLS 1.3** across all external and internal microservice communication.
34
-
35
- ### Distributed Rate Limiting
36
- Protect APIs against brute force, scraping, and denial-of-service (DoS) attacks using a distributed Token Bucket or Leaky Bucket algorithm backed by Redis:
37
- - **Authentication Endpoints (`/login`, `/signup`)**: Strict limit of 5 requests per minute per IP.
38
- - **Public API Endpoints**: Default limit of 100 requests per minute per IP/API token.
39
- - **Response Headers**: Return RFC 6585 headers: `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset`, and `429 Too Many Requests` when exceeded.
40
-
41
- ---
42
-
43
- ## 3. Regulatory Compliance: SOC 2, ISO 27001 & GDPR
44
-
45
- All systems handling sensitive, customer, or enterprise data must satisfy fundamental compliance controls:
46
-
47
- 1. **Immutable Audit Trails (SOC 2 CC6.8 / ISO 27001 A.12.4)**:
48
- - All state mutations, privilege changes, and authentication events must write to an immutable audit log recording: `timestamp`, `actorId`, `tenantId`, `action`, `resourceId`, `clientIp`, and `userAgent`.
49
- - Audit logs must be retained in append-only storage and protected from tampering or deletion.
50
- 2. **GDPR Data Erasure Rights (Article 17 "Right to be Forgotten")**:
51
- - Systems must provide an automated data erasure pipeline capable of permanently deleting or cryptographically pseudonymizing user PII across all databases and backups within 30 days of a verified request.
52
- 3. **Least Privilege Access (SOC 2 CC6.1)**:
53
- - Developers and runtime services must operate under strict principle of least privilege. Production database credentials and encryption keys must never be accessible in local development environments.
1
+ # Application Security, Cryptography & Regulatory Compliance
2
+
3
+ > **Core Mandate:** Enforce OWASP Top 10 security defenses, cryptographic rigor, token bucket rate limiting, SOC 2 Type II security controls, ISO/IEC 27001 standards, and GDPR data erasure rights.
4
+
5
+ ---
6
+
7
+ ## 1. OWASP Top 10 Application Security Defenses
8
+
9
+ Production software must systematically eliminate OWASP Top 10 attack vectors:
10
+
11
+ 1. **Injection Defense (SQL / Command / LDAP)**:
12
+ - Always use parameterized queries and prepared statements. Never concatenate untrusted strings into database queries or shell command strings.
13
+ 2. **Cross-Site Scripting (XSS)**:
14
+ - Standardize on modern framework auto-escaping (React, Vue, Svelte). Strictly forbid `dangerouslySetInnerHTML` or `v-html` unless sanitized by a verified sanitizer (e.g. DOMPurify).
15
+ 3. **Server-Side Request Forgery (SSRF)**:
16
+ - When fetching URLs provided by users, validate hostnames against an explicit domain allowlist. Never make outbound requests to private RFC 1918 subnets (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) or cloud metadata endpoints (`169.254.169.254`).
17
+ 4. **Security Misconfiguration & Headers**:
18
+ - Enforce secure HTTP response headers:
19
+ ```http
20
+ Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
21
+ X-Content-Type-Options: nosniff
22
+ X-Frame-Options: DENY
23
+ Content-Security-Policy: default-src 'self'; script-src 'self';
24
+ ```
25
+
26
+ ---
27
+
28
+ ## 2. Cryptographic Standards & Rate Limiting
29
+
30
+ ### Cryptographic Rigor
31
+ - **Password Hashing**: Use **Argon2id** (minimum 64MB memory, 3 iterations) or **bcrypt** (work factor $\ge 12$). Never use SHA-256, SHA-1, or MD5 for password storage.
32
+ - **Data Encryption at Rest**: Encrypt sensitive PII, access tokens, and secrets using **AES-256-GCM** or **ChaCha20-Poly1305** with authenticated encryption.
33
+ - **Data in Transit**: Mandate **TLS 1.3** across all external and internal microservice communication.
34
+
35
+ ### Distributed Rate Limiting
36
+ Protect APIs against brute force, scraping, and denial-of-service (DoS) attacks using a distributed Token Bucket or Leaky Bucket algorithm backed by Redis:
37
+ - **Authentication Endpoints (`/login`, `/signup`)**: Strict limit of 5 requests per minute per IP.
38
+ - **Public API Endpoints**: Default limit of 100 requests per minute per IP/API token.
39
+ - **Response Headers**: Return RFC 6585 headers: `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset`, and `429 Too Many Requests` when exceeded.
40
+
41
+ ---
42
+
43
+ ## 3. Regulatory Compliance: SOC 2, ISO 27001 & GDPR
44
+
45
+ All systems handling sensitive, customer, or enterprise data must satisfy fundamental compliance controls:
46
+
47
+ 1. **Immutable Audit Trails (SOC 2 CC6.8 / ISO 27001 A.12.4)**:
48
+ - All state mutations, privilege changes, and authentication events must write to an immutable audit log recording: `timestamp`, `actorId`, `tenantId`, `action`, `resourceId`, `clientIp`, and `userAgent`.
49
+ - Audit logs must be retained in append-only storage and protected from tampering or deletion.
50
+ 2. **GDPR Data Erasure Rights (Article 17 "Right to be Forgotten")**:
51
+ - Systems must provide an automated data erasure pipeline capable of permanently deleting or cryptographically pseudonymizing user PII across all databases and backups within 30 days of a verified request.
52
+ 3. **Least Privilege Access (SOC 2 CC6.1)**:
53
+ - Developers and runtime services must operate under strict principle of least privilege. Production database credentials and encryption keys must never be accessible in local development environments.
@@ -1,88 +1,88 @@
1
- # Server-Driven UI (SDUI) & Dynamic Theming
2
-
3
- > **Core Mandate:** Enforce metadata-driven UI rendering from declarative backend schemas, eliminating client-side tenant code forks, and inject white-label branding via W3C Design Tokens (DTCG).
4
-
5
- ---
6
-
7
- ## 1. The YAGNI Gate: Static Client Components vs. Server-Driven UI
8
-
9
- Server-Driven UI requires building and maintaining a JSON schema specification, schema versioning, validation, and multi-platform component interpreters. **Never build a Server-Driven UI when standard client-side components and modern web deployments solve the problem.**
10
-
11
- ```mermaid
12
- flowchart TD
13
- subgraph SDUIGate["Server-Driven UI YAGNI Gate"]
14
- B1["1. Simple Baseline (Day 1)<br/>• Standard React/JSX components styled with Tailwind CSS<br/>• Instant web deployments via continuous delivery<br/>• Zero dynamic layout interpreters or backend schema JSONs"]
15
- B2["2. Anti-Triggers (Forbidden)<br/>• Web-only SaaS dashboards, internal admin tools, or landing pages<br/>• Early-stage products iterating on UI layouts<br/>• Teams without multi-platform client parity requirements"]
16
- B3["3. The Tipping Point (Graduation)<br/>• Native mobile apps (iOS/Android) where app store review cycles delay urgent UI/flow mutations<br/>• Multi-tenant white-label products where customers dynamically construct custom form layouts<br/>• Cross-platform parity: 1 backend drives layout across Web, iOS SwiftUI, and Android Jetpack Compose"]
17
- B1 -->|Forbidden if web-only or early| B2
18
- B1 -->|Triggered by multi-platform or white-label| B3
19
- end
20
- ```
21
-
22
- ---
23
-
24
- ## 2. Declarative Client-Agnostic SDUI Schema
25
-
26
- The backend provides a declarative UI layout schema describing fields, layouts, dynamic visibility rules (via Common Expression Language or JSON expressions), and allowed actions (`_actions`):
27
-
28
- ```json
29
- {
30
- "view": "OrderEdit",
31
- "layout": "two-column",
32
- "sections": [
33
- {
34
- "id": "general",
35
- "title": "General Details",
36
- "components": [
37
- { "type": "TextInput", "id": "orderNumber", "label": "Order #", "readOnly": true },
38
- { "type": "TextInput", "id": "custom_attributes.poNumber", "label": "PO Number", "required": true }
39
- ]
40
- },
41
- {
42
- "id": "tax",
43
- "title": "Tax Exemption",
44
- "visibleIf": "order.custom_attributes.isTaxExempt == true",
45
- "components": [
46
- { "type": "TextInput", "id": "custom_attributes.taxExemptionId", "label": "Tax ID", "required": true }
47
- ]
48
- }
49
- ],
50
- "_actions": [
51
- { "action": "SUBMIT_FOR_APPROVAL", "label": "Submit Order", "method": "POST", "target": "/api/v1/orders/123/submit" }
52
- ]
53
- }
54
- ```
55
-
56
- ---
57
-
58
- ## 3. Multi-Platform Component Registries
59
-
60
- Frontend clients (Web, Mobile, Desktop) never contain hardcoded tenant branching. Each platform implements a local **Component Registry** mapping backend descriptors to native platform primitives:
61
-
62
- - **Web Clients**: Rendered dynamically via accessible primitives (Web Components, React, Vue, Svelte, or Solid).
63
- - **Mobile Clients**: Rendered natively via Flutter, iOS SwiftUI, or Android Jetpack Compose.
64
- - **Desktop Clients**: Rendered natively via Tauri or cross-platform toolkits.
65
-
66
- ---
67
-
68
- ## 4. Universal Design Tokens (W3C DTCG Standard)
69
-
70
- Manage tenant white-label branding and design systems via the **W3C Design Tokens Community Group (DTCG)** specification:
71
-
72
- ```json
73
- {
74
- "color": {
75
- "brand": {
76
- "primary": { "$value": "#1e40af", "$type": "color" },
77
- "accent": { "$value": "#f59e0b", "$type": "color" }
78
- }
79
- },
80
- "dimension": {
81
- "radius": {
82
- "base": { "$value": "6px", "$type": "dimension" }
83
- }
84
- }
85
- }
86
- ```
87
-
88
- - **Universal Compilation**: Process tenant `tokens.json` files using **Style Dictionary** to compile dynamic themes at runtime for CSS Custom Properties (`--color-brand-primary`), Android XML / Compose, and iOS Swift tokens without code redeployments.
1
+ # Server-Driven UI (SDUI) & Dynamic Theming
2
+
3
+ > **Core Mandate:** Enforce metadata-driven UI rendering from declarative backend schemas, eliminating client-side tenant code forks, and inject white-label branding via W3C Design Tokens (DTCG).
4
+
5
+ ---
6
+
7
+ ## 1. The YAGNI Gate: Static Client Components vs. Server-Driven UI
8
+
9
+ Server-Driven UI requires building and maintaining a JSON schema specification, schema versioning, validation, and multi-platform component interpreters. **Never build a Server-Driven UI when standard client-side components and modern web deployments solve the problem.**
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ subgraph SDUIGate["Server-Driven UI YAGNI Gate"]
14
+ B1["1. Simple Baseline (Day 1)<br/>• Standard React/JSX components styled with Tailwind CSS<br/>• Instant web deployments via continuous delivery<br/>• Zero dynamic layout interpreters or backend schema JSONs"]
15
+ B2["2. Anti-Triggers (Forbidden)<br/>• Web-only SaaS dashboards, internal admin tools, or landing pages<br/>• Early-stage products iterating on UI layouts<br/>• Teams without multi-platform client parity requirements"]
16
+ B3["3. The Tipping Point (Graduation)<br/>• Native mobile apps (iOS/Android) where app store review cycles delay urgent UI/flow mutations<br/>• Multi-tenant white-label products where customers dynamically construct custom form layouts<br/>• Cross-platform parity: 1 backend drives layout across Web, iOS SwiftUI, and Android Jetpack Compose"]
17
+ B1 -->|Forbidden if web-only or early| B2
18
+ B1 -->|Triggered by multi-platform or white-label| B3
19
+ end
20
+ ```
21
+
22
+ ---
23
+
24
+ ## 2. Declarative Client-Agnostic SDUI Schema
25
+
26
+ The backend provides a declarative UI layout schema describing fields, layouts, dynamic visibility rules (via Common Expression Language or JSON expressions), and allowed actions (`_actions`):
27
+
28
+ ```json
29
+ {
30
+ "view": "OrderEdit",
31
+ "layout": "two-column",
32
+ "sections": [
33
+ {
34
+ "id": "general",
35
+ "title": "General Details",
36
+ "components": [
37
+ { "type": "TextInput", "id": "orderNumber", "label": "Order #", "readOnly": true },
38
+ { "type": "TextInput", "id": "custom_attributes.poNumber", "label": "PO Number", "required": true }
39
+ ]
40
+ },
41
+ {
42
+ "id": "tax",
43
+ "title": "Tax Exemption",
44
+ "visibleIf": "order.custom_attributes.isTaxExempt == true",
45
+ "components": [
46
+ { "type": "TextInput", "id": "custom_attributes.taxExemptionId", "label": "Tax ID", "required": true }
47
+ ]
48
+ }
49
+ ],
50
+ "_actions": [
51
+ { "action": "SUBMIT_FOR_APPROVAL", "label": "Submit Order", "method": "POST", "target": "/api/v1/orders/123/submit" }
52
+ ]
53
+ }
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 3. Multi-Platform Component Registries
59
+
60
+ Frontend clients (Web, Mobile, Desktop) never contain hardcoded tenant branching. Each platform implements a local **Component Registry** mapping backend descriptors to native platform primitives:
61
+
62
+ - **Web Clients**: Rendered dynamically via accessible primitives (Web Components, React, Vue, Svelte, or Solid).
63
+ - **Mobile Clients**: Rendered natively via Flutter, iOS SwiftUI, or Android Jetpack Compose.
64
+ - **Desktop Clients**: Rendered natively via Tauri or cross-platform toolkits.
65
+
66
+ ---
67
+
68
+ ## 4. Universal Design Tokens (W3C DTCG Standard)
69
+
70
+ Manage tenant white-label branding and design systems via the **W3C Design Tokens Community Group (DTCG)** specification:
71
+
72
+ ```json
73
+ {
74
+ "color": {
75
+ "brand": {
76
+ "primary": { "$value": "#1e40af", "$type": "color" },
77
+ "accent": { "$value": "#f59e0b", "$type": "color" }
78
+ }
79
+ },
80
+ "dimension": {
81
+ "radius": {
82
+ "base": { "$value": "6px", "$type": "dimension" }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ - **Universal Compilation**: Process tenant `tokens.json` files using **Style Dictionary** to compile dynamic themes at runtime for CSS Custom Properties (`--color-brand-primary`), Android XML / Compose, and iOS Swift tokens without code redeployments.