Skip to content

fix(agent-status): report a stale pane that still holds a PTY as unverifiable, not idle - #18012

Merged
nwparker merged 5 commits into
mainfrom
fix/unverified-agent-status
Sep 2, 2026
Merged

nwparker merged 5 commits into
mainfrom
fix/unverified-agent-status

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​387 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​374
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​351 $\color{#cf222e}{\Huge{\mathbf{−}}}$​145 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​206

Stacked on #17981. Two commits: the decay destination, and the mirrored-remote clock skew.

Why this exists

#17981 made the 30-minute agent-status staleness window actually fire (it had been restamped on every reconnect, so it never elapsed). Now that it fires, where it decays to matters — and the destination was wrong.

worktree-agent-rows.ts decayed to 'idle', and smart-sort defines that bucket as "no live entry, stale entry, interrupted done, or an aged-out completion." So a pane that is stale but still holds a live PTY was bucketed identically to a pane with no agent at all. It never claimed finished — but it asserted "nothing is happening here" on zero evidence.

Commit 1 — split the decay destination

New resolveDecayedAgentRowState(entry, hasLivePty): !isFresh && tabHasLivePty → unverifiable; otherwise idle, exactly as before.

Rendered in the observer's voice with elapsed time — an amber CircleDashed (not the done check, not the working spinner) and "No update in 34m", measured from agentStatusEvidenceObservedAt so a relay replay cannot reset it. The elapsed time is the point: it lets a user apply knowledge Orca doesn't have, like knowing they started a 40-minute build.

Smart-attention gains class 4 (unverifiable) between working (3) and idle (now 5), ordered by last observation so the least-silent pane ranks first.

Naming deviation, flagged: I asked for unverified; the implementation used unverifiable, because docs/reference/ssh-execution-boundary.md fixes the vocabulary as live/unverifiable/exited and says "do not introduce synonyms" — and unverifiable is already the word in UnstoppedPtyVerdict, HostLiveTerminalProbeVerdict, TerminalStreamEndVerdict, and pty-liveness-verdict. That is the right call and I was wrong; a one-token rename if anyone disagrees.

Two deliberate narrowings:

  • restoredUnconfirmed rows stay idle — stale by construction rather than by elapsed silence, and their last evidence predates a process boundary, so there is no honest gap to report. Including them would have flipped a large population of rows on every app start.
  • Nothing crosses a wire. DashboardCardDotState is validated against a fixed allowlist and read by pop-outs, so it still publishes idle. Mobile derives its own decay from RuntimeWorktreeAgentRow, which carries no liveness signal at all, so unverifiable is underivable there without a Rule 1 addition. Rule 3 satisfied by construction.

Commit 2 — the mirrored-remote clock skew

agent-status-observation.ts documented this and left it unfixed: for a mirrored remote row, updatedAt is the host's clock, and freshness computed rendererNow − hostClock. So on the paired-runtime path the effective window was 30 minutes ± host clock skew — tuning the constant was meaningless there. (The SSH relay path is unaffected: its envelope carries no timestamp and ingestRemote stamps on client receipt.)

Chose the local receipt stamp. A new replica-local mirroredEvidenceReceivedAt is stamped when the authority's observation clock advances and carried across an exact repaint, so both sides of the subtraction come from one machine. The accessor is split so the distinction is nameable: agentStatusAuthorityObservedAt (host clock, for cross-row arbitration) vs agentStatusEvidenceObservedAt (reader clock, for decay).

Rejected the alternative — carrying the authority's freshness verdict — and there is a test asserting against it: a verdict is computed at publish time and cannot age between snapshots, so the moment the host stops publishing (the loss-of-contact case the window exists for) the replica would hold fresh forever. It would also still need the receipt stamp as the mixed-version fallback: two mechanisms for one rule.

A test that was passing for the wrong reason

smart-sort.test.ts's "palette ranks blocked above working" used fixed-epoch 2026-03-27 stamps against a live Date.now(), so both entries were months stale and the assertion passed on alphabetical fallback — never on the class layer it claims to pin. Switched to a live clock so it tests its stated intent.

That is the eighth test in this sweep found green while encoding something other than its stated claim.

User-facing regressions

None expected. AGENT_STATUS_STALE_AFTER_MS is untouched at 30 minutes. Negative controls, all passing: a live pane with fresh events still reads working; a pane with no live PTY still reads idle; a done pane is unaffected including interrupted; the dot is never done and never working.

One genuine improvement: the freshness scheduler now arms its timer off the receipt clock for mirrored rows, so on a replica the timer fires at the right wall time for the first time.

Testing

Commit 1 before: Tests 6 failed | 5 passed (11) — expected 'idle' to be 'unverifiable', expected 4 to be less than 4, Expected: "No update in 34m" / Received: "Claude". After: 11 passed.

Commit 2 before: Tests 5 failed (5) — expected true to be false on the decay boundary in both skew directions. After: 5 passed.

pnpm tc all projects clean; check:code-quality:changed 0 new findings across 54 files; localization verified with no catalog change. Regression sweep src/renderer src/main src/shared mobile → 64,650 passed; the 5 failing files are Electron-harness/temp-dir flakes, and run-electron-vite-dev was reproduced failing identically on the base branch.

agent-status-types.ts crossed the 300-line max-lines budget, so the clock rules moved to a new src/shared/agent-status-freshness.ts and are re-exported — no lint disable.

Finding worth passing on

Mobile has the same clock-skew defect, unfixed. mobile/src/worktree/agent-row-display.ts:34 compares the host's updatedAt against mobile's own now. Fixing it needs a host-clock offset on the mobile client or a wire change, so it is out of scope here — but it is the same bug class on a second surface.

…e 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
…lock

#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
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.
…lock

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.

@pullfrog pullfrog 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.

Important

One substantive concern about the liveness evidence's granularity; the rest is minor.

Reviewed changes

One review of a two-commit fix that splits the decay destination for a stale agent-status row (unverifiable vs idle) and stamps a replica-local receipt clock so mirrored remote rows decay on the reader's clock instead of the host's.

  • Decay destination split — new resolveDecayedAgentRowState(entry, hasLivePty) routes a stale non-done entry on a live-PTY pane to unverifiable, else idle; wired into buildWorktreeAgentRows and smart-attention (new class 4 between working and idle, idle renumbered to class 5).
  • Mirrored-remote clock skew — new mirroredEvidenceReceivedAt facet stamped by buildMirroredAgentStatusPatch and carried forward on repaints; agentStatusEvidenceObservedAt prefers it so the decay subtraction uses one machine's clock.
  • Shared dot-state mapping — agentRowDotState consolidates three duplicate asDotState copies; AgentStateDot/DashboardAgentRow/compact sidebar rows render the amber dashed unverifiable indicator.
  • Clock rules split — AGENT_STATUS_STALE_AFTER_MS plus the observation/decay accessors move to agent-status-freshness.ts and are re-exported (no max-lines disable).

⚠️ Decay evidence is tab-granular, but the claim is pane-granular

The PR's premise is "a pane that still holds a live PTY", but resolveDecayedAgentRowState receives hasLivePty = tabHasLivePty(ptyIdsByTabId, tab.id), which is true when the tab holds any live PTY, not when the pane does. The row this decides for is per-pane (entry.paneKey = tabId:leafId). In a split-pane tab, a stale entry on a pane whose own PTY is closed — but which shares the tab with a still-running sibling — decays to unverifiable ("No update in N") instead of idle, even though Orca can already verify that pane is gone.

This errs in the safe direction (never claims a held pane is empty) and is narrow, but it is the exact distinction the feature exists to draw. Leaf-level liveness is derivable at every call site, so this is a "confirm intent" finding rather than a hard defect.

Technical details
# Decay liveness signal is tab-level, not pane-level

## Affected sites
- `src/renderer/src/lib/agent-row-decay-state.ts:24` — `resolveDecayedAgentRowState(entry, hasLivePty)` documents "a pane whose PTY is still in the live-PTY map", but the map is keyed by tab.
- `src/renderer/src/components/sidebar/worktree-agent-rows.ts:173` — `hasLivePty = tabHasLivePty(ptyIdsByTabId, tab.id)` per tab, applied to every per-pane entry.
- `src/renderer/src/components/sidebar/smart-attention.ts:301` — `collectTabPaneInputs` computes one `hasLivePty` per tab and stamps it on each hook input; `buildAttentionByWorktree` (line 390) hardcodes `hasLivePty: false` for the no-tab fallback.
- `src/renderer/src/lib/tab-has-live-pty.ts:11` — the source of the tab-level signal.

## Scenario
Split-pane tab with two panes. Pane A's agent crashes without a `done` signal (its PTY dies and is dropped from `ptyIdsByTabId`); pane B's agent keeps running. Pane A's stale `working` entry still has `tabHasLivePty(tab.id) === true` because of pane B, so it renders `unverifiable`/amber instead of `idle` — a stale "Orca still holds this pane" claim for a pane Orca can already verify is gone.

## Required outcome
- Either plumb leaf-level PTY evidence (`TerminalLayoutSnapshot.ptyIdsByLeafId`, already available as `terminalLayoutsByTabId` at all three call sites) into `hasLivePty`, or
- Document the tab-level granularity in the code (not just the PR body) so the `unverifiable` contract is "the pane's tab still holds a PTY", not "the pane does".

## Open questions for the human
- Is split-pane-with-multiple-agents frequent enough to justify the extra plumbing, or is tab-level an acceptable simplification today?

ℹ️ Nitpicks

  • unverifiable has three labels across surfaces: agentStateLabel → "No recent update", formatSummaryStateLabel → "not reporting", agentNoUpdateLabel → "No update in N". Each fits its slot, but a reader can't tell they name the same state.
  • The idle→class-5 renumber didn't sweep its stale "Class 4 = idle" references: smart-attention.ts:203 ("pane stays in Class 4"), use-sort-order.ts:108 ("collapse all to Class 4"), and smart-sort.test.ts describe names/comments ("stale entries fall to Class 4", "Class 4 ordering"). These sit right beside the fixed "passing for the wrong reason" test in the same file.
  • smart_sort_class_distribution.class_4 silently changes meaning (idle → unverifiable) for any existing analytics on that bucket; the schema comment documents it, but a changelog/analytics note would save someone a confused regression report.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker changed the base branch from fix/ssh-sweep-leftovers to main September 2, 2026 05:43
@nwparker
nwparker merged commit 266b2ea into main Sep 2, 2026
4 checks passed
@nwparker
nwparker deleted the fix/unverified-agent-status branch September 2, 2026 05:44
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 5a1889f2-a18b-41c4-a95b-5222c38e8c36

📥 Commits

Reviewing files that changed from the base of the PR and between 4e35e05 and be74c8f.

📒 Files selected for processing (31)
  • src/renderer/src/components/AgentStateDot.test.ts
  • src/renderer/src/components/AgentStateDot.tsx
  • src/renderer/src/components/dashboard/DashboardAgentRow.tsx
  • src/renderer/src/components/dashboard/dashboard-row-bucket.ts
  • src/renderer/src/components/dashboard/dashboard-subagent-cards.ts
  • src/renderer/src/components/dashboard/useDashboardData.ts
  • src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx
  • src/renderer/src/components/sidebar/smart-attention.test.ts
  • src/renderer/src/components/sidebar/smart-attention.ts
  • src/renderer/src/components/sidebar/smart-sort.test.ts
  • src/renderer/src/components/sidebar/smart-sort.ts
  • src/renderer/src/components/sidebar/stale-agent-row-unverifiable.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-card-agent-summary.test.ts
  • src/renderer/src/components/sidebar/worktree-card-agent-summary.ts
  • src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts
  • src/renderer/src/lib/agent-row-decay-state.ts
  • src/renderer/src/lib/agent-row-dot-state.ts
  • src/renderer/src/lib/agent-row-tool-preview.test.ts
  • src/renderer/src/lib/agent-row-tool-preview.ts
  • src/renderer/src/lib/pane-agent-evidence.ts
  • src/renderer/src/lib/recent-workspace-tab-rows.ts
  • src/renderer/src/runtime/mirrored-agent-status-clock-skew.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts
  • src/renderer/src/runtime/web-session-tabs-sync/state-equality-core.ts
  • src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts
  • src/shared/agent-status-freshness.ts
  • src/shared/agent-status-observation.ts
  • src/shared/agent-status-types.ts
  • src/shared/telemetry-onboarding-event-schemas.ts

📝 Walkthrough

Walkthrough

The change adds unverifiable for stale, non-done agent rows backed by a live PTY. Freshness now uses authority observation time or mirrored replica receipt time. Renderer components map and display the new state with amber dashed indicators and no-update labels. Smart attention adds Class 4 for unverifiable rows and moves idle rows to Class 5. Tests cover decay, ordering, rendering, clock skew, and telemetry.

✨ Finishing Touches
📝 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.

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
…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