Documentation

Docs / Reference

ADR 0075 - Multi-repository projects

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

Context

VISION.md (Foundation) promises projects that span several repositories, linked across repositories, with each repository's identities kept stable. The project plan moves this to launch 1 (item 2; ROADMAP.md) and requires the identity decision before any rationale or disposition persists (M4, first bullet), because those attach to node identity + content hash.

Today (inventory: the T022 task record (internal)):

Options considered

A. Multi-root workspace indexed as one logical repository with a per-root identity prefix (frontend/src/...).

B. Separate per-repository indexes, a project manifest, and a link-time cross-repository linker over stored nodes.

C. Hybrid: B for identity and storage, but the link pass parses both repositories again in one process (A's linkers) when both checkouts are present, falling back to stored nodes otherwise.

Decision (B; open points decided by the developer on 2026-11-18)

Option B. The developer's decisions on the investigation open points are recorded in the T022 task record (internal) ("Decisions (developer, 2026-11-18)") and applied below.

Identity rules

  1. A node's global key is the pair (repository ID, identity). The identity string is unchanged; no repository segment is added. Existing indexes stay valid; no re-index, no contract change.
  2. Adding a repository to, or removing it from, a project never changes any identity, in that repository or another.
  3. A cross-repository reference is always stored and sent as two fields (repository, identity), never as one concatenated string (API and MCP alike).
  4. Repository IDs of project members are set in the project manifest (repository: per member, required). A member's own graphvein.yaml repository: wins: graphvein project init and project add copy it into the manifest, and a manifest name that differs from it is refused whenever the member's checkout is read. The directory name is never used for a project member (it differs between machines). A remote URL is never the ID (forks, SSH vs HTTPS); it may be recorded as metadata and shown.
  5. IDs stay nonempty, without NUL and without @ref:. A project member ID must also be unique within the store (two projects sharing one store and one backend share that repository's index).

Project configuration

Storage

Migration 0005 (both dialects; migrations.Version 5) adds four tables. Text keys use COLLATE "C" on Postgres, as in migration 0004, so both backends order keys in byte order.

Store methods: Repositories (every stored repository, ref namespaces excluded, with its latest run by finish time), ProjectLinks (project, members, links and pass number in one read transaction; unknown project is ErrProjectUnknown), ReplaceProjectLinks and ProjectLinkRuns. ReplaceProjectLinks writes project, members, the complete link set, the outcomes and the journal row in one transaction, writing only links whose payload changed. A link whose payload differs only in its endpoints' runs (a member indexed again with the same content) is rewritten, so stored runs are the members' latest, but counted as unchanged; the journal's payload hash leaves the runs out for the same reason. A member record may carry the error that stopped graphvein index --project from indexing it before the pass (index_error): the pass linked its previous index, and readers show those links as stale. It refuses, writing nothing, an invalid set (ErrInvalid: an endpoint outside the members, an endpoint run other than the member run the pass recorded, a confidence outside (0, 1], an empty assumption, duplicate keys) and a stale one (ErrProjectStale: a member run that is not that member's latest run, or an endpoint node not stored with the recorded content hash). Freshness is computed by readers from stored data: the last pass's member runs against Repositories, and its manifest hash against the current manifest; nothing is written to mark links stale.

Project lock: postgres.ProjectLocker is a session advisory lock in its own class (714839212) with key LockKey(schema, project); sqlite.ProjectLocker is the store's index lock.

RetireProjectMember(project, repository) removes a member renamed from the UI, in one transaction: the project's links naming it, the outcomes whose source, target or candidates name it, its member record, and its whole stored index (runs, files, nodes, edges, diagnostics, fact cache, change journal and pins, ref snapshots). It refuses (ErrRepositoryShared), deleting nothing, a repository another stored project names, and a ref namespace. The link journal keeps its past passes. Options considered for the renamed member's rows: (a) keep them until removed by hand (B10; orphaned rows under a name no manifest uses); (b) migrate them to the new name (no re-index needed, but every run header and journal payload stores the repository name, and both backends' foreign keys would have to be rewritten in place); (c) remove them with the rename and re-index under the new name (chosen: the re-index was already offered, and nothing is rewritten). Removing at the next link pass instead would need the rename remembered between the write and the pass (across restarts and CLI passes), which the store does not hold.

Project index

graphvein index --project indexes each member checkout into the project store under its own index lock (released before the next member), then runs the pass under the project lock; graphvein status --project reports member freshness, the pass state and stale links (docs/cli/project.md). The manifest hash is computed over the declarations the pass reads (project name, member order, consumes, scopes), not the file bytes: paths and comments do not mark links stale. A member that fails to index does not stop the others; the pass runs with what is stored and records the failure. Options considered for that case: leave the member out of the pass (its sources and every call it could serve become incomplete, losing links that were right a moment ago), or abort the pass (one broken member blocks the project). Linking its previous index and marking those links stale keeps the links visible with an honest freshness.

internal/projectlink implements the pass; its claim contract table is docs/extract/project-links.md. Each candidate provider is matched separately with clients.NewStoredRouteMatcher (stored route nodes only); two or more providers with a candidate give ambiguous, even when one provider's route is more specific. Only sources the member's own index left unmatched are linked (and, since step B5, sources left ambiguous that a link scope declaration resolves); a candidate provider without a stored index links nothing. Every source gets an outcome with its row; outcomes are returned, not yet stored (T022 "B3 notes").

Two extractor outputs make the stored matcher equal to the in-repository one (extractors-47; additive contract-v1 attributes, contract version unchanged):

TestStoredMatcherReplaysClientLinks checks on ten client fixtures that the stored attributes reproduce every in-repository alternative result. Measured: react + express 27/27 calls and 19/19 operations as the composite (21 and 17 before); langflow src/frontend + src/backend as a two-member project reproduce all 167 composite links, 18 of them from 16 calls with several alternatives (PL-R3 before), 0 wrong.

A member's declared scopes are link endpoints: each scope (the routes in its folder) and the member's default scope (its other routes) has its own matcher, as a member has across repositories, so a call matching routes of two scopes is ambiguous (PL-R11) even without declarations. A source in a declared scope uses that scope's consumes (no inheritance from the member); a consumes entry with scope names one endpoint, an entry without it every endpoint of the repository. The pass resolves a source its own index left ambiguous as a project overlay only through a declaration naming a scope of its own repository, and only by narrowing: exactly one covered endpoint has a candidate, it is an own scope, its matcher links one route, and that route is one of the in-repository ties (replayed by the member's whole-member matcher). Everything else stays ambiguous (PL-S3) or keeps its own result (PL-R1). Overlay links are ordinary project links whose source and target are in the same member, with an assumption ending "resolves an in-repository ambiguity across link scopes"; the member's snapshot is unchanged. Claim rows PL-S1 to PL-S3 (docs/extract/project-links.md); B3's PL-R4 refusal is removed.

Options considered: (a) scopes only filter the candidates of declared consumers and leave undeclared matching per member (a call matching two scopes of one provider would link by specificity across servers, which B3 refuses across members); (b) let a declaration override an in-repository link as well (it would change a decided result on a declaration alone; not asked, left as a follow-up); (c) accept any route of the declared scope, even one outside the in-repository ties (a weaker or less specific route would win over the ties). The chosen rule is the narrowest: it can turn a link into an ambiguity, and resolves an ambiguity only to one of its own candidates. A shorthand string repository/scope in consumes was not added: repository IDs may contain /, so the mapping form (repository, scope) stays the only one.

Precision

Query, impact and change journal

Query and impact

Server and UI

Server read API

UI view

Suggestions

Step B6b (coverage recovery, T022 "B6b notes"):

Manifest editing from the UI

Manifest editing

Unknowns from unlinked outcomes (T022 review)

Locks

Consequences

Known gaps

Acceptance notes (2026-11-19)

Report a problem with this pageSource: docs/adr/0075-multi-repository-projects.md