Discovery: one dashboard module per resource in webui #1778

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

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

What is wrong: internal/webui puts 189 handler methods on *Server (68 fields on Server, 12 storecontract-typed) across 54 api_*.go files (9.7k lines, 21 test files). Every handler repeats nil-check → parse → validate → store call → view shaping, so the Server's method set is approximately as large as its implementation and the same bug pattern recurs in 47 files.

Wanted: one module per dashboard resource (bindings, tasks, audit, …), each declaring the narrow storecontract sub-interface it needs and registering its own routes; Server becomes a registrar.

Done when:

  • each resource module exposes its handlers through one narrow store seam (staterpc adapter in prod, fake in tests)
  • per-handler nil-check boilerplate is gone from the handlers
  • task check green; dashboard e2e checks pass
From the 2026-08 architecture review (recommendation: worth exploring). **What is wrong:** `internal/webui` puts 189 handler methods on `*Server` (68 fields on `Server`, 12 storecontract-typed) across 54 `api_*.go` files (9.7k lines, 21 test files). Every handler repeats nil-check → parse → validate → store call → view shaping, so the Server's method set is approximately as large as its implementation and the same bug pattern recurs in 47 files. **Wanted:** one module per dashboard resource (bindings, tasks, audit, …), each declaring the narrow `storecontract` sub-interface it needs and registering its own routes; `Server` becomes a registrar. **Done when:** - each resource module exposes its handlers through one narrow store seam (staterpc adapter in prod, fake in tests) - per-handler nil-check boilerplate is gone from the handlers - `task check` green; dashboard e2e checks pass
sam added the discovery label 2026-11-02 14:53:46 +00:00
Author
Owner

Pilot done: commit d55d8580 extracts bindingsAPI (internal/webui/bindings.go) owning the /api/bindings* routes and handlers off *Server. The module is constructed only when the binding store is configured; a 503 stub mounts the same routes otherwise, so not-configured answers are unchanged. The shared dispatch-ledger handler stays on Server (captures/tasks routes use it too). task check green. Pattern proven: one module per resource, constructor takes the narrow storecontract surfaces + cross-cutting helpers as func fields, register(mux) owns the routes. Next: mappings, sources, event-types, then the rest area by area.

Pilot done: commit d55d8580 extracts `bindingsAPI` (internal/webui/bindings.go) owning the /api/bindings* routes and handlers off *Server. The module is constructed only when the binding store is configured; a 503 stub mounts the same routes otherwise, so not-configured answers are unchanged. The shared dispatch-ledger handler stays on Server (captures/tasks routes use it too). task check green. Pattern proven: one module per resource, constructor takes the narrow storecontract surfaces + cross-cutting helpers as func fields, register(mux) owns the routes. Next: mappings, sources, event-types, then the rest area by area.
Author
Owner

Roll-out wave 1 done: commit 864b87fa extracts eventTypesAPI (internal/webui/eventtypes.go), mappingsAPI (mappings.go) and sourcesAPI (sources.go) off *Server, same pattern as the bindings pilot (d55d8580). event-types registers unconditionally (list answers enabled:false without a store); mappings and sources mount a 503 stub when their store is nil. Shared helpers (unsignedSources, recentRefusals, listedIn) and the dispatch-ledger handler stay on Server. task check green. Remaining areas: tasks, harness, config/logs, chat, and the core routes in registerCoreRoutes.

Roll-out wave 1 done: commit 864b87fa extracts eventTypesAPI (internal/webui/eventtypes.go), mappingsAPI (mappings.go) and sourcesAPI (sources.go) off *Server, same pattern as the bindings pilot (d55d8580). event-types registers unconditionally (list answers enabled:false without a store); mappings and sources mount a 503 stub when their store is nil. Shared helpers (unsignedSources, recentRefusals, listedIn) and the dispatch-ledger handler stay on Server. task check green. Remaining areas: tasks, harness, config/logs, chat, and the core routes in registerCoreRoutes.
Author
Owner

Done. Modules extracted: tasks, bindings, event types, mappings, sources, harness, extensions, orgs, identities/tokens, access, control plane, logs, chat, schedules, alerts, audit, workflows. Each owns its routes and narrow dependencies; Server registers them. Remaining Server routes are single-route readers and shared helpers. task check green on every commit; dashboard e2e 25/26 on a fresh stack, the remaining failure is the catalogue signature (#1790), unrelated to this refactor.

Done. Modules extracted: tasks, bindings, event types, mappings, sources, harness, extensions, orgs, identities/tokens, access, control plane, logs, chat, schedules, alerts, audit, workflows. Each owns its routes and narrow dependencies; Server registers them. Remaining Server routes are single-route readers and shared helpers. `task check` green on every commit; dashboard e2e 25/26 on a fresh stack, the remaining failure is the catalogue signature (#1790), unrelated to this refactor.
sam closed this issue 2026-11-02 22:38:06 +00:00
sam added the high label 2026-11-12 15:51:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1778