Repository navigation
Conversation
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 17, 2026 01:24
bd5f83b to
704e48f
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 17, 2026 03:36
704e48f to
85bdbee
Compare
ymichael
changed the base branch from
bb/live-data-stack-2-plugin-reads-and-writes-on-cor-thr_agngjehcrj
to
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
October 17, 2026 03:36
This was referenced Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 17, 2026 04:51
6d9f283 to
32451bf
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 17, 2026 04:51
85bdbee to
20b1077
Compare
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 17, 2026 05:19
32451bf to
981caaa
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 17, 2026 05:19
20b1077 to
1051535
Compare
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 19, 2026 22:20
981caaa to
ecc94d6
Compare
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 19, 2026 22:20
1051535 to
9918fb7
Compare
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 19, 2026 22:49
ecc94d6 to
89ec38b
Compare
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 19, 2026 22:49
9918fb7 to
52cd1df
Compare
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
…mutations (#5640) ## Human comments ## What was wrong **Stack 1 of 14.** Merge order: #5640 → #5658 → #5688 → #5661 → #5669 → #5666 → #5659 → #5660 → #5663 → #5667 → #5668 → #5677 → #5673 → #5670. When a core write changes data that other screens or clients show, someone has to remember to refresh every query that depends on it. Today each write does this by hand: a cache-owner module plus a system change kind (for UI preferences, `ui-preferences-changed`, routed through the realtime registry). Plugins have no equivalent at all, which is #4944. This is step 1 of a stack that replaces #5582. Here, a contract declares what a read depends on and what a write changes, and the client refreshes from those declarations. The plugin hooks in later steps will be thin wrappers over this same core path. ## What changed - **`@bb/domain`:** a new `ContractTagDeclarations` type with `tags(input, output)` and `invalidates(input, output)`. It contains types only. - **`@bb/hono-typed-routes`:** - `defineRoute` accepts these declarations. - After a 2xx JSON response, `typedRoutes` publishes the route's `invalidates` tags through a new `invalidateTags` option. - Registering a route that declares `invalidates` throws if that option is missing. - **Server:** `hub.notifyTags` batches tags within a microtask and sends `{type:"changed", entity:"tags", tags}` to every connected client. This is a new message between the server and the app; the daemon is untouched, so `HOST_DAEMON_PROTOCOL_VERSION` is unchanged. - **New `@bb/query-tags` package:** - Tags are registered on queries through `meta`. - `invalidateTags` refreshes the queries whose data carries a matching tag, within a scope. Core uses `core`. - A read that is in flight restarts only if an overlapping invalidation arrives during it. - `runTaggedMutation` settles only after the affected active reads have re-read. That includes a first load whose tags aren't known yet, which the reference branch got wrong. - **App:** - The realtime cache effects pass `tags` messages to `invalidateTags`, and hold them while the tab is hidden. - A small `route-tags.ts` adapter connects route contracts to these reads and mutations. - **UI preferences, which prove the mechanism:** - The read declares `ui-preferences`, and update and reset invalidate it. - The sync engine saves through `runRouteMutation`. - `ui-preferences-cache-owner.ts`, the `ui-preferences-changed` change kind and its registry entry are deleted. - The sync keeps each acknowledged entry, so a failed re-read neither reverts the preference nor bases the next write on a stale revision. Not in this PR: plugin SDK hooks, plugin RPC, plugin WebSocket targets and the CLI. Those come in later steps of the stack, each with its first caller. ## How you verified - `pnpm exec turbo run build typecheck lint test --filter='...[origin/main]' --continue`: 296/296 tasks passed. - Lint has no errors, and the app's warnings match `origin/main`. - New tests in `@bb/query-tags` cover tag matching, scope isolation, stale inactive queries, in-flight races, and refresh failure and recovery. - The first-load race test fails against the reference implementation. - `@bb/hono-typed-routes` tests: invalidations are published only after 2xx JSON responses, and registration fails without the publisher. - Two isolated browser profiles against a source server: a preference write in one refreshed the footer preferences in the other, and a composer draft survived the refresh. - Two WebSocket clients with no subscriptions both received the `tags` message after an HTTP write. - Sidebar perf, five paired samples per checkout with 3,000 threads, against `origin/main`: | Metric | Main median (range) | Branch median (range) | | --- | ---: | ---: | | Mount, ms | 410 (404–419) | 408 (359–412) | | Pin, ms | 72 (71–73) | 71 (70–73) | | Status patch, ms | 69 (69–71) | 70 (69–73) | | Membership refresh, ms | 103 (103–107) | 107 (103–108) | | Query observers | 13 | 13 | The ranges overlap and the number of query observers is unchanged. These samples were taken before the unused pieces were removed; removing them deleted code paths without changing the read path. Part of #4944 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 20, 2026 19:46
89ec38b to
d23a5ad
Compare
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 20, 2026 19:46
52cd1df to
38dcf61
Compare
ymichael
force-pushed
the
bb/live-data-stack-4-concurrency-limit-thread-list-thr_adfmverzkq
branch
from
October 20, 2026 21:19
d23a5ad to
afd991d
Compare
ymichael
force-pushed
the
bb/live-data-stack-6-storage-retention-thr_uzjechs2j6
branch
from
October 20, 2026 21:19
38dcf61 to
64f6ffd
Compare
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Storage-retention kept its own refresh and ordering logic:
useRealtime("changed")and"policy-changed"handlers;host:changedand reconnect subscriptions;Because report data and host metadata were loaded together, a host rename with unchanged report JSON could leave the labels stale. A retention sweep didn't refresh reports, and a failed metadata load was swallowed.
Stack 6 of 13, stacked on #5666. #5640 is merged and #5688 is folded into #5658. Review only this PR's commits. Merge order: #5658 → #5661 → #5669 → #5666 → #5659 → #5660 → #5663 → #5667 → #5668 → #5677 → #5673 → #5670.
What changed
src/contract.tsdeclares the read tags and theinvalidatesof every write.metadataRPC returns the persistent-host list and primary host ID through the server SDK, so metadata refreshes on its own.bb.rpc.experimental_invalidate.app.tsxusesexperimental_useRpcQueryfor state, hosts and metadata,experimental_useRpcMutationfor every action, andexperimental_useRpcRefresh.Behaviour changes:
Optimistic updates (this PR): settings switches and selects update instantly through the shared optimistic option, and roll back if the write fails, as on main.
How you verified
pnpm exec turbo run build typecheck lint test --filter='...[origin/main]' --continue: 318/318 passed. Storage-retention: 79 tests, lint clean.Part of #4944
🤖 Generated with Claude Code