Skip to content

fix: never fail the start page over a query answer that came back short - #694

Open
ashleycaselli wants to merge 1 commit into
masterfrom
fix/623-home-page-falls-back-to-cache
Open

fix: never fail the start page over a query answer that came back short#694
ashleycaselli wants to merge 1 commit into
masterfrom
fix/623-home-page-falls-back-to-cache

Conversation

@ashleycaselli

Copy link
Copy Markdown
Member

Closes #623.

The home page reported Configured home resource ... could not be found whenever the resource repository had latched a snapshot and that snapshot had no entry for the configured id. Latching, though, took any answer at face value — an answer with no rows at all included.

That is the wrong reading of an empty answer. The query API is a set of instances with independently built indexes, so a short or empty result set is a routine kind of failure and not news that the resources are gone. One such answer latched an empty snapshot, ran removeStale() over it (wiping every MaintainedResource instance), and turned a passing API hiccup into the page declaring its own configuration broken — with the persisted cache that could have covered it overwritten along the way.

What now stands between such an answer and the page

An emptied answer is not latched build() keeps the current snapshot when a new answer carries no resources at all and the current one has some, so what was fetched before — or restored from the persistent cache after a restart — goes on being served, instances and all.
A resource is not forgotten Every resource a snapshot ever held is kept by id, and findLastKnownById() falls back to it. findById() keeps its strict answer for the many callers that use it to ask whether an IRI is a maintained resource.
"Not found" has to be earned isAbsent() replaces isReady() as what the home page asks: a snapshot is latched, it holds resources, and neither it nor any earlier answer carried this id.

So the notice is reserved for a genuine misconfiguration — the configured IRI is none of the resources this instance knows, and never was. Anything else keeps the last known resource on screen, or goes on waiting for one.

The trade-off

An instance whose query API reports no maintained resources at all now waits on the loading state instead of showing the notice, because that case cannot be told apart from an answer that failed to carry them. That is the trade the issue asks for: the start page should not fail.

Tests

Four new, driving the repository through the answers it has to survive — an answer with nothing in it, an answer short of one resource, an id no answer ever carried, and a repository that knows nothing yet. All stubbed, so none of them goes near the network.

Suite: 1263 tests, green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TtcVArNfYKiiTVowsdkF44

The home page reported "Configured home resource ... could not be found"
whenever the resource repository had latched a snapshot and that snapshot
had no entry for the configured id. Latching, though, took any answer at
face value, an answer with no rows at all included: the query API is a set
of instances with independently built indexes, so a short or empty result
set is a routine kind of failure and not news that the resources are gone.
One such answer latched an empty snapshot, ran removeStale() over it --
wiping every MaintainedResource instance -- and turned a passing API
hiccup into the page declaring its own configuration broken, with the
persisted cache that could have covered it overwritten as well.

Three things now stand between such an answer and the page:

- An answer carrying no resources is not latched while the current
  snapshot has some, so what was fetched before (or restored from the
  persistent cache after a restart) goes on being served, instances and
  all.
- Every resource a snapshot ever held is kept by id, and
  findLastKnownById() falls back to it. findById() keeps its strict answer
  for the many callers that use it to ask whether an IRI is a maintained
  resource at all.
- isAbsent() replaces isReady() as what the home page asks. It says a
  snapshot is latched, it holds resources, and neither it nor any earlier
  answer carried this id -- so the notice is reserved for a genuine
  misconfiguration, and everything else keeps the last known resource on
  screen or goes on waiting for one.

The one case that now waits rather than explaining itself is an instance
whose query API reports no maintained resources at all, which is
indistinguishable from an answer that failed to carry them.

Four tests come with it, driving the repository through the answers it
has to survive. Suite: 1263 tests, green.

Closes #623.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtcVArNfYKiiTVowsdkF44
@ashleycaselli
ashleycaselli force-pushed the fix/623-home-page-falls-back-to-cache branch from 71ae55e to a32ae70 Compare September 8, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start page should never fail (now that we have persistent caching)

1 participant