Description
Some tenants require data to remain in a specific jurisdiction. Add a residency tag per tenant and a routing layer that selects the correct shard or read replica; cross-region writes must be rejected.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/db/, src/middleware/
- Residency mismatches must emit security audit events
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/data-residency-routing
- Implement changes
- Add
tenants.residency_region and shard map
- Middleware sets
AsyncLocalStorage region; pool selects accordingly
- Block cross-region writes with explicit error code
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Missing residency tag must fail closed
- Include test output and notes
Example commit message
feat: tenant data residency routing
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Some tenants require data to remain in a specific jurisdiction. Add a residency tag per tenant and a routing layer that selects the correct shard or read replica; cross-region writes must be rejected.
Requirements and context
src/db/,src/middleware/Suggested execution
git checkout -b feat/data-residency-routingtenants.residency_regionand shard mapAsyncLocalStorageregion; pool selects accordinglyTest and commit
npm testExample commit message
feat: tenant data residency routingGuidelines