iter-02 plan
This commit is contained in:
parent
39e20e11f9
commit
088e9ecb4a
|
|
@ -0,0 +1,34 @@
|
|||
# Checkpoint 019 — Stage 10 Iteration Planning Complete for Iteration 02
|
||||
|
||||
- **Checkpoint ID:** CKPT-019
|
||||
- **Date:** 2026-10-12
|
||||
- **Active Stage:** Stage 10 (Iteration Planning) Complete; Stage 11 (Wireframes) & Stage 12 (Test Models) Ready
|
||||
- **Active Track:** Greenfield, India-first, multi-tenant Agriculture Trading Backoffice (ATB)
|
||||
- **Active Skills:** `up-iteration-plan`
|
||||
- **Governed Standard:** UP-AI v1.5 Standard
|
||||
|
||||
## Completed
|
||||
- **Iteration 02 Scope Selection:**
|
||||
- Selected the core multi-tenancy control plane and database data isolation vertical slice:
|
||||
- [`UC-018`](../../03_requirements/use_cases/uc-018-tenant-lifecycle/use-case.md): Tenant Provisioning and Lifecycle Management (`FR-TENANTLIFECYCLE-001`, `BRD-FR-042`)
|
||||
- [`UC-019`](../../03_requirements/use_cases/uc-019-tenant-membership-context/use-case.md): Tenant Membership and Verified Context (`FR-TENANTMEMBERSHIPCONTEXT-001`, `FR-TENANTMEMBERSHIPCONTEXT-002`, `BRD-FR-043`, `BRD-FR-044`)
|
||||
- [`UC-017`](../../03_requirements/use_cases/uc-017-tenant-security-audit/use-case.md): Tenant Data Isolation and Transaction Audit (`FR-TENANTSECURITYAUDIT-001`, `FR-TENANTSECURITYAUDIT-003`, `BRD-FR-039`, `BRD-FR-041`)
|
||||
- **Stage 10 Iteration Planning Deliverables Authored:**
|
||||
- [`iteration_plan.md`](../../05_iteration_planning/iterations/iteration-02/iteration_plan.md): Defines 23-point capacity across 5 stories, clear demo criteria, and regression suite continuity from Iteration 01.
|
||||
- [`iteration_backlog.md`](../../05_iteration_planning/iterations/iteration-02/iteration_backlog.md): Establishes `STORY-TENANT-001` through `STORY-TENANT-005` with strict acceptance criteria, PRD role validations, and SoD constraints.
|
||||
- [`iteration_surface_matrix.md`](../../05_iteration_planning/iterations/iteration-02/iteration_surface_matrix.md): Mapped all 11 delivery surfaces across platform portal, member management, header switcher, DB migrations, and RLS policies.
|
||||
- [`parallel_work_plan.md`](../../05_iteration_planning/iterations/iteration-02/parallel_work_plan.md): Established Wave 0 mock fixtures and 3 isolated parallel lanes (Lane 1: Backend Tenancy, Lane 2: Database RLS & Audit, Lane 3: Frontend Views).
|
||||
- **Traceability Updates:**
|
||||
- Transitioned `FR-TENANTLIFECYCLE-001`, `FR-TENANTMEMBERSHIPCONTEXT-001`, `FR-TENANTMEMBERSHIPCONTEXT-002`, `FR-TENANTSECURITYAUDIT-001`, `FR-TENANTSECURITYAUDIT-003` to `In Construction (Iteration 02)` in [`traceability_graph.md`](../traceability_graph.md).
|
||||
- **Quality Gates:**
|
||||
- Gates 5.1 and 9.1 continue to pass with 0 Critical issues.
|
||||
- Gate 14.1 for `iteration-01` verified and passing cleanly with automated regression tests.
|
||||
|
||||
## Open Items
|
||||
- Authoring Stage 11 screen specifications (`SCREEN-TENANT-001` through `SCREEN-TENANT-004`).
|
||||
- Authoring Stage 12 multi-path functional test models (`TC-017`, `TC-018`, `TC-019`), 21-sheet QA workbook, and Bruno collections for `iteration-02`.
|
||||
- Production deployment runtime selection (`BRD-NFR-011`) and ambiguities `AMB-001`, `AMB-006`, `AMB-008`–`AMB-011` remain tracked.
|
||||
|
||||
## Exact Next Action
|
||||
Proceed to **Stage 11 Wireframe Specifications (`/up-wireframe-spec`)** and **Stage 12 Test Model Generation (`/up-test-model-generate`)** in parallel for `iteration-02`.
|
||||
|
||||
|
|
@ -41,3 +41,4 @@
|
|||
| `CKPT-016` | 2026-10-12 | Stage 10 (Iteration Planning aligned) | Aligned iteration-01 planning artifacts (`iteration_plan.md`, `iteration_backlog.md`, `iteration_surface_matrix.md`, `parallel_work_plan.md`) with Stage 9 architecture contracts (`LLD-001`, `api_design.md`). Scheduled Wave 0 deterministic identity mock and 3-lane isolation. | Iteration-01 remains Incomplete / Pending Construction; Stage 12 deliverables (21-sheet QA workbook, Bruno collections) pending; AMB-001/006/008–011 open. | Proceed to Stage 11 (`/up-wireframe-spec`) and Stage 12 (`/up-test-model-generate`) in parallel. | `checkpoint-016-iteration-01-planning-aligned.md` |
|
||||
| `CKPT-017` | 2026-10-12 | Stage 11 (Wireframes) & Stage 12 (Test Models) complete | Authored screen specifications (`SCREEN-AUTH-001`–`003`), `wireframe_index.md`, compiled dense 21-sheet QA workbook (32 cases), created Bruno collections (`get-session.bru`, `logout.bru`), and updated test traceability. Gate 14.1 referential integrity passed. | Iteration-01 in construction; implementation awaiting Stage 13 code generation; AMB-001/006/008–011 open. | Proceed to Stage 13 (`/up-code-generate`) for wave-based code generation. | `checkpoint-017-stage-11-12-wireframes-test-models.md` |
|
||||
| `CKPT-018` | 2026-10-12 | Stage 13 (Code Generation) & Stage 14 (Gate 14.1 Pass) | Generated Wave 0 IdP mock, Wave 1 FastAPI auth/RBAC backend services, Wave 2 React auth views, and Wave 3 automated test suites. 31 tests passing with 99.2% AST coverage. Gate 14.1 PASSED. FR-AUTH-001–003 transitioned to Implemented (Domain/Schema). | Iteration-02 planning pending; containerized E2E browser automation for Delivered (E2E Verified) state; AMB-001/006/008–011 open. | Present completion summary to stakeholder and proceed to `/up-iteration-plan` for iteration-02. | `checkpoint-018-stage-13-code-generation-and-gate-14-1-pass.md` |
|
||||
| `CKPT-019` | 2026-10-12 | Stage 10 (Iteration 02 Planning Complete) | Selected and scoped Iteration 02 for Multi-Tenant Control Plane, Context Resolution & PostgreSQL RLS (`UC-017`, `UC-018`, `UC-019`). Authored `iteration_plan.md`, `iteration_backlog.md` (5 stories, 23 pts), `iteration_surface_matrix.md`, and `parallel_work_plan.md`. | Iteration-02 in construction; Stage 11 screen specs and Stage 12 test models pending; AMB-001/006/008–011 open. | Proceed to Stage 11 (`/up-wireframe-spec`) and Stage 12 (`/up-test-model-generate`) for iteration-02. | `checkpoint-019-iteration-02-planning.md` |
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ stack:
|
|||
|
||||
## 4. Active Stage & Next Actions
|
||||
|
||||
- **Current Stage:** Stage 13 Code Generation & Stage 14 Verification / Gate 14.1 passed for `iteration-01` (`CKPT-018`). Wave 0 mock adapter, Wave 1 FastAPI auth/RBAC backend services, Wave 2 React auth views, and Wave 3 automated test suites are implemented. 31 tests passing with 99.2% AST statement coverage. Gate 14.1 PASSED. Requirements `FR-AUTH-001`, `FR-AUTH-002`, `FR-AUTH-003` transitioned to `Implemented (Domain/Schema)`.
|
||||
- **Active Iteration:** `iteration-01` completed domain and controller implementation across 3 stories (13 pts) covering `UC-001`. Screen specifications (`SCREEN-AUTH-001`–`003`), dense 21-sheet QA workbook (32 cases), Bruno collections, manual testing guide, and multi-path test suites are verified.
|
||||
- **Next:** Proceed to Stage 10 Iteration Planning (`/up-iteration-plan`) for `iteration-02` (e.g., Market Discovery & Inward Receiving, or Tenant Context & Data Isolation). Carry `AMB-001`, `AMB-006`, `AMB-008`–`AMB-011` and `ASM-001`–`ASM-003` forward.
|
||||
- **Current Stage:** Stage 10 Iteration Planning complete for `iteration-02` (`CKPT-019`). `iteration_plan.md`, `iteration_backlog.md` (5 stories, 23 pts), `iteration_surface_matrix.md`, and `parallel_work_plan.md` authored. Traceability graph updated with `FR-TENANTLIFECYCLE-001`, `FR-TENANTMEMBERSHIPCONTEXT-001/002`, and `FR-TENANTSECURITYAUDIT-001/003` set to `In Construction (Iteration 02)`.
|
||||
- **Active Iterations:**
|
||||
- `iteration-01`: Domain and controller implementation verified (`Implemented (Domain/Schema)`), 31 tests passing with 99.2% AST coverage.
|
||||
- `iteration-02`: In Construction across 5 stories (23 pts) covering `UC-017`, `UC-018`, and `UC-019`. Ready for Stage 11 Wireframe Specifications and Stage 12 Test Model Generation.
|
||||
- **Next:** Proceed to Stage 11 (`/up-wireframe-spec`) and Stage 12 (`/up-test-model-generate`) in parallel for `iteration-02`. Carry `AMB-001`, `AMB-006`, `AMB-008`–`AMB-011` and `ASM-001`–`ASM-003` forward.
|
||||
|
|
|
|||
|
|
@ -153,14 +153,14 @@ These artifacts are candidate Stage 7 spike outputs. They do not replace Stage 8
|
|||
| `UC-016` | Commodity and Trading Counterparty Master Data | — | `BRD-FR-037`, `BRD-FR-038` | Draft |
|
||||
| `FR-MASTERDATA-001` | Agricultural Commodity Master Data Management | `UC-016` | `BRD-FR-037` | Draft |
|
||||
| `FR-MASTERDATA-002` | Trading Counterparty Masters (Suppliers, Customers & Godowns) | `UC-016` | `BRD-FR-038` | Draft |
|
||||
| `UC-017` | Tenant Isolation and Transaction Audit | — | `BRD-FR-039`, `BRD-FR-041` | Draft (CR-001, v1.1.0) |
|
||||
| `FR-TENANTSECURITYAUDIT-001` | Tenant Data Isolation | `UC-017` | `BRD-FR-039` | Draft |
|
||||
| `FR-TENANTSECURITYAUDIT-003` | Immutable Transaction Audit Logging | `UC-017` | `BRD-FR-041` | Draft |
|
||||
| `UC-018` | Tenant Provisioning and Lifecycle | — | `BRD-FR-042` | Draft |
|
||||
| `FR-TENANTLIFECYCLE-001` | Tenant Provisioning and Lifecycle Management | `UC-018` | `BRD-FR-042` | Draft |
|
||||
| `UC-019` | Tenant Membership and Verified Context | — | `BRD-FR-043`, `BRD-FR-044` | Draft |
|
||||
| `FR-TENANTMEMBERSHIPCONTEXT-001` | Tenant Membership and Role Administration | `UC-019` | `BRD-FR-043` | Draft |
|
||||
| `FR-TENANTMEMBERSHIPCONTEXT-002` | Verified Tenant Context for Every Operation | `UC-019` | `BRD-FR-044` | Draft |
|
||||
| `UC-017` | Tenant Isolation and Transaction Audit | — | `BRD-FR-039`, `BRD-FR-041` | In Construction (Iteration 02) |
|
||||
| `FR-TENANTSECURITYAUDIT-001` | Tenant Data Isolation | `UC-017` | `BRD-FR-039` | In Construction (Iteration 02) |
|
||||
| `FR-TENANTSECURITYAUDIT-003` | Immutable Transaction Audit Logging | `UC-017` | `BRD-FR-041` | In Construction (Iteration 02) |
|
||||
| `UC-018` | Tenant Provisioning and Lifecycle | — | `BRD-FR-042` | In Construction (Iteration 02) |
|
||||
| `FR-TENANTLIFECYCLE-001` | Tenant Provisioning and Lifecycle Management | `UC-018` | `BRD-FR-042` | In Construction (Iteration 02) |
|
||||
| `UC-019` | Tenant Membership and Verified Context | — | `BRD-FR-043`, `BRD-FR-044` | In Construction (Iteration 02) |
|
||||
| `FR-TENANTMEMBERSHIPCONTEXT-001` | Tenant Membership and Role Administration | `UC-019` | `BRD-FR-043` | In Construction (Iteration 02) |
|
||||
| `FR-TENANTMEMBERSHIPCONTEXT-002` | Verified Tenant Context for Every Operation | `UC-019` | `BRD-FR-044` | In Construction (Iteration 02) |
|
||||
| `UC-020` | Tenant Resource Isolation and Privileged Support | — | `BRD-FR-045`, `BRD-FR-046` | Draft |
|
||||
| `FR-TENANTSUPPORTSECURITY-001` | End-to-End Tenant Resource Isolation | `UC-020` | `BRD-FR-045` | Draft |
|
||||
| `FR-TENANTSUPPORTSECURITY-002` | Controlled Privileged Support Access | `UC-020` | `BRD-FR-046` | Draft |
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
# Iteration Backlog — Iteration 02
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Iteration** | `iteration-02` |
|
||||
| **Parent Use Cases** | [`UC-017`](../../../03_requirements/use_cases/uc-017-tenant-security-audit/use-case.md), [`UC-018`](../../../03_requirements/use_cases/uc-018-tenant-lifecycle/use-case.md), [`UC-019`](../../../03_requirements/use_cases/uc-019-tenant-membership-context/use-case.md) |
|
||||
| **Governed Standard** | UP-AI v1.5 Stage 10 Standard |
|
||||
| **Status** | Aligned with Stage 9 Architecture (Gate 9.1 Passed); Ready for Stage 11/12 |
|
||||
| **Version** | 1.0.0 |
|
||||
| **Last CR** | none |
|
||||
|
||||
---
|
||||
|
||||
## Story Backlog
|
||||
|
||||
| Story ID | Parent FR | Story Title | Points | Priority | Primary Delivery Surface | Assigned Roles | Status |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| `STORY-TENANT-001` | `FR-TENANTLIFECYCLE-001` | Platform Tenant Provisioning & Lifecycle Management | 5 | P0 | Backend API (`/api/v1/platform/tenants`), Platform Portal `/platform/tenants` | `@backend-dev`, `@ui-designer-dev` | Ready for Construction |
|
||||
| `STORY-TENANT-002` | `FR-TENANTMEMBERSHIPCONTEXT-001` | Tenant User Membership & Role Administration | 5 | P0 | Backend API (`/api/v1/tenants/{id}/memberships`), Tenant Portal `/settings/members` | `@backend-dev`, `@ui-designer-dev` | Ready for Construction |
|
||||
| `STORY-TENANT-003` | `FR-TENANTMEMBERSHIPCONTEXT-002` | Verified Tenant Context Resolution & Multi-Tenant Switching | 5 | P0 | Backend Context Middleware (`get_current_tenant`), Frontend Header Context Switcher | `@backend-dev`, `@ui-designer-dev` | Ready for Construction |
|
||||
| `STORY-TENANT-004` | `FR-TENANTSECURITYAUDIT-001` | PostgreSQL Row-Level Security (RLS) Isolation Engine | 5 | P0 | Database Engine & Transaction Context Dependency (`set_config`) | `@backend-dev`, `@adversarial-tester` | Ready for Construction |
|
||||
| `STORY-TENANT-005` | `FR-TENANTSECURITYAUDIT-003` | Immutable Transaction Audit Trail Logging | 3 | P1 | Backend Audit Interceptor, Table `transaction_audit_logs`, API `/api/v1/audit/events` | `@backend-dev`, `@adversarial-tester` | Ready for Construction |
|
||||
|
||||
---
|
||||
|
||||
## Detailed Story Specifications
|
||||
|
||||
### STORY-TENANT-001: Platform Tenant Provisioning & Lifecycle Management
|
||||
- **Parent Requirement:** [`FR-TENANTLIFECYCLE-001`](../../../03_requirements/use_cases/uc-018-tenant-lifecycle/functional-reqs.md#fr-tenantlifecycle-001-tenant-provisioning-and-lifecycle-management)
|
||||
- **SRS Linkage:** `SRS-TENANTLIFECYCLE-001`
|
||||
- **Architecture Contract:** `HLD-TENANCY`, [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`api_design.md`](../../../04_architecture_design/api_design.md), [`database_design.md`](../../../04_architecture_design/database_design.md)
|
||||
- **Story Points:** 5 (P0)
|
||||
- **Description:** Implement platform-level tenant creation and lifecycle state management (`ACTIVE`, `SUSPENDED`, `CLOSED`), establishing the control-plane boundary where new agricultural trading enterprises are registered and administered by System Administrators.
|
||||
- **Acceptance Criteria:**
|
||||
1. Only users with the `System Administrator` role can create tenants or update lifecycle status via `POST /api/v1/platform/tenants` and `PATCH /api/v1/platform/tenants/{tenant_id}/status`.
|
||||
2. Creates tenant record with Tenant ID, Business Name, Legal Identifier/GSTIN, Contact Email, Primary Mandi, and Initial Tenant Admin.
|
||||
3. Enforces valid lifecycle state transitions: `ACTIVE` $\to$ `SUSPENDED`, `SUSPENDED` $\to$ `ACTIVE`, and `ACTIVE`/`SUSPENDED` $\to$ `CLOSED`.
|
||||
4. Setting status to `SUSPENDED` or `CLOSED` immediately prevents all member logins and rejects all API requests for that tenant.
|
||||
5. Closing a tenant does not delete business records; data is marked read-only and preserved for statutory retention.
|
||||
|
||||
---
|
||||
|
||||
### STORY-TENANT-002: Tenant User Membership & Role Administration
|
||||
- **Parent Requirement:** [`FR-TENANTMEMBERSHIPCONTEXT-001`](../../../03_requirements/use_cases/uc-019-tenant-membership-context/functional-reqs.md#fr-tenantmembershipcontext-001-tenant-membership-and-role-administration)
|
||||
- **SRS Linkage:** `SRS-TENANTMEMBERSHIPCONTEXT-001`
|
||||
- **Architecture Contract:** `HLD-TENANCY`, [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`api_design.md`](../../../04_architecture_design/api_design.md)
|
||||
- **Story Points:** 5 (P0)
|
||||
- **Description:** Implement tenant-level user membership management, allowing Tenant Administrators to invite/add users to their specific firm, assign approved PRD business roles, and activate or revoke memberships within their tenant boundary.
|
||||
- **Acceptance Criteria:**
|
||||
1. Only users holding the `Tenant Administrator` role for the active tenant can administer memberships via `POST/PATCH /api/v1/tenants/{tenant_id}/memberships`.
|
||||
2. Cross-tenant administration is strictly prohibited: an administrator of Tenant A cannot view, add, or alter memberships in Tenant B (`403 Forbidden`).
|
||||
3. Role assignments are validated against the approved PRD roles: `Tenant Administrator`, `Mandi Buyer`, `Purchase Manager`, `Yard Supervisor`, `Quality Officer`, `Sales Executive`, `Sales Manager`, `Logistics Coordinator`, `Accounts Executive`, `Partner / MD`.
|
||||
4. A user can belong to multiple tenants with distinct roles in each tenant.
|
||||
5. Revoking membership immediately revokes the user's access to that specific tenant on subsequent requests.
|
||||
|
||||
---
|
||||
|
||||
### STORY-TENANT-003: Verified Tenant Context Resolution & Multi-Tenant Switching
|
||||
- **Parent Requirement:** [`FR-TENANTMEMBERSHIPCONTEXT-002`](../../../03_requirements/use_cases/uc-019-tenant-membership-context/functional-reqs.md#fr-tenantmembershipcontext-002-verified-tenant-context-for-every-operation)
|
||||
- **SRS Linkage:** `SRS-TENANTMEMBERSHIPCONTEXT-002`
|
||||
- **Architecture Contract:** `HLD-TENANCY`, [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`api_design.md`](../../../04_architecture_design/api_design.md)
|
||||
- **Story Points:** 5 (P0)
|
||||
- **Description:** Implement the core FastAPI request context resolver (`TenantContextResolver` / `get_current_tenant`) that derives the effective tenant context from verified server-side memberships on every request, providing explicit tenant switching for multi-firm users.
|
||||
- **Acceptance Criteria:**
|
||||
1. A client-supplied tenant ID (e.g. `X-Tenant-ID` header) alone never grants access; the resolver validates server-side that the authenticated subject has an `ACTIVE` membership in the requested tenant.
|
||||
2. If the user belongs to multiple tenants, `GET /api/v1/auth/my-tenants` lists all eligible active memberships, and `POST /api/v1/session/active-tenant` sets the verified active tenant context.
|
||||
3. Requests with missing, invalid, or unauthorized tenant context fail closed with HTTP `403 Forbidden` (`code: INVALID_TENANT_CONTEXT`).
|
||||
4. Requests targeting a `SUSPENDED` or `CLOSED` tenant are denied with HTTP `403 Forbidden` (`code: TENANT_NOT_ACTIVE`).
|
||||
5. Injects an immutable `TenantContext(tenant_id, subject_id, roles, correlation_id)` into the request state for downstream handlers and DB sessions.
|
||||
|
||||
---
|
||||
|
||||
### STORY-TENANT-004: PostgreSQL Row-Level Security (RLS) Isolation Engine
|
||||
- **Parent Requirement:** [`FR-TENANTSECURITYAUDIT-001`](../../../03_requirements/use_cases/uc-017-tenant-security-audit/functional-reqs.md#fr-tenantsecurityaudit-001-tenant-data-isolation)
|
||||
- **SRS Linkage:** `SRS-TENANTSECURITYAUDIT-001`
|
||||
- **Architecture Contract:** `HLD-ISOLATION-AUDIT`, [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`database_design.md`](../../../04_architecture_design/database_design.md)
|
||||
- **Story Points:** 5 (P0)
|
||||
- **Description:** Implement database-level multi-tenant data isolation using PostgreSQL Row-Level Security policies, ensuring every database transaction sets transaction-local context (`set_config('app.current_tenant_id', :tenant_id, true)`) and blocks cross-tenant leakage.
|
||||
- **Acceptance Criteria:**
|
||||
1. Every tenant-owned table includes a non-null `tenant_id` foreign key and has `ENABLE ROW LEVEL SECURITY` and `FORCE ROW LEVEL SECURITY`.
|
||||
2. RLS policies enforce `USING (tenant_id = current_setting('app.current_tenant_id', true))` and `WITH CHECK (tenant_id = current_setting('app.current_tenant_id', true))`.
|
||||
3. Database session manager automatically executes `SET LOCAL app.current_tenant_id = :tenant_id` at the start of each transaction using the verified `TenantContext`.
|
||||
4. Queries without an active tenant context setting return 0 rows and abort any insert/update operations.
|
||||
5. Connection pooling tests verify that executing a query for Tenant A, returning the connection to the pool, and querying for Tenant B without setting context never leaks Tenant A data.
|
||||
|
||||
---
|
||||
|
||||
### STORY-TENANT-005: Immutable Transaction Audit Trail Logging
|
||||
- **Parent Requirement:** [`FR-TENANTSECURITYAUDIT-003`](../../../03_requirements/use_cases/uc-017-tenant-security-audit/functional-reqs.md#fr-tenantsecurityaudit-003-immutable-transaction-audit-logging)
|
||||
- **SRS Linkage:** `SRS-TENANTSECURITYAUDIT-003`
|
||||
- **Architecture Contract:** `HLD-ISOLATION-AUDIT`, [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`database_design.md`](../../../04_architecture_design/database_design.md)
|
||||
- **Story Points:** 3 (P1)
|
||||
- **Description:** Implement an in-transaction append-only audit trail logging mechanism that records governed business mutations into the `transaction_audit_logs` table, preserving an immutable history of who changed what, when, and why.
|
||||
- **Acceptance Criteria:**
|
||||
1. Audit records are written in the same database transaction as the governed mutation; if the mutation rolls back, the audit entry rolls back, ensuring consistency.
|
||||
2. Captures: `audit_id`, `tenant_id`, `actor_id`, `entity_type`, `entity_id`, `action` (`CREATE`, `UPDATE`, `DELETE`, `STATUS_CHANGE`), `timestamp`, `correlation_id`, and `field_diff_json`.
|
||||
3. Table `transaction_audit_logs` is append-only: database permissions prohibit `UPDATE` and `DELETE` queries on audit rows.
|
||||
4. Provides authorized query endpoint `GET /api/v1/audit/events` restricted to Tenant Administrators and Partners within their own verified tenant.
|
||||
5. Minimizes sensitive data: passwords, tokens, and personal credential payloads are strictly redacted before serialization.
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# Iteration Plan — Iteration 02 (Tenant Lifecycle, Context Resolution & RLS Data Isolation)
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Iteration** | `iteration-02` |
|
||||
| **Slice Goal** | Deliver multi-tenant control plane, verified tenant context resolution, and PostgreSQL Row-Level Security (RLS) data isolation across `UC-017`, `UC-018`, and `UC-019`. |
|
||||
| **Governed Standard** | UP-AI v1.5 Stage 10 Standard |
|
||||
| **Parent Use Cases** | `UC-017`, `UC-018`, `UC-019` |
|
||||
| **Capacity** | 5 Stories (23 Story Points) |
|
||||
| **Status** | In Planning (Stage 10 Planned) |
|
||||
| **Version** | 1.0.0 |
|
||||
| **Last CR** | none |
|
||||
|
||||
---
|
||||
|
||||
## 1. Iteration Goal & Scope Summary
|
||||
|
||||
Deliver the core multi-tenancy control plane and database data isolation foundation for the Agriculture Trading Backoffice (ATB). This vertical slice operationalizes:
|
||||
1. Platform tenant provisioning and lifecycle governance (`UC-018`: `FR-TENANTLIFECYCLE-001`).
|
||||
2. Tenant administrator user membership and role management (`UC-019`: `FR-TENANTMEMBERSHIPCONTEXT-001`).
|
||||
3. Verified tenant context resolution and explicit multi-tenant switching (`UC-019`: `FR-TENANTMEMBERSHIPCONTEXT-002`).
|
||||
4. Automated PostgreSQL Row-Level Security (RLS) data isolation (`UC-017`: `FR-TENANTSECURITYAUDIT-001`).
|
||||
5. Tamper-resistant immutable transaction audit trail logging (`UC-017`: `FR-TENANTSECURITYAUDIT-003`).
|
||||
|
||||
By completing this slice, every subsequent business domain iteration (Mandi Price Discovery, Procurement Contracts, Inward Receiving, Inventory, Sales) automatically inherits verified tenant scoping, database connection isolation (`SET LOCAL app.current_tenant_id = :tenant_id`), and mutation audit trails out of the box without retrofitting.
|
||||
|
||||
---
|
||||
|
||||
## 2. Demo & Acceptance Criteria
|
||||
|
||||
Planned acceptance evidence for Iteration 02:
|
||||
1. **Tenant Lifecycle Management (`FR-TENANTLIFECYCLE-001`):** A Platform Administrator creates a new tenant trading firm with company details and assigns an initial Tenant Administrator. The platform administrator can activate, suspend, or close the tenant. Suspended or closed tenants cannot process API commands or authenticate members.
|
||||
2. **Tenant Membership & Role Assignment (`FR-TENANTMEMBERSHIPCONTEXT-001`):** A Tenant Administrator adds users to their specific firm and assigns approved PRD business roles. A Tenant Administrator is prevented from administering users or roles in any other tenant (cross-tenant administrative isolation).
|
||||
3. **Verified Tenant Context Resolution (`FR-TENANTMEMBERSHIPCONTEXT-002`):** Users with memberships in multiple trading firms explicitly select their active tenant context upon login. The backend verifies that the authenticated subject has an active membership in that tenant for every request. Client-supplied tenant IDs without verified membership fail closed with HTTP `403 Forbidden`.
|
||||
4. **PostgreSQL Row-Level Security (RLS) Isolation (`FR-TENANTSECURITYAUDIT-001`):** All tenant-owned tables enforce PostgreSQL RLS policies (`USING` and `WITH CHECK`). Every database transaction executes parameterized transaction-local context (`set_config('app.current_tenant_id', :tenant_id, true)`). Direct queries without active tenant context return zero rows and block writes. Pooled connection reuse between different tenants never leaks data.
|
||||
5. **Immutable Transaction Audit Trail (`FR-TENANTSECURITYAUDIT-003`):** Every governed business mutation appends an immutable audit trail record containing tenant ID, actor subject, action, entity type, entity ID, timestamp, correlation ID, and field changes. Audit rows cannot be modified or deleted.
|
||||
6. **Deterministic Offline Sandbox:** Extends the offline identity sandbox with tenant fixture data, membership claims, and multi-tenant personas for isolated local execution.
|
||||
7. **Quality & Coverage Compliance:**
|
||||
- Backend domain/FSM coverage: $\ge 95.0\%$
|
||||
- Integration adapter coverage: $\ge 90.0\%$
|
||||
- Frontend components coverage: $\ge 80.0\%$
|
||||
8. **Gate 14.1 Artifact Density:**
|
||||
- 21-sheet Excel QA Workbook with $\ge 20$ dense test cases across categories.
|
||||
- Git-versioned Bruno API collections (`.bru`) under `docs/api/bruno/tenant/` covering declared endpoints.
|
||||
- Multi-path 4-dimension functional test models in `07_test_design/functional_test_cases/` for `UC-017`, `UC-018`, and `UC-019`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Carried-Over Scope & Regression Debt
|
||||
|
||||
- **Carried-over stories from previous iteration:** None. Iteration 01 domain and controller logic passed all quality gates and statement coverage requirements.
|
||||
- **Regression debt from `regression_test_cases.md`:** All 31 automated tests from Iteration 01 (`TC-AUTH-001` through `TC-AUTH-004`) are carried forward into the regression suite and executed on every run.
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# Iteration Delivery Surface Matrix — Iteration 02
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Iteration** | `iteration-02` |
|
||||
| **Governed Standard** | UP-AI v1.5 Stage 10 Standard |
|
||||
| **Status** | In Planning (Stage 10 Planned) |
|
||||
| **Version** | 1.0.0 |
|
||||
| **Last CR** | none |
|
||||
|
||||
---
|
||||
|
||||
## 11-Dimension Delivery Surface Coverage
|
||||
|
||||
| Story ID | Parent FR | Portal / Screen | Route | API Endpoint | DB Migration | Sandbox / Mock | Config / Secret | Test Scopes | Dev Owner | QA Owner | Surface Status |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| `STORY-TENANT-001` | `FR-TENANTLIFECYCLE-001` | Platform Tenant Management View | `/platform/tenants` | `POST /api/v1/platform/tenants`, `PATCH /api/v1/platform/tenants/{tenant_id}/status` | Schema: `tenants` table via Alembic | `sandbox/identity_mock.py` (Tenant fixtures) | none | Unit (pytest), API (Bruno), Browser E2E (Playwright) | `@backend-dev`, `@ui-designer-dev` | `@adversarial-tester` | Planned for Construction |
|
||||
| `STORY-TENANT-002` | `FR-TENANTMEMBERSHIPCONTEXT-001` | Tenant Membership & Roles View | `/settings/members` | `POST /api/v1/tenants/{tenant_id}/memberships`, `GET /api/v1/tenants/{tenant_id}/memberships` | Schema: `tenant_memberships` table | Multi-tenant user persona fixtures | none | Unit (pytest), Security RBAC checks, API (Bruno) | `@backend-dev`, `@ui-designer-dev` | `@adversarial-tester` | Planned for Construction |
|
||||
| `STORY-TENANT-003` | `FR-TENANTMEMBERSHIPCONTEXT-002` | Header Active Tenant Switcher | Header Dropdown, `/select-tenant` | `GET /api/v1/auth/my-tenants`, `POST /api/v1/session/active-tenant` | Context resolver middleware | `sandbox/identity_mock.py` (Context claims) | none | Unit (pytest), API (Bruno), FSM Invariant | `@backend-dev`, `@ui-designer-dev` | `@adversarial-tester` | Planned for Construction |
|
||||
| `STORY-TENANT-004` | `FR-TENANTSECURITYAUDIT-001` | Data Access Boundary (All Portals) | All protected routes | Parameterized DB Session (`Depends(get_tenant_db)`) | Migration: `003_enable_postgresql_rls.py` (RLS policies) | PostgreSQL / SQLite context emulator | none | Concurrency unit tests, connection pooling leak tests | `@backend-dev` | `@adversarial-tester` | Planned for Construction |
|
||||
| `STORY-TENANT-005` | `FR-TENANTSECURITYAUDIT-003` | Audit Log Viewer Screen | `/settings/audit-logs` | `GET /api/v1/audit/events` | Migration: `004_transaction_audit_logs.py` | Mutation audit fixtures | none | Unit (pytest), Append-only immutability tests | `@backend-dev`, `@ui-designer-dev` | `@adversarial-tester` | Planned for Construction |
|
||||
|
||||
---
|
||||
|
||||
## Surface Breakdown & Responsibilities
|
||||
|
||||
1. **Frontend Portal / Screen Surfaces:**
|
||||
- **Platform Tenant Management View (`STORY-TENANT-001`):** React view allowing System Administrators to provision new agricultural trading firms, review company information, and toggle lifecycle state (`ACTIVE`, `SUSPENDED`, `CLOSED`).
|
||||
- **Tenant Member Management View (`STORY-TENANT-002`):** React view allowing Tenant Administrators to add colleagues, assign business roles from the 11 PRD roles, and deactivate memberships.
|
||||
- **Active Tenant Switcher (`STORY-TENANT-003`):** Header dropdown component displaying the currently active firm name and allowing seamless context switching for users with multiple trading firm memberships.
|
||||
- **Audit Log Viewer Screen (`STORY-TENANT-005`):** Read-only table view for Tenant Admins displaying immutable mutation history (timestamp, actor, action, entity, changed fields).
|
||||
2. **Backend API Endpoints:**
|
||||
- `POST /api/v1/platform/tenants`: Platform administrator endpoint to provision a new tenant firm.
|
||||
- `PATCH /api/v1/platform/tenants/{tenant_id}/status`: Transition tenant lifecycle state.
|
||||
- `POST /api/v1/tenants/{tenant_id}/memberships`: Tenant administrator endpoint to assign a user to a firm.
|
||||
- `GET /api/v1/auth/my-tenants`: Returns list of active tenant memberships for the current user.
|
||||
- `POST /api/v1/session/active-tenant`: Validates and binds active tenant context to current session.
|
||||
- `GET /api/v1/audit/events`: Returns paginated, tenant-scoped transaction audit logs.
|
||||
3. **Database & Migrations:**
|
||||
- Initial tenancy schema migration adding `tenants` and `tenant_memberships` tables.
|
||||
- RLS enablement migration adding PostgreSQL row-level security policies (`USING` and `WITH CHECK`).
|
||||
- Audit trail schema migration adding append-only `transaction_audit_logs` table.
|
||||
4. **Integration Sandboxes (Wave 0):**
|
||||
- Deterministic multi-tenant fixtures in `sandbox/identity_mock.py` pre-seeding `tenant-alpha`, `tenant-beta`, and multi-firm user personas (`multi@trader.com`).
|
||||
5. **Quality Assurance Deliverables:**
|
||||
- **Bruno Collections:** Git-versioned collections in `docs/api/bruno/tenant/` covering declared endpoints.
|
||||
- **Excel QA Workbook:** 21-sheet manual QA workbook compiled with $\ge 20$ test cases across categories.
|
||||
- **Multi-Path Automated Tests:** Happy Path, Boundary/Edge, Negative/Security, and FSM Invariant tests in `tests/backend/`.
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
# Parallel Work & Lane Isolation Plan — Iteration 02
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Iteration** | `iteration-02` |
|
||||
| **Governed Standard** | UP-AI v1.5 Standard |
|
||||
| **Integration Skill** | `up-parallel-work-integrate` |
|
||||
| **Status** | Approved for Construction |
|
||||
| **Version** | 1.0.0 |
|
||||
| **Last CR** | none |
|
||||
|
||||
---
|
||||
|
||||
## 1. Wave 0 — Sandbox & Integration Scaffolding
|
||||
|
||||
Before parallel application lanes commence development, Wave 0 establishes deterministic offline fixtures and mock claims for multi-tenancy:
|
||||
|
||||
| Adapter Component | Physical Path | Target Dependency | Mode | Owner |
|
||||
|---|---|---|---|---|
|
||||
| **Identity & Tenant Mock Adapter** | `sandbox/identity_mock.py` | Keycloak Multi-Tenant Claims & DB fixtures | Deterministic Mock (Local PKCE, JWT & Tenant Seeder) | `@backend-dev` |
|
||||
|
||||
- **Wave 0 Completion Criteria:** `sandbox/identity_mock.py` pre-seeds distinct trading firm records (`tenant-alpha`, `tenant-beta`), defines active tenant memberships, mints tokens with multi-tenant claims (`tenants: ["tenant-alpha", "tenant-beta"]`), and provides deterministic fixtures for multi-firm test personas (`multi@trader.com`).
|
||||
|
||||
---
|
||||
|
||||
## 2. Lane Allocations & Isolation
|
||||
|
||||
### Lane 1: Control Plane, Tenancy & Context APIs (`lane/backend-tenancy`)
|
||||
- **Assigned Stories:** `STORY-TENANT-001`, `STORY-TENANT-002`, `STORY-TENANT-003`
|
||||
- **Owner:** `@backend-dev`
|
||||
- **Allowed Scope / Paths:**
|
||||
- `backend/app/tenants/` (Tenant lifecycle manager, membership manager)
|
||||
- `backend/app/middleware/tenant.py` (TenantContextResolver, FastAPI `get_current_tenant` dependency)
|
||||
- `backend/app/api/platform_tenants.py` (Platform tenant endpoints)
|
||||
- `backend/app/api/tenant_memberships.py` (Tenant membership endpoints)
|
||||
- `tests/backend/test_tenancy_*.py` (Pytest / unittest test suite)
|
||||
- **Shared Artifacts & Ownership:** OpenAPI schema for `/api/v1/platform/tenants` and `/api/v1/tenants/*` (Single Owner: `@backend-dev`).
|
||||
- **Required Contracts:** [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`api_design.md`](../../../04_architecture_design/api_design.md).
|
||||
- **Dependencies:** Wave 0 `sandbox/identity_mock.py`.
|
||||
- **Completion Evidence:** `pytest tests/backend/test_tenancy_*.py` passes with $\ge 95\%$ domain coverage.
|
||||
|
||||
---
|
||||
|
||||
### Lane 2: PostgreSQL RLS Engine & Transaction Audit Trails (`lane/database-rls-audit`)
|
||||
- **Assigned Stories:** `STORY-TENANT-004`, `STORY-TENANT-005`
|
||||
- **Owner:** `@backend-dev` (Database / Security specialist)
|
||||
- **Allowed Scope / Paths:**
|
||||
- `backend/app/db/session.py` (Transaction-scoped `set_config('app.current_tenant_id', ...)` hook)
|
||||
- `backend/app/audit/` (In-transaction audit event logging service)
|
||||
- `backend/app/models/tenant.py`, `backend/app/models/audit.py`
|
||||
- `backend/alembic/versions/` (Tenancy, RLS policies, and audit log migrations)
|
||||
- `tests/backend/test_rls_isolation.py`, `tests/backend/test_audit_trail.py`
|
||||
- **Shared Artifacts & Ownership:** SQLAlchemy database session dependency and Alembic migration scripts.
|
||||
- **Required Contracts:** [`LLD-002`](../../../04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md), [`database_design.md`](../../../04_architecture_design/database_design.md).
|
||||
- **Dependencies:** Lane 1 TenantContext model.
|
||||
- **Completion Evidence:** Connection-pooling leakage tests pass; queries without active tenant return 0 rows; audit records append atomically with zero update/delete capabilities.
|
||||
|
||||
---
|
||||
|
||||
### Lane 3: Frontend Tenant Views & Context Switcher (`lane/frontend-tenancy`)
|
||||
- **Assigned Stories:** `STORY-TENANT-001` (UI), `STORY-TENANT-002` (UI), `STORY-TENANT-003` (UI), `STORY-TENANT-005` (UI)
|
||||
- **Owner:** `@ui-designer-dev`
|
||||
- **Allowed Scope / Paths:**
|
||||
- `frontend/src/features/tenants/` (Platform tenant list, create modal, status switcher)
|
||||
- `frontend/src/features/members/` (Member list, role assignment modal)
|
||||
- `frontend/src/components/HeaderTenantSwitcher.tsx` (Global header context switcher)
|
||||
- `frontend/src/features/audit/AuditLogView.tsx` (Read-only audit log viewer)
|
||||
- `frontend/src/stores/tenantStore.ts` (Active tenant state management)
|
||||
- **Shared Artifacts:** Consumes OpenAPI schema published by Lane 1.
|
||||
- **Required Contracts:** `06_wireframes/DESIGN.md`, Stage 11 Screen Specs (`SCREEN-TENANT-001` through `SCREEN-TENANT-004`).
|
||||
- **Dependencies:** Lane 1 API contract freeze.
|
||||
- **Completion Evidence:** Component tests pass ($\ge 80\%$ coverage); header context switcher successfully switches active tenant in state.
|
||||
|
||||
---
|
||||
|
||||
## 3. Integration Order & Merge Strategy
|
||||
|
||||
1. **Wave 0 (T0):** Pre-seed multi-tenant fixtures in `sandbox/identity_mock.py`.
|
||||
2. **Lane 1 + Lane 2 Core (T1):** Implement `TenantContext` model, DB session RLS hook, and migrations.
|
||||
3. **Lane 1 APIs (T2):** Implement FastAPI endpoints for platform tenancy and memberships.
|
||||
4. **Lane 3 UI Integration (T3):** Connect React header switcher and management views to API endpoints.
|
||||
5. **Wave 3 Convergence & Verification (T4):** Run combined regression test suite (`scripts/run_tests.sh --scope iteration-02`) verifying all 4 test dimensions and $\ge 95\%$ statement coverage.
|
||||
|
||||
|
|
@ -58,3 +58,27 @@ Executed Stage 13 (`up-code-generate`) and verified Gate 14.1 for `iteration-01`
|
|||
5. Test Runner & Quality Gate 14.1: Updated `scripts/run_tests.sh` to include Python unittest runner fallback. Executed `scripts/verify_traceability_gates.py --all --run-tests`; Gates 5.1, 9.1, and 14.1 passed with 0 Critical issues.
|
||||
6. Traceability & Lifecycle Progression: Transitioned `FR-AUTH-001`, `FR-AUTH-002`, `FR-AUTH-003` to `Implemented (Domain/Schema)` in `traceability_graph.md` and updated `iteration_surface_matrix.md`. Recorded Checkpoint 018 (`checkpoint-018-stage-13-code-generation-and-gate-14-1-pass.md`), updated `checkpoint_index.md` and `master_context.md`.
|
||||
|
||||
## 2026-10-12T05:26:24Z — User
|
||||
|
||||
What is your recommendation?
|
||||
|
||||
## 2026-10-12T05:27:00Z — Assistant — Action summary
|
||||
|
||||
Presented comprehensive architectural analysis recommending Pathway 1: Plan Iteration 02 for Multi-Tenant Control Plane, Verified Context Resolution & PostgreSQL RLS (`UC-018`, `UC-019`, `UC-017`) to establish the data isolation foundation prior to business domain construction, alongside alternative pathways (Playwright browser E2E vs. jumping directly to Mandi Price discovery).
|
||||
|
||||
## 2026-10-12T05:29:54Z — User
|
||||
|
||||
proceed
|
||||
|
||||
## 2026-10-12T05:35:00Z — Assistant — Action summary
|
||||
|
||||
Executed Stage 10 Iteration Planning (`up-iteration-plan`) for `iteration-02`:
|
||||
1. Scoped vertical slice across `UC-017`, `UC-018`, and `UC-019` covering 5 functional requirements (`FR-TENANTLIFECYCLE-001`, `FR-TENANTMEMBERSHIPCONTEXT-001/002`, `FR-TENANTSECURITYAUDIT-001/003`).
|
||||
2. Authored `iteration_plan.md` (23 story points capacity, clear demo acceptance criteria, regression suite continuity).
|
||||
3. Authored `iteration_backlog.md` detailing stories `STORY-TENANT-001` through `STORY-TENANT-005` with strict acceptance criteria and PRD role constraints.
|
||||
4. Authored `iteration_surface_matrix.md` mapping all 11 delivery surfaces across platform management, member management, header tenant switcher, DB migrations, and RLS policies.
|
||||
5. Authored `parallel_work_plan.md` defining Wave 0 multi-tenant sandbox fixtures and 3 isolated parallel development lanes (Backend Tenancy, Database RLS & Audit, Frontend Views).
|
||||
6. Transitioned child requirements in `traceability_graph.md` to `In Construction (Iteration 02)`.
|
||||
7. Recorded Checkpoint 019 (`checkpoint-019-iteration-02-planning.md`), updated `checkpoint_index.md` and `master_context.md`. Re-verified Gate 14.1 on `iteration-01` regression suite passing cleanly.
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue