Documentation

Project links (cross-repository)

ADR 0075 "Cross-repository links", task T022 (link scopes). Package internal/projectlink. The project link pass is application-side: it reads the stored nodes of every member of a project (graphvein-project.yaml, docs/cli/project.md) and writes links owned by the project (store.ProjectLink). No member snapshot changes and the indexer contract is unchanged.

Inputs

For each member, from the store: its latest run (Repositories) and its route, client_call and api_operation nodes (Nodes with a kind filter). From the manifest: member order, consumes with selectors, and each member's link scopes with their own consumes. A member without a stored index has no run and no nodes.

Sources are the stored client call alternatives (paths entries of client_call nodes) and OpenAPI operation path entries (paths of api_operation nodes). Targets are stored route nodes of other members, and, for the scope overlay (rows PL-S1 to PL-S3), of the source's own member. Matching reuses the client matcher (clients.NewStoredRouteMatcher) over contract attributes: method, path templates with optional and trailing-slash flags, route path scope, framework and equivalent_registrations; the call's base kind, origin and origin resolution; the operation's exact tier. Tiers and confidences are those of client matching and OpenAPI route correspondence: 0.9 exact without origin, 0.7 exact with an origin or an assignment-derived origin, 0.6 suffix; operations 0.9 without server origins, 0.7 with.

Two stored attributes (extractors-47) let the pass match as the in-repository linker does:

The link precision rules LF-1 and LF-2 of client matching are rules of that shared matcher, so they hold here too (T034). A call with an origin never takes a provider route without a literal segment (a catch-all, /{id}, /), except a call of another member whose literal origin a covering consumes entry names in origins (PL-L4): that entry is the proof LF-1 asks for. An assignment-derived origin is never proven. A link scope of the same member is matched with the member's own matcher, where LF-1 holds even when a consumes entry names the origin (a possible miss, never a false link). An OpenAPI operation path entry with literal origins (its spec's servers) never takes another member's route without a literal segment unless a covering consumes entry names one of its origins in origins, the routes of the spec's own member included (as in the repository's own correspondence). A link whose origin is assumed, not proven (a call's unresolved origin, an operation whose origins no consumes entry names), appends "origin <origin> assumed to be <provider>'s server" to its stored assumption. A catch-all that wins only because a call parameter stands where other routes of the endpoint have literal segments leaves the call ambiguous (LF-2), as inside the repository.

Routes served below a prefix their code does not fix carry no paths entry, only unresolved_prefix_paths entries (T033, ADR 0084). The shared matcher's unknown-prefix tier (rows UP-13..UP-21 of client matching) replays on stored nodes, and the pass links on it only through a declaration (rows UP-25 and UP-26):

Fixture: testdata/fixtures/projectlink-unknown-prefix, test TestUnknownPrefixProjectScenarios (scenarios without a declaration, with one, with an origins selector, and with two declared providers).

TestStoredMatcherReplaysClientLinks (internal/index) checks on the client fixtures that the stored attributes reproduce every in-repository alternative result (status, candidates and count).

Next.js route targets

TOP-1 of 2026-11-18 (T022 x T024; NX-S had left them out). Next.js route handlers and Pages Router API routes of another member are targets (clients.NewProjectRouteMatcher), under the project rules:

Each candidate provider is matched separately (one matcher per provider endpoint, see "Link scopes"). A provider is possible when its matcher links or finds an ambiguous tie for the source. A less specific route in a second provider still makes that provider possible: specificity orders routes inside one server, but which server a call reaches is exactly what is not proven.

Step B5. A member's scopes (manifest) declare named folders inside it, typically several servers in one repository (express apps/app, apps/user, apps/article; ADR 0021 note). A node belongs to the declared scope whose folder holds its file (path + / is a prefix of the node's file); every other node belongs to the member's default scope. Scopes never nest (manifest rule scope-overlap).

Candidate providers

Claim contract

One row per source form. Every source (a client call, or one path entry of an operation) gets exactly one row; a form no row lists goes to PL-U, which claims nothing. Rows are checked in table order; the first that applies decides. PL-R4 (B3: a member declaring link scopes got no link until unit B5) was removed when B5 implemented scopes; its ID is not reused. The code table is internal/projectlink/contract.go, and TestContractTable keeps both tables and the per-row cases 1:1.

id form claim refusal / unknown
PL-S1 a call alternative its own index left ambiguous, in a member that declares link scopes, covered by a consumes entry of its consumer naming its own repository, where exactly one covered endpoint has a candidate, it is a scope of the own repository, its matcher links one route, and that route is one of the in-repository ties calls_route to that route in the same repository, at the matcher's tier and confidence, assumption naming the entry and "resolves an in-repository ambiguity across link scopes" (project overlay; the member's snapshot keeps ambiguous) -
PL-S2 an operation path entry in the same position as PL-S1 (exact tier only) documents_route to that route, 0.9 or 0.7, assumption as PL-S1 -
PL-S3 any other source its own index left ambiguous, in a member that declares link scopes, covered by a consumes entry of its consumer naming its own repository: two or more covered endpoints have candidates, the one endpoint is another repository or is itself tied, no declared scope holds one of the in-repository ties, the tie list is truncated, or a covered provider has no stored index none (outcome ambiguous; candidates the declarations leave, or the in-repository ties) -
PL-R1 a source the member's own index decided, other than PL-S1 to PL-S3: a call whose own status is wrapper, linked, ambiguous, test_only or generated (committed bundler output, ADR 0085), an alternative (of a call with several or conditional alternatives) whose own status is linked, ambiguous or test_only, or an operation path whose own status is linked, ambiguous or test_only none: the repository's own result stands (outcome in_repository) -
PL-R2 a source without a template: own status dynamic (a call with one unconditional alternative, or an alternative) or unresolved (operation), a null template, or a call with no paths (an Orval call bound to the wrong generated file) none (outcome dynamic) -
PL-R3 an unmatched alternative of a call with several or conditional alternatives that has no stored base (an index before extractors-47) none (outcome unproven): the alternative's base is not known -
PL-R5 a call alternative with a literal origin that no covering consumes entry names in origins none (outcome unmatched, reason literal origin) -
PL-R6 a source in a member with consumes that no entry covers none (outcome unmatched, reason not declared) -
PL-R12 an operation path entry without consumes, in a member that itself stores route nodes (a server's own spec documents its own server; T022 review) none (outcome unmatched, reason "spec of a server repository"): only a consumes entry naming the provider links it across (PL-L6) -
PL-R7 a candidate provider without a stored index none (outcome incomplete, naming the provider): its routes could make the source ambiguous; the indexed providers' matching routes are listed as candidates (T022 review), or the reason ends "no route of an indexed provider matches" -
PL-R8 no candidate provider has a candidate route none (outcome unmatched) -
PL-R13 the only matches of a call alternative in its candidate providers are routes' unresolved_prefix_paths entries (routes served below a prefix their code does not fix; T033, row UP-25 of the unknown-prefix contract), and no consumes entry naming the provider covers it (no consumes, or an entry naming the source's own member) none (outcome unproven, reason "only routes whose prefix is not read from code match ... without a consumes entry naming the provider"): neither the server nor the prefix the call reaches is shown (decision U5) -
PL-R9 only test-scope routes match a production source none (outcome test_only, candidates listed) -
PL-R10 exactly one possible provider (a member, or one link scope of a member), with tied routes none (outcome ambiguous, candidates listed) -
PL-R11 two or more possible providers (members, or link scopes of one or more members) none (outcome ambiguous, candidates of every provider listed) -
PL-L1 a call alternative without consumes, one possible provider, one route calls_route at the matcher's tier and confidence, assumption "matched across project repositories; base URL not proven" -
PL-L7 a call alternative covered by a consumes entry that names the provider, another member (for a literal origin, an entry whose origins names it: row UP-21), one possible provider, one route, matched only on its unresolved_prefix_paths entries (row UP-26 of the unknown-prefix contract) calls_route, inferred, 0.6, match: "suffix", link attribute route_prefix: "unresolved", assumes UP-V1 (UP-V2 for an unresolved base) and UP-V3, assumption naming the entry (and its selector) and ending "route prefix not read from code: assumes ..." -
PL-L2 a call alternative covered by a consumes entry without a selector, one possible provider, one route calls_route at the matcher's tier and confidence, assumption naming the entry -
PL-L3 a call alternative covered through bases or path_prefixes of a selector (no literal origin), one possible provider, one route calls_route at the matcher's tier and confidence, assumption naming the entry and its selector -
PL-L4 a call alternative with a literal origin covered through origins, one possible provider, one route calls_route at the matcher's tier and confidence (0.7 for a literal origin), assumption naming the entry and its selector -
PL-L5 an operation path entry without consumes, in a member that stores no route nodes (a frontend's or client's spec), one possible provider, one route (exact tier only) documents_route, 0.9 or 0.7 as inside one repository, assumption "matched across project repositories; base URL not proven" -
PL-L6 an operation path entry covered by a consumes entry, one possible provider, one route (exact tier only) documents_route, 0.9 or 0.7, assumption naming the entry (its selector only when an origins entry named the server origin) -
PL-U anything else: attributes that do not decode to the shapes above, an own status outside the listed values none (outcome unknown) -

Notes:

Known gaps

Report a problem with this pageSource: docs/extract/project-links.md