Skip to content
Toolkit

ADR-0009: "Recently edited" is a server-sourced read across the registry, not a client-side merge

  • Status: Accepted
  • Date: 2026-08-13
  • Deciders: Cardsite platform team (workstream 001-renaissance, audit 01-D2)

Context

The dashboard's "Recently edited" panel was built in the browser from two fetches — GET /api/v1/links and GET /api/v1/biolinks — concatenated, deduped, sorted and sliced in DashboardPage.tsx. The dedupe key was the row id and a display label, and the two code paths spelled that label differently: the links path took it from the registry (linkTypeLabel('biolink') → "Bio page") while the biolinks path hardcoded 'Biolink'. A bio page arrived from both endpoints with the same link_id and two different labels, so the filter kept both and the same page was listed twice under two names (audit 01-D2, .archives/removal-safe/AUDITS-081226.md).

Two things changed the shape of the problem before it was fixed:

  1. The duplicate is no longer reproducible. ADR-0008 filtered GET /api/v1/links to type='link', so bio pages no longer arrive from both endpoints. The broken key survived; only the input that exercised it went away.
  2. The panel's coverage collapsed. With /links narrowed, the two fetches can produce short links and bio pages and nothing else — two of the eight registered link types. ADR-0008 recorded this narrowing against 01-D2 as deliberately unaddressed. A panel headed "Pick up where you left off" that cannot see six of the eight things a user can make is a worse defect than the duplicate row, and it is silent.

So the decision is not how to spell the dedupe key. Deduping is not the fix; client-side aggregation is the defect. Two endpoints can only ever produce two types, and no client-side merge can order what it cannot see — a top-5 assembled from two page-1 fetches is not the five most recently edited resources, it is the five most recent of whatever those two pages happened to contain.

There is also a standing rule this surface was breaking: AGENTS.md non-negotiable #4 — "Everything is a link. Add link types to @cardsite/link-model, never to a hardcoded list in a page." [...links, ...biolinks] is a hardcoded list of two types in a page.

Decision

"Recently edited" is one server-side read over the links table, scoped by the registry, and every per-row property is resolved from the registry.

  • A new endpoint, GET /api/v1/resources/recent?limit=5, returns the workspace's most recently edited rows across every registered link type, newest first — ordered by updated_at falling back to created_at, which is what "recently edited" claims. Its siblings order by link_id DESC, which is creation order; naming that "recently edited" would be the same class of untruth this finding is about.
  • The query's type allowlist is models.LinkTypes — the registry — so registering a ninth type puts it on the dashboard with no edit to the endpoint, and a row whose type is not registered is excluded rather than offered a surface it has no route for.
  • The client renders each row's name, icon and destination from @cardsite/link-model keyed on the row's own type: linkTypeLabel, the registry icon through one Phosphor→lucide map, and editPathFor(type, id) ?? listPathFor(type). No type literals remain in the page.
  • The dedupe disappears with the merge. Rows are keyed on id alone, which is correct: links.link_id is a single SERIAL sequence shared by every type.

resources is the noun. docs/GLOSSARY.md records Resource as Decided — "any single member of the Library, the noun to use in code, API and docs when the type does not matter". The collection's own name is still open (decision 001), so the route deliberately uses the settled word and not the unsettled one. This ADR does not pre-empt that decision.

The word is not unambiguous today: the admin portal's /admin/resources uses "Resources" for domains, projects, pixels, QR codes and more, and the dashboard's own "Resources" tile counts a third set. Putting the Library-member meaning in a URL makes the collision load-bearing, so it is recorded in docs/GLOSSARY.md under the words that mean more than one thing, with the API meaning named as the canonical one. That row is part of this change.

Consequences

The panel now shows what it says it shows, across the whole registry, from one ordered query. The class of bug is closed rather than patched: there is no second list to disagree with the first, and no display string load-bearing in a comparison.

What this buys beyond the fix:

  • /resources/ is now a place for type-agnostic views of the collection — the catalogue surface (phase 01 task 4) and any future cross-type search or activity feed have somewhere to live that is not one product's endpoint. That is also the risk: it must not become a second, competing way to read one type. It is read-only and cross-type by definition; anything type-specific stays on its own endpoint.
  • Two gates make the registry load-bearing. TestResourceHandler_Recent_RequestsEveryRegisteredType fails if the endpoint is ever scoped to a subset of models.LinkTypes; the frontend unit gate apps/web/src/lib/linkTypeIcons.test.ts fails if a registered type cannot produce a name, an icon and a destination — a recents row that shipped and does not work (non-negotiable #7).

Costs, accepted:

  • A new endpoint is new surface: an OpenAPI path, one more thing to keep in agreement with the registry, and a decision about scoped tokens. The alternative — eight client fetches — was worse on every axis.
  • Scoped API tokens cannot read it at all. A cross-type row set spans two scopes — links and biolinks are separate resources in middleware.scopeByPrefix — so admitting /resources/ under either would let a token holding one read rows governed by the other. That is a widening of an existing scope, invisible in KnownScopes(), and it would get worse as /resources/ grows. The scope table has no way to require a union, and inventing one for a dashboard panel is the wrong trade, so the prefix is absent from the table and deny-by-default closes it (ADR-0002). The per-type endpoints remain the integration surface; the panel is a session surface and unaffected.
  • The panel's reach stops at the links table. QR codes and PWAs live in their own tables and are not in the link registry, so they do not appear. That is honest today (they are outside LINK_TYPES) and it is not a new omission, but it means "recently edited" is not yet "everything you have touched". Widening it is phase 01 task 2's registry work and is gated on decisions 002 and 003 — this change is correct under every answer to both.
  • A links row of type splash_page now appears, and its destination is a page that cannot contain it. listPathFor('splash_page') is /splash-pages, which reads the splash_pages table — a different table — so such a row links to a list it is not in. This is the open ROADMAP item "A links row of type splash_page is listed nowhere", inherited whole from ADR-0008's consequences; the row was invisible before and is visible and mis-linked now. Excluding the type here was rejected: the resource exists, the user made it, and hiding it is the defect class this ADR is about. Fixing it is the product call about what a splash page is — decision 002's neighbour — and it stays on the ROADMAP where it already was.
  • Editing a bio page's blocks does not move it up the list. biolinks_blocks writes do not touch the parent links.last_datetime, so the commonest way to edit a bio page leaves its position unchanged. The ordering is still honest about what it reads; it is the write side that does not record the edit. Fixing that is a change to the block repository, not to this read, and it is out of this slice.
  • Every mutation that writes a links row invalidates qk.resources.all() as well as its own product key — seven hook files, plus two call sites in the bio-page editor that write through the service directly rather than through useUpdateBiolink (BiolinkSettingsPanel, BiolinkEditorPage). Without them the panel could serve a cached list that a save on another page had already invalidated (ADR-0005's ratchet: all mutations invalidate the relevant resource keys, including in legacy pages).
  • "Top performer" on the same page still merges /links and /biolinks and so still sees two types. It is the same class of defect and it is deliberately untouched here: it is a different finding, it needs a different query (highest clicks, not most recent), and folding it in would have made this change unreviewable. It is recorded on the ROADMAP.

Alternatives considered

  • Fix the dedupe key and stop (dedupe on id, take the label from the registry on both paths) — rejected. It is a two-line change that makes the duplicate impossible, and it leaves a panel headed "Pick up where you left off" showing two of eight product types with nothing recording why. The ROADMAP entry for 01-D2 says the surface needs deciding as well as fixing; this would have been the fixing without the deciding.
  • Fan out on the client — one fetch per registered type, merged — rejected. Eight requests on dashboard load, ordering that is still only approximate (each fetch returns its own page 1, so a type with many recent rows can crowd out an older one it should not), and the registry hardcoded into a page as a loop rather than as a list. It also gets slower with every product added, which is the direction the catalogue is going.
  • Re-open GET /api/v1/links to all types with a type filter — rejected outright. That is ADR-0008 reversed one release after it shipped, and it restores the collection/product name collision that started the audit.
  • Add ?recent=1 to an existing per-type endpoint — rejected. Every existing list endpoint is defined by its single type; a cross-type read is not a mode of a per-type read.
  • Name the route after the collection (/api/v1/library/recent) — rejected. "Library" is decision 001 and unanswered; shipping it in a URL would decide it by accident, in the one place that is hardest to change.

Source: docs/decisions/0009-recents-is-a-server-sourced-registry-wide-read.md

Library