Repository navigation
fix(remote): gate empty session inventory on host authority - #16546
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe runtime now publishes authoritative session-tab inventories with capability negotiation, publication epochs, PTY liveness validation, cancellation, and recovery handling. RPC listing and subscription paths use the shared inventory implementation. Renderer synchronization carries authority and connection, pairing, and tracking generations to reject stale results. Probing distinguishes live, empty, and unverifiable legacy inventories. Tests cover publication, hydration, daemon lifecycle, PTY restoration, and reliability gates. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 38 files. (2 skipped: 1 unsupported, 1 too large.) Full details: Description checkExplanation The description provides a detailed summary, rationale, behavior matrix, implementation details, linked issue identifier, and validation results. However, it does not follow the required template structure and omits several required sections, including Visual Proof, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Reformat the description using the required template headings. Add a ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts (1)
134-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClarify the intent of this test; it passes while asserting the undesired outcome.
The title says "goes red", but the assertions match current behavior: a scoped zero-terminal census yields
none, the mirror hydrates, the resume runs, and a second writer is spawned. The test is green today and locks in the duplicate-writer result. Rename it to state that it records the legacy scoped-empty behavior, or invert it to assert the desired single-writer outcome so a future fix does not fail it for the wrong reason.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d3b5d5e7-71dd-4105-803c-02349a029a5f
📒 Files selected for processing (21)
config/reliability-gates.jsoncsrc/main/daemon/terminal-host-agent-session.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.tssrc/main/runtime/rpc/methods/session-tabs-inventory.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/runtime/session-tabs-inventory-publication.test.tssrc/renderer/src/runtime/host-live-terminal-probe.tssrc/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.tssrc/renderer/src/runtime/host-session-mirror-frame-ordering-harness.tssrc/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsxsrc/renderer/src/runtime/host-session-mirror-settle-receipt-frames.test.tsxsrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/runtime-status.tssrc/shared/protocol-version.tssrc/shared/remote-runtime-client-capabilities.tstests/e2e/paired-remote-terminal-host-restart-background-sync.spec.tstests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
7261-7385: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a churn regression test and bound retries.
listAllMobileSessionTabsInventorycan remain pending while each awaited collection observes a new publication epoch. Add coverage for repeated epoch changes and assert thatsessionTabsInventoryWaitersis empty after resolution and cancellation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b9e29bd4-dc26-4230-a5e2-cd15c37a9dd0
📒 Files selected for processing (22)
config/reliability-gates.jsoncsrc/main/daemon/terminal-host-agent-session.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.tssrc/main/runtime/rpc/methods/session-tabs-inventory.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/runtime/session-tabs-inventory-publication.test.tssrc/renderer/src/hooks/ipc-events/direct-ssh-hydration-fanout.test.tssrc/renderer/src/runtime/host-live-terminal-probe.tssrc/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.tssrc/renderer/src/runtime/host-session-mirror-frame-ordering-harness.tssrc/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsxsrc/renderer/src/runtime/host-session-mirror-settle-receipt-frames.test.tsxsrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/runtime-status.tssrc/shared/protocol-version.tssrc/shared/remote-runtime-client-capabilities.tstests/e2e/paired-remote-terminal-host-restart-background-sync.spec.tstests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts
🚧 Files skipped from review as they are similar to previous changes (20)
- src/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsx
- src/renderer/src/runtime/web-runtime-session.test.ts
- src/main/runtime/rpc/methods/session-tabs.test.ts
- src/renderer/src/runtime/host-session-mirror-frame-ordering-harness.ts
- src/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.ts
- src/renderer/src/store/slices/runtime-status.ts
- src/renderer/src/runtime/web-runtime-session.ts
- tests/e2e/paired-remote-terminal-host-restart-background-sync.spec.ts
- src/shared/remote-runtime-client-capabilities.ts
- tests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts
- config/reliability-gates.jsonc
- src/renderer/src/runtime/host-session-mirror-settle-receipt-frames.test.tsx
- src/shared/protocol-version.ts
- src/main/runtime/session-tabs-inventory-publication.test.ts
- src/renderer/src/runtime/host-live-terminal-probe.ts
- src/main/runtime/rpc/methods/session-tabs-inventory.ts
- src/main/daemon/terminal-host-agent-session.test.ts
- src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts
- src/renderer/src/runtime/web-session-tabs-sync.ts
- src/main/runtime/rpc/methods/session-tabs.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Pre-hostScope hosts (before #14973) cannot prove emptiness, so parking them forever would strand agent auto-resume on every truly-empty legacy host. Keep main's behavior for them: a scope-less empty probe result settles the mirror. New hosts always publish hostScope, so the authoritative-inventory fix for STA-5377 is unaffected; outdated hosts keep main's existing narrow duplicate-writer window until they update.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
9122-9145: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winDocument the coalescing invariant for targeted callers.
refreshMobileSessionPtyInventorynow joins targeted and fleet-wide refreshes under one promise keyed bynull. When a targeted call joins an in-flight fleet-wide refresh, it receives the fleet-wideallLivePtyIds, not a set scoped to its owntargetWorktreeId. This is correct today only because every caller that passes an explicittargetWorktreeIdtorefreshMobileSessionPtyRecordsdiscards the returnedSet<string>and relies only on the side effect of updatingptysById.Add a short comment noting that a future caller must not consume the returned set when passing a
targetWorktreeId, or add an assertion that rejects a caller expecting scoped results while sharing the coalesced promise. This prevents a future scoped-consumer from silently receiving unscoped results.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cd13afbb-15b8-41f4-af1a-12215ba375f3
📒 Files selected for processing (8)
config/reliability-gates.jsoncsrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.tssrc/main/runtime/rpc/methods/session-tabs-inventory.tssrc/main/runtime/session-tabs-inventory-publication.test.tssrc/renderer/src/runtime/host-live-terminal-probe.tssrc/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.tstests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (signal?.aborted) { | ||
| throw new Error('client_disconnected') | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Reject aborted legacy requests before collection.
This check runs after collectInventory(). If authority is unsupported, an already-aborted request still starts listAllMobileSessionTabs(). Check signal.aborted before collectInventory() and add a legacy-runtime regression test.
Proposed fix
export async function listSessionTabsInventory(context: RpcContext): Promise<SessionTabsInventory> {
const { runtime, pairedDeviceId, signal } = context
+ if (signal?.aborted) {
+ throw new Error('client_disconnected')
+ }
const collectInventory = async (): Promise<SessionTabsInventory> =>Review follow-ups from the Opus pass on PR #16546: - A failed PTY census (e.g. one configured-but-disconnected SSH host, or a raced inventory generation) no longer hard-fails session.tabs.* for capability-negotiating clients. Every client now gets the best-effort list with the authoritative label omitted; empty results stay behind the client liveness probe, which is independently unverifiable for the same omitted-host condition. Census failure only ever invalidates the emptiness verdict, never the list itself. - Fence trim asymmetry: settle fences and batch capture now read the tracking generation through the trimming accessor, so an untrimmed environment id can no longer permanently park a healthy mirror. - Remove an abort-listener leak on the synchronous-cleanup subscribe path. - Collapse the single-key pending-refresh map back to one aggregate field. - Reuse projectSessionTabsForClient from the inventory module instead of re-inlining the projection. - Coverage: authoritative empty settles with zero probes in the daemon oracle; the e2e disable override reports no authoritative support.
Follow-up to the second review round (N1): the RPC-layer fallback re-collected the entire inventory after a census failure, and the fresh aggregate scan bumped the controller inventory generation — invalidating concurrent scans from other clients and running the renderer-owned PTY restore pass twice per degraded request. The runtime now settles the scan it already collected: a complete census labels it authoritative, an incomplete one returns the same snapshots unlabeled. One scan per request, no error-message string matching, no generation churn. The RPC layer is a straight passthrough again.
CI regression from the single-scan degrade: during a paired host relaunch, concurrent probes invalidate the initial scan's PTY census, so that scan also could not restore preserved daemon-backed tabs — serving its snapshots handed clients a list missing the surviving PTY, and the paired-restart background-sync spec went red at head. Retrying the collection once after the race restores the pre-degrade freshness; the retry runs outside the epoch fence and therefore never claims authority, and a still-incomplete retry stays an unlabeled best-effort list.
…g destruction (#17981) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror #11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (#16414, #16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from #13621 that blocked this were all written before the `authoritative` label existed (#13621 landed 2026-08-11; the capability landed 2026-08-26 in #16546). #13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs #11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock #15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs #15317
…rifiable, not idle (#18012) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror #11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (#16414, #16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from #13621 that blocked this were all written before the `authoritative` label existed (#13621 landed 2026-08-11; the capability landed 2026-08-26 in #16546). #13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs #11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock #15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs #15317 * fix(sidebar): stop a stale agent row claiming the pane is empty A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged. * fix(agent-status): decay a mirrored remote row on the replica's own clock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget.
…g destruction (stablyai#17981) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317 Mirror-Of: 4e35e05
…rifiable, not idle (stablyai#18012) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317 * fix(sidebar): stop a stale agent row claiming the pane is empty A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged. * fix(agent-status): decay a mirrored remote row on the replica's own clock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget. Mirror-Of: 266b2ea
…g destruction (stablyai#17981) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317
…rifiable, not idle (stablyai#18012) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317 * fix(sidebar): stop a stale agent row claiming the pane is empty A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged. * fix(agent-status): decay a mirrored remote row on the replica's own clock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget.
Summary
Fixes STA-5377 by making an empty session-tab mirror settle only after the host has published the current renderer graph and the complete PTY census is authoritative. This preserves truly empty hosts while preventing an unpublished
0 === 0snapshot from releasing parked resume sweeps and spawning a duplicate agent writer.Reproduction and oracle
orca serveparity passed. The final headed paired reconnect run was blocked three times before the STA-5377 assertion by pane transport recovery (connecting/null); no headed failure is claimed.Behavior matrix
Transport errors, no-response, omitted-host scope, and unpublished/unknown empty inventories remain unverifiable. A complete authoritative empty inventory settles.
Implementation
session-tabs.authoritative-inventory.v1); no new opcode.Review follow-ups applied
An independent review pass produced these fixes (all in-branch):
terminal_liveness_unavailableblanked the list for any host with a configured-but-unconnected SSH repo).ORCA_E2E_DISABLE_AUTHORITATIVE_SESSION_TABS_INVENTORYoverride has a negative-control test.Deferred follow-ups (not blockers): derive the client connection-generation fence from a single source instead of two co-maintained counters; a user-visible "cannot verify host sessions" state with a manual resume affordance for indefinitely-unverifiable environments; end-to-end gate coverage that drives the host authority machinery and client settle in one harness.
Validation
pnpm tc: green. Changed-code quality, type-aware oxlint, React Doctor: 0 findings.git diff --check: clean.No production Relay changes, deployments, merges, or Linear updates were made.