PR #269 · pramaan-io/pramaan-functions · merged 2026-06-08
Pickers and management lists cannot share one filter.
Live-only pickers, opt-in archived lists — both true, but only with an explicit boundary.
One filter, two jobs — picker ends up serving retired items.
The fix — Management lists show everything on demand; pickers stay live-only by default.
sequenceDiagram autonumber participant client as Client participant router as Router participant service as Service participant repo as Repository / SQL client->>router: GET /matter-types?includeArchived=true router->>router: parse param (default false) router->>service: include_archived=True service->>repo: include_archived=True repo->>repo: archive_status_clause(...) → SQL repo->>client: rows (active + archived)
| Method | in → out | what it does |
|---|---|---|
archive_status_clause | (column, include_archived, active_value) → Any | builds the SQL filter for active/archived rows from one flag |
visibility_availability_clause | (column, include_archived, live_value, deleted_value) → Any | builds the SQL filter for live/deleted semantic from one flag |
Shared module that builds SQL clauses for active/archived and live/deleted filters, so every list reads the same archive rule. Added to centralize the doctrine and avoid per-list drift.
| new method | signature |
|---|---|
archive_status_clause | (column, include_archived, active_value) → Any |
visibility_availability_clause | (column, include_archived, live_value, deleted_value) → Any |
Matter router that now accepts the includeArchived query param and forwards it to the service. Wires the boundary at the HTTP edge.
include_archived : Annotated[Matter-type router exposing includeArchived for the management list while keeping picker consumers live-only. Splits the two views cleanly.
include_archived : Annotated[Matter-type repository that builds the visible clause from include_archived and returns the list. Encapsulates the SQL toggle in one place.
| new method | signature |
|---|---|
_visible_clause | (include_archived) → Any |
list_matter_types | (db, include_archived) → list[MatterTypeRow] |
Proceeding service that threads include_archived through kind and stage listings. Applies the same doctrine to proceedings.
include_archived : boolForum router that adds the includeArchived query param for admin views. Default false keeps live-only behavior for consumers.
include_archived : Annotated[Matter-type service that passes include_archived to the repository and assembles the response. Bridges router and repo.
| new method | signature |
|---|---|
list_matter_types | (db, include_archived) → MatterTypeListResponse |
Template service for matter templates, threaded with include_archived so the template list honors the doctrine. Picker stays live.
| new method | signature |
|---|---|
list_matter_templates | (session, include_archived) → MatterTemplateListResponse |
Matter-template router exposing includeArchived for the management list. Default false preserves live-only pickers.
include_archived : Annotated[Forum service that receives include_archived and forwards it down. Keeps forum list and picker behavior aligned with the doctrine.
include_archived : boolMatter-type DTO module that adds a MatterTypeStatus class and a status field on the row. Lets the API surface live vs archived cleanly.
| new class | signature |
|---|---|
MatterTypeStatus | (class) |
status : MatterTypeStatusMatter redesign service threaded with include_archived for related matter link listings. Same opt-in pattern, same doctrine.
include_archived : bool