Skip to content

fix(remote): gate empty session inventory on host authority - #16546

Merged
Jinwoo-H merged 10 commits into
mainfrom
aug25-sta5377-host-inventory-verdict
Aug 27, 2026
Merged

Jinwoo-H merged 10 commits into
mainfrom
aug25-sta5377-host-inventory-verdict

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1475 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1459
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​570 $\color{#cf222e}{\Huge{\mathbf{−}}}$​127 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​443

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 === 0 snapshot from releasing parked resume sweeps and spawning a duplicate agent writer.

Reproduction and oracle

  • Deterministic paired-host oracle keeps one live Codex PTY/daemon session, bumps the connection/runtime generation, and delivers an empty inventory before renderer publication.
  • Two independent oracles are asserted: host session/process/PID and writer identity, plus client mirror hydration/resume dispatch.
  • Affected baseline/unconditional-empty behavior: 1 resume dispatch, 2 live session IDs, 2 PIDs, and 2 independent writers.
  • Candidate behavior: 0 resume dispatch, mirror remains parked/unverifiable, 1 PID, and 1 writer. An authoritative empty settles with exactly one resume dispatch and zero liveness probes.
  • Headless orca serve parity 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

Client Host Result
New New Waits for authoritative publication; authoritative empty/non-empty settles safely. A failed census (e.g. a configured-but-disconnected SSH host) degrades to the best-effort list with the authoritative label omitted — empty results then stay behind the client liveness probe.
Old New Host waits for authority before answering; census failure serves the same best-effort list. No authoritative flag is leaked to non-negotiating clients.
New Old No new field/opcode required. A scoped-incomplete census stays unverifiable. A scope-less legacy empty keeps its pre-authority best-effort settle so outdated hosts retain agent auto-resume (main's behavior; those hosts keep main's pre-existing narrow duplicate-writer window until they update).
Old Old Existing best-effort path is preserved.

Transport errors, no-response, omitted-host scope, and unpublished/unknown empty inventories remain unverifiable. A complete authoritative empty inventory settles.

Implementation

  • Adds an optional capability-gated authoritative inventory verdict (session-tabs.authoritative-inventory.v1); no new opcode.
  • Publication is fenced by renderer graph epoch, connection generation, pairing revision, tracking generation, and PTY census completeness.
  • Census failure only invalidates the emptiness verdict, never the list: every client receives the unlabeled best-effort snapshots and capable clients gate empty results behind the liveness probe, which is independently unverifiable for the same omitted-host condition.
  • Adds cancellation, resync, secondary-window, mixed-version, frame-ordering, and two-process/writer regression coverage.

Review follow-ups applied

An independent review pass produced these fixes (all in-branch):

  • Census hard-failure for capability-negotiating clients replaced with the unlabeled best-effort degrade above (previously a permanent terminal_liveness_unavailable blanked the list for any host with a configured-but-unconnected SSH repo).
  • Settle fences read the tracking generation through the trimming accessor, removing a trim asymmetry that could permanently park a mirror.
  • Abort-listener leak on the synchronous-cleanup subscribe path removed; single-key pending-refresh map collapsed back to one field; projection helper deduplicated.
  • Daemon oracle now also pins the authoritative-empty settle (1 dispatch, 0 probes); the ORCA_E2E_DISABLE_AUTHORITATIVE_SESSION_TABS_INVENTORY override 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

  • Focused inventory/RPC/renderer/daemon/oracle suites: green (1330 tests across the 10 affected files).
  • pnpm tc: green. Changed-code quality, type-aware oxlint, React Doctor: 0 findings.
  • Reliability gate manifest check: 97/97. git diff --check: clean.

No production Relay changes, deployments, merges, or Linear updates were made.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 stru… Reformat the description using the required template headings. Add a Fixes #... issue link, provide visual proof or state N/A with a reason, complete the Testing and Checklist sections, and address AI Disclosure, Review, Agent skill ups…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: gating empty remote session inventory on host authority.
Full details: Docstring Coverage

Explanation

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 check

Explanation

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 Fixes #... issue link, provide visual proof or state N/A with a reason, complete the Testing and Checklist sections, and address AI Disclosure, Review, Agent skill upstream boundary, and Notes.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Clarify 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5479bd9 and d4e9f81.

📒 Files selected for processing (21)
  • config/reliability-gates.jsonc
  • src/main/daemon/terminal-host-agent-session.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/rpc/methods/session-tabs.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/session-tabs-inventory-publication.test.ts
  • src/renderer/src/runtime/host-live-terminal-probe.ts
  • src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts
  • src/renderer/src/runtime/host-session-mirror-frame-ordering-harness.ts
  • src/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsx
  • src/renderer/src/runtime/host-session-mirror-settle-receipt-frames.test.tsx
  • src/renderer/src/runtime/web-runtime-session.test.ts
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/protocol-version.ts
  • src/shared/remote-runtime-client-capabilities.ts
  • tests/e2e/paired-remote-terminal-host-restart-background-sync.spec.ts
  • tests/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.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

7261-7385: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a churn regression test and bound retries. listAllMobileSessionTabsInventory can remain pending while each awaited collection observes a new publication epoch. Add coverage for repeated epoch changes and assert that sessionTabsInventoryWaiters is 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

📥 Commits

Reviewing files that changed from the base of the PR and between b57b812 and e5440a8.

📒 Files selected for processing (22)
  • config/reliability-gates.jsonc
  • src/main/daemon/terminal-host-agent-session.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/rpc/methods/session-tabs.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/session-tabs-inventory-publication.test.ts
  • src/renderer/src/hooks/ipc-events/direct-ssh-hydration-fanout.test.ts
  • src/renderer/src/runtime/host-live-terminal-probe.ts
  • src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts
  • src/renderer/src/runtime/host-session-mirror-frame-ordering-harness.ts
  • src/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsx
  • src/renderer/src/runtime/host-session-mirror-settle-receipt-frames.test.tsx
  • src/renderer/src/runtime/web-runtime-session.test.ts
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/protocol-version.ts
  • src/shared/remote-runtime-client-capabilities.ts
  • tests/e2e/paired-remote-terminal-host-restart-background-sync.spec.ts
  • tests/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.

Comment thread src/main/runtime/orca-runtime.ts Resolved
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

9122-9145: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Document the coalescing invariant for targeted callers.

refreshMobileSessionPtyInventory now joins targeted and fleet-wide refreshes under one promise keyed by null. When a targeted call joins an in-flight fleet-wide refresh, it receives the fleet-wide allLivePtyIds, not a set scoped to its own targetWorktreeId. This is correct today only because every caller that passes an explicit targetWorktreeId to refreshMobileSessionPtyRecords discards the returned Set<string> and relies only on the side effect of updating ptysById.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 80fd05a and 0d5017b.

📒 Files selected for processing (8)
  • config/reliability-gates.jsonc
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory-rpc.test.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/session-tabs-inventory-publication.test.ts
  • src/renderer/src/runtime/host-live-terminal-probe.ts
  • src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts
  • tests/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.

Comment on lines +54 to +56
if (signal?.aborted) {
throw new Error('client_disconnected')
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 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.
@Jinwoo-H
Jinwoo-H merged commit 0f522c3 into main Aug 27, 2026
106 of 107 checks passed
@Jinwoo-H
Jinwoo-H deleted the aug25-sta5377-host-inventory-verdict branch August 27, 2026 05:30
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
nwparker added a commit that referenced this pull request Sep 2, 2026
…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
nwparker added a commit that referenced this pull request Sep 2, 2026
…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.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
…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
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
…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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant