Case Management & Claims — standalone architecture
Build just this flow: when a policy is sold, an async install gate builds the account/COPE structure and activates the policy; then servicing and FNOL/claims. Advance the maturity stage to add the install gate, then claims media + audit, then carve out claims.
Stage 1 · MVP. A Cloud Run Case API + Cloud SQL for case/COPE/policy. Ops can view and service an in-force policy.
Stage 2 · Install gate. Add an ordered install gate (Cloud Tasks / SQS FIFO) that consumes MarkedAsSold, runs the checks, and activates the policy — idempotent, with a manual fallback. Emit PolicyActivated.
Stage 3 · Claims. Add FNOL intake with claim media in object storage; feed decisions/outcomes (governed, redacted) to the knowledge store.
Stage 4 · Scale. Claims is the natural first carve-out into its own service (different lifecycle from servicing) — and the event spine makes that split clean.
📖 Flow story — what really happens
Two mechanisms here: the event bus (async facts — events announcing something that already happened — via the outbox → Pub/Sub/EventBridge → push-subscription, deduped on event_id) AND the install-gate FIFO work queue (ordered commands — instructions to do something, processed in order — Cloud Tasks / SQS FIFO) — they are not the same thing.
- The Case API's push-subscription receives
MarkedAsSoldfrom the bus (deduped onevent_id) and writes aninstall_jobrow (statusPENDING) to Cloud SQL. - It enqueues one message on the install-gate work queue (Cloud Tasks / SQS FIFO) — an ordered command queue, not the event bus — grouped by
policy_idso the case installs exactly once, in order. - A worker pulls the job and runs the gate: is the
account_structurebuilt? underwriting clean? broker valid? - PASS → in one transaction it writes
account_structure+cope_locationrows, flips thepolicyrow toACTIVE, setsinstall_job=DONE, and writes anoutboxrow → the relay publishesPolicyActivated. - FAIL → it opens an
ops_taskrow, puts the state-filed temporary cover in effect (binder coverage), and emitsInstallGateFailed; transient errors retry, and a poison message (one that keeps failing on every retry) lands in the dead-letter queue for a human. - The case is now in-force: Ops (internal, SSO) service coverages, endorsements, billing, and the timeline from the same Cloud SQL.
- On a loss, FNOL writes a
claimrow (statusOPEN) linked to thepolicy; photos/docs upload to object storage, only their storage keys (reference IDs, not the files) inclaim_media; anoutboxrow →FNOLReceivedon the bus. - A VLM analyzes the damage photos and writes a damage score + fraud signal onto the
claim; the governed, redacted outcome is written to thedecision_log/rag_documentstore (embedded inpgvector) — closing the loop back to underwriting.
Interfaces (black-box contract)
| Direction | Contract | Who |
|---|---|---|
| Consumes | MarkedAsSold {policy id, premium snapshot} | Pricing |
| Emits | PolicyActivated, InstallGateFailed, FNOLReceived | Servicing, ops queue, RAG |