Skip to content

fix(renderer): host agent-status rows are never outranked by a client wall clock - #20692

Open
unempyd wants to merge 1 commit into
stablyai:mainfrom
unempyd:upstream/S
Open

unempyd wants to merge 1 commit into
stablyai:mainfrom
unempyd:upstream/S

Conversation

@unempyd

@unempyd unempyd commented Sep 14, 2026

Copy link
Copy Markdown

ELI5

Two machines (the host running an agent, and a client mirroring its status) don't have synchronized clocks. Orca's renderer used to let a client's status update win over the host's just because the client's timestamp looked "newer" — even when the client wasn't the one actually running the agent. That let a stale, unrelated status beat the real one, forever.

What Changed

buildMirroredAgentStatusPatch's merge (src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts:118) had a second arm, existing.updatedAt > entry.updatedAt, that let any client row — proven owner or not — outrank the host purely by cross-machine wall-clock comparison. The file's own comment already said cross-machine wall clocks are not comparable. Two consequences: a stale, unproven client row with a lucky clock could outrank the host forever, and a host blocked/interactivePrompt row — meant to pierce the client fence via hostAgentStatusPiercesClientAuthority — still lost to an unowned client row on wall clock alone, because piercing only disabled the first arm, not the second.

A host row is now replaced only by clientOwnsEntry — a proven, fresh, client-owned row the host does not pierce; the wall-clock arm is deleted.

Why

Comparing wall clocks across two machines to decide which status wins is exactly the kind of "loss of contact / unrelated signal treated as authoritative" pattern this codebase's agent-status-store contract exists to prevent (the execution host owns status in one store; readers keep only presentation policy).

Linked Issue

No existing tracked issue — found via an independent orchestration/safety audit of this codebase (Odin, see final note); the main-process copies of this class of bug were already closed upstream per docs/reference/agent-status-store.md.

Testing

  • Automated tests added/updated, or explained why not below

web-session-tabs-sync-host-authority.test.ts (new) — an unowned client row with a later wall clock no longer beats a host blocked row or a host done row; a proven fresh client-owned row still keeps its state when the host does not pierce. On main:

expected 'working' to be '(blocked|done)'

One existing test in web-session-tabs-sync-agent-status.test.ts built its "existing" mirrored row directly into state without ever registering it as a proven writer — three of its five assertions were passing purely via the deleted wall-clock arm. Its expectations are updated to match the corrected contract, each with a one-line comment naming the change.

Ran: both files above, every other test file under src/renderer/src/runtime/ (185 files / 1562 tests), and pnpm run tc:node + pnpm run tc:web. tc:node is clean. tc:web currently reports ~290 pre-existing errors in this environment, entirely in unrelated @tiptap/markdown-editor files caused by a broken node_modules symlink for @tiptap/core in this local checkout (confirmed: zero of those errors are in any file this PR touches, and the missing top-level node_modules/@tiptap/core symlink predates this change). Tested on macOS only; no OS-specific code touched.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: none. Cross-platform: no OS-specific code touched. Remote SSH: this is a renderer-side mirroring path for remote-runtime/structured-chat panes whose bytes never transit the host's own agent-status store; that residual (the renderer still writing authoritative rows itself in those two cases) is a separate, larger change and out of scope here. Mobile: not applicable. Backwards compatibility: no wire shape changed — this only removes one arm of a local merge decision.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason — N/A, this changes which status value wins a merge, not any rendered layout; no visual diff to show.
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — ran targeted vitest + tc:node/tc:web locally (see Testing, including the pre-existing unrelated tc:web environment issue); full pnpm lint/pnpm build left to CI.

Extracted from Odin (github.com/unempyd/odin), a derivative that closes Orca's residual orchestration and safety contracts; all of its changes are offered upstream.

… wall clock

Why: `buildMirroredAgentStatusPatch`'s merge
(src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts:118)
had a second arm, `existing.updatedAt > entry.updatedAt`, that let any
client row -- proven owner or not -- outrank the host purely by
cross-machine wall-clock comparison. The file's own comment already says
cross-machine wall clocks are not comparable. Two consequences: a stale,
unproven client row with a lucky clock could outrank the host forever, and a
host `blocked`/`interactivePrompt` row -- meant to pierce the client fence
via `hostAgentStatusPiercesClientAuthority` -- still lost to an unowned
client row on wall clock alone, because piercing only disabled the first
arm, not the second.

A host row is now replaced only by `clientOwnsEntry` -- a proven, fresh,
client-owned row the host does not pierce; the wall-clock arm is deleted.

Test: `web-session-tabs-sync-host-authority.test.ts` (new) -- an unowned
client row with a later wall clock no longer beats a host `blocked` row or a
host `done` row; a proven fresh client-owned row still keeps its state when
the host does not pierce. On `main`:

```
expected 'working' to be '(blocked|done)'
```

One existing test in `web-session-tabs-sync-agent-status.test.ts` built its
"existing" mirrored row directly into state without ever registering it as a
proven writer -- three of its five assertions were passing purely via the
deleted wall-clock arm. Its expectations are updated to match the corrected
contract, each with a one-line comment naming the change.

Ran: both files above, every other test file under
`src/renderer/src/runtime/`, and `pnpm run tc:web`. All pass. Tested on
macOS only; no OS-specific code touched.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017xLuDWCWWWjzMm64rL13TR
@pullfrog

pullfrog Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Pullfrog stalled

The agent stopped emitting events for 125s and was killed by the activity-timeout watchdog. The model produced no output at all before the stall — the request was sent but nothing came back. This is usually transient; re-running often succeeds.

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a6ba8e1a-1614-4b79-9c92-190bf42d5890

📥 Commits

Reviewing files that changed from the base of the PR and between d5be0d6 and f0c51ff.

📒 Files selected for processing (3)
  • src/renderer/src/runtime/web-session-tabs-sync-agent-status.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync-host-authority.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The host agent-status patch no longer uses cross-machine wall-clock timestamps to preserve existing client rows. It preserves an existing row only when the row is proven client-owned and the host does not pierce it. Tests now cover host precedence for unowned rows and preservation of eligible client-owned rows. Existing expectations also reflect host timestamps, host turn state, and provider-session identity.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f0c51

Host status synchronization now avoids cross-machine clock arbitration and has coverage for host precedence and valid client ownership. No current merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, reason, scope, tests, compatibility considerations, and checklist status. However, it omits the required Visual Proof section and does not provide the required lin… Add the required ## Visual Proof section with N/A and a brief reason. Provide a valid issue reference after Fixes #, or obtain repository approval for an exception. Add and complete the manual-testing checklist item, or explain why manu…
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 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing client wall-clock timestamps from outranking host agent-status rows.
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.
Full details: Description check

Explanation

The description explains the change, reason, scope, tests, compatibility considerations, and checklist status. However, it omits the required Visual Proof section and does not provide the required linked issue; it states that no tracked issue exists instead. The manual-testing checklist item is also missing.

Resolution

Add the required ## Visual Proof section with N/A and a brief reason. Provide a valid issue reference after Fixes #, or obtain repository approval for an exception. Add and complete the manual-testing checklist item, or explain why manual testing was not performed.

  • Fix all pre-merge checks with AI

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.

This branch has not been deployed

No deployments
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