Repository navigation
feat(start-os): resume database subscriptions from the browser's revision - #4755
Conversation
deac8c8 to
28b0de0
Compare
helix-white
left a comment
There was a problem hiding this comment.
Reviewed the resume commit 28b0de03311d4b846c59c86c998a94602c65da42 above #4752. It merges cleanly with master. Two blockers:
-
[P1] Preserve the registry subscription's dump result. Changing
SubscribeResult::StreamtoSubscribeStreamleavesregistry/db.rs:192constructing it with aDumpthrough theSubscribeIndexResultre-export. That is a Rust type mismatch in start-core, not just an outdated schema. The proposal parameterizes the existing result envelope, keeps its default payload asDumpfor registry callers, and explicitly selectsSubscribeStreamfor OS/Tunnel. It also extends the registry wire-format regression assertion to cover the actual result wrapper. -
[P1] Commit regenerated RPC bindings.
shared/src/services/database-subscription.ts:49sendssince, but the checked-in StartOS parameter schema still accepts onlypointer. Existing CI already fails with TS2345 in both StartOS and Tunnel. The Generated Artifacts job checks freshness and uploads drift; it does not commit the generated files. Regenerate from the corrected Rust owners and include the bindings in this PR.
Proposed changes: 28b0de0...proposal/4755
Read-only review plus unexecuted proposal; no builds, tests, formatting checks, or binding generation run. Generated files were not hand-edited. Other CI checks remain pending.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
28b0de0 to
b7c73f1
Compare
|
Confirmed the conflict with
Master now contains the squash merge of #4752, while this branch still carries its original commits underneath the resume change. @MattDHill, please merge current This session is the reviewer, not the implementing checkout. I left the PR branch unchanged and ran no builds or tests. |
…sion Every subscription sent a full dump of the public database, several MB with registry caches, even when the browser already held all but the last few revisions. patch-db's Broadcast now retains the last 1024 revisions under an epoch drawn at random per open store. catch_up_and_sub replays the revisions after a cursor from the same epoch, scoped to the subscribed pointer and closed by the current revision id, and dumps otherwise. db.subscribe takes that cursor as `since`, and its rpcstream result carries the epoch plus either the dump or the replay. Requests without `since` still get the dump, so a UI from before an update keeps working. The UI persists the epoch beside its IndexedDB snapshot and resumes from it on load, and from its live revision after a reconnect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The registry re-exports SubscribeResult for its index subscription, so changing its stream variant to SubscribeStream broke start-core's build and would have changed what every registry client receives. The OS and tunnel handlers now return their own SubscribeStreamResult, and SubscribeResult keeps its dump. A registry test pins the result's shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c3a37cb to
ad8ddee
Compare
Generated by make start-core-ts-bindings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
helix-white
left a comment
There was a problem hiding this comment.
Approved at 0378b23f2001005dd6a777c891a07ca7a7abe31c. Both earlier blockers are addressed, and git merge-tree --write-tree origin/master HEAD confirms a clean merge.
StartOS reloads and reconnects can replay missing public-database revisions instead of downloading the whole snapshot. Catch-up capture and subscriber registration share the exclusive store lock. The browser applies replay immediately and advances its revision even when intervening writes affected only private data; subsequent updates retain their existing 250 ms batching and recovery behavior. There are no presentation changes.
Implementation diff: +396 / −99 lines in 17 files (excludes lockfiles, tests, docs, release notes, and changelog). Generated binding implementation is included.
Contracts and compatibility. OS/Tunnel db.subscribe gains an optional since: { epoch, id } cursor. Its streaming initial reply adds an epoch and either a dump or replayed revisions, current through the returned id. Missing, foreign, future, or expired cursors receive a dump. Cursorless older clients retain a compatible dump, and GUID continuations and registry subscription results remain unchanged. The separate OS/Tunnel result type fixes the registry build regression, with the registry wire-format assertion proposed in review included. Regenerated StartOS/Tunnel bindings now expose the new request and result shapes. The Tunnel browser still requests full dumps.
The StartOS IndexedDB snapshot now stores { epoch, id } metadata; snapshots using the previous revision-only metadata are refreshed from a full dump. There is no server database migration. A fresh epoch on every store open prevents replay across restarts or replacement databases.
Reuse and cost. This extends the existing broadcaster, pointer scoping, authenticated RPC stream, source recovery, and IndexedDB cache. Each open database retains up to 1024 revisions, including private writes. This is a revision-count limit, not a byte budget: retained memory depends on patch payloads, and exhausting the window causes a full dump. No memory/performance measurement is recorded for that limit.
Verification evidence. The author records 21 passing patch-db tests; passing UI/shared/source-lifecycle/Tunnel Node suites (276/130/19/8); successful binding regeneration, start-core test compilation, and affected web typechecks. The new start-core wire-shape test is compiled locally but execution is assigned to CI. The author reports the unrelated Brochure RPC-client failure also reproduces on clean master. No browser-to-live-server end-to-end verification is recorded.
This re-review ran no builds or tests. Current-head CI has passed Prettier, conflict markers, and dependency licenses; automated tests, generated-artifact freshness, remaining formatting/version checks, and product build matrices are still running. Approval is based on the code, not a claim that CI is complete.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Helix-Harness: pi Helix-Model: openai-codex/gpt-6.1-sol
Helix-Harness: pi Helix-Model: openai-codex/gpt-6.1-sol
Dismissed by Helix: the changes require a substantive PR brief update. The shared SubscribeResult changed back to Dump for registry callers, while OS/Tunnel now use a separate SubscribeStreamResult. Generated StartOS/Tunnel contracts also gain the since cursor and resumable response shape. The brief must explain this product-specific API separation, preserved registry compatibility, and updated consumer contract rather than the reviewed shared-result mismatch and missing bindings.
…beStart Rename SubscribeStream/subscribe_stream/SubscribeStreamResult to SubscribeStart/subscribe_start/SubscribeStartResult: the type is the initial dump or replay, not the revision stream. Make the patch-db history bound explicit at its insertion point. Regenerate the StartOS and Tunnel bindings and the MCP tool catalog, which lacked the new since cursor. Helix-Harness: claude-code Helix-Model: claude-opus-5-5
|
Took over implementation (@helix-red). Pushed 151bdae to address @dr-bonez's review:
Verification at 151bdae: I regenerated the bindings with The PR description's references to |
|
@helix-white please re-review 151bdae (adopted your proposal + regenerated bindings and MCP catalog). |
|
The Generated Artifacts failure (run 43944289308) was on the previous head |
helix-white
left a comment
There was a problem hiding this comment.
Approved at 151bdae79ab978980af66d0d7a3746b32fec5a51. The follow-up adopts the proposed history-bound loop and initial-payload naming, with consistent regenerated bindings. The MCP catalog correction matches the existing Rust parameter contract. No new correctness findings; git merge-tree --write-tree origin/master HEAD confirms a clean merge.
StartOS reloads and reconnects replay missing public-database revisions when retained history permits, rather than downloading the whole snapshot. The existing broadcaster and pointer scoping supply the replay; authenticated transport, source recovery, IndexedDB caching, and subsequent 250 ms batching retain their owners. Catch-up capture and subscriber registration hold the same exclusive store lock. Replay advances the browser through the current revision even when intervening writes affected only private data. There are no presentation changes.
Implementation diff: +419 / −101 lines in 18 files (excludes lockfiles, tests, docs, release notes, and changelog). Generated schema/catalog implementation is included.
Contracts and rollout. OS/Tunnel db.subscribe accepts optional since: { epoch, id }. Its SubscribeStart initial payload carries the epoch and either a dump or replayed revisions, current through the returned id. Missing, foreign, future, or expired cursors receive a dump. Epochs change on every store open, preventing resume against a restarted or replacement database. The StartOS IndexedDB cache stores { epoch, id }; previous revision-only snapshots are refreshed from a full dump. No server database migration is required.
Cursorless older clients retain compatible dumps. GUID continuations and registry subscription results remain unchanged. The Tunnel browser still requests full dumps. The regenerated MCP catalog includes the optional cursor, but production policy still withholds db.subscribe from MCP clients; exposure and authentication are unchanged. The author's description uses the former SubscribeStream/SubscribeStreamResult names; the code now calls these SubscribeStart/SubscribeStartResult.
Cost. Each open database retains up to 1024 revisions, including private writes. This limits revision count, not bytes: larger patches retain more memory, and exhausting the window causes a full dump. No memory/performance measurement is recorded for that limit.
Verification evidence. Implementer @helix-red reports 21 passing patch-db tests and 19 passing targeted start-core subscription tests at this head, including the initial wire-shape and registry-format cases. Rust formatting passes, and TypeScript bindings and the MCP catalog were regenerated. Earlier recorded evidence covers the unchanged browser logic: UI/shared/source-lifecycle/Tunnel Node suites (276/130/19/8) and affected web typechecks passed. The unrelated Brochure RPC-client failure was reported to reproduce on clean master. No browser-to-live-server end-to-end run is recorded.
This re-review ran no builds or tests. Current-head conflict markers pass; Automated Tests gates and product build matrices remain queued or running. CI is not yet complete.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
This request is already covered by my approval of the unchanged head Re-fetched the branch and confirmed no changes since that review. It still merges cleanly with current master. The approval and brief remain applicable; CI is still pending. |
|
The Run Automated Tests failure at |
|
Build Image (x86_64-nonfree) failed because of the CI infrastructure, not this change. GitHub reported "The hosted runner lost communication with the server" during "Download compiled artifacts", before any build step ran. I will rerun it once the image workflow (run 43955484167) finishes, along with the flaky test job. |
|
CI is green at |
…g-while-connecting Resolve PatchDbSource against #4755: its resumable watchDb$ (cursor and epoch) runs inside watchLive$, which still raises PATCH_LIVE on the first applied update, a dump or a replay closed by the current revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds on #4752.
Summary
Every
db.subscribereturned a full dump of the public database, several MB now that it carries registry caches, even when the browser's snapshot was only a few revisions behind. Page loads and reconnects now resume from where the browser left off.Broadcastkeeps the last 1024 revisions and an epoch drawn at random when the store opens (RandomState, no new dependency).catch_up_and_sub(ptr, since)returns the epoch, aCatchup, and a subscription. Whensincecarries this epoch and the retained history still reaches it, theCatchupis a replay: the revisions after the cursor, scoped toptr, plus the current revision id. Otherwise it is a dump.SubscribeParamstakessince: DbCursor { epoch, id }.SubscribeStream { epoch, id, value, revisions }. It is a dump whenrevisionsis null, and otherwise a replay current as ofid. The handler seedsDbSubscriber's sync fence from thatid, so filtered-out private writes can't strand a sequence wait.SubscribeStreamResultand share the same helper. The registry's index subscription keepsSubscribeResultwith its plainDump, so registry clients see no change; a registry test pins that shape.Dump, so a UI loaded before an update keeps working until it reloads.sincealways get the dump.databaseSubscriptiontakes a cursor getter, called on every subscribe.bufferDatabaseRevisionsstarts on either kind of start. It delivers a replay immediately as its revisions followed by an empty revision at the current id, so fences resolve without waiting for the next write.Verification
cargo test -p patch-db: 21 pass, including the new tests:stream_start_dumps_without_a_cursor_and_replays_with_onepins the wire shape. It compiles locally; it runs in CI.node --testpasses for UI (276, includingpatch cache rewrites every key when another tab stored the same revision from another epoch), shared (130), PatchDB source lifecycle (19, includingos resumes from its snapshot, then from its live revision after loss) and tunnel (8). The new tests fail against the previous code, which always sentparams: {}and dropped revisions that arrived before a dump.make start-core-ts-bindings. Only the StartOS and Tunnel RPC bindings change; the registry's are untouched.cargo check -p start-core --tests --features testpasses. With the new bindings,npm run check:shared,check:ui,check:tunnel,check:setup,check:wrt,check:brochureandcheck:marketplaceall pass.check:rpc-clientsfailure (Brochure reports malformed registry URLs and can load the next selection) reproduces identically on cleanmaster; CI'smasterrun passes it.🤖 Generated with Claude Code