azcodr 1.2.2 → 1.4.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 (69) hide show
  1. package/.agents/hooks.json.example +42 -0
  2. package/.agents/mcp_config.json.example +24 -0
  3. package/.agents/skills/agentic-architect/SKILL.md +14 -7
  4. package/.agents/skills/agentic-architect/references/agents_md_template.md +6 -3
  5. package/.agents/skills/agentic-architect/references/skill_architecture_inquiry.md +1 -1
  6. package/.agents/skills/agentic-architect/references/skill_template.md +2 -1
  7. package/.agents/skills/agentic-architect/scripts/validate_agentic_configs.sh +156 -4
  8. package/.agents/skills/clean-code-refactor/SKILL.md +6 -6
  9. package/.agents/skills/compliance-audit/SKILL.md +1 -1
  10. package/.agents/skills/lets-build/SKILL.md +12 -4
  11. package/.agents/skills/lets-build/references/hexagonal_bootstrap_scaffolds.md +1 -1
  12. package/.agents/skills/lets-build/references/project_readme_template.md +4 -4
  13. package/.agents/skills/lets-build/scripts/bootstrap_workspace.sh +63 -35
  14. package/.agents/skills/relentless-questioner/SKILL.md +10 -5
  15. package/AGENTS.md +25 -41
  16. package/README.md +27 -43
  17. package/bin/azcodr.js +3 -82
  18. package/docs/knowledge/ubiquitous_language.md +1 -6
  19. package/docs/rules/agentic_configuration.md +120 -32
  20. package/docs/rules/api_architecture.md +179 -0
  21. package/docs/rules/caching.md +30 -13
  22. package/docs/rules/cloud_native.md +10 -12
  23. package/docs/rules/cqrs.md +203 -0
  24. package/docs/rules/database_design.md +125 -0
  25. package/docs/rules/database_operations.md +56 -14
  26. package/docs/rules/design_patterns.md +18 -11
  27. package/docs/rules/devops_ci_cd.md +76 -0
  28. package/docs/rules/domain_driven_design.md +17 -13
  29. package/docs/rules/feature_flags.md +21 -4
  30. package/docs/rules/frontend_architecture.md +157 -0
  31. package/docs/rules/multitenancy_architecture.md +98 -0
  32. package/docs/rules/product_ownership.md +22 -27
  33. package/docs/rules/requirements_engineering.md +16 -14
  34. package/docs/rules/security_compliance.md +53 -0
  35. package/docs/rules/server_driven_ui.md +20 -3
  36. package/docs/rules/test_driven_development.md +118 -62
  37. package/docs/rules/type_safety.md +65 -0
  38. package/docs/rules/ui_ux_architecture.md +33 -30
  39. package/docs/rules/workflow_state_machines.md +20 -3
  40. package/lib/index.d.ts +0 -30
  41. package/lib/scaffold.js +9 -46
  42. package/memory.md +158 -14
  43. package/package.json +2 -3
  44. package/changes.md +0 -79
  45. package/docs/rules/accessibility.md +0 -31
  46. package/docs/rules/advanced_api_patterns.md +0 -104
  47. package/docs/rules/api_versioning.md +0 -113
  48. package/docs/rules/application_security.md +0 -23
  49. package/docs/rules/architecture_decision_records.md +0 -42
  50. package/docs/rules/compliance.md +0 -25
  51. package/docs/rules/container_infrastructure.md +0 -32
  52. package/docs/rules/continuous_deployment.md +0 -24
  53. package/docs/rules/continuous_integration.md +0 -20
  54. package/docs/rules/continuous_learning.md +0 -29
  55. package/docs/rules/database_integrity.md +0 -80
  56. package/docs/rules/database_migrations.md +0 -41
  57. package/docs/rules/database_performance.md +0 -44
  58. package/docs/rules/database_transactions.md +0 -81
  59. package/docs/rules/devsecops.md +0 -33
  60. package/docs/rules/multitenancy_isolation.md +0 -88
  61. package/docs/rules/react.md +0 -78
  62. package/docs/rules/rest_api_conventions.md +0 -46
  63. package/docs/rules/tenant_dynamic_schemas.md +0 -88
  64. package/docs/rules/tenant_pluggable_logic.md +0 -59
  65. package/docs/rules/test_isolation.md +0 -26
  66. package/docs/rules/typescript.md +0 -55
  67. package/docs/rules/ui_navigation.md +0 -20
  68. package/docs/rules/upstream_synchronization.md +0 -53
  69. package/docs/rules/workspace_isolation.md +0 -25
@@ -0,0 +1,157 @@
1
+ # Frontend Architecture & Client State Management
2
+
3
+ > **Core Mandate:** Enforce production-grade client architecture: accessible headless component primitives, WCAG 2.2 Level AA compliance, asynchronous server-state cache synchronization and deduplication, declarative contract schema form validation, bidirectional URL navigation synchronization, explicit 5-tier state separation, and symmetrical design tokens.
4
+
5
+ ---
6
+
7
+ ## 1. The YAGNI Gate: Semantic Markup & Headless Primitives vs. Premature Sprawl
8
+
9
+ Frontend engineering is frequently derailed by two opposing anti-patterns: **reinventing the wheel** (hand-rolling custom dialogs and bespoke CSS architectures) or **premature framework sprawl** (installing heavy global state machines for simple data flows).
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ subgraph Gate ["Frontend Architecture YAGNI Gate"]
14
+ B1["1. SIMPLE BASELINE (Day 1)"]
15
+ B1_D["• Semantic HTML/markup styled with utility classes.<br/>• Battle-tested accessible headless primitives (Radix, Melt, Kobalte, PrimeVue).<br/>• Zero bespoke CSS architectures, unstyled div modals, or Redux."]
16
+
17
+ B2["2. ANTI-TRIGGERS (Strictly Forbidden)"]
18
+ B2_D["• Headless backends, REST/gRPC microservices, or cloud workers.<br/>• Terminal CLI utilities, embedded libraries, or game engines.<br/>• Monolithic global state stores (Redux, MobX, Pinia) before separating server cache."]
19
+
20
+ B3["3. THE TIPPING POINT (Graduation Threshold)"]
21
+ B3_D["• Dynamic client interfaces with asynchronous server data fetching.<br/>• Multi-step declarative form submissions and complex workflows.<br/>• Strict WCAG 2.2 AA accessibility, focus trapping, and keyboard navigation."]
22
+
23
+ B1 --- B1_D
24
+ B2 --- B2_D
25
+ B3 --- B3_D
26
+ end
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 2. The Asymmetry Law: Outside-In Discovery vs. Inside-Out Execution
32
+
33
+ A fundamental architectural question is: **Does the User Interface dictate Business Logic, or does Business Logic dictate the UI?**
34
+
35
+ The answer is governed by the **Outside-In Discovery vs. Inside-Out Execution Asymmetry**:
36
+
37
+ ```mermaid
38
+ flowchart LR
39
+ subgraph Discovery ["Outside-In Discovery (Phase 1 & 2)"]
40
+ UI["User Interface & Interaction Model<br/>(Web GUI, Mobile, or Terminal CLI)"]
41
+ UC["Inbound Driving Port<br/>(Use Case / Command DTO)"]
42
+ UI -->|"Discovers Required Capabilities"| UC
43
+ end
44
+
45
+ subgraph Execution ["Inside-Out Execution (Phase 3 & 4)"]
46
+ DM["Domain Core & Invariants<br/>(100% UI-Agnostic Rules & State Machines)"]
47
+ AD["Outbound Driven Adapters<br/>(Database, Email, External Services)"]
48
+ UC -->|"Executes Isolated Logic"| DM
49
+ DM -->|"Persists / Notifies"| AD
50
+ end
51
+ ```
52
+
53
+ ### 1. Outside-In Discovery (Why Interaction Must Be Refined Early)
54
+ - The user's operational mental model, workflow steps, and interaction touchpoints (whether Web forms, CLI flags, or API endpoints) **guide the discovery of system capabilities**.
55
+ - If business logic is authored in a vacuum without interaction analysis, engineers build speculative methods and database models that do not align with user journeys (**The Anemic Core Antipattern**).
56
+ - *Mandate:* In Phase 1 (Requirements) and Phase 2 (Domain Analysis), interaction models and wireframe workflows must be refined early via [`product-analyst`](../../.agents/skills/product-analyst/SKILL.md) and [`ui_ux_architecture.md`](./ui_ux_architecture.md).
57
+
58
+ ### 2. Inside-Out Execution (Why Domain Logic Remains Pure)
59
+ - Once discovered, **business invariants are 100% decoupled from the UI**.
60
+ - A business rule (e.g. *"An invoice cannot be paid twice"*, *"Discount cannot exceed 50%"*) must never live in a React `onClick` handler, a component hook, or a CLI flag parser (**The Smart UI Antipattern**).
61
+ - The presentation layer merely parses user interaction into a plain **Command DTO** and calls an **Application Use Case** (Driving Port).
62
+ - If the Web UI is replaced with a CLI or a background job, the core domain logic requires **zero modifications**.
63
+
64
+ ### 3. What If a Project Has No UI? (Headless Topologies)
65
+ - For Headless Backends, Daemon Workers, and Embedded Systems:
66
+ - The **API Schema (OpenAPI / gRPC Protobuf) or Function Signature IS the UI**.
67
+ - For a CLI Utility, the **Command Pipeline (flags, stdin/stdout, exit codes)** IS the UI.
68
+ - The principle remains identical: the external interface defines the boundary contract, while the internal engine enforces pure invariants.
69
+
70
+ ---
71
+
72
+ ## 3. Component Primitives, Headless Accessibility & WCAG 2.2 Standards
73
+
74
+ - **Accessible Headless Primitives**: All interactive UI components (dialogs, dropdowns, selects, tabs, tooltips, popovers) must decouple behavioral accessibility (focus trapping, keyboard navigation, ARIA states) from visual presentation using headless primitives:
75
+ - *React:* `@radix-ui` / `shadcn/ui` in `@/components/ui/`
76
+ - *Vue:* `radix-vue` / `shadcn-vue` or `primevue`
77
+ - *Svelte:* `melt-ui` / `bits-ui`
78
+ - *Solid:* `@kobalte/core`
79
+ - *Angular:* `@angular/cdk/a11y`
80
+ - **Zero Unstyled Raw Elements**: Never create unstyled raw HTML modals, dropdowns, or custom select tags using raw `<div>` tags and ad-hoc mouse-only click handlers.
81
+ - **Focus Management & Trapping**:
82
+ - Modal dialogs must trap keyboard focus within the dialog container while open.
83
+ - Closing a dialog must return keyboard focus deterministically to the triggering element.
84
+ - **Visible Focus Indicators**: Never remove default outline rings (`outline: none`) without providing an explicit, high-contrast replacement (`focus-visible:ring-2 focus-visible:ring-offset-2`).
85
+ - **Dynamic Content & ARIA Live Regions**:
86
+ - Asynchronous notifications, toast alerts, and status updates must use `role="status"` or `aria-live="polite"` so screen readers announce changes without interrupting the user.
87
+ - Critical error alerts must use `role="alert"` or `aria-live="assertive"`.
88
+ - **Strict Prohibition of Native Dialogs**: Browser-native `window.alert()` and `window.confirm()` are strictly forbidden. Use accessible headless dialogs (`<ConfirmDialog />`).
89
+ - **Utility Styling & Class Merging (`cn` helper)**: Combine utility classes using deterministic class merging (e.g., `clsx` and `tailwind-merge` via `cn(...)`) to allow clean prop overrides and consistent theming.
90
+
91
+ ---
92
+
93
+ ## 4. Server-State Cache Synchronization & Invalidation
94
+
95
+ - **Decoupling Remote Cache from Local State**: Server state (owned remotely, asynchronous, shared across clients) must never be treated as local synchronous client state.
96
+ - **Mandatory Cache Synchronization Engine**: Asynchronous data fetching, caching, deduplication, and background revalidation must use a dedicated cache synchronization manager (e.g., TanStack Query, SWR, or RTK Query in React; Pinia Colada or VueUse `useFetch` in Vue; Superforms or SvelteKit load functions in Svelte; Angular Signals with HttpClient).
97
+ - **Elimination of Raw Lifecycle Fetch Loops**:
98
+ - *Anti-Pattern:* Uncoordinated manual fetching in component lifecycles (`useEffect(() => { fetch().then(...) })`, `onMounted`, `ngOnInit`) with hand-rolled `isLoading` and `error` boolean states.
99
+ - *Standard Pattern (Query Hook / Cache Invalidation):*
100
+ ```tsx
101
+ const { data: resources, isLoading, error } = useQuery({
102
+ queryKey: ['resources', tenantId],
103
+ queryFn: () => api.getResources(tenantId),
104
+ });
105
+ ```
106
+ - **Declarative Mutations & Cache Invalidation**:
107
+ - Mutations must declare side-effects that explicitly invalidate affected cache keys rather than imperatively splicing local component state arrays:
108
+ ```tsx
109
+ const queryClient = useQueryClient();
110
+ const createResourceMutation = useMutation({
111
+ mutationFn: (newResource: CreateResourceInput) => api.createResource(newResource),
112
+ onSuccess: () => {
113
+ queryClient.invalidateQueries({ queryKey: ['resources'] });
114
+ },
115
+ });
116
+ ```
117
+ - **Hierarchical Query Keys**: Format query keys hierarchically as structured tuples: `['entity', id, ...filters]`, e.g., `['orders', orderId]`, `['users', tenantId]`.
118
+
119
+ ---
120
+
121
+ ## 5. Form State Management & Fail-Fast Schema Validation
122
+
123
+ - **Mandatory Schema Validation**: Every form submission must be validated against a formal declarative schema (Zod, Valibot, standard-schema, or framework validator) that mirrors shared DTO/input contracts.
124
+ - **Dedicated Form State Engines**: Use dedicated form engines (React Hook Form, TanStack Form, VeeValidate, Superforms, Angular Reactive Forms) that track field dirty states, touched states, and asynchronous validation without triggering full component tree re-renders.
125
+ - **Zero Unvalidated Multi-Field Objects**:
126
+ - *Anti-Pattern:* Unvalidated ad-hoc dictionary state (`useState({ name: '', email: '' })`) with manual string checking in submit handlers.
127
+ - *Standard Pattern:*
128
+ ```tsx
129
+ const form = useForm<CreateUserInput>({
130
+ resolver: zodResolver(createUserSchema),
131
+ defaultValues: { name: '', email: '' },
132
+ });
133
+ ```
134
+ - **Accessible Error Linking**: Form inputs must bind validation errors to `aria-invalid="true"` and `aria-describedby="<field>-error"`. Every input must have an associated semantic `<label>`.
135
+
136
+ ---
137
+
138
+ ## 6. The 5-Tier State Hierarchy & Bidirectional URL Navigation
139
+
140
+ Never dump all application state into a single global state container. Enforce strict categorical separation across 5 distinct lifecycles:
141
+
142
+ 1. **Server State (Remote Cache)**: Managed exclusively by the query cache engine; invalidated by resource keys.
143
+ 2. **URL State (Navigation / Search / Pagination / Filters)**:
144
+ - Must synchronize bidirectionally with URL search parameters (`useSearchParams`) to ensure deep linkability, bookmarkability, and seamless browser history (back/forward) navigation.
145
+ - Standard format: `?tab=security&page=2&limit=25&sort=createdAt&order=desc&status=ACTIVE`.
146
+ - Modals and drawers representing actionable entities must synchronize with the URL (e.g. `?modal=edit-user&userId=123`).
147
+ 3. **Form State (Transient Edits)**: Managed by form validation engines; discarded after submission or reset.
148
+ 4. **Local Component State (Ephemeral UI)**: Managed by primitive local component state (`useState`, `ref`, `$state`) strictly for local UI toggles (dropdown open, accordion expanded, hover).
149
+ 5. **Global Application State (Session / Context)**: Managed by lightweight client stores (Zustand, Pinia, Context, Signals) strictly for cross-cutting session data (current user, tenant context, active feature flags).
150
+ 6. **Data Grids & Large Tables**: When building sortable, paginated, or virtualized tables, standardize on headless table engines (TanStack Table, AG Grid) with row virtualization for datasets exceeding 100 rows.
151
+
152
+ ---
153
+
154
+ ## 7. Theme Architecture & Symmetrical Design Tokens
155
+
156
+ - **Symmetric Design Tokens**: Ensure foundational CSS variables (`--background`, `--foreground`, `--card`, `--border`, `--popover`) are symmetrically declared across `:root` and `.dark`. Omitted root tokens in `.dark` result in unstyled backgrounds and illegible text when switching themes.
157
+ - **System Preference Detection & Reactive Synchronization**: `ThemeProvider` implementations must listen to `window.matchMedia('(prefers-color-scheme: dark)')` with dynamic event listeners so OS appearance toggles seamlessly propagate in real-time, and synchronize `document.documentElement.style.colorScheme = resolvedTheme` to ensure browser-native elements (scrollbars, input widgets) match the active theme.
@@ -0,0 +1,98 @@
1
+ # Multi-Tenancy Architecture, Isolation & Extensibility
2
+
3
+ > **Core Mandate:** Enforce tenant context resolution from trusted cryptographic tokens, strict data isolation across the 4 tenancy models, leak-proof PostgreSQL Row-Level Security (RLS), and YAGNI-gated tenant extensibility (dynamic JSON schemas and sandboxed pluggable logic).
4
+
5
+ ---
6
+
7
+ ## 1. The Multi-Tenancy YAGNI Gate: Single-Tenant vs. Shared SaaS
8
+
9
+ Multi-tenancy introduces significant operational complexity: tenant routing, cross-tenant data leak risks, noisy neighbor resource starvation, and complex database migrations. **Never force multi-tenant abstractions onto applications that execute in single-tenant boundaries.**
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ subgraph MultiTenancyGate["Multi-Tenancy YAGNI Gate"]
14
+ B1["1. Simple Baseline (Day 1)<br/>• Single-tenant application architecture<br/>• Standard database tables without tenant foreign keys<br/>• Zero RLS policies, tenant interceptors, or dynamic schemas"]
15
+ B2["2. Anti-Triggers (Forbidden)<br/>• Single-tenant on-premise deployments or dedicated instances<br/>• Internal employee enterprise tools, developer CLIs, or games<br/>• Early-stage prototypes validating core domain logic"]
16
+ B3["3. The Tipping Point (Graduation)<br/>• Multi-tenant B2B SaaS where independent organizations share infrastructure<br/>• Strict legal, SOC 2, and regulatory mandates prohibiting cross-tenant data leakage"]
17
+ B1 -->|Forbidden if single-tenant| B2
18
+ B1 -->|Triggered by B2B SaaS requirements| B3
19
+ end
20
+ ```
21
+
22
+ ---
23
+
24
+ ## 2. Tenant Context Resolution
25
+
26
+ Tenant identity must be resolved at the edge/gateway from **cryptographically verified session context**, never from spoofable client input:
27
+
28
+ ```mermaid
29
+ flowchart LR
30
+ Req["Incoming Request"] --> Auth["Auth Middleware<br/>Extract Verified tenantId from JWT"]
31
+ Auth --> Ctx["AsyncLocalStorage / Context"]
32
+ Ctx --> DB["Database Connection<br/>SET LOCAL app.current_tenant_id"]
33
+ Ctx --> Audit["Audit / Event Log<br/>Tagged with tenantId"]
34
+ ```
35
+
36
+ ### Invariants:
37
+ 1. **Never Trust Raw Query/Body Parameters**: Never accept `?tenantId=...` or `{ tenantId: "..." }` on public mutations without validating that the authenticated session owns that tenant.
38
+ 2. **Ambient Context Propagation**: Bind the resolved `tenantId` to an ambient request context (e.g. `AsyncLocalStorage` in Node, `ThreadLocal` in Java, `context.Context` in Go) to prevent passing tenant IDs manually through every service layer.
39
+
40
+ ---
41
+
42
+ ## 3. The 4 Universal Data Isolation Models
43
+
44
+ Choose the isolation model matching your security classification and cost profile:
45
+
46
+ | Model | Isolation Mechanism | Operational Trade-off | Compliance Target |
47
+ |---|---|---|---|
48
+ | **1. Pooled with RLS** | Shared DB, shared schema; tables partitioned by `tenant_id` + Postgres RLS. | Lowest infrastructure cost, highest engineering rigor required. | Standard B2B SaaS, SOC 2 Type II. |
49
+ | **2. Silo Schema** | Shared DB, separate database schema per tenant (`tenant_acme.*`). | High isolation; complex schema migrations across hundreds of schemas. | Regulated SaaS, HIPAA, FinTech. |
50
+ | **3. Silo Database** | Separate physical or logical database instance per tenant. | Highest cost and isolation; zero cross-tenant blast radius. | Enterprise Dedicated, PCI-DSS Level 1. |
51
+ | **4. App-Level Interceptor** | Shared DB, ORM/query builder automatically appends `WHERE tenant_id = :id`. | Brittle; human error in ad-hoc raw SQL queries bypasses isolation. | Forbidden for high-security applications. |
52
+
53
+ ---
54
+
55
+ ## 4. PostgreSQL Row-Level Security (RLS) Invariants
56
+
57
+ When using **Model 1 (Pooled with RLS)**, enforce data isolation at the database engine level so that even a buggy or malicious application query cannot access another tenant's rows:
58
+
59
+ ### 1. Dual-Lock Table Setup
60
+ Every table containing tenant-scoped data must enable and force RLS:
61
+ ```sql
62
+ ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
63
+ ALTER TABLE orders FORCE ROW LEVEL SECURITY;
64
+ ```
65
+ *(The `FORCE` clause ensures that table owners and superusers are also bound by the policy).*
66
+
67
+ ### 2. Session Context Binding
68
+ The application connection pool must initialize the tenant session variable inside every transactional checkout:
69
+ ```sql
70
+ -- Executed inside transaction before running queries
71
+ SELECT set_config('app.current_tenant_id', :tenantId, true);
72
+ ```
73
+
74
+ ### 3. Declarative Tenant Isolation Policy
75
+ ```sql
76
+ CREATE POLICY tenant_isolation_policy ON orders
77
+ AS RESTRICTIVE
78
+ FOR ALL
79
+ TO application_user
80
+ USING (tenant_id = NULLIF(current_setting('app.current_tenant_id', true), '')::UUID)
81
+ WITH CHECK (tenant_id = NULLIF(current_setting('app.current_tenant_id', true), '')::UUID);
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 5. Advanced Tenant Extensibility (YAGNI Gated)
87
+
88
+ ### 5.1. Dynamic Schemas (Runtime Custom Fields)
89
+ - **Tipping Point:** External enterprise tenants require self-service custom fields without engineering running relational DDL migrations.
90
+ - **Hybrid Storage Pattern:** Core relational columns for shared invariants + `custom_attributes JSONB` validated against **JSON Schema Draft 2020-12** stored per tenant.
91
+ - **Fail-Fast Schema Validation:** Custom field inputs must be validated against the tenant's compiled JSON schema before database persistence.
92
+
93
+ ### 5.2. Pluggable Tenant Logic (Sandboxed Scripting)
94
+ - **Tipping Point:** Enterprise tenants require custom business logic (tax calculation, approval routing) executed at runtime.
95
+ - **Zero Raw `eval()`**: Never execute tenant code via raw `eval()`, Python `exec()`, or NodeJS VM isolates.
96
+ - **Safe Sandboxing**:
97
+ - *Simple Expressions:* Use **Common Expression Language (CEL)** (Google) for safe, deterministic boolean and mathematical evaluation.
98
+ - *Complex Logic:* Compile tenant extension plugins to **WebAssembly (Wasm)** executed via Wasmer or Wasmtime with strict CPU time and memory quotas.
@@ -41,20 +41,12 @@ The only vehicle through which a team delivers actual product value is a usable,
41
41
 
42
42
  The OKR framework connects overarching strategic vision to sprint execution and product backlog ordering.
43
43
 
44
- ```
45
- Company Vision & Strategy
46
- │
47
- ▼
48
- Strategic OKRs (Annual / Quarterly)
49
- │
50
- ▼
51
- Product Goal (Long-Term Commitment)
52
- │
53
- ▼
54
- Product Backlog (Emergent, Ordered PBIs)
55
- │
56
- ▼
57
- Sprint Goal (Tactical Increment)
44
+ ```mermaid
45
+ flowchart TD
46
+ V["Company Vision & Strategy"] --> OKR["Strategic OKRs (Annual / Quarterly)"]
47
+ OKR --> PG["Product Goal (Long-Term Commitment)"]
48
+ PG --> PB["Product Backlog (Emergent, Ordered PBIs)"]
49
+ PB --> SG["Sprint Goal (Tactical Increment)"]
58
50
  ```
59
51
 
60
52
  ### Anatomy of an OKR
@@ -111,19 +103,22 @@ A collaborative prioritization exercise where stakeholders are allocated a const
111
103
 
112
104
  Following Gunther Verheyen's backlog topology, the Product Backlog serves as an **emergent, living roadmap**:
113
105
 
114
- ```
115
- ▲ Finer Granularity (Top)
116
- │ [ PBI 1: Sprintable, vertically sliced, clear DoD & Gherkin ]
117
- │ [ PBI 2: High priority, well-understood, estimated ]
118
- │ [ PBI 3: Actionable, small, customer value clear ]
119
- │
120
- │ Medium Granularity (Middle)
121
- │ [ PBI 4: Candidate for next period, coarse slice ]
122
- │ [ PBI 5: Alternative approach under evaluation ]
123
- │
124
- ▼ Coarser Granularity (Bottom)
125
- [ PBI 6: Long-term idea, future capability ]
126
- [ PBI 7: Raw thought, exploratory concept ]
106
+ ```mermaid
107
+ flowchart TD
108
+ subgraph Top["Finer Granularity (Top of Backlog)"]
109
+ P1["PBI 1: Sprintable, vertically sliced, clear DoD & Gherkin"]
110
+ P2["PBI 2: High priority, well-understood, estimated"]
111
+ P3["PBI 3: Actionable, small, customer value clear"]
112
+ end
113
+ subgraph Middle["Medium Granularity (Middle)"]
114
+ P4["PBI 4: Candidate for next period, coarse slice"]
115
+ P5["PBI 5: Alternative approach under evaluation"]
116
+ end
117
+ subgraph Bottom["Coarser Granularity (Bottom)"]
118
+ P6["PBI 6: Long-term idea, future capability"]
119
+ P7["PBI 7: Raw thought, exploratory concept"]
120
+ end
121
+ Top --> Middle --> Bottom
127
122
  ```
128
123
 
129
124
  ### Rules of Progressive Elaboration
@@ -40,20 +40,22 @@ Ensure every user story satisfies Bill Wake's **INVEST** criteria:
40
40
 
41
41
  ### The Multi-Layer Cake Metaphor (Vertical Slicing)
42
42
  Think of a complete feature as a multi-layer cake:
43
- ```
44
- ┌──────────────────────────────────────┐
45
- │ Presentation / UI Layer │
46
- ├──────────────────────────────────────┤
47
- │ Business Logic & Application Use Case│
48
- ├──────────────────────────────────────┤
49
- │ Domain Invariants & Entities │
50
- ├──────────────────────────────────────┤
51
- │ Persistence & Database Layer │
52
- └──────────────────────────────────────┘
53
- ▲
54
- │
55
- Vertical Cake Slice
56
- (Customer gets a taste of every layer)
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
57
59
  ```
58
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.
59
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.
@@ -0,0 +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.
@@ -4,7 +4,24 @@
4
4
 
5
5
  ---
6
6
 
7
- ## 1. Declarative Client-Agnostic SDUI Schema
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
8
25
 
9
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`):
10
27
 
@@ -38,7 +55,7 @@ The backend provides a declarative UI layout schema describing fields, layouts,
38
55
 
39
56
  ---
40
57
 
41
- ## 2. Multi-Platform Component Registries
58
+ ## 3. Multi-Platform Component Registries
42
59
 
43
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:
44
61
 
@@ -48,7 +65,7 @@ Frontend clients (Web, Mobile, Desktop) never contain hardcoded tenant branching
48
65
 
49
66
  ---
50
67
 
51
- ## 3. Universal Design Tokens (W3C DTCG Standard)
68
+ ## 4. Universal Design Tokens (W3C DTCG Standard)
52
69
 
53
70
  Manage tenant white-label branding and design systems via the **W3C Design Tokens Community Group (DTCG)** specification:
54
71