Discovery: consumers name the store sub-interfaces they use #1781

Open
opened 2026-11-02 14:32:58 +00:00 by sam · 3 comments
Owner

From the 2026-08 architecture review (recommendation: speculative).

What is wrong: storecontract.TaskStore composes 8 sub-interfaces (91 methods across 31 interfaces), but internal/daemon and internal/webui's Server take the whole thing while each uses a fraction. The daemon already splits BindingTaskCreator off ad hoc, which shows the composed seam is wider than any one consumer needs.

Wanted: consumers declare exactly the sub-interfaces they consume (structural typing makes this free); TaskStore stays as the production composition, not the consumer's dependency.

Done when:

  • daemon and webui depend on named sub-interfaces, not the composed TaskStore
  • task check green
From the 2026-08 architecture review (recommendation: speculative). **What is wrong:** `storecontract.TaskStore` composes 8 sub-interfaces (91 methods across 31 interfaces), but `internal/daemon` and `internal/webui`'s `Server` take the whole thing while each uses a fraction. The daemon already splits `BindingTaskCreator` off ad hoc, which shows the composed seam is wider than any one consumer needs. **Wanted:** consumers declare exactly the sub-interfaces they consume (structural typing makes this free); `TaskStore` stays as the production composition, not the consumer's dependency. **Done when:** - daemon and webui depend on named sub-interfaces, not the composed `TaskStore` - `task check` green
sam added the discovery label 2026-11-02 14:53:56 +00:00
Author
Owner

Follow-up from review of the Deps wiring (app/statestore/server.go stateStoreDeps/executionDeps/accessDeps, staterpc/server.go Deps, daemon wireWebStoreSurfaces): the Deps struct re-lists every storecontract surface as a field, and each composition root re-asserts it (if x, ok := b.st.(I); ok { deps.X = x }) — three places that must agree per surface (contract, Deps field, assertion block), plus the nil→Unavailable error var in the RPC handler.

Proposal (design fix, not codegen — per the no-compensating-tools rule a Go-from-Go generator would just move the list): shrink staterpc.Deps to non-store deps (Grants, Log, ControlPlane, OrgModels, OrgInstructions, ScheduleSettings, LogFeed) plus one Store any; each per-contract server type asserts its own storecontract surface once at construction, nil → codes.Unavailable (current behavior). A new store surface then touches exactly two places: the contract and the server that serves it. Same fix on the daemon client side.

Done when: Deps has no per-store-interface fields; assertion blocks live only in the per-contract server constructors; adding a surface no longer requires editing a central field list; task check green.

Follow-up from review of the Deps wiring (app/statestore/server.go stateStoreDeps/executionDeps/accessDeps, staterpc/server.go Deps, daemon wireWebStoreSurfaces): the Deps struct re-lists every storecontract surface as a field, and each composition root re-asserts it (`if x, ok := b.st.(I); ok { deps.X = x }`) — three places that must agree per surface (contract, Deps field, assertion block), plus the nil→Unavailable error var in the RPC handler. Proposal (design fix, not codegen — per the no-compensating-tools rule a Go-from-Go generator would just move the list): shrink staterpc.Deps to non-store deps (Grants, Log, ControlPlane, OrgModels, OrgInstructions, ScheduleSettings, LogFeed) plus one `Store any`; each per-contract server type asserts its own storecontract surface once at construction, nil → codes.Unavailable (current behavior). A new store surface then touches exactly two places: the contract and the server that serves it. Same fix on the daemon client side. Done when: Deps has no per-store-interface fields; assertion blocks live only in the per-contract server constructors; adding a surface no longer requires editing a central field list; `task check` green.
Author
Owner

Maintainer direction from review: contract-first codegen is preferred where a single IDL contract exists (protobuf, sqlc). Applied to the store seam, the candidate is to make proto/state/v1 the single source of truth and generate the Go port (storecontract) + staterpc Deps plumbing from it, eliminating the hand-maintained storecontract↔proto mirror. Open cost: generated signatures are wire-typed (pb.*) rather than domain-typed (task.Task); keeping domain types means generating only the plumbing, not the signatures. Exploration only — the Deps per-server-assertion fix from the previous comment stands as the no-codegen alternative.

Maintainer direction from review: contract-first codegen is preferred where a single IDL contract exists (protobuf, sqlc). Applied to the store seam, the candidate is to make proto/state/v1 the single source of truth and generate the Go port (storecontract) + staterpc Deps plumbing from it, eliminating the hand-maintained storecontract↔proto mirror. Open cost: generated signatures are wire-typed (pb.*) rather than domain-typed (task.Task); keeping domain types means generating only the plumbing, not the signatures. Exploration only — the Deps per-server-assertion fix from the previous comment stands as the no-codegen alternative.
Author
Owner

Correction to my earlier comment: internal/daemon has no wireWebStoreSurfaces symbol; the phrase appears only in a comment at internal/app/statestore/server.go:259. TaskStore embeds 8 sub-interfaces, not 12 (issue body corrected).

Correction to my earlier comment: `internal/daemon` has no `wireWebStoreSurfaces` symbol; the phrase appears only in a comment at internal/app/statestore/server.go:259. `TaskStore` embeds 8 sub-interfaces, not 12 (issue body corrected).
sam added the medium label 2026-11-14 14:45:43 +00:00
sam added the deferred label 2026-11-15 17:26:13 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1781