Discovery: CRUD-shaped store interfaces could be one generic CRUD[E] #1784

Open
opened 2026-11-02 15:26:38 +00:00 by sam · 0 comments
Owner

From the 2026-08 architecture review follow-up (complements #1781, #1783).

What is wrong: several store interfaces are the same CRUD operation set repeated under entity-prefixed method names:

  • MappingStore: InsertMapping/GetMapping/ListMappings/UpdateMapping/DeleteMapping
  • BindingStore: the same five + Approve/Pause/Resume
  • SourceStore: Insert/Get/List/Delete + Set* mutators
  • EventTypeStore: Insert/Update/Delete/List
  • access.PolicyStore: PutPolicy/ListPolicies/DeletePolicy, plus version and seeding methods

Each repeats the insert/get/list/update/delete-by-id shape with per-entity validation and sentinel errors. Consumer tests hand-write a per-entity fake.

Wanted: one generic CRUD[E] interface in storecontract — Insert(ctx, E) (string, error), Get(ctx, id) (E, error), List(ctx), Update(ctx, E), Delete(ctx, id) — with per-entity extras (Approve/Pause/Resume, Set*) staying on the specific interfaces, and per-entity sentinels carried by the entity's adapter (e.g. an errors hook) rather than by method names. Plus one generic in-memory fake for tests. Postgres implementations stay per-entity (sqlc generates per-table SQL; the generic interface removes the Go-side duplication, not the SQL).

Done when:

  • CRUD[E] exists and at least MappingStore and EventTypeStore are expressed as CRUD[...] + extras
  • one shared fake serves the consumer tests that today hand-roll fakes
  • task check green
From the 2026-08 architecture review follow-up (complements #1781, #1783). **What is wrong:** several store interfaces are the same CRUD operation set repeated under entity-prefixed method names: - `MappingStore`: InsertMapping/GetMapping/ListMappings/UpdateMapping/DeleteMapping - `BindingStore`: the same five + Approve/Pause/Resume - `SourceStore`: Insert/Get/List/Delete + Set* mutators - `EventTypeStore`: Insert/Update/Delete/List - `access.PolicyStore`: PutPolicy/ListPolicies/DeletePolicy, plus version and seeding methods Each repeats the insert/get/list/update/delete-by-id shape with per-entity validation and sentinel errors. Consumer tests hand-write a per-entity fake. **Wanted:** one generic `CRUD[E]` interface in `storecontract` — `Insert(ctx, E) (string, error)`, `Get(ctx, id) (E, error)`, `List(ctx)`, `Update(ctx, E)`, `Delete(ctx, id)` — with per-entity extras (Approve/Pause/Resume, Set*) staying on the specific interfaces, and per-entity sentinels carried by the entity's adapter (e.g. an errors hook) rather than by method names. Plus one generic in-memory fake for tests. Postgres implementations stay per-entity (sqlc generates per-table SQL; the generic interface removes the Go-side duplication, not the SQL). **Done when:** - `CRUD[E]` exists and at least MappingStore and EventTypeStore are expressed as `CRUD[...]` + extras - one shared fake serves the consumer tests that today hand-roll fakes - `task check` green
sam added the discovery label 2026-11-02 15:26:38 +00:00
sam added the medium label 2026-11-14 14:45:42 +00:00
sam added the deferred label 2026-11-15 17:26:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1784