Skip to main content

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):

  1. Resolve the org's residency_region (column on organizations, NULL = global).
  2. If global → free-pass (no latency overhead, no pack evaluation).
  3. If regulated but no pack is registered for that region → fail-closed (403).
  4. The pack evaluates the model's region + family against its rules:
    • jurisdiction not allowed → 403 residency_policy_violation
    • family not whitelisted → 403
    • (IN only) blacklist hit → hard-deny 403
  5. On allow, the response carries X-Residency-Region and X-Residency-Pack.

Fail-closed is intentional: for a regulated region, blocking is safer than serving through the wrong jurisdiction.

Default rules​

RegionPack IDAllowed jurisdictionsAllowed familiesData residencyBlacklist
SGsg_pdpa_masSG, EUopenai, anthropic, sovereign_sg, open_weightsSG—
INin_dpdp_rbiIN, SGopenai, anthropic, sovereign_in, open_weightsINCN
IDid_pdpID, SGopenai, anthropic, sovereign_id, open_weightsID—
JPjp_appiJPopenai, anthropic, sovereign_jp, open_weightsJP—

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 / denied
  • gateway_residency_remap_total{region} — denied → in-region remap
  • gateway_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.