Skip to main content

Target architecture

Status: Approved target

Where the system is going. Nothing on this page is built yet; an item moves to current/ in the pull request that builds it. The decisions and their reasons are the ADRs linked from each item.

flowchart LR
subgraph edge["User machines"]
agent["Worker (engine in-process, ADR 0006)"]
sink[("User's storage")]
end
subgraph platform["Platform (hosting not decided; ADR 0007, 0014, 0015 withdrawn)"]
dashboard["Dashboard (backend for frontend)"]
identity["identity"]
runs["runs"]
insights["insights"]
mcp["mcp"]
observatory["observatory"]
jobs["outbox relay and jobs (River)"]
subgraph pg["PostgreSQL: a schema per service (ADR 0004)"]
s_identity[("identity")]
s_runs[("runs")]
s_insights[("insights")]
s_obs[("observatory")]
end
end
agent -->|"REST /v1 + Idempotency-Key (ADR 0003)"| runs
agent --> sink
dashboard --> identity & insights & runs
dashboard --> observatory
mcp -->|"APIs, no SQL"| insights & runs
identity --> s_identity
runs --> s_runs
insights --> s_insights
observatory --> s_obs
runs -->|"outbox events (ADR 0005)"| jobs
jobs --> insights & observatory

Items​

ItemWhat changesADRPull requestState
Platform code and contractssrc/internal becomes src/platform; contracts/ holds an OpenAPI file per service and a schema per event, with a breaking-change check in CI; cache, queue, rate-limit and lock ports with in-memory, Postgres and Valkey adapters0002, 0003, 0005B1built; the rate limits use the ports and B4's jobs the queue; the locks wait for a user
A schema per serviceidentity, runs, insights, observatory schemas, one database role per service, compatibility views while readers move0004B2built; the Go services name the schemas (B3), the Observatory moves in B7, then the views go
The API splitidentity, runs and insights binaries; the ingress routes by path; the dashboard uses a generated client; per-service credentials replace INTERNAL_SECRET with X-Account-Id0002, 0003, 0009, 0010B3built; INTERNAL_SECRET is deprecated and goes once its counter stays at zero
Events and jobsa transactional outbox and jobs on the queue port (not River); insights rollups fed by events; server-assigned schedule slots and cheap hourly checks; per-plan limits on manual runs; one pending request per account and target; expired leases stop counting0005, 0011B4abuilt; a 304 answered without a database query waits for a shared cache
Ownership by eventsfaster revocation across processes; research consent owned by runs; account deletion by account.deleted and an export per service, so identity's grants in runs and insights go0004, 0005, 0008, 0012B4bbuilt; the Observatory's rows still go with identity's transaction until B7
The engine contractplan.v1 schema and conformance vectors the Go engine passes in CI0006B5built; deletions (pruning, legacy cleanup) are outside plan.v1
The MCP server over the APIsno SQL of its own; requests and fixes written only through runs0002, 0004B6built; the Observatory records fixes through runs too, and ghb_mcp is retired
Embed failures onlythe Observatory consumes run.failed, embeds errors and fixes, indexes incrementally in a background job, and caps LLM concurrency0008, 0013B7built in B7a (additive: grants, deletion and chunk retention unchanged); B7b moves account deletion and orphan chunks to the Observatory and revokes its runs grants (needs the owner's decisions on the deletion promise and on old chunks); B7c drops the compatibility views
Hosting on one VMwithdrawn on 2026-11-05: the VM deployments (deploy/oci, deploy/k8s) were removed; production is the self-hosted stack of ADR 00190007, 0014, 0015 (superseded by 0019)A4 (#81)withdrawn
Deletion and exportfull chat deletion, account deletion, a JSON export0008A6 (#83)planned

Scaling steps beyond these (a second node, a read replica, log partitioning) wait for the trigger each one names in the October 2026 architecture review (in git history); they are not approved items yet. Rate limits shared across instances are a setting since B1 (RATELIMIT_BACKEND).