Residency policy-packs
Honest scope: policy-packs are typed residency-rule presets plus lineage hooks. They are NOT certified compliance products — Yabanin is not "HIPAA compliant" or "ITAR certified" because a pack exists, and marketing must never claim so. Certification, where needed, is a separate audit process.
Yabanin enforces region-pin per request for regulated jurisdictions: Singapore (PDPA + MAS), India (DPDP + RBI), Indonesia (UU PDP), and Japan (APPI). This document describes what is enforced, the default rules per region, how to override per org via the admin API, and how residency relates to the rest of the sovereignty stack.
What is enforced
For every /v1/chat/completions request, after the final model is selected
(classifier + tier router + routing rules), the gateway runs the residency
Enforcer (pkg/policy/enforcer.go):
- Resolve the org's
residency_region(column onorganizations, NULL = global). - If global → free-pass (no latency overhead, no pack evaluation).
- If regulated but no pack is registered for that region → fail-closed (403).
- The pack evaluates the model's
region+familyagainst its rules:- jurisdiction not allowed → 403
residency_policy_violation - family not whitelisted → 403
- (IN only) blacklist hit → hard-deny 403
- jurisdiction not allowed → 403
- On allow, the response carries
X-Residency-RegionandX-Residency-Pack.
Fail-closed is intentional: for a regulated region, blocking is safer than serving through the wrong jurisdiction.
Default rules
| Region | Pack ID | Allowed jurisdictions | Allowed families | Data residency | Blacklist |
|---|---|---|---|---|---|
| SG | sg_pdpa_mas | SG, EU | openai, anthropic, sovereign_sg, open_weights | SG | — |
| IN | in_dpdp_rbi | IN, SG | openai, anthropic, sovereign_in, open_weights | IN | CN |
| ID | id_pdp | ID, SG | openai, anthropic, sovereign_id, open_weights | ID | — |
| JP | jp_appi | JP | openai, anthropic, sovereign_jp, open_weights | JP | — |
The JP pack maps directly to how Japanese regulated buyers procure AI: an
approved-model list that only admits models with in-country data storage
(国内データ保管). Under jp_appi, a model passes only when it is registered
with region JP — an Azure OpenAI Japan East resource, a Bedrock
ap-northeast-1 model, a domestic provider, or self-hosted open weights.
A global endpoint such as api.openai.com (region US) is denied; opening
US/EU requires an explicit per-org override backed by the customer's own APPI
transfer assessment (Art. 28: consent or APPI-equivalent destination
standards).
Per-org overrides (admin API)
Overrides are stored in policy_packs (migration 0032) as a JSON override of
the ResidencyRule. Root-only endpoints:
# Set org residency region
curl -X PUT http://admin/api/organizations/$ORG_ID/residency \
-H 'Content-Type: application/json' \
-d '{"residency_region":"SG"}'
# Override the SG pack to also allow US
curl -X PUT http://admin/api/organizations/$ORG_ID/policy-packs/SG \
-H 'Content-Type: application/json' \
-d '{"pack_id":"sg_pdpa_mas","config":{"allowed_jurisdictions":["SG","EU","US"]}}'
# List overrides
curl http://admin/api/organizations/$ORG_ID/policy-packs
To clear enforcement for an org, set residency_region to "".
Metrics
gateway_residency_enforcement_total{region,decision}— allowed / deniedgateway_residency_remap_total{region}— denied → in-region remapgateway_residency_evaluation_seconds{pack_id}— pack eval latency
Relationship to the rest of the sovereignty stack
Residency is the enforcement layer — it stops a request from reaching the wrong jurisdiction. It composes with the other sovereignty components to deliver J=3 (full jurisdictional sovereignty):
- Jurisdictional lineage attestation — proves, cryptographically, where each request actually ran. Residency prevents; lineage proves.
- Multi-region active-active — residency rules are meaningful only because data is physically pinned to a home region via Postgres Row-Level Security.
- Air-gap / on-prem — single-tenant, customer-VPC deployments take residency to its logical extreme: nothing leaves the customer's environment.
- Sovereign-model registry — residency packs whitelist which model families are legal per region; the registry classifies models by sovereignty tier.