Delegiert System handbook

Chapter 07 / 14

Database

Domain schema

Maintained domain tables live in PostgreSQL schema app; retained compatibility tables remain temporarily in public. This makes cutover reversible without misleading _v2 names.

Administrative knowledge is jurisdictions → service_responsibilities → authorities → service_locations. Procedures and forms have stable identity rows, immutable versions, source evidence, and explicit published-version pointers. Conversations, turns, memory items, and memory consents represent tiered memory without raw audio. Tool executions, authorizations, and audit events share enforced identities.

Domain relationship guide

The diagram below groups the relational model into six public domains. It is an orientation aid rather than a substitute for SQLAlchemy constraints: its text equivalent names every displayed relationship, and the generated inventory that follows is derived from maintained model declarations. Authentication identities do not contain case data or voice audio; voice audio remains outside Postgres. The presentation demos use ephemeral data and do not create these domain records.

Migration state

The additive add_domain_schema_v2 migration is applied. Production backfill preserves 10,943 jurisdictions, 153 authorities and locations, 153 responsibilities, 291 procedures, 292 procedure versions, 294 evidence records, five form definitions/versions, the official EzB asset reference, and 1,749 audit events. Verification reports zero unexpected orphans and zero missing publication pointers.

Legacy tables remain intact for rollback. The unowned students table has three rows, no foreign keys or dependencies, and is inventoried without publishing its row values. Moving or deleting it requires separate destructive authorization.

Rules and retention

Foreign keys replace encoded polymorphic references and have supporting indexes. Stored timestamps are timezone-aware. Official AGS values are unique domain attributes, not foreign keys everywhere. Personal/operational tables name expiry, revocation, deletion, or purge state. Demos bypass persistence.

Migration commands verify the expected Alembic head and require an explicit production acknowledgement. Cleanup is deliberately separate from additive migration and observation.

Database domain relationshipsSix public database domains and their primary relationships. The generated inventory below lists 44 maintained model tables.jurisdictions → service responsibilitiesresponsibilities → proceduresprocedures → procedure versionsaccounts → bounded conversationsconversations → conversation turnsapproved proposals → tool executionstool executions → audit eventsallow-listed outcomes → product eventsIdentityAdministrative knowledgeProcedures and formsConversations and memoryVoice and backend actionsOperations
Text equivalent: database domain relationships.
  1. Administrative knowledge → Administrative knowledge: jurisdictions → service responsibilities
  2. Administrative knowledge → Procedures and forms: responsibilities → procedures
  3. Procedures and forms → Procedures and forms: procedures → procedure versions
  4. Identity → Conversations and memory: accounts → bounded conversations
  5. Conversations and memory → Conversations and memory: conversations → conversation turns
  6. Conversations and memory → Voice and backend actions: approved proposals → tool executions
  7. Voice and backend actions → Voice and backend actions: tool executions → audit events
  8. Voice and backend actions → Operations: allow-listed outcomes → product events
TableSchema
admin_audit_eventspublic
admin_ownerspublic
admin_sessionspublic
app.account_tokensapp
app.audit_eventsapp
app.authoritiesapp
app.conversation_turnsapp
app.conversationsapp
app.form_assetsapp
app.form_definitionsapp
app.form_versionsapp
app.jurisdictionsapp
app.memory_consentsapp
app.memory_itemsapp
app.procedure_versionsapp
app.proceduresapp
app.service_locationsapp
app.service_responsibilitiesapp
app.source_evidenceapp
app.tool_authorizationsapp
app.tool_executionsapp
app.voice_enrolmentsapp
authoritiespublic
contactspublic
content_revisionspublic
conversation_memoriespublic
conversation_memory_consentspublic
diagnostic_reportspublic
institution_scenariospublic
institutionspublic
municipalitiespublic
municipality_authoritiespublic
officespublic
password_reset_tokenspublic
product_eventspublic
profilespublic
template_assetspublic
tool_audit_recordspublic
tool_execution_recordspublic
tool_resource_authorizationspublic
user_accountspublic
user_sessionspublic
verification_recordspublic
voice_enrolmentspublic
Owner: Data Reviewed: 2026-09-01 Revision: domain-schema-v2-2026-09-01
Domain-oriented Postgres schema · Live