You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clear ended SSH relay ids by recording which ones the desktop window wrote - #45291
When the last SSH terminal session on a host ended, the session save never told main, so main kept the ended relay ids. If Orca then quit without its clean shutdown (crash, force quit, hang), the next launch tried to reattach those ended sessions.
The window saves relay ids per host partition, and a host whose last relay ended gets no save at all. Simply sending an empty map isn't safe: main writes relay ids for the window's tabs too (pane moves, windowless attach, mobile terminals), and older builds left copies in other partitions, so an empty or whole-field write could erase relay ids that still work.
Change
Main records which relay ids the desktop window wrote, per partition, and the window's relay ids now go through one operation that changes only those.
Ownership record: main-owned fields on each partition, saved in the same write as the relay ids. desktopRelayOwnerByTabId stores one row per tab, like the relay ids, so a one-tab change rewrites one row and workspace removal drops its tabs' entries. desktopRelayAdoptionVersion records the legacy adoption below. The relay apply writes only these fields, skips terminal row ordering, and (for a relay-only write) tells session listeners only about the tabs whose relay ids changed. Window saves can't write them (window-save-relay-ownership.ts, like main-owned sleep records).
the window sets or removes a key only while the stored id is the one it wrote;
it can claim an id main holds only by sending the same id, and an empty key only for a tab row the partition still has; anything else is refused and main's id stays;
a host the window speaks for in full (local, its SSH repos' partitions, runtime partitions it loaded, none with rows parked for another host) loses the owned ids the window left out, which is the fix.
Main's own writers take keys back: pane moves and pane-close follow, windowless attach, mobile retirement and tab close drop the window's ownership of each key whose id they change or remove, so a stale window can't remove or revive it. Rewriting the same id keeps the window's ownership, so its later removal still lands. SSH target id migration carries ownership over to the rewritten id only where the window owned the old one. WSL moves and orcad migration drop the record with the relay ids.
Ids saved before this version: captured when main starts, before any writer runs, and adopted once per partition, only for SSH repo tabs whose row is in exactly one partition under its repo's host, including an older build's copy in another partition. Folder workspaces', ambiguous and main-written ids stay.
Wire: used only after session:desktop-relays-version answers (an older main, the paired web client, or the main-owned layout switch keep relay ids in ordinary saves as today).
In a debounced save, a host's relay ids ride with that host's session:patch-entries call. Main applies the entries, then the relay ids by ownership against the result, and publishes once.
A full save (mobile terminal close, project move pause) does the same with each host's session:set: main applies the snapshot, then the relay ids by ownership, in one write.
Hosts with relay changes but no partition write in that save go through session:apply-desktop-relays in the same turn.
Main stages a quit snapshot's relay ids with their ownership in one step.
Fenced partitions (a frozen source, a held WSL move) change nothing and are reported as skipped. Refused hosts are reported too. For debounced saves, the save subscriber keeps the terminal fields pending and resends them with the next session change. A full save (mobile terminal close, project move pause) drops its record for those hosts, so the next debounced save that carries relay ids sends them in full.
Perf: the window remembers what main last accepted per host and sends only changed ids (a delta with removals for hosts it speaks for in full). Any failed, skipped or refused write, and any full replacement (quit, unload), sends a full baseline next; removal evidence includes writes main may have stored but not yet answered, and drops ids main already removed. For a host a save leaves out, the window keeps that evidence while the host still has a live owner (a catalog repo, folder or group, parked rows, an unread partition) and drops it otherwise. Main applies a host's write by visiting only the ids it names (all stored ids only for a complete baseline) and checks only that partition's existence. A title-only save sends no relay host; one relay change sends one host with one id.
Known limits:
activeWorktreeIdsOnShutdown on an SSH partition is unchanged by this.
With the main-owned layout switch on (off in shipped builds), the window keeps relay ids in ordinary saves and main recomputes them as before, so the last ended relay on a host can still stay saved on that path.
A relay id with no owner in a partition other than its row's (an older build's leftover after a move) stays.
A relay id main writes for a session that ends before the window takes it over stays main's; the window can't clear it.
An ended relay id can survive restart on a runtime host that is offline, outside the catalog, and won an older build's duplicate rows before the SSH listing loaded (removal evidence for a host with no live owner isn't kept). Live ids are never lost.
Main's startup capture of legacy relay ids for adoption is held until each host adopts. A host whose workspaces or partition are removed before any relay write reaches it keeps its captured entry in main memory until exit: first launch after upgrade only, bounded by the startup data (KBs). The audit traced it as memory-only (no stale relay is persisted or reconnected). Accepted by the perf owner rather than adding invalidation at every removal path.
Evidence
Each fails on main:
desktop-relay-writes.test.ts: the last SSH relay ends and the partition a crash restarts from no longer holds it, while another tab's relay main saved stays; a fenced partition clears after it opens again; a host's relay ids are saved before its worktree listing loads, and for a repo that names its SSH host only by execution host id.
desktop-relay-ownership.test.ts:
an ended relay is removed and another writer's kept;
a relay main moved into a tab survives a stale set (refused) and a removal;
a same-id main write leaves the window able to remove it;
a closed tab's id isn't revived;
a host not spoken for in full is left alone;
a delta removes only the ids it names;
a pre-version relay is adopted only when offered.
desktop-relay-legacy-adoption.test.ts: only SSH repo tabs' ids are adopted (folder and unknown tabs are not), including an older build's copy in another partition.
desktop-relay-writes.test.ts also: a relay that ended while its save was unanswered is named at quit; one that ended during a save that left its incomplete host out is named when the host next goes; an ended relay main stored from a partly refused write is cleared.
desktop-relay-writes.performance.test.ts: after the first save, a tab rename sends no relay host, and one ended relay sends one host with one removed id, carried with that host's entries patch; an ended relay on a host whose other tab main keeps refusing is named once; a full save carries its changed relay with the host's snapshot (no separate relay write).
desktop-relay-ownership.performance.test.ts: an incomplete host's write reads none of the partition's other stored relay ids.
session-desktop-relays.performance.test.ts: applying relay ids never lists the saved partitions.
Performance review: BLOCKED — 2 P0 and 2 P1 findings. These are source-proven retention and operation counts; no runtime slowdown, CPU percentage, or heap size is claimed.
Reviewed origin/main...8888b14eb8d89f31c4266dce95ab93ce24bdaab6; merge base 77f4a1f023210156e27216da1e593b5ff3889542. PR head matched the requested revision. All 35 changed files and the relevant production callers, subscribers, normalization, removal, and storage paths were inspected. No checkout edits, tests, typechecks, builds, or app launches.
Every distinct retired tab adds a null owner even if it never had a desktop relay. Deletion only happens in applyDesktopRelayWrite after write.complete passes (lines 63–67). However, completeRelayHostIds at desktop-relay-writes.ts:52 includes SSH hosts through repos and runtime hosts through hydrated repo hosts. A folder-only remote host therefore never gets that acknowledgement; a headless owner has no desktop writer either. Workspace/repo removal explicitly keeps this metadata (profile-project-session-field-disposition.ts:190), and window saves preserve it. This is durable, unbounded history, not just live-terminal state.
At a fixed live population, 300 unique create/retire operations retain 300 obsolete markers; 3,000 retain 3,000. The new spread copies 44,850 versus 4,498,500 prior marker entries across those operations, before other existing session work. The SQLite split depth stores desktopRelayOwnership.relayIdByTabId as one payload, so subsequent changes serialize/rewrite the growing marker map. Main-process work, retained memory, and persisted state grow with lifetime. P0 follows the unbounded-growth criterion. Preserve stale-write protection with an acknowledgement/generation-based retirement owner that can compact these records, including folder and headless paths. Proposed guard, not executed: repeated create/close/remove at fixed live population for folder-only SSH/runtime and headless sessions must return obsolete ownership state to a bounded baseline while stale writes still cannot resurrect retired relays.
P0 — The main-process host cache retains obsolete full session snapshots indefinitely. Introducing code: session-desktop-relays.ts:60 and line 95.
lastApplied is owned by the process-lifetime IPC handler and strongly holds each host's entire WorkspaceSessionState plus its serialized relay map. There is no delete, clear, host-lifecycle subscription, or capacity bound. This survives window reloads. The production target re-adoption route reassignSshTargetId deletes the old partition key and rekeys to the replacement (ssh-target-reassignment.ts:112), but the cache still owns the old snapshot; writing the replacement adds another entry.
Price independently from terminal throughput: with four active SSH hosts, 20 rounds of replacement IDs leave 80 obsolete partition references plus their relay strings; at 40 hosts, 800. Active hosts can remain constant while this count grows without limit. Nested values may share allocations, so these counts do not imply an equal number of independent heap-sized copies. The abandoned snapshots nevertheless stay reachable, including data no live partition needs. P0 follows the unbounded-growth criterion. Evict with host removal/rekeying and avoid using a strong full-session reference merely as a cache identity. Proposed guard, not executed: write, replace/remove, and reload across repeated host generations; obsolete cache entries and retained snapshots must disappear, with unchanged-host skipping and real updates preserved.
Production route: useAppSessionPersistence → the single 150 ms debounced subscriber → buildWorkspaceSessionPatch → split/write. A durable title/tab change, PTY-map change, or repo/worktree refresh includes the complete relay map. Previously, AcknowledgedWorkspaceSessionEntries.diff omitted unchanged relay entries before IPC. The new extraction bypasses that delta path: one apply call sends every complete host's full map, main validates/copies it, and JSON.stringify walks every host's map beforelastApplied can skip it. Thus even a title-only save with zero relay changes sends all relay pairs again.
At 300 SSH relay tabs and two eligible saves/s, that is 600 relay pairs/s transmitted, validated and serialized, versus zero unchanged relay pairs on the warmed base path; at 3,000 tabs, 6,000/s. One changed relay still sends 300/3,000 pairs instead of one changed entry. Host count adds envelopes independently; this is one desktop-to-main IPC, not an SSH round trip per tab. The effect is unnecessary repeated renderer/IPC/main work that scales with the terminal fleet, hence P1 without a timing claim. The opt-in main-layout branch also bypasses caching via its early continue and invokes reconnect-fact derivation for every supplied non-runtime host; that derivation reads other partitions as well. Ordinary saves already invoked that derivation; this adds another invocation per supplied host.
Keep ownership semantics but admit/diff unchanged relay data before IPC, preserving explicit empty-host clearing, external-writer invalidation and skipped-host retry debt. Proposed guard, not executed: at 300 and 3,000 relays, unchanged eligible saves carry zero relay entries after acknowledgement and one changed tab carries only its required change; fence/reopen, main takeover and last-relay removal remain correct. The added performance test only counts downstream ownership applications for 20/200 hosts. It does not count the full payload, validation or serialization upstream of the cache.
P1 — Cold legacy adoption rebuilds the same fleet-wide tab index once per host. Introducing code: desktop-relay-legacy-adoption.ts:55, reached through the apply loop at session-desktop-relays.ts:88 and the synchronous unload staging path.
On the first save after upgrade, each partition with saved legacy relays calls uniqueSshRepoTabHosts. That function rebuilds the repo index and visits all partitions' workspaces and terminal tabs. For H adopting hosts, R repos, W saved workspaces and T saved terminal tabs, this is H × (R + W + T) synchronous main-process work instead of one shared index plus the required per-host relay checks. The version marker prevents later adoption, but does not share this initial work between hosts.
With 12 repos, 750 workspaces, 300 terminal tabs and four adopting hosts, this performs 48 repo-index insertions, 3,000 workspace visits and 1,200 tab visits. Increasing only hosts to 40 multiplies those visits by ten; increasing only tabs to 3,000 makes tab visits 12,000; jointly scaling hosts/workspaces/tabs gives 300,000 workspace and 120,000 tab visits. This amplifies cold first-save/unload CPU occupancy; duration is unmeasured. P1 is for repeated construction of identical global attribution within the migration, not for necessary one-time processing of each legacy relay. Build the attribution index once per coherent apply/staging batch, preserving ambiguity and cross-partition-copy checks. Proposed guard, not executed: cold N/10N adoption scans each partition's tab catalog once per batch, warmed adoption scans none, and ambiguous/folder entries stay unclaimed. The new handler performance fixture supplies empty repo/partition catalogs, so it does not cover this workload.
Coverage and bounds
perf-surface-detect returned three IDs and five unique files; every flagged surface was traced:
Surface
Paths and production lifetime
Disposition
startup-migration
orcad-source-workspace-session-layout.ts; ssh-target-id-migration.ts; their extraction/re-adoption callers
The donor adds one property deletion within the existing migration; no new traversal. SSH re-adoption adds ownership marking over the existing relay map and exposes retained old-host snapshots (#2). Cold ownership adoption is #4.
Promotion runs on window attachment, collecting at most one added tab ID per qualifying PTY. Retirement marks one parent tab per accepted surface; lifetime retention/copy amplification is #1.
publish
session-bridge.ts; renderer subscriber/extraction; main handlers; store/listener/storage consumers
One capability probe per API/document owner; full relay apply publication is #3. Single in-flight debounced save; pending debt is a set of session fields, not a queue of snapshots.
Six scan questions
Disposition
1. Work before skip?
Finding #3: full transport/validation/stringification precedes equality. Unrelated store writes otherwise retain the existing identity/projection gates.
2. Ownership multiplying work?
Findings #1/#2 retain dead ownership; #4 repeats one global index per adopting host. No per-pane client or new listener multiplication.
3. Thread/storage cost?
Schema validation, map copies, adoption and serialization run synchronously on main; ownership payload growth is #1. Existing selective saves use the async persistence authority; no new synchronous SQLite/filesystem calls or subprocesses.
4. Growth/progress?
Findings #1–#4. Adoption advances its version; fenced writes retain field debt and await a store wake rather than self-retrying. Full quit staging adds host/map passes, with #4 on cold adoption.
5. Execution host?
Source traced local, SSH, runtime partitions, folder ownership, paired-web fallback and WSL/migration fences. Shared JavaScript findings apply across macOS/Windows/Linux; no new host probes or per-item remote RPCs.
6. Obsolete work/cleanup?
Findings #1/#2. Subscriber disposal removes its listener/timer and field debt; an admitted persistence operation finishes for durability. No new recurring idle timer or stream capture.
Finding #4; ordinary terminal-session construction already scanned W/T on eligible saves before this diff. That pre-existing work is not separately graded as a regression.
Whole-field rewrite
Finding #1: the nested ownership map is one serialized storage part and grows with retired-tab history. Existing storage uses entry patches rather than rewriting the whole profile.
No-op state writes/publication
Ownership application compares resulting relay/owner records and returns null when equal; host identity caching can skip that application, subject to #2/#3. Existing layout stream comparisons gate unchanged output after projection; they cannot undo producer work.
Unbounded pending fan-out/retry
Checked bounds: one subscriber write in flight, one relay IPC per save, field-set retry debt; existing host patch fan-out remains proportional to distinct partitions. No new per-tab subprocess/network queue.
Startup import work
New ownership/adoption modules contain map operations and a schema; no new SDK/native initialization. Probe cost is one request/reply per document/API owner. Fleet-dependent startup work is #4.
Evidence limits: static review on the macOS checkout only; no runtime tests, profiles, live SSH/Windows/WSL/Linux runs, or timing/heap measurements. Added test assertions were inspected, not executed. Source counts establish the findings; proposed remedies and guards remain unverified. No runtime performance gate or release action was added.
Performance review: blocked — three source-proven regressions at 8a382a15f1ba422005015a18b04e8b6b832a62eb.
[P1] Preserve entry-level storage for ownership updates.desktop-relay-ownership.ts:97–101 introduces desktopRelayOwnership.relayIdByTabId, one level deeper than ordinary tab-keyed session fields. The persisted split depths remain 2 for local sessions and 3 for host sessions (profile-state-document-parts.ts:25–29). Consequently, the entire ownership map is one leaf/database part. A one-tab ownership change creates a new map; WorkspaceSessionSaveBaseline.diff serializes that whole map on Electron main (workspace-session-save-baseline.ts:65–76) before sending it to the persistence worker. The narrow renderer delta therefore becomes an O(R) serialization and row replacement, where R is that host's owned relays; existing remoteSessionIdsByTabId entries are individually split.
At R=300, one persisted change serializes 300 ownership entries instead of one; at R=3,000 it serializes 3,000. During sustained changes, the existing five-second maximum save delay gives approximately 60/600 ownership entries serialized per second respectively, versus 0.2 changed entries/s. This is a source count, not a CPU or latency measurement. It adds main-thread allocation and storage write amplification as terminal populations grow. Keep the ownership values individually addressable in the persisted representation while preserving the adoption version and atomic ownership/relay update.
The new separate commit also adds unrelated main work: a save that changes both the active-worktree list and a relay binding now calls the ordinary partition patch and then session-desktop-relays.ts:106. Both reach SessionSnapshotOperations.publishSession with topology processing enabled, so orderTerminalRowsByTabGroups visits the partition twice, versus once before this change. At 750/7,500 worktree keys on that host, that is 1,500/15,000 key visits per such save, plus two synchronous write-listener traversals. A relay-only commit needs a path that avoids unrelated topology work, or the changes should commit together.
Proposed check, not run: at 300 and 3,000 owned relays, change one binding through the real main handler and save baseline. Assert one ownership-entry payload, bounded payload bytes for a fixed-length ID, and no extra topology traversal; retain controls for ownership refusal, last-relay removal and durable restart.
[P1] Do not rediscover a known changed tab by diffing every relay.mobile-session-terminal-persistence-retirement.ts:206–208 adds changedRelayKeys after code that can modify only surface.parentTabId. That helper enumerates both complete maps, builds a Set and compares every key. Argument evaluation performs this scan even when forgetDesktopRelayKeys immediately returns because there is no ownership record. The pane-close/detach and terminal-leaf-move additions repeat the same pattern for one or two already-known tab IDs. These are reachable synchronous main-process close/move paths, including mobile surface closes and legacy retirement sanitization.
With 300/3,000 relay entries, one close adds roughly 300/3,000 comparisons plus two full key enumerations, instead of one known-key comparison. Retiring a shrinking population of 300/3,000 bindings adds approximately 45,150/4,501,500 comparisons over the burst. These scans were absent before the diff; the existing relay-map copies are separate, pre-existing work. forgetDesktopRelayKeys also copies the full ownership map before discovering that the supplied keys own nothing. This adds avoidable allocation during terminal close and pane movement.
Compare only the known source/destination keys, preserve ownership when their IDs are unchanged, and check ownership membership before copying on a no-op. Proposed check, not run: use the real retirement/move seam at N and 10N; require a constant number of key comparisons, zero whole-map diffs and zero ownership copies for unchanged/unowned keys. A changed owned key must still be forgotten, and an identical main rewrite must retain ownership.
[P1] Release ownership entries when their workspace/repo is removed.profile-project-session-field-disposition.ts:190–193 explicitly keeps the new record on workspace removal. removeWorkspaceSessionOwner removes the corresponding relay IDs through the ownerTabKey census, but leaves their nested ownership entries. Removing the last repo on an SSH host follows this path and retains the host partition (repo-lifecycle-operations.ts:124–144, profile-project-session-state.ts:139–147).
There is no reliable subsequent cleanup for that retired partition: completeRelayHostIds derives SSH hosts from the remaining repos, so the removed host is absent; an empty, incomplete slice is excluded by takeDesktopRelayWrite. Renderer acknowledgement pruning only deletes the renderer's cache, not main's record. A future complete baseline could heal it if the host is used again, but ordinary saves and restarts need not send one. Thus removing workspaces containing 300/3,000 owned relays can retain 300/3,000 dead ownership entries, versus zero such entries before this change. They remain in main memory and persisted session data after their tab rows and bindings have gone. This is retained-record evidence; heap bytes are unmeasured.
Remove the deleted tab IDs from the nested ownership map in the existing workspace-removal census, preserving the partition's adoption version and surviving tabs' bindings. Proposed check, not run: establish ownership, remove the host's last repo through the real lifecycle path, then save/reload with no repo on that host. At N and 10N, removed ownership entries must be zero while another workspace's ownership remains intact.
Coverage and evidence
Compared the requested three-dot range; its merge base is 77f4a1f023210156e27216da1e593b5ff3889542. All 37 changed files were reviewed along with production callers, removal paths, store publication, save-baseline splitting and worker-write routing. The detector reported three surface IDs across five unique paths:
Surface
Paths and disposition
startup-migration
orcad-source-workspace-session-layout.ts: ownership deletion is one extra property deletion per migrated fragment; existing tab/layout traversal is unchanged. ssh-target-id-migration.ts: ownership rewriting runs only when relay rewriting changes that partition, one extra O(R) pass for required rewritten output; no new SSH call or subprocess.
hot-path
session-graph-promotion.ts: windowless handoff runs on attachment/promotion, once per affected host, rather than on terminal output/status; existing PTY discovery remains. mobile-session-terminal-persistence-retirement.ts: finding 2.
publish
session-bridge.ts: capability probe is cached once per API identity/window. Accepted unchanged relay state produces no relay IPC; one changed binding sends one host/delta. Main persistence expands that work as described in finding 1.
The six scan questions were assessed as follows:
Question
Disposition
Work before skip gates
Renderer acknowledgement gates and main patch: null suppress unchanged relay publication. Full terminal projection/routing on relevant terminal saves predates the diff. Findings 1–2 identify new downstream work.
Ownership multiplicity/lifetime
One renderer acknowledgement cache per window, keyed by host; missing hosts are removed there and API changes invalidate it. Main removal has the lifetime gap in finding 3. No per-pane client, poll or subscription was introduced.
Thread/storage cost
Apply/diff and JSON preparation execute synchronously on Electron main; durable database work uses the existing worker route. Finding 1 follows the actual split depths, rather than assuming a wire delta implies a storage delta.
Growth/progress
Legacy capture visits H hosts and copies only unadopted saved IDs once at handler registration. Adoption indexes fleet tab rows at most once per relevant batch; consuming the baseline and persisted version prevent repeated adoption. Refused/skipped writes retain a fixed set of pending field names and retry on later real session changes, with one subscriber write in flight, not an autonomous retry timer. Findings 1–3 cover disproportionate growth.
Execution host
Inspected desktop local/SSH partitions, runtime-host hydration, contested hosts, folder-workspace exclusions, SSH ID migration, WSL binding removal and paired-client/older-main fallback. Added operations are in-memory/IPC/persistence; no per-terminal SSH round trip or platform subprocess was added. macOS, Windows and Linux runtime behavior was not exercised.
Obsolete work/cleanup
Subscriber disposal removes its listener/timer; acknowledgement invalidation rejects obsolete generations. Full replacement/unload invalidates the cache and stages ownership with relays. Main close/move paths drop changed-key ownership, but do unnecessary scans (finding 2); whole-workspace removal leaves records (finding 3).
Touched recurring regression classes: whole-map serialization/row replacement and broad publication — finding 1; hot-path rescans and no-op allocation — finding 2; per-entity state outliving its entity — finding 3. Unchanged publication was matched and disproved by the acknowledgement and null-patch gates. Retry/queue multiplication was screened: no new periodic producer, one subscriber write in flight, fixed-size field debt. Startup rereads were screened: store getters return in-memory state; no new filesystem read, native probe or heavy adapter initialization was introduced. Existing full terminal projection, map copies, unscoped store listeners and row-order processing are pre-existing; their newly added executions are distinguished above.
Validation limits: source inspection only. No tests, typechecks, builds, application launches or timing/CPU/heap measurements were run. The added performance test was inspected: it asserts wire host/ID counts using an in-memory main fixture that bypasses the real Store/save-baseline path, so it does not cover these findings. Startup, unload, reconnect and cross-platform runtime timings remain unmeasured. Proposed remedies and guards above are unverified. Checkout unchanged.
Performance review: BLOCKED — two P1 findings. Source inspection of origin/main...14fa89ace76d32b76e5e366d6bc8b3240a373004 (merge base 77f4a1f023210156e27216da1e593b5ff3889542). Counts below follow production code; no timing, CPU or heap measurements are claimed.
A debounced save changing tab data and a relay binding sends the ordinary partition patch and the separate relay apply (workspace-session-host-persistence.ts:292–304). Each changes the same host and calls scheduleSave. Passing topologyChanged=false correctly skips row ordering, but still sends a second unscoped notifyWorkspaceSessionWritten (write-scheduling.ts:150). Before this diff, these fields traveled in one partition patch and notified once.
This has a concrete synchronous consumer: saved-conversation-title-publication.ts:39 calls StructuredConversationLabelChanges.reconcile, whose loop (structured-conversation-label-changes.ts:90–127) rechecks every cached conversation workspace and rebuilds aliases for those on the written host. Relay ownership cannot change those aliases. For 100 cached conversation workspaces on that host, each combined save now does 200 workspace checks instead of 100; at two eligible saves/s, that is 200 extra workspace checks/s. At 1,000 cached workspaces, it is 2,000 extra/s. No timing threshold is needed for this repeated, fleet-sized unrelated work.
With a live layout.subscribe reader, the unscoped notice also marks the whole partition stale (workspace-layout-projection.ts:124–140), leading to a whole-session clone/load and publication preparation (workspace-layout-load.ts:194–246, workspace-layout-projection.ts:72–98). Its microtask batching only combines writes within a task; separate IPC deliveries can each reload. At 750/7,500 workspace keys, an additional whole reload visits 750/7,500 workspaces and clones that partition's session bytes before final equality suppresses unchanged frames. The synchronous title reconciliation above does not depend on this scheduling detail or on a layout subscriber.
Impact: extra main-thread allocation and reconciliation on terminal lifecycle saves, including unrelated saved chats. This is the remaining notification portion of the earlier P1 Linux support #1; bypassing topology ordering fixes only its ordering portion. Coalesce the ordinary and relay changes into one publication, or give relay writes a consumer-appropriate change scope that avoids unrelated title work while preserving relay-dependent layout freshness. Proposed guard, unexecuted: through the real handler/Store and subscribed consumers, change one tab plus its relay at N/10N; require one coherent session publication, no second alias scan, and correct final relay/layout state, refusal and last-relay removal.
This finding applies to the opt-in ORCA_LAYOUT_OWNER=main branch; the shipped window-owned branch narrows correctly. A tab title change rebuilds terminal save fields (workspace-session-patch.ts:116–137) even when every relay is unchanged. Main-owned layout deliberately sends the full host list instead of using AcknowledgedDesktopRelays. Each existing non-runtime host calls patchWindowRelays → patchWindowSession → windowViewPatchForMain → shutdownReconnectFactsFor, in addition to the ordinary patch path. deriveShutdownReconnectFacts scans its own tabs and all other partitions' tabs (shutdown-reconnect-facts.ts:73–87); the other-partition route is wired in restored-terminal-placement.ts:240–246. This is local main-process work, not an SSH RPC per tab.
With four SSH hosts plus local, five existing partitions and 300 total tabs, one unchanged-relay title save adds at least 5 × 300 = 1,500 tab visits, before active-workspace derivation, pane traversal, validation, topology ordering and notifications. At two saves/s, that is 3,000 additional tab visits/s. Scaling only tabs to 3,000 makes it 30,000/s; scaling only SSH hosts to 40 with 300 total tabs makes it 24,600/s. These are extra calls compared with the base's ordinary save, whose existing scans are separate. The new handler also publishes on this branch without the window-owned no-op gate. Thus a local title interaction now triggers repeated global work for unchanged hosts.
Impact: main-thread work grows with complete hosts × total terminals on ordinary terminal saves. Preserve main's reconnect authority while admitting only relevant changes, or derive once per coherent save and reuse the result; merely suppressing final frames is too late. Proposed guard, unexecuted: enable main-owned layout and drive the real title-save route at N/10N hosts and terminals; after warming, assert no extra relay IPC/global reconnect derivations for unchanged relay input. Include live-exit, main takeover and reconnect-freshness controls before accepting a remedy.
Recheck of comment 7034145708
Earlier P1
Disposition at this head
#1: nested ownership became one storage leaf; separate commit repeated topology/publication
Storage and ordering fixed; publication remains finding 1.desktopRelayOwnerByTabId is now a top-level scalar-valued map. At split depths 2 local / 3 host, one ownership change serializes one scalar leaf at 300 or 3,000 entries; the adoption version is a separate scalar. The save baseline still visits map keys to diff them, but no longer serializes/replaces the entire ownership map. The relay-specific method skips row ordering.
#2: close/move rediscovered known changed keys by scanning all relays
Fixed by source. Retirement and pane-close pass one known tab ID; detach/leaf-move pass two. changedRelayKeys enumerates only those IDs. forgetDesktopRelayKeys checks membership before copying, so an unowned/unchanged key causes zero ownership-map copies at 300 or 3,000 relays. A real owned deletion still copies the immutable owner map.
Fixed by source. The flattened ownership map uses onWorkspaceRemoval: ownerTabKey. The existing deleteOwnerKeyedSessionFields census deletes each removed legacy/unified terminal ID from ownership and relay fields, through single/batch/every-partition removal and repo removal. Removing 300/3,000 such tab IDs leaves zero corresponding owner entries, without needing a later renderer baseline; the adoption version remains.
Coverage
All 39 changed files were inspected with relevant production callers, acknowledgement/invalidation, lifecycle removal, session listeners, layout projection and durable-storage consumers. perf-surface-detect returned three IDs across six unique paths; every flagged surface was covered:
Surface
Paths and source bounds
publish
session-snapshot-operations.ts, session-bridge.ts, plus renderer subscriber/diff, main handlers and storage. Findings 1–2. Window-owned acknowledged saves send zero relay hosts when unchanged and one changed/removed ID for one changed binding; Zod validates the narrowed payload. Null patches publish nothing. Probe is once per API identity/document.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, pane-close/detach/leaf-move and tab-close. Promotion runs on window attachment/handoff, processing qualifying PTYs once per affected host; no per-output/status invocation was added. Known-key close/move comparison is constant (one/two IDs); owner copies occur only for actual owned removals.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy adoption. Donor extraction adds two property deletions per fragment, no new traversal. SSH ID reassignment updates ownership in one pass over the rewritten relay output only when bindings change; no new transport or subprocess. Legacy capture copies at most the startup's unadopted saved relay entries; the lazy tab-attribution index is shared once per apply batch, not rebuilt per host. Consumed baseline entries are deleted and persisted adoption versions prevent restart repetition.
Six scan questions
Disposition
1. Work before skip?
Reviewed: window-owned acknowledgement gates wire payloads; findings 1–2 identify downstream/global work and the main-owned bypass. Existing terminal projection/routing still precedes delta comparison, as on the base.
2. Ownership multiplying work?
Reviewed: one renderer acknowledgement cache per document, pruned for absent hosts and reset on API/replacement/failure; no new per-pane clients/listeners. Finding 1 repeats existing consumers; finding 2 multiplies global scans by hosts.
3. Thread/storage cost?
Reviewed: validation, immutable map copies, adoption and baseline JSON preparation run on Electron main. Ownership now has entry-level persistence; database writes retain the existing worker route. No new synchronous filesystem/SQLite call or subprocess was added.
4. Growth/progress?
Reviewed: no growing snapshot queue. One subscriber write in flight; pending/deferred debt is a set of session field names. Refused/fenced writes retry on subsequent real changes, with no autonomous retry timer. Migration version and consumed legacy baseline advance; teardown removes ownership keys.
5. Execution host?
Reviewed in source: local/SSH/runtime partitions, runtime hydration, contested partitions, folder ownership/removal, paired-client/older-main fallback, SSH reassignment, frozen migration and WSL fences. Shared JavaScript work applies across macOS/Windows/Linux; no per-tab remote round trip or new host probe. Main-owned mode is explicitly separated in finding 2.
6. Obsolete work stops?
Reviewed: subscriber cleanup removes listener/timer and stops admission; admitted writes finish for durability. Acknowledgement generations reject obsolete completion after replacement. Full quit/unload stages per-host relay state with snapshots and skips legacy attribution until placement is settled. Legacy-baseline retention is bounded by startup input, not ongoing churn. No new recurring idle capture/poll or abandoned full-session cache.
Touched regression classes: whole-map serialization/row replacement — earlier defect fixed by flattening; hot-path rescans/no-op copies — earlier defect fixed with known-key admission; per-entity state outliving its entity — earlier defect fixed by removal census; broad/duplicate publication and work before equality — finding 1; unchanged input reconstruction, full snapshots and host-multiplied scans — finding 2. Retry/queue multiplication was matched and bounded as above. Startup imports add lightweight ownership/schema modules, with no new SDK/native adapter initialization. No new React component subscription or per-mounted-instance resource owner was introduced.
Pre-existing amplification: full terminal projection/routing on relevant saves remains O(workspaces + tabs); ordinary unscoped session writes can clone/load whole partitions for subscribed layouts and reconcile cached conversation aliases. A base combined save did this once per written host. Finding 1 identifies the added notification/consumer execution; finding 2 identifies new calls to existing reconnect scans. These existing costs are not independently graded as regressions.
Validation limits: read-only source review. No tests, typechecks, builds, app launches or runtime measurements were run, as requested. The added performance test was inspected but not executed: it checks wire payloads with one tab using an in-memory main fixture; it bypasses real Store publication, listeners, save-baseline persistence and main-owned mode, so it does not guard these findings. Proposed fixes/guards remain unverified. Runtime timings, cross-platform execution and unload/reconnect behavior were not measured. Checkout unchanged.
In the shipped window-owned layout path, a debounced save changing terminal rows and a relay binding sends an ordinary host patch and then a separate relay apply (workspace-session-host-persistence.ts:283–291). Both publish the same host through scheduleSave. The new empty workspace scope plus changed-row refs correctly describes the relay write, but saved-conversation-title-publication.ts:39 accepts only hostId, discarding that scope. It synchronously calls StructuredConversationLabelChanges.reconcile, which visits every cached conversation workspace and rebuilds aliases for those on that host (structured-conversation-label-changes.ts:90–127). Relay IDs and ownership cannot change those aliases.
Price: with 100 cached conversation workspaces, one combined save now performs 200 workspace checks instead of 100. At two eligible lifecycle saves/s, this adds 200 checks/s on Electron main, plus alias arrays/maps; at 1,000 cached workspaces it adds 2,000 checks/s. There is one tracker per runtime, not one per terminal. These are source-derived counts, not measured durations. Before the diff these fields shared one publication. This remains the publication portion of both earlier reviews' P1 Linux support #1.
A subscribed layout reader also remains exposed: WorkspaceLayoutProjection.invalidate explicitly ignores partial scope in window-owned builds (workspace-layout-projection.ts:135–139). Separate IPC tasks can therefore cause a second whole-partition load and publication preparation: another 750/7,500 workspace visits plus cloning the partition's session bytes, before final equality suppresses unchanged frames. The synchronous conversation scan above proves the finding independently of that scheduling case.
Remedy/check, proposed and unexecuted: commit ordinary and relay changes coherently once, or propagate a change kind/scope that unrelated consumers actually honor. Preserve relay-dependent layout freshness. Through the real handler, Store and title/layout consumers at N/10N, a combined tab/relay update should cause no second alias scan; verify final binding, last-relay removal, refusal and restart durability.
P1 — A one-ID relay delta still rediscovers changes by comparing the entire ownership map. Introducing comparisons: desktop-relay-ownership.ts:95–96.
The renderer now sends a precise delta with removedTabIds, and lines 62–64 correctly limit touched to those known keys. Nevertheless, after applying it, sameRecord enumerates both complete relay maps and both complete ownership maps; equal-sized maps also compare values until the first difference (desktop-relay-ownership.ts:155–162). Only touched/adopted keys can differ, as the following changed-ID calculation already recognizes. The whole-map equality pass is unnecessary for determining whether either field changed.
Trigger/price: each actual relay replacement/removal reaches this synchronously through session:apply-desktop-relays, once per changed host. Removing one owned ID from R owned relays enumerates 2R−1 ownership keys solely for equality: 599 at R=300, 5,999 at R=3,000, versus one known-key comparison. At two removals/s that adds 1,198/11,998 ownership-key visits/s and temporary key arrays. The separate relay-map comparison does another whole-map enumeration. For an equal-sized replacement at the end of insertion order, each comparison can additionally inspect R values. The new ownership equality pass has no counterpart in the base. Existing relay-map copying/equality and the immutable copies needed to produce changed records are separate costs; they do not require this additional global change discovery.
Impact: repeated, avoidable main-thread allocation and fleet-sized scanning on terminal lifecycle saves, despite the narrowed wire payload. No timing or CPU claim is needed for this count regression.
Remedy/check, proposed and unexecuted: determine relay/owner changes from touched and adopted keys, with lazy copying for unchanged/refused input; retain complete-baseline omission semantics. A production-seam performance contract at 300/3,000 relays should require zero whole-map equality scans for a one-ID delta and zero output-map copies for a refused/no-op delta, while meaningful replacement, removal, adoption and takeover controls still pass.
Earlier P1 recheck
Earlier report
Disposition at this head
7034145708 #1: storage leaf, topology and publication amplification
Storage and ordering fixed; publication remains finding 1. desktopRelayOwnerByTabId is flat: split depths 2 local / 3 host persist a changed ownership scalar individually at both 300 and 3,000 entries. Relay publication passes topologyChanged=false, so no added row-order traversal.
7034145708 #2: global changed-key discovery on close/move
Fixed in those paths. Retirement/pane-close compare one supplied tab ID; detach/leaf-move compare two. forgetDesktopRelayKeys checks membership before copying: zero ownership copies for unchanged/unowned keys at either population. Finding 2 concerns the separate apply path.
Fixed. onWorkspaceRemoval: ownerTabKey feeds the existing legacy/unified-tab deletion census, including last-repo removal in retained host partitions. Removing 300/3,000 owner tab IDs deletes all corresponding ownership entries without a future renderer baseline; adoption version survives.
Fixed by source. probeDesktopRelays disables the separate protocol when ORCA_LAYOUT_OWNER_IS_MAIN (desktop-relay-writes.ts:44–46). Relays stay in the ordinary save. The added separate relay IPC/reconnect derivations are zero per title save at 4/40 SSH hosts and 300/3,000 terminals. Existing ordinary-save reconnect work remains.
Coverage and bounds
Reviewed all 39 changed files and relevant production callers/consumers for origin/main...0645075cc9e4c5d727b78a1aa3ea748a5736075f; merge base 77f4a1f023210156e27216da1e593b5ff3889542. Remote PR head matches. Every detector surface was covered:
Surface
Paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts; traced renderer subscriber → host split/acknowledgement → IPC → apply → Store listeners → layout/title consumers and entry-level storage. Findings 1–2. Warm unchanged relays send zero relay hosts; one changed ID sends one host/ID. Probe runs once per API identity/document; null patches publish nothing.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, plus pane/tab close and move callers. Promotion runs on desktop attachment after a windowless gap, not PTY output/status; adds one comparison per qualifying PTY. Retirement checks one known key. Owned changes copy one immutable owner map; unchanged/unowned cleanup copies none.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy capture/adoption. Migration adds two property deletions per fragment. SSH reassignment adds one O(R) ownership pass only when that partition's IDs were rewritten, for required output, with zero new remote calls. Legacy capture is O(H+R) once at handler registration; adoption indexes fleet rows at most once per applicable batch, deletes each consumed host baseline and persists its adoption version.
Six scan questions
Disposition
Work before skip gates
Reviewed renderer field/admission gates, acknowledgement narrowing, main null-patch handling and downstream consumers. Findings 1–2 identify work remaining after the wire gate.
Ownership multiplication
One acknowledgement cache per document/API, keyed by host; obsolete generations cannot acknowledge, missing hosts are pruned. One main apply per changed host. No added per-pane client, subscription or poll.
Thread/storage
Apply, comparisons and listener reconciliation pay on Electron main. Storage uses the existing persistence worker and split scalar leaves; one changed binding writes one relay leaf and one owner leaf, not R-entry JSON payloads. Save-baseline container enumeration remains O(R).
Growth/progress
Ownership/cache populations follow current host/tab records, with removal paths inspected. Legacy retained copies are bounded by unadopted startup IDs, never replenished; fenced hosts retain their baseline until adoption. Retry debt is a fixed set of field names, retried with later real session changes; one subscriber save in flight. Findings cover repeated disproportionate work.
Execution host
Inspected local/SSH/runtime partitions, hydration, contested hosts, folder-workspace exclusions, SSH re-adoption, WSL rewrite/fences and paired/older-main fallback. Added operations use memory/IPC/storage, with zero per-ID SSH round trips or subprocesses. macOS/Linux/Windows behavior was inspected, not executed.
Obsolete work/release
Subscriber disposal removes its timer/listener; replacement/unload forgets acknowledgement and stages relay/ownership together. No legacy-adoption scan runs during unload; staging adds O(H+R+T) synchronous work per full checkpoint, including apply's comparisons, with no repeated producer. Close/move/removal release ownership through the relevant tab census. Added steady-idle timer/IPC wakeups: 0/s in renderer, main and daemon.
Touched recurring classes: broad publication/unrelated consumers — finding 1; hot-path rescans/work before no-op gates — finding 2; whole-map storage writes — matched, storage layout fixed; per-entity retention — matched, removal census fixed; unchanged publication — matched, acknowledgement/null-patch gates suppress it; retry/queue fan-out and idle wakeups — checked, one in-flight subscriber save, fixed field debt, no autonomous retry or new periodic producer; startup rereads/imports — in-memory store access, no new disk probe or heavy startup adapter.
Pre-existing scaling work was also traced: relevant terminal saves rebuild/project and route the terminal population O(T), renderer acknowledgement compares current host records O(R), save-baseline snapshots visit ownership/relay keys O(R), and an ordinary session publication reconciles cached conversation workspaces O(C). These are distinct from the extra reconciliation and global equality passes identified above. Immutable owner-record output adds R scalar slots per affected host when a real owner change requires a new record; it does not grow with terminal history.
Validation limits: source inspection only, including the added assertions; no tests, typechecks, builds, application launches or timing/CPU/heap measurements were run. The added performance test checks wire payloads through an in-memory main fixture; it bypasses real Store notification/storage consumers and does not count apply-time whole-map comparisons, so it does not guard either finding. Runtime startup/unload latency and platform transport behavior remain unmeasured. Proposed fixes/guards are unverified. Checkout unchanged.
Performance review: BLOCKED — one P1 finding at 85661cfd6bf5eae324805db861330def7a6f953d. The P1s reported in comments 7034145708, 7034431725 and 7034648570 are fixed by source inspection; the finding below is a different remaining path.
P1 — Reject a conflicting existing relay before indexing the partition's terminal rows. Introducing code: desktop-relay-ownership.ts:77.
When main holds another relay for a tab and the window no longer owns that binding, current !== wanted, owned === false, and current !== undefined. The result must be refusal regardless of whether the tab has a row. Nevertheless, line 77 calls tabIdsWithRows(session) before checking current === undefined. That helper enumerates every workspace bucket, visits every terminal row and allocates a Set containing their IDs (lines 160–167). A single conflicting ID therefore causes an unnecessary O(W + T) scan on Electron main, even when the apply returns no patch.
This is reachable through both the carried entries handler (session.ts:119) and the separate apply handler. A production source of the conflict is a main-side pane close that replaces a tab's saved relay with the surviving pane's relay and forgets the old ownership (pane-remote-session-follow.ts:18–35), followed by an already queued/stale window save. Refusal discards that host's acknowledgement (desktop-relay-acknowledged-hosts.ts:45–54) and returns pending ptyIdsByTabId (desktop-relay-writes.ts:142–146); subsequent real session changes carry that debt (session-write-subscriber.ts:258–262). Until the window reconciles, those retries repeat the scan. There is no autonomous retry timer.
Price: for one affected host containing 300 terminal rows, each conflicting apply adds 300 row visits/Set insertions; at 3,000 rows it adds 3,000, where the refusal needs zero row visits. At two eligible saves/s while the conflict remains, that is 600/6,000 unnecessary row visits/s, plus workspace-bucket enumeration. Independently, 750/7,500 workspace buckets add 1,500/15,000 bucket visits/s at that rate. Count this once per affected host/apply, not once per conflicting ID: the Set is reused within one apply. These are source-derived counts, not measured durations. The new ownership protocol introduces this work; existing session projection, immutable map copies and ordinary publication are separate costs.
Impact/remedy: avoidable main-thread allocation and scanning during terminal lifecycle saves, amplified by the recovery path. Check the existing-ID conflict before building the live-row index; retain membership validation for an empty binding and preserve ownership refusal/retry semantics. Proposed guard, unexecuted: through the production apply seam at 300/3,000 rows, send one conflicting existing-key delta and then retry it. Require refusal, unchanged saved binding and zero terminal-row enumeration/output-map copies. Also check a valid empty-key claim, a missing-row refusal, replacement/removal of an owned ID and legacy adoption. The remedy has not been implemented or validated.
Fixed. Ownership is the flat desktopRelayOwnerByTabId map. Split depths 2 local / 3 host make one changed ownership value one scalar storage leaf at 300 and 3,000 entries. patchWorkspaceSessionRelays skips topology ordering. The production subscriber supplies entry acknowledgements; planDesktopRelayWrite carries each present host's relay delta with its entries. Main merges both into one ordinary publication, or makes one relay-only publication when the entries are unchanged (session.ts:126–135).
7034145708 #2: global changed-key discovery on close/move
Fixed. Retirement/pane-close compare one supplied ID; detach/leaf-move compare two. forgetDesktopRelayKeys checks membership before copying: zero ownership copies for unchanged/unowned keys at either population.
Fixed.onWorkspaceRemoval: ownerTabKey feeds deleteOwnerKeyedSessionFields, covering legacy and unified terminal IDs, single/batch/every-partition removal and last-repo removal. Deleting 300/3,000 tab IDs deletes their ownership entries without a future renderer baseline; adoption version survives.
7034431725 #1 and 7034648570 #1: split debounced save repeats unrelated consumers
Fixed for the reported production route. Carrying relay changes with the same host's entries removes the second publication, hence the extra alias reconciliation and potential second layout reload. A host absent from the entry slices can receive a separate relay write, but has no ordinary host write to duplicate. Existing title listeners still ignore scope and window-owned layout readers still reload whole partitions on a real publication; those broad consumers predate this span.
Fixed.probeDesktopRelays disables this protocol for main-owned layout. A title save adds zero separate relay IPC/reconnect derivations at 4/40 SSH hosts and 300/3,000 terminals. Existing ordinary-save reconnect work remains.
7034648570 #2: whole-map apply equality after a one-ID delta
Fixed. Apply records candidate changes and compares only touched/adopted keys (lines 97–98); sameRecord is gone. A one-ID removal compares that ID, with zero whole-map equality passes at 300/3,000 entries. Changed immutable output maps still require copying; unchanged/refused maps are not copied. The finding above concerns row discovery on refusal, not equality.
Coverage: inspected all 40 changed files and relevant production callers, lifecycle cleanup, acknowledgement/invalidation, Store publication, title/layout consumers and persistence splitting for origin/main...85661cfd6bf5eae324805db861330def7a6f953d (merge base 77f4a1f023210156e27216da1e593b5ff3889542). Remote PR head matches. Every detector surface was covered:
Surface
Paths, trigger and bounds
publish
session-snapshot-operations.ts, session-bridge.ts; traced subscriber → field projection/host routing → acknowledgement/entry carrier → IPC validation/apply → Store listeners → storage. Warm unchanged relays send zero relay hosts; one changed ID sends one host/ID. Probe runs once per API identity/document. Null relay patches publish nothing. Main apply has the P1 above.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, plus close/detach/leaf-move/tab-close. Windowless attachment adds comparisons only for its qualifying PTYs, once per handoff, not per PTY output/status event. Retirement checks one known key. Ownership deletion copies a record only when an owned key really changes; no per-pane client/listener/poll was added.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy capture/adoption. Fragment migration adds two property deletions. SSH reassignment adds an ownership pass only for a partition whose relay IDs were actually rewritten, with zero extra subprocesses/SSH calls. Legacy capture copies unadopted startup IDs once; consumption and persisted version stop repeat adoption. Separate apply batches share one global row index; carried entry calls each have their own applier, so D adopting hosts can visit D × (W + T) rows/buckets once during upgrade, rather than once for the whole renderer save. For D=5, W=750, T=300 that is 5,250 visits; scaling each by 10 gives 525,000. These are bounded upgrade counts; cold-start latency was not measured.
Six scan questions
Disposition
Work before skip gates
Reviewed field identity/projection gates, capability probe, acknowledgement, main null-patch and downstream publication. Existing-key refusal indexes rows before its decisive gate: P1 above.
Ownership multiplication/lifetime
One renderer host cache per document/API; missing hosts are pruned and obsolete generations cannot acknowledge. Main ownership follows tab cleanup. No new per-row resource owner.
Thread/storage
Apply and listener callbacks run synchronously on Electron main. Durable database writes use the existing worker path. A changed binding persists scalar relay/owner leaves, not a whole ownership JSON leaf. Save-baseline snapshots still visit map keys.
Growth/progress
Current host/tab records bound caches and ownership. Startup legacy copies are never replenished; consumed host baselines are deleted. Deferred debt contains fixed field names and rides later real session changes. One subscriber write is in flight; all partition writes settle before retry. Refusal can repeat the P1 scan.
Execution host
Inspected local, SSH and runtime partitions, runtime hydration/contested hosts, folder-workspace exclusions, SSH ID migration, WSL binding removal/fences and older-main/paired-client fallback. New work is memory/IPC/storage; no per-ID remote round trip or platform process was introduced. macOS/Linux/Windows were inspected, not exercised.
Obsolete work/release
Disposal removes subscriber timer/listener; replacement/unload invalidates acknowledgement. Unload applies relay/ownership with staged snapshots and skips legacy adoption. Close/move/workspace/repo deletion releases ownership. Added steady-idle wakeups are 0/s in renderer/main/daemon: retries require real changes and no periodic producer was added.
Touched recurring classes: work before skip gates / hot-path rescans — finding; duplicate publication — matched, reported path fixed; unchanged publication/no-op allocation — acknowledgement and null-patch gates suppress it; whole-map storage replacement — scalar split fixed; per-entity retention — removal census fixed; retry/queue amplification — one subscriber write in flight, fixed field debt, no autonomous retry; startup rereads/eager imports — in-memory getters and existing lightweight modules, no added disk probe or heavy adapter.
Pre-existing work remains distinct: relevant terminal saves project/route the terminal population; entry acknowledgement already compared relay keys before this protocol moved them into its own acknowledgement record; ordinary publication reconciles cached conversation workspaces and can reload whole layout partitions. Adding the ownership field adds necessary current-state storage and immutable owner-map output on real changes. None of those observations excuses the independently avoidable refusal scan.
Validation limits: source inspection only, including the added test assertions. No tests, typechecks, builds, application launches or timing/CPU/heap measurements were run. The performance fixture checks narrow wire payloads and carriage with entries, bypassing real Store consumers; it does not count terminal-row discovery for conflicting writes. Runtime startup/unload latency and cross-platform transport behavior remain unmeasured. Checkout unchanged.
Performance review: CLEAN by source inspection at 105c5cde3d025930c2f8f363b979504114253e68. No remaining P0/P1 performance regression identified. Every P1 in comments 7034145708, 7034431725, 7034648570 and 7034953583 is fixed in the inspected production paths. This is a source-based verdict, with no runtime speed, CPU or memory claim.
Reviewed origin/main...105c5cde3d025930c2f8f363b979504114253e68, merge base 77f4a1f023210156e27216da1e593b5ff3889542. PR head matches the requested revision. Inspected all 41 changed files, including test assertions, and relevant production callers, session listeners, removal census, storage splitting and worker-write routing.
Earlier P1s
Report / finding
Disposition and evidence at this head
7034145708 #1: ownership stored as one large leaf; extra topology/publication
Fixed. Ownership is the flat desktopRelayOwnerByTabId field. Local/host split depths are 2/3 (profile-state-document-parts.ts:25); a one-ID change serializes one owner scalar rather than 300/3,000 owner entries. patchWorkspaceSessionRelays skips topology ordering (session-snapshot-operations.ts:144). The normal subscriber supplies entry acknowledgements, so relay changes ride with their host's entries and merge into one publication (session.ts:119–135).
7034145708 #2: global close/move change discovery and no-op copies
Fixed. Retirement/pane-close compare one supplied tab ID; detach/leaf-move compare two. changedRelayKeys checks only these keys, and forgetDesktopRelayKeys tests membership before copying (desktop-relay-ownership.ts:132–158). At 300/3,000 relays, an unchanged/unowned cleanup makes zero ownership-map copies and only one/two comparisons. Real owned changes still produce an immutable replacement.
Fixed.onWorkspaceRemoval: ownerTabKey puts ownership into deleteOwnerKeyedSessionFields, which collects legacy and unified terminal IDs. Single/batch/every-partition removal and repo removal use that census. Deleting 300/3,000 tab IDs deletes their corresponding owner entries without a later renderer baseline; adoption version survives.
7034431725 #1 and 7034648570 #1: split debounced save repeats unrelated consumers
Fixed for the reported production route.planDesktopRelayWrite carries each present host's relay delta with its entries. Main publishes entries plus relays once, or makes one relay-only publication if entries are unchanged (session.ts:126–135). For 100/1,000 cached conversation workspaces, the combined save adds zero second reconciliation passes, instead of another 100/1,000 workspace checks. A host absent from entry slices can receive a separate relay write, with no ordinary write for that host to duplicate.
Fixed.probeDesktopRelays disables this protocol when main owns layout (desktop-relay-writes.ts:52). At 4/40 SSH hosts and 300/3,000 terminals, an unchanged-relay title save adds zero separate relay IPCs and zero separate reconnect derivations. Existing ordinary-save work remains.
Fixed. Delta admission uses desired/removed keys, and change detection compares only candidate changed/adopted keys (desktop-relay-ownership.ts:63–98). A one-ID removal has one candidate per changed field and zero whole-map equality passes at 300/3,000 entries. Refused/no-op input does not copy output maps. Baselines retain full omission processing as required.
7034953583 #1: conflicting existing relay builds all terminal-row IDs before refusal
Fixed.current === undefined now short-circuits before tabIdsWithRows (desktop-relay-ownership.ts:78). One conflicting existing-key delta, including a retry, refuses with zero row enumeration and zero output-map copies at 300/3,000 rows and 750/7,500 workspace buckets. Empty-key claims still validate row membership; matching/owned IDs retain their direct path. Legacy adoption is a separate version-gated operation.
Detector surfaces and production traces
perf-surface-detect returned hot-path,publish,startup-migration across six unique paths. All were covered:
Surface
Trigger → owner/thread → work, bounds and disposition
Relevant session changes → one document subscriber, 150 ms debounce, one save in flight → renderer projection/routing and acknowledgement → host entries IPC → main apply/publication → existing persistence worker. Warm unchanged relays produce zero relay hosts; one changed binding sends one host/ID. Main applies a delta over its named keys; combined entry/relay writes publish once. Null relay patches publish nothing. Capability probe is once per API identity/document, with older-main and paired-client fallback. No per-terminal network call is added.
hot-path — session-graph-promotion.ts
Window attachment after a windowless gap → runtime/main → added comparisons over qualifying PTYs once per handoff, grouped by host. At 300/3,000 qualifying PTYs this adds at most 300/3,000 key comparisons, plus immutable owner replacement only where a binding really changes. It is not called per PTY chunk or status tick. Existing PTY discovery and topology publication remain.
Close/retire/sanitize → main → one known parent-tab comparison; pane moves use one/two known keys. No-op ownership cleanup copies nothing. A real owned deletion copies the current owner record, bounded by that host's current owner population. Tab/workspace/repo teardown removes the corresponding records.
Migration fragment extraction → main → two added property deletions per fragment. No additional fragment traversal, native probe, subprocess or remote request.
startup-migration — ssh-target-id-migration.ts
SSH target reassignment → main → ownership rewrite only when that partition's relay IDs changed; one pass over rewritten bindings and an immutable owner replacement preserve current IDs/ownership. For 300/3,000 bindings this visits 300/3,000 rewritten entries, with zero extra SSH round trips or child processes.
Legacy adoption is also on the startup/save graph: capture visits H partitions and copies only their unadopted startup relay IDs once. The batch reads other partitions only when a target host still has a legacy baseline. Row attribution indexes the fleet at most once per applicable applier; successful stored adoption versions prevent repeat indexing, while failed storage preserves retryability. Carried entry calls have separate appliers: D adopting hosts can require D × (W + T) row/bucket visits during upgrade. For D=5, W=750, T=300 that is 5,250 visits; scaling just D gives 52,500, just W gives 39,000, just T gives 18,750; scaling all three gives 525,000. These are source counts for version-gated attribution, not measured startup latency. Retained legacy copies never grow beyond startup input and are dropped on the next targeted call after stored adoption is observed.
Full unload/checkpoint captures remain lifecycle work: the renderer resets acknowledgement and sends complete host baselines; main stages relay/ownership with the snapshots before its existing durable flush. Per checkpoint, admission visits current relay/owner keys, with at most one membership index per host needing an empty-key claim; legacy adoption is explicitly skipped there. Async full snapshots are used by mobile-close/project-pause receipts, then flush through the existing durability route. These paths were inspected separately from the debounced combined-save fix; full replacement intentionally invalidates the acknowledged copy.
Six scan questions
Question
Disposition
1. Work before skip gates?
Reviewed field-identity/projection gates, capability probe, acknowledgement, main refusal/null-patch and downstream consumers. Unchanged relay input sends nothing; conflict refusal avoids row indexing. Renderer full terminal projection/routing remains before narrowing, as on the base.
2. Ownership multiplies/recreates work?
One relay cache per document/API, keyed by host; no per-pane client, timer or subscription. Hosts absent from the current full write are pruned. Generation checks reject acknowledgements from before replacement/failure invalidation. Main's persisted owner keys follow terminal/workspace cleanup.
3. Thread and storage?
Validation, apply, immutable copying and save-baseline preparation run on Electron main. A real owner mutation copies 300/3,000 current scalar entries at those populations; storage serializes the changed scalar leaves. Baseline container enumeration remains O(R). Durable database work keeps the existing worker route; no added synchronous fs/SQLite operation or subprocess.
4. Growth and retry progress?
Subscriber retains one in-flight save and fixed sets of session field names, not a queue of snapshots. All partition results settle before retry. Refused/fenced hosts lose their acknowledgement and carry debt on later real changes, with no autonomous retry timer. Adoption advances by stored version; startup copies remain bounded. Unread-host exclusions arise from startup hydration and retain host IDs only, not session payloads.
5. Execution host?
Inspected local/SSH/runtime partitions, runtime hydration, contested hosts, folders, SSH reassignment, frozen migration, WSL binding removal/fences, older-main fallback and paired web. New operations are JavaScript/IPC/storage with no per-ID SSH round trip or platform process. No macOS/Linux/Windows runtime was exercised.
6. Obsolete work stops/releases budget?
Subscriber disposal removes listener/timer and stops admission; already admitted persistence settles for durability. Full replacement invalidates acknowledgement. Close/move/workspace/repo removal clears ownership. No new periodic producer is introduced: added steady-idle timer/IPC wakeups are 0/s in renderer, main and daemon by source inspection. Existing periodic resume capture is unchanged.
Touched recurring classes: whole-map serialization/row replacement — matched, fixed by scalar storage leaves; duplicate/broad publication — matched, combined-save duplication removed; hot-path rescans/work before gates — matched, known-key comparison and conflict short-circuit remove the reported scans; no-op allocation/unchanged publication — matched, lazy output copies and acknowledgement/null-patch gates suppress it; per-entity retention — matched, removal census clears keys; queue/retry amplification and idle wakeups — one in-flight subscriber save, fixed field debt, no new periodic source; startup rereads/eager imports — in-memory getters and lightweight ownership/schema modules, no added disk probe or heavy adapter initialization. No new React selector, mounted-instance effect, streaming-text processor or per-item subprocess path was introduced.
Pre-existing scaling work remains: relevant terminal saves project/route current terminal state; entry acknowledgement already traversed relay records before this protocol split them out; ordinary session publications reconcile cached conversation workspaces and subscribed window-owned layout readers can reload whole partitions. Those consumers still ignore/narrow scope imperfectly, but the reported added execution for combined debounced writes is gone. At two eligible saves/s, the existing 100/1,000-workspace title reconciliation still performs 200/2,000 workspace checks/s per written host; this span no longer doubles it on that route. Necessary new ownership state and immutable output follow current relays, not history or elapsed uptime.
Validation limits: read-only code inspection and inspection of added assertions only. No tests, typechecks, builds, application launches or timing/CPU/heap measurements ran. The added performance fixture establishes intended narrow wire payload/carriage behavior at one tab; it bypasses real Store listeners/storage and does not establish fleet timing or refusal-scan operation counts. Runtime startup/checkpoint latency, adverse transport and platform behavior remain unmeasured. Checkout unchanged.
Performance review: CLEAN by source inspection at 98ac84d578711d7da71807b20c2419449df3d8c2. No remaining P0/P1 performance regression identified. All P1s in the four requested earlier comments are fixed in source.
Reviewed origin/main...98ac84d578711d7da71807b20c2419449df3d8c2, merge base 77f4a1f023210156e27216da1e593b5ff3889542: all 41 changed files, production callers, acknowledgement/invalidation, ownership removal, session publication consumers and durable persistence. Local HEAD and PR head match. Counts below are derived from code; no runtime performance measurements are claimed.
Fixed. Ownership is the flat desktopRelayOwnerByTabId map. Local/host split depths 2/3 persist a changed ownership value as one scalar leaf, at both 300 and 3,000 relays. Relay-only publication skips row ordering (session-snapshot-operations.ts:127). Combined debounced publication is covered below.
7034145708 #2: close/move scans all relays to rediscover known changed keys
Fixed. Retirement and pane-close supply one tab ID; detach/leaf-move supply two. changedRelayKeys compares only those supplied IDs. forgetDesktopRelayKeys checks ownership before copying: unchanged/unowned keys cause zero owner-map copies at 300/3,000 relays (desktop-relay-ownership.ts:133). Actual owned removals still copy the immutable output record.
Fixed.onWorkspaceRemoval: ownerTabKey joins the existing deletion census. deleteOwnerKeyedSessionFields gathers legacy and unified terminal IDs and deletes their ownership entries through single/batch/every-partition removal and repo removal. Removing 300/3,000 tab IDs removes those owner entries without a subsequent renderer save; the adoption version remains.
7034431725 #1 and 7034648570 #1: split debounced save repeats conversation/layout consumers
Fixed for the reported production route. The subscriber supplies entry acknowledgements; each present host's relay delta rides with its entries (workspace-session-host-persistence.ts:284). Main merges both before one publication, or publishes only the relay patch when entries are unchanged (session.ts:131). Thus the reported second reconciliation of 100/1,000 cached conversation workspaces and potential second reload of 750/7,500 workspace keys are removed. A host without an entry slice can receive a separate relay write, with no ordinary write for that host to duplicate.
Fixed. The capability probe disables this protocol under main-owned layout (desktop-relay-writes.ts:52). Title saves add zero separate relay calls/reconnect derivations at 4/40 SSH hosts and 300/3,000 terminals. Ordinary main-owned save processing remains.
Fixed. Candidate relay/owner changes are compared only at touched/adopted keys; sameRecord is gone (desktop-relay-ownership.ts:97). One-ID removal has one candidate per field and zero whole-map equality passes at 300/3,000 entries. No-op/refused deltas copy neither output map.
7034953583 #1: existing-ID refusal indexes every terminal row before rejecting
Fixed.current === undefined now short-circuits before tabIdsWithRows (desktop-relay-ownership.ts:78). With adoption already recorded, a conflicting existing-key delta and its retries enumerate zero workspace buckets/terminal rows and copy zero output maps, at 300/3,000 terminals and 750/7,500 buckets. This removes the previously reported 600/6,000 row visits/s at two eligible retries/s. Empty-key claims still require row-membership validation, once per affected partition/apply; missing-row refusal, owned replacement/removal and legacy adoption retain their distinct branches.
Every detected surface
The detector returned hot-path, publish, and startup-migration, across six unique paths.
Surface
Trigger → owner/work → bound and disposition
publish
session-bridge.ts and session-snapshot-operations.ts: one document-level subscriber, 150 ms debounce, one save in flight. Relevant terminal changes project/route state, then the host acknowledgement narrows the wire payload. After acknowledgement, a title-only save sends zero relay hosts; one changed binding sends one host/ID with its entries. Main validates/applies synchronously; a null patch publishes nothing. A real delta copies changed immutable records and persists changed scalar leaves through the existing worker route. Capability probing is once per API identity. No extra publication in the earlier combined-save case.
hot-path
session-graph-promotion.ts: window attachment/handoff processes qualifying connected PTYs once per affected host; the addition compares their supplied tab IDs. At 300/3,000 qualifying PTYs that is at most 300/3,000 supplied-ID comparisons across partitions, with no added output/status-event invocation. mobile-session-terminal-persistence-retirement.ts: one known parent-tab comparison per retirement; close/detach/leaf-move/tab-close paths likewise limit change discovery to their known keys. Real owner removal requires an immutable owner-record copy; unowned/unchanged input avoids it. No per-pane client, timer or listener was introduced.
startup-migration
orcad-source-workspace-session-layout.ts: two property deletions per migrated fragment, without a new traversal. ssh-target-id-migration.ts: ownership follows rewritten bindings in one additional pass only when that partition's relay IDs change; no added SSH call/subprocess. Legacy capture/adoption was also traced: handler registration indexes launch-time row attribution once when unadopted saved IDs exist. Later host applies reuse that index instead of rebuilding global attribution per host.
Legacy startup work is O(H + repos + W + T + R), with a constant number of passes, where W/T/R are aggregate workspace buckets, terminal rows and saved relay entries across partitions. At W=750, T=300, R=300, attribution visits 750 buckets and 300 rows once, plus 300 relay candidates; at 10× these populations, 7,500 buckets, 3,000 rows and 3,000 candidates. Increasing host count alone from 5 to 41 adds host enumeration, not another whole-fleet attribution scan per host. With no unadopted IDs, row attribution is skipped. Persisted adoption versions advance recovery; baseline entries are discarded on a later batch after adoption is recorded. Launch attribution and original relay-map references remain bounded by launch-time population for the handler lifetime and are never replenished by ongoing terminal churn. Startup latency/retained bytes were not measured.
Six scan questions
Question
Disposition
1. Work before skip gates
Reviewed identity/projection gates → host routing → acknowledgement → IPC apply → publication/persistence. Unchanged relays do not travel; existing-key conflicts skip row discovery; no-op output records are not copied. Complete baselines intentionally inspect stored/owned keys to detect omissions.
2. Ownership multiplication/lifetime
One relay acknowledgement cache per document/API, keyed by host; missing hosts are pruned and generations reject obsolete completion. Main ownership follows tab/workspace/repo teardown. Unread-host exclusions come from startup hydration and retain at most its failed-host population. No new mounted-row resource owner.
3. Thread/storage cost
Validation, apply, immutable copies, listener callbacks and save-baseline preparation run on Electron main. Durable database writes retain the existing worker path. Ownership is individually split for persistence, rather than serialized as one large leaf. Full lifecycle saves send snapshots plus a relay baseline; unchanged bindings yield no relay patch. Unload stages ownership with its snapshots, without legacy attribution.
4. Growth/progress
Current host/tab populations bound normal caches and records. One subscriber write is in flight; pending/deferred debt is a fixed set of session field names. All partition writes settle before retry. Failed/refused/skipped writes invalidate acknowledgement and retry on later changes; no autonomous retry producer or growing snapshot queue.
5. Execution host
Inspected local/SSH/runtime partitions, cold worktree listings, runtime hydration, contested/unread hosts, folder-workspace exclusions and deletion, SSH reassignment, WSL removal/fences, older-main and paired-client fallback, and the main-owned switch. Added work is in-memory/IPC/storage, with zero per-ID remote round trips or new platform subprocesses. macOS/Linux/Windows execution was not exercised.
6. Obsolete work/release
Subscriber disposal removes its listener/timer and stops admission; admitted writes finish for durability. Full replacement/unload invalidates acknowledgement, preserving baseline recovery. Close/move/deletion release current ownership. Source adds zero steady-idle scheduled wakeups/s on renderer, main or daemon; existing schedules remain.
Touched regression classes and dispositions: whole-map storage replacement — matched, fixed by scalar splitting; duplicate/broad publication — matched, reported duplicate removed; hot-path rescans/work before skip gates — matched, known-key and existing-ID gates fix them; no-op allocation/unchanged publication — matched, suppressed by acknowledgement and null-patch gates; per-entity retention — matched, current ownership joins removal census, launch snapshots remain bounded; retry/queue multiplication and idle wakeups — matched, one in-flight save/fixed debt/no new periodic producer; startup rereads/eager imports — in-memory store getters and lightweight modules, no added filesystem/native probe or heavy adapter. No new React component subscription, transcript/history traversal or streaming-output processing was introduced.
Pre-existing scaling work remains: relevant terminal saves project/route the fleet; renderer entry acknowledgement already compared relay entries before this protocol; save baselines traverse session maps; ordinary session publications reconcile cached conversation workspaces and window-owned layout readers can reload whole partitions. These broad consumers remain, but the reported extra debounced execution has been removed. Added ownership storage and changed-record copies represent the current ownership output, without history growth.
Validation: source inspection only, including all added assertions. No tests, typechecks, builds or application launches were run, as requested. The performance fixture checks wire host/ID counts and carriage with entries, using an in-memory main; it does not validate real Store listener counts, storage behavior, fleet-scale timings or conflicting-write row-enumeration counts. Runtime startup/unload latency, CPU, heap and cross-platform transport behavior remain unmeasured. Checkout unchanged.
Performance review: BLOCKED — one P1 retention finding at 13e8873dabc2af37022cd177213cfb7dee459df4.
P1 — Release the startup attribution snapshot after legacy adoption finishes. Introducing allocation: desktop-relay-legacy-adoption.ts:42–49. The new baseline stores both the complete startup SSH-tab attribution index and references to every partition's original relay map whenever any partition needs adoption. session-desktop-relays.ts:84–87 captures that object in the applier retained by the registered IPC handlers.
The adoption cleanup at desktop-relay-legacy-adoption.ts:96–105 deletes only relaysByHost entries. Even after every partition has adopted and a subsequent apply has removed every pending baseline entry, neither tabHosts nor relaysAtStart is released. All later calls return early for the absent legacy entry, leaving those two snapshots unused but reachable for the main-process lifetime. Closing terminals, removing workspaces/repos and replacing live session maps cannot release the original relay records held there. The relay snapshot also includes already-adopted partitions when another partition still needed adoption at startup.
Source-derived price: start an upgrade session with 300 SSH terminal rows and 300 saved relay IDs, adopt all hosts, allow the next apply to consume the pending baselines, then remove all those terminals/workspaces. These caches still retain 300 tab-attribution entries plus an original map containing 300 relay entries: 600 obsolete keyed entries per main process, versus zero startup-attribution entries in the comparison base. At 3,000 rows/relays, 6,000 entries remain. This is bounded by startup population, does not accumulate another snapshot per save, and does not include terminal buffers or whole session objects. It nevertheless prevents reclamation of retired entity records after their migration owner has finished; retained heap bytes and user-visible memory impact were not measured. This matches the per-entity retention class and is P1 under this scan's grading rules.
Release the attribution/index references once no legacy hosts remain; preserve the immutable startup evidence while any fenced, failed or not-yet-adopted host can still need it. A proposed, unexecuted retention-count performance contract should cover the real handler lifetime at 300/3,000 entries: complete adoption and removal must leave zero obsolete migration records retained, while a still-pending host can retry correctly and first-save row movement remains attributable. The current tests do not check this lifetime.
Recheck of every earlier P1
Earlier report / finding
Disposition at this head
7034145708#1: whole ownership-map storage and duplicate topology/publication
Fixed for the reported debounced-save route. Ownership is the flat desktopRelayOwnerByTabId; local/host split depths 2/3 persist individual scalar leaves. A changed binding adds one changed owner leaf, rather than serializing 300/3,000 owner values. Relay-only commits skip row ordering. Combined entry/relay saves now publish once, as detailed below.
7034145708 #2: global change discovery and no-op ownership copies on close/move
Fixed. Retirement/pane-close compare one supplied tab ID; detach/leaf-move compare two. forgetDesktopRelayKeys checks membership before copying, so unchanged/unowned cleanup copies zero owner maps at both 300 and 3,000 relays. Actual owner removal still creates the required immutable output.
Fixed in live/persisted ownership.onWorkspaceRemoval: ownerTabKey feeds the existing legacy/unified-tab deletion census, including retained partitions after last-repo removal. Removing 300/3,000 tab IDs removes their 300/3,000 ownership entries and keeps the adoption version. The separate startup-cache retention above is a different record/lifetime.
Fixed for the reported combined entry/relay save.planDesktopRelayWrite carries a changed host with its patchEntries; session.ts:119–140 applies against the combined state and commits once. That host is excluded from sendRest. At 100/1,000 cached conversation workspaces, one such save now causes one 100/1,000-workspace reconciliation, rather than two. The extra layout invalidation from the second publication is removed too. A no-op ordinary patch with a real relay change commits only the relay patch; a wholly unchanged apply commits nothing.
7034431725 #2: main-owned layout multiplied reconnect scans by complete hosts
Fixed.probeDesktopRelays disables the separate protocol under ORCA_LAYOUT_OWNER_IS_MAIN; relays remain in the ordinary save. Added separate relay IPC/reconnect derivations per unchanged title save are zero at 4/40 SSH hosts and 300/3,000 terminals.
7034648570#1: separate relay publication repeated conversation reconciliation
Fixed for its reported route, by the same carried-entry single commit. The existing title listener still discards scope and window-owned layout still reloads whole partitions, but this route no longer invokes them a second time for the same combined save.
7034648570 #2: one-ID apply rediscovered changes through whole-map equality
Fixed.desktop-relay-ownership.ts:63–65,97–107 derives differences from touched/adopted keys and lazily builds changed output maps. After adoption, a one-ID removal makes one relay and one owner change comparison, independent of 300/3,000 stored IDs; the old extra 599/5,999-key ownership equality enumeration is gone. Refused/unchanged deltas copy zero output maps. Complete baselines still enumerate the population to implement omission semantics.
Coverage and source bounds
Reviewed all 41 changed files in origin/main...13e8873dabc2af37022cd177213cfb7dee459df4, merge base 77f4a1f023210156e27216da1e593b5ff3889542, with production callers, invalidation consumers, removal paths and storage routing. The remote PR head matches the requested revision. Every detector hit was covered (three surface IDs, six unique files):
Surface
Paths / disposition
publish
session-snapshot-operations.ts, session-bridge.ts; traced renderer subscriber → host split/acknowledgement → carried/separate IPC → main apply → Store scheduling → title/layout consumers → save-baseline splitting and persistence worker. Warm unchanged input sends zero relay hosts; one changed binding sends one host/ID. Probe is once per API identity. Combined entry/relay saves publish once; relay-only commits bypass topology ordering.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts; also pane close/detach/leaf move and tab-close. Promotion is attachment/handoff after a windowless gap, not PTY-output/status cadence: one added comparison per qualifying PTY, batched by affected host. Retirement compares one known ID, moves at most two. Owner-record copies are admitted only for real owned changes.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts; also legacy capture/adoption. Donor migration adds two property deletions per fragment. SSH reassignment adds one pass over the rewritten relay population only when bindings changed, preserving ownership for rewritten IDs. Legacy capture lists partitions once on the normal adopted launch and indexes no rows; an upgrade needing adoption additionally scans startup rows once and captures relay evidence. The finding concerns release of that evidence. No new disk probe or subprocess is introduced.
Six scan questions
Disposition
1. Work before skip gates?
Reviewed field/probe admission, renderer acknowledgement narrowing, main touched-key differences and null patches, plus downstream listeners. Warm unchanged saves avoid relay publication; the previously added duplicate consumer execution is gone on the reported entry-save path. Terminal projection/routing still precedes delta comparison as in the base.
2. Ownership multiplying/recreating work?
One acknowledgement cache per renderer document/API; one main applier owner. No new per-pane client, poll or subscription. Missing hosts are pruned from acknowledgements; replacement/API changes invalidate generations. Startup migration references outlive their useful ownership: finding above.
3. Thread/storage cost?
Validation, map construction, migration capture, listeners and save-baseline preparation run on Electron main; renderer projection/diff runs on the renderer. Durable writes retain the existing worker route. Changed ownership persists per scalar leaf. Full immutable owner output costs R scalar slots for an actual changed host; unchanged/refused deltas allocate no full output record.
4. Growth/progress?
Deltas examine K touched keys; first acquisition of an empty key lazily indexes that partition's tab rows once per apply for membership validation. Complete baselines necessarily inspect saved/desired/owned keys. Persisted adoption versions prevent repeated adoption; pending legacy hosts are consumed on a later apply once their stored version confirms adoption. Startup snapshots remain retained after completion: finding above. Retry debt is a fixed set of field names, not a snapshot queue.
5. Execution host?
Inspected local, SSH and runtime-host partitions; cold listing fallback; contested/unread hosts; folder-workspace attribution/removal; paired/older-main fallback; main-owned layout; SSH ID reassignment; WSL fences and binding removal. Changes perform JavaScript/IPC/storage work, with zero new per-tab SSH round trips, native calls or platform subprocesses. Shared paths apply across macOS, Linux and Windows; platforms/transports were not executed.
6. Obsolete work stops/releases?
Subscriber teardown removes its listener/timer and stops admission; accepted writes settle for durability. One subscriber save is in flight, with failures/fences retried on later store activity/real session changes rather than a new retry timer. Unload stages snapshots with relay ownership together and does no legacy adoption; full durable snapshot callers retain their explicit set/apply/flush lifecycle route. Tab/workspace removals clean live ownership. Migration-cache references do not release: finding above. Added recurring steady-idle wakeups are 0/s in renderer, main and daemon.
Touched recurring classes and dispositions: per-entity state outliving its entity — finding in startup attribution; whole-map serialization/row replacement — matched, flat entry persistence fixes the earlier defect; hot-path rescans/no-op copies — matched, known-key and lazy-copy gates fix the earlier defects; duplicate/whole-snapshot publication and work before equality — matched, carried entry commits remove the reported extra publication and main-owned mode disables the separate route; unchanged publication — matched, acknowledgement/null-patch gates suppress it; queue/fan-out/retry and idle polling — one subscriber write in flight, fixed field debt, no added periodic producer; startup imports/rereads — lightweight schema/ownership imports and in-memory Store getters, no new heavyweight initialization or filesystem read.
Pre-existing amplification remains: relevant terminal saves rebuild/project and route the terminal population; ordinary session publications reconcile cached conversation workspaces, and subscribed window-owned layouts clone/load whole host partitions before equality can suppress frames. Save-baseline container traversal remains linear in stored entries. These existing costs are separate from the new retained startup snapshots and are not independently graded as regressions of this span.
Validation limits: read-only source review and source-derived counts. No tests, typechecks, builds, app launches, timing, CPU or heap measurements were run. The added assertions were inspected: the performance test covers title-change/one-ID wire routing through an in-memory main fixture with one tab, bypassing actual Store consumers, durable storage and migration-snapshot lifetime. Runtime startup/unload latency, cross-platform transport behavior and the proposed retention remedy/guard remain unverified. Checkout unchanged.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The change adds per-tab desktop relay ownership to workspace-session state and applies relay writes through main-process IPC. Renderer persistence probes support, routes writes with session patches or separately, and tracks acknowledgements and retries. Legacy relay IDs can be adopted under defined partition and tab-attribution conditions. Session transformations also clear or migrate ownership when terminal bindings change.
Merge Risk: Low · up to e1b8e
This change stops ended SSH relay IDs from being saved for reattachment after a crash. One narrow edge case remains: a stale window write could re-save a relay that main had just removed, and the next full save heals it. The risk is low, and the author has documented it as a known limit.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the desktop window's writes are recorded so that ended SSH relay IDs can be cleared. The raw summary and objectives describe ownership tracking for relay IDs, which ma…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is thorough and follows the template's core intent. It gives a Problem statement, a Change section with the mechanism, an Evidence section that lists specific tests and what each one c…
Full details: Title check
Explanation
The title names the main change: the desktop window's writes are recorded so that ended SSH relay IDs can be cleared. The raw summary and objectives describe ownership tracking for relay IDs, which matches the title. The title is specific and single-sentence, though it is somewhat long at 13 words.
Full details: Description check
Explanation
The description is thorough and follows the template's core intent. It gives a Problem statement, a Change section with the mechanism, an Evidence section that lists specific tests and what each one checks, and Known limits. The template's ELI5 section is missing, and so are the Visual Proof section (UI behavior is not visibly changed, so N/A with a reason would suffice), the Linked Issue section (it says 'Replaces #45051' but no 'Fixes #' issue link), the Testing checklist boxes, the Risk section with a level and backout plan (the Known limits partly cover risk but a Level and revert guidance are absent), the AI Disclosure section (which is only needed for non-team contributors), and the Agent skill upstream boundary checkbox. Most of the critical technical content is present, so the check passes on completeness of substance, but the template-required items should be added.
Resolution
Not required for a PASS, but the author should consider adding: an ELI5 summary; a linked issue (the template says one should always exist for outside contributors); a Visual Proof entry or N/A with reason; a Risk level (Low, Medium, or High) with backout guidance (a plain revert versus what a revert would not undo, such as the persisted ownership fields); and the Testing checklist items.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
SSH_HOST comes from production getRepoExecutionHostId. If that helper routes the fixture to the wrong host, the recorded host and expected host can change together. Use the literal host ID required by this fixture.
As per coding guidelines, a performance contract must check “hardcoded values,” with expected values “never computed by production code.”
Source: Coding guidelines
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 5ae1ce86-41ed-4f3b-b814-952de0921dc6
Commits
Reviewing files that changed from the base of the PR and between 08515a0 and 13e8873.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Performance review: BLOCKED — one remaining P1 at 63ec2886b8695ac77bfb94e08c84d95a95c3d2a4.
P1 — Retire the legacy baseline when adoption succeeds, without requiring another relay change.desktop-relay-legacy-adoption.ts:100–111 now releases the attribution snapshots when relaysByHost becomes empty, but that condition is not reached by the successful adoption itself.
legacyRelayAdoptionBatch checks the stored version before applying the first write. That host still has version 0, so it remains pending. The subsequent Store commit installs version 1, but neither the carried handler (session.ts:119–140) nor the separate handler (session-desktop-relays.ts:136–143) retires its baseline afterward.
Cleanup requires another apply for that host. Acknowledged unchanged relays produce no host write (desktop-relay-acknowledged-hosts.ts:60–82, desktop-relay-writes.ts:210–212); ordinary title/session saves therefore do not run this cleanup. Changes on other hosts check only their own IDs. There is no removal/completion observer for this baseline.
Removing the host's last repo can make the retained records obsolete permanently: live session removal deletes its rows/bindings, but does not touch this cache (repo-lifecycle-operations.ts:124–145). The renderer no longer catalogs that host as complete; its empty slice is excluded by takeDesktopRelayWrite, so removal does not guarantee the second host apply either.
Price and impact: with one startup SSH population of 300 rows/relay IDs, successful adoption followed by last-repo removal without another relay write retains 300 attribution entries, 300 original-map entries and 300 copied pending bindings: 900 migration-only keyed entries per Electron main process. At 3,000 rows/IDs, 9,000 remain. These survive despite the live rows and bindings being gone. The base retains zero entries in these new migration caches. This is bounded by startup population and does not accumulate another snapshot per save; it is still abandoned ownership state after its migration has completed. Heap bytes and latency were not measured. This is the remaining lifetime gap in comment 7036747549, rather than an unbounded-growth claim.
Retire successfully committed hosts at a guaranteed completion boundary and release the shared startup evidence when the last pending host retires; preserve evidence for genuinely failed/fenced hosts. Do not depend on a future mutation or add an idle cleanup poll. Proposed check, not run: through the real registered-handler/Store lifetime at 300/3,000 entries, complete the first adoption, flush it, then make unchanged title saves and remove the last repo without a second relay write. Require zero completed-host baseline records and zero attribution/original-map entries once all hosts finish. Include a still-pending host that retries successfully and the first-save cross-partition row-movement control. The proposed remedy is unverified.
Fixed for the reported debounced-save route. Ownership is flat desktopRelayOwnerByTabId. Split depths 2 local / 3 host persist one changed owner scalar at 300/3,000 entries. Relay-only commits pass topologyChanged=false; combined entries/relay saves publish once.
7034145708 #2: full-map change discovery/no-op owner copies on close/move
Fixed. Retirement/pane-close compare one supplied tab ID; detach/leaf-move compare two. forgetDesktopRelayKeys checks membership before copying: zero owner-map copies for unchanged/unowned cleanup at 300/3,000 IDs. Real removals retain immutable output.
Fixed in live/persisted ownership.onWorkspaceRemoval: ownerTabKey feeds the existing legacy/unified-tab deletion census, including last-repo removal in retained host partitions. Removing 300/3,000 owned tabs deletes their corresponding owner entries and keeps the adoption version. The startup cache above has a separate lifetime.
Fixed for the reported combined entries/relay save.planDesktopRelayWrite carries a host's relay delta with patchEntries, excludes it from sendRest, and session.ts:140 commits once. At 100/1,000 cached conversation workspaces, this means one 100/1,000-workspace reconciliation instead of two; the second layout invalidation is also removed.
7034431725 #2: main-owned layout multiplied reconnect scans by complete hosts
Fixed. The capability gate disables this separate protocol under ORCA_LAYOUT_OWNER_IS_MAIN; relays stay in ordinary saves. Added separate relay IPC/reconnect derivations per unchanged title save are zero at 4/40 SSH hosts and 300/3,000 terminals.
7034648570 #1: separate publication repeated conversation reconciliation
Fixed for its reported route by the same carried-entry single commit. Existing consumers still discard scope/reload whole window-owned partitions, but this combined save no longer invokes them twice.
Fixed. Apply derives changes from touched/adopted keys (desktop-relay-ownership.ts:63–65,97–107). After adoption, one-ID removal makes one relay and one owner difference comparison at 300/3,000 IDs; the extra 599/5,999-key ownership equality enumeration is gone. Refused/unchanged deltas copy no output maps.
Partially fixed; still P1 above. Once a later apply has consumed every pending host, lines 109–111 now release the two snapshots, fixing that exact empty-pending-set case. Successful first adoption does not itself consume those hosts, and a later same-host apply is not guaranteed.
Coverage and source bounds
Reviewed the 41-file diff origin/main...63ec2886b8695ac77bfb94e08c84d95a95c3d2a4 (merge base 77f4a1f023210156e27216da1e593b5ff3889542) plus production callers, acknowledgement/invalidation, removal, title/layout listeners and durable-storage routing. The PR head matches. Every detector hit was covered: three surface IDs across six unique paths.
Surface
Paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced subscriber → projection/host split → acknowledgement → carried/separate IPC → main apply → Store/listeners → save-baseline splitting → persistence writer. Warm unchanged relays send zero hosts; one changed binding sends one host/ID. Combined entry/relay saves commit once; relay-only commits skip topology ordering; null patches do not publish. Version probing is one IPC per API identity/document.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, plus pane/tab close and move paths. Promotion runs on window attachment/handoff, not output/status cadence: one added comparison per qualifying PTY, batched per host. Retirement compares one known ID, moves at most two. Actual owner changes create the required immutable owner map; unowned/unchanged cleanup copies none.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy capture/adoption. Donor extraction adds two property deletions per fragment. SSH reassignment adds one owner-output pass only when relay IDs change. Legacy capture is one in-memory host pass on adopted launches; an upgrade additionally scans startup workspaces/tabs and captures relay evidence once, O(H+W+T+R), with no new disk/SSH probe. Its incomplete release is the finding.
Six scan questions
Disposition
1. Work before skip gates?
Reviewed field/probe admission, acknowledged narrowing, touched-key differences, null patches and downstream consumers. Existing terminal projection/routing still precedes narrowing. Cold-listing/execution-host fallback now visits qualifying SSH tabs for required reconnect outputs using indexed repo lookup: 300/3,000 tabs for up to 300/3,000 outputs, without per-tab RPCs.
2. Ownership multiplies/recreates work?
One acknowledgement owner per document/API and one main baseline owner; no per-pane client, subscription or poll. Missing hosts prune acknowledgement state; replacement/API changes invalidate generations. Completed migration ownership is not reliably retired: finding.
3. Thread/storage cost?
Projection/diff pays on renderer; validation, adoption, immutable records, listeners and save preparation pay synchronously on Electron main. Durable database writes retain the existing worker route. Changed ownership persists as scalar leaves; full owner output copies R slots only on an actual owner change, with no whole-map equality rediscovery.
4. Growth/progress?
Deltas examine K touched keys. Acquiring empty keys lazily indexes that partition's tab rows once per apply; complete baselines inspect saved/desired/owned IDs for omission semantics. Adoption version prevents repeated adoption. One subscriber save is in flight; retry debt is a fixed set of field names. The pending migration ledger's completion gap is source-proven above.
5. Execution host?
Inspected local/SSH/runtime partitions, cold catalogs, unread/contested hosts, folder attribution/removal, paired/older-main fallback, main-owned mode, SSH target reassignment and WSL/migration fences. Added work is JavaScript/IPC/storage, with zero new per-ID SSH round trips, native calls or subprocesses. macOS/Linux/Windows and live transports were not executed.
6. Obsolete work stops/releases?
Subscriber disposal removes listener/timer and stops admission; admitted writes finish for durability. Failures defer to later store activity and fenced/refused fields ride later real changes. Unload stages relays/ownership with snapshots and skips legacy adoption; full durable snapshot callers retain set/apply/flush. Live close/workspace removal cleans ownership, but the startup cache can survive it. Added recurring steady-idle wakeups: 0/s in renderer, main and daemon by source inspection.
Touched recurring classes: per-entity retention — finding; whole-map storage/whole-file rewrite — matched, entry splitting and existing coalesced persistence avoid a new whole owner-map row; hot-path rescans/no-op copies — matched, known-key/lazy-copy gates remove the reported waste; duplicate/whole-snapshot publication and work before equality — matched, carried commits remove the reported extra consumer pass and main-owned mode disables separate relay work; unchanged publication — matched, acknowledgement/null-patch gates suppress it; queue/fan-out/retry and idle polling — one subscriber save in flight, fixed field debt, no new autonomous retry/periodic producer; startup imports/rereads — lightweight ownership/schema imports and in-memory getters, no new heavyweight adapter or filesystem read.
Pre-existing amplification: relevant saves project/route the terminal population O(W+T); ordinary session publication reconciles cached conversation workspaces O(C), and subscribed window-owned layouts clone/load entire host partitions before equality. Save-baseline container traversal remains linear in persisted entries. These costs were traced separately from the new retained migration records and are not independently graded as regressions of this span.
Validation limits: source inspection and source-derived counts only. No tests, typechecks, builds, application launches, timing, CPU or heap measurements were run. Inspected test assertions cover ownership behavior, legacy attribution and one-tab wire routing; the performance fixture bypasses real Store listeners/storage and no added assertion checks migration lifetime after the first successful commit. Runtime latency, transport/platform behavior and the proposed remedy remain unverified. Checkout unchanged.
Performance review: CLEAN by source inspection at 70718e8bad4945224bfadf6e38030040340e5182. No new P0/P1 performance regression found. Every P1 in the four requested earlier comments is fixed in this checkout. Runtime latency, CPU and memory usage were not measured.
Reviewed the full local origin/main...70718e8bad4945224bfadf6e38030040340e5182 diff: 41 files, merge base 77f4a1f023210156e27216da1e593b5ff3889542. Also compared against d8290d0f8034f2a94edba0505eb0582f57da6e78 and followed production callers, downstream listeners, persistence, invalidation and removal paths. All counts below are derived from source, not executed benchmarks.
Earlier P1 recheck
Earlier finding
Disposition at this head
7034145708#1: nested ownership storage and duplicate topology/publication
Fixed.desktopRelayOwnerByTabId is flat. Existing split depths 2 local / 3 host make a changed ownership value one scalar leaf at R=300 or 3,000 owned relays. The debounced entries path carries relay changes into one commit; the relay-only method skips topology ordering.
7034145708 #2: global changed-key discovery and no-op copies on close/move
Fixed. Retirement and pane close supply one known tab ID; detach/leaf move supply two. changedRelayKeys compares just those keys, and forgetDesktopRelayKeys checks ownership before copying. At R=300/3,000, an unchanged/unowned cleanup performs one/two comparisons and zero ownership-map copies. Actual owned deletions still produce an immutable output record.
Fixed.onWorkspaceRemoval: ownerTabKey includes ownership in the existing legacy/unified terminal-ID census. Single, batch, all-partition and repo removal delete the corresponding ownership keys. Removing 300/3,000 tab IDs leaves zero corresponding owner entries without a later renderer baseline; surviving owners and the adoption version remain.
Fixed for the reported production save.planDesktopRelayWrite attaches changed relays to the host entries patch; session.ts:119 applies them against the same save and commits once. At C=100/1,000 cached conversation workspaces, the combined save invokes one reconciliation rather than two. It also avoids the second layout invalidation. Scope alone is not being credited as the fix: the title listener still ignores partial scope.
7034431725 #2: main-owned layout adds global reconnect scans for unchanged relays
Fixed. The capability probe disables the separate protocol under ORCA_LAYOUT_OWNER_IS_MAIN. Relays stay in ordinary saves. Added separate relay IPC/reconnect derivations per title save are zero with 4/40 SSH hosts and 300/3,000 terminals.
7034648570#1: partial scope still duplicates conversation reconciliation
Fixed by the combined commit above. One combined save produces one title reconciliation per written host. Window-owned layout still reloads whole partitions, but this route no longer adds a second publication.
Fixed.desktop-relay-ownership.ts:63 limits a delta to supplied keys; lines 97–100 determine change from the resulting changes only. One existing-binding delta compares one relay and one ownership value at R=300/3,000, without whole-map equality. Refused/no-op deltas copy neither record.
7038397653: parked-tab indexing before the omission gate
Fixed.desktop-relay-acknowledged-hosts.ts:91 computes omitted accepted IDs first and returns before held(hostId) when none are missing. With 300/3,000 parked rows and unchanged relays, each eligible title save adds zero parked-row visits and zero index builds, including an empty acknowledged map. At two saves/s the earlier extra 600/6,000 visits/s becomes zero. Actual omissions still request one cached index per affected host/write to protect parked live tabs.
The additional stale-acknowledgement changes preserve removal evidence after a skipped, refused or failed write. Invalidation marks H host records stale without copying their relay maps; late generations cannot acknowledge. A later real save resends the necessary baseline, and acceptance clears staleness. This adds no autonomous retry producer.
Every detected surface covered
Surface
Paths and production trace
publish
session-snapshot-operations.ts:129, session-bridge.ts:7. App subscriber → terminal projection/host split → acknowledgement/plan → carried or separate IPC → ownership apply → Store listeners → save baseline → existing persistence worker. The subscriber has one save in flight and a 150 ms debounce. Warm unchanged relays send zero hosts; one changed binding sends one host/ID. Null main patches publish nothing. Combined entries/relay saves publish once; relay-only publication bypasses topology ordering.
hot-path
session-graph-promotion.ts:240, mobile-session-terminal-persistence-retirement.ts:206, plus tab close and pane moves. Promotion runs on attachment after a windowless gap, adds one known-key comparison per qualifying PTY and commits per affected host; it is not a PTY-output/status handler. Retirement compares one key; moves compare two. No extra subprocess, transport inventory or per-pane owner was introduced.
startup-migration
orcad-source-workspace-session-layout.ts:41, ssh-target-id-migration.ts:20, plus legacy adoption. Donor cleanup adds two property deletions per fragment. SSH reassignment adds one ownership pass only when relay rewriting changes that partition; no new remote call. Legacy capture indexes rows once only when unadopted saved IDs exist: O(H + repos + W + T + R), not hosts × terminals. At W=750/7,500 and T,R=300/3,000 this is one required attribution traversal; adopted launches skip row indexing. Consumed baseline hosts are deleted.
Six scan questions
Question
Disposition and bounds
1. Work before skip gates
Reviewed identity/field gates, capability probe, relay narrowing, parked-omission admission and main null-patch handling. Unrelated store writes do not enter relay projection. Current/previous relay comparison is O(R) per eligible save to discover the delta; unchanged parked population contributes zero row visits.
2. Ownership multiplication
One acknowledgement cache per document/API, keyed by host; absent hosts are pruned and generations reject late answers. WeakMap metadata lasts only as long as its write. No added mounted-pane client, listener, poll or timer.
3. Thread/storage payer
Narrowing runs on renderer; apply, notification and serialization preparation run on main. Database writes keep the worker route. A one-binding change persists one relay scalar and one owner scalar. Real immutable owner changes copy R slots; baseline capture visits R owner keys, while unchanged scalar leaves avoid serialization/writes. No new synchronous filesystem/SQLite call.
4. Growth/progress
Retained ownership follows current tabs through teardown. Startup legacy copies are bounded by initial adoptable IDs and are never replenished. Adoption versions advance; fences retain retry evidence. Retry debt is a fixed set of field names, not queued snapshots. Actual new bindings index tab rows at most once per host apply for required membership validation; replacements/refusals against occupied keys skip that index.
5. Execution host
Inspected local/SSH/runtime routing, contested/unread partitions, hydration, folder exclusions/removal, SSH reassignment, WSL/source fences, older-main and paired-client fallback, and main-owned layout. New work is in memory/IPC/storage with zero per-ID SSH round trips, native probes or subprocesses. Cold-start repo-ID fallback uses indexed repo lookup and only widens production of required SSH bindings. macOS/Linux/Windows behavior was source-reviewed, not executed.
6. Obsolete work/release
Subscriber disposal removes its listener/timer; invalidation fences late acknowledgement. Full replacement clears acknowledgement and sync unload stages relay/ownership together, without legacy attribution. Extra unload work is O(H + R + T) once per checkpoint, with at most one row index per host apply. Explicit durable full saves and their close/sleep callers were also inspected. No new periodic producer: source-derived added steady-idle timer/IPC wakeups are 0/s in renderer, main and daemon.
Touched recurring classes and dispositions: work before equality / hot-path rescans / unchanged-input reconstruction — matched, earlier global comparisons and eager parked indexing fixed; duplicate/broad publication — matched, combined debounced commits eliminate duplication; whole-map storage rewrite — matched, flat scalar leaves; no-op allocation/publication — matched, lazy output copies and null patches; per-entity retention — matched, removal census and host pruning; retry/queue fan-out — matched, one subscriber save in flight and fixed field debt; steady-idle wakeups — no added producer; eager startup imports/rereads — lightweight in-memory modules, no new disk/native/SDK startup probe; loosened admission — cold-start SSH output is required and remains host/row gated. No new React selector or per-mounted-pane resource-owning effect.
Pre-existing amplification remains: eligible terminal saves project/route the terminal population and restore parked fields; session publications reconcile C cached conversation workspaces, and window-owned layout can reload/clone whole partitions at W=750/7,500. The changed debounced route does not double those executions. New relay comparisons and scalar ownership retention support delta discovery and ownership semantics; actual changed immutable records still require output copies. These source counts do not establish elapsed stalls.
Validation limits: read-only source inspection, including added test assertions. No tests, typechecks, builds, application launches or timing/CPU/heap measurements ran. The performance assertion checks outgoing relay hosts/IDs through an in-memory main fixture; it does not measure parked-index work or real Store/storage listeners, and its assertions were not executed. Runtime startup/unload latency and cross-platform transport behavior remain unmeasured. No checkout edits or commits.
Performance review: BLOCKED — one new finding at local head 2f151c0db348c9a05e3bcc40eb8501c644c5a2de. The earlier reports' P1s remain fixed; the new union of removal evidence introduces growth with terminal history.
The round-12 markStale unions the previous evidence with the current full desired record, but never subtracts removals that main has processed. A refusal of any other tab prevents the accepted-host branch from replacing that union. This is reachable through the real subscriber → patchWorkspaceSessionByHost → carried entries/relay write → settleSessionWrites → acknowledgement route, with one write at a time; concurrency or unanswered requests are unnecessary.
Source-derived workload, extending the new partial-refusal case in desktop-relay-writes.test.ts:87:
Keep a host incomplete because it holds a parked workspace. Main holds a different relay for live tab B, so each write refuses B while applying other keys.
Send live tab A's relay. Main stores it; the refused host's evidence becomes {A, B}.
End A. endedOnIncompleteHost sends removedTabIds: [A]. Main removes A and its ownership even though B remains refused (desktop-relay-ownership.ts:63–98; session.ts:120–143). The answer again runs markStale, preserving A in {A, B}.
Later eligible saves send A's removal again. Open/end fresh tabs C, D, etc.; each joins the union permanently until the entire host is accepted, the host disappears from a write, or the API/document is replaced. No per-tab removal acknowledgement retires this evidence. Keeping B and the host live prevents those cleanup conditions indefinitely.
Price and impact: hold the live terminal population L fixed at 300, then 3,000, and vary retired unique tab IDs K independently. After K=300/3,000 such closures, the renderer retains 300/3,000 unnecessary historical entries in addition to L live entries. Each subsequent eligible save enumerates them in endedOnIncompleteHost, copies them in markStale, serializes K dead removal IDs, and makes main revisit K already-resolved keys. At two eligible saves/s, this adds 600/6,000 dead removal IDs/s across IPC and the main apply loop, plus renderer enumeration/copy work. Across K sequential closures, the removal lists alone contain at least K(K+1)/2 historical ID occurrences: 45,150 / 4,501,500, despite each ended binding requiring removal only once. The retained map grows with unique terminal history, with no bound derived from live entities or outstanding work. P0 follows the scan's unbounded-growth rule; these are source-proven counts, not measured latency or heap bytes.
The stale omitted IDs also repeatedly pass the parked-index admission gate: a fresh write rebuilds that host's parked-tab index even when all actual relay changes have settled except B's refusal. With P=300/3,000 parked rows and two eligible saves/s, that adds 600/6,000 parked-row visits/s. The earlier omission gate itself remains present, but the union supplies obsolete omissions forever. Complete hosts avoid the removal-list/index portion but still accumulate and copy the historical union under persistent refusal.
Remedy/check, proposed and unexecuted: retain evidence for genuinely unanswered, skipped or partly applied writes, while retiring explicitly processed removals from a non-skipped committed answer even if another desired key was refused. Keep unresolved evidence separate if necessary; do not fix this by discarding all partial-write evidence or imposing a truncating cap. Through the real save/acknowledgement seam, hold one sibling refused and cycle 300/3,000 distinct tabs at a fixed live population. Assert that a later title save carries zero already-processed removal IDs, and each new end sends only its newly ended ID. Include controls for parked live tabs, skipped/failed/unanswered writes, replacement, stale generations and eventual acceptance. The added test establishes the first partial-refusal removal but stops before the next save/churn cycle, so it does not cover this regression.
Fixed. Ownership is a flat desktopRelayOwnerByTabId map. Split depths 2 local / 3 host persist one changed ownership scalar, rather than an R-entry leaf, at R=300/3,000. Debounced entries and relays ride in one host IPC (workspace-session-host-persistence.ts:281–301) and one Store publication (session.ts:131–143). Relay-only publication passes topologyChanged=false (session-snapshot-operations.ts:144). Thus a combined save adds zero second topology/title/layout-consumer executions.
Fixed. Retirement/pane close compare one supplied tab ID; detach/leaf move compare two. changedRelayKeys only visits supplied IDs. Membership is checked before ownership copying; unchanged/unowned keys cause zero owner-map copies at R=300/3,000. Actual immutable owned changes still copy the required output map.
Fixed.onWorkspaceRemoval: ownerTabKey feeds deleteOwnerKeyedSessionFields, covering legacy and unified terminal IDs through workspace, batch and repo removal. Removing 300/3,000 owned tabs deletes all their persisted ownership entries even if the host partition remains. The new finding concerns the renderer's retry evidence, a different record.
7034431725 #2: main-owned layout's extra per-host reconnect scans
Fixed.probeDesktopRelays declines the separate protocol for main-owned layout; registration skips legacy capture there. Added separate relay IPC/reconnect derivations per title save remain zero at 4/40 SSH hosts and 300/3,000 terminals.
7034648570 #2: whole relay/ownership equality scans after a one-ID delta
Fixed.desktop-relay-ownership.ts:63–100 visits the supplied delta keys and detects changes from those changes, without whole-map equality. A one-existing-binding delta checks one relay/owner pair at R=300/3,000; no-op/refused output copies are zero.
The prior fixes remain. Comparing 70718e8..2f151c0 isolates the finding to the new evidence union. The new inFlight tracking was also traced: only nonempty writes register, answers remove their registration, invalidate/replacement clears the old set while fencing its generation, and API reset clears it. It retains references to already-created host records rather than copying their maps on admission. It introduces no new producer or additional save concurrency.
Coverage: every detected surface
Reviewed all 41 changed files and relevant production callers/consumers for origin/main...2f151c0db348c9a05e3bcc40eb8501c644c5a2de, merge base 77f4a1f023210156e27216da1e593b5ff3889542. Used local target-ref code; no assumption that GitHub already has this commit. Detector IDs: hot-path,publish,startup-migration, across six unique files.
Surface
Paths and bounds
publish
session-snapshot-operations.ts, session-bridge.ts; traced app subscriber → terminal projection/host routing → acknowledgement/plan → carried or separate IPC → ownership apply → Store listeners/title/layout → save baseline → existing persistence worker. Outside the finding's stale-history case, warm unchanged relays send zero hosts and one changed binding sends one host/ID. Null main patches publish nothing. Probe runs once per API identity/document. Subscriber debounce is 150 ms, with one save in flight and fixed field-name retry debt.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, plus pane/tab close and move consumers. Windowless handoff runs on attachment/promotion, once per affected host, adding one known-key comparison per qualifying PTY; it is not an output/status handler. Retirement compares one known key, moves two. No additional PTY inventory, subprocess or per-pane owner was introduced.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy adoption/hydration. Donor cleanup adds two property deletions per fragment. SSH reassignment adds one ownership pass only when that partition's relay values change, for required rewritten output; zero extra remote calls. Legacy capture is O(H + repos + W + T + R) once when unadopted saved IDs exist, sharing one row-attribution index across hosts; at W=750/7,500 and T,R=300/3,000 this is one traversal, not hosts × tabs. Adopted launches skip row indexing; each stored adoption removes its startup baseline. Failed-read host IDs are recorded on startup hydration, without a new retry loop.
Six scan questions
Question
Disposition
1. Unused work before skip gates?
Reviewed raw identity/session-field gates, capability probe, current/accepted delta discovery, omission-before-parked-index gate and main null-patch handling. New historical evidence defeats the omission gate as described in the finding. Cold-start repo-ID fallback uses indexed lookup and emits required SSH bindings.
2. Ownership multiplying/recreating work?
One acknowledgement cache per document/API, keyed by host; missing hosts are pruned, and generations reject obsolete answers. No new mounted-pane client, listener or poll. In-flight registration cleanup is sound for inspected success/failure/replacement paths. Host-wide refusal retains unrelated resolved tab evidence: finding.
3. Thread/storage payer?
Delta narrowing and evidence union pay on renderer; schema validation, ownership apply, listeners and JSON preparation pay on main. Actual immutable changes copy current records. Persisted ownership is split into scalar leaves and database writes retain the worker route. No new synchronous filesystem/SQLite call or subprocess. Historical removal payload/main-loop amplification: finding.
4. Growth and retry progress?
Legacy evidence is bounded by initial adoptable IDs, never replenished, with version/consumption progress. Field retry debt is fixed-size and waits for later real changes. The new stale union grows with retired IDs and does not advance after processed removals while another tab remains refused: finding.
5. Execution host?
Inspected desktop local/SSH/runtime partitions, hydrated/unread and contested partitions, folder-workspace exclusions/removal, SSH target reassignment, WSL/source fences, older-main/paired-client fallback and main-owned layout. Added work uses memory/IPC/persistence, with zero per-ID SSH round trips, native probes or subprocesses. The finding needs one host/document, not replica multiplication.
6. Obsolete work and budget release?
Subscriber disposal removes listener/timer; admitted writes finish for durability. Invalidation fences late answers. Quit/unload stages relay/ownership with snapshots without legacy attribution; at fixed current state it adds O(H + R + T) required checkpoint work, with at most one membership index per host apply. Historical stale evidence adds the finding's K-dependent work. Added autonomous steady-idle timer/IPC wakeups are 0/s in renderer, main and daemon.
Touched recurring regression classes: per-entity state outliving its entity, hot-path rescans, repeated no-op payloads and work before equality — finding in stale evidence; duplicate/broad publication — matched, combined debounced commits eliminate the earlier duplication; whole-map storage rewrite — matched, flat scalar leaves; no-op output copies/publication — matched, lazy changed-key output and null patches; queue/fan-out growth — in-flight registrations release on settlement/invalidation, fixed field debt and no new producer; eager startup imports/rereads — lightweight in-memory modules, no new SDK/native/disk probe; loosened admission — required cold-start SSH output stays row/host gated; idle wakeups — zero added producer. No new React selector or per-mounted-pane resource effect.
Pre-existing amplification remains separately identified: eligible terminal saves project/route the current terminal population O(W+T); ordinary session publication can reconcile C cached conversation workspaces and clone/load a whole W=750/7,500-workspace partition for layout subscribers. This diff no longer doubles the debounced combined-save publication. Required ownership updates copy current R scalar slots and save-baseline capture enumerates them; unchanged leaves avoid serialization/writes. These costs are distinct from new K-dependent historical evidence.
Validation limits: read-only source inspection, including added assertions. No tests, typechecks, builds, application launches or timing/CPU/heap measurements ran. The performance assertion inspects outgoing hosts/IDs through an in-memory main fixture; it was not executed and does not cover repeated partial-refusal churn or real Store/storage listeners. Proposed remedy/guard is unverified. Runtime startup/unload latency and macOS/Linux/Windows transport behavior remain unmeasured. Checkout unchanged; no commits.
Performance review: BLOCKED — one P1 finding at local head bc445ea6387db20e5c8e8b5d04e82ff018465c6e. The earlier P1s and the reported P0 are fixed in source; a separate incomplete-host recovery scan remains.
P1 — An incomplete baseline scans stored keys it cannot change on every refused retry. Introducing code: desktop-relay-ownership.ts:63–65; unnecessary iterations exit at lines 86–87.
An incomplete host is a production state: a partition holding parked workspaces is excluded from completeRelayHostIds. If main holds a different relay for one desired tab, its answer marks that host stale. Every subsequent eligible terminal save retries it. When no acknowledged ID ended, deltaFor:162–164 returns the incomplete baseline without removedTabIds. This reaches the real subscriber → host plan → carried entries IPC → session.ts:120–121 → main relay applier route. No concurrent writes, timer loop, or repeated migration is needed.
With removedTabIds absent, applyDesktopRelayWrite enumerates all stored relay keys and all ownership keys, builds their union with desired keys, and visits that union. For each omitted key, it then reaches !removed && !write.complete and immediately continues. These omitted keys cannot be removed or otherwise changed by this write. The adoption version can already be current, and the conflicting desired key already exists, so neither legacy adoption nor live-row indexing requires this scan. A final null patch prevents publication only after this work has been paid.
Source-derived price: keep one desired tab persistently refused on an incomplete partition with R total stored relay bindings; the other R−1 bindings belong to main/parked rows and must remain untouched. With an empty ownership map, each retry unnecessarily enumerates R stored keys and performs R−1 omitted-key iterations instead of examining only the one desired key. At R=300/3,000 and two eligible saves/s, that is 600/6,000 stored-key visits during enumeration plus 598/5,998 unnecessary loop iterations per second on Electron main, with temporary arrays and a fleet-sized Set. A populated ownership map adds its enumeration too. These counts isolate the new ownership apply pass; the base's ordinary session projection and no-op comparisons are separate costs. Scaling worktrees, hosts or mounted panes is unnecessary to trigger it: one host and one renderer suffice. This repeated fleet-sized no-op scan is P1; no measured CPU or latency threshold is claimed.
Remedy/check, proposed and unexecuted: an incomplete baseline without explicit removals should visit only desired keys. Preserve the full stored/owner census for complete-baseline omission semantics, and desired-plus-removal keys for explicit deltas; preserve separately collected adoption changes. At 300/3,000 stored bindings, drive a parked/incomplete host with one persistent refusal through the real save/acknowledgement seam, then another title save. Require constant main apply key examination for this one-ID input, no enumeration of omitted stored/owner keys, unchanged unrelated bindings, and no publication from a null relay patch. Include complete omission, explicit last-ID removal, adoption, takeover, skipped/unanswered writes and eventual recovery controls. The inspected performance assertion checks outgoing removal IDs, so it does not detect this main-side scan.
Earlier findings rechecked
Report / finding
Disposition at this head
7038792364 P0: processed removals accumulated under a sibling refusal
Fixed.markStale:66–73 discards prior evidence for a processed complete baseline, or deletes a processed incomplete write's explicit removal IDs before merging current desired IDs. acknowledge:127 supplies the actual sent delta for refused answers. Holding the live population fixed while cycling K=300/3,000 unique ended IDs therefore retains zero of those processed ended IDs and sends zero of them on the next retry, rather than retaining K and resending the growing prefix. Skipped/unanswered outcomes retain recovery evidence. Replacement now invalidates before deriving omissions, so unanswered writes also contribute to the unload removal list. The new performance assertion at desktop-relay-writes.performance.test.ts:33 checks a later save after the partial-refusal removal; inspected, not executed.
7034145708 #1: ownership stored as one large leaf; duplicate topology/publication. Also 7034431725 #1 and 7034648570 #1: duplicate unrelated consumers
Fixed. Ownership is flat desktopRelayOwnerByTabId; split depths 2 local / 3 host persist a changed scalar separately. At R=300/3,000, one changed owner writes one scalar leaf, not an R-entry payload. host-persistence:284–301 carries relay changes with the host's entries; session.ts:140–142 publishes them together. A combined debounced save adds zero second topology/title/layout-consumer executions. Relay-only publication passes topologyChanged=false.
7034145708 #2: close/move rediscovered known keys globally
Fixed. Retirement and pane close compare one known tab ID; detach/leaf move compare two. changedRelayKeys visits only those supplied IDs. Membership is checked before owner-map copying: unchanged/unowned cleanup makes zero owner copies at R=300/3,000.
Fixed.onWorkspaceRemoval: ownerTabKey feeds deleteOwnerKeyedSessionFields, including legacy/unified terminal IDs, batch/every-partition removal and last-repo removal with a retained host partition. Removing 300/3,000 owned tab IDs deletes all corresponding ownership entries without a future renderer baseline.
7034431725 #2: main-owned layout added per-host global reconnect scans
Fixed. The capability probe declines the separate protocol in main-owned layout; handler registration also skips legacy capture there. Added separate relay IPC/reconnect derivations per title save are zero at 4/40 SSH hosts and 300/3,000 terminals.
7034648570 #2: one-ID delta used whole-map equality
Fixed. Change detection uses relayChanges/ownerChanges, not whole-map equality. A warm explicit one-ID delta examines one relay/owner pair at R=300/3,000; unchanged/refused output copies are zero. The new finding concerns incomplete baselines without an explicit removal array, not this repaired delta branch.
Coverage
Reviewed the 41 changed files and relevant production callers/consumers in origin/main...bc445ea6387db20e5c8e8b5d04e82ff018465c6e; merge base 77f4a1f023210156e27216da1e593b5ff3889542. Citations use local target-ref code; GitHub availability of the commit was not assumed. Every detector surface was covered:
Surface
Paths and workload / bounds
publish
session-snapshot-operations.ts, session-bridge.ts; traced subscriber → projection/host routing → acknowledgement/plan → carried/separate IPC → ownership apply → Store title/layout listeners → save-baseline serialization → existing database worker. Warm unchanged relays send zero hosts; a warm one-binding change sends one host/ID. Main null patches publish nothing. Combined debounced host saves publish once. Finding above covers refused incomplete baselines before the null-patch gate.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, plus pane/tab close and move paths. Windowless handoff is attachment/promotion work, once per affected host, adding one supplied-key comparison per qualifying PTY. Retirement checks one key; moves two. These additions are not PTY-output/status handlers and add no PTY inventory or subprocess. Actual immutable ownership changes copy the current record; unowned/unchanged keys do not.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy capture and hydration. Donor cleanup adds two property deletions per fragment, no new traversal. SSH reassignment adds an ownership pass only after that partition's relay rewrite changes values, with zero new remote calls. Legacy capture uses one shared repo/tab index: O(H + repos + W + T + R) once when unadopted IDs exist, rather than H×T. At W=750/7,500 and T,R=300/3,000 this remains one fleet traversal. Adopted launches skip row indexing; storing adoption consumes that host's startup baseline. Cold-start SSH lookup uses preindexed repo/worktree identity, adding required reconnect outputs rather than per-tab catalog scans.
Six scan questions
Disposition
1. Work before skip gates?
Reviewed raw identity/session-field gates, cached capability probe, acknowledgement narrowing, omission-before-parked-index gate, main apply and downstream listeners. The finding is work paid before the main null-patch gate.
2. Ownership multiplying work?
One acknowledgement cache per document/API, keyed by host; absent hosts are pruned and generations fence late answers. One subscriber save in flight. No new per-pane client, listener, projection owner or poll.
3. Thread/storage payer?
Narrowing/evidence maintenance run on renderer; validation, apply, listeners and JSON preparation run on main. Ownership storage is scalar-split; database writes retain the existing worker route. No new synchronous filesystem/SQLite call, transport probe or subprocess. Finding prices main's unnecessary census.
4. Growth/progress?
Processed removals now retire despite sibling refusal. Legacy evidence is bounded by startup input and consumed/versioned. Retry debt is a fixed set of field names; retries wait for later real session changes. No new autonomous retry producer or per-update promise queue. The finding repeats work over current stored population, independently of terminal history.
5. Execution host?
Inspected local/SSH/runtime partitions, contested/parked and unread/hydrated hosts, folder-workspace attribution/removal, SSH reassignment, frozen source and WSL holds, paired/older-main fallback and main-owned layout. Added work uses memory/IPC/persistence: zero per-ID SSH round trips or native subprocesses. Finding applies to shared JavaScript on macOS, Linux and Windows, not a platform-specific process cost.
6. Obsolete work/budget release?
Subscriber disposal removes its listener/timer; admitted writes finish for durability. In-flight registrations release on settlement/invalidation; generations reject obsolete answers. Quit/unload stages relay and ownership with snapshots, skips legacy attribution, and includes unanswered removal evidence. At fixed current state, checkpoint work follows H + R + T, not processed terminal history. Added autonomous steady-idle wakeups are 0/s in renderer, main and daemon.
Touched recurring regression classes: hot-path rescans/work before no-op gates — finding; whole-map storage rewrite — matched, scalar split fixes prior defect; duplicate/broad publication — matched, combined debounced commits fix prior duplication; per-entity retention — matched, removal census and processed-removal retirement fix prior defects; unchanged publication/no-op output copies — acknowledgement and null-patch gates suppress them; queue/fan-out and idle wakeups — existing host fan-out, one subscriber save in flight, fixed field debt, no new periodic producer; loosened admission — required cold-start SSH outputs remain indexed and host/tab gated; eager imports/rereads — lightweight in-memory ownership/schema modules, no new SDK/native/disk probe. No new React selector or per-mounted-pane resource effect.
Pre-existing scaling remains separate: eligible terminal saves project/route O(W+T); ordinary session publication can reconcile C cached conversation workspaces and clone/load a W=750/7,500-workspace partition for layout subscribers. Actual ownership changes also require immutable current-record output, and the existing save-baseline mechanism enumerates the new scalar entries; unchanged scalar leaves avoid serialization/writes. These costs do not justify the finding's extra read-only census of omitted keys.
Validation limits: source inspection only, including the added assertions. No tests, typechecks, builds, app launches or timing/CPU/heap measurements ran. The performance fixture exercises real renderer saving and shared apply logic with in-memory main partitions; it does not exercise real Store/storage listeners or count omitted-key visits. No runtime latency, cross-platform transport or heap claim is made. Proposed remedy/guard is unverified. Checkout unchanged; no edits or commits.
Performance review: BLOCKED — one P0 and one P1, based on the local checkout at 5fa9990b0fe7e165eed7acffe25ad287f4db1ff8. Source inspection only; no tests, typechecks, builds, application launches, or runtime measurements ran.
P0 — Retire acknowledgement records for hosts that have actually gone away. Introducing change: desktop-relay-acknowledged-hosts.ts:96–102. Compared with bc445ea, absent-host deletion has been replaced with marking the record stale. This preserves necessary removal evidence for a temporarily omitted incomplete host, but also preserves every permanently removed host's entire last relay map.
Production reachability: repo-removal.ts:261 removes the last repo and purges its worktrees/tabs in the existing renderer. The host then disappears from the slices and from completeRelayHostIds; takeDesktopRelayWrite never offers it again. Main's workspace-removal census correctly deletes the stored ownership/bindings, but that does not notify this separate renderer cache. Every subsequent eligible save reaches narrow through the real subscriber → patchWorkspaceSessionByHost → relay plan route and walks the historical host map.
There is no retirement path: successful acknowledgement replaces only hosts actually sent; invalidate() retains all hosts; even forgetAcknowledgedDesktopRelays() calls invalidate(). The sole clearing forget() is reached on a changed API object, not ordinary host removal. Repeatedly using and removing distinct SSH hosts, or reassigning their identities, therefore retains historical records until document/API replacement. Subscriber remount and a vetoed unload do not clear them.
Source-derived price: hold the current fleet at 300 terminals across four SSH hosts, 75 per host, while replacing one host at a time. After K=40/400 retired identities, the cache retains 3,000/30,000 dead tab→relay entries and every subsequent relay-bearing save performs another 40/400 obsolete-host checks. At two eligible saves/s, that is 80/800 obsolete checks/s on the renderer, independently of the unchanged live population. K has no cap or cleanup owner, so retention and repeated work grow with window lifetime. Before this PR there was no relay acknowledgement cache; the immediately preceding head pruned absent hosts. P0 follows the skill's unbounded-growth rule; retained heap bytes and latency are unmeasured.
Remedy/check, proposed and unexecuted: distinguish temporary omission from authoritative owner retirement, and retire evidence only when main's cleanup/removal is established. Preserve incomplete-host omission, held rows, skipped/unanswered writes, and reappearance recovery. With a stable API and fixed live population, cycle K and 10K distinct host identities through the real save/removal seam; retired records and subsequent scan work must return to the live-owner bound. Keep the new omitted-host recovery control: a temporarily absent incomplete host must still name its ended ID when it returns. The added single-host recovery assertion does not exercise retirement or bound historical hosts.
The debounced entries path now carries relays correctly, but persistWorkspaceSessionByHost still sends session:set for every snapshot with relays: 'separate', followed by sendDesktopRelayWrite. The set preserves the old relay fields and publishes the ordinary snapshot (session.ts:88–95); a real changed relay then causes a second publication of that host (session-desktop-relays.ts:148–150). On the base, those relay fields were included in the single full set.
This is a recurring production route, not just process shutdown: mobile-terminal-close-ipc-bridge.ts:191 durably saves after a requested tab close; project-move-pause-follower.ts:95 uses the same path. The amplification occurs when that full snapshot also carries a real relay change awaiting persistence—for example, an SSH relay ends before the 150 ms debounced write, then a requested close persists the current state. It does not require every close to change a relay, and an entirely unchanged relay baseline correctly produces no second relay publication.
The second notification still reaches saved-conversation-title-publication.ts:39, which discards the supplied workspace/ref scope. StructuredConversationLabelChanges.reconcile visits every cached conversation workspace and reconstructs aliases for those on the host (structured-conversation-label-changes.ts:94). Relay changes cannot affect those aliases.
Source-derived price: C=100/1,000 cached conversation workspaces means 200/2,000 workspace checks instead of 100/1,000 per such durable save: 100/1,000 unnecessary synchronous main-thread checks, plus alias allocations. At two qualifying saves/s during a burst, the addition is 200/2,000 checks/s. A subscribed window-owned layout can also reload the whole partition again across separate IPC tasks, visiting W=750/7,500 workspaces and cloning its session bytes before equality suppresses an unchanged frame; the synchronous title scan proves the finding without relying on that scheduling case. No duration or CPU claim is made.
Remedy/check, proposed and unexecuted: apply full snapshot and relay ownership coherently before one publication, as the entries path now does. Preserve full-set semantics, main takeover/refusal, last-relay removal, ordering, and the durable receipt. Through the real full-save handler/Store/listeners, save a changed ordinary field plus one changed owned relay at C=100/1,000; require one publication and no second alias scan, with final binding and restart durability controls. The current renderer fixture has no durable full-set route or real Store listeners.
Earlier findings rechecked
Earlier comment / P1
Disposition at this head
7040306171: incomplete baseline enumerated all stored relay/owner keys on refusal
Fixed in source.desktop-relay-ownership.ts:64–68 uses desired keys alone for an incomplete baseline without explicit removals. With one conflicting desired ID and adoption already current, R=300/3,000 stored bindings produce one touched key, zero omitted-key enumeration, zero live-row indexing, and zero output-map copies/publications. Explicit deltas visit desired+removed IDs; complete baselines retain the necessary omission census. The new proxy enumeration assertion guards the shared apply branch; inspected, not executed.
7034145708 #1: ownership became one storage leaf; duplicate topology/publication
Storage and ordering fixed. Flat desktopRelayOwnerByTabId splits into scalar leaves at local depth 2 / host depth 3: one changed owner serializes one scalar at R=300/3,000. Relay-only publication skips topology ordering. Debounced duplication fixed, but the durable full-save variant remains finding 2.
7034431725 #1 and 7034648570 #1: repeated unrelated title/layout consumers
Fixed for the originally traced debounced saves:host-persistence.ts:284–301 carries relays with entries and session.ts:140–142 publishes together, adding zero second consumer executions. Not eliminated from every save route: finding 2.
7034145708 #2: close/move rediscovered known changed keys globally
Fixed. Retirement/pane-close compare one supplied ID; detach/leaf move compare two. Membership precedes owner copying: unchanged/unowned cleanup makes zero owner-map copies at R=300/3,000. Real immutable owned deletions still produce a changed record.
Fixed in main.onWorkspaceRemoval: ownerTabKey feeds the legacy/unified terminal census and deletes all removed ownership/binding entries, including last-repo removal in a retained partition. Removing 300/3,000 tab IDs leaves zero corresponding persisted owner entries. Finding 1 concerns the separate renderer acknowledgement record.
Fixed. The capability probe declines the separate protocol in main-owned mode, and registration skips legacy capture there. Added separate relay IPC/reconnect derivations per title save remain zero with 4/40 SSH hosts and 300/3,000 terminals.
7034648570 #2: one-ID delta compared whole maps for equality
Fixed. Change detection filters only relayChanges/ownerChanges; a warm one-ID delta compares one key at R=300/3,000. Unchanged/refused results copy no output maps.
The previously reported processed-removal accumulation also stays fixed: markStale drops processed complete-baseline evidence or deletes an incomplete write's explicit removals before merging desired IDs. Cycling 300/3,000 ended IDs under a sibling refusal retains zero processed ended IDs. Skipped/unanswered evidence remains available for recovery; unload invalidates before deriving removals. This does not retire permanently omitted hosts, as finding 1 shows.
Coverage and evidence
Inspected the 42 changed files and relevant production callers/consumers in origin/main...5fa9990b0fe7e165eed7acffe25ad287f4db1ff8; merge base 77f4a1f023210156e27216da1e593b5ff3889542. Citations use the local target; GitHub availability of that commit was not assumed. Every detector surface was reviewed:
Surface
Flagged paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced renderer field gates, acknowledgement/plan, carried and separate IPC, shared apply, Store listeners, split save baseline and existing database worker/fallback. Warm unchanged relays send zero hosts; a warm one-binding change sends one host/ID; main null patches publish nothing. Findings 1–2 cover historical-owner work and full-save publication.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: attachment/windowless handoff compares supplied PTY tab IDs once per affected host; retirement compares one known key, moves two. No new per-output/status hook, PTY inventory, subprocess, or per-pane owner. Changed ownership uses immutable current-record output; unchanged/unowned cleanup avoids copying.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: donor cleanup adds two property deletions per fragment; SSH rewriting adds an ownership pass only after relay IDs actually rewrite, for corresponding output, with zero new remote calls. Legacy capture indexes repos/rows once when unadopted IDs exist: O(H+repos+W+T+R), not H×T. At W=750/7,500 and T,R=300/3,000 this is one fleet traversal. Adopted launches skip row indexing. Legacy evidence is bounded by startup input, consumed per stored adoption, and never replenished. Cold-start reconnect attribution uses existing preindexed repo/worktree identities.
Six scan questions
Disposition
1. Work before the skip gate?
Reviewed raw identity/session-field gates, one cached capability probe per API, acknowledgement narrowing, parked-row indexing only on missing evidence, touched-key apply and final publication. Incomplete refusal is now constant in stored population; findings identify remaining historical-host work and downstream duplication.
2. Ownership multiplying/recreating work?
One acknowledgement cache per renderer document/API; one subscriber write in flight; no added per-pane client/poll/subscription. Finding 1: historical hosts outlive ownership. Finding 2: distinct publications repeat existing consumers.
3. Which thread/storage pays?
Narrowing/retention pay on renderer; validation, apply, listeners and JSON preparation on Electron main. Scalar ownership leaves prevent whole-owner JSON replacement. Database work retains the existing worker route and synchronous fallback; no new direct filesystem/SQLite operation, native probe, or subprocess was added.
4. Growth and progress?
Finding 1: absent-host state lacks a retirement bound. Processed refusals/removals otherwise advance; legacy versions/baseline consumption advance. Retry debt is a fixed set of session field names and retries await later real changes, with no autonomous retry timer. Host write fan-out follows the existing partition set.
5. Execution host?
Inspected local/SSH/runtime partitions, contested/parked and unread/hydrated hosts, folder attribution/removal, frozen migration/WSL holds, SSH reassignment, paired/older-main fallback and main-owned mode. Added work is shared JavaScript/IPC/storage; zero per-relay SSH round trips or host subprocesses. macOS/Linux/Windows transport execution was not assessed at runtime.
6. Obsolete work releases budget?
Subscriber disposal removes listener/timer; admitted saves finish for durability; generations fence obsolete answers and in-flight registrations release on settlement/invalidation. Main close/move/removal releases ownership. Unload stages snapshot and ownership together and skips legacy attribution. Finding 1: renderer host evidence is not retired. Added autonomous steady-idle wakeups are 0/s in renderer, main and daemon; existing debounce/shutdown timers remain event-triggered.
Touched regression classes: per-entity state outliving its owner / history-sized rescans — finding 1; duplicate/broad publication — finding 2, debounced variant repaired; whole-map storage replacement — disproved by scalar split; no-op allocation/unchanged publication and changed-key rediscovery — gated by membership, touched-change filtering, acknowledgement and null-patch admission; retry/queue multiplication — one subscriber save in flight and bounded field debt, no added periodic producer; newly reachable cold-start work — required SSH outputs use indexed ownership; eager imports/rereads — lightweight in-memory ownership/schema additions, no SDK/native/disk initialization. No new whole-store React selector or per-mounted-pane resource effect; the existing effects own persistence subscriptions and checkpoint handlers.
Pre-existing scaling is separate: relevant terminal saves project/route O(W+T); ordinary session notices reconcile C cached conversation workspaces and can reload/clone an entire W-workspace layout partition. The new owner map also participates in existing save-baseline enumeration, while unchanged scalar leaves avoid serialization/writes. Necessary immutable output copies follow the current relay population. Those costs do not justify scanning retired hosts or a second unrelated reconciliation for the same coherent full save.
Reliability control: ended desktop-owned IDs must disappear from durable restart state while main-owned/parked/live IDs survive; stale generations must not revive them. The inspected tests cover representative apply, adoption, refusal, last-ID removal, unanswered unload, omitted-host return and debounced wire behavior. They were not executed and do not prove the two findings absent. Existing terminal-session.layout-pty-ownership, terminal-session.explicit-close-retirement and startup-upgrade.persisted-session-corpus gates were not run under the requested machine constraint. Local/daemon/SSH/WSL/mobile and native platform runtime validation remain explicit gaps; PTY launch/input/geometry implementations are unchanged. No latency, CPU, heap-byte, live transport, or restart-execution claim is made. Proposed remedies/guards are unverified. Checkout unchanged; no edits or commits.
Performance review: BLOCKED — one P1 finding. Reviewed the local origin/main...c8616924e5247b25a20a54f67117442257bc9d9b diff (merge base 77f4a1f023210156e27216da1e593b5ff3889542). All requested earlier findings are fixed in source. The remaining finding is a different amplification in the main-side apply wrapper.
P1 — Do not rebuild the entire saved-host inventory for each known host's relay apply. Introducing work: session-desktop-relays.ts:115; the full-save fix newly invokes this per snapshot at session.ts:110.
The applier unconditionally executes new Set(store.getWorkspaceSessionHostIds()) after shared apply, even when patch is null (unchanged or refused). The real Store method session-host-partitions.ts:98 enumerates and normalizes every saved nonlocal partition, constructs a Set and returns another array. The wrapper constructs a second Set solely to ask whether this one host exists. Its cache lasts for one applier instance. Carried entries and full snapshots each create a new instance with [relayHostId], so separate IPC deliveries cannot share it.
Production trigger: ordinary one-ID relay updates through the debounced subscriber, and full durable saves through persistWorkspaceSessionByHost after requested tab closes (mobile-terminal-close-ipc-bridge.ts:191) or project-move pause (project-move-pause-follower.ts:95). Full saves invalidate acknowledgements and resend baselines, including unchanged hosts; setSnapshotsWithRelays carries each baseline with its snapshot. Consequently every qualifying snapshot pays this inventory even if its relays are unchanged. This repeats during normal use, rather than only at startup/quit.
Source-derived price: let H be written hosts, including local, and P saved nonlocal partitions. A full save adds H × P host normalizations, plus H inventories/arrays and wrapper Sets, on Electron main. With four SSH hosts plus local, H=5/P=4 gives 20 normalizations per save; scaling SSH hosts independently to 40 gives H=41/P=40 and 1,640. At two full saves/s during a close burst, those are 40/3,280 normalizations/s. Compared with the preceding head's single batched relay apply, this full-save route increases inventories from one to H (4→20 and 40→1,640 normalizations). Compared with the requested base, this relay inventory is entirely additional. Hold H=5 fixed while retained saved partitions reach P=40/400: the added cost is 200/2,000 normalizations per full save. A warm one-ID debounced delta also adds P unrelated host normalizations, although its target is already known. Terminal count can stay fixed at 300 throughout these host-population comparisons; this finding does not assume an SSH round trip per entry.
Impact/severity: repeated global discovery and temporary allocations for a single-host membership question; host growth makes full saves quadratic when H and P grow together. This is P1 under the repeated fleet-scaling-work rule, without claiming a measured stall, CPU percentage or heap size. Existing partition storage/copies and required full-snapshot processing are separate costs.
Remedy/check, proposed and unexecuted: use a targeted partition-existence query, and skip existence work when apply produced no patch or when the full-set caller will publish that partition anyway. Preserve the rule that a relay-only empty adoption must not materialize a new partition. Through the real handlers/Store at H=5/41 and independently P=40/400, count global inventory enumerations for unchanged/refused input, one owned-ID removal and full saves: target-specific applies should add zero inventory scans. Retain controls for absent hosts, adoption, refusal, fences, last-ID removal, one coherent publication and durability. The renderer performance fixture bypasses the real Store inventory and cannot catch this.
Earlier findings rechecked at this head
Comment / finding
Source disposition
7041292925 P0: retired-host acknowledgement records grew without bound
Fixed.AcknowledgedDesktopRelays.narrow deletes an omitted host when its captured routing context says it is no longer routed (desktop-relay-acknowledged-hosts.ts:106–113). The lazy context includes catalog, folder/group, hydrated, parked and unread owners (desktop-relay-writes.ts:145). Removing the last SSH repo and its tabs removes that route; after the next relay-bearing save, K=40/400 retired hosts retain zero acknowledgement maps/ended entries, rather than 3,000/30,000 dead entries at 75 relays per host. Temporarily omitted but still routed incomplete hosts retain removal evidence. In-flight answers can restore evidence until the next narrowing pass; this does not create a growing historical registry after settled churn.
7041292925 P1: durable full saves published ordinary fields and relays separately
Fixed.setSnapshotsWithRelays carries a host's relay write in its session:set; main applies it against the replacement snapshot before one setWorkspaceSession call (session.ts:96–115). Hosts carried in sets are excluded from sendRest. For C=100/1,000 cached conversation workspaces, the prior extra C-check reconciliation per combined host save is now zero; there is no second same-host publication. The inventory amplification above is distinct.
7034145708 #1: whole ownership-map storage leaf and duplicated topology/publication
Fixed. Flat scalar-valued desktopRelayOwnerByTabId uses local depth 2 / host depth 3 splitting. One changed owner serializes one scalar leaf at R=300/3,000, rather than the whole ownership map; the adoption version is a separate scalar. Relay-only publication skips row ordering. Combined entries and full saves publish once per host. Existing baseline key enumeration remains.
7034145708 #2: global relay comparison on close/move
Fixed. Retirement/pane-close pass one known ID; detach/leaf-move pass two. changedRelayKeys checks only those IDs, and forgetDesktopRelayKeys tests ownership before copying. Unchanged/unowned cleanup makes zero owner-map copies at R=300/3,000. Actual owned deletion still constructs the immutable changed map.
Fixed.onWorkspaceRemoval: ownerTabKey feeds the existing legacy/unified-terminal deletion census, including batch/every-partition and last-repo removal. Removing 300/3,000 owned tab IDs deletes all corresponding persisted ownership entries without a later renderer baseline; adoption version remains.
7034431725 #1 and 7034648570 #1: duplicate unrelated title/layout consumers
Fixed. Debounced entries carry relays into patchWindowSession and one Store publication; full sets now do likewise. The relay-only branch publishes only when the ordinary save is a no-op and relay fields actually change. Extra same-save title reconciliation/partition invalidation executions are zero.
Fixed. Capability probing declines the separate protocol under ORCA_LAYOUT_OWNER_IS_MAIN, and registration skips legacy capture there. Added separate relay IPC/reconnect derivations per title save are zero with 4/40 SSH hosts and 300/3,000 terminals.
Fixed. Shared apply filters only touched/adopted changes (desktop-relay-ownership.ts:100–103). A warm one-ID delta compares one key at R=300/3,000; unchanged/refused apply makes zero output-map copies. The wrapper's separate all-host enumeration is the finding above.
The later incomplete-baseline and processed-removal fixes also remain: an incomplete conflicting desired ID visits one key, with zero stored-map enumeration/live-row indexing in shared apply; processed refusal removes already-processed ended IDs from evidence. Cycling 300/3,000 ended IDs behind a sibling refusal retains zero processed ended IDs. Skipped/unanswered evidence survives for recovery, and unload invalidates before deriving explicit removals.
Coverage
Inspected the 43 changed paths, production callers, routing/removal, publication listeners, layout projection, save-baseline splitting and worker-write routing. Every detector hit is covered; three surface IDs span six unique files:
Surface
Flagged files and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced identity gates → host split/acknowledgement/plan → IPC/shared apply → Store listeners → layout/title consumers → persistence. Warm unchanged relays send zero relay hosts; one changed binding sends one host/ID. Null patches publish nothing. Main apply-wrapper inventory is the P1 above.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: promotion adds one supplied-key comparison per qualifying PTY on attachment/windowless handoff, once per affected host; retirement compares one known tab ID. No new per-output/status invocation, PTY inventory or resource owner. Pane moves compare two IDs.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: donor cleanup adds two property deletions per fragment; SSH ownership rewriting adds one pass only when relay IDs actually rewrite, for the corresponding changed output. Zero new subprocesses/remote calls. Legacy capture is O(H+repos+W+T+R) once for unadopted startup data: one row traversal at W=750/7,500 and T,R=300/3,000; adopted launches skip row indexing. Consumed baseline/version advances and startup evidence is never replenished.
Six scan questions
Disposition
1. Unused work before skip?
Reviewed renderer raw identity/field gates, cached capability probe, acknowledgement narrowing, parked-row indexing only for omitted IDs, touched-key apply and null-patch admission. Finding: all-host inventory runs even after apply returns null.
2. Ownership multiplies/recreates work?
One acknowledgement cache per renderer document/API; routed-host retirement now prunes it. No new per-pane client/poll/subscription. Finding: rebuilding an applier per carried host repeats its global inventory.
3. Which thread/storage pays?
Narrowing/evidence on renderer; validation, apply, inventory and listener work synchronously on Electron main. Flat ownership leaves retain changed-entry JSON/storage writes through the existing worker authority; existing whole-write/synchronous routes remain. No new direct filesystem/SQLite call or native initialization.
4. Growth/progress?
Main inventory work is H×P, including retained saved partitions. Other ledgers advance: legacy adoption consumes startup evidence; accepted/refused removals discard processed IDs; skipped/refused retry debt is a fixed set of field names. Subscriber has one save in flight and retries on later real changes, with no autonomous retry loop.
5. Execution host?
Inspected local/SSH/runtime partitions, contested/parked rows, unread/hydrated hosts, folder workspaces, SSH reassignment, WSL/frozen-source fences, paired/older-main fallback and main-owned mode. Added operations are shared JavaScript/IPC/persistence, with zero new per-relay transport calls or platform subprocesses. Runtime macOS/Linux/Windows transport costs were not measured.
6. Obsolete work releases budget?
Subscriber disposal removes listener/timer and stops admission; admitted writes finish for durability. Generations fence obsolete answers; in-flight registrations release on settlement/invalidation. Main close/move/removal releases ownership. Unload stages ownership with snapshots without legacy attribution; temporary omission retains recovery evidence. Added autonomous steady-idle wakeups are 0/s in renderer/main/daemon; existing debounce, minute capture and shutdown deadline remain unchanged.
Touched recurring classes: global discovery/hot-path rescans and work before skip — finding; ownership multiplication — finding; duplicate/broad publication — prior findings repaired; whole-map storage replacement — scalar splitting disproves; unchanged publication/no-op copies — acknowledgement, touched-change and null-patch gates; per-entity retention — routed-host retirement and workspace-removal census; retry/queue growth — one subscriber save in flight and fixed field debt; startup rereads/eager imports — in-memory getters and lightweight ownership/schema additions, no new disk/SDK/native initialization; whole-state persistence — existing serialization route, with changed scalar leaves rather than an ownership blob. No new whole-map React selector, mounted-pane resource effect, subprocess loop or recurring idle producer.
Pre-existing scaling is separate: relevant terminal saves project/route O(W+T); immutable changed records copy their current maps; session baseline snapshots enumerate keys; ordinary session notices reconcile C cached conversation workspaces and subscribed window-owned layouts can reload/clone an entire W-workspace partition. These are not independently graded as regressions. Their existence does not require the new H×P inventory.
Validation limits: source-derived counts only. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or live transport/restart checks ran, per the machine constraint. Added apply/adoption/recovery and performance assertions were read, not executed; the renderer fixture does not exercise real Store listeners, inventory or disk persistence. Platform, mobile, unload/reconnect and durable-restart execution remain unmeasured. Ancillary terminal-session and effect reference skill files were unavailable in the installed skill roots; their relevant ownership, subscription and teardown paths were inspected directly. The proposed remedy/guard is unverified. No further source-proven regression found; checkout unchanged, no edits or commits.
Performance review: BLOCKED — one P1 finding. Reviewed local origin/main...58bd161f0cc881733013813a6312810652ac775f, merge base 77f4a1f023210156e27216da1e593b5ff3889542. The requested earlier P1s are fixed in source, including the per-apply saved-host inventory. A later routing addition regresses renderer acknowledgement retirement.
P1 — Do not keep deleted hosts alive through historical primary-host mappings. Introducing line: desktop-relay-writes.ts:154. routedRelayHosts now treats every value in contestedPrimaryHostBySessionKey as a live route, without checking whether that workspace still exists.
Production trace: startup SSH adoption populates this map for adopted SSH workspaces, including uncontested ones (workspace-session-host-hydration.ts:223–233); hydration installs it in renderer state (workspace-terminal-hydration.ts:162). After the window has saved those hosts' relay IDs, remove the last project on one such SSH host, with no surviving folder/group, parked workspace or runtime owner remaining there. repo-removal.ts:230 calls purgeWorktreeTerminalState, which reaches buildWorktreePurgeState; its layout/surface purge removes tabs, PTY IDs and reconnect evidence. The subsequent repo-removal patch removes the catalog/worktree rows (repo-removal.ts:261–295). Neither patch removes contestedPrimaryHostBySessionKey entries, and this path does not reload the document.
The next relay-bearing save consequently has no slice or complete-host baseline for that retired host. Nevertheless, the new Object.values(...) includes its historical primary mapping. In desktop-relay-acknowledged-hosts.ts:106, routes(hostId) stays true: the omitted-host branch marks the acknowledgement stale instead of deleting it. Its entire last relayIdsByTabId remains reachable from the module singleton, and every later narrowing pass revisits the retired host. Main's workspace-removal census correctly deletes persisted ownership; that does not release this renderer record. Invalidating acknowledgements also preserves these IDs as stale evidence rather than clearing them.
Source-derived price: remove four startup SSH hosts holding 75 acknowledged relays each: 300 dead relay entries across four host records remain, versus zero after settled removal before this routing addition. At 40 hosts with the same per-host population, 3,000 entries across 40 records remain. These populations are the reference 300-terminal fleet and its 10× scale. Keep another live terminal to exercise subsequent saves: two relevant saves/s add 8/80 retired-host checks/s, plus the shared routing-set preparation, for the lifetime of the document. These are retained-record and operation counts, not measured heap bytes or CPU time. No timer is needed to establish the leak. This is P1 for entity state surviving authoritative removal and repeated work over retired owners; no unbounded-growth or measured-stall claim is necessary.
Compared with c861692, the newly included historical primary mappings prevent an otherwise unrouted host from reaching the existing delete branch. Thus the retired-host cleanup described in comment 7041929860 no longer holds for startup-restored SSH workspaces, even though that comment's actual inventory P1 is repaired.
Remedy/check, proposed and unexecuted: prune read-source mappings on authoritative workspace removal, or count them as relay routes only while their workspace still has surviving ownership evidence. Preserve incomplete/parked workspaces, catalog hydration gaps and surviving host twins. A performance contract through startup hydration → acknowledged save → real last-project removal → later save, at 4/40 hosts and 75 relays/host, should show zero retired host records/IDs and zero subsequent retired-host visits. Include a control retaining removal evidence for a genuinely surviving incomplete host. Existing added tests do not exercise this removal path with startup primary mappings.
Requested earlier P1s rechecked
Earlier comment / finding
Disposition at this head
7041929860: each relay apply rebuilt saved-host inventory
Fixed.session-desktop-relays.ts:119–122 short-circuits on null patches or a nonempty relay-map patch; otherwise it calls hasWorkspaceSessionHost. The real implementation (session-host-partitions.ts:99,193) normalizes only the requested host and directly indexes its persisted partition. Warm delta/full-set applies add zero global inventories, independent of P saved partitions. H=5/41 writes with independently P=40/400 cost at most H targeted lookups, replacing H×P discovery; unchanged/refused null patches cost zero existence lookups. Startup and unload retain their separate, single inventory passes.
7034145708 #1: whole ownership-map storage leaf and repeated topology/publication
Fixed. Flat scalar-valued desktopRelayOwnerByTabId matches split depths 2 local / 3 host. One changed ownership value at R=300/3,000 serializes one scalar leaf, not R entries. Relay-only Store publication skips topology ordering. Combined entries and full snapshots publish once per host. Baseline key enumeration remains.
7034145708 #2: whole relay-map discovery on close/move
Fixed. Retirement and pane close compare one supplied key; detach/leaf move compare two. Promotion compares the supplied qualifying PTY keys once per host. forgetDesktopRelayKeys checks membership before copying: zero owner-map copies for unchanged/unowned cleanup at R=300/3,000; a real owned deletion builds the changed immutable map.
Fixed on main.onWorkspaceRemoval: ownerTabKey includes the owner record in the existing legacy/unified terminal-ID census (session-owner-fields.ts:51–74), including batch/every-partition removal. Removing 300/3,000 owned tab IDs deletes all corresponding persisted ownership entries. The renderer retention above is a different record and lifetime.
7034431725 #1 and 7034648570 #1: duplicate unrelated title/layout consumers
Fixed. Debounced writes carry each host's relays with its entries; full saves carry them with its snapshot (desktop-relay-write-plan.ts:137–158). Main applies before one Store call (session.ts:107–109,133–149). Carried hosts are excluded from sendRest. At C=100/1,000 cached conversation workspaces, extra same-host title-reconciliation checks from a second publication are zero. A relay-only changed save still publishes once; a null patch publishes nothing.
Fixed. The capability probe declines the separate protocol in main-owned mode (desktop-relay-writes.ts:60–69); main skips legacy capture there. With 4/40 SSH hosts and 300/3,000 terminals, unchanged-relay title saves add zero separate-protocol IPCs or reconnect derivations. Existing ordinary main-owned saves remain.
Fixed.desktop-relay-ownership.ts:64–68,100–103 derives changes from touched/adopted keys. A warm one-ID delta visits one touched key at R=300/3,000; unchanged/refused input makes zero output-map copies. An incomplete conflict also avoids row indexing. Complete baselines deliberately visit stored keys to implement omission removal.
Coverage and source bounds
Inspected all 45 changed paths, relevant production callers, hydration/routing, project and terminal teardown, Store composition/publication listeners, title/layout consumers, save-baseline splitting and worker-write routing. perf-surface-detect origin/main...58bd161f0cc881733013813a6312810652ac775f reported three surface IDs across six unique files; every hit is covered:
Surface
Flagged paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced renderer identity gates → host split/acknowledgement → carried/separate IPC → ownership apply → Store listeners → persistence. Warm unchanged relays send zero relay hosts; one changed binding sends one host/ID. Null relay patches publish nothing. Carried saves publish once. Main host membership is now targeted; renderer retirement is the finding.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: promotion runs on desktop attachment/windowless handoff, once per affected host; added comparisons are proportional to qualifying PTYs (300/3,000 total at the chosen scales), with no new PTY inventory or per-output/status invocation. Retirement checks one known key, moves two. Actual changed owner maps are copied for immutable publication; unchanged/unowned cleanup returns the original object.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: donor extraction adds two property deletions per existing fragment; no new traversal. SSH reassignment adds one owner-record rewrite pass only when relay IDs actually rewrite, preserving ownership for changed IDs. Legacy capture is one in-memory O(H+repos+W+T+R) startup pass for unadopted input: W=750/7,500 and T,R=300/3,000. Adopted launches skip tab attribution; stored version/consumed baseline prevents repeated adoption. No per-tab transport, subprocess, disk probe or heavy startup adapter is added.
Six scan questions
Disposition
1. Unused work before skip gates?
Reviewed raw relevant-field identity gates, cached capability probe, acknowledgement delta construction, lazy parked-row indexing, touched-key apply and null-patch admission. An empty-key claim indexes rows once per affected apply for membership; an existing-ID conflict does not. Complete baselines scan the IDs their omission semantics govern. Finding: obsolete primary mappings defeat host retirement before later saves settle.
2. Ownership multiplies/recreates work?
One acknowledgement owner per renderer document/API; no new per-pane client, poll or subscription. The main wrapper no longer recreates global host inventories. Finding: removed SSH owners remain in the renderer registry through historical primary mappings.
3. Thread/storage cost?
Routing/acknowledgement work is on renderer; validation, apply and publication listeners are synchronous on Electron main. Changed scalar ownership leaves use the existing save baseline and worker authority; whole snapshots/fallback remain the existing persistence routes. No new direct synchronous filesystem/SQLite call. Runtime occupancy and storage timings were not measured.
4. Growth and recovery progress?
Finding: retained renderer state scales with removed startup hosts and their last relay populations. Other ledgers advance: stored adoption consumes startup evidence; processed refusal drops explicitly processed ended IDs; skipped/unanswered IDs remain recovery evidence. Subscriber write admission is one in flight; pending/deferred debt is a fixed set of session field names, without autonomous retries.
5. Execution host?
Source reviewed for local/SSH/runtime partitions, contested/parked rows, unread startup hosts, folder workspaces, WSL/frozen-source fences, SSH reassignment, paired/older-main fallback and main-owned mode. Added work is JavaScript/IPC/persistence: zero new per-relay SSH round trips or platform subprocesses. macOS/Linux/Windows runtime transport performance was not exercised.
6. Obsolete work releases budget?
Subscriber disposal removes its listener/timer and stops admission; admitted writes settle for durability. Acknowledgement generations fence late answers, and in-flight records release on settlement/invalidation. Main close/move/workspace removal drops ownership. Unload stages relays with snapshots and skips legacy attribution; its host inventory is once per checkpoint, not per apply. Finding: acknowledgement host deletion is bypassed by stale primary mappings. Added autonomous steady-idle wakeups are 0/s in renderer, main and daemon; existing debounce, minute capture and shutdown deadline remain unchanged.
Touched recurring classes: per-entity state outliving its entity / retained-owner scans — finding; global per-event discovery — previous main inventory defect fixed; duplicate/broad publication — coalescing disproves added same-save fanout; whole-map storage replacement — scalar splitting disproves; whole-map equality/no-op allocation — touched-key/null-patch gates disprove; retry/queue amplification — one subscriber save in flight and bounded field debt; startup rereads/eager imports — in-memory capture and lightweight modules, no new I/O/adapter initialization; steady-idle work — no added recurring producer. No matching new whole-map React selector, mounted-pane resource effect, subprocess loop or streaming reprocessing.
Pre-existing scaling was traced separately: relevant terminal saves project/route O(W+T); changed immutable maps copy their current entries; baseline snapshots enumerate session keys; ordinary session publication reconciles C cached conversation workspaces and subscribed window-owned layouts can reload/clone a W-workspace partition. Those costs predate the span; no second combined-save invocation remains. The historical primary mapping's own retention also predates this span; using it to retain and repeatedly visit an additional relay acknowledgement map is introduced here.
Validation limits: read-only source evidence and inspected, unexecuted assertions. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or transport/restart checks ran, as requested. The new main performance contract checks zero inventories after registration across 40 adopted hosts, but stubs Store membership and exercises null-patch inputs. Renderer performance fixtures check wire payloads using an in-memory main; they bypass real Store listeners/storage and do not cover restored-host project removal. Runtime startup/unload latency and platform/mobile execution remain unmeasured. Ancillary reference skill files named by perf/perf-scan were unavailable in the installed skill roots; relevant lifecycle/effect paths were inspected directly. The proposed remedy and guard are unverified. Checkout unchanged; no edits or commits.
Performance review: BLOCKED — one P1 finding at local head eba49d09c963b41f94ee855fd5b9b93b3bf3e309.
P1 — Retire empty relay acknowledgements for explicitly removed runtime hosts. Introducing call: desktop-relay-writes.ts:149. routedRelayHosts still imports every startup-loaded runtime host through routedSessionHostIds; that function unconditionally includes hydratedRuntimeSessionHostIds (workspace-session-host-entries-write.ts:34). Removing the historical primary/read-source mappings fixes the reported SSH case, but this other historical list still retains retired runtime-host records.
Production trace: startup reads saved runtime partitions and returns them in hydratedRuntimeSessionHostIds (workspace-session-host-hydration.ts:170–185,234); terminal hydration installs that list (workspace-terminal-hydration.ts:165–166). A normal runtime repo with terminal rows gets a host slice in the initial save. takeDesktopRelayWrite includes that host even with an empty relay map (desktop-relay-writes.ts:167–175). Main accepts the empty baseline, and AcknowledgedDesktopRelays.acknowledge stores the host record (desktop-relay-acknowledged-hosts.ts:133–138). This path needs no nested SSH connection or retained relay payload.
After an accepted save, explicitly remove the last ordinary runtime project on that host, with no surviving folder/group or parked workspace there. removeProject sweeps the desktop's persisted host rows (repo-removal.ts:172–178), purges terminal/reconnect state (:230), then removes catalog/worktree rows (:233–295). Neither this action nor its purge prunes hydratedRuntimeSessionHostIds; its only production assignments are initial state and hydration. This removal does not reload the document.
On the next relay-bearing save, the host has no slice, and completeRelayHostIds correctly excludes it because it no longer has a repo (desktop-relay-writes.ts:108–112). Nevertheless, routes(hostId) remains true through the startup hydration list. The omitted-host branch therefore marks its acknowledgement stale instead of deleting it (desktop-relay-acknowledged-hosts.ts:106–114). The module singleton retains the host and its empty relay record, and every later narrowing pass visits that retired host again. Invalidation preserves host records; main's successful ownership cleanup does not release this renderer record.
Source-derived price: use the reference 300-terminal population distributed across four startup-loaded runtime hosts, then remove those projects while another live terminal continues saving. Four obsolete relay-acknowledgement records remain, even with zero relay IDs in them; scaling hosts to 40 and terminals to 3,000 retains 40 records. At two later relay-bearing saves/s, the new registry adds 8/80 retired-host checks/s, plus 8/80 historical-host insertions/s when its lazy routing set is rebuilt. Those extra checks and retained records last for the document's lifetime. These are operation/record counts, not measured heap bytes or CPU time; retained relay payloads are not claimed. The hydration list and its ordinary-entry acknowledgement use predate the span; the additional registry and its later traversals are introduced here. Under this scan's fleet-scaling and entity-lifetime rules this is P1; no unbounded-growth or latency claim is needed.
Remedy and proving check, proposed and unexecuted: retire hydration/relay evidence after authoritative last-owner removal, while preserving unread/catalog-gap, parked and surviving-twin evidence. At 4/40 runtime hosts and 300/3,000 total terminals, exercise startup hydration → accepted empty relay baseline → real last-project removal → subsequent saves. Require zero retired relay host records and zero later visits to them; retain a control with a genuinely surviving incomplete host. The added assertions do not cover this lifecycle.
Requested earlier findings
Earlier comment / P1
Disposition at this head
7034145708 #1: whole ownership-map storage leaf and repeated topology/publication
Fixed in source. Flat desktopRelayOwnerByTabId matches persistence split depths 2 local / 3 host. Changing one owner at R=300/3,000 serializes one scalar leaf, rather than an R-entry ownership payload. Relay-only publication skips topology ordering. Combined entries/full snapshots commit once per host. Container-key enumeration remains.
7034145708 #2: global changed-key discovery on close/move
Fixed in source. Retirement/pane close compare one supplied key; detach/leaf move compare two. Promotion compares the qualifying PTY keys once per affected host. forgetDesktopRelayKeys checks membership before copying: zero owner-map copies for unchanged/unowned cleanup at R=300/3,000. Real owned changes produce the required immutable map.
Fixed in source on main.onWorkspaceRemoval: ownerTabKey includes ownership in the existing legacy/unified terminal-ID census (session-owner-fields.ts:51–74). Removing 300/3,000 owned tab IDs removes their persisted owner entries without a later renderer baseline. The finding above concerns a separate renderer record.
Fixed in source. Host relays ride with entries or snapshots; carried hosts are excluded from sendRest. Main applies them before one Store mutation (session.ts:107–108,133–149). At C=100/1,000 cached conversation workspaces, the extra second-publication reconciliation is zero.
Fixed in source. The capability probe declines the separate protocol in main-owned mode; main also skips legacy capture. With 4/40 SSH hosts and 300/3,000 terminals, unchanged-relay title saves add zero separate relay IPCs/global reconnect derivations. Ordinary main-owned save work remains.
Fixed in source by the same carried-write composition above, including full snapshots. Relay-only changed saves publish once; null relay patches publish nothing.
7034648570 #2: whole-map equality for a one-ID delta
Fixed in source.desktop-relay-ownership.ts:64–68,100–103 derives changes from touched/adopted keys. A warm one-ID delta visits one touched key at R=300/3,000; unchanged/refused input copies no output maps. Complete baselines visit stored keys for omission semantics.
7042234431: historical primary mappings keep retired SSH hosts' relay records
The specific SSH case is fixed in source.routedRelayHosts no longer includes either historical primary/read-source map. Once its last live owner is removed, an SSH host without parked/unread evidence reaches the acknowledgement delete branch: zero retained IDs and zero subsequent host checks after that pruning pass. Runtime hydration evidence still causes the obsolete-host-record P1 above.
The previously repaired per-apply host inventory also remains repaired: session-desktop-relays.ts:119–122 uses targeted hasWorkspaceSessionHost; its real Store implementation directly indexes the requested partition. For H=5/41 writes and independently P=40/400 saved partitions, this adds zero whole-host inventories and at most H targeted membership lookups; null patches add none.
Coverage and bounds
Reviewed origin/main...eba49d09c963b41f94ee855fd5b9b93b3bf3e309, merge base 77f4a1f023210156e27216da1e593b5ff3889542: all 45 changed paths, their relevant production callers, ownership/removal, hydration/routing, Store publication, conversation/layout consumers, save-baseline splitting and durable-write routing. The detector returned three surface IDs across six files; every hit was inspected:
Surface
Paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced subscriber → host split → acknowledgement → carried/separate IPC → main apply → Store listeners → storage. Warm unchanged relays send zero relay hosts; one changed binding sends one host/ID. Capability probe is once per API identity/document. Combined writes publish once; relay-only writes skip topology; null patches publish nothing. Renderer host retirement has the finding above.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: promotion runs on attachment after a windowless gap, once per affected host, adding comparisons proportional to qualifying PTYs (300/3,000 total), with no added PTY inventory. Retirement compares one known key, moves two. These additions do not run per PTY output/status frame. Owned changes copy their immutable owner record; no-op cleanup copies none.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: donor extraction adds two property deletions per existing fragment; no new traversal. Target reassignment adds one ownership rewrite pass only when a partition's relay IDs actually rewrite. Legacy capture adds one in-memory O(H+repos+W+T+R) startup pass for unadopted input, with W=750/7,500 and T,R=300/3,000; already-adopted launches skip row attribution. Stored adoption consumes the baseline/version. No per-ID transport or subprocess is added.
Six scan questions
Disposition
1. Work before skip gates
Reviewed raw field-identity gates, cached probe, acknowledgement narrowing, lazy parked-row indexing, touched-key apply and null-patch admission. Complete baselines inspect omission-governed IDs; empty-key claims index that partition's rows once per apply to establish membership. Existing-ID conflicts avoid that index. The finding concerns obsolete host admission before later passes settle.
2. Ownership multiplication/lifetime
One relay acknowledgement owner per renderer document/API, no new per-pane resource owner/client/poll. Main membership is targeted. Removed runtime hosts can outlive their entities as described above.
3. Thread/storage
Renderer pays projection/routing/acknowledgement; Electron main pays validation, apply, serialization preparation and synchronous listeners. Changed ownership values split into scalar storage leaves through the existing worker authority; the existing synchronous fallback remains. No new direct filesystem/SQLite operation. No runtime occupancy claim.
4. Growth/progress
Finding: dead renderer host records remain proportional to removed startup runtime hosts. Other ledgers progress: persisted adoption consumes startup evidence; processed refusals discard explicitly removed IDs; skipped/unanswered IDs retain recovery evidence. Subscriber admission is one save in flight; pending/deferred debt is a fixed set of session field names. Refusal may resend a host baseline O(R), on a later real session change, to recover uncertain main state; no autonomous retry producer.
5. Execution host
Source inspected for local/SSH/runtime partitions, nested SSH, parked/contested rows, unread startup partitions, folder workspaces, WSL/frozen-source fences, SSH reassignment, paired/older-main fallback and main-owned mode. Added work is JavaScript/IPC/persistence: zero new per-relay SSH round trips or platform subprocesses. macOS/Linux/Windows and mobile transport behavior were not executed.
6. Obsolete work/release
Subscriber disposal removes its listener/timer and stops new admission; already-admitted writes settle for durability. Generations fence late acknowledgements; in-flight records release on settlement/invalidation. Main tab/workspace removal clears ownership. Unload stages relay/owner fields with snapshots, skips legacy attribution and inventories hosts once per checkpoint. Renderer runtime-host retirement is the finding. Added autonomous steady-idle wakeups: 0/s in renderer, main and daemon; existing debounce/minute capture/shutdown deadline are unchanged.
Touched recurring classes: entity state outliving its entity and retained-owner scans — finding; global per-event discovery — disproved by targeted membership; duplicate/broad publication — disproved by carried-write composition; whole-map storage replacement — disproved by scalar splitting; whole-map change discovery/no-op allocation — disproved by touched-key/null-patch gates; retry/queue amplification — one in-flight subscriber save and fixed field debt, no autonomous retry; startup rereads/eager imports — in-memory capture and lightweight dependencies, no new disk/native/adapter startup producer; idle wakeups — no new recurring producer. No matching new whole-map React subscription, mounted-pane resource effect, subprocess loop or streaming reprocessing.
Pre-existing scaling is separate: relevant terminal saves project/route O(W+T); ordinary entry acknowledgement already retains hosts from the startup hydration list; save-baseline snapshots enumerate session keys; ordinary publication reconciles C cached conversation workspaces and subscribed window-owned layouts can reload/clone a W-workspace partition. The new owner record requires R scalar slots when an actual owner change creates its immutable output, and adds R leaves to save-baseline traversal. These populations follow current saved ownership rather than terminal history. The newly retained renderer relay-acknowledgement host records are the additional obsolete population identified above.
Evidence limits: source inspection and read-only detector output; added assertions inspected but unexecuted. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or live restart/transport checks ran, as requested. The renderer performance fixtures exercise wire payloads through an in-memory main and bypass real Store consumers/storage; the main contract covers 40 adopted hosts with null patches; the ownership contract covers an incomplete refused write. None covers startup runtime-host removal. Runtime startup/unload latency and platform/mobile execution remain unmeasured. Ancillary lifecycle/effect reference skills named by the scan were unavailable in the installed skill roots; those code paths were inspected directly. The proposed remedy/check is unverified. Checkout unchanged; no edits or commits.
Performance review: BLOCKED — one P1 finding at local head c9f19523d4cec71109da59218050bfd6ff286297.
P1 — Release captured legacy relay IDs on authoritative project removal before adoption. The new process-lived capture at session-desktop-relays.ts:106 has no removal invalidation. desktop-relay-legacy-adoption.ts:47 copies adoptable startup IDs into independent per-host records. Their only deletion paths are a later relay apply recording adoption (session-desktop-relays.ts:123–126) or an apply batch observing an already-adopted version (desktop-relay-legacy-adoption.ts:106–112). Neither runs for an omitted host.
Production trigger and lifetime: on an upgrade with unadopted SSH relay IDs, let a host partition's startup read fail. Hydration explicitly supports this outcome: it records the unread host and continues without its rows (workspace-session-host-hydration.ts:158–164). With no surviving folder/group or other workspace there, remove that host's last project before any relay apply adopts it. The normal removal calls main's removeProjectForHost; it deletes persisted rows, relays and owners through removeRepoFromHostWorkspaceSessions and the workspace-removal census (repo-lifecycle-operations.ts:124–144, session-owner-fields.ts:51–74). Those operations do not touch the captured legacy record. The unread host has no slice, and completeRelayHostIds excludes it (desktop-relay-writes.ts:114–116); after project removal it also lacks catalog completeness. Later ordinary saves and unload therefore need not send a relay apply for it. Main's registered IPC closures keep the independent capture reachable until process exit. IPC registration is explicitly once per process (register-core-handlers.ts:126–132), so replacing the window does not release it.
Source-derived price: four unadopted startup SSH hosts with 75 IDs each leave 300 obsolete tab-to-relay entries in four main-process records after authoritative removal; 40 such hosts leave 3,000 entries in 40 records. Main's persisted/session copies can be correctly cleared while this additional capture remains. This is an introduced entity-lifetime retention regression, distinct from the repaired renderer acknowledgements. The capture is bounded by startup input and never replenished; I am not claiming unbounded growth, repeated scans of omitted hosts, disk retention, measured heap bytes or a latency threshold. Under this scan's retained-entity rule this is P1: removed terminal populations remain charged to main memory for the rest of the process.
Proposed remedy and proving check, unexecuted: invalidate captured keys through authoritative tab/workspace/project removal, while preserving startup provenance for still-live unread, fenced or relocated rows. Avoid introducing whole-host inventories on each apply. At 4/40 hosts and 300/3,000 total IDs, cover real capture → failed partition hydration → last-project removal → subsequent saves/window replacement; require zero captured IDs for removed owners. Keep controls proving a surviving unread host retains adoption evidence and a first save moving rows between partitions still adopts correctly. The added assertions do not cover this lifecycle.
Fixed in source. Flat desktopRelayOwnerByTabId fits split depths 2 local / 3 host. At R=300/3,000, one changed owner serializes one scalar leaf. Relay-only writes skip topology; combined entries/full snapshots commit once per host.
7034145708 #2: global relay comparison on close/move
Fixed in source. Retirement/pane close compare one supplied key; detach/leaf move compare two. Membership is checked before copying ownership: unchanged/unowned cleanup copies zero maps at R=300/3,000.
Fixed in source.onWorkspaceRemoval: ownerTabKey joins the legacy/unified tab census. Removing 300/3,000 owner tabs clears their persisted owner entries. The finding above concerns a separate startup capture.
7034431725 #1 and 7034648570 #1: duplicate unrelated title/layout reconciliation
Fixed in source. Relays ride with their host's entries or snapshot; carried hosts are excluded from sendRest. Main applies before one Store mutation (session.ts:107–109,133–152). For C=100/1,000 cached conversation workspaces, the extra second-publication checks are zero.
Fixed in source. The probe declines the separate protocol in main-owned mode; main also skips legacy capture. At 4/40 SSH hosts and 300/3,000 terminals, unchanged-relay title saves add zero separate relay IPCs/reconnect derivations.
7034648570 #2: whole-map equality for a one-ID delta
Fixed in source. Apply derives changes from touched/adopted keys (desktop-relay-ownership.ts:64–68,100–103). A warm one-ID delta checks one touched key at R=300/3,000; unchanged/refused writes copy no output maps. Complete baselines inspect stored keys for omission semantics.
Fixed in source. Relay routing excludes primary/read-source startup maps. With no surviving live/parked/unread evidence, an omitted SSH host is deleted on the next narrowing pass: zero retained relay IDs and zero subsequent retired-host visits.
7042505846: startup runtime-host list retains empty acknowledgements
Fixed in source.routedRelayHosts passes only repos/folders/groups to ordinary routing (desktop-relay-writes.ts:150–155), excluding the hydration list. Omitted empty acknowledgements are also deleted before routing (desktop-relay-acknowledged-hosts.ts:110–111). At 4/40 removed runtime hosts, zero relay records remain after pruning and zero subsequent visits occur.
The earlier per-apply host-inventory fix also remains: real Store membership directly indexes one partition. H=5/41 writes with independently P=40/400 saved partitions add zero whole inventories and at most H targeted existence lookups; null patches add none.
Coverage and bounds
Read-only review of origin/main...c9f19523d4cec71109da59218050bfd6ff286297, merge base 77f4a1f023210156e27216da1e593b5ff3889542. Inspected all 45 changed paths and relevant save, hydration, removal, publication and storage callers/consumers. Every detector hit was covered; its three surface IDs span six unique files:
Surface
Paths and disposition
publish
session-snapshot-operations.ts, session-bridge.ts: traced subscriber identity admission → host split/acknowledgement → carried/separate IPC → main ownership apply → Store listeners → scalar storage. Warm unchanged relays send zero relay hosts; one changed binding sends one host/ID. Capability probe is once per document/API identity. Combined saves publish once; relay-only writes skip topology; null patches publish nothing.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: attachment after a windowless gap adds comparisons for qualifying PTYs once per affected host (300/3,000 total), without a new PTY inventory or per-output/status trigger. Retirement compares one known key, moves two. Real owner changes build the required immutable record; no-op cleanup returns the input.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: two property deletions per existing donor fragment, without another traversal; one owner rewrite pass only when that partition's relay IDs actually rewrite. Legacy capture adds one in-memory O(H+repos+W+T+R) upgrade pass, with W=750/7,500 and T,R=300/3,000. Adopted launches skip row attribution. Ordinary adoption consumes its version/baseline; abandoned pre-adoption captures have the finding above. No new disk probe, subprocess or per-ID remote call.
Six scan questions
Disposition
1. Unused work before skip gates
Reviewed field-identity/probe gates, acknowledgement deltas, lazy parked-row indexing, touched-key apply and null-patch admission. Empty-key claims index that partition's tab rows once per apply to establish membership; existing-ID conflicts avoid that index. Complete baselines inspect omission-governed keys.
2. Ownership multiplication/lifetime
One acknowledgement registry per renderer document/API; one startup capture per main process; no new pane-owned client/poll/listener. Renderer host retirement is repaired. Main capture lifetime is the finding.
3. Thread/storage
Renderer pays projection/routing/diff; Electron main pays validation/apply and synchronous publication listeners. Owner values persist as scalar leaves through the existing worker authority; existing synchronous fallback remains. No new direct filesystem/SQLite call. No measured occupancy claim.
4. Growth/progress
Finding: captured removed IDs remain bounded by unadopted startup input. Other ledgers advance: adoption consumes evidence; processed refusals remove named ended IDs; skipped/unanswered writes preserve recovery evidence. Subscriber admits one save in flight, with pending/deferred debt bounded by session field names. Refusal retries with a later real session change, without an autonomous retry producer.
5. Execution host
Inspected local/SSH/runtime partitions, nested SSH, parked/contested rows, unread hydration, folder workspaces, WSL/frozen-source fences, SSH reassignment, paired/older-main fallback and main-owned mode. Added runtime work is JavaScript/IPC/persistence: zero new per-relay SSH round trips/platform subprocesses. macOS/Linux/Windows and mobile were source-reviewed, not executed.
6. Obsolete work/release
Subscriber disposal removes its timer/listener and stops admission; admitted durable writes settle. Generations fence late answers, and in-flight records release on settlement/invalidation. Main tab/workspace removal clears persisted ownership. Unload stages relays/owners with snapshots, skips legacy attribution, and inventories hosts once per checkpoint. Startup-capture removal is the finding. Added autonomous steady-idle wakeups: 0/s on renderer, main and daemon; existing debounce/minute capture/deadline behavior remains.
Touched recurring classes: entity state outliving its entity — finding; global per-event discovery — disproved by targeted membership; duplicate/broad publication — disproved by carried-write composition; whole-map storage replacement — disproved by scalar splitting; whole-map equality/no-op allocation — disproved by touched-key/null-patch gates; retry/queue amplification — one subscriber save in flight and fixed field debt; startup rereads/eager imports — in-memory capture and lightweight imports, no new I/O/adapter initialization; idle wakeups — no added periodic producer. No matching new whole-map React selection, per-mounted-pane resource effect, subprocess loop or streaming reprocessing.
Pre-existing scaling remains separate: relevant terminal saves project/route O(W+T); ordinary entry acknowledgement retains historical hydrated hosts; save-baseline snapshots enumerate session keys; ordinary publication reconciles C cached conversation workspaces and a subscribed window-owned layout can reload/clone a W-workspace partition. This span adds R owner scalar slots to immutable changed output and save-baseline traversal, representing saved ownership. No second combined-save publication remains. The new abandoned startup capture is the distinct obsolete population reported above.
Evidence limits: source-derived counts and inspected, unexecuted assertions. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or live restart/transport checks ran, as requested. The main performance assertion covers null-patch applies over 40 adopted hosts with stubbed membership; renderer assertions use an in-memory main without real Store consumers/storage; the ownership assertion covers an incomplete refused write. None covers removal before legacy adoption. Runtime startup/unload latency and platform execution remain unmeasured. Some ancillary lifecycle/effect skill files referenced by perf-scan were unavailable in the installed roots; their relevant production code was inspected directly. Proposed remedy/check is unverified. Checkout unchanged; no edits or commits.
Performance review: BLOCKED — two P1 findings at local head e7e142b51b43fe29394e0cecb70ce7b9750d363c.
P1 — Direct host removal still leaves captured legacy relay IDs alive. The introduced process-lived capture at session-desktop-relays.ts:106 now receives workspace-removal invalidation, but desktop-relay-legacy-adoption.ts:28 is reached only through the single/batch workspace-removal helpers. Removing a runtime environment instead calls retireRemovedRuntimeEnvironment → removeWorkspaceSessionHost, which drops the partition directly (runtime-environment-removal-cleanup.ts:36, session-host-partitions.ts:122). Neither operation invalidates the independent capture. Orphaned-runtime reconciliation uses the same direct removal.
Reachable population and lifetime: capture accepts a runtime:<environment> repo with a nested SSH connectionId: getRepoSshConnectionId explicitly accepts that shape, and uniqueSshRepoTabHosts attributes its rows to the runtime partition (execution-host.ts:266–273, desktop-relay-legacy-adoption.ts:97–100). On an upgrade, capture that partition's legacy ssh:…@@… IDs, let its renderer hydration read fail, then remove the environment before a relay apply adopts it. Failed reads are explicitly omitted and marked unread (workspace-session-host-hydration.ts:158–164); completeness excludes unread hosts. With no surviving slice, later saves/unload need not apply that removed host. The capture remains reachable through the once-per-process IPC registration and the new module reference. No later adoption/removal owner is guaranteed to release it.
Source-derived price: four removed unadopted runtime partitions with 75 nested-SSH IDs each retain 300 obsolete tab-to-relay bindings in four records; 40 partitions retain 3,000 bindings in 40 records, until process exit. Persisted partitions are gone. This is additional main-process retention introduced by the capture, bounded by startup input; no claim of unbounded growth, disk leakage, measured heap bytes or latency. It is the retained-entity P1 class. The exact last-project/workspace-removal case from 7042781827 is repaired; direct host teardown remains uncovered.
Remedy/check, proposed and unexecuted: retire the corresponding captured host record at authoritative partition/environment removal, preserving evidence belonging to surviving partitions. Through real capture and direct host removal at 4/40 hosts and 300/3,000 IDs, require zero removed-host capture entries without a subsequent apply or window restart. Keep controls for a surviving unread host, legacy copies in another partition, adoption after row relocation, and main-owned mode. The added removal assertion exercises a workspace helper, so it cannot catch this route.
P1 — Workspace cleanup enumerates every remaining captured relay record even when none of its IDs changed. The new loop's desktop-relay-legacy-adoption.ts:36 calls Object.keys(relays) for every pending host after every nonempty removal census, including hosts where every delete missed. The calls at session-owner-removal.ts:143 and line 167 run synchronously on main.
Production trigger: normal folder deletion calls removeFolderWorkspace → removeWorkspaceSessionOwnerEverywhere → the new cleanup (folder-workspace-operations.ts:276–284). A removed folder with one saved terminal supplies a nonempty tab census. Folder tabs cannot enter this legacy capture, which admits only SSH repo tabs. Nevertheless, deleting that folder enumerates the entire capture of unrelated unadopted SSH repos. Those records can remain pending after failed hydration or fencing, so later folder removals repeat the work. This route is enabled in the shipped window-owned mode. Authoritative listing cleanup was also checked and excluded: its callers require main-owned mode, where capture is empty.
Source-derived price: with H=4 pending hosts and R=300 total captured IDs, one unrelated one-tab folder removal performs four absent-key deletes plus 300 unnecessary key enumerations/array entries solely to ask whether unchanged records became empty. At H=40/R=3,000, it performs 40 deletes plus 3,000 enumerated keys. Twenty such folder removals add 6,000/60,000 key enumerations, with zero captured bindings changed. R and removal count multiply; ordinary session cloning/removal costs predate this addition. This is repeated fleet-sized discovery/allocation on Electron main for an unrelated interaction, hence P1 under this scan's count criteria; no duration threshold is claimed.
Remedy/check, proposed and unexecuted: gate emptiness work on actual membership changes and use maintained counts or an early-exit emptiness check, preserving removal of every legacy partition copy. A production-seam guard at R=300/3,000 should count zero full-record enumerations for unrelated folder removal, and work proportional to named deletions for affected records. Verify final-host removal, duplicate legacy copies, surviving IDs and subsequent adoption. The new one-tab retention assertion checks release only; it does not guard this scan amplification.
Requested earlier P1s
Earlier finding
Disposition at this head
7034145708 #1: whole ownership-map storage leaf; extra topology/publication
Fixed in source. Flat desktopRelayOwnerByTabId fits split depths 2 local / 3 host: a changed owner serializes one scalar leaf at R=300/3,000. Relay-only writes bypass topology. Combined entries/snapshot saves publish once per host.
Fixed in source. Retirement/close compare one supplied key; detach/leaf move compare two. Unchanged/unowned cleanup copies zero owner maps at either R.
7034145708 #3: persisted ownership after workspace/repo removal
Fixed in source.onWorkspaceRemoval: ownerTabKey feeds the legacy/unified tab census. Removing 300/3,000 owner tabs clears those persisted owner entries.
7034431725 #1 and 7034648570 #1: duplicate unrelated reconciliation/publication
Fixed in source. Carried hosts are excluded from the separate send; main applies carried relays before one Store mutation. At C=100/1,000 cached conversation workspaces, the added second combined-save reconciliation is zero.
Fixed in source. Main-owned mode declines the separate protocol and skips capture: zero added separate relay IPCs/reconnect derivations for unchanged saves at 4/40 SSH hosts and 300/3,000 terminals.
7034648570 #2: whole-map equality for one-ID apply delta
Fixed in source. Change discovery uses touched/adopted keys. A warm one-ID delta compares one named key; refused/unchanged writes copy zero output maps. Complete baselines inspect stored keys for required omission semantics.
7042781827: capture outlived last-project/workspace removal before adoption
That removal route is fixed in source. Both workspace helpers now forget their tab census across captured partitions, including unread hosts, leaving zero removed-tab bindings. Findings 1–2 cover the remaining teardown route and the cleanup's new work.
The earlier renderer host-retirement fixes also hold: historical primary/read-source maps and the hydration list do not count as live relay routes; omitted empty acknowledgements are removed. Per-apply main membership is a direct partition lookup, with zero new whole-host inventories at P=40/400 saved partitions. Null patches perform no membership lookup or publication.
Coverage
Read-only review of origin/main...e7e142b51b43fe29394e0cecb70ce7b9750d363c, merge base 77f4a1f023210156e27216da1e593b5ff3889542. Inspected the 47 changed paths and relevant hydration, routing, publication, storage and removal consumers. All detector hits covered:
Surface
Paths, trigger and bounds
publish
session-snapshot-operations.ts, session-bridge.ts: subscriber identity admission → host routing/acknowledgement → carried/separate IPC → main apply → Store/title/layout consumers → scalar storage. Warm unchanged relays send zero relay hosts; one changed binding sends one host/ID. Probe once per document/API identity. Combined saves publish once; standalone relay writes skip topology; null patches publish nothing.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts: attach after a windowless gap compares qualifying PTYs once per affected host, 300/3,000 total; no added PTY inventory or per-output/status trigger. Retirement compares one known key, moves two. Real owner changes produce the required immutable map; no-op ownership cleanup returns its input.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts: two property deletions per existing donor fragment; one owner rewrite pass only when that partition's relay IDs actually rewrite. Legacy capture adds one in-memory O(H+repos+W+T+R) upgrade pass, W=750/7,500 and T,R=300/3,000. Adopted launches skip row attribution. Adoption consumes its host evidence/version. Findings cover pending capture teardown/cleanup. Zero new disk probes, subprocesses or per-ID remote calls.
Six scan questions
Disposition
1. Work before skip gates
Reviewed field identity/probe gates, deltas, lazy parked-tab indexing, touched-key apply and null-patch admission. Empty-key claims index their partition's rows once per apply; conflicting existing IDs avoid that index. Cleanup's missing change gate is finding 2.
2. Ownership multiplication/lifetime
One acknowledgement registry per renderer document/API and one main capture; no new pane-owned client/poll/listener. Finding 1 identifies capture surviving host teardown.
3. Thread/storage
Renderer pays routing/projection/diff; Electron main pays apply, cleanup and synchronous publication consumers. Ownership persists through existing scalar parts and worker authority; existing synchronous fallback remains. No new direct fs/SQLite calls. Findings report counts/retention, without occupancy claims.
4. Growth/progress
Finding 2 scales with remaining startup IDs × removal events. Capture is never replenished. Adoption consumes evidence; processed refusals discard named ended IDs; skipped/unanswered writes preserve recovery evidence. Subscriber admits one save in flight; pending/deferred debt is bounded by session field names, retried on later changes without an autonomous producer.
5. Execution host
Source-reviewed local/SSH/runtime partitions, nested SSH, unread/parked/contested rows, folders, WSL/frozen-source fences, SSH reassignment, paired/older-main fallback and main-owned mode. Added work is JavaScript/IPC/storage: zero new per-relay SSH round trips or platform subprocesses. macOS/Linux/Windows and mobile were not executed.
6. Obsolete work/release
Subscriber disposal removes its timer/listener and stops admission; admitted writes settle for durability. Generations fence late answers; in-flight records release on settlement/invalidation. Unload stages snapshots and relays/owners together, skips legacy attribution and inventories hosts once per checkpoint. Finding 1 is the remaining capture release gap. Added autonomous steady-idle wakeups: 0/s on renderer, main and daemon.
Touched recurring classes: entity state outliving its entity — finding 1; hot-path/global rescans and missing no-op admission — finding 2; duplicate/broad publication — combined writes disprove the earlier amplification; whole-map storage replacement — scalar split leaves disprove it; apply-time whole-map equality/no-op copies — touched-key/null-patch gates disprove it; retry/queue amplification — one subscriber write in flight and fixed field debt; startup rereads/eager imports — in-memory capture and lightweight imports, no new I/O/adapter initialization; idle wakeups — no added periodic producer. No matching new whole-map React selector, per-mounted-pane resource effect, streaming reprocessing or subprocess loop.
Pre-existing scaling remains separate: relevant terminal saves project/route O(W+T); ordinary entry acknowledgement retains historical hydrated hosts; save baselines enumerate session keys; ordinary session publication reconciles C cached conversation workspaces, and a subscribed window-owned layout can reload/clone a W-workspace partition. This span adds R owner scalar slots to required changed output/save-baseline traversal. The findings identify independent obsolete retention and unnecessary cleanup enumeration.
Evidence limits: source-derived counts and inspected, unexecuted assertions. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or live restart/transport checks ran, as requested. Main membership assertions stub Store consumers; renderer assertions use an in-memory main; the new capture-release assertion covers one workspace and bypasses direct host teardown. Runtime startup/unload latency and platform execution remain unmeasured. Ancillary git/terminal/effect scenario files referenced by the installed skill were unavailable; relevant production code was inspected directly. Proposed remedies/checks are unverified. Checkout unchanged; no edits or commits.
Review loop status for 7b94e4791dcfc9db9fa48975ec0a80b9d28105e4.
Design: main owns which writer owns each relay id per partition and changes only the window's keys; the window sends its relay ids per host. A host's relay ids ride with that host's partition write (entries patch or full session:set), so main publishes each save once.
Reviews: twenty rounds of fresh Claude and Codex reviews. Round 20 at this head: Claude READY (no P0/P1/P2), Codex READY (no findings); both confirmed the code equals c9f19523d4cec71109da59218050bfd6ff286297 (round 19's change was reverted, below).
Regression audit: a fresh, blinded Codex audit of the merged result each round. Rounds 5, 6, 9 and 13 each found one must-fix, a second fresh reviewer confirmed each, and each is fixed with a test in this PR. Final audit at 7b94e479: AUDIT: SAFE. It also traced main's retained legacy-relay capture: RETENTION: MEMORY-ONLY (no stale relay is persisted or reconnected after restart, no live relay lost).
Fixed since the last status: removal evidence kept for unanswered, refused and replaced writes, and for incomplete hosts a save leaves out while they still have a live owner; full saves carry each host's relay ids with its snapshot; main visits only a write's ids and checks only that partition's existence; refused retries no longer grow the removal list.
Perf-scan: fresh scan at this head: CLEAN (comment 7043899275). Every earlier finding is fixed, except two on main's one-time legacy-relay capture (comments 7042781827 and 7043567519), which the scan lists as accepted and non-blocking. Accepted by Perf bot as perf owner: the retention is KBs, first launch after upgrade only, and only for hosts never written before their removal. The round-19 attempt to release it on removal ran before commit and dropped ids still stored in other partitions, so it was reverted.
Reviewed and accepted (not regressions versus main): listed under Known limits in the PR body (main-owned layout switch, unowned cross-partition leftovers, a main-written relay that ends before handover, an offline runtime host outside the catalog winning an older build's duplicate rows, and the capture retention above).
Checks:
Omarchy check:changed on 7b94e4791dcfc9db9fa48975ec0a80b9d28105e4: PASS (typecheck, lint, ratchets, unit tests).
Each new test fails when its fix is reverted (checked), including the perf contracts listed in the PR body.
QA: qa=tests. Session persistence and IPC only; no UI change.
Measurement: no runtime benchmark. Per-save relay work is bounded by the hosts and ids that changed (perf contracts), main applies a write in O(named ids) with one targeted partition check, and full saves publish once per host; perf-scan traced every flagged surface at 300/3,000 relays and 4/40 hosts.
Performance review: CLEAN — no blocking P0/P1 findings at local head 7b94e4791dcfc9db9fa48975ec0a80b9d28105e4. The bounded startup legacy-capture retention is accepted/non-blocking, and is still present; it is not being reported as fixed.
Reviewed origin/main...7b94e4791dcfc9db9fa48975ec0a80b9d28105e4, merge base 77f4a1f023210156e27216da1e593b5ff3889542: all 45 changed paths, their production callers, publication/storage consumers, hydration and removal paths. The local tree also has no diff against c9f19523d4cec71109da59218050bfd6ff286297. Evidence below is source-derived operation/retention counts and inspected assertions, without runtime measurements.
Earlier P1 rechecks
Earlier comment / finding
Disposition at this head
7034145708 #1: whole ownership-map storage leaf and duplicate topology/publication
Fixed.desktopRelayOwnerByTabId is a flat tab-to-scalar map. The existing split depths, 2 local / 3 host, persist one changed owner as one scalar leaf at R=300/3,000. Relay-only commits skip row ordering. Combined entries/full saves commit once per host.
7034145708 #2: whole-relay comparison on close/move
Fixed. Retirement/pane-close supply one known tab ID; detach/leaf-move supply two. changedRelayKeys compares only those keys. forgetDesktopRelayKeys checks membership before copying: unchanged/unowned cleanup copies zero owner maps at both R populations. Real owned changes still construct the required immutable output.
Fixed. Ownership uses onWorkspaceRemoval: ownerTabKey; the existing legacy/unified terminal census deletes owners together with relay bindings. Removing 300/3,000 owner tabs deletes those persisted owner entries, including last-project removal with a retained partition.
7034431725 #1 and 7034648570 #1: second unrelated title/layout reconciliation for a combined save
Fixed. The renderer carries each host's changed relays with its entries/snapshot and excludes it from the separate send. Main applies them before one Store mutation: session.ts:107, session.ts:133. At C=100/1,000 cached conversation workspaces, the additional second combined-save reconciliation is zero. Necessary standalone relay changes still publish.
7034431725 #2: main-owned layout adds unchanged-relay global reconnect scans
Fixed. Main-owned mode declines the separate protocol and skips legacy capture. For 4/40 SSH hosts and 300/3,000 terminals, title saves add zero separate relay IPCs/reconnect derivations. Existing ordinary-save work remains.
7034648570 #2: whole-map equality after a one-ID delta
Fixed.desktop-relay-ownership.ts:64 discovers changes from touched/adopted keys; lines 100–103 compare only proposed changes. A warm one-ID delta checks one named key at R=300/3,000, with zero whole-map equality passes. Refused/unchanged input copies no output maps. Complete baselines still inspect stored keys for required omission semantics.
7042781827 #1: capture survives project/workspace removal before adoption
Still present; accepted/non-blocking, for the bounded memory-only reasons below. The attempted invalidation was reverted. Persisted/session ownership cleanup remains fixed.
7043567519 #1: capture survives direct runtime/partition removal
Still present; accepted/non-blocking, under the same bounded memory-only limit. Direct removal deletes the partition, while the independent capture can remain until process exit.
7043567519 #2: every removal enumerates unrelated captured relay maps
Removed by the revert. Workspace-removal helpers no longer call capture cleanup; there is no added capture enumeration on folder/project removal. With 300/3,000 pending captured IDs, 20 unrelated folder removals add zero capture-key enumerations.
Accepted legacy-capture limit
desktop-relay-legacy-adoption.ts:27 creates independent records of adoptable startup IDs once per main process. Host adoption/version observation releases them; project/workspace removal and direct runtime/partition removal do not. Failed renderer hydration can omit a host indefinitely, so an unused captured record can remain reachable through registered handlers until exit.
The bound is the captured startup population: four removed hosts with 75 IDs each retain at most those 300 entries; 40 retain 3,000 entries. Removal/re-add cycles never replenish the capture, and omitted hosts receive no recurring capture scan. At an illustrative 100 ASCII bytes of tab/relay text per entry, that is 30/300 KB of logical ID text; this is a sizing example, not a heap measurement, and excludes engine overhead/string sharing. No scrollback, transcript, session object, transport or timer is retained by these records.
I traced removal through the workspace/repo census and direct runtime-host teardown, failed hydration, and subsequent apply/re-add behavior. Adoption only proposes ownership when the currently stored ID still equals the captured ID (desktop-relay-ownership.ts:53); it never inserts captured IDs into relay state. A deleted/replaced ID therefore cannot be revived, persisted, reconnected or removed through that stale evidence. Existing copies in another partition still need their provenance, which explains the correctness risk of broad early invalidation. The PR records the perf owner's acceptance. My source review agrees: this finite migration allocation, with no recurring producer or retained live resource, is a documented non-blocking limit rather than a merge-blocking perf regression. The retirement case disappears on restart because removed IDs are no longer persisted; unadopted surviving hosts retain their migration evidence.
Every detected surface
Surface
Paths, production trigger, owner and bounds
publish
session-snapshot-operations.ts, session-bridge.ts, plus renderer subscriber/routing/acknowledgement, main handlers and durable storage. Relevant session changes enter the existing 150 ms debounce; unrelated store changes stop at the identity gate. One capability probe per document/API identity. After acceptance, an unchanged relay population sends zero relay hosts; one binding change sends one host with one changed/removed ID. Combined saves publish once per host; relay-only writes skip topology; null patches publish nothing. Main checks partition membership by direct lookup, never a fleet inventory per apply: H=5/41 changed hosts with independently P=40/400 saved partitions require at most H targeted membership checks.
hot-path
session-graph-promotion.ts, mobile-session-terminal-persistence-retirement.ts, with pane/tab close and move callers. Desktop attachment after a windowless gap adds comparisons for qualifying PTYs once per affected host: 300/3,000 total qualifying PTYs add that many key comparisons, with no new inventory or PTY-output/status trigger. Retirement compares one known key; moves two. Changed ownership constructs one immutable host record; unchanged/unowned cleanup returns the input. Mobile-requested durable saves carry relays with snapshots.
startup-migration
orcad-source-workspace-session-layout.ts, ssh-target-id-migration.ts, plus legacy capture. Migration drops two ownership properties per existing donor fragment without another traversal. SSH reassignment copies/visits the owner record only when that partition's relay IDs actually rewrite, preserving ownership of the rewritten IDs; zero added SSH requests/subprocesses. Main capture is one in-memory O(H+repos+W+T+R) attribution pass, with W=750/7,500 and T,R=300/3,000. Already-adopted launches skip row attribution. Later batches consult only named hosts, consume their evidence/version, and never repeat the fleet attribution pass.
Six scan questions
Question
Disposition
1. Work before skip gates
Reviewed identity/probe gates, host narrowing, lazy parked-row indexing, touched-key apply and null-patch admission. Renderer comparison visits current relay records once per relevant save to discover the required delta: 300/3,000 entries, then zero relay payload for unchanged input. A new empty-key claim lazily indexes its partition's tab rows once per apply to prove membership; conflicts with an existing ID avoid that index.
2. Ownership multiplicity
One acknowledgement registry per renderer document/API and one startup capture per main process. No per-pane client/poll/subscription. In-flight evidence releases on settlement/invalidation; generations reject obsolete answers. Omitted empty/retired acknowledgements are pruned using live routes, excluding historical primary/read-source and hydration lists. Startup failed-read markers are bounded by that hydration's hosts. Accepted capture retention is described above.
3. Thread/storage
Renderer pays projection/routing/diff. Electron main pays validation/apply, immutable changed-map construction and synchronous listeners. A real owner update can copy/enumerate R=300/3,000 scalar slots; this is the new authoritative output representation, not an extra equality pass. Durable values split into individual scalar parts through the existing persistence worker authority; existing synchronous fallback remains. No new direct filesystem/SQLite call or per-host storage replica fan-out.
4. Growth/progress
Capture never replenishes. Adoption consumes host evidence; processed refusals discard IDs main has removed; skipped/unanswered writes retain removal evidence. Subscriber admits one save at a time; pending/deferred debt is bounded by session field names and retries on later state changes. No autonomous refusal retry loop. Full explicit lifecycle saves can overlap as before; their added acknowledgement evidence settles with those writes.
5. Execution host
Source-reviewed local/SSH/runtime partitions, nested SSH, unread/parked/contested rows, folder workspaces, WSL/frozen-source fences, SSH reassignment, paired/older-main fallback and main-owned mode. Added work is JavaScript/IPC/persistence with zero per-relay SSH round trips or platform subprocesses. macOS/Linux/Windows and mobile behavior were inspected, not executed.
6. Obsolete work/release
Subscriber disposal removes its timer/listener and stops admission; admitted durable work settles. Replacement/unload fences late acknowledgements and stages relays/owners with snapshots. Unload skips legacy attribution and builds one host inventory per checkpoint, rather than per host. Persisted ownership leaves with its tabs/workspace/partition. Added autonomous steady-idle wakeups are 0/s in renderer, main and daemon by source inspection. Existing debounce, capture and shutdown-deadline behavior remains.
Touched recurring classes: whole-map storage rewrite — disproved by scalar splitting; duplicate/broad publication — disproved for combined saves by carried-write composition; hot-path rescans/no-op allocation — disproved by known-key/touched-key admission and lazy copying; unchanged publication — acknowledgement/null-patch gates suppress it; per-entity retention — persisted owners and renderer retirement clean up, with the explicit accepted startup-capture exception; global discovery/re-reading unchanged input — targeted host membership and one-time in-memory attribution, no new filesystem reads; retry/queue fan-out — serialized subscriber, fixed field debt and no new autonomous producer; startup imports/idle wakeups — no heavy adapter import or new periodic producer.
Pre-existing amplification remains separate: relevant terminal saves project/route O(W+T); save baselines enumerate session keys; ordinary publication reconciles C cached conversation workspaces, and a subscribed window-owned layout may clone/reload a W-workspace partition. At W=750/7,500 and C=100/1,000 these remain fleet-sized operations per ordinary save. The span adds ownership scalar slots to necessary immutable output/save-baseline traversal, but no second combined-save publication. No new history/refs/remotes scan, streaming reprocessing, broad React selector or per-mounted-pane resource effect was found.
Validation limits: source review only, as requested. No tests, typechecks, builds, app launches, timing/CPU/heap measurements or live restart/transport checks ran. Inspected performance assertions cover relay wire narrowing/carriage, absence of per-apply host inventories and an incomplete refused write without map enumeration. Renderer fixtures bypass real Store consumers/storage; main membership is stubbed; these are not executed end-to-end performance evidence. Startup/unload latency, native-platform execution and actual heap overhead remain unmeasured. The referenced ancillary terminal scenario skill was unavailable; relevant production lifecycle code was inspected directly. Checkout unchanged; no edits or commits.
…aces once (#45998)
A save carrying relay ids while main's relay support was still unknown returned a localWrite promise with no handler, so a failed local save showed as both a persist warning and an unhandled rejection. It now settles like the direct path, reporting once through written.
Tracked in STA-16736 / #45291
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
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.
Problem
When the last SSH terminal session on a host ended, the session save never told main, so main kept the ended relay ids. If Orca then quit without its clean shutdown (crash, force quit, hang), the next launch tried to reattach those ended sessions.
The window saves relay ids per host partition, and a host whose last relay ended gets no save at all. Simply sending an empty map isn't safe: main writes relay ids for the window's tabs too (pane moves, windowless attach, mobile terminals), and older builds left copies in other partitions, so an empty or whole-field write could erase relay ids that still work.
Change
Main records which relay ids the desktop window wrote, per partition, and the window's relay ids now go through one operation that changes only those.
desktopRelayOwnerByTabIdstores one row per tab, like the relay ids, so a one-tab change rewrites one row and workspace removal drops its tabs' entries.desktopRelayAdoptionVersionrecords the legacy adoption below. The relay apply writes only these fields, skips terminal row ordering, and (for a relay-only write) tells session listeners only about the tabs whose relay ids changed. Window saves can't write them (window-save-relay-ownership.ts, like main-owned sleep records).shared/workspace-session/desktop-relay-ownership.ts):session:desktop-relays-versionanswers (an older main, the paired web client, or the main-owned layout switch keep relay ids in ordinary saves as today).session:patch-entriescall. Main applies the entries, then the relay ids by ownership against the result, and publishes once.session:set: main applies the snapshot, then the relay ids by ownership, in one write.session:apply-desktop-relaysin the same turn.activeWorktreeIdsOnShutdownon an SSH partition is unchanged by this.Evidence
Each fails on main:
desktop-relay-writes.test.ts: the last SSH relay ends and the partition a crash restarts from no longer holds it, while another tab's relay main saved stays; a fenced partition clears after it opens again; a host's relay ids are saved before its worktree listing loads, and for a repo that names its SSH host only by execution host id.desktop-relay-ownership.test.ts:desktop-relay-legacy-adoption.test.ts: only SSH repo tabs' ids are adopted (folder and unknown tabs are not), including an older build's copy in another partition.desktop-relay-writes.test.tsalso: a relay that ended while its save was unanswered is named at quit; one that ended during a save that left its incomplete host out is named when the host next goes; an ended relay main stored from a partly refused write is cleared.desktop-relay-writes.performance.test.ts: after the first save, a tab rename sends no relay host, and one ended relay sends one host with one removed id, carried with that host's entries patch; an ended relay on a host whose other tab main keeps refusing is named once; a full save carries its changed relay with the host's snapshot (no separate relay write).desktop-relay-ownership.performance.test.ts: an incomplete host's write reads none of the partition's other stored relay ids.session-desktop-relays.performance.test.ts: applying relay ids never lists the saved partitions.Replaces #45051 (tracked there).