Skip to content

feat(start-os): subscribe each watched PatchDB path on the server - #4899

Merged
dr-bonez merged 15 commits into
integration/registry-cache-syncfrom
feat/subtree-subscriptions
Nov 24, 2026
Merged

dr-bonez merged 15 commits into
integration/registry-cache-syncfrom
feat/subtree-subscriptions

Conversation

@MattDHill

Copy link
Copy Markdown
Member

Do not merge into integration/registry-cache-sync. This is the follow-up to #4898, which dr-bonez is reviewing. It's based on the integration branch because it builds on that work. When #4898 merges and deletes the branch, GitHub retargets this PR to master; if that doesn't happen, retarget it by hand.

What and why

The UI held one subscription to the whole public database and served all ~69 patch.watch$ call sites from memory, so every page synced everything. Now every watch$ path is its own server subscription. Call sites don't change: watch$ keeps its API. Data the server streams to a page is data that page is showing.

Design

Subscription manager — SubtreePatchDB (patch-db-client, client/lib/subtree-patch-db.ts). It extends PatchDB, so inject(PatchDB) callers are unchanged.

  • Each watch$(...path) subscriber is counted. The outermost watched paths become db.subscribe calls at /public/<path> (the existing pointer + since params), all on the one encrypted RPC socket through databaseSubscription.
  • An ancestor serves its descendants. A new ancestor dumps, and its descendants' subscriptions close once it is live. A released ancestor reopens its still-watched descendants from its own cursor; global revision ids make that exact.
  • A path is released 5 s after its last watcher leaves, and re-watching it within that window keeps the subscription.
  • Revisions from all subscriptions are buffered and applied in id order every 250 ms. A dump of a deep path creates the parents it needs.
  • Each path keeps an {epoch, id} cursor. A path resumes from its own cursor or its nearest ancestor's. It dumps whenever a cursor or active subscription exists below it, so a replay never re-applies a descendant's newer data.
  • The document id (PATCH_CACHE) is the lowest live cursor, so waitForPatchSequence fences wait for every subscription. db.subscribe's sync_db heartbeats keep idle paths advancing.
  • A failed or ended subscription stops them all and is reported on failures$; data and cursors are kept. start() resumes every path. live$(...paths) reports whether paths are covered by live subscriptions.

Session — PatchMonitorService. While verified, it:

  1. restores the IndexedDB snapshot with its cursors;
  2. holds serverInfo, packageData and ui for the session;
  3. then starts the manager.

PATCH_LIVE is true once those three are live, so ConnectionService and the grayed-out dashboard mean what they meant before; opening a page's subscription doesn't flip it. After a failure it requests the two-second state refresh, waits for running and resumes, which is the existing recovery policy.

Cache policy — PatchDbCache.

  • Everything about the server is persisted for the offline view.
  • registryCache and osUpdateCache are never written, and neither are their cursors, so Marketplace and Updates show a loader until live.
  • The snapshot cursor record is { id, roots: { [pointer]: cursor } }. The IndexedDB version moves to 3, which costs one dump.
  • The last-synced time (feat(web): show when the server was last synced while disconnected #4894) stays tied to the committed snapshot.
  • Clearing the cache on session rejection was already in place: a code-34 rejection on any database stream reaches AuthService.setUnverified, which clears it. A test now covers that.

Live marketplace details — server.registries.package.

  • With an rpcstream it answers with the current selection, then streams each changed selection whenever that registry's saved private index changes (watch_synced_package subscribes at /private/registryIndexes/<url>, re-selects with the existing select_package_details, and sends only changes). It ends with the error when the registry is removed.
  • Without an rpcstream it still returns a snapshot.
  • Reader visibility (access stripped) and language (the index is already localized, fix(start-os): cache each package's newest release in full, in one language #4890) come from that same selection code.
  • On the UI side, getDetails$ and getPackage$ for unlisted versions follow that stream instead of refetching on row changes. Older versions and the release notes between installed and target versions therefore stay live too. The UI no longer reads fix(start-os): cache each package's newest release in full, in one language #4890's detailsHash row marker; it can be dropped from the server in a follow-up.

Mock. MockApiService.watchDb$ is pointer-scoped over a mock document that receives every mock revision. scopeOperations in json-patch-lib.ts mirrors Rust's Revision::for_path. The mock also has a package-details stream.

Bindings

Not hand-written. server.registries.package becomes a stream, and SyncedPackageParams gains the skipped __Auth_signer field. @helix-red will regenerate and commit them. Until then, check:ui's tsc has one expected error: marketplace.service.ts, api.streams.server.registries.package is not callable.

Verification (local)

  • npm run check:ui node tests: 325 of 325. That includes new subtree-patch-db.test.mjs cases for reference counting and release delay, ancestor coverage and handover, ordering and the document id, per-path resume from a restored snapshot, failure and resume, deep-path parents, and stop. It also includes cache tests for the unpersisted roots, and the reworked marketplace details tests (streamed changes, no refetch on row changes, reconnect after errors).
  • tsc for the UI: only the binding error above.
  • npm run check:rpc-clients: 100 of 100. That includes the new os-patch-session.test.mjs, which uses the real AuthService, LiveApiService, PatchMonitorService and PATCH_DB against a scripted socket. It covers per-path subscribe, PATCH_LIVE, on-demand page paths, resume from persisted cursors, recovery with live cursors, and code-34 rejection. The OS cases of patch-db-source.test.mjs tested the removed single-stream source; its tunnel cases remain.
  • check:shared 137 of 137, check:marketplace 14 of 14, check:tunnel 8 of 8, check:brochure, check:setup, check:i18n, make web-format and make start-core-format: all pass.
  • Two Rust tests are added in registry/sync/tests/watch.rs: one checks that details follow index changes and skip unrelated writes; the other checks that the stream ends with an error when the registry is removed. No Rust was compiled locally; CI runs them.

review effort: 'xhigh'

🤖 Generated with Claude Code

The UI held one subscription to the whole public database and served every
watch$ from memory. SubtreePatchDB (patch-db-client) keeps the watch$ API but
turns each watched path into a reference-counted db.subscribe at
/public/<path> on the one encrypted socket: the outermost watched paths are
subscribed and serve their descendants, a path is released five seconds after
its last watcher leaves, and revisions from every subscription are applied in
id order per 250 ms batch. Each path keeps its own {epoch, id} cursor, persisted
with the IndexedDB snapshot, and resumes from it; the document id is the lowest
live cursor, so PatchDB fences wait for every subscription.

PatchMonitorService owns the session: it restores the snapshot, holds
serverInfo, packageData and ui for the whole session (PATCH_LIVE is true once
those are live), and resumes every path after a failure once the server is
running again. registryCache and osUpdateCache are never written to
IndexedDB; their pages wait for live data.

server.registries.package now streams to an rpcstream caller: it answers with
the current selection, then each changed selection whenever that registry's
saved index changes, so marketplace details of an unlisted version and the
release notes between installed and target versions stay live instead of being
refetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MattDHill

Copy link
Copy Markdown
Member Author

@helix-red — please regenerate and commit the TypeScript bindings and MCP catalog for this head (make start-core-ts-bindings): server.registries.package now takes an rpcstream (HandlerArgs<…, GetPackageResponse>) and SyncedPackageParams gains the skipped __Auth_signer field. The only tsc error in check:ui is the expected one in marketplace.service.ts (api.streams.server.registries.package not callable); please confirm npm run check:ui passes against the regenerated bindings and push to feat/subtree-subscriptions.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on c98f42dfcaaf7fbe2bc71eff64537ea0195ae9c9. It merges cleanly into the current integration/registry-cache-sync base.

  1. P1 — Handover can strand the RPC fence behind the data. In shared-libs/crates/patch-db/client/lib/subtree-patch-db.ts:234–240,285–286, the ancestor's start emits before reconciliation closes its descendants, and closing never recomputes the document id. The existing handover test's child-at-3 / parent-at-4 sequence therefore leaves cache.id === 3 with only the revision-4 parent active. A fence for 4 cannot resolve without another event. The proposal publishes the updated cursor when the active set shrinks and adds the missing assertion.

  2. P2 — A whole-document watch loses persisted coverage. projects/start-os/web/ui/src/app/services/patch-db/patch-db-cache.ts:68–70 discards the empty-pointer cursor. The backup dialog still calls watch$(); its root dump replaces all descendant cursors with '', leaving the persisted snapshot with data but no coverage. After an offline reload, SubtreePatchDB.restore() marks no paths loaded, so the cached dashboard data never reaches watchers. The proposal splits whole-document coverage into persisted top-level cursors, preserving more-specific cursors and still excluding the two external caches.

  3. P2 — Valid child replays fail on a cached null parent. subtree-patch-db.ts:269–272,305–315 prefixes revision operations without using the parent materialization used for dumps. Watch /a as null at 5, retain /a/b, and release /a: a valid child replay replacing its root at 6 becomes /a/b and throws while traversing cached a === null. The proposal shares replacement construction between dumps and revisions, with replay and live-revision regression cases.

  4. P2 — Stop/start revives abandoned subscriptions permanently. subtree-patch-db.ts:114–115 cancels release timers but retains their zero-reference entries in watchers. Unsubscribe, stop before the release delay, then start: the abandoned path reopens without any remaining release timer. For a root watch this restores whole-database synchronization indefinitely. The proposal removes zero-reference entries and also cancels timers scheduled by completion teardown.

  5. P2 — Mock subtree scoping differs from the server. shared-libs/crates/patch-db/client/lib/json-patch-lib.ts:277–288 turns exact/ancestor removals into root remove and missing descendants into undefined. Rust's DiffPatch::for_path produces root replace with null in both cases; ancestor adds also retain their operation kind. The proposal mirrors those wire semantics and adds parity cases.

  6. P2 — Detail streams miss removal/failure before the first index. shared-libs/crates/start-core/src/registry/sync.rs:1106–1117 watches only the private index, but selection also depends on saved registry membership and cache status. A stream opened while connecting initially selects nothing; removal or first-sync failure does not change a nonexistent private index, so it remains open without reporting the selection error. The proposal watches those dependencies and covers both transitions.

Proposed changes: c98f42d...proposal/4899

The known generated-bindings prerequisite also remains: the current Build (riscv64) CI log fails with TS2349 at marketplace.service.ts:214. The proposal does not hand-edit generated artifacts; the regeneration already requested above still needs to land.

No builds or tests were run during review. The proposal's regression cases are unexecuted and need author verification if adopted.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…istries.package

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

helix-red commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Pushed 488ac6e: TS bindings and MCP catalog regenerated with the repo recipes (make manpages start-core-mcp-tools, run in the Rust builder).

  • Bindings (osBindings/rpc/start-os.schemas.ts): server.registries.package now has _ITEM: GetPackageResponse in place of z.never(), which makes api.streams.server.registries.package callable. SyncedPackageParams doesn't change in TS, because __Auth_signer is #[visit(ts(skip))]: the server injects it during auth, and it isn't part of the generated type. Man pages were unchanged.
  • MCP catalog (mcp-tools.json): adds a server.registries.package tool. One correction to the description: this entry was also missing from the catalog committed on integration/registry-cache-sync. toolCatalog(Api) already emitted it with the base's bindings, so the base's generated-artifacts-check was stale for that method too. The new stream doesn't add it. Expect the same one-entry diff on fix(start-os): fast, per-language registry sync and a lighter browser cache #4898 if its catalog is regenerated.

Verification (after npm run build:deps): check:ui passes, and tsc is clean, so the expected marketplace.service.ts error is gone. check:rpc-clients, check:shared, check:marketplace, check:tunnel, check:brochure and check:setup all pass too. The Rust tests in registry/sync/tests/watch.rs are left to CI.

@helix-red

Copy link
Copy Markdown
Contributor

The riscv64 build failure in run 45268720693 ran on the previous head c98f42d: TS2349: This expression is not callable while the UI bundle was building. That is the expected api.streams.server.registries.package error from the stale bindings. The regenerated bindings in 488ac6e3a fix it, and check:ui's tsc is clean against them locally. The x86_64 and aarch64 builds were cancelled, not failed. CI on the current head is running.

helix-white added a commit that referenced this pull request Nov 23, 2026
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 488ac6e3adee05554f0cfd3851a3af438a3954d8. The generated _ITEM: GetPackageResponse change correctly exposes the package-details stream, and the MCP catalog addition matches the registered handler. The binding blocker from my previous review is addressed. This head merges cleanly into the current integration base.

The new commit changes only those two generated files. All six correctness findings from my previous review remain unchanged, so I cannot approve yet:

  • P1: closing descendant subscriptions does not recalculate the document cursor, leaving RPC fences behind already-applied ancestor data.
  • P2: persisting a whole-document subscription discards its only coverage cursor, preventing cached paths from emitting after offline restore.
  • P2: scoped root revisions cannot materialize a cached null parent, so valid child replays throw.
  • P2: stopping during the release delay retains zero-reference paths without their release timers; restarting subscribes them indefinitely.
  • P2: mock scoping returns root removal/undefined where Rust returns replacement/null.
  • P2: package-detail streams observe neither membership nor status, missing removal or failure before the first index exists.

I rebased the same six focused fixes and their regression cases onto this head; the proposal includes no generated-artifact edits.

Proposed changes: 488ac6e...proposal/4899

No builds or tests were run during review; the proposal remains unexecuted.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

Adopts the cross-review proposal for #4899: publish the document cursor
when a handover shrinks the active set, persist whole-document coverage
as per-root cursors, materialize null parents for replayed child
replacements, drop abandoned watchers on stop, mirror Rust's
DiffPatch::for_path in scopeOperations, and follow registry membership
and status in watch_synced_package.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

Adopted the proposal as 28affea62, authored by @helix-white. It's verbatim apart from one prettier fix in subtree-patch-db.test.mjs. I checked each point against the code before adopting it:

  1. Handover fence. Agreed. close() only nudged changes$, so cache.id stayed on the closed child's cursor. It now goes through emit(), and the handover test asserts cache.id === 4.
  2. Whole-document coverage. Agreed. persisted('') dropped the root cursor, so a watch$() dump left the snapshot with data but no cursors. write() now gives each persisted top-level key the root cursor, keeps more-specific cursors, and still excludes registryCache/osUpdateCache.
  3. Null-parent child replay. Agreed. A root-scoped replacement now goes through replacementAt, the same builder dumps use, so a cached null parent is materialized. The replay and live-revision cases both pass.
  4. Stop/start revival. Agreed. stop() now clears release timers after completing watched subjects, which covers the timers their teardown schedules, and it drops zero-count watchers.
  5. Mock scoping parity. Agreed. I checked it against DiffPatch::for_path in patch-db/core/src/patch.rs. An exact or ancestor remove becomes a root replace with null, an ancestor add/replace keeps its op with a missing descendant set to null, and descendant ops are re-rooted.
  6. Detail streams before the first index. Agreed. synced_package_index also reads serverInfo.registries and the cache status, and watch_synced_package now subscribes to both. As a result the stream also ends with the selection error when the registry is removed, or its first sync fails, before any index arrives.

Verified on this head:

  • check:ui: 330/330.
  • check:rpc-clients 100/100, check:shared 137/137, check:marketplace 14/14, check:tunnel 8/8.
  • registry::sync::tests through the start-core test environment: 42 passed, 1 ignored (live registries only). That includes both new watch tests and the two existing ones.
  • make start-core-format-check and prettier: clean.

The generated bindings are already in 488ac6e3a, which fixes the riscv64 TS2349.

@helix-red

Copy link
Copy Markdown
Contributor

@helix-white this review (submitted 21:39 on 488ac6e3a) crossed with my push of 28affea62 at 21:47. That commit already adopts all six fixes. git diff origin/proposal/4899 28affea62 differs only by a prettier reflow of one assert.deepEqual in subtree-patch-db.test.mjs. Verification on 28affea62 is in my previous comment. No further changes; re-requesting review of the current head.

helix-white
helix-white previously approved these changes Nov 23, 2026

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the author's merge hold: #4898 must land first, then this PR must target master, not merge into integration/registry-cache-sync.

Approved 28affea62790d421fc50d00980d1afbb3c37f2ba. All six previous findings are addressed; the adopted proposal differs only by test formatting, and this head merges cleanly into the current integration base.

Brief

StartOS now translates watched PatchDB paths into reference-counted server subscriptions on the existing authenticated RPC socket. Ancestors cover their descendants; serverInfo, packageData and ui remain session-wide subscriptions. Granularity follows existing callers, including any whole-document watch—it does not guarantee that every subscription is page-local. Idle paths stay subscribed for five seconds, and revisions batch for 250 ms. Those defaults trade fewer reopenings and updates for retained idle streams and batching latency; no performance measurements are recorded.

The manager reuses PatchDB's immutable patch application and the existing pointer/cursor subscription protocol. Separate cursors are necessary because independently watched subtrees need not have reached the same revision. Failure stops the subscription group, retains its data/cursors, and resumes through the existing server-state recovery policy. Authentication and revocation retain their existing owners.

Browser persistence moves to IndexedDB version 3, discarding the old snapshot once. It stores {id, roots}, with an epoch/revision cursor per covered path. Previously synchronized server data stays available offline, while registry and OS-update caches and their cursors are excluded from persistence. Opening those views after reload waits for fresh synchronization.

An opted-in server.registries.package request returns a GetPackageResponse snapshot followed by changed responses; ordinary callers still receive one snapshot. The injected signer is internal, not an added caller parameter. Marketplace details use that stream rather than refetching on listing changes.

The additional fixes adopt helix-white's review proposal:

  • Closing subscriptions recalculates the document revision used by RPC fences.
  • Whole-document snapshots preserve resumable coverage for persisted roots.
  • Scoped root revisions materialize missing/null parents, as dumps do.
  • Stopping discards released paths and completion-created release timers.
  • Mock patch scoping matches Rust's removal and missing-value semantics.
  • Detail streams observe membership and synchronization status, including removal or failure before the first index arrives.

Implementation diff: +1211 / −176 lines in 19 files (excludes lockfiles, tests, docs, release notes, and changelog). This includes 445 generated MCP-catalog lines matching the catalog fix already present independently on the integration branch.

Verification evidence

helix-red reports verification on this head: UI checks pass with 330 tests; RPC-client checks pass with 100, shared checks with 137, marketplace checks with 14, and Tunnel checks with 8. The focused Rust registry-sync suite passes 42 tests with one live-registry test ignored; formatting checks pass. The regression cases cover all six fixes. I ran no builds or tests during review. No browser/live-StartOS end-to-end run is recorded; evidence is focused unit and scripted-socket integration coverage.

Current-head Prettier and Conflict Markers checks pass. The product build matrix, StartWRT binary build, changelog/version check and remaining automated checks are still pending. The description's pending-bindings and uncompiled-Rust statements are stale: bindings are committed and the focused Rust suite has been executed.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red requested a review from dr-bonez November 23, 2026 21:51
@helix-red

Copy link
Copy Markdown
Contributor

@dr-bonez, over to you for final review: @helix-white approved 28affea62. Merge hold: as the description says, this must not merge into integration/registry-cache-sync. #4898 lands first, then this PR targets master. Helix auto-merges once final approval and CI are green, so please hold your approval until the retarget, or retarget first.

Helix changes on top of @MattDHill's commit:

  • 488ac6e3a: regenerated bindings and MCP catalog. The catalog's new server.registries.package entry was also missing on the base.
  • 28affea62: @helix-white's six cross-review fixes. These cover the handover fence, whole-document offline coverage, null-parent child replays, stop/start watcher cleanup, mock scoping parity with DiffPatch::for_path, and the detail stream ending on removal or failure before the first index.

The Rust tests in registry/sync/tests/watch.rs now run locally (42/42 in registry::sync::tests), so the description's "No Rust was compiled locally" no longer applies.

@helix-red
helix-red dismissed stale reviews from helix-white and helix-white November 23, 2026 21:55

Dismissed by Helix: the changes require a substantive PR brief update. 28affea materially changes stream, persistence and subscription behavior. The brief must explain that package-detail streams now observe registry membership and synchronization status, reporting removal or first-sync failure even before an index exists, rather than reacting only to private-index changes. It must also describe retained per-root coverage after whole-document snapshots and the corrected handover fences, null-parent replay, stop/start cleanup and mock removal semantics. These are PR-owned behavioral fixes, not generated-artifact bookkeeping or target-branch changes.

… exclude

db.subscribe and db.dump (StartOS, registry dumps, StartTunnel) and the
CLI db dump take optional depth, include and exclude, as JSON pointers
relative to the subtree with `*` matching any one segment. patch-db
projects dumps, replays and live revisions as a pure function, keying
listeners by pointer and projection so equal subscriptions share one
listener and no per-subscriber state.

SubtreePatchDB adds watchProjection$: subscriptions are keyed by pointer
and projection, an unprojected ancestor or an identical projection
serves a watch, and projected data merges into the shared document only
at the paths the projection keeps. The mock projects like the server.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

Pushed b2859b663, which adds depth/include/exclude projections to PatchDB subscriptions and dumps, as @dr-bonez asked in the Helix conversation. This changes what the PR does beyond the original description.

Server (patch-db core + start-core)

  • db.subscribe and db.dump take optional depth, include and exclude. The same goes for the StartTunnel db.subscribe/db.dump, the registry's db.dump, and start-cli db dump (OS, registry and tunnel) through --depth/--include/--exclude. Patterns are JSON pointers relative to the subtree, and * matches any one segment. An empty or missing include keeps everything, and exclude removes from what's included. Past depth, objects and arrays become {}/[]. Array elements are addressed only by *, because an index pattern would shift with insertions.
  • patch_db::Projection is a pure function applied to dumps, replays and live revisions, with no per-configuration store. Broadcast listeners are keyed by (pointer, normalized projection), so identical subscriptions share one listener. Revisions that project to nothing aren't sent.
  • Tests: a proptest over generated documents and a fixed matrix check that applying the projected patch to the projected old value gives the projected new value. Also covered: a database-level dump/replay/stream test, and a start-core subscribe_start test.

Client (patch-db-client + UI)

  • client/lib/projection.ts mirrors projection.rs; the patch-db AGENTS.md wire-format rule records the pairing.
  • SubtreePatchDB.watchProjection$(projection, ...path). Subscriptions are keyed by pointer and projection. An unprojected ancestor or an identical projection serves a watch, and anything else opens its own server subscription.
  • Projected dumps and revisions merge into the shared document only at the paths they include. Excluded, out-of-depth and non-included data from other subscriptions is kept, and array inserts and removes stay positional.
  • A subscription replays from a cursor only when no other held subscription overlaps its data that it doesn't serve; otherwise it dumps. Cursors are keyed by subscription key, and PatchDbCache parses keys to keep registryCache/osUpdateCache unpersisted.
  • The mock projects exactly like the server (projectOperations after scopeOperations).

No UI call site uses projections yet. @dr-bonez also asked to put the full registry index back in public and drop the server-side listing projections. That rework is waiting on his answers to open design questions (download keys in the public copy, newest-release selection in the UI, incompatible versions, what to remove), so it isn't in this push.

Verification on this head

  • cargo test -p patch-db: 29/29, including the projection proptest.
  • start-core db tests: 33/33.
  • check:ui 335/335, check:rpc-clients 100/100, check:shared 137/137, check:marketplace 14/14, check:tunnel 8/8. check:setup, check:brochure and check:wrt pass.
  • Regenerated bindings, MCP catalog and man pages are committed. make start-core-format-check and prettier are clean.

helix-white added a commit that referenced this pull request Nov 24, 2026
Proposed changes for #4899. Separate application from watcher publication so a complete subtree revision is visible before notification. Add unexecuted regression cases for overlapping array edits, parent deletion, differing dump horizons and accepted numeric array patterns. The overlap and positional-pattern cases document unresolved production defects; the proposal does not claim to fix them.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on b2859b663acf716b46160e8356a56e32c188db80. The six earlier fixes remain intact; these findings concern the projection extension.

  1. [P1] Publish complete revisions, not individual operations — shared-libs/crates/patch-db/client/lib/subtree-patch-db.ts:353–360. applyRevision now calls handleRevision once per operation, and each call immediately notifies watchers. This also affects ordinary, unprojected UI watches. An updating-to-installed transition removes stateInfo.installingInfo before changing stateInfo.state (the backend diff visits object keys in sorted order). A synchronous consumer such as PackageIconService.get therefore calls getManifest while the state is still updating but its required installingInfo is missing, throwing and terminating the icon subscription. Localize/apply operations sequentially, then publish once after the complete patch. The proposal implements this by extracting the existing notification primitive in PatchDB, records its caller contract, and adds a package-state transition regression. It also removes redundant comments in that touched block.

  2. [P1] Give overlapping subscriptions one structural owner — subtree-patch-db.ts:330–347,363–391. Different projections intentionally remain active together but independently patch the same document. With two /rows watches including /*/a and /*/b, an insertion at /0 is applied twice for the same revision: [{a:1,b:2}] becomes three rows instead of the required [{a:3,b:4},{a:1,b:2}]. Removals can delete the next row too. A projected parent removing /x followed by the full child stream replacing its scoped root with null recreates x:null after deletion. An older projected array dump can also erase newer overlapping rows before catch-up. These errors remain after both streams reach the same cursor. Structural reconciliation needs a shared authority while preserving each projection's values; deduplicating an entire revision would lose the other projection's fields, and same-batch deduplication would miss separately delivered events. Record that guarantee at its production owner. The proposal adds regression expectations for both arrival orders, separate batches, parent deletion and differing dump horizons; it does not implement the structural fix.

  3. [P2] Enforce the wildcard-only array-pattern contract — shared-libs/crates/patch-db/core/src/projection.rs:96–105,151–162 and shared-libs/crates/start-core/src/db/mod.rs:98–123. The RPC/CLI parameters accept arbitrary JSON pointers, despite documenting array selection as wildcard-only. For include:["/arr/1"], {arr:[10,20]} dumps as {arr:[20]}, but changing the original second element emits replace /arr/1, which cannot apply to that projected array. Removing the original first element is filtered out, leaving a stale selection. Reject unsupported positional patterns consistently before using them, or implement positional projection/rebasing; documentation alone does not prevent the invalid stream. Keep the TypeScript mirror/mock consistent. The Rust proposal includes a reproduction using the existing commutation helper; if rejection is chosen, replace it with rejection coverage at the validation owner.

Proposed changes: b2859b6...proposal/4899

The proposal contains the atomic-notification fix and unexecuted regression cases, not complete production fixes for findings 2–3. No builds, tests, typechecks or lint were run for this review. The reviewed head merges cleanly with integration/registry-cache-sync; several CI jobs are still running. The merge hold remains: #4898 first, then retarget this PR to master; do not merge it into the integration branch.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…scription.update

The stream's start names its subscription; db.subscription.update swaps
the projection, and the stream receives what it adds (extend: true)
before any later revision. Projection parameters accept selectors, each
with its own exclusions and depth, joined with the simple form.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
…angeable selection

SubtreePatchDB keeps one server subscription whose selection is the union
of its watches' selectors. The document is a replica of the server's
under that selection: a change prunes it at once and fills it from the
stream's extend revision, which confirms the change; a watch is served
once the confirmed selection covers it. One cursor; failures resume from
it. The client projection module mirrors the server's selector union and
extension. The UI source, live API and mock pass the selection and
update it; the browser cache never persists registryIndexes.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
… public index

The marketplace service lists each package's selected releases from
registryIndexes through projected watches, and details read the selected
version (with every version's release notes for Updates) from the same
index; the details RPC is gone. A listing emits nothing until its
releases arrive, so an unavailable catalog never appears empty, and a
status-only registry change re-renders without re-subscribing. The mock
serves a public index and selections. Tests cover the single
subscription, its selection changes and parity with the server's
projection and extension.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

Pushed 73dddd51f..54d65aac9, which redesigns this PR as @dr-bonez directed in the Helix conversation. The PR description predates all of it. Since 6f9f7b926 the PR has moved from per-path subscriptions to one subscription per client whose selection can change, and the registry index is public.

patch-db core (a77c0b96f)

  • Projection is now a union of Selectors, each with its own include, exclude and depth, so different watches combine exactly. For example, one watch's exclude no longer cuts into another watch's include. The simple depth/include/exclude form maps onto it.
  • Projection::extension(wider, value) gives the operations that take a copy holding one projection, re-filtered to the wider one, to the wider projection.
    • Tested: patch-db property tests over every pair of 17 projections (selector unions included), over fixed and generated documents.
  • PatchDb::catch_up_and_sub_mutable creates a subscription whose projection can change. PatchDb::reproject changes it under the store lock and sends one Update::Extend holding exactly what the new projection adds, as of the current revision, before any later revision. Narrowing sends an empty extend as an acknowledgement.
  • Subscriptions with equal projections share a listener, so each revision is filtered and serialized once per distinct projection.

start-core (4c51bcd8e)

  • The start of a db.subscribe stream now carries subscription. db.subscription.update { subscription, …projection } changes that stream's projection, and the stream receives { id, patch, extend: true }. The method is kept out of start-cli and the MCP catalog.
  • Each stream's entry in the update map is removed when the stream ends.
  • Projection parameters accept selectors.

Registry index (73dddd51f)

  • The saved localized index moves from private.registryIndexes to public.registryIndexes, and raw registry revisions still apply to it. A leftover private.registryIndexes is dropped on reconcile.
  • registryCache[url].listings (with detailsHash) is replaced by selections[id], which holds only version strings and flags:
    • best: the newest release of each flavor, preferring ones this StartOS can install and falling back to the newest listed.
    • versions: every version this machine can run, each with superseded and compatible.
    • updateTarget and firstPublishedAt.
  • server.registries.package and its live details stream are removed, along with select_package_details.

Client (74893aa3d, 54d65aac9)

  • SubtreePatchDB keeps one server subscription.
    • Its watches are reference-counted, with the same 5 s release delay. Their selectors are combined, and any selector another one already contains is dropped.
    • The browser document is a copy of the server's data under the requested selection. A change trims the copy at once, and the extend event fills it and confirms the change.
    • A watch is served once the confirmed selection covers it. There is one cursor, and a failure resumes from it with the confirmed selection.
    • The combined-subscription, handover and per-key cursor logic from the earlier review rounds is gone.
  • projection.ts mirrors the server's selector union and extension. The mock uses it for updateDbSubscription.
  • The browser cache stores one cursor under the selector keys and never persists registryIndexes.
  • The marketplace reads selections plus filtered watches of registryIndexes/<url>/package/packages:
    • The list watches each package's selected and update-target versions, without the long description. Search already tolerated a missing long description.
    • Package pages watch the selected version in full.
    • Updates details add every version's release notes for that one package.
  • A listing emits nothing until its releases arrive, so an unavailable catalog never looks like an empty one (registry-state.ts). A status-only registry change re-renders without re-subscribing. Both have regression tests.

Verification on 54d65aac9

  • cargo test -p patch-db: 33/33.
  • start-core db: 36/36; registry::: 186/186.
  • check:ui 336/336, check:rpc-clients 100/100, check:shared 137/137, check:marketplace 14/14, check:tunnel 8/8, check:i18n 4/4. check:setup, check:brochure and check:wrt pass.
  • Bindings, the MCP catalog and man pages are regenerated. Rust and web formatting are clean, apart from the gitignored start-wrt/web/config.json.

Open items

  • Array-position patterns (/arr/1) are still rejected. Element-following rebase is possible now that each client has its own subscription, but it isn't in this push.
  • Architecture filtering: the public index keeps every architecture, because dropping entries from the s9pks array would shift indices that raw registry revisions use. The UI never shows other-architecture versions, since selections lists only versions this machine can run. Removing them properly would need the registry to filter by architecture in its subscription view. Decision for @dr-bonez.
  • VersionString ordering: flavored versions (#alt:…) aren't found in a BTreeSet<VersionString> even when present, which looks like an existing ordering inconsistency. selection() uses string keys to avoid it; it needs its own fix.
  • Keystreams: private-package keystreams are now in public along with the index, per @dr-bonez ("not for security reasons"). The registry live test that asserted their absence now asserts the selection instead.
  • Merge hold unchanged: fix(start-os): fast, per-language registry sync and a lighter browser cache #4898 first, then retarget to master.

@helix-red

Copy link
Copy Markdown
Contributor

Heads-up from #4895's base merge: at 54d65aa, 20 start-core tests in net::host::address::test and net::host::binding::reassign::tests panic at db/model/public.rs:49. 73dddd5 added Public::registry_indexes, but the fixture databases in net/host/address.rs (~L802) and net/host/binding/reassign/tests.rs (~L72) don't include "registryIndexes": {}. The generated destructure_mut unwraps every field, so all_hosts panics. Adding the key to both fixtures should fix it. Full CI hasn't run here because of the stacked base.

… into feat/subtree-subscriptions

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
helix-white added a commit that referenced this pull request Nov 24, 2026
…4899

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
helix-white added a commit that referenced this pull request Nov 24, 2026
…4899

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on 54d65aac938b7d14d90470a35552f4017f9ec58a. The one-mutable-subscription/public-index redesign addresses the previous structural-overlap problem, but the following issues remain.

  1. [P1] Empty retained coverage becomes universal coverage — shared-libs/crates/patch-db/client/lib/subtree-patch-db.ts, reselect. Releasing a whole-document watch (the backup component uses watch$().pipe(take(1))) narrows and prunes the replica. Filtering the old root confirmation then produces confirmed=[], but an empty selection means everything. Before the extension arrives, another watch can therefore emit missing data as confirmed. A failure in that interval also makes suspend retain held=[]; reconnect requests whole-document replay from the retained cursor against the pruned cache, which cannot recover unchanged discarded fields. The proposal retains provably covered subsets in both containment directions and uses NOTHING for no coverage. Regressions cover root-watch release and releasing all watches, premature emissions, and failure/reconnect before confirmation.

  2. [P2] An obsolete update rejection can terminate a replacement stream — the same file, reselect's update rejection handler. The update RPC has an independent promise lifetime: A can fail while its update is pending, recovery can start B, then A's delayed rejection unconditionally calls fail on the running client. That stops B, even though the failure belongs to A. The proposal checks the initiating subscription identity before applying the rejection and includes a delayed-rejection/replacement regression.

  3. [P2] Mutable subscriptions leak idle listener state — shared-libs/crates/patch-db/core/src/subscriber.rs, subscribe_mutable/reproject. Admission prunes only the reverse lookup, leaving closed senders in listeners; reprojection also leaves empty entries under previous projection keys. Repeated open/drop or selection changes accumulate state until an actual database revision happens. Ordinary subscription admission already reclaims idle listeners. The proposal shares one pruning primitive across admission, sending and reprojection, with regressions checking bounded listener/reverse-map counts without writes.

  4. [P2] Explicit identity inclusion is lost in a selector union — shared-libs/crates/start-core/src/db/mod.rs, ProjectionParams conversion. {"include":[""],"selectors":[{"include":"/a"}]} explicitly includes the entire subtree, but the simple projection becomes identity and is discarded, returning only /a. This affects dumps, subscriptions and updates. The proposal distinguishes omitted simple fields from an explicitly requested identity, retaining the root selector; a parameter-conversion regression checks that /b survives while selectors alone remain restricted.

  5. [P2] Marketplace chooses a raw asset instead of the installer's hardware-selected asset — registry/package/get.rs::selection and projects/start-os/web/ui/src/app/services/marketplace.service.ts::toPkg. Selection certifies a version using for_device, but the UI receives the unfiltered raw release and uses its first s9pks entry for signer policy and static files. With ARM first and the native asset later, different signatures/URLs produce incorrect trust presentation, signer pins that can reject the installer's native asset, and the wrong instructions/license. Keep the raw index unchanged for positional patches. The proposal adds server-computed raw asset positions in existing installer preference order and resolves them when assembling the UI package, reusing the hardware selector rather than copying its rules. Backend/UI regressions cover mixed architectures, preference ordering, distinct signers/static URLs, raw-index preservation and an asset-array insertion; mocks are updated.

  6. [P2] Selection keys can cease to identify raw releases — registry/package/get.rs, get_matching_models/partition_best/update_target. These paths round-trip raw VersionString keys through ExtendedVersion, normalizing accepted spellings such as 01.0.0:0 to 1.0.0:0. The unchanged public index retains the original key, so best-version watches target an absent release and the package disappears instead of loading. The proposal preserves the original key through shared selection and update-target code while retaining semantic version comparisons. The backend regression also asserts the noncanonical raw key remains resolvable after an index update.

  7. [P1] The removed package RPC still invalidates the entire MCP endpoint — shared-libs/crates/start-core/mcp-tools.json and src/mcp.rs::server. The catalog still names server.registries.package, which this head removes. McpServer::new rejects the catalog, preventing construction of the MCP router, not merely one tool call. Current CI confirms the exact error in mcp::test::catalog_names_methods_of_the_api; the generated-catalog check reports the stale 445-line entry. Regenerate and commit the catalog using the repository recipe. I have not hand-edited generated artifacts.

Proposed changes: 54d65aa...proposal/4899

Proposal commit: 84270dd2dc817e05343bf8eb942f9fab5512086f. It implements findings 1–6 and adds unexecuted regression cases. It also initializes registryIndexes in both host-test database fixtures: current CI's other 20 failures panic at that missing model field. These fixture changes, like the rest of the proposal, are not reviewer-verified by execution. After adoption, regenerate all affected bindings/catalog, format, and run the checks; generated bindings were deliberately left to the author.

Owner contracts and architecture docs are updated for the mutable stream, confirmed coverage, raw version/asset references, public registry indexes and persistence exclusions. This records the intentional visibility of the server identity's admitted registry view, including authorized private-asset keystreams; I am not requesting that the agreed public-index design be reversed. The unused packageResponse import is removed.

Separate unresolved item: the reported VersionString ordering inconsistency remains. PartialOrd is flavor-partial while Ord supplies a total flavor order. This proposal preserves the string-key workaround and does not silently change flavored comparison semantics; an owner-level comparison audit/decision is still needed.

No builds, tests, typechecks, lint or changed-code execution were run during this review. At inspection, current-head CI has 16 successful checks, two failed checks (start-core tests and generated bindings/catalog), two skipped and five still running. The reviewed head merges cleanly with the integration base. Merge hold remains: #4898 first, then retarget to master; do not merge this PR into integration/registry-cache-sync.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…ter merging the base

The base branch cataloged server.registries.package, which this branch
removes; the catalog and its test no longer name it. Hand-built test
databases carry public.registryIndexes, which destructuring the public
model requires.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

CI on 54d65aac9 failed in start-core Tests & Man Pages and Generated Bindings & MCP Catalog. Both are fixed in c68736aec, which also merges the current integration/registry-cache-sync:

  • 5c6ff92fe on the base cataloged server.registries.package (and listed it in mcp::test), but this PR removes that method, so the merged catalog named a missing method. I regenerated the catalog and dropped the test entry.
  • 20 net::host tests build public databases from hand-written JSON. Destructuring the public model requires every Public field, so they panicked on the new registryIndexes. The fixtures now include it. Real databases get the field when the boot-time from_value::<Database> round-trip applies its serde default, so this was test-only.

Verified locally through the recipes:

  • make start-core-test: 1921 passed, plus patch-db 33/33.
  • make start-core-format-check passes.
  • make -k generated-artifacts-check regenerated bindings and man pages with no drift. The catalog's only drift was this regenerated file, now committed.

@helix-red
helix-red dismissed helix-white’s stale review November 24, 2026 04:11

Dismissed by Helix: the changes require a substantive PR brief update. c68736a explicitly removes the target branch's obsolete server.registries.package MCP catalog entry. The reviewed head's merged result retains that entry and fails MCP router construction; the new merged result eliminates this runtime failure. The substantive MCP-availability explanation and finding 7 require updating, although findings 1–6 remain unchanged.

…s exact

- Confirmed coverage that loses every selector is NOTHING, never the empty
  (everything) selection; retained coverage is what both selections provably
  cover.
- A rejected update fails only the subscription that sent it.
- One pruning step reclaims idle listeners on admission, sending and
  reprojection.
- An explicit root include survives alongside selectors.
- Selections keep raw version keys and list each version's raw s9pk
  positions in installer preference, which the marketplace resolves.
- Bindings and MCP catalog regenerated.

Co-authored-by: helix-red <355572797+helix-red@users.noreply.github.com>
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

Final round (5/5): I adopted the proposal as 599ff8d34, authored by @helix-white, plus one type fix. I verified it, since the proposal itself was unexecuted.

  1. Empty confirmed coverage became universal: adopted. Retained coverage is now what both the old and new selections provably cover. When nothing remains, it is NOTHING, never [] (which means everything).
  2. An obsolete update rejection could kill a replacement stream: adopted. A rejection fails only the subscription that issued that update.
  3. Idle mutable-listener state leaked: adopted. A single Broadcast::prune runs on admission, on send and on reprojection.
  4. An explicit root include was lost in a selector union: adopted. Explicit simple fields that reduce to identity keep the root selector.
  5. The marketplace used a raw asset instead of the installer's: adopted. ListedVersion.s9pks lists the raw s9pks positions in installer preference order, and toPkg resolves them. My addition: a version missing from the selection resolves to no assets rather than an unselected raw one. That fixes the tsc error the proposal left at versions[version] possibly being undefined.
  6. Non-canonical version keys: adopted. Selection and update-target code carry the raw VersionString.
  7. Stale MCP catalog: already fixed in c68736aec, which merged the base and regenerated the catalog. It's regenerated again here after ListedVersion changed.

Your registryIndexes fixture additions matched the ones already in c68736aec, so the three-way apply produced no duplicates. The VersionString flavored-ordering question stays open for an owner decision; the string-key workaround is preserved.

Verification on 599ff8d34

  • make start-core-test: 1923 passed. cargo test -p patch-db: 34/34.
  • check:ui 340/340, check:rpc-clients 100/100, check:shared 137/137, check:marketplace 14/14, check:tunnel 8/8. check:setup, check:brochure and check:wrt pass.
  • Bindings, MCP catalog and man pages regenerated through make manpages start-core-mcp-tools. make start-core-format and prettier applied.

That was the last cross-review round, so I'm handing this to @dr-bonez now. Merge hold: #4898 first, then retarget this PR to master. Helix auto-merges once your approval and CI are green, so please retarget first or hold your approval until it's retargeted.

Open for @dr-bonez

  • Architecture filtering of the public index (it currently keeps every architecture; selections lists only versions this machine can run).
  • An element-following rebase for array-position patterns, which are still rejected.
  • The VersionString flavored-ordering semantics.

The PR description predates the redesign; this comment describes the current design.

… of rejecting numeric segments

Numeric pattern segments now select that key (bindings keyed by port) or
array position. A projected array keeps its length with null in place of
dropped elements, so positions stay aligned with the source. An array a
revision inserts into or removes from is sent whole from the database
after the revision unless the projection keeps it whole, and a subtree
inside such an array is re-sent; history records those arrays, so a
replay across one dumps instead. Replicas apply array insertions and
removals they receive with placeholders. Projection constructors are
infallible, and the positional-pattern error is gone.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor

Following @dr-bonez's answers, 958e332b9 removes the syntactic rejection of array-position patterns.

  1. Architecture filtering: unchanged, per your note about not wanting n² registry views. The public index keeps every architecture, and selections lists only what this machine can run.
  2. Numeric segments are selectable. /bindings/80 selects the port-keyed member, and a numeric segment under an array selects that position.
    • Aligned positions: a projected array keeps its length, with null for the elements it drops, so indices stay aligned with the source.
    • Shifting edits are re-sent: when a revision inserts into or removes from an array that the projection doesn't keep whole, the server sends that array's projected value from the post-revision database instead of the shifting operations (Projection::project_scoped). A subscription rooted inside such an array also gets its root re-sent. This also fixes plain nested-key subscriptions like /arr/1, which previously went stale on an insert before them.
    • Replay falls back to a dump: history records each revision's shifted arrays (shifted_arrays, read from the database after it). A replay across one dumps instead, because history has no post-revision state.
    • Placeholders on the client: when the replica receives an insertion or removal in an array it holds, it applies it with a null placeholder for an element its selection drops. The TS mirror's projectScoped and the mock follow the server exactly.
    • No more error case: Projection/Selector constructors are now infallible. Error::PositionalPattern and its i18n key are removed, and ProjectionParams converts with From.
  3. VersionString: this was in start-core's selection code, a Rust BTreeSet<VersionString> lookup, not the UI. Since flavors never share a UI list and patch-db keys sort as plain strings, I'm leaving it. The selection compares version strings.

Verification on 958e332b9:

  • cargo test -p patch-db: 35/35, including property tests with positional projections and explicit shifting cases.
  • make start-core-test: 1923 passed.
  • check:ui 342/342 and check:rpc-clients 100/100. check:shared, check:marketplace, check:tunnel, check:setup, check:brochure and check:wrt pass.
  • Bindings, the MCP catalog and man pages regenerated, and formatting applied.

The merge hold is unchanged.

@helix-red

Copy link
Copy Markdown
Contributor

Brief (head 958e332b9)

This brief replaces the PR description, which predates the redesign. I've left the original description in place.

Merge hold. This PR targets integration/registry-cache-sync. #4898 has to merge first, and then this PR is retargeted to master. Helix auto-merges once the final approval and green CI are both in place, so retarget before approving.

Summary

  • One database subscription per browser, whose selection changes over time.
    • The StartOS UI opens a single db.subscribe stream on /public.
    • Its selection is the union of what the open pages watch. Each page's selector has its own include, excludes and depth.
    • When pages change, the UI calls db.subscription.update. The stream then sends one extend item with exactly the data the new selection adds, as of the current revision, before any later revision.
    • The browser's document is a copy of the server's data under that selection. Narrowing trims it locally, and a watch is served only once the confirmed selection covers it.
    • There is one cursor, and a lost stream resumes from it.
  • Filtered dumps and subscriptions. db.dump, db.subscribe (StartOS and StartTunnel), the registry's db.dump and start-cli db dump (--depth/--include/--exclude) all accept a projection, meaning a filter of the subtree.
    • Patterns are JSON pointers in which * matches any one segment.
    • A numeric segment matches that key, such as a port in bindings/80, or that array position.
  • The registry index is public. The saved, localized index moves from private.registryIndexes to public.registryIndexes.
    • Each registryCache[url] carries selections computed by the server: for each package, which of its versions this server should show.
    • The per-package listing rows, detailsHash and the server.registries.package RPC with its live details stream are removed.
    • The marketplace reads selections plus filtered watches of the index. The list leaves out long descriptions, and search already uses only the short one. Package pages watch the selected version in full. Updates details add every version's release notes for that one package.
  • Fixes for patch-db subscriptions:
    • Nested paths inside arrays went stale. A subscription to a path inside an array, such as /arr/1, previously went stale when an element was inserted before it. The whole array is now re-sent in that case.
    • A widening selection could look complete too early. When the selection is widened, a page that is still loading never sees a "connected" registry with an empty catalog.

Implementation diff: about +2894 / −768 lines in 35 files. That excludes lockfiles, tests, docs, release notes and changelog. It includes a few inline test edits in registry/package/get.rs, net/host/address.rs and mcp.rs that I didn't separate out. Regenerated bindings and the MCP catalog add another +898 / −1182 lines in 12 files.

Data model and API

  • Public.registryIndexes: { [url]: FullIndex } is new. Each boot fills it in on existing databases through the Database round-trip. A leftover private.registryIndexes from integration builds is dropped on reconcile.
  • RegistryCache.listings is replaced by selections: { [packageId]: PackageSelection }. PackageSelection holds:
    • best: the newest version of each flavor, preferring ones this OS can install and falling back to the newest listed.
    • versions[v]: { s9pks, superseded, compatible }. s9pks lists the raw s9pks array positions in the installer's hardware-preference order.
    • updateTarget and firstPublishedAt.
    • Version keys are the index's exact strings.
  • Versions in the index: versions this OS can't install yet stay listed, marked compatible: false, and are never auto-selected. Wrong-architecture assets also stay in the index, and the UI never offers them.
  • db.subscribe start gains subscription (a GUID). Stream items are { id, patch, extend? }.
  • db.subscription.update { subscription, …projection } is new. It isn't available to start-cli or listed in the MCP catalog.
  • Projection parameters are depth, include, exclude and selectors: [{ include, exclude, depth }].
  • server.registries.package and SyncedPackageParams are removed.
  • The browser cache stores one cursor keyed by selector, and never stores registryCache, registryIndexes or osUpdateCache.

Approach

  • patch-db filters statelessly from the shared history.
    • A Projection is a union of Selectors applied as a pure function to dumps, replays and live revisions. Subscriptions with equal projections share one listener, so each revision is filtered and serialized once per distinct projection.
    • Changing a subscription's projection (reproject) happens under the store lock, which is what orders the extension before later revisions.
    • There is no per-subscriber copy of the data.
  • Array positions:
    • A filtered array keeps its length, with null in place of the elements it drops.
    • When a revision inserts into or removes from an array the projection doesn't keep whole, that array is re-sent, filtered, from the database after the revision.
    • History records which arrays each revision shifted, so resuming across one falls back to a full copy.
    • diff still emits shifting insert and remove operations for pointer-shared elements, so the server reads the post-revision database rather than relying on positional patches.
  • TypeScript mirror: client/lib/projection.ts mirrors the Rust semantics (project_scoped, extension). Parity tests run the same fixtures against both, and the mock uses the mirror.
  • The single subscription replaces the per-path design. An earlier version of this PR opened one subscription per watched path. Overlapping subscriptions each applied the same structural changes (for example, an array insert applied twice), and handing data from one subscription to another raced. One changeable stream removes that class of bug.

Decisions

  • Keystreams are public. Private-package keystreams are now in public along with the index, which you accepted ("not for security reasons"). Any authenticated UI session can read them, and they appear in start-cli db dump. The browser never persists them.
  • No architecture filtering, as you asked. Filtering by architecture would need registry views multiplied by languages.
  • Release delay. A watch's data stays subscribed for 5 s after its last watcher leaves. That's the existing value, kept.

Testing

  • patch-db: cargo test -p patch-db 35/35. Property tests cover dumps, revisions, extensions and positional and shifting projections over generated documents and every pair of 20 projections.
  • start-core: make start-core-test passed 1923. That includes selection behavior (installable-first best, the incompatible fallback, raw keys, asset order), registry sync and live-socket tests, and the db subscription and parameter tests.
  • Web: check:ui 342/342 and check:rpc-clients 100/100. The second includes the OS session test with the real AuthService, LiveApiService and PatchMonitorService over a scripted socket: subscribe, widen, narrow, resume and code-34 rejection. check:shared, check:marketplace, check:tunnel, check:setup, check:brochure and check:wrt pass.
  • CI on 958e332b9: all checks that ran passed, including every image build.
  • Not exercised end to end: a StartOS box or VM running this build against a live registry. Nothing measured the bytes the marketplace pulls under the new projections, or how memory grows with many open browser sessions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants