PR #288 · pramaan-io/pramaan-functions · merged 2026-06-09
Create-matter screen fans out to five services — every time.
Slow opens, stale dropdowns, one firm-wide read model missing.
Stale cache. The dropdown shows filing types that no longer exist, hides ones that were just added.
The fix — Catalog once per firm, stamp permissions per visit, pull the card on every mutation.
sequenceDiagram autonumber participant visitor as Visitor (request) participant librarian as Librarian (service + cache) participant catalog as Catalog card (DB row) visitor->>visitor: opens 'create matter' form visitor->>librarian: request with firm_id + user librarian->>catalog: read firm card catalog->>catalog: forums, filingTypes, proceedingTypes, participantLabels librarian->>visitor: catalog + fresh permission stamp visitor->>visitor: form ready, all four dropdowns populated catalog-->>librarian: admin mutates a card → librarian pulls it
| Method | in → out | what it does |
|---|---|---|
MatterConfigBootstrapService | (class) | |
_permission_context | (session, current_user, firm_id) → AppMeView | |
_load_catalogs | (session, firm_id) → MatterConfigBootstrapCatalogs |
Builds the aggregate matter-config read model (permission context plus catalogs) for the new create-bootstrap endpoint.
| new class | signature |
|---|---|
MatterConfigBootstrapService | (class) |
_permission_context | (session, current_user, firm_id) → AppMeView |
_load_catalogs | (session, firm_id) → MatterConfigBootstrapCatalogs |
Firm-scoped persisted cache with TTL metadata and write-path invalidation for the matter config bootstrap payload.
| new class | signature |
|---|---|
MatterConfigBootstrapCache | (class) |
get_fresh_payload | (session, firm_id) → dict[str, Any] | None |
put_payload | (session, firm_id, payload, now) → None |
invalidate_firm | (session, firm_id, stale_reason) → None |
invalidate_current_firm | (session, stale_reason) → None |
Alembic migration that creates the new firm-scoped bootstrap cache table used by the aggregate service.
| new method | signature |
|---|---|
upgrade | () → None |
downgrade | () → None |
revision : strdown_revision : str | Sequence[str] | Nonebranch_labels : str | Sequence[str] | Nonedepends_on : str | Sequence[str] | NoneResponse DTOs MatterConfigBootstrapCatalogs and MatterConfigBootstrapResponse for the aggregate bootstrap payload.
| new class | signature |
|---|---|
MatterConfigBootstrapCatalogs | (class) |
MatterConfigBootstrapResponse | (class) |
permission_context : AppMeViewWires GET /app/matter-templates/create-bootstrap to the bootstrap service via get_config_screen_bootstrap.
| new method | signature |
|---|---|
get_config_screen_bootstrap | (response, user, db) → MatterConfigBootstrapResponse |