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
| Item | What changes | ADR | Pull request | State |
|---|---|---|---|---|
| Platform code and contracts | src/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 adapters | 0002, 0003, 0005 | B1 | built; the rate limits use the ports and B4's jobs the queue; the locks wait for a user |
| A schema per service | identity, runs, insights, observatory schemas, one database role per service, compatibility views while readers move | 0004 | B2 | built; the Go services name the schemas (B3), the Observatory moves in B7, then the views go |
| The API split | identity, runs and insights binaries; the ingress routes by path; the dashboard uses a generated client; per-service credentials replace INTERNAL_SECRET with X-Account-Id | 0002, 0003, 0009, 0010 | B3 | built; INTERNAL_SECRET is deprecated and goes once its counter stays at zero |
| Events and jobs | a 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 counting | 0005, 0011 | B4a | built; a 304 answered without a database query waits for a shared cache |
| Ownership by events | faster 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 go | 0004, 0005, 0008, 0012 | B4b | built; the Observatory's rows still go with identity's transaction until B7 |
| The engine contract | plan.v1 schema and conformance vectors the Go engine passes in CI | 0006 | B5 | built; deletions (pruning, legacy cleanup) are outside plan.v1 |
| The MCP server over the APIs | no SQL of its own; requests and fixes written only through runs | 0002, 0004 | B6 | built; the Observatory records fixes through runs too, and ghb_mcp is retired |
| Embed failures only | the Observatory consumes run.failed, embeds errors and fixes, indexes incrementally in a background job, and caps LLM concurrency | 0008, 0013 | B7 | built 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 VM | withdrawn on 2026-11-05: the VM deployments (deploy/oci, deploy/k8s) were removed; production is the self-hosted stack of ADR 0019 | 0007, 0014, 0015 (superseded by 0019) | A4 (#81) | withdrawn |
| Deletion and export | full chat deletion, account deletion, a JSON export | 0008 | A6 (#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).