ADR-0005: Collaboration / session model#

  • Status: Accepted
  • Date: 2026-10-01

Context#

Several users must be able to work on one project at the same time, like players on a game server (DESIGN_GOALS §4). Single-user use must take the same code path.

Options considered#

  1. File locking / check-out — simple, but no real concurrent work.
  2. CRDTs (automatic merge) — good for text, but can produce merges that are valid data yet invalid engineering (e.g. a span referencing a deleted structure, broken constraints).
  3. Authoritative server with a validated, ordered command log.

Decision#

  • Authoritative server (ohl-session) owns the model; clients send commands, the server validates, applies atomically, appends to the log and broadcasts change sets. Single-user = in-process server.
  • Optimistic client prediction: edits apply instantly locally, are confirmed by the server, rolled back on rejection.
  • Conflicts: per-object versions; stale destructive edits are rejected with a clear message; soft locks on a section while being dragged; presence indicators.
  • Undo (confirmed): per user — each person undoes only their own changes, via inverse commands.
  • Admin rollback (confirmed): admins can roll back other users' commands, revisions, or everything after a point in time.
  • Roles & permissions (confirmed, detailed later): default roles viewer / designer / checker-approver / admin, custom roles from fine-grained permissions, scoped per project, area/chunk and object type; some actions admin-only; all admin actions logged. See DESIGN_GOALS §4.
  • Compute: server computes authoritative results; clients compute local previews with the same engine while dragging.
  • Interest management: clients receive only the chunks they view.
  • Transport: QUIC (quinn) for desktop; WebSocket fallback (firewalls, future web client); versioned compact binary messages.
  • Security: TLS + per-session access code in v1; OIDC/SSO later.
  • History: the log is the basis for git-like version control — revisions, branches for design alternatives, merge, tags (DESIGN_GOALS §7).

Consequences#

  • Every edit in the codebase must be a command: no direct mutation of the model from the GUI.
  • Requires a running session even offline (in-process, invisible to the user).

Implementation (alpha, 2026-10)#

ohl-server: one authority thread owns the session; clients join with an invitation (address, access code, certificate fingerprint), receive a consistent copy of the project file (VACUUM INTO), and replay the broadcast operations with the same session code, checking the log sequence numbers (a mismatch: join again). Users known to the project join only with a personal invitation (its code derived from the server's secret and the name). Not yet: optimistic prediction (edits wait for the answer), interest management (the whole project is copied), the WebSocket fallback for the desktop client, OIDC.

Web client (2026-10): an optional HTTPS listener (same self-signed certificate; the browser trusts it once, the user compares the fingerprint) serves an embedded HTML/JavaScript client and a WebSocket speaking the same JSON messages (ClientMsg/ServerMsg, one per text message), checked by the same authority, codes and size limits. A browser keeps no replica: the welcome has size 0 and a new ServerMsg::Scene follows — the line, its wires solved on the server in one weather case (cached per line revision, one solve at a time) — and again after each edit of the line or its libraries. The protocol number is unchanged: QUIC clients never receive a Scene.

Amendment (2026-11-18): country server#

ADR-0013, in active development (not approved yet):

  • The authority owns a session over a store (PostgreSQL on a country server, SQLite on a desktop server and alone); still one writer, one order, each command one transaction committed before it is broadcast.
  • Interest management is built as working sets and context tiles: a client holds the routes it picked (full, editable) and light tiles around its camera; it keeps a partial replica fed by the operations that touch what it holds, with a heartbeat carrying the current seq (protocol 3). A joining desktop no longer gets a copy of the whole project.
  • Roles and permissions are detailed: named roles (shipped: viewer, designer, checker, library maintainer, line admin, network admin) of permissions (see, edit, create, delete, review, export, lock, request, manage rights), assigned to users or groups on a scope — almost every element kind and every library kind is a scope; default deny; an explicit deny overrides grants; one function resolves it for commands and for everything the server sends. A desktop project keeps today's three roles and edit grants.
  • OIDC/SSO sign-in becomes needed on a country server.

Note (2026-11-19): protocol 3#

The server on a country server's database (ADR-0013 phase 5, ohl network serve) speaks protocol 3: a client follows models, routes and tiles; it receives the changes touching them (change), tile packages of the context (tile), "read again" for changes too large to follow (tiles_changed), a heartbeat with the stream's position and the last change sent to it, and catches up from its position (catch, catch_up); a desktop following a model replays its changes taking the server's log numbers. A file server speaks protocol 3 too, its messages unchanged (hello, applied, scene, …). A client of protocol 2 (the alpha) is refused with a message saying to update OpenOHL. The messages: data model.

View this page's source on GitHub