docs(03-01): complete zone management plan

Tasks completed: 2/2
- Task 1: Zone schema, migration, and tenant scoping
- Task 2: Zone service, API routes, and integration tests

SUMMARY: .planning/phases/03-operational-modules/03-01-SUMMARY.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kevin-asprec
2026-03-05 07:32:21 +08:00
parent 214df6cd92
commit 2321bf2ada
2 changed files with 162 additions and 9 deletions

View File

@@ -9,12 +9,12 @@ See: .planning/PROJECT.md (updated 2026-03-04)
## Current Position
Phase: 2 of 5 (Subscriber and Billing Core) — COMPLETE
Plan: 5 of 5 in phase 2 (11/20 total complete)
Status: Phase 2 complete. 02-01 (COA), 02-02 (JournalEntryService), 02-03 (Subscriber), 02-04 (BillingEngine), 02-05 (PaymentService) all done.
Last activity: 2026-03-04 — Completed 02-05-PLAN.md (PaymentService, 29 tests, 265 total)
Phase: 3 of 5 (Operational Modules) — In progress
Plan: 1 of 5 in phase 3 (12/20 total complete)
Status: Phase 3 started. 03-01 (Zone Management) complete. Zones, ZoneAssignment, collector scoping all implemented.
Last activity: 2026-03-05 — Completed 03-01-PLAN.md (Zone management, 25 tests)
Progress: [███████████░] 55% (11/20 plans across all phases)
Progress: [███████████░] 60% (12/20 plans across all phases)
## Performance Metrics
@@ -31,8 +31,8 @@ Progress: [███████████░] 55% (11/20 plans across all pha
| 02-subscriber-and-billing-core | 5/5 complete | 57 min | 11.4 min |
**Recent Trend:**
- Last 9 plans: 01-02 (8 min), 01-03 (9 min), 01-04 (7 min), 01-05 (6 min), 02-01 (7 min), 02-03 (7 min), 02-02 (16 min), 02-04 (12 min), 02-05 (8 min)
- Trend: stable — 02-05 was complex but tests passed on second run
- Last 10 plans: 01-02 (8 min), 01-03 (9 min), 01-04 (7 min), 01-05 (6 min), 02-01 (7 min), 02-03 (7 min), 02-02 (16 min), 02-04 (12 min), 02-05 (8 min), 03-01 (15 min)
- Trend: stable — 03-01 had a migration workaround but tests passed on first run
*Updated after each plan completion*
@@ -95,6 +95,11 @@ Recent decisions affecting current work:
- [02-05]: Overpayment to subscriber.creditBalance atomically with JE — same pattern as invoice.amountPaid from 02-04
- [02-05]: Outstanding report computed in JS after fetching — Prisma doesn't support computed fields in WHERE/ORDER BY; acceptable for ISP scale
- [02-05]: Test invoiceCounter for periodStart uniqueness — monotonic counter generates unique periodStart per invoice, avoids @@unique([tenantId, subscriberId, periodStart]) in test helpers
- [03-01]: Collector security boundary enforced at service layer: getCollectorSubscribers THROWS (not empty return) when collector has no zone assignments — zero-access default
- [03-01]: ZoneAssignment upsert for idempotent collector assignment — duplicate assign calls don't throw errors
- [03-01]: Subscriber.zone String? replaced with Subscriber.zoneId FK — required for relational queries and JOIN-based ordering
- [03-01]: COLLECTOR gets can("read", "Zone") in CASL: coarse-grained gate, data layer enforces which specific zones
- [03-01]: Migration applied via Docker exec psql + prisma migrate resolve --applied (non-interactive CLI workaround)
### Pending Todos
@@ -112,6 +117,6 @@ None.
## Session Continuity
Last session: 2026-03-04T15:52:55Z
Stopped at: Completed 02-05-PLAN.md (PaymentService + 29 tests — Phase 2 complete)
Last session: 2026-03-05T07:31:00Z
Stopped at: Completed 03-01-PLAN.md (Zone management — 25 tests, Zone/ZoneAssignment models, collector scoping)
Resume file: None