Skip to content

refactor(api): keep plan diffs in one place and drop unwatched node-state views - #1588

Merged
kvlonge merged 7 commits into
mainfrom
refactor/plan-diffs-node-states
Nov 19, 2026
Merged

kvlonge merged 7 commits into
mainfrom
refactor/plan-diffs-node-states

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

Plan diffs lived in two places, the node-states cache refreshed every target anyone had read for the life of the server, a build invalidated the node list's ETag, and the publication cache was generic over the one type it held.

Changes

  • Plans: the location stores every model diff beside the plan document, and the server reads diffs only from there. The second diff type is gone.
  • Node states: a change stream holds its target watched. A signal refreshes watched targets and drops the rest, keeping any with a refresh pending or due, and the next read loads them again.
  • /nodes no longer embeds states, which /node-states serves. It is serialized once per snapshot and tagged with the snapshot ID.
  • UI: the catalog keeps the states it holds while the list and states are read again. A node page or overview opened without the held list reads the states after the list is allowed, so a partial viewer is refused once.
  • The publication cache holds prepared publications by name, not a type parameter.

Plans stored with diffs inside the document show line counts without diff text until they expire.

Verification

  • Failing-first tests:
    • a plan's diffs are stored apart;
    • an unwatched target is dropped;
    • a target with a refresh pending stays;
    • the catalog keeps its states across a reconnect;
    • a node read without a listing gets its states.
  • Node-states, person-plans, publication-cache and plan-display tests on SQLite and PostgreSQL; UI vitest and svelte-check.
  • make check-ci on the final head.

A location always detaches model diff text and the server reads a diff only
from where it stored it, so the inline lookup and the copied diff type go.
…by snapshot

The node states cache kept refreshing every target anyone had read for
the life of the server. A change stream now holds its target watched
while it is open; a store signal refreshes watched targets and drops the
others, which the next read loads again.

The node list no longer embeds states, which node-states serves, so it
is serialized once per snapshot and its ETag is the snapshot ID: a build
no longer invalidates it.
SnapshotSlots and cached only ever held prepared publications, so they
name CachedPublication instead of a type parameter.
The node list no longer carries states, so the catalog keeps the states
it holds while the list and states are read again, and a node page or
overview opened without the held list reads the states with it. The
server keeps a dropped target's entry while a refresh is still pending,
so the refresh cannot push the old entry's versions to a new stream.
…artial overview once

A refresh that finds its target changed again runs another pass, so the
entry stays held while one is due as well as while one is scheduled. A
read without the held node list asks for the states only once the list
is allowed, so a partial viewer's refusal is recorded once.
@kvlonge
kvlonge enabled auto-merge November 18, 2026 22:27
… tests

The node list no longer carries states, so the catalog-read and
check-count tests read them from node-states as clients do. The
wide-listing statement guard still counts the node list alone, within
its unchanged budget.
@kvlonge
kvlonge added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 18, 2026
…ode-states

# Conflicts:
#	crates/sqlbuild-orchestration/src/warehouse_metadata/models.rs
@kvlonge
kvlonge enabled auto-merge November 18, 2026 23:17
@kvlonge
kvlonge added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 8816dfa Nov 19, 2026
35 checks passed
@kvlonge
kvlonge deleted the refactor/plan-diffs-node-states branch November 19, 2026 00:17
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.

1 participant