Documentation

Docs / Reference

ADR 0089 - Search and couldn't-read endpoints

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

Context

2026-11-24 adds three UI features that need server support (T040): a jump-to palette (Ctrl+K) across routes, Explorer operations, tables, files and symbols; a per-repository page "What Graphvein couldn't read"; and a "Report a wrong fact" flag that opens the public wrong-fact issue form, which must render nothing until the project's repository is public.

What existed: the route list (/api/v0/api/endpoints), the schema sets, the generated OpenAPI document and the explorer's path values are served; files and symbols are not. Of the couldn't-read parts, unknown mount hops, routes without a path, dynamic and wrapper client calls and the compact route shapes (sections not read, depth caps) are already computed by existing endpoints; files not read, files read with syntax errors, scanner gaps, patterns built at run time, Go router forms outside the claim contract, files with no fact stored and unresolved in-code call totals are not served anywhere. The store marks every unrecognised file with language unknown, yet Dockerfiles, go.mod and compose files of that language hold facts (5 of express's 20 such files), so a language alone does not prove a file was not read. The unresolved call counts are written into an unresolved_calls diagnostic message and, since T009, also into the structured file node attributes unresolved_calls_external and unresolved_calls_unknown (every file node has them, so a zero means "none" only for the languages whose reader counts).

The design questions and their accepted defaults are recorded in the T040 task record (internal) and the 2026-11-24 UI decisions.

Options considered

Search:

  1. The UI loads every list (routes, schema sets, the document) and filters locally; files and symbols get list endpoints. Large repositories (dozzle 9,131 nodes) would ship every symbol to the browser.
  2. One GET /api/v0/search over the store with a substring filter, counts per kind and a limit, searching every project member in one call. Chosen.

Couldn't read:

  1. A generic diagnostics list the UI groups. The UI would re-implement the existing endpoints' rules (one rule, two implementations) and read counts from message text.
  2. One GET /api/v0/unread returning every part with counts and bounded lists, each part computed by the code that already serves it. Chosen.

Public-repository switch:

  1. A graphvein.yaml key with the issue URL. Any repository could point reports elsewhere, and the switch would be on wherever a file says so.
  2. A build-time setting served by GET /api/v0/ui. Chosen.

Decision

  1. GET /api/v0/search?q=&kinds=&limit=&editor= under the claim contract jump-search (rows JS-1..JS-20, D; amended by Revision 1 and Revision 2). The query is one string matched as an ASCII case-folded substring of fixed keys per kind (route paths, pattern and name; operation path keys of the generated document; table and symbol names and qualified names; file base names and paths). Ranking: tier (prefix, word start, substring), then key length, key, identity; kind groups by best tier, then the order route, operation, table, symbol, file. Each kind holds at most limit items (default 10, at most 50) with its total. Every answer names what was searched (run, stored files, files not read, scanner gaps) and states its absence as not_proven only. Under serve --project, repository= searches one member; without it every member is searched in one call (first= first, then manifest order), each item names its member, and per-member and project totals are given.
  2. GET /api/v0/unread?scope=&limit=&editor= under the claim contract couldnt-read (rows CR-1..CR-33, D; amended by Revisions 1, 2 and 3). Parts reuse the existing code: the explorer's unresolved and mounts lists from generateDocument, the calls endpoint's status rule, the endpoint list's compact shape, the schema views' scanner codes and not-read file codes (now one shared set). New parts read stored diagnostics (route_dynamic_pattern / route_dynamic_methods with the line from the documented <expression> at L:C-L:C message form through a tested parser; go_routes_unread verbatim, without a form total; amended by Revision 1, CR-38 form counts). "Files without facts" are, in a built-in run only, the files whose language has no built-in reader and from which no fact is stored; they are never called unread. Unresolved in-code call totals are the sums of the structured file node attributes over the files of counted languages without a not-read or syntax-error diagnostic, never a message. No count adds units. Under serve --project the page is per member, or every member plus project totals (null, with the members named, where a part is not available).
  3. Store. store.Query gains Contains (ASCII case-folded substring of name or qualified name; the SQL prefilter lower-cases the name columns, which both dialects fold at least in ASCII, and Go applies the exact test) and the Store interface gains FactFiles (the files of non-file nodes and of every edge's evidence, read in one transaction). No schema change.
  4. Public-repository switch. -X main.reportURL=<form URL> (scripts/build.sh REPORT_URL), empty by default; server.ReportURL accepts only an absolute https URL without user information, query or fragment. GET /api/v0/ui serves it as report_url, null while unset. The UI renders no flag while it is null and builds the prefilled form link (template wrong-fact.yml, fields version and shown) itself, after showing the user what will be sent.

Both endpoints are GET only behind the existing guards (Host allow-list, loopback listener, Sec-Fetch-Site and Origin checks, CSP), read through the store interface with the runs-before/after consistency check, and follow the per-repository handler pattern, so a multi-index server can dispatch them like every other member endpoint.

Consequences

Revision 1 (T040 server follow-ups)

Revision 2 (T040 review)

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

The review of the T040 UI found gaps that the contract left out (CR-33) and a search key the palette showed but never matched. Options for the couldn't-read gaps were a softer sentence on the page, or listing the stored diagnostics; listing them was chosen, because a sentence alone leaves the files and mounts unnamed.

UI decisions of the same review, recorded here because they bound what the page and the flag claim:

Revision 3 (T040 review, second fix round)

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

A route without a full path was still written by its stored pattern in three places: the couldn't-read page's "Routes without a full path" list (and its "Copy as text"), and the wrong-fact flag's endpoint fact (dozzle: GET /rules for …/api/notifications/rules). The pattern is the part below the innermost mount, so it reads as a different path.

No schema, store, contract-version or extractor-version change.

Revision 4 (T040 review, third fix round)

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

A re-check on owncast found a route registration counted as a mount and a route with no path labelled by its bare pattern; the wrong-fact prefill kept hosts after a scheme built in code and cut whole lines where one line was too long.

No schema, store, contract-version or extractor-version change.

Revision 5 (T040 review, fourth fix round)

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

The API section and the change views still called a route with no composed path "not mounted", which is false for owncast's ANY /* on the root router, whose path is only withheld; and the full-path sentence did not count files read with syntax errors.

No schema, store, contract-version or extractor-version change.

Known gaps

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

Accepted with Revisions 1-5 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)). One independent review and a focused re-check (counts equal the stored diagnostics on dozzle, owncast, miniflux and chatbot-ui at every scope), four fix rounds, converged. A regression it introduced (skip notices made freshness unknown for any repository with a binary file) was found at integration and fixed (scan.DeliberateSkip, regression tests per path). Wording for routes without a path is one classification (shadowed / path withheld / path not known). Known gaps as recorded above (test routes without a full path, pattern-based host redaction).

Report a problem with this pageSource: docs/adr/0089-search-and-couldnt-read-endpoints.md