Skip to content

Add tenant data-residency routing pinning records to a region-specific shard #424

Description

@thlpkee20-wq

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
    • npm test
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveStellar Wave issue batchbackendBackend scopedatabaseMigrations, queries, pooling, transactionssecuritySecurity hardening and threat mitigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions