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
@@ -1,88 +0,0 @@
1
- # Multi-Tenancy Context Resolution & Data Isolation Models
2
-
3
- > **Core Mandate:** Enforce multi-tenancy isolation through dynamic context resolution combined with database-agnostic isolation models (AST query interceptors, RLS, schema namespaces, or connection routing) as an immutable backstop.
4
-
5
- ---
6
-
7
- ## 1. Multi-Tenant Context Resolution
8
-
9
- Resolve tenant identity dynamically in an inbound gateway or middleware pipeline in strict priority order:
10
- 1. **Host Subdomain**: `subdomain.app.com` (extracted via hostname regex).
11
- 2. **Explicit Headers**: `X-Tenant-ID: <uuid>` or `X-Tenant-Slug: <slug>`.
12
- 3. **Path Prefix**: `/t/:tenantSlug/...`.
13
- 4. **JWT Claim Fallback**: Authenticated token `tid` (tenant ID) claim.
14
-
15
- *Validation:* If the resolved tenant does not exist or is in `SUSPENDED` status, immediately return **`403 Forbidden`** (`TENANT_SUSPENDED` or `TENANT_INVALID`). Propagate `TenantContext` across service calls using standard W3C Baggage headers or request contexts.
16
-
17
- - **Fail-Closed Multi-Tenancy Invariant**: Never trust client-supplied tenant headers (`X-Tenant-ID`) without cryptographically verifying that the authenticated session actor actually belongs to the requested tenant organization/workspace. Mismatched tenant headers must immediately fail closed with HTTP 403 `FORBIDDEN_TENANT_ACCESS`.
18
-
19
- ---
20
-
21
- ## 2. Four Universal Data Isolation Models
22
-
23
- Never rely solely on application developers remembering to manually append `WHERE tenant_id = ?`. Standardize on one of four architectural isolation strategies:
24
-
25
- ```mermaid
26
- flowchart TD
27
- Request["Inbound Request (TenantContext)"] --> Strategy{"Isolation Strategy"}
28
-
29
- Strategy -->|"Model 1: Discriminator AST"| AST["Query Interceptor / AST Rewriter\n(Automatically injects tenant_id into AST before DB execution)"]
30
- Strategy -->|"Model 2: Engine RLS"| RLS["Row-Level Security (RLS)\n(Database session config: current_setting / session variable)"]
31
- Strategy -->|"Model 3: Schema Namespace"| Schema["Schema-per-Tenant\n(SET search_path / USE tenant_schema)"]
32
- Strategy -->|"Model 4: Instance Routing"| Pool["Database-per-Tenant\n(Connection pool router per tenant ID)"]
33
-
34
- AST --> Database[(Any Relational / Document DB)]
35
- RLS --> Database
36
- Schema --> Database
37
- Pool --> Database
38
- ```
39
-
40
- ### Model 1: Universal AST Query Interceptor (Engine-Agnostic)
41
- The persistence layer interceptor parses the query Abstract Syntax Tree (AST) at runtime and automatically enforces `tenant_id = current_tenant` for all reads and mutations. Compatible with all ANSI SQL and NoSQL engines.
42
-
43
- ### Model 2: Database Row-Level Security (RLS)
44
- For engines supporting native RLS (e.g. PostgreSQL, Oracle):
45
- ```sql
46
- ALTER TABLE "Order" ENABLE ROW LEVEL SECURITY;
47
- ALTER TABLE "Order" FORCE ROW LEVEL SECURITY;
48
-
49
- CREATE POLICY order_tenant_isolation ON "Order"
50
- FOR ALL
51
- USING (tenant_id = current_setting('app.tenant_id', true)::uuid)
52
- WITH CHECK (tenant_id = current_setting('app.tenant_id', true)::uuid);
53
- ```
54
- > [!IMPORTANT]
55
- > **Connection Pool Safety:** Always set `is_local = true` when configuring session variables (`set_config('app.tenant_id', id, true)`). This restricts settings strictly to the current database transaction, preventing cross-tenant leakage in connection pools.
56
-
57
- ### Model 3: Schema-per-Tenant
58
- Separate schemas per tenant within a shared database instance (`tenant_acme`, `tenant_globex`). Routing dynamically sets the active search path per transaction.
59
-
60
- ### Model 4: Database-per-Tenant
61
- Dedicated physical database instances per enterprise tenant, selected by a dynamic connection pool resolver based on resolved tenant metadata.
62
-
63
- ---
64
-
65
- ## 3. Polyglot Adapter Interceptor Contract
66
-
67
- Adapters in any language (Go, Rust, Python, Java, TypeScript) must expose an interceptor wrapping the data access layer:
68
-
69
- ```
70
- ┌────────────────────────────────────────────────────────┐
71
- │ Context Interceptor Contract (Pseudocode / Polyglot) │
72
- ├────────────────────────────────────────────────────────┤
73
- │ onQueryExecution(query, tenantContext): │
74
- │ assert(tenantContext != null, "MissingTenantContext")│
75
- │ if adapter.supportsRLS(): │
76
- │ execute("SET LOCAL app.tenant_id = :tenantId") │
77
- │ else if adapter.supportsAST(): │
78
- │ query.addPredicate(EQUALS("tenant_id", tenantId)) │
79
- │ return execute(query) │
80
- └────────────────────────────────────────────────────────┘
81
- ```
82
-
83
- ---
84
-
85
- ## 4. Tenant Lifecycle Management
86
-
87
- - **Atomic Provisioning**: Tenant creation must run inside an atomic transaction (provision tenant record, seed default RBAC roles `ADMIN`/`MEMBER`, assign subscription tier).
88
- - **GDPR Cascading Deletion**: Deleting a tenant triggers an asynchronous job that cascade purges or pseudonymizes all tenant records, ensuring zero orphaned data.
@@ -1,78 +0,0 @@
1
- # React & Modern Frontend Architecture
2
-
3
- > **Core Mandate:** Enforce modern, production-grade React standards across all web interfaces: `shadcn/ui` with Radix UI primitives, TanStack Query for server-state caching, React Hook Form / TanStack Form with Zod validation, and zero ad-hoc `useState` forms or raw `useEffect` fetch loops.
4
-
5
- ---
6
-
7
- ## 1. Component Library & Styling (`shadcn/ui` + Radix UI)
8
-
9
- - **Accessible Radix Primitives**: All interactive UI components (dialogs, dropdowns, selects, tabs, tooltips, popovers) must be built on `@radix-ui` headless primitives or `shadcn/ui` components located in `@/components/ui/`.
10
- - **Zero Unstyled Raw Elements**: Never create unstyled raw HTML modals, dropdowns, or custom select tags.
11
- - **Tailwind Utility Styling (`cn` helper)**: Combine Tailwind utility classes using `clsx` and `tailwind-merge` (`cn(...)`) to allow clean prop overrides and consistent theming.
12
- - **Strict Prohibition of Native Dialogs**: As mandated in [`docs/rules/accessibility.md`](./accessibility.md), `window.alert()` and `window.confirm()` are strictly forbidden. Use accessible Radix UI dialogs (`<ConfirmDialog />`).
13
-
14
- ---
15
-
16
- ## 2. Server State & Data Fetching (TanStack Query)
17
-
18
- - **Mandatory TanStack Query**: All asynchronous data fetching, caching, and mutation must use **TanStack Query (`@tanstack/react-query`)**.
19
- - **No Raw `useEffect` Fetch Loops**:
20
- - *Anti-Pattern:* `useEffect(() => { fetch(...).then(setData) }, [])` with manual `loading` and `error` state.
21
- - *Standard Pattern:*
22
- ```tsx
23
- const { data: resources, isLoading, error } = useQuery({
24
- queryKey: ['resources', tenantId],
25
- queryFn: () => api.getResources(),
26
- });
27
- ```
28
- - **Declarative Mutations & Invalidation**:
29
- - Mutations must define `useMutation` with `onSuccess` cache invalidation:
30
- ```tsx
31
- const queryClient = useQueryClient();
32
- const createResourceMutation = useMutation({
33
- mutationFn: (newResource: CreateResourceInput) => api.createResource(newResource),
34
- onSuccess: () => {
35
- queryClient.invalidateQueries({ queryKey: ['resources'] });
36
- },
37
- });
38
- ```
39
- - **Query Key Conventions**: Format query keys hierarchically as tuples: `['entity', id, ...filters]`, e.g., `['orders', orderId]`, `['users', tenantId]`.
40
-
41
- ---
42
-
43
- ## 3. Form State Management & Validation (Zod + Form Engines)
44
-
45
- - **Mandatory Schema Validation**: Every form submission must be validated against a formal **Zod schema** (`z.object({ ... })`) that mirrors the shared DTO/input contracts from shared packages.
46
- - **Form State Engines**: Use **React Hook Form (`react-hook-form` + `@hookform/resolvers/zod`)** or **TanStack Form (`@tanstack/react-form`)**.
47
- - **Zero Unvalidated `useState` Multi-Field Objects**:
48
- - *Anti-Pattern:*
49
- ```tsx
50
- const [form, setForm] = useState({ name: '', email: '' });
51
- // manual validation in submit handler...
52
- ```
53
- - *Standard Pattern:*
54
- ```tsx
55
- const form = useForm<CreateUserInput>({
56
- resolver: zodResolver(createUserSchema),
57
- defaultValues: { name: '', email: '' },
58
- });
59
- ```
60
- - **Accessible Error Linking**: Form inputs must bind validation errors to `aria-invalid="true"` and `aria-describedby="<field>-error"`.
61
-
62
- ---
63
-
64
- ## 4. State Separation & Data Tables
65
-
66
- - **State Hierarchy**:
67
- 1. **Server State (Remote)**: Manage exclusively with **TanStack Query**.
68
- 2. **URL State (Search / Pagination / Filters)**: Manage in URL search params per [`docs/rules/ui_navigation.md`](./ui_navigation.md).
69
- 3. **Form State (Transient Edits)**: Manage via **React Hook Form / TanStack Form**.
70
- 4. **Global Client State (Session/UI)**: Manage via **Zustand** (or React Context for theme/auth).
71
- - **Data Grids & Tables**: When building sortable, paginated, or virtualized tables, standardize on **TanStack Table (`@tanstack/react-table`)**.
72
-
73
- ---
74
-
75
- ## 5. Theme Architecture & Design Token Completeness
76
-
77
- - **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.
78
- - **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.
@@ -1,46 +0,0 @@
1
- # REST API Design & Response Conventions
2
-
3
- > **Core Mandate:** Enforce standardized RESTful conventions, proper HTTP status codes, enumeration masking, and consistent subresource routing.
4
-
5
- ---
6
-
7
- ## 1. HTTP Status Code Conventions
8
-
9
- - **`200 OK`**: Successful GET, PUT, or PATCH requests returning modified state.
10
- - **`201 Created`**: Successful resource creation via POST (must include `Location` header or created entity).
11
- - **`204 No Content`**: Successful DELETE operations or operations returning no body.
12
- - **`400 Bad Request`**: Malformed payload or validation schema failure.
13
- - **`401 Unauthorized`**: Missing, expired, or invalid authentication credentials.
14
- - **`403 Forbidden`**: Authenticated caller lacks permissions, tenant is suspended, or action targets protected system roles.
15
- - **`404 Not Found`**: Resource does not exist or belongs to another tenant (enumeration masking).
16
- - **`409 Conflict`**: Unique constraint collision or concurrent optimistic lock conflict.
17
- - **`422 Unprocessable Entity`**: Semantic domain violation.
18
- - **`429 Too Many Requests`**: Rate limit exceeded.
19
- - **`500 Internal Server Error`**: Unexpected server error.
20
-
21
- ---
22
-
23
- ## 2. Cross-Tenant Enumeration Masking
24
-
25
- - If an authenticated user attempts to access a resource ID belonging to a different tenant, the API must return **`404 Not Found`** (rather than `403 Forbidden`) to prevent leaking the existence of other tenants' records.
26
-
27
- ---
28
-
29
- ## 3. Subresource Endpoints & Pluralization
30
-
31
- - Always use pluralized nouns for resources (e.g. `/api/v1/users`, `/api/v1/orders`).
32
- - Use nested subresources for closely owned relations:
33
- - `/api/v1/roles/:id/permissions`
34
- - `/api/v1/tenants/:id/members`
35
-
36
- ---
37
-
38
- ## 4. Full Lifecycle Resource CRUD & Route Tolerances
39
-
40
- - **Full Lifecycle Support:** All primary resource endpoints must provide comprehensive CRUD capabilities before completion:
41
- - `GET /api/v1/<resources>`: List with pagination and tenant filtering.
42
- - `GET /api/v1/<resources>/:id`: Detailed record by ID.
43
- - `POST /api/v1/<resources>`: Create new entity returning `201 Created`.
44
- - `PUT /api/v1/<resources>/:id` or `PATCH`: Update attributes or mutate state machine status.
45
- - `DELETE /api/v1/<resources>/:id`: Remove or archive returning `204 No Content`.
46
- - **Defensive Route Tolerances for Infrastructure Probes:** Operational probes (`/healthz`, `/readyz`) must defensively support trailing slashes (`/healthz/`) and common typos (`/healtz/`) to prevent reverse proxy routing mismatches between frontend dev servers (e.g. Vite) and ingress gateways.
@@ -1,88 +0,0 @@
1
- # Multi-Tenant Schema Extensibility & Virtual Entities
2
-
3
- > **Core Mandate:** Enforce dynamic schema extensibility via hybrid relational columns and validated JSON Schema (Draft 2020-12), prohibiting sparse nullable columns and branch-specific migrations in shared databases.
4
-
5
- ---
6
-
7
- ## 1. Hybrid Core + JSON/Document Extensibility
8
-
9
- Store universal relational attributes in standard typed columns. Store tenant-specific custom fields in a semi-structured `custom_attributes` column governed by tenant-scoped JSON Schemas:
10
-
11
- ```sql
12
- CREATE TABLE customers (
13
- id VARCHAR(64) PRIMARY KEY,
14
- tenant_id VARCHAR(64) NOT NULL,
15
- first_name VARCHAR(100) NOT NULL,
16
- last_name VARCHAR(100) NOT NULL,
17
- email VARCHAR(255) NOT NULL,
18
- custom_attributes TEXT NOT NULL DEFAULT '{}',
19
- created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
20
- );
21
-
22
- CREATE TABLE tenant_schema_definitions (
23
- id VARCHAR(64) PRIMARY KEY,
24
- tenant_id VARCHAR(64) NOT NULL,
25
- entity_name VARCHAR(50) NOT NULL,
26
- json_schema TEXT NOT NULL,
27
- version INT NOT NULL DEFAULT 1,
28
- UNIQUE(tenant_id, entity_name)
29
- );
30
- ```
31
-
32
- ### Runtime Validation Contract (JSON Schema Draft 2020-12)
33
- Validate all inbound custom attribute payloads at runtime against the tenant's compiled JSON Schema before persisting mutations:
34
-
35
- ```
36
- ┌────────────────────────────────────────────────────────┐
37
- │ Dynamic Schema Validator Contract (Agnostic) │
38
- ├────────────────────────────────────────────────────────┤
39
- │ validateCustomAttributes(schemaDef, data): │
40
- │ compiledValidator = compileJsonSchema(schemaDef) │
41
- │ result = compiledValidator.validate(data) │
42
- │ if !result.isValid: │
43
- │ return Failure(ValidationError(result.errors)) │
44
- │ return Success(data) │
45
- └────────────────────────────────────────────────────────┘
46
- ```
47
- Supported natively by open-source engines in every major language (`valico` in Rust, `gojsonschema` in Go, `jsonschema` in Python, `networknt` in Java, `ajv` in Node).
48
-
49
- ---
50
-
51
- ## 2. Meta-Schema Catalog for Virtual Custom Entities
52
-
53
- When tenants define completely custom entities/tables dynamically without deploying code:
54
-
55
- ```sql
56
- CREATE TABLE tenant_entities (
57
- id VARCHAR(64) PRIMARY KEY,
58
- tenant_id VARCHAR(64) NOT NULL,
59
- name VARCHAR(64) NOT NULL,
60
- display_name VARCHAR(128) NOT NULL,
61
- schema_definition TEXT NOT NULL,
62
- UNIQUE(tenant_id, name)
63
- );
64
-
65
- CREATE TABLE tenant_records (
66
- id VARCHAR(64) PRIMARY KEY,
67
- tenant_id VARCHAR(64) NOT NULL,
68
- entity_id VARCHAR(64) NOT NULL REFERENCES tenant_entities(id) ON DELETE CASCADE,
69
- data TEXT NOT NULL DEFAULT '{}',
70
- created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
71
- );
72
- ```
73
-
74
- ---
75
-
76
- ## 3. Indexing Strategies for Dynamic Custom Attributes
77
-
78
- 1. **Virtual / Generated Columns**: For high-throughput queried fields inside dynamic attributes, project them into virtual/generated columns and attach standard B-tree indexes:
79
- ```sql
80
- ALTER TABLE customers ADD COLUMN vat_number VARCHAR(64)
81
- GENERATED ALWAYS AS (custom_attributes->>'vat_number') STORED;
82
- CREATE INDEX idx_customers_vat ON customers (tenant_id, vat_number);
83
- ```
84
- 2. **Functional / Expression Indexes**: Index specific nested attributes directly on engines that support expression indexes:
85
- ```sql
86
- CREATE INDEX idx_customers_po ON customers (tenant_id, ((custom_attributes->>'po_number')::text));
87
- ```
88
- 3. **Inverted Indexes**: Use generalized inverted indexing (e.g. GIN in PostgreSQL) for arbitrary key-value path searches.
@@ -1,59 +0,0 @@
1
- # Pluggable Multi-Tenant Business Logic & Workflows
2
-
3
- > **Core Mandate:** Eliminate `if-tenant` conditional branching via Strategy registries, Common Expression Language (CEL), durable workflow orchestration, and secure WebAssembly (Wasm) micro-sandboxes.
4
-
5
- ---
6
-
7
- ## 1. Strategy Pattern & Dynamic Strategy Registry
8
-
9
- Encapsulate diverging tenant algorithms into discrete strategies conforming to a unified domain port:
10
-
11
- ```
12
- ┌────────────────────────────────────────────────────────┐
13
- │ Discount Strategy Port Contract │
14
- ├────────────────────────────────────────────────────────┤
15
- │ calculateDiscount(order): Decimal │
16
- └────────────────────────────────────────────────────────┘
17
- ```
18
-
19
- The application maintains an in-memory Strategy Registry resolving the active strategy based on `tenant.subscriptionTier` or custom tenant config:
20
-
21
- ```
22
- StrategyRegistry.register("standard", StandardDiscountStrategy)
23
- StrategyRegistry.register("enterprise_vip", HighVolumeTierStrategy)
24
-
25
- strategy = StrategyRegistry.resolve(tenant.discountStrategyKey)
26
- discount = strategy.calculateDiscount(order)
27
- ```
28
-
29
- ---
30
-
31
- ## 2. Declarative Rule Evaluation: Common Expression Language (CEL)
32
-
33
- Allow tenants or administrators to configure dynamic conditional logic stored as declarative text or JSON without redeploying binaries. Standardize on **Common Expression Language (CEL)**:
34
-
35
- ```cel
36
- // Example Tenant Rule Expression:
37
- order.total >= 500 && order.shipping_country == "US" && tenant.tier == "ENTERPRISE"
38
- ```
39
-
40
- - **Memory-Safe & Non-Turing Complete**: Prevents infinite loops, recursion crashes, and side-effects.
41
- - **Polyglot Portability**: Native compilers and runtimes available across Go (`cel-go`), Rust (`cel-rust`), Python (`cel-python`), Java (`cel-java`), and TypeScript (`cel-js`).
42
-
43
- ---
44
-
45
- ## 3. Durable Workflows & Orchestration (Temporal / BPMN 2.0)
46
-
47
- For tenants with diverging multi-step approval, fulfillment, or refund lifecycles:
48
- - **Durable Execution Engines**: Standardize on **Temporal.io** or **Camunda 8 / Zeebe (BPMN 2.0)**.
49
- - **Resilience Guarantees**: Workflows automatically persist state across node crashes, manage timeouts, execute automatic retries, and trigger compensation transactions (Saga pattern) across polyglot workers.
50
- - **Tenant Workflow Selection**: The domain routes entity state transitions to tenant-specific workflow IDs configured in database metadata.
51
-
52
- ---
53
-
54
- ## 4. Secure Script Sandboxing: WebAssembly (Wasm / Extism)
55
-
56
- Never execute untrusted tenant strings via host runtime evaluation (`eval()`, dynamic reflection, or unshielded isolates).
57
- - **Universal Sandboxing with Extism / Wasmtime**: Tenants compile custom logic (in Rust, Go, Python, or TypeScript) to portable `.wasm` bytecode.
58
- - **Strict Execution Quotas**: Max 50ms CPU execution budget, max 16MB linear memory boundary.
59
- - **Complete Host Isolation**: Sandboxed instances possess zero access to host filesystem, network sockets, environment variables, or database connections unless explicitly passed via memory interfaces.
@@ -1,26 +0,0 @@
1
- # Test Coverage, Isolation & Determinism
2
-
3
- > **Core Mandate:** Enforce 100.00% test coverage thresholds, transactional database rollback per test, deterministic data factories, and zero-sleep flakiness elimination across all test suites.
4
-
5
- ---
6
-
7
- ## 1. Mandatory 100.00% Test Coverage Thresholds
8
-
9
- - **Strict Coverage Thresholds**: Maintain line, function, branch, and statement test coverage at **100.00%** across all backend domain logic, adapters, contracts, and frontend suites. Strictly enforce 100% threshold failure gates in CI pipelines.
10
- - **Exhaustive Status Codes & Error Branches**: Explicitly test all HTTP/gRPC response codes:
11
- - Success: `200 OK`, `201 Created`, `204 No Content`
12
- - Client Errors: `400 Bad Request`, `401 Unauthorized`, `403 Forbidden`, `404 Not Found`, `409 Conflict`, `422 Unprocessable Entity`, `429 Too Many Requests`
13
- - Server Failures: `500 Internal Server Error`, `503 Service Unavailable`
14
- - **UI Interaction States & Edge Cases**: Fully assert all presentation states (loading spinners, disabled controls, error banners, success feedback, empty states) across suites.
15
-
16
- ---
17
-
18
- ## 2. Database Test Isolation & Zero Flakiness
19
-
20
- - **Transactional Rollback per Integration Test**:
21
- - Every integration test that interacts with persistence must execute within a scoped transaction that is rolled back upon test completion (`afterEach` rollback) or use ephemeral, disposable database isolates. Never leave mutated rows that pollute subsequent tests.
22
- - **Deterministic Test Data Factories**:
23
- - Utilize strongly-typed test data factories (`buildUser()`, `buildOrder()`) with randomized unique identifiers rather than hardcoded magic strings or fixed database IDs.
24
- - **Zero Sleep / Flakiness Elimination**:
25
- - Strictly forbid arbitrary `sleep()` or timeout pauses in tests.
26
- - Rely exclusively on deterministic condition polling (`waitFor(condition)`) or reactive event promises to eliminate test flakiness.
@@ -1,55 +0,0 @@
1
- # Static Type Safety & Sound Type Systems
2
-
3
- > **Core Mandate:** Enforce maximum compiler strictness, branded nominal typing for domain identifiers, strict prohibition of untyped escape hatches, and automated pre-commit quality guardrails across polyglot implementations.
4
-
5
- ---
6
-
7
- ## 1. Maximum Compiler Strictness & Soundness
8
-
9
- Regardless of the execution language chosen for an adapter or service, enforce maximum compiler rigor to eliminate runtime null pointer exceptions, unhandled type cases, and memory errors at compile time:
10
-
11
- - **TypeScript**: Enable all strict compiler flags (`strict: true`, `noImplicitAny: true`, `strictNullChecks: true`, `noUncheckedIndexedAccess: true`).
12
- - **Rust**: Enable `#![deny(clippy::all)]` and `#![deny(missing_docs)]` with zero `unsafe` blocks.
13
- - **Go**: Enable comprehensive static analysis (`golangci-lint` with `errcheck`, `govet`, `staticcheck`).
14
- - **Python**: Enforce strict type checking (`mypy --strict` or `pyright`).
15
-
16
- ---
17
-
18
- ## 2. Branded Nominal Typing & Primitive Obsession Elimination
19
-
20
- Prevent accidental mixing of raw primitive identifiers (e.g. passing an arbitrary `string` representing a `TenantId` where a `UserId` is expected) by enforcing nominal types:
21
-
22
- ```
23
- ┌────────────────────────────────────────────────────────┐
24
- │ Nominal Domain Identifier Pattern (Polyglot) │
25
- ├────────────────────────────────────────────────────────┤
26
- │ Rust: struct TenantId(String); │
27
- │ struct UserId(String); │
28
- │ Go: type TenantId string │
29
- │ type UserId string │
30
- │ TypeScript: type TenantId = Brand<string, 'TenantId'>; │
31
- │ type UserId = Brand<string, 'UserId'>; │
32
- │ Python: TenantId = NewType('TenantId', str) │
33
- │ UserId = NewType('UserId', str) │
34
- └────────────────────────────────────────────────────────┘
35
- ```
36
-
37
- Domain functions must accept and return branded types rather than raw primitive strings or integers.
38
-
39
- ---
40
-
41
- ## 3. Strict Prohibition of Untyped Escape Hatches
42
-
43
- - **Zero Tolerance for Unsound Types**: Strictly prohibit `any` in TypeScript, raw `interface{}` / `any` without type assertion checks in Go, raw `Any` in Python, or unchecked casts in Java/Rust.
44
- - **Runtime Validation at Boundaries**: External payloads (network requests, message queues, disk files) must be parsed and narrowed into strongly-typed domain structures before passing to application services.
45
- - **Commit Guardrails**: Enforce Conventional Commits via commit linters. Never bypass pre-commit hooks running static type checking, formatting, and linters.
46
-
47
- ---
48
-
49
- ## 4. Module Path Aliases & Relative Traversal Elimination
50
-
51
- - **Path Alias Mandate (`@/*`)**: All TypeScript packages in the workspace must configure and standardize on `@/*` mapped to `./src/*` across `tsconfig.json` (`"baseUrl": "."`, `"paths": { "@/*": ["./src/*"] }`), bundlers (Vite `resolve.alias`), and test runners (Vitest `resolve.alias`).
52
- - **Strict Prohibition of Deep Relative Traversal**: Never use deep relative traversals (`../../../..`, `../../..`, `../..`) across layers or contexts. Deep relative paths create fragile coupling, impair refactoring, and obscure domain layer boundaries.
53
- - **Node.js ESM Production Resolution**: In backend environments executing compiled JavaScript under Node.js ESM (`node dist/index.js`), use `tsc-alias` post-compilation (`tsc && tsc-alias`) to resolve path aliases in `dist/` to valid relative paths without introducing runtime loader overhead.
54
- - **Scope of Sibling Imports**: Local relative imports (`./file.js`) are permitted only for immediate siblings within the identical directory. Any import traversing up a directory hierarchy or crossing architectural boundaries (domain, ports, adapters, components, context) MUST resolve via `@/*`.
55
-
@@ -1,20 +0,0 @@
1
- # UI Navigation & URL State Synchronization
2
-
3
- > **Core Mandate:** Enforce bidirectional URL state synchronization for all interactive view states, preserving deep linkability, bookmarkability, and native browser navigation.
4
-
5
- ---
6
-
7
- ## 1. Bidirectional URL State Synchronization
8
-
9
- Every view state that represents navigation, active tab, filtering, sorting, pagination, or search query must synchronize bidirectionally with URL search parameters (`useSearchParams`):
10
- - **Bookmarkability**: A user copying the browser URL must be able to restore the exact view, active tab, filter selections, and pagination page on any device.
11
- - **Browser History Integration**: The browser's back and forward buttons must navigate between state transitions smoothly without triggering full page reloads.
12
-
13
- ---
14
-
15
- ## 2. Deep Linking Standards
16
-
17
- - **Tabbed Interfaces**: Encode active tab keys in query params (e.g. `?tab=security` or `/settings/security`).
18
- - **Data Tables & Lists**: Preserve table states in URL parameters:
19
- - `?page=2&limit=25&sort=createdAt&order=desc&status=ACTIVE`
20
- - **Modal & Drawer States**: If a modal or drawer represents an actionable sub-view (e.g. `?modal=edit-user&userId=123`), synchronize it with the URL so direct links open the intended context.
@@ -1,53 +0,0 @@
1
- # Upstream Baseline Synchronization & changes.md Ledger
2
-
3
- > **Core Mandate:** Upstream template/baseline workspaces (`azcodr`) must remain strictly untouched during project development. When generic architectural improvements, rule refinements, or post-mortems are identified, record them solely into the `changes.md` ledger with zero automated repo merging or baseline contamination.
4
-
5
- ---
6
-
7
- ## 1. The Baseline-Project Decoupling Principle
8
-
9
- Workspaces operate under a clean, decoupled flow:
10
-
11
- ```
12
- [Upstream Generic Baseline: azcodr]
13
- │
14
- ▼ (Scaffolded via npx azcodr)
15
- [Derived Project Workspace: my-app / others]
16
- │
17
- │ (Accumulates project code, specificities, and institutional lessons)
18
- │
19
- ▼ (Record reusable improvements)
20
- [Upstream Changes Ledger: changes.md]
21
- ```
22
-
23
- - **Pristine Upstream Mandate:** Never edit, commit, or attempt automated git merges to an upstream baseline repository during routine project development, feature implementation, or bug fixes.
24
- - **Ledger-Only Synchronization:** When generic architectural discoveries or defect post-mortems occur, document them cleanly in `changes.md` at the workspace root. No automated merge AI or remote repo synchronization is executed.
25
-
26
- ---
27
-
28
- ## 2. Zero-Contamination Invariant (Generic vs. Specific)
29
-
30
- When logging proposed changes into `changes.md`, enforce strict domain filtering:
31
-
32
- | Element Category | Keep in Specific Project Workspace | Allow in changes.md for Upstream (`azcodr`) |
33
- |---|---|---|
34
- | **Domain Entities** | Concrete business models (`Order`, `Customer`, `Invoice`, etc.) | Abstract archetypes (`Entity`, `Aggregate`, `ValueObject`, `Resource`) |
35
- | **Tech Stack / Adapters** | Concrete choices (Prisma, SQLite dev, PostgreSQL prod, Vite React) | Hexagonal Ports, abstract repository contracts, polyglot adapter guidance |
36
- | **Architectural Rules** | Specific entity validation, specific route paths | Universal invariants (5-Phase Agile Lifecycle, SemVer trigger matrix, FK dropdowns) |
37
- | **ADRs** | Stack decisions (`ADR-006: Target Tech Stack for Project`) | Generic architecture patterns (`ADR-007` to `ADR-010`) |
38
- | **Test Suites** | Concrete domain tests (`order_domain.test.ts`, domain-specific suites) | Boundary smoke test pattern (`scripts/smoke_test.sh`), 100% coverage gate |
39
-
40
- ---
41
-
42
- ## 3. Atomic changes.md Entry Protocol
43
-
44
- Every upstream-bound proposal logged to `changes.md` must follow the standardized format:
45
-
46
- ```markdown
47
- ### [YYYY-MM-DD] <Title of Change>
48
- - **Category:** Rule | Skill | Infrastructure | CLI | Knowledge Hub
49
- - **Target File(s):** `docs/rules/...`, `.agents/skills/...`, etc.
50
- - **Rationale:** Why this improvement is necessary or valuable across all enterprise projects.
51
- - **Description:** Concise summary of the mutation or invariant added.
52
- - **Domain Filter Verification:** Verified 100% generic; purged of all project-specific business entities and models.
53
- ```
@@ -1,25 +0,0 @@
1
- # Workspace Isolation & Zero Global Context Interference
2
-
3
- > **Core Mandate:** Enforce strict workspace containment within the workspace root (`./`), strictly prohibiting any leakage, interference, or unverified assumptions from global configurations, external directories, or sibling projects.
4
-
5
- ---
6
-
7
- ## 1. Principle of Workspace Sovereignty
8
-
9
- - **Ground Truth Boundary**: Only files, dependencies, configuration files (`package.json`, `tsconfig.json`, `docker-compose.yml`), and verified command executions within the local workspace (`./`) constitute project truth.
10
- - **Zero Global Contamination**: Never import, execute, or assume tools, environment variables, or conventions from global system directories (e.g. `~/.config`, `/tmp`, `~/.gemini/antigravity-cli`, or parent directories) unless explicitly defined within local workspace configuration.
11
- - **Sibling Project Isolation**: Strictly ignore all external or legacy projects. Do not read from or write to directories outside the local repository (`./`).
12
-
13
- ---
14
-
15
- ## 2. Dependency & Tooling Isolation
16
-
17
- - **Local Package Manager**: Standardize strictly on local workspace dependencies managed via `npm` within this workspace. Never rely on global npm packages (`npm install -g`).
18
- - **Container Network Containment**: All Docker containers and bridge networks must be named and scoped specifically to this project (e.g. `azcodr_network`, `azcodr_postgres`) to prevent port collisions or cross-project data leakage.
19
-
20
- ---
21
-
22
- ## 3. Subagent & Execution Context Sandboxing
23
-
24
- - When spawning subagents or executing commands, ensure the working directory (`Cwd`) is anchored strictly to the workspace root (`./`).
25
- - Subagents must never carry over assumptions from other workspaces or global memory pools.