SR-010 — Centralized Personal Information Store: System Requirements
By Engineering Team•October 1, 2026•7 min read
| Metadata | Details |
|---|---|
| System Name | pii-service — Centralized Personal Information Store |
| Document ID | SR-2026-PII-001 |
| Author | Engineering Team |
| Status | Approved |
Traces back to BRD-009 — Centralized Personal Information Store.
Functional Requirements
Attribute Storage & Retrieval
- FR-01 (gRPC-Only Surface):
pii-serviceMUST exposeUpsertAttributes,GetAttributes, andDeleteAttributesover gRPC only — it MUST NOT expose any HTTP/REST surface, and no other service MUST be able to query its PostgreSQL database directly. - FR-02 (Entity-Attribute-Value Keying): every stored attribute MUST be keyed by
(tenant_id, entity_type, entity_id, attribute_key), persisted in theuser_pii_attributestable under the"pii-service"schema, with a unique index on that four-part key. - FR-03 (Encryption At Rest): every
plaintext_valueMUST be encrypted with AES-256-GCM, with a fresh random nonce per value, before being written touser_pii_attributes— decryption MUST happen only insideGetAttributes, and a decrypted value MUST never be written to a log line. - FR-04 (Caller Attribution): every
UpsertAttributes/GetAttributes/DeleteAttributesrequest MUST carry a non-emptycaller_serviceandtransaction_idin its payload —pii-servicehas no other mechanism to attribute a call to its originating system or business operation. - FR-05 (Consumer-Owned entity_type Namespace):
entity_typeis a free-text value chosen by each consuming service ("warehouse","user_personal","user_address"are the values in use today) — adding a new entity type requires no code change insidepii-serviceitself.
Address Snapshot & Dedup
- FR-06 (Dedicated Address Snapshot Model): shipping/billing address content submitted via
CreateAddressSnapshotsMUST be stored in two dedicated tables (address_snapshots,address_snapshot_attributes) rather than the genericuser_pii_attributesmodel, since an address snapshot has no caller-ownedentity_idto key by until after deduplication occurs. - FR-07 (Content-Hash Deduplication): for each submitted address block,
pii-serviceMUST sort its attributes byattribute_key, compute a SHA-256 hex digest ofkey=trimmed_lowercased_value\nper attribute, and combine them into onecontent_hash; a lookup on(tenant_id, created_user_id, content_hash)that finds an existingaddress_snapshotsrow MUST reuse itssnapshot_id(is_new_snapshot: false) instead of writing a new one. - FR-08 (Per-User Dedup Scope): deduplication MUST be scoped to
(tenant_id, created_user_id)— two different users in the same tenant who submit an identical physical address MUST NOT collide into the same snapshot. - FR-09 (Race-Safe Snapshot Insert): a
CreateAddressSnapshotscall that races another concurrent call for the same(tenant_id, created_user_id, content_hash)MUST detect the resulting unique-constraint violation, re-fetch the winning row’ssnapshot_id, and use it — the losing request MUST NOT write its own orphaned child attribute rows. - FR-10 (Snapshot Retrieval By ID):
GetAddressSnapshotsMUST resolve each{snapshot_id, address_type}lookup to its decrypted attributes without requiring the caller to know the attribute-key set in advance, and MUST passaddress_typethrough unchanged from the request without validating it.
Multi-Tenancy & Auth Propagation
- FR-11 (gRPC Metadata Auth):
tenant_id,user_id, androleMUST be read exclusively from gRPC metadata, extracted viarust_lang_core_lib::auth::extract_auth_claims— a request missing any of the three MUST be rejected withtonic::Status::unauthenticated, and these values MUST NEVER be read from the request payload.
Audit Trail
- FR-12 (Per-Call Audit Logging): every
UpsertAttributes(Write),GetAttributes(Read), andDeleteAttributes(Delete) call — including a snapshot lookup that reuses an existing snapshot via dedup — MUST write one entry torow_attribute_audit_logrecordingcaller_service,transaction_id,action,entity_type, andentity_id.
Non-Functional Requirements
Security
- NFR-01 (Per-Service Encryption Key): each of
pii-service/pci-serviceMUST use its own AES-256-GCM key (PII_ENCRYPTION_KEY/PCI_ENCRYPTION_KEY), sourced from an environment variable, never hardcoded or shared across services. - NFR-02 (Shared Implementation, Isolated Schema):
pii-serviceandpci-serviceMUST share the samedomain::encrypt/service::encrypt/repository::encryptimplementation fromrust-lang-core-lib, while each persisting to its own PostgreSQL schema ("pii-service"vs."pci-service") — no row of one service’s data MUST ever be reachable through the other’s schema.
Consistency & Cross-Service Transactions
- NFR-03 (Caller-Owned Compensation): because
pii-serviceparticipates in no distributed transaction with its callers, a consuming service that writes its own local row before callingUpsertAttributesMUST compensate (roll back its own local write) if thepii-servicecall fails. (Gap —inventory-service’sCreateWarehouseis the only verified implementation of this today, and its own compensating delete is best-effort: a failure of the compensatingDeleteWarehouseByIDcall is only logged, not retried, leaving a warehouse row with no PII attributes. Tracked as technical debt — see Technical Debt — Centralized Personal Information Store Gaps, TD-01.)
Caller Attribution Integrity
- NFR-04 (Accurate caller_service Attribution):
caller_servicesent by any consumer MUST identify the actual calling service, never a copy-pasted value from a different service’s integration code. (Gap —notification-service’sinfra/pii_client.rsis a verbatim copy ofuser-secure-engine’s client, including a hardcodedCALLER_SERVICE = "user-secure-engine"constant, and is wired into a live gRPC server (UserServiceServer) insidenotification-service’s ownapp_config.rs— every resultingrow_attribute_audit_logentry misattributes the real caller. Tracked as technical debt — see Technical Debt — Centralized Personal Information Store Gaps, TD-02.)
Namespace Governance
- NFR-05 (entity_type Collision Avoidance): two unrelated consuming services SHOULD NOT be able to pick the same
entity_typevalue for unrelated data. (Gap —entity_typeis free text with no central registry or compile-time enforcement; today’s values ("warehouse","user_personal","user_address") avoid collision only by convention. Tracked as technical debt — see Technical Debt — Centralized Personal Information Store Gaps, TD-03.)
Observability
- NFR-06 (Span Hygiene): every public
pii-servicemethod MUST use#[tracing::instrument]withclaims/struct parameters inskip(), never auto-captured, per 04-observability-and-tracing’s Rust instrumentation rule. - NFR-07 (Metadata Propagation to Callers): every outbound call to
pii-serviceMUST carrytenant_id/user_id/roleas gRPC metadata sourced from the calling service’s ownAuthClaims, never re-derived.
Related Documents
- BRD-009 — Centralized Personal Information Store
- ADR-00018 — Row-Based Encrypted Attribute Model, Value-Level Encryption, and the Address-Snapshot Exception
- ADR-00019 — Dedicated pii-service vs. Duplicated Per-Service PII Handling
- ADR-00020 — Shared Core-Lib Encryption/Audit/CRUD Pattern vs. In-Service Implementation
- ADR-00021 — PostgreSQL vs. MongoDB for pii-service’s Data Store
- Architecture: Centralized Personal Information Store
- Technical Debt — Centralized Personal Information Store Gaps