Architecture tour
Zentri has two Go binaries. zentri-server is the coordinator: one HTTP service on Postgres that holds sessions, claims, intents, questions, decisions and the audit log. zentri is the CLI that engineers and agents run. Its zt name is a symlink to the same binary. Everything else in the repository feeds one of these two, or talks to the coordinator over HTTP.
The repository
Section titled “The repository”One Go module, zentri.dev/zentri, sits at the root. ADR-0001 sets the layout.
| Path | What it holds |
|---|---|
server/cmd/zentri-server |
The coordinator’s entry point and its serve, migrate, audit, intents and overlap commands |
server/internal |
The coordinator’s packages. Nothing outside server/ imports them. |
server/migrations |
The SQL schema, embedded in the binary |
cli/cmd/zentri |
The CLI’s entry point |
cli/internal |
The CLI’s packages: commands, the HTTP client, the MCP shim, the agent hooks and the kit |
pkg |
Code both binaries import: path normalization, symbol records, the session launchers and build metadata |
adapters |
The kits written into a session’s worktree for each agent: Claude Code, Codex, OpenCode and a generic MCP one. They are embedded in the CLI. |
sandbox/openshell |
The OpenShell policies and images for the sandboxed launcher |
integrations |
The Slack bot (TypeScript), the GitHub merge check, and the terminal kit for pasting images |
deploy |
Docker Compose, the Postgres init scripts, the install scripts, the Cloudflare Pages configs, and the Helm chart |
web |
The marketing site, these docs, and a placeholder for the accounts Worker |
examples |
Labeled task pairs and symbol pairs that calibrate dedup |
docs |
ADRs, architecture notes, the roadmap and the threat model |
scripts |
The end-to-end tests, the integration test runner, calibration and the lint checks |
ee |
The enterprise license draft. No code yet. |
Inside the coordinator
Section titled “Inside the coordinator”Each package in server/internal owns one subsystem and its own SQL.
| Package | Job |
|---|---|
api |
The HTTP surface. Each route is a row in routes.go, and openapi.yaml documents the same table. A test fails when the two drift. |
auth |
Tokens, and every authorization decision through one table (ADR-0003) |
sessions |
The session lifecycle, heartbeats, and the sweeper that abandons silent sessions |
claims |
Exclusive write claims on paths (ADR-0005) |
intents |
Compare a new task with existing work, then register it (ADR-0006) |
overlap, plans |
Live overlap between sessions’ plans and snapshots (ADR-0007) |
questions, decisions, prd |
Questions to people, decision records, and PRD revisions (ADR-0009) |
mergecheck |
Whether a pull request may merge (ADR-0008) |
mcp |
The MCP tools. A thin adapter over the same services as api. |
router |
Cheap or frontier model per session (ADR-0011) |
slack, notify, notices |
The Slack side of the bot, message delivery, and per-session notices |
audit |
The hash-chained audit log (ADR-0005) |
store |
The Postgres pool, migrations and transactions |
modelclient |
The only outbound HTTP: embedders and LLMs |
secretscan, ratelimit, telemetry |
Redaction, rate limits, and logs, metrics and traces |
How a request flows
Section titled “How a request flows”An agent and a person reach the same services by two paths.
- An engineer runs
zt. The CLI reads the user token from the OS keychain throughcli/internal/keyring, or from its config file where there is none, and calls the coordinator’s REST API withcli/internal/client. - An agent calls a tool. The kit points the agent at
zentri mcp, an MCP server on stdio. It forwards each tool call to the coordinator’s/mcpendpoint with the session token. The agent’s hooks runzentri hook, which claims a file before an edit.
On the coordinator, each request passes through the same steps in server/internal/api:
- The route table matches the method and path, and names the action the route needs.
- The body is capped at 1 MiB.
- The bearer token is looked up by its hash, and its bucket is rate limited.
- The handler calls
authorizefor the action and the resource. A handler that returns without calling it fails closed with a 500. - The service runs its SQL in one transaction, and writes its audit rows in the same transaction. A write and its audit row commit together or not at all.
- Errors the caller can act on carry a status and a code from
apperr. Every other error is a 500 with the codeinternaland no detail.
The coordinator never runs agent code and never holds git credentials. Agents run on the engineer’s machine, or in an OpenShell sandbox. See Why the coordinator is not sandboxed.
The open-core boundary
Section titled “The open-core boundary”ADR-0002 splits the code in two:
- Everything outside
ee/is Apache-2.0. That covers dedup, claims, overlap, questions and decisions, the MCP server and every adapter, both launchers, the CLI, the merge check, the basic Slack bot, the model router, metrics,zt statsand the audit chain. - Code under
ee/is source-available under the Zentri Enterprise License. It is meant for SSO and SCIM, audit export, multiple organizations, approval policy rules, advanced Slack flows and cross-project analytics.
Core code never imports ee/. New features go in the core unless the pull request says why they belong in ee/.
Not built yet
Section titled “Not built yet”ADR-0002 describes these, and none exist yet:
- License keys that gate
ee/at run time.server/internal/licenseis an empty placeholder. - The
ossbuild tag for a pure Apache-2.0 binary. - A CI job that builds and tests the core with
ee/removed. Withee/empty, the normal build already does.
server/internal/sandbox is an empty placeholder too. The launchers live in pkg/launcher and the sandbox helpers in cli/internal/sandbox.