From f92728420663f697d36ba03c8f6a97198dc3021c Mon Sep 17 00:00:00 2001 From: Prashant Shendre Date: Sun, 11 Oct 2026 16:35:15 +0530 Subject: [PATCH] architecture spike --- .../00_process_control/ambiguity_register.md | 3 +- .../architecture_risk_register.md | 68 +++++++++---- ...kpoint-012-stage-6-7-architecture-spike.md | 25 +++++ .../checkpoints/checkpoint_index.md | 2 + .../00_process_control/master_context.md | 7 +- .../00_process_control/traceability_graph.md | 31 +++++- .../00_process_control/traceability_index.md | 6 +- .../architecture_spike_report.md | 97 +++++++++++++++++++ .../deployment_spike.md | 46 +++++++++ .../04_architecture_design/hld.md | 91 +++++++++++------ .../lld/LLD-001_auth_service.md | 72 ++++++++------ .../LLD-002_tenant_context_and_isolation.md | 57 +++++++++++ .../LLD-003_receiving_quality_inventory.md | 48 +++++++++ .../lld/LLD-004_financial_controls.md | 39 ++++++++ .../lld/LLD-005_reporting_and_events.md | 36 +++++++ .../lld/LLD-006_privacy_lifecycle.md | 31 ++++++ ...11T074829Z-session-greenfield-bootstrap.md | 16 +++ 17 files changed, 590 insertions(+), 85 deletions(-) create mode 100644 04_generated_documentation/00_process_control/checkpoints/checkpoint-012-stage-6-7-architecture-spike.md create mode 100644 04_generated_documentation/04_architecture_design/architecture_spike_report.md create mode 100644 04_generated_documentation/04_architecture_design/deployment_spike.md create mode 100644 04_generated_documentation/04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md create mode 100644 04_generated_documentation/04_architecture_design/lld/LLD-003_receiving_quality_inventory.md create mode 100644 04_generated_documentation/04_architecture_design/lld/LLD-004_financial_controls.md create mode 100644 04_generated_documentation/04_architecture_design/lld/LLD-005_reporting_and_events.md create mode 100644 04_generated_documentation/04_architecture_design/lld/LLD-006_privacy_lifecycle.md diff --git a/04_generated_documentation/00_process_control/ambiguity_register.md b/04_generated_documentation/00_process_control/ambiguity_register.md index 8f6897d..1dcd79b 100644 --- a/04_generated_documentation/00_process_control/ambiguity_register.md +++ b/04_generated_documentation/00_process_control/ambiguity_register.md @@ -6,7 +6,7 @@ | **Process** | UP-AI v1.5 | | **Last Updated** | 2026-10-11 | -Open requirements questions are tracked here (`AMB-xxx`). Unresolved business rules will not be inferred from the illustrative mockup. +Open requirements and architecture questions are tracked here (`AMB-xxx`). Unresolved business rules will not be inferred from the illustrative mockup. | ID | Date | Stage | Ambiguity / Question | Context & Impact | Resolution / Decision | Status | Resolved By | |---|---|---|---|---|---|---|---| @@ -18,3 +18,4 @@ Open requirements questions are tracked here (`AMB-xxx`). Unresolved business ru | AMB-006 | 2026-10-11 | Stage 0B | What actual retention durations and additional India-specific sectoral/contractual obligations apply to v1? | The stakeholder accepted the SaaS privacy roles, India-first scope, all-natural-person coverage, four internal sensitivity labels with separate personal-data/purpose tags, category/purpose retention governance, OWASP ASVS v5.0.0 Level 2, and the review path: tenant legal/accounting reviewers approve trading-data purposes/retention; the ATB operator’s qualified privacy/legal reviewer approves platform processing, retention, and processor obligations. Exact durations and other legal/contractual duties remain unconfirmed. The Act/Rules have phased commencement. | PRD captures accepted policy in `BRD-FR-047`–`BRD-FR-051` and `BRD-NFR-009`/`BRD-NFR-014`. Under `ASM-002`, extraction and early design proceed without assuming durations or obligations; record qualified review evidence and revalidate current requirements before production release. | Open | — | | AMB-007 | 2026-10-11 | Stage 0B | What production availability, backup retention, RTO, and RPO targets are acceptable? | These targets determine hosting, data protection, recovery design, and support commitments. | Resolved: 99.9% monthly availability measured 24/7; RTO ≤4 hours; RPO ≤15 minutes; encrypted daily backups with point-in-time recovery and 35-day retention; quarterly restore exercises. Captured in `BRD-NFR-011`. | Resolved | Stakeholder, 2026-10-11 | | AMB-008 | 2026-10-11 | Stage 0B | What tenant count, active-user count, transaction volume, peak concurrency, and per-tenant limits must the platform support? | Stakeholder approved an initial envelope of 50 tenant firms, 25 named users per tenant, and 250 concurrent active users service-wide. The approved provisional planning scenario is 200 core business documents per tenant per operating day with a 5× peak-hour burst. Stakeholder accepted no fixed business-document quota; observe per-tenant use, provide configurable early warnings near the tested fair-share budget, and protect core transactions while using backpressure/temporary throttling for expensive reports or bulk exports under contention. Numeric fair-share budgets and alert thresholds still require architecture/load-test evidence and later pilot refinement. | Partially resolved: approved 50 tenant firms, up to 25 named users per tenant, 250 concurrent active users service-wide, and 50,000 ledger rows per tenant for report validation. The 200 documents/tenant/operating day and 5× peak-hour burst scenario has been accepted for load testing; set numeric fair-share budgets and alert thresholds from architecture/load-test evidence and refine them with pilot telemetry; see `BRD-NFR-004` and `BRD-NFR-012`. | Open | — | +| AMB-009 | 2026-10-11 | Stage 7 | Which candidate architecture patterns should be adopted for the Stage 7 walking skeleton, and what evidence is required before full-breadth design? | The Stage 7 report proposes transaction-local PostgreSQL tenant context with RLS, server-verified UC-019 membership, append-only audit and a transactional outbox, Keycloak session/logout semantics, provider-neutral HA/deployment controls, and an in-scope runtime validation threshold. These are not yet approved implementation decisions. | Candidate analysis is in 04_generated_documentation/04_architecture_design/architecture_spike_report.md; obtain human-lead approve/adjust/defer disposition. Runtime proof is explicitly pending product implementation/environment. | Open | — | diff --git a/04_generated_documentation/00_process_control/architecture_risk_register.md b/04_generated_documentation/00_process_control/architecture_risk_register.md index 05f9708..f9d351e 100644 --- a/04_generated_documentation/00_process_control/architecture_risk_register.md +++ b/04_generated_documentation/00_process_control/architecture_risk_register.md @@ -2,29 +2,63 @@ | Field | Value | |---|---| -| **Governed Standard** | SEI-CMMI Level 3 (UP-AI v1.0) | +| **Governed Standard** | UP-AI v1.5, Stages 6–7 | | **Document Path** | `04_generated_documentation/00_process_control/architecture_risk_register.md` | | **Last Updated** | 2026-10-11 | -| **Version** | 1.1.0 | -| **Last CR** | `CR-001` | +| **Version** | 2.0.0 | +| **Last CR** | `CR-001` (UC-001 rebaseline retained) | +| **Stage Status** | Stage 6 scored; Stage 7 architecture review pending human-lead sign-off | ---- +## 1. Scoring Scale and Dimensions -## 1. Architectural Risk Dimensions (1 to 5 Scale) +Scores are ordinal: 1 = low, 2 = limited, 3 = moderate, 4 = high, 5 = critical. RISK-xxx maps one-to-one to its owning UC; the total is the sum of D1–D5. Rank sorts total descending, with UC number as the deterministic tie-break. These are comparative design risks, not likelihood percentages. -1. **D1: Data Isolation & Multi-Tenancy:** Cross-tenant boundaries, RLS schema isolation complexity. -2. **D2: External Integration Dependency:** Third-party APIs, external identity providers, payment gateways, messaging. -3. **D3: Financial & Transactional Sensitivity:** Ledgers, payment processing, irreversible state transitions. -4. **D4: Throughput & Concurrency:** High-volume streaming, live event ingestion, background queue locks. -5. **D5: Novelty & Uncertainty:** Complex algorithms, lack of precedent, unproven patterns. +1. **D1 — Data Isolation & Multi-Tenancy:** Tenant boundaries, membership/context verification, RLS, control-plane separation. +2. **D2 — External Integration Dependency:** External identity, payment, messaging, or other explicitly specified service dependencies. Do not assume an external weighbridge/payment API where the BRD specifies manual capture only. +3. **D3 — Financial & Transactional Sensitivity:** Ledger integrity, credit decisions, irreversible state, posting/reversal atomicity. +4. **D4 — Throughput & Concurrency:** Real-time behavior, concurrent writes, queue contention, report capacity obligations. +5. **D5 — Novelty & Technical Uncertainty:** Unproven design, cross-module invariants, complex state/data lifecycle. Open business/legal values are not scored as settled design. ---- +A use case is Architecturally Significant if any dimension is 4–5 or it is in the top 20% by total score. The threshold deliberately includes all single-dimension high/critical risks even when that exceeds 20% of the set. -## 2. Use Case Risk Scoring Matrix +## 2. Full Use-Case Risk Matrix -CR-001 changed UC-001 scope to OIDC authentication and authorization. The prior sample score and Stage 7 walking-skeleton claim are not current evidence; the row is marked for scoring in the Stage 6 assessment across the complete 26-use-case set. +| Risk ID | UC-ID | Use Case Name | D1 | D2 | D3 | D4 | D5 | Total | Rank | Architecturally Significant | Rationale | +|---|---|---|---:|---:|---:|---:|---:|---:|---:|---|---| +| `RISK-001` | `UC-001` | User Authentication and Authorization | 5 | 5 | 2 | 2 | 4 | **18** | 2 | Yes | OIDC identity dependency plus tenant-scoped authorization and session security; exact revocation design remains open after CR-001. | +| `RISK-002` | `UC-002` | Record Daily Mandi Arrivals and Prices | 2 | 1 | 2 | 2 | 1 | **8** | 25 | No | Daily observation entry is tenant scoped but has no specified external integration, financial posting, or complex state machine. | +| `RISK-003` | `UC-003` | Mandi Price Trend Analytics | 2 | 1 | 1 | 4 | 3 | **11** | 18 | Yes | 20-day trend analytics must meet the 50,000-row report SLA; query shape and summary strategy need measurement. | +| `RISK-004` | `UC-004` | Purchase Sauda and Supplier Payables Setup | 2 | 1 | 3 | 2 | 3 | **11** | 19 | No | Sauda booking spans partial deliveries and commercial calculations, but no external provider or irreversible ledger transition is specified. | +| `RISK-005` | `UC-005` | Inward Vehicle Receiving and Goods Receipt | 3 | 1 | 4 | 3 | 4 | **15** | 9 | Yes | Weighments and tare/shortage calculations culminate in GRN, stock, and lot creation; no physical weighbridge API is specified. | +| `RISK-006` | `UC-006` | Inward Quality Inspection and Lot Control | 3 | 1 | 3 | 2 | 4 | **13** | 15 | Yes | QC Hold/Released invariants, lot lineage, and deduction rules must remain consistent across allocation and dispatch. | +| `RISK-007` | `UC-007` | Warehouse Stock, Audit, Capacity and Transfer | 3 | 1 | 5 | 4 | 3 | **16** | 7 | Yes | Double-entry multi-godown stock movements, real-time positions, reconciliation adjustments, and concurrency create transactional risk. | +| `RISK-008` | `UC-008` | Customer Sales Contract, Credit Check and Allocation | 3 | 1 | 4 | 3 | 3 | **14** | 11 | Yes | Credit exposure and available-lot reservation couple sales confirmation to receivables and inventory state. | +| `RISK-009` | `UC-009` | Outbound Dispatch and Delivery | 3 | 2 | 4 | 4 | 3 | **16** | 8 | Yes | Dispatch state, outward weighment, POD, shortage notes, and compensating credit notes span operational and financial records. | +| `RISK-010` | `UC-010` | Transport Fleet Registry | 2 | 1 | 1 | 1 | 1 | **6** | 26 | No | Fleet registry is conventional master-data CRUD without a specified live telematics integration. | +| `RISK-011` | `UC-011` | Customer Receivables and Credit Controls | 3 | 1 | 5 | 4 | 4 | **17** | 4 | Yes | Immutable receivables, credit locks/overrides, receipt clearing and bounced-instrument reversals have high financial and concurrency impact. | +| `RISK-012` | `UC-012` | Supplier Payables and Aging | 3 | 1 | 3 | 2 | 2 | **11** | 20 | No | Payables aging and snapshots are financial but primarily derived from accepted GRNs; no payment execution integration is specified. | +| `RISK-013` | `UC-013` | Mandi Operating Expense Recording | 2 | 1 | 3 | 1 | 2 | **9** | 22 | No | Expense recording has accounting sensitivity but no complex posting lifecycle or external dependency specified. | +| `RISK-014` | `UC-014` | Operational Alert Review | 3 | 2 | 2 | 4 | 3 | **14** | 12 | Yes | Proactive alerts depend on timely evaluation of multiple operational and financial conditions; delivery-channel integration is not yet specified. | +| `RISK-015` | `UC-015` | Executive Dashboard and Trading Snapshots | 3 | 1 | 3 | 4 | 3 | **14** | 13 | Yes | Executive dashboard and rolling snapshots combine live operational and financial aggregates under the report SLA. | +| `RISK-016` | `UC-016` | Commodity and Trading Counterparty Master Data | 3 | 1 | 2 | 2 | 1 | **9** | 23 | No | Commodity and counterparty masters are tenant-scoped reference data with standard lifecycle complexity. | +| `RISK-017` | `UC-017` | Tenant Isolation and Transaction Audit | 5 | 1 | 4 | 3 | 4 | **17** | 5 | Yes | Tenant isolation is a system-wide security boundary; immutable transaction audit must cover governed mutations without leakage. | +| `RISK-018` | `UC-018` | Tenant Provisioning and Lifecycle | 5 | 3 | 1 | 2 | 3 | **14** | 14 | Yes | Tenant create/activate/suspend is a control-plane boundary with identity provisioning and risk of cross-tenant administration. | +| `RISK-019` | `UC-019` | Tenant Membership and Verified Context | 5 | 4 | 2 | 4 | 4 | **19** | 1 | Yes | Membership and active-tenant verification join external identity to tenant roles on every operation; stale or spoofed context is critical. | +| `RISK-020` | `UC-020` | Tenant Resource Isolation and Privileged Support | 5 | 1 | 3 | 5 | 4 | **18** | 3 | Yes | Isolation spans synchronous and asynchronous resources, exports, files, caches, jobs, and exceptional support access. | +| `RISK-021` | `UC-021` | Personal Data Purpose, Notice and Consent | 3 | 1 | 2 | 1 | 2 | **9** | 24 | No | Purpose, notice, and consent evidence is privacy-sensitive but uses a conventional tenant-governed record lifecycle. | +| `RISK-022` | `UC-022` | Data Principal Rights and Grievance Requests | 3 | 2 | 2 | 2 | 3 | **12** | 16 | No | Rights and grievance cases involve identity matching and controlled disclosure, with moderate workflow uncertainty. | +| `RISK-023` | `UC-023` | Personal Data Breach Response Coordination | 4 | 2 | 2 | 3 | 4 | **15** | 10 | Yes | Breach coordination spans tenant and operator responsibilities, affected-person data, evidence, and notification workflow. | +| `RISK-024` | `UC-024` | Purpose-Aware Retention, Erasure and Legal Holds | 4 | 1 | 4 | 3 | 5 | **17** | 6 | Yes | Purpose-aware erasure must reconcile legal holds, statutory minimums, backups, logs, and tenant data boundaries; durations remain AMB-006. | +| `RISK-025` | `UC-025` | Processor and Subprocessor Governance | 3 | 3 | 1 | 1 | 2 | **10** | 21 | No | Processor inventory and due-diligence records have external-party scope but are not specified as live integrations. | +| `RISK-026` | `UC-026` | Tenant Operating Policy Configuration | 3 | 1 | 3 | 2 | 3 | **12** | 17 | No | Tenant-scoped effective-dated policies gate affected workflows and audit changes; candidate thresholds require controlled rollout. | -| UC-ID | Use Case Name | D1 | D2 | D3 | D4 | D5 | Total Score | Rank | Architecturally Significant (Y/N) | Architecture Rationale | -|---|---|---|---|---|---|---|---|---|---|---| -| `UC-001` | User Authentication and Authorization | TBD | TBD | TBD | TBD | TBD | **TBD** | TBD | **Pending Stage 6** | Re-score after CR-001; do not rely on bootstrap sample score or claimed Stage 7 validation. | -| `UC-002` | User Profile & Preferences | 3 | 1 | 1 | 1 | 1 | **7** | 2 | **No** | Standard CRUD operations; inherits service template and RLS pattern from `UC-001`. | +## 3. Stage 6 Result + +- Use cases scored: **26**; child FRs in the current gated set: **54**. +- Architecturally significant by the stated rule: **16**. All six top-ranked UCs are included; remaining high single-dimension risks are retained in the significant set. +- Stage 7 deep-spike focus: `UC-001`, `UC-005`, `UC-006`, `UC-007`, `UC-011`, `UC-014`, `UC-017`, `UC-019`, `UC-020`. These cover identity and external auth, tenant control/data boundaries, goods receipt/lot state, stock ledger, financial reversal, and operational event delivery. Other significant UCs map to these validated patterns for full-breadth Stage 9 design. +- The former UC-001 bootstrap score and “Stage 7 validated” assertion are superseded; scores above are based on current UC/FR content after CR-001. + +## 4. Stage 7 State + +Risk ranking complete. Candidate HLD/LLD/deployment and design-level walking-skeleton analysis are in `04_architecture_design/architecture_spike_report.md`, `hld.md`, `lld/LLD-001_auth_service.md`, `lld/LLD-002_tenant_context_and_isolation.md`, `lld/LLD-003_receiving_quality_inventory.md`, `lld/LLD-004_financial_controls.md`, `lld/LLD-005_reporting_and_events.md`, `lld/LLD-006_privacy_lifecycle.md`, and `deployment_spike.md`. Human-lead sign-off is pending. No runtime skeleton has been implemented or tested; the design report distinguishes scenario walkthrough evidence from runtime proof. diff --git a/04_generated_documentation/00_process_control/checkpoints/checkpoint-012-stage-6-7-architecture-spike.md b/04_generated_documentation/00_process_control/checkpoints/checkpoint-012-stage-6-7-architecture-spike.md new file mode 100644 index 0000000..47bd5f7 --- /dev/null +++ b/04_generated_documentation/00_process_control/checkpoints/checkpoint-012-stage-6-7-architecture-spike.md @@ -0,0 +1,25 @@ +# Checkpoint 012 — Stages 6–7 Architecture Risk Spike + +- **Checkpoint ID:** CKPT-012 +- **Date:** 2026-10-11 +- **Active Stage:** Stage 6 complete; Stage 7 candidate design ready for human-lead review +- **Active Track:** Greenfield, India-first, multi-tenant Agriculture Trading Backoffice (ATB) +- **Active Skill:** up-arch-risk-spike + +## Completed +- Verified CKPT-011, current workspace artifacts, Stage 6–7 process rules, and the active tech-profile.yaml. +- Re-ran Gate 5.1: 26 use cases / 54 child FRs; zero Critical and two documented Major parser warnings for justified new — not in BRD on FR-AUTH-001/003. +- Replaced the incomplete/stale two-row risk register with scored rows for all 26 use cases, five dimensions each, deterministic total/rank, rationale, and significance rule. Sixteen UCs meet at least one 4–5 dimension. +- Drafted Stage 7 candidate ATB HLD, updated the UC-001 identity LLD, added five focused LLDs (tenant/security; receiving/quality/inventory; finance; events/reporting; privacy lifecycle), provider-neutral deployment view, and architecture spike report. +- Walked through tenant-scoped GRN→QC→stock→alert and bounced-receipt reversal scenarios, including failure cases. This is a design-consistency walkthrough only. Risk-score consistency and diff-format checks passed. +- Logged candidate architecture choices and human-lead disposition under AMB-009. No new architecture decisions were recorded as accepted. +- No product app, migration, deployment target, or runtime spike harness exists; no runtime or load tests were run. The report does not claim runtime validation. + +## Open Items +- Human lead must Approve / Approve with changes / Defer the candidate patterns in AMB-009 and sign off on the Stage 7 report. +- Runtime PostgreSQL RLS, Keycloak/sandbox, event-outage, concurrency, privacy storage, deployment recovery, and load validation remain implementation evidence. +- Gate 9.1 is not run; SRS has not yet been derived for all FRs. Iteration-01 remains Incomplete / Pending Construction; Gate 14.1 has two Critical findings (missing dense workbook and Bruno collections). +- AMB-001, AMB-006, AMB-008 and assumptions ASM-001–ASM-003 remain open/evidence-gated. + +## Exact Next Action +Review architecture_spike_report.md and record the human-lead disposition in AMB-009. If approved, proceed to Stage 8 /up-srs-derive; if changes are requested, update the candidate artifacts and review them again. Do not claim runtime validation or start full-breadth Stage 9 design until the spike disposition is recorded. diff --git a/04_generated_documentation/00_process_control/checkpoints/checkpoint_index.md b/04_generated_documentation/00_process_control/checkpoints/checkpoint_index.md index 204b2e6..2f61033 100644 --- a/04_generated_documentation/00_process_control/checkpoints/checkpoint_index.md +++ b/04_generated_documentation/00_process_control/checkpoints/checkpoint_index.md @@ -33,3 +33,5 @@ | `CKPT-010` | 2026-10-11 | Stage 5 (CR-001 Approved Rebaseline) | UC-001 and associated requirements/governance records realigned to OIDC AuthN/AuthZ and the ATB baseline; Gate 5.1 passed with 0 Critical and 2 justified source-parser warnings. | CR-001 downstream architecture/iteration/test reconciliation pending; affected files remain deleted in active worktree; Gate 9.1 pending; `AMB-001`, `AMB-006`, `AMB-008` remain open. | Make restored downstream artifacts visible in the active worktree (or confirm deleted scope), reconcile applicable CR-001 impacts, and verify delivery evidence before closing CR-001. | `checkpoint-010-cr001-rebaseline.md` | | `CKPT-011` | 2026-10-11 | Stage 5 (CR-001 Verification) | Restored impacted artifacts confirmed and rebaselined to UC-001 v1.1.0; Gate 5.1 passed with 0 Critical and 2 documented source-parser warnings. Unsupported Gate 14.1 claim corrected to Incomplete / Pending Construction. | Gate 14.1 failed (2 Critical: workbook and Bruno evidence missing); construction, Gate 9.1, and `AMB-001`/`AMB-006`/`AMB-008` remain pending. CR-001 is closed after impact rebaseline verification. | Proceed to Stage 6 architecture risk scoring/spike; then complete remaining Elaboration gates before Construction. Keep iteration-01 Incomplete / Pending Construction. | `checkpoint-011-cr001-restored-artifacts.md` | + +| CKPT-012 | 2026-10-11 | Stage 6 complete / Stage 7 human review | Scored all 26 UCs/54 FRs; 16 architecturally significant. Drafted candidate HLD, LLDs, deployment view, and spike report; design walkthrough only, no runtime proof. | AMB-009 human-lead disposition; runtime validation and Gate 9.1 remain pending; iteration-01 Gate 14.1 blockers unchanged. | Review architecture_spike_report.md; record Approve / Approve with changes / Defer for AMB-009. If approved, proceed to Stage 8 SRS derivation. | checkpoint-012-stage-6-7-architecture-spike.md | diff --git a/04_generated_documentation/00_process_control/master_context.md b/04_generated_documentation/00_process_control/master_context.md index aecdef5..bab0d3b 100644 --- a/04_generated_documentation/00_process_control/master_context.md +++ b/04_generated_documentation/00_process_control/master_context.md @@ -8,6 +8,7 @@ | **Active Process** | AI-Native Unified Process (UP-AI v1.5) | | **Governance Tier** | `tier_2_standard_enterprise` | | **Last Updated** | 2026-10-11 | +| **Last CR** | CR-001 (Closed) | --- @@ -85,6 +86,6 @@ stack: ## 4. Active Stage & Next Actions -- **Current Stage:** Stage 1 — Business requirements extraction; PRD baselined for extraction under bounded, evidence-gated assumptions. -- **Active Iteration:** None; no iteration has been planned for this project baseline. -- **Next:** Review `04_generated_documentation/01_source_inventories/brd_inventory.md` for completeness, then continue the Greenfield track to Stage 5 use-case authoring. Carry `ASM-001`–`ASM-003` forward. Pilot results (`AMB-001`), qualified legal/accounting evidence (`AMB-006`), and load-test/pilot evidence (`AMB-008`) remain production/release gates; the assumptions do not resolve them. +- **Current Stage:** Stage 6 risk ranking is complete across 26 UCs. Stage 7 candidate HLD/LLD/deployment and a design-level walking-skeleton analysis are drafted; human-lead sign-off is pending under AMB-009. Runtime validation has not been performed. +- **Active Iteration:** No iteration is in construction. Iteration-01 remains planned but Incomplete / Pending Construction; Gate 14.1 has two Critical findings (dense QA workbook and Bruno API collections missing). +- **Next:** Review 04_generated_documentation/04_architecture_design/architecture_spike_report.md and resolve AMB-009 (Approve / Approve with changes / Defer). If approved, continue to Stage 8 with /up-srs-derive, then Stage 9 /up-hld-lld-generate and Gate 9.1 before Construction. Gate 5.1 passed with two documented Major source-parser warnings for justified new auth requirements and no Critical findings. Carry ASM-001–ASM-003 and open production evidence gates AMB-001, AMB-006, AMB-008 forward. diff --git a/04_generated_documentation/00_process_control/traceability_graph.md b/04_generated_documentation/00_process_control/traceability_graph.md index 36935f2..018c140 100644 --- a/04_generated_documentation/00_process_control/traceability_graph.md +++ b/04_generated_documentation/00_process_control/traceability_graph.md @@ -56,9 +56,34 @@ graph TD | Node ID | Node Name | Parent ID | Downstream Linkages | Status | |---|---|---|---|---| | `UC-001` | User Authentication and Authorization | `BRD-FR-040`, `BRD-NFR-009`, `tech-profile.yaml` | `FR-AUTH-001`, `FR-AUTH-002`, `FR-AUTH-003` | Baselined (CR-001, v1.1.0) | -| `FR-AUTH-001` | OIDC Authentication | `UC-001` | HLD/LLD, STORY-AUTH-001, TC-AUTH-001/002 rebaselined under CR-001 | Baselined; pending construction verification | -| `FR-AUTH-002` | Role-Based Authorization | `UC-001` | `BRD-FR-040`; HLD/LLD, STORY-AUTH-002, TC-AUTH-003 rebaselined under CR-001 | Baselined; pending construction verification | -| `FR-AUTH-003` | Session Handling and Logout | `UC-001` | `BRD-NFR-009`; HLD/LLD, STORY-AUTH-003, TC-AUTH-004 rebaselined under CR-001 | Baselined; pending construction verification | +| `FR-AUTH-001` | OIDC Authentication | `UC-001` | Candidate HLD-ATB / LLD-001/002 (Stage 7); SRS pending Stage 8; story/test specs rebaselined under CR-001 | Baselined; pending Stage 7 sign-off and construction | +| `FR-AUTH-002` | Role-Based Authorization | `UC-001` | `BRD-FR-040`; candidate HLD-ATB / LLD-001/002 (Stage 7); SRS pending Stage 8 | Baselined; pending Stage 7 sign-off and construction | +| `FR-AUTH-003` | Session Handling and Logout | `UC-001` | `BRD-NFR-009`; candidate HLD-ATB / LLD-001/002 (Stage 7); SRS pending Stage 8 | Baselined; pending Stage 7 sign-off and construction | + + +## Stage 7 Candidate Design Links (Draft; Gate 9.1 not run) + +| Use Case | Functional Requirements | Candidate Architecture Artifact | +|---|---|---| +| UC-001 | FR-AUTH-001–003 | HLD-ATB, LLD-001, LLD-002 | +| UC-003 | FR-MARKETTRENDANALYTICS-001 | LLD-005 | +| UC-004 | FR-PROCUREMENTCONTRACTS-001–004 | LLD-004 | +| UC-005 | FR-INWARDRECEIVING-001–006 | LLD-003 | +| UC-006 | FR-QUALITYANDLOTCONTROL-001–004 | LLD-003 | +| UC-007 | FR-WAREHOUSEINVENTORY-001–003 | LLD-003 | +| UC-008 | FR-SALESCONTRACTS-001–003 | LLD-004 | +| UC-009 | FR-DISPATCHDELIVERY-001–003 | LLD-004 | +| UC-011 | FR-CUSTOMERRECEIVABLES-001–004 | LLD-004 | +| UC-014 | FR-OPERATIONALALERTS-001 | LLD-005 | +| UC-015 | FR-EXECUTIVEREPORTING-001/002 | LLD-005 | +| UC-017 | FR-TENANTSECURITYAUDIT-001/003 | LLD-002 | +| UC-018 | FR-TENANTLIFECYCLE-001 | LLD-002 | +| UC-019 | FR-TENANTMEMBERSHIPCONTEXT-001/002 | LLD-002 | +| UC-020 | FR-TENANTSUPPORTSECURITY-001/002 | LLD-002 | +| UC-023 | FR-PRIVACYBREACHRESPONSE-001 | LLD-006 | +| UC-024 | FR-RETENTIONERASURE-001 | LLD-006 | + +These artifacts are candidate Stage 7 spike outputs. They do not replace Stage 8 SRS derivation or Stage 9 full-breadth design, and they do not satisfy Gate 9.1. --- diff --git a/04_generated_documentation/00_process_control/traceability_index.md b/04_generated_documentation/00_process_control/traceability_index.md index ff90170..b7576ea 100644 --- a/04_generated_documentation/00_process_control/traceability_index.md +++ b/04_generated_documentation/00_process_control/traceability_index.md @@ -22,6 +22,6 @@ $$\text{BRD-FR-xxx} \longrightarrow \text{UC-xxx} \longrightarrow \text{FR-xxx} | Trace ID | Requirement Name | Actor(s) | BRD Feature | UC ID | FR ID(s) | HLD / LLD Component | Delivery Stories | Test Cases | Delivery Status | |---|---|---|---|---|---|---|---|---|---| -| `TR-001` | User Authentication & OIDC PKCE | All Users | `tech-profile.yaml`; `BRD-NFR-009` | `UC-001` | `FR-AUTH-001` | HLD/LLD rebaselined (CR-001) | `STORY-AUTH-001` | `TC-AUTH-001`, `TC-AUTH-002` | Pending Construction; not delivered | -| `TR-002` | Role-Based Authorization | PRD-defined roles | `BRD-FR-040` | `UC-001` | `FR-AUTH-002` | HLD/LLD rebaselined (CR-001) | `STORY-AUTH-002` | `TC-AUTH-003` | Pending Construction; not delivered | -| `TR-003` | Session Handling and Logout | All Users | `BRD-NFR-009`; `tech-profile.yaml` | `UC-001` | `FR-AUTH-003` | HLD/LLD rebaselined (CR-001) | `STORY-AUTH-003` | `TC-AUTH-004` | Pending Construction; not delivered | +| `TR-001` | User Authentication & OIDC PKCE | All Users | `tech-profile.yaml`; `BRD-NFR-009` | `UC-001` | `FR-AUTH-001` | Candidate HLD-ATB / LLD-001/002 (Stage 7; draft) | `STORY-AUTH-001` | `TC-AUTH-001`, `TC-AUTH-002` | Pending Construction; not delivered | +| `TR-002` | Role-Based Authorization | PRD-defined roles | `BRD-FR-040` | `UC-001` | `FR-AUTH-002` | Candidate HLD-ATB / LLD-001/002 (Stage 7; draft) | `STORY-AUTH-002` | `TC-AUTH-003` | Pending Construction; not delivered | +| `TR-003` | Session Handling and Logout | All Users | `BRD-NFR-009`; `tech-profile.yaml` | `UC-001` | `FR-AUTH-003` | Candidate HLD-ATB / LLD-001/002 (Stage 7; draft) | `STORY-AUTH-003` | `TC-AUTH-004` | Pending Construction; not delivered | diff --git a/04_generated_documentation/04_architecture_design/architecture_spike_report.md b/04_generated_documentation/04_architecture_design/architecture_spike_report.md new file mode 100644 index 0000000..0317253 --- /dev/null +++ b/04_generated_documentation/04_architecture_design/architecture_spike_report.md @@ -0,0 +1,97 @@ +--- +id: ARCH-SPIKE-001 +version: 1.0.0 +status: Draft — Stage 7 design review pending human-lead sign-off +last_cr: none +--- + +# Architecture Spike Report — ATB Stages 6–7 + +| Field | Value | +|---|---| +| **Scope** | Current 26 authored use cases / 54 child FRs | +| **Architecture source** | `tech-profile.yaml` | +| **Risk register** | `00_process_control/architecture_risk_register.md` v2.0.0 | +| **Stage 5 gate** | Passed with 0 Critical; 2 documented Major source-parser warnings on FR-AUTH-001/003 (`new — not in BRD`) | +| **Stage 6** | Scored all 26 UCs; 16 meet the high/critical dimension rule | +| **Stage 7 status** | Design-level walking-skeleton analysis drafted; human lead sign-off and runtime proof pending | + +## 1. Spike Selection + +The deep walkthrough uses the highest-risk representative cross-section: UC-001 (OIDC/auth), UC-019 (membership/context), UC-017/020 (isolation/audit/support), UC-005 (GRN), UC-006 (QC FSM), UC-007 (double-entry stock), UC-011 (financial reversal/credit), and UC-014 (operational alerts). Related architecturally significant use cases map to the same component patterns: UC-003/015 to reporting/events, UC-004/008/009/012 to financial controls, UC-018 to the tenant control plane, and UC-023/024 to privacy lifecycle controls. No non-significant use case is used to justify a separate Stage 7 architecture pattern. + +## 2. Candidate Service Template + +```text +app/ + api/v1/ # thin FastAPI routes, auth/context dependencies + modules// + domain/ # entities, transitions, policies (no HTTP/DB framework) + application/ # commands, queries, transaction boundaries + infrastructure/ # SQLAlchemy repositories, outbox, adapters + platform/ + identity/ # OIDC validation, membership/context resolver + tenancy/ # transaction-local context + RLS helpers + audit/ # append-only governed-mutation interface + events/ # outbox publisher, idempotent consumers + integrations/ + identity/ notification/ # configured real adapters + deterministic sandbox ports + worker/ # outbox consumers use the same tenant context controls +db/migrations/ # Alembic, RLS policies, indexes, constraints +tests/ + unit/ integration/ api/ browser/ smoke/ +``` + +Domain modules depend on application ports; HTTP, SQLAlchemy, Keycloak and Valkey stay at adapters. Every write uses a transaction-scoped tenant context, authorization decision, idempotency key, audit write, and (when publishing) outbox row. Full repository structure is a candidate for lead review, not a claim that files/code already exist. + +## 3. End-to-End Walking-Skeleton Scenarios + +### Scenario A — Tenant-scoped receipt through QC and stock + +1. User signs in through Keycloak OIDC/PKCE; invalid identity/session fails closed. +2. API resolves the selected tenant against active membership and role; a forged or inactive membership is denied. +3. Yard Supervisor submits weighment and GRN command with idempotency key. One PostgreSQL transaction sets verified tenant context, applies RLS, validates measurements, persists GRN/lot, posts balanced stock entries and audit, then inserts outbox event. +4. Quality Officer records inspection. A source-threshold breach transitions lot to `QC Hold`; an allocation/dispatch attempt is rejected in domain service and database transaction. +5. Outbox worker publishes the committed event; alert consumer records one tenant-scoped alert. Retry after Valkey/messaging interruption is idempotent. +6. A second tenant cannot read the GRN, lot, ledger, uploaded evidence or alert by API, direct repository query, export or background job. + +### Scenario B — Bounced payment preserves financial history + +1. Authorized Accounts Executive records a customer receipt under verified tenant context. +2. A later `Bounced` transition atomically appends reversal entries, recomputes exposure, restores a required credit lock, writes audit and outbox event. +3. A repeated bounce command does not add a second reversal. Concurrent sales confirmation cannot pass on stale exposure. Partner override requires a separate authorized, justified, audited command. + +## 4. Design Validation Matrix + +| Risk / invariant | Candidate control | Walkthrough result | Evidence still required | +|---|---|---|---| +| Forged tenant selector / stale membership | Server-side UC-019 resolver before tenant data access | Consistent: denial occurs before DB context is established | Implemented Keycloak adapter, membership tests | +| Pooled connection tenant leakage | Transaction-local context; RLS USING + WITH CHECK; no BYPASSRLS role | Consistent if all tenant queries share the transaction wrapper; bypass remains a critical implementation hazard | PostgreSQL integration tests across reused connections and direct SQL paths | +| Partial GRN/lot/ledger writes | Single ACID transaction + idempotency + constraints | Consistent: rollback leaves no partial posting | Migration execution, fault injection, retry tests | +| QC Hold bypass / concurrent allocation | Domain transition and allocation lock/check in transaction | Consistent: service/API and browser cannot override state | Concurrency/invariant tests against PostgreSQL | +| Duplicate/lost events | Transactional outbox, idempotent consumer; Valkey is not source of truth | Consistent under stream outage; delivery delay is visible | Worker restart, duplicate delivery and outage test | +| Financial bounce reversal | Append-only compensating entries; serialize exposure update | Consistent with immutable financial history and lock recomputation | Race tests, precision tests, reconciliation evidence | +| Data disclosure in export/cache/file | Tenant ownership on object references and job payload; resolver used in worker | Pattern is consistent but storage provider/ACL semantics unresolved | Cross-tenant security tests for each storage surface | +| Provider outage | Identity fails closed; committed business events remain in outbox | Consistent; no login during identity outage; no event loss | Offline deterministic sandbox and failure-injection execution | + +**Design walkthrough result:** no internal contradiction was found in the proposed trust/transaction sequence. The walkthrough is not runtime validation. There is no product app, database migration, deployment target, or spike test harness in this repository; no runtime or load tests were run. Stage 7 must not be described as runtime-validated. + +## 5. Invalidated Assumptions and Open Decisions + +CR-001 removed sample-only RS256, 15-minute token lifetime, Valkey blacklist, 500 ms revocation target, and cross-tenant super-admin scope; none is restored by this architecture spike. Candidate choices now awaiting lead decision are: + +1. Whether to adopt transaction-local PostgreSQL tenant context + RLS wrapper exactly as LLD-002 proposes, including application role privileges and support access separation. +2. Whether to adopt a DB transactional outbox with Valkey Streams as delivery transport and idempotent workers. +3. How the production identity/session/logout contract should translate to Keycloak operations without adding unapproved token timing requirements. +4. Which provider-neutral deployment controls satisfy NFR availability/recovery and where private user-uploaded documents reside. +5. Confirmation that Stage 7 design-only evidence is sufficient to proceed to Stage 8, with runtime proof deferred to implementation, or whether a runnable prototype is required first. + +These are recorded as AMB-009 for human-lead review. No new decision is recorded as accepted in the decision log. + +## 6. Recommendation and Sign-Off + +**Recommendation:** approve the modular-monolith boundaries, verified-membership-before-RLS flow, transaction-local tenant context, append-only financial/audit history, and durable-outbox pattern as candidate reference patterns, subject to security and deployment decisions above. Continue design for all requirements only after lead sign-off. Keep high-assurance runtime and load validation as explicit construction/production evidence gates. + +- Human lead: ____________________ +- Disposition: Approve / Approve with changes / Defer +- Date and notes: ____________________ diff --git a/04_generated_documentation/04_architecture_design/deployment_spike.md b/04_generated_documentation/04_architecture_design/deployment_spike.md new file mode 100644 index 0000000..251151c --- /dev/null +++ b/04_generated_documentation/04_architecture_design/deployment_spike.md @@ -0,0 +1,46 @@ +--- +id: DEPLOYMENT-SPIKE +version: 1.0.0 +status: Draft — provider-neutral; human-lead review pending +last_cr: none +--- + +# Deployment View — Stage 7 Architecture Spike + +## 1. Logical Topology + +```mermaid +flowchart LR + User[Browser] --> CDN[Static React delivery] + CDN --> Edge[TLS ingress / rate limiting] + Edge --> API1[FastAPI API instance] + Edge --> API2[FastAPI API instance] + API1 --> PG[(PostgreSQL primary + HA recovery target)] + API2 --> PG + API1 --> Valkey[(Valkey HA cache / Streams)] + Worker[FastAPI worker process] --> PG + Worker --> Valkey + API1 --> IdP[Keycloak OIDC] + API2 --> IdP + Worker --> Msg[Messaging adapter / deterministic sandbox] + API1 --> Obj[Private object storage] + Ops[Metrics, traces, redacted logs] --- API1 + Ops --- API2 + Ops --- Worker + Backup[Encrypted backup / PITR] --> PG +``` + +This is a logical candidate, not a provider selection or deployment manifest. Runtime target (cloud, region, managed/self-hosted services, ingress, secrets manager, object store and failover automation) is unselected. + +## 2. Deployment Responsibilities + +- React static assets are served through TLS-protected edge delivery. The browser obtains identity through Keycloak OIDC/PKCE and sends bearer tokens to the API. +- API replicas are stateless. Request tenant context is never stored in process-global state; PostgreSQL context is transaction-local. +- PostgreSQL stores business records, append-only audit, idempotency records, and outbox. Backup/PITR and restore exercises must prove NFR-011 (RPO ≤15 minutes, RTO ≤4 hours, encrypted daily backups retained 35 days, quarterly restore exercise). +- A worker consumes durable outbox work; Valkey speeds delivery but is not the only copy of work. The worker uses the same code and tenant security middleware as the API. +- Keycloak, object storage and notification providers are external trust boundaries. `sandbox/identity_mock.py`, `sandbox/notification_mock.py` and other configured mocks support reproducible offline tests. +- Secrets are injected from an environment-specific secret store, not committed. Logs/telemetry exclude secrets and unnecessary personal or trading data; tenant/correlation labels are included only where authorized. + +## 3. Deployment Proof Required Before Baseline + +Demonstrate API/worker horizontal scaling without tenant context leakage; PostgreSQL failover and restore against NFR-011; stream unavailability with durable retry; private-file authorization and erasure behavior; and capacity at the NFR-012 envelope. These checks are pending; no cloud, cluster, instance, pool, or replica sizing is claimed as validated. diff --git a/04_generated_documentation/04_architecture_design/hld.md b/04_generated_documentation/04_architecture_design/hld.md index 844ff24..b3cc216 100644 --- a/04_generated_documentation/04_architecture_design/hld.md +++ b/04_generated_documentation/04_architecture_design/hld.md @@ -1,41 +1,72 @@ -# High-Level Architecture Design (HLD) — Universal Enterprise Platform +--- +id: HLD-ATB +version: 2.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: CR-001 +--- + +# High-Level Architecture Design — Agriculture Trading Backoffice | Field | Value | |---|---| -| **Document** | `hld.md` | -| **System** | Universal Enterprise Platform (UEP) | -| **Pattern** | Modular Monolith with Multi-Tenant Row-Level Security | -| **Version** | 1.1.0 | -| **Last CR** | `CR-001` | -| **Status** | Rebaselined; pending authentication design decisions | +| **System** | Agriculture Trading Backoffice (ATB) | +| **Pattern** | FastAPI modular monolith, tenant isolation through PostgreSQL RLS | +| **Technology authority** | `tech-profile.yaml` | +| **Architecture status** | Candidate walking-skeleton design; not production-baselined | +| **Stage 7 focus** | UC-001, UC-005, UC-006, UC-007, UC-011, UC-014, UC-017, UC-019, UC-020 | ---- - -## 1. System Architecture Topology +## 1. Logical Architecture ```mermaid graph TD - ClientWeb["Web Portals (React + Vite + Tailwind)"] --> NGINX["API Gateway / Reverse Proxy (NGINX)"] - ClientMobile["Mobile Apps / External Consumers"] --> NGINX - - NGINX --> AuthFilter["Auth & Tenant Context Middleware"] - AuthFilter --> Keycloak["Identity Provider (Keycloak OIDC)"] - - subgraph Modular Monolith Core - AuthFilter --> ModAuth["IAM / Auth Module (LLD-001)"] - AuthFilter --> ModDomain["Core Business Modules"] - AuthFilter --> ModIntegration["Integration & Sandboxes"] - end - - ModAuth --> PG[("PostgreSQL DB (with RLS)")] - ModDomain --> PG - ModAuth --> Valkey[("Valkey / Redis (Platform Cache; Auth Use TBD)")] + Browser[React + TypeScript SPA] -->|OIDC PKCE / HTTPS| IdP[Keycloak] + Browser -->|JWT bearer / HTTPS| Edge[Ingress / TLS] + Edge --> API[FastAPI modular monolith] + API --> IAM[Identity validation + role policy] + API --> Tenant[Membership/context resolver] + API --> Domain[Receiving / Quality / Inventory / Finance] + API --> PG[(PostgreSQL + RLS + audit + outbox)] + Worker[Background worker] --> PG + Worker --> Stream[Valkey Streams / cache] + Worker --> Notify[Messaging adapter] + API --> ObjectStore[Private document storage] + Ops[Telemetry / alerting] <-- API + Ops <-- Worker ``` ---- +The API and worker are separately scaled processes from one modular-monolith codebase. PostgreSQL is the source of truth for business state, audit records, and pending events. Valkey is an acceleration/delivery component only; loss of Valkey must not lose committed business transactions. Object storage is a candidate dependency for POD and other uploaded documents; provider and retention controls require review because the technology profile does not select a storage provider. -## 2. Core Architectural Pillars +## 2. Module Boundaries -1. **Tenant Context and Isolation:** Tenant membership and active context are verified under `UC-019`; resource isolation and RLS are governed by `UC-017` / `UC-020`. Middleware must consume the verified context and apply the approved isolation design. This HLD does not define a client/JWT-supplied tenant as trusted context. -2. **Deterministic Wave 0 Sandboxing:** All external third-party integrations (payment gateways, identity verification, SMS/email) implement an abstract adapter with a local deterministic mock under `app/integrations/sandbox/`. -3. **Pluggable Event Stream:** Inter-module communication executes via in-process domain event dispatchers that can scale out to message queues (RabbitMQ / Kafka) as needed. +| Module | Owning use cases in Stage 7 scope | Owns | Must not own | +|---|---|---|---| +| Identity & authorization | UC-001 | OIDC session establishment, authorization decision, logout contract | Membership lifecycle or trusted tenant selection | +| Tenant control plane | UC-018, UC-019 | Tenant lifecycle, memberships, verified active context | Tenant-owned business records | +| Tenant isolation & audit | UC-017, UC-020 | RLS enforcement, cross-resource isolation, governed mutation history, support access | Ordinary feature authorization policy | +| Receiving | UC-005 | Gate/weighment records, GRN posting, inward lot identity | QC release decision or stock read model | +| Quality | UC-006 | Inspection evidence, QC state transitions, lot lineage | Client-side-only state enforcement | +| Inventory | UC-007 | Append-only stock movements, position projection, reconciliation | Direct mutation of posted ledger history | +| Finance | UC-011 (with UC-004/008/009/012 at Stage 9) | Receivables, credit lock, receipt and reversal | External payment execution; none is specified in the BRD | +| Operational events | UC-014 (with UC-003/015 at Stage 9) | Reliable event delivery, alert evaluation, reporting projections | Source-of-truth business state | + +## 3. Trust and Transaction Boundaries + +1. Keycloak authenticates the user through configured OIDC/PKCE. The API validates the configured JWT bearer token; algorithm, lifetime and logout revocation semantics remain explicit security-design decisions. +2. The application resolves the active tenant through server-side membership and role checks (UC-019). A client-supplied tenant identifier or token claim alone is never trusted as authorization. +3. Each tenant database unit of work begins a transaction, sets transaction-local tenant context from the verified resolver, then performs queries under PostgreSQL RLS. Missing context fails closed. No request-scoped context may leak through a pooled connection. +4. A GRN, lot, stock movements, audit record and outbox event commit atomically. A QC Hold lot cannot be allocated or dispatched, even if a client bypasses the UI. +5. Financial correction uses compensating ledger entries and immutable history; it does not rewrite a posted receipt. Event consumers are idempotent. + +These are candidate architecture patterns for lead review, not newly approved product requirements. + +## 4. Operational Constraints to Prove + +- 50 tenant firms, up to 25 named users per tenant, and 250 concurrent active users; run the accepted 5× peak-hour load scenario (BRD-NFR-012 / AMB-008). +- Tenant reports across at least 50,000 ledger rows meet the 1-second report target (BRD-NFR-004). +- Core financial conversions preserve 3-decimal weight and 2-decimal currency precision (BRD-NFR-001). +- Tenant isolation fails closed for API, DB, exports, files, cache, jobs, and support paths (BRD-NFR-006/010). +- Availability/recovery evidence must meet BRD-NFR-011. No provider or instance size is selected in this spike. + +## 5. Design Status + +This HLD is a Stage 7 candidate. The design walkthrough is recorded in `architecture_spike_report.md`; runtime integration, RLS, failure-injection, and load validation have not run because the repository has no product application implementation or deployment environment yet. Do not mark it Validated or Baseline until the human lead accepts the decisions and required evidence is produced. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-001_auth_service.md b/04_generated_documentation/04_architecture_design/lld/LLD-001_auth_service.md index 370bc5f..677b16c 100644 --- a/04_generated_documentation/04_architecture_design/lld/LLD-001_auth_service.md +++ b/04_generated_documentation/04_architecture_design/lld/LLD-001_auth_service.md @@ -1,43 +1,59 @@ -# LLD-001: IAM & Authentication Service +--- +id: LLD-001 +version: 2.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: CR-001 +--- + +# LLD-001 — Identity, OIDC Authentication & Authorization | Field | Value | |---|---| -| **Document** | `LLD-001_auth_service.md` | -| **Component** | `HLD-AUTH` (Identity & Access Management) | -| **Parent Use Case** | [`UC-001`](../../03_requirements/use_cases/uc-001_user-authentication/use-case.md) | -| **Parent FRs** | `FR-AUTH-001`, `FR-AUTH-002`, `FR-AUTH-003` | -| **Status** | Rebaselined; pending authentication/session design decisions | -| **Version** | 1.1.0 | -| **Last CR** | `CR-001` | +| **Component** | Identity & Access Management | +| **Parent UCs** | UC-001; tenant context delegated to UC-019 (LLD-002) | +| **Parent FRs** | FR-AUTH-001, FR-AUTH-002, FR-AUTH-003 | +| **Status** | Candidate; human-lead review pending | ---- +## 1. Boundary and Candidate API Shape -## 1. Component Boundaries & Endpoints +The module establishes authenticated application sessions and evaluates the BRD-FR-040 role permission matrix. Tenant membership/active-tenant resolution is performed by LLD-002. This module does not own RLS schema policies, tenant provisioning, cross-tenant support access, or a super-admin bypass. -### 1.1 API Router Endpoints (`/api/v1/auth`) +| Method | Candidate route | Purpose | Contract status | +|---|---|---|---| +| POST | `/api/v1/auth/token` | Complete configured OIDC authorization-code/PKCE callback | Candidate; confirm at Stage 8/9 | +| POST | `/api/v1/auth/logout` | End the active application session | Candidate; endpoint and Keycloak operation need security review | +| GET | `/api/v1/auth/me` | Return authenticated subject and current role/context summary | Candidate; tenant fields only from verified LLD-002 context | -| Method | Endpoint | Description | Auth Required | Request Body | Response Codes | -|---|---|---|---|---|---| -| `POST` | `/api/v1/auth/token` | Exchange authorization code & PKCE verifier for JWT tokens | No | `TokenExchangeRequest` | 200 OK, 400 Bad Request | -| `POST` | `/api/v1/auth/refresh` | Obtain fresh access token using valid refresh token | No | `RefreshTokenRequest` | 200 OK, 401 Unauthorized | -| `POST` | `/api/v1/auth/logout` | End the active application session; revocation mechanism and timing require approved security design | Yes | `LogoutRequest` | 200 OK, 401 Unauthorized | -| `GET` | `/api/v1/auth/me` | Return active user claims, roles, and tenant context | Yes | — | 200 OK, 401 Unauthorized | +Refresh endpoint, token lifetime, signing algorithm, refresh-token storage, revocation latency, and provider-session behavior are not fixed by UC-001 or `tech-profile.yaml`; do not treat earlier sample values as requirements. ---- +## 2. Authentication Request Flow -## 2. Tenant Context and Data Isolation Boundary +1. React client starts Keycloak OIDC Authorization Code + PKCE. +2. Callback handler exchanges the authorization response using the configured client; the server validates issuer, audience, expiry, signature/JWKS and nonce/state according to approved security settings. +3. Establish an application session using the configured JWT bearer-token approach. Reject malformed, invalid, expired or unauthenticated sessions. +4. For a tenant operation, call the membership/context resolver described in LLD-002 and apply the role/action policy. No client-supplied role or tenant identifier grants access. +5. Logout ends the application session and subsequent protected operations using that session are denied; exact IdP revocation mechanics and timing are open design decisions. -Tenant membership and active-tenant context must be verified by `UC-019` before tenant-scoped work. Tenant data isolation and RLS are owned by `UC-017` / `UC-020`; this authentication component must not treat an unverified tenant claim as authorization. Schema and RLS policy details belong in the accountable tenant/data LLD and must be validated against those requirements. +## 3. Authorization Decision -## 3. Authentication Token and Session Validation +Input is authenticated subject, verified tenant context (when the resource is tenant-scoped), resource/action, and the approved role permission matrix. Enforce `Read`, `Write`, `Create`, `Delete`, `Submit`, `Cancel`, and `Amend` permissions plus the stated segregation-of-duties restrictions. Deny before the business command executes. Cache policy decisions only if freshness/invalidation preserves role-change revocation; this spike does not select a cache strategy. -Validate identity-provider responses and authenticated application sessions according to the approved identity-provider and application-session design. Signing algorithm, token lifetime, refresh behavior, revocation mechanism, and revocation timing remain design decisions; this LLD does not baseline them. +## 4. Integration and Failure Contract ---- +- Keycloak/JWKS calls use the configured identity-provider adapter; local tests use `sandbox/identity_mock.py` and require no network. +- Invalid identity response, provider outage during sign-in, unresolved key material, or absent active session fails closed. +- Avoid logging bearer tokens, secrets, or unnecessary identity data. Use correlation IDs and the minimum subject/tenant context needed for authorized observability. +- Errors from authentication, membership resolution, and business authorization remain distinct internally but reveal no cross-tenant resource existence. -## 4. Middleware & Security Context Propagation +## 5. Validation Cases -The FastAPI dependency `get_current_user` extracts the JWT Bearer token: -1. Validates signature with Keycloak JWKS public keys. -2. Validates the authenticated session according to the approved identity-provider and application-session design. This LLD does not prescribe a token blacklist, cache, signing algorithm, token lifetime, or revocation latency. -3. Obtains tenant membership and active context only through the verified `UC-019` flow; applies tenant resource isolation according to `UC-017` / `UC-020`. +| Case | Expected result | +|---|---| +| Valid OIDC/PKCE callback | Authenticated application session created | +| Invalid signature/issuer/audience/expiry or replayed state | No session; protected action denied | +| Keycloak unavailable at sign-in | Fail closed; deterministic mock supports offline tests | +| Role lacks action permission / violates SoD | Business command is not invoked | +| Logout then reuse ended session | Protected action denied; no specific revocation latency asserted | +| Tenant selector forged or membership inactive | LLD-002 rejects before tenant-scoped data access | + +**Runtime validation:** pending implementation and approved security settings. This document is a Stage 7 candidate, not proof of an executed walking skeleton. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md b/04_generated_documentation/04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md new file mode 100644 index 0000000..d181a32 --- /dev/null +++ b/04_generated_documentation/04_architecture_design/lld/LLD-002_tenant_context_and_isolation.md @@ -0,0 +1,57 @@ +--- +id: LLD-002 +version: 1.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: none +--- + +# LLD-002 — Identity, Tenant Context, Isolation & Audit + +| Field | Value | +|---|---| +| **Parent UCs** | UC-001, UC-017, UC-018, UC-019, UC-020 | +| **Parent FRs** | FR-AUTH-001, FR-AUTH-002, FR-AUTH-003; FR-TENANTSECURITYAUDIT-001, FR-TENANTSECURITYAUDIT-003; FR-TENANTLIFECYCLE-001; FR-TENANTMEMBERSHIPCONTEXT-001, FR-TENANTMEMBERSHIPCONTEXT-002; FR-TENANTSUPPORTSECURITY-001, FR-TENANTSUPPORTSECURITY-002 | +| **Status** | Candidate; design review pending | + +## 1. Request Authentication and Context Resolution + +1. Browser initiates Keycloak OIDC Authorization Code + PKCE using the configured client. +2. API validates bearer token issuer, audience, expiry, signature against the configured provider metadata/JWKS, and application session state. Concrete algorithm/lifetime/revocation behavior needs security design sign-off. +3. `TenantContextResolver` receives the user subject and requested active-tenant selector. It loads an active membership and role from server-side records. A role or tenant claim supplied by the client is not sufficient. +4. Authorization evaluates the action/resource against the BRD-FR-040 permission matrix. The resolver returns an immutable request context `(subject_id, tenant_id, role_ids, correlation_id)` for that request. +5. No active membership or suspended tenant returns a deny result; no fallback to a platform-wide tenant context. + +## 2. PostgreSQL RLS Contract (Candidate) + +- Every tenant-owned table has a non-null `tenant_id` and tenant-leading lookup/index keys where appropriate. +- Set context only inside an open transaction, using a parameterized call equivalent to `set_config('app.tenant_id', :tenant_id, true)`. The final `true` makes the setting transaction-local and protects pooled connections. +- RLS policies use both `USING` and `WITH CHECK`; an absent setting yields no visible rows and rejects writes. Consider `FORCE ROW LEVEL SECURITY`; the application role must not be superuser or have `BYPASSRLS`. +- Tenant-specific DB work must use the same transaction/context wrapper. Background work obtains tenant id from a validated persisted job/outbox row and sets context for its own transaction. Missing or malformed tenant context is a hard failure. +- Support access is a separate, explicit, time-bounded authorization path under UC-020 with reason and audit evidence; it does not weaken ordinary tenant policies. + +```text +verified identity + -> active membership lookup (UC-019) + -> action permission decision (UC-001 / BRD-FR-040) + -> begin DB transaction + -> SET LOCAL app.tenant_id = verified membership tenant + -> RLS-protected query/write + -> commit or rollback +``` + +## 3. Audit Contract + +For a governed business mutation, append an audit entry in the same transaction containing tenant id, actor subject, action, entity type/id, timestamp, and correlation id. Minimize personal/business payloads. The application DB role cannot update/delete audit rows; retention/legal-hold treatment is governed by the approved data-governance design. Do not introduce a cross-tenant audit query path except a specifically authorized platform security workflow. + +## 4. Validation Cases + +| Case | Expected result | +|---|---| +| Valid identity and active membership | Scoped operation proceeds under verified tenant context | +| Missing membership, suspended tenant, or forged selector | Denied before business query/write | +| No tenant context on direct tenant-owned table access | No rows visible; writes rejected | +| Reuse pooled connection after tenant A request for tenant B | Tenant A context is absent; B sees only B rows | +| Background export/job omits tenant binding | Job fails closed; no data emitted | +| Ordinary support identity requests tenant data without approved grant | Denied and audited | + +**Runtime validation:** pending implementation and isolated PostgreSQL environment; this contract is not yet proven by execution. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-003_receiving_quality_inventory.md b/04_generated_documentation/04_architecture_design/lld/LLD-003_receiving_quality_inventory.md new file mode 100644 index 0000000..4b00d18 --- /dev/null +++ b/04_generated_documentation/04_architecture_design/lld/LLD-003_receiving_quality_inventory.md @@ -0,0 +1,48 @@ +--- +id: LLD-003 +version: 1.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: none +--- + +# LLD-003 — Receiving, Quality FSM & Stock Ledger + +| Field | Value | +|---|---| +| **Parent UCs** | UC-005, UC-006, UC-007 | +| **Parent FRs** | FR-INWARDRECEIVING-001, FR-INWARDRECEIVING-002, FR-INWARDRECEIVING-003, FR-INWARDRECEIVING-004, FR-INWARDRECEIVING-005, FR-INWARDRECEIVING-006; FR-QUALITYANDLOTCONTROL-001, FR-QUALITYANDLOTCONTROL-002, FR-QUALITYANDLOTCONTROL-003, FR-QUALITYANDLOTCONTROL-004; FR-WAREHOUSEINVENTORY-001, FR-WAREHOUSEINVENTORY-002, FR-WAREHOUSEINVENTORY-003 | +| **Status** | Candidate; design review pending | + +## 1. Component Contracts + +- `ReceivingService`: records vehicle/gate details and gross/tare measurements, validates tare < gross, applies approved packaging tare inputs, computes net received quantity, and posts a GRN. +- `LotService`: creates the immutable lot identity with the GRN; captures inspection measures; enforces the BRD-defined `Under QC` → `QC Hold` / `Released` transition and lot split/blend lineage. +- `InventoryLedger`: records append-only, balanced movement entries for GRN receipt, dispatch, and inter-godown transfer. Position views are derived from entries, not independently editable balances. +- No physical weighbridge protocol/API is included: the current FRs specify recording weighment measurements, not device integration. Add a device adapter only after an approved requirement/design decision. + +## 2. Posting Boundary + +A GRN posting command has a tenant-scoped idempotency key and executes in one PostgreSQL transaction: + +1. Revalidate authorization and tenant context; acquire the relevant sauda/receipt serialization lock. +2. Validate measurement and quantity invariants without floating-point arithmetic; apply NFR-001 precision rules. +3. Persist GRN and uniquely identified lot; start its QC lifecycle as specified by the current process model. +4. Append stock receipt journal entries and mutation-audit record. +5. Insert an outbox event keyed by tenant and aggregate version. +6. Commit once. Any failure before commit rolls back all six writes; retry with the same command key returns the original posting result without duplicate stock. + +A lot in `QC Hold` is rejected by server-side allocation and dispatch services. State checks and the corresponding stock reservation/movement must share a transaction/locking strategy so concurrent commands cannot bypass the hold or overdraw the available balance. + +## 3. Transfer and Reconciliation + +A godown transfer is modeled as one transfer aggregate with origin deduction, in-transit identity, destination confirmation, and paired inventory entries. Partial completion must remain represented as in transit; retries are idempotent. Physical stock adjustment creates a separately authorized, reason-coded journal entry and audit item; it never edits historical movements. + +## 4. Validation Walkthrough + +- Valid weighment posts one GRN, one lot, balanced stock movements, audit and outbox atomically. +- `tare >= gross`, invalid quantity, wrong tenant, or duplicate identity produces no partial posting. +- Concurrent duplicate command creates only one GRN/stock effect. +- QC Hold lot is denied allocation and dispatch through API paths. +- Outbox worker outage leaves committed source event pending for retry; repeated delivery has one logical effect. + +**Runtime validation:** pending; scenario results in the spike report are design reasoning, not executed test results. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-004_financial_controls.md b/04_generated_documentation/04_architecture_design/lld/LLD-004_financial_controls.md new file mode 100644 index 0000000..fcf09aa --- /dev/null +++ b/04_generated_documentation/04_architecture_design/lld/LLD-004_financial_controls.md @@ -0,0 +1,39 @@ +--- +id: LLD-004 +version: 1.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: none +--- + +# LLD-004 — Receivables, Credit Locks & Financial Posting + +| Field | Value | +|---|---| +| **Parent UCs** | UC-004, UC-008, UC-009, UC-011, UC-012 | +| **Parent FRs** | FR-PROCUREMENTCONTRACTS-001, FR-PROCUREMENTCONTRACTS-002, FR-PROCUREMENTCONTRACTS-003, FR-PROCUREMENTCONTRACTS-004; FR-SALESCONTRACTS-001, FR-SALESCONTRACTS-002, FR-SALESCONTRACTS-003; FR-DISPATCHDELIVERY-001, FR-DISPATCHDELIVERY-002, FR-DISPATCHDELIVERY-003; FR-CUSTOMERRECEIVABLES-001, FR-CUSTOMERRECEIVABLES-002, FR-CUSTOMERRECEIVABLES-003, FR-CUSTOMERRECEIVABLES-004; FR-SUPPLIERPAYABLES-001 | +| **Status** | Candidate; design review pending | + +## 1. Financial Consistency Rules + +- Use PostgreSQL transactions for each contract/receipt/ledger state change; preserve NFR-001 decimal precision (weight 3 decimals, currency 2 decimals). +- Posted ledger entries are append-only. Correct an error through a reversing/compensating entry with actor, reason, source entry and audit linkage. +- Sales credit exposure check and confirmation must serialize on the customer account/credit projection so concurrent orders cannot both pass a stale limit check. Reserve exposure consistently with order state. +- A customer receipt records its BRD status (`Pending Clearance`, `Cleared`, `Bounced`). A bounce creates a reversal entry, recomputes exposure, reinstates a >100% credit lock and emits an alert in the same database transaction. It does not erase the original receipt history. +- A Partner override is an explicit authorized command with mandatory justification and an immutable audit event; it does not mutate the historical lock decision. +- No external payment execution API is assumed; the BRD currently records received instruments and statuses. + +## 2. Candidate Data/Command Shape + +`PartyLedgerEntry(tenant_id, party_id, source_type, source_id, entry_type, debit, credit, currency, effective_at, reversal_of, idempotency_key)`; account/tenant uniqueness is enforced in the database. `CreditControl` stores the sanctioned limit and lock state/version. Derived outstanding/exposure values must be reconciled to the immutable journal and not maintained as an independent source of truth. + +Commands: `ConfirmSalesOrder`, `RecordReceipt`, `MarkReceiptBounced`, `OverrideCreditLock`. Each command carries tenant context from LLD-002, actor, correlation id and idempotency key. Endpoint shape and source documents are to be derived at Stage 8/9. + +## 3. Validation Cases + +- Two concurrent orders near limit cannot exceed available approved exposure without the specified override. +- Replaying a receipt/bounce command creates no duplicate ledger entry. +- Bounce reverses the credit posting, restores receivable exposure, reinstates the lock where the source threshold requires it, and emits one alert. +- Unauthorized override is denied and leaves ledger/lock state unchanged. +- Every financial write is tenant-isolated and has an attributable audit record. + +**Runtime validation:** pending implementation, schema, and load/concurrency evidence. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-005_reporting_and_events.md b/04_generated_documentation/04_architecture_design/lld/LLD-005_reporting_and_events.md new file mode 100644 index 0000000..50c2bf5 --- /dev/null +++ b/04_generated_documentation/04_architecture_design/lld/LLD-005_reporting_and_events.md @@ -0,0 +1,36 @@ +--- +id: LLD-005 +version: 1.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: none +--- + +# LLD-005 — Operational Events, Alerts & Reporting + +| Field | Value | +|---|---| +| **Parent UCs** | UC-003, UC-014, UC-015; consumes events from UC-005–012 | +| **Parent FRs** | FR-MARKETTRENDANALYTICS-001; FR-OPERATIONALALERTS-001; FR-EXECUTIVEREPORTING-001, FR-EXECUTIVEREPORTING-002 | +| **Status** | Candidate; design review pending | + +## 1. Source-of-Truth and Event Delivery + +- Domain mutations write a versioned outbox row in the same transaction as the business state and audit record. The outbox is the durable source; Valkey Streams is a delivery/cache mechanism configured in `tech-profile.yaml`. +- A worker publishes eligible outbox records, records delivery attempts, and retries transient failures with bounded backoff. Consumers use `(tenant_id, event_id)` for idempotency and preserve tenant context for each read/write. +- If Valkey or the messaging adapter is unavailable, source transactions may commit; delivery is delayed and observable, not silently dropped. Dead-letter/manual replay policy and retention require lead review. +- Alert evaluation is based on source events plus periodic reconciliation so a missed event cannot permanently suppress an active alert. Only channels supported by approved messaging configuration are enabled. + +## 2. Read Models and Performance + +- UC-003/UC-015 queries remain tenant-scoped and read from indexed transactional data or a derived tenant-scoped summary. Any summary is rebuildable from source records and has a documented freshness indicator. +- Validate the 20-day trend and multi-godown reports at 50,000 ledger rows in under 1 second (BRD-NFR-004), and the 50-tenant/250-active-user 5× peak scenario (BRD-NFR-012). Do not assert that Valkey alone meets the report SLA. +- Keep reports read-only; never calculate a decision-critical credit or stock balance from a stale display projection. + +## 3. Validation Cases + +- Database commit succeeds while stream is unavailable: event remains pending and later publishes once logically. +- Duplicate/out-of-order event does not duplicate or regress alert state. +- Tenant-A event cannot populate or be queried from tenant-B projection. +- Rebuilt report summary matches the source ledger within defined freshness and exact financial/quantity precision. + +**Runtime validation:** pending offline sandbox, load profile, and implementation. diff --git a/04_generated_documentation/04_architecture_design/lld/LLD-006_privacy_lifecycle.md b/04_generated_documentation/04_architecture_design/lld/LLD-006_privacy_lifecycle.md new file mode 100644 index 0000000..c2399f7 --- /dev/null +++ b/04_generated_documentation/04_architecture_design/lld/LLD-006_privacy_lifecycle.md @@ -0,0 +1,31 @@ +--- +id: LLD-006 +version: 1.0.0 +status: Draft — Stage 7 spike; human-lead review pending +last_cr: none +--- + +# LLD-006 — Privacy Incident and Data Lifecycle Boundaries + +| Field | Value | +|---|---| +| **Parent UCs** | UC-023, UC-024 (interfaces to UC-021/022/025) | +| **Parent FRs** | FR-PRIVACYBREACHRESPONSE-001; FR-RETENTIONERASURE-001 | +| **Status** | Candidate; legal/security review pending | + +## 1. Privacy-Safe Architecture Boundaries + +- Every data object carries tenant ownership and purpose/sensitivity metadata as applicable; purpose tags and four internal sensitivity labels are not treated as statutory classifications. +- Breach cases link affected tenant/data categories and evidence references, not bulk sensitive payloads. Access to incident evidence is role-restricted, audited, and tenant-scoped. +- Erasure is a governed workflow: determine subject/data scope, check approved purpose schedule and legal holds, apply deletions/anonymization where legally permitted, and record evidence without retaining the erased payload in the audit log. +- Backups, processor copies, exports, caches and derived reports need explicit retention/erasure treatment. A deletion from the primary table alone is not completion. +- Exact retention durations, statutory exception mapping, and evidence retention remain blocked by AMB-006; this LLD invents none. + +## 2. Validation Cases + +- Tenant operator cannot resolve another tenant's subject or breach case. +- Active legal hold blocks the affected erasure action while unrelated data rights cases continue. +- Completed erasure removes or de-identifies in-scope live/search/cache/derived data and creates non-sensitive evidence; backup expiry/restore behavior follows the approved schedule. +- Incident evidence access creates a separate audit entry and excludes secrets from service telemetry. + +**Runtime/legal validation:** pending qualified legal review, approved schedules and implementation. diff --git a/prompts/20261011T074829Z-session-greenfield-bootstrap.md b/prompts/20261011T074829Z-session-greenfield-bootstrap.md index c58a175..b27e3f0 100644 --- a/prompts/20261011T074829Z-session-greenfield-bootstrap.md +++ b/prompts/20261011T074829Z-session-greenfield-bootstrap.md @@ -343,3 +343,19 @@ Confirmed all downstream HLD/LLD, iteration-01, wireframe, test, and QA paths ar ## 2026-10-11T10:47:38Z — Assistant — Verification and disposition Gate 5.1 passed with zero Critical findings and two justified Major source-parser warnings (`FR-AUTH-001`/`003`, `new — not in BRD`). Gate 14.1 was run against iteration-01 and failed with two Critical findings: no dense Excel QA workbook and no Bruno API collections. The iteration matrix and traceability records state Incomplete / Pending Construction; no requirement is marked Delivered. `git diff --check` passed. No test suite was run. Closed CR-001 as verified requirements/design/test-specification alignment because its approved impacted artifact set is rebaselined and no affected FR is Delivered; Gate 14.1 remains a construction/iteration closure blocker. Updated CR register, traceability graph, CKPT-011/index, and this transcript. Next process action: Stage 6 architecture risk scoring/spike, then remaining Elaboration gates; iteration construction must not be treated as delivered. + +## 2026-10-11T10:50:17Z — User + +Asked: “as per the process what is the next step?” + +## 2026-10-11T10:50:17Z — Assistant — Action summary + +Verified CKPT-011 and the UP-AI v1.5 Skills Usage Guide. The next action is /up-arch-risk-spike for Stage 6–7; follow with Stage 8 SRS derivation, Stage 9 HLD/LLD fan-out, and Gate 9.1 before Construction. Updated master_context.md, which still reflected Stage 1, to match the current checkpoint and record that iteration-01 is pending construction with Gate 14.1 blockers (missing dense workbook and Bruno collections). No tests run. + +## 2026-10-11T10:56:49Z — User + +Invoked up-arch-risk-spike and supplied the canonical Stage 6–7 skill instructions. + +## 2026-10-11T10:56:49Z — Assistant — Action summary + +Verified CKPT-011, re-ran Gate 5.1 (zero Critical; two documented Major source-parser warnings), confirmed 26 UCs/54 FRs, and reviewed the active technology profile and all use cases. Replaced the incomplete risk register with scores/ranks/rationales for all 26 UCs; 16 score 4–5 on at least one dimension. Drafted a candidate ATB HLD, updated UC-001 identity LLD plus five focused LLDs, provider-neutral deployment view, and architecture spike report. The report walks through tenant-scoped GRN-to-QC-to-stock-to-alert and payment-bounce reversal plus failure cases. This is design-level consistency analysis only: no product app/runtime harness exists, so runtime and load validation were not claimed or run. Logged proposed patterns for human-lead decision as AMB-009 and saved CKPT-012. Next action: human review of the spike; if approved, proceed to Stage 8 SRS derivation. Risk-matrix validation passed (26 unique UCs, five scores, totals/ranks/significance consistent); `git diff --check` passed. No tests run.