Repository navigation
Conversation
ymichael
force-pushed
the
bb/live-data-stack-7-workflows-thr_yb23e6wnnq
branch
from
October 17, 2026 01:24
8189989 to
e928c32
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-7-workflows-thr_yb23e6wnnq
branch
from
October 17, 2026 03:36
e928c32 to
2d91f1d
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-6-storage-retention-thr_uzjechs2j6
October 17, 2026 03:36
This was referenced 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
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-7-workflows-thr_yb23e6wnnq
branch
from
October 17, 2026 04:51
2d91f1d to
eee5436
Compare
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
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-7-workflows-thr_yb23e6wnnq
branch
from
October 17, 2026 05:19
eee5436 to
3ac0069
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 19, 2026 22:20
1051535 to
9918fb7
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-7-workflows-thr_yb23e6wnnq
branch
from
October 19, 2026 22:20
3ac0069 to
5386514
Compare
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 19, 2026
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
force-pushed
the
bb/live-data-stack-7-workflows-thr_yb23e6wnnq
branch
from
October 19, 2026 22:49
5386514 to
4ed0dde
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-6-storage-retention-thr_uzjechs2j6
branch
from
October 20, 2026 19:46
52cd1df to
38dcf61
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-7-workflows-thr_yb23e6wnnq
branch
from
October 20, 2026 19:46
4ed0dde to
258e30d
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
ymichael
force-pushed
the
bb/live-data-stack-7-workflows-thr_yb23e6wnnq
branch
from
October 20, 2026 21:19
258e30d to
a5cc05c
Compare
Collaborator
Author
ymichael
added a commit
that referenced
this pull request
Oct 28, 2026
## Human comments ## What was wrong The Workflows UI kept itself fresh by hand. `src/app.tsx` subscribed to a `workflow-runs` realtime channel, ran a 15-second fallback poll while a run was active, backed failed reads off from 2 s up to 60 s, coalesced signal bursts, guarded against stale responses with request sequence numbers, and refetched when the tab or realtime connection came back. All of that duplicates what core's live-read lifecycle already does for `plugins/git`, `plugins/github-pr-status` and `plugins/docs`. This rebuilds #5660 on main. #5660 was stacked on SDK changes that never landed, and it also bundled new behaviour (inline Retry rows, Retry on errors), which this PR leaves out. No Plugin SDK changes were needed. ## What changed - `ui-contract.ts`: `workflowActiveRuns` and `workflowRunView` declare the origin thread's `runs:<threadId>` tag, and `workflowStopRun` invalidates it. - `service.ts`: `publishRunsChanged` now calls `bb.rpc.experimental_invalidate([`runs:<threadId>`])` instead of `bb.realtime.publish`. It runs at the same points as before: start, claim, phase or call change, settle, cancel. `realtime-channel.ts` is deleted. - `app.tsx`: the two read hooks are now `experimental_useRpcQuery`, and Stop uses `experimental_useRpcMutation`. The poll, backoff, coalescing, sequence guards and visibility/reconnect handling are deleted (−318/+78 in `app.tsx`). Load, error and refresh-error states map onto the same UI as before, and a loaded "Workflow run not found" is still replaced by a later read error. Stop keeps "Stopping…" until the refreshed view lands, as it did on main. - README: the paragraph describing the refresh mechanism is updated. **User-visible differences** (each one forced by the deleted poll; there are no other UI changes): - **Refresh warning text.** "Could not refresh: X. Retrying…" is now "Could not refresh: X." Without the plugin's backoff loop, the next attempt comes from the next invalidation, a reconnect or a resume, not a timer. Keeping "Retrying…" would bring back the false promise #5660 found. - **Elapsed labels.** On main, the duration labels in the message preview and the side panel only advanced when a poll or signal re-rendered them, about every 15 s (measured max gap: 15.0 s). The branch has no poll, so those labels now tick locally once per second while a run is active. That reuses the 1 s tick the composer card already had, and the label freezes once the run finishes. Without it they would freeze for the whole length of a long agent call. - **Banner on a failed refresh.** On main, one failed `workflowActiveRuns` refresh hid the composer banner until the next successful retry. The branch keeps showing the last loaded runs, because core retains data through refresh errors. - **Retries after HTTP failures.** Core does not retry HTTP failures on a timer; it retries network failures twice at 250 ms. A read that fails with an HTTP error now recovers on the next invalidation, reconnect or resume. For an active run, invalidations arrive with every progress change. Neither bug #5660 listed reproduces on main today. I checked with a probe test against main's code: the warning really did retry and cleared after recovery, and a later failure already replaced a cached "Workflow run not found". The second case now has a regression test. No server/daemon wire changes. No CLI or SDK surface changes. ## How you verified - `pnpm exec turbo run typecheck lint test --filter=bb-plugin-workflows`: 247/247 tests passed, lint reports 4 pre-existing warnings (main has 7 in `app.tsx`). - `pnpm exec turbo run build typecheck lint test --filter='...[origin/main]'`: 189/191 tasks passed. The two failures were in unrelated files (`install-machine-script`, `builtin-plugins`, `FilePreview`) while the machine's load average was 23–38. `FilePreview` passed on its first rerun; `builtin-plugins` failed on a different test on the first rerun (a 40 s hot-reload timeout) and passed 28/28 on the second. - New app tests drive real tag invalidations (`experimental_invalidateRpc`): - only the thread's own tag refreshes the banner, and runs stay visible through a failed refresh; - initial and refresh failures recover on the next invalidation, and the warning makes no retry promise; - a loaded missing run is replaced by a later read error; - the elapsed label ticks while running and freezes once finished. Reverting the missing-run branch or the label tick makes the corresponding test fail. - Service tests now assert `runs:origin` invalidations for start, claim, cancel, and phase and call progress. **Main vs branch on one real `pnpm dev` instance** (fresh store, scripted echo provider so agent calls are real worker threads with fixed `delay:` lengths). Each comparison swaps only `plugins/workflows` and reloads the plugin. Requests were counted in-page on `/rpc/workflow*`, and UI timing was taken from DOM changes against each call's server-side `finishedAt`: | Flow | main | branch | | --- | --- | --- | | 56 s run (2 parallel agents, then 1), thread open with banner + preview: workflow RPCs | 28 / 27 | 22 | | …of which 15 s fallback polls | 6 | 0 | | 60 s idle after completion | 0 | 0 | | Call finished → preview count updates | 20–39 ms | 27–62 ms | | Run finished → preview "Complete" / banner removed | 14–36 ms | 25–51 ms | | Preview elapsed label, max gap between updates | 15.0 s | 1.0 s | | Open in right panel → Stop button shown | 141 ms | 79–108 ms | | Click Stop → panel shows Cancelled (button stays "Stopping…" throughout) | 49 / 76 / 62 ms | 49 / 42 / 94 ms | | RPCs in the 10 s after Stop | 8 | 10 | | Tab hidden while two calls finish, then shown → preview + banner correct | 107 / 264 ms (0 reads while hidden) | 150 / 152 ms (1 read pair while hidden) | One branch Stop sample took 395 ms. Its first read started before the server had finished cancelling, and the next three samples were 42–94 ms. I also clicked through the branch in the running app: expanded the banner card, used Open in right panel, and clicked Stop (the CLI reports `cancelled`). I injected 500s on `workflowRunView` through browser request interception: the preview and panel showed "Could not refresh: injected outage." with the run still visible, and the warning cleared on the next invalidation. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Michael Yong <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
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
The workflows UI kept itself fresh by hand:
workflow-runssignals;Refresh errors could be hidden: a warning kept promising retries after they had stopped, and a cached "Workflow run not found" covered up a later failure.
Stack 7 of 13, stacked on #5659. #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
workflowActiveRunsandworkflowRunViewdeclare the thread'sruns:<threadId>tag, including when the lookup finds nothing.workflowStopRuninvalidates it on every successful response, includingstopped:false.bb.rpc.experimental_invalidateinstead of signals.experimental_useRpcQueryandexperimental_useRpcMutation, so it inherits core's cache, retry, reconnect and resume behaviour.realtime-channel.ts.Behaviour changes:
stopped:falsefor a run that had already finished.How you verified
pnpm exec turbo run build typecheck lint test --filter='...[origin/main]' --continue: 318/318 passed. Workflows: 252 tests.acaeb6fdf7) and pass here.stopped:false), refreshes viewsPart of #4944
🤖 Generated with Claude Code