Documentation

Docs / Reference

ADR 0087 - Multi-index server and the workspace registry

Status: Accepted (delegated review, 2026-11-25)

Context

Until now one graphvein serve process served one index: a repository (serve <path>) or a project (serve --project). Switching to another repository meant stopping the server and starting another, and the UI could not list what else was indexed on the machine. The T038 workspace (the T038 task record (internal); developer decisions of 2026-11-19/20 and the mockup round of 2026-11-24, every recommended default accepted) asks for a sidebar listing every indexed repository and project with its freshness, switching without a restart, keeping recently used indexes warm, adding a folder from the UI, and links that name the index.

Constraints: ADR 0041 (loopback only, Host allow-list, Fetch Metadata and Origin checks, read-only store for requests), ADR 0052 (the index lock; a re-index runs inside serve with its own writer store), ADR 0075 (projects: one store per project, members keyed by repository), the boundary rules (only internal/egress opens sockets, all persistence through the store interface) and VISION's precision rule: nothing may be shown as fresh or present that the store did not prove.

Options considered

Where the list of indexes lives (D1)

How serve starts (D2)

Whether the command-line forms register was left open by the design round; they do: serving an index is the interactive act that puts it in the sidebar. graphvein index does not register (D1 listed it): index runs in scripts, CI, temporary copies and corpus checks would fill the registry with folders that vanish. This is an open point for the developer.

One process, several indexes

Warm indexes (D3)

Freshness of entries that are not current (D4)

Typed folder paths (D5)

Recorded as the revision of ADR 0041 (typed paths behind the guards): POST /api/v0/workspace/check validates a path and returns a one-time confirm value; POST /api/v0/workspace/add needs it. Rules and refusals are the claim rows WS-21..WS-38.

Removed or moved folders (D6), cancel (D7), projects (D8)

id = <name>~<first 8 hex of SHA-256(kind, NUL, path, NUL, name)>: the name keeps a link readable, the hash separates two entries of the same name and is the same on every start. A link carries ws=<id> (and repository= for a project member); an id the server does not have is 404 unknown_entry, never another index in its place.

Decision

  1. internal/workspace owns the registry file: strict YAML (version: 1, unknown fields refused), atomic replace through a temporary file in the same folder, a damaged file reported and never rewritten, entries never dropped except by remove. The store location is not stored: each entry is opened from its folder as the CLI opens it, under the serve process's GRAPHVEIN_SQLITE_PATH / GRAPHVEIN_POSTGRES_URL, so no URL or secret is ever written. (D1 suggested recording the store location and a Postgres variable name per entry; the process environment already decides it for the CLI, so storing it would only let the two disagree.)
  2. server.Options.Workspace makes a server a multi-index server: the command layer passes the registry, the command-line index (opened by the caller, never closed by the server) and an Open function that opens an entry exactly as serve <path> or serve --project would. Every serve form now builds a workspace server; server.Options without Workspace keeps the single-index server unchanged (tests, server.Reader for MCP).
  3. Endpoints: GET /api/v0/workspace, POST /api/v0/workspace/check, /add, /remove (docs/cli/serve.md "Workspace"); ws= on every per-index endpoint. Claim contract: workspace (WS-1..WS-40, WS-D).
  4. GET /api/v0/index/run always carries repository (empty in project mode, beside project), so the UI's parser accepts project mode.

Consequences

Revision 1: registry lock, folder casing, status freshness

Recorded after the T038 server follow-ups; accepted with the ADR on 2026-11-25.

Registry writes

Folder casing

Status freshness

Revision 2: review (list precision, typed-path rules, one folder one entry)

Status: Accepted (delegated review, 2026-11-25)

An independent review of the first build found the list claiming more than it knew, a read path writing into user folders, and gaps in the typed-path rules. The decisions below are proposed for review; claim rows changed: WS-4, WS-8, WS-9, WS-11, WS-15, WS-20, WS-36, WS-37; new rows WS-53 and WS-54 (server) and WS-55 and WS-56 (web UI), taken from the reserved range WS-41..WS-69.

The list never writes and never claims more than a check found

Adding and indexing

Typed-path rules (R8)

One folder, one entry; one SQLite file, one index

Revision 3: names shared in one store, neutral not-indexed dot

Status: Accepted (delegated review, 2026-11-25)

The review left one wrong-fact risk open: under GRAPHVEIN_POSTGRES_URL every entry's index lives in one database, which keeps a repository's facts by its repository ID and a project's links by its name, not by folder. Two registered folders with one repository name (two copies of a checkout, or two unrelated folders that happen to share a directory name) read whichever folder was indexed last, and a freshness check of one compares its files with the other's facts (two identical copies would even read "fresh"). New claim rows WS-57 (server) and WS-58 (web UI); rows WS-8, WS-15, WS-20, WS-41, WS-54 and WS-55 changed.

Revision 4: re-check of the fix rounds

Status: Accepted (delegated review, 2026-11-25)

A focused re-check of revisions 2 and 3 found four places where the server still said more than it knew. Claim rows changed: WS-8, WS-9, WS-15, WS-53, WS-57.

Known gaps

Review notes (delegated review, 2026-11-25, T038)

Accepted with Revisions 1-4 after the final CI gate of 2026-11-25 (CI runs 45627357238, 45632313364 and 45638139948 (the last green on Linux, Postgres and Windows; postgres log 0 FAIL, 291 /postgres PASS): Linux, Postgres and Windows). One independent review (R1-R9) and a focused re-check (W1-W4), each fixed with tests from the review's inputs; the rounds converged. Measured: eight open indexes (langflow, opencollective-api and others) about 107 MB, the largest cached answer about 0.8 MB; no stale answer after a CLI re-index in another process, a graphvein.yaml edit or a project link pass. Reads never write to disk; a moved folder is folder_gone; system folders are refused (WS-53, with Windows prefix forms and os.SameFile); a shared Postgres store refuses entries that share a name (WS-57). Known gaps as recorded above (a shared store cannot tell which folder its facts came from; the Windows SameFile path is covered by Windows CI only).

Report a problem with this pageSource: docs/adr/0087-multi-index-server.md