Phase 2: Extract the State Store Service #113

Closed
opened 2026-10-27 13:35:00 +00:00 by sam · 0 comments
Owner

Second extraction in the resolved order. Expose internal/store as its own
service behind its narrow contracts over gRPC. This generalises the
pattern already in production: internal/storerpc proxies
store.WorkflowStore to the archie-agent container over NATS request/reply
today (see resolved open question #4).

Per question #4's resolution: ONE State Store service owns the existing
single SQLite file (archie.db) behind narrow typed contracts (TaskStore,
CaptureStore, MappingStore, BindingStore, WorkflowStore, BindingDispatcher,
BindingTaskCreator from internal/store/interface.go). No physical
database-per-service split -- one store means no distributed-transactions
problem, and per the team-topology rule of thumb a solo maintainer gets no
autonomy benefit from physical isolation. The Gateway's already-separate
session SQLite is unaffected and stays Gateway-owned.

Migration path (from the research doc, in order of blast radius):

  1. Ratify internal/store/interface.go's narrow interfaces as the State
    Store contract surface (already true in code; authority decision only).
  2. Generalise internal/storerpc from proxying only WorkflowStore to
    serving the full narrow contract set, and move it from NATS
    request/reply to gRPC (per the PRD, gRPC is the sync transport).
  3. Swap direct internal/store imports in internal/webui,
    internal/domain/workflow, and the intake/binding paths onto the
    contract, starting with low-touch reads (CaptureStore, MappingStore,
    BindingStore), then WorkflowStore, then the TaskStore lifecycle
    surface.
  4. Stand up internal/store as archie-state-store (gRPC server over the
    same archie.db file); delete the in-process imports once every
    consumer speaks the contract.

Depends on Phase 1 (Gateway extraction) per the resolved extraction
order -- Gateway proves the process-split + gRPC playbook first.

Full reasoning: docs/inspiration/service-decomposition-open-questions-research-2026-09-05.md#4
and #1 (Phase 2 section).

Acceptance criteria

  • New cmd/archie-state-store binary serving TaskStore, CaptureStore,
    MappingStore, BindingStore, WorkflowStore, BindingDispatcher, and
    BindingTaskCreator over gRPC, all backed by the single existing
    archie.db SQLite file (no physical file split).
  • internal/storerpc generalised (or a successor package) to serve the
    full narrow contract set, migrated from NATS request/reply to gRPC.
  • internal/webui, internal/domain/workflow, and the intake/binding paths
    no longer import internal/store directly -- they call the State Store
    contract.
  • Each contract swap follows the local-adapter + gRPC-adapter +
    bufconn-conformance-suite shape from Phase 0, with a same-commit flip
    to mode = "remote" once archie-state-store is standing.
  • The Gateway's own session SQLite is untouched and remains
    Gateway-owned.
  • task check passes; a dashboard/combined view that reads across
    multiple contracts (task/event/capture) still works correctly through
    the new contract calls.

Close reason

All 8 children (.4.1-.4.8) verified against main and closed 2026-09-07: .4.1 ratification (docs/prds/state-store-contract.md), .4.8 domain type relocation (PR #754), .4.2 gRPC contract generalization (PR #770), .4.3 standalone archie-state-store binary (PR #771), .4.4 capture/mapping/binding consumer migration (PR #772), .4.5 workflow/intake/task-lifecycle migration (PR #773), .4.6 daemon/Gateway cutover (PR #774), .4.7 end-to-end verification + the remaining task-scoped-credential/streaming-capture/CI-artifact gaps found and fixed this session (commits f94e484, accb987, 4e1efd5, d687f05). Phase 2 acceptance criteria (single archie.db owner, narrow typed contracts, task check passing, dashboard reading across contracts) all hold.


Imported from beads archie-core-8cda.4 · GitHub #729 · type task · priority P2 · created 2026-09-05 · closed 2026-09-07

Second extraction in the resolved order. Expose internal/store as its own service behind its narrow contracts over gRPC. This generalises the pattern already in production: internal/storerpc proxies store.WorkflowStore to the archie-agent container over NATS request/reply today (see resolved open question #4). Per question #4's resolution: ONE State Store service owns the existing single SQLite file (archie.db) behind narrow typed contracts (TaskStore, CaptureStore, MappingStore, BindingStore, WorkflowStore, BindingDispatcher, BindingTaskCreator from internal/store/interface.go). No physical database-per-service split -- one store means no distributed-transactions problem, and per the team-topology rule of thumb a solo maintainer gets no autonomy benefit from physical isolation. The Gateway's already-separate session SQLite is unaffected and stays Gateway-owned. Migration path (from the research doc, in order of blast radius): 1. Ratify internal/store/interface.go's narrow interfaces as the State Store contract surface (already true in code; authority decision only). 2. Generalise internal/storerpc from proxying only WorkflowStore to serving the full narrow contract set, and move it from NATS request/reply to gRPC (per the PRD, gRPC is the sync transport). 3. Swap direct internal/store imports in internal/webui, internal/domain/workflow, and the intake/binding paths onto the contract, starting with low-touch reads (CaptureStore, MappingStore, BindingStore), then WorkflowStore, then the TaskStore lifecycle surface. 4. Stand up internal/store as archie-state-store (gRPC server over the same archie.db file); delete the in-process imports once every consumer speaks the contract. Depends on Phase 1 (Gateway extraction) per the resolved extraction order -- Gateway proves the process-split + gRPC playbook first. Full reasoning: docs/inspiration/service-decomposition-open-questions-research-2026-09-05.md#4 and #1 (Phase 2 section). ### Acceptance criteria - New cmd/archie-state-store binary serving TaskStore, CaptureStore, MappingStore, BindingStore, WorkflowStore, BindingDispatcher, and BindingTaskCreator over gRPC, all backed by the single existing archie.db SQLite file (no physical file split). - internal/storerpc generalised (or a successor package) to serve the full narrow contract set, migrated from NATS request/reply to gRPC. - internal/webui, internal/domain/workflow, and the intake/binding paths no longer import internal/store directly -- they call the State Store contract. - Each contract swap follows the local-adapter + gRPC-adapter + bufconn-conformance-suite shape from Phase 0, with a same-commit flip to mode = "remote" once archie-state-store is standing. - The Gateway's own session SQLite is untouched and remains Gateway-owned. - task check passes; a dashboard/combined view that reads across multiple contracts (task/event/capture) still works correctly through the new contract calls. ### Close reason All 8 children (.4.1-.4.8) verified against main and closed 2026-09-07: .4.1 ratification (docs/prds/state-store-contract.md), .4.8 domain type relocation (PR #754), .4.2 gRPC contract generalization (PR #770), .4.3 standalone archie-state-store binary (PR #771), .4.4 capture/mapping/binding consumer migration (PR #772), .4.5 workflow/intake/task-lifecycle migration (PR #773), .4.6 daemon/Gateway cutover (PR #774), .4.7 end-to-end verification + the remaining task-scoped-credential/streaming-capture/CI-artifact gaps found and fixed this session (commits f94e484, accb987, 4e1efd5, d687f05). Phase 2 acceptance criteria (single archie.db owner, narrow typed contracts, task check passing, dashboard reading across contracts) all hold. --- _Imported from beads `archie-core-8cda.4` · GitHub #729 · type task · priority P2 · created 2026-09-05 · closed 2026-09-07_
sam added the mediumtask labels 2026-10-27 13:35:00 +00:00
sam self-assigned this 2026-10-27 13:35:00 +00:00
sam closed this issue 2026-10-27 13:35:00 +00:00
sam added a new dependency 2026-10-27 13:41:44 +00:00
sam added a new dependency 2026-10-27 13:41:44 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#113