# Runtime interaction views These sequences describe successful code paths. Framework authentication and role policies precede the boundary. Scope checks also occur in controllers; the views condense repeated checks without implying they are removed. ## Record an observation ```mermaid sequenceDiagram participant C as Patient client participant H as Host / boundary participant X as AccessPolicy participant O as ObservationFacade participant P as ProfileFacade participant T as RequestTransaction participant D as PostgreSQL C->>H: POST patient observations + bearer ticket H->>T: BeginAsync(write): ReadCommitted T->>D: Open pooled connection / begin H->>X: Authorize actual patient before binding X->>P: ResolveAccountAsync(account) P->>D: Own schema account lookup X-->>H: AuthorizedPatientContext H->>O: RecordAsync(scope, validated request) O->>P: GetAsync(scope) P->>D: Read patient in shared transaction O->>D: Validate / insert owned observation O-->>H: Immutable ObservationDto H->>T: FinishAsync T->>D: Commit and release connection H-->>C: 201 + relative Location ``` Denial yields empty 404 before body validation. SQL/model failures cannot produce a successful creation response. Concurrent updates lock the owner-scoped row; failures roll back on disposal. ## Coherent overview ```mermaid sequenceDiagram participant C as Authorized client participant H as Host / boundary participant T as RequestTransaction participant V as OverviewFacade participant P as ProfileQueries participant O as ObservationQueries participant A as AnalyticsFacade participant S as SummaryPolicy C->>H: GET overview with period / selection H->>T: BeginAsync(read): RepeatableRead H->>H: Authorize patient H->>V: GetAsync(scope, period, selection) V->>P: GetAsync(scope) P-->>V: Profile snapshot V->>O: LatestAsync(scope) O-->>V: Latest overall snapshot V->>A: InsightAsync(scope, period, selection) A->>O: SelectedAsync (once) O-->>A: Immutable selected series A->>T: FinishAsync: release snapshot connection A->>S: CalculateSummary S-->>A: Insight or null A-->>V: Selected insight V-->>H: DTO with separate bases / explanations H-->>C: 200 overview ``` A concurrent commit after snapshot capture is invisible to all in-flight overview reads; a later request can see it. Missing profile returns 404. Empty selection leaves profile/latest intact and produces a null insight explanation. Overview does not call the trend calculator. ## Trends and failure handling Trend requests follow the same authorization/read transaction path, then one SelectedAsync capture, FinishAsync, and TrendPolicy → ClinicalPolicy → ReferenceCatalog calls. Computation occurs after database release. No remote reference fetch or analytics write occurs. Immediate admission refusal returns 503 with Retry-After. Database errors map to dependency 503 or recognized timeout 504; the deadline maps to 504 when writable. Empty data follows distinct successful absence paths. Cleanup releases admission slots and disposes unfinished transactions. Caller abort closes the connection. Login and static guidance do not require a healthy database.