Skip to content

fix(bots): let a paired server's bots see the computers paired to it and the bots they allow - #50417

Merged
AmethystLiang merged 16 commits into
mainfrom
AmethystLiang/m4-client-bot-lookup
Nov 27, 2026
Merged

AmethystLiang merged 16 commits into
mainfrom
AmethystLiang/m4-client-bot-lookup

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a computer is paired to an Orca server, bots on the server couldn't see that computer or its bots, so they couldn't ask one for help. Now the server's orca bot list shows each connected paired computer, the bots that computer lets the server ask, and how to ask them.

Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​421 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​420
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​268 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​239

What Changed

  • Before: on a paired server, orca bot list listed only the server's own bots, and its hint pointed at --on <server>, which can't reach a paired computer. send --on-client help said "a person on that computer approves it once", but the computer actually declines asks to bots nobody @-mentioned in that chat or allowed.
  • After: each pull a paired computer already makes to the server also names the bots it always lets that server ask (its existing Who can ask list; paused or removed bots are left out; capped at 100, with a flag when there are more). On the server, orca bot list lists each connected paired computer with its --on-client address, those bots, and how the owner makes another one askable. A computer shows only while it is live (it pulled within the last minute, and since this computer last slept or woke) and only when its --on-client id reaches it alone. Ids that aren't plain generated ids are left out, and names stay single-line, quoted text labelled as that computer's own. A paired computer names no bots while its bots are off. One that dropped off between pulls stops showing within a minute and never hides or blocks a live one.
  • send --on-client help, the mention text a server agent reads, the bot preamble and the orca-cli bots guide now say briefly what happens: always-allowed bots take the ask, @-mentioned or previously allowed bots get a card, others decline.

Why

The consent model stays on the paired computer: it already decides which of its bots a server may ask. This only tells the server what that computer already allows, so its bots stop guessing (or searching elsewhere) and get declined. Checked against how comparable products handle this: the side that owns the agents publishes what is reachable, and the other side lists only that.

Linked Issue

Refs #45831

Visual Proof

N/A: CLI text that bots read (orca bot list, send --help); no UI change.

Testing

  • Reproduced on a paired server: orca bot list showed no paired computer; an --on-client ask to a bot nobody allowed came back "Declined" with no card.
  • Automated tests added: the integration test for paired-server asks checks that a server lists the computer and only its always-allowed, unpaused bots, and drops one after it is disallowed; it also checks that the real bots.roster handler gives the computer section to the server's own callers and never to a paired caller. Unit tests cover malformed and ambiguous ids, bots off, the 100-bot cap flag, liveness expiry, suspend and resume, overlapping pulls of one session, the per-device bound, and dropping a malformed list without failing the pull.
  • Added behavior tests fail without this change: the first set was run against the base sources and failed; each later liveness test targets the branch its fix adds (for example, the overlapping-pull test fails without the per-pull id check).
  • Ran on macOS: the three test files pass (46 tests), typecheck (node, cli) passes, and oxlint and oxfmt are clean on the changed files.

Performance

None, because the computer adds one indexed SQLite read of its allowances and a filter over its bot list to a pull it already makes every ~20 seconds per paired server, and the server keeps at most 100 small entries per connected installation (at most 8 installations per paired device) in memory. orca bot list reads that in-memory list in one pass.

Risk

Level: Low

The riskiest part is the pull between versions. The new fields are optional, an older server ignores them, an older computer omits them, and a malformed list is dropped without failing the pull. If it went wrong, a server's orca bot list would show a missing or stale computer section; asks themselves are decided on the paired computer exactly as before. A plain revert backs it out.

…and the bots they allow

A bot on a paired server had no way to find bots on the computer paired to it: `orca bot list` there listed only its own bots, and `send --on-client` help said a person approves any ask, while the computer declines asks to bots nobody introduced or allowed.

- Each pull a paired computer makes now names the bots it always lets that server ask (its existing allowlist; nothing else).
- On the server, `orca bot list` lists each connected paired computer with its `--on-client` address, those bots, and how the owner makes another one askable.
- `send --on-client` help, the bot preamble and the bots guide say what actually happens.

Refs #45831
…flag a capped list

- A server's bot list leaves out a paired computer whose installation id isn't a plain generated id, so no computer can put control text or instructions into it.
- Copy says a bot its owner once allowed gets a card, not a decline.
- A computer allowing more bots than one pull names says so.
- Copy-only assertions replaced by behavior tests.
…no bots while bots are off

- A paired computer names no bots while bots are off there.
- A server's bot list keeps only computers whose --on-client id resolves to that one computer, and only bots with plain ids; bot names print as quoted text next to their address.
- bot list says 'No bots on this computer.' above a paired-computer section; its help describes paired servers and computers.
- Tests cover ambiguous ids, bots off, display fallbacks and a list that is dropped whole.
…installations per device

- The server's bot list shows a paired computer only if it pulled within the last minute, so one that crashed or dropped off between pulls (and the bots it named) stops showing. Routing is unchanged.
- One paired device keeps at most 8 installations listening; its least recently seen goes first.
- Ambiguity is counted in one pass, matching the --on-client resolver.
- Help and preamble say a paired computer's bots come with name and address only.
- Tests cover liveness expiry, session isolation, the per-device bound, the display fallback and the bots.roster caller gate.
…e; time liveness monotonically

- Roster ambiguity counts only computers seen within the lease, and a tie on --on-client is settled the same way, so a computer that crashed between pulls never hides or blocks a live one. A lone match routes as before.
- Liveness uses a monotonic clock, so changing the system clock neither revives nor hides a computer.
- Tests cover a stale collider through the roster and send resolution, and both clock moves.
…ly once it pulls again

performance.now() stops during sleep on Linux, so a computer that went silent before a suspend could stay live for up to a minute of awake time. The wake-signal clock now also keeps the monotonic time of the last resume, and a listener seen before it is not live until its next pull.
…ts on every platform

The resume timestamp only fed on macOS. Liveness now records systemPowerGeneration(), which the desktop bumps on every suspend and resume on macOS, Linux and Windows: a computer last seen before the latest one isn't live until it pulls again, and a pull begun before it no longer refreshes liveness when it is answered after. wake-signal-clock is back to its original form.
… end or refresh it

One session's pulls overlap across a reconnect, so a superseded pull ending late (caller gone or answered) could delete or refresh the newer pull's listener. Each pull now carries its own id and only the current one acts. Tests cover overlapping pulls across and within a power generation, recovery after a resume, lone-match routing, and a suspend alone.
…t is away

The send fails at once only when no paired computer, or more than one, answers to the selector; to a computer this Orca knows it is queued. The send help and the mention context said it always failed at once.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Paired-server pulls now carry metadata for bots that the server is allowed to ask. The runtime tracks connected client rosters, filters them by liveness and power generation, and exposes them to local callers. The CLI lists paired computers and their available bots. Command descriptions and guides document roster contents, --on-client requests, authorization, and delivery outcomes.

Merge Risk: Minimal · up to f902c

This change lets a paired server list the computers paired to it and the bots they allow. No merge-blocking problems were found, and the earlier documentation concern has been addressed.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: paired servers' bots can now see the computers paired to them and the bots those computers allow. It matches the changeset, which adds paired-client roster data to bot…
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Refs #45831), Visual Proof (N/A with reason), Testing with checked items, Performance (None, because ...)…
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: Title check

Explanation

The title names the main change: paired servers' bots can now see the computers paired to them and the bots those computers allow. It matches the changeset, which adds paired-client roster data to bot list and the bots.roster handler. The 'fix(bots)' prefix is a conventional commit style and is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Refs #45831), Visual Proof (N/A with reason), Testing with checked items, Performance (None, because ...), Risk with level Low and a revert note, and Notes. The AI Disclosure, Review, and Agent skill upstream boundary sections are not filled in. The AI Disclosure section is optional for internal contributors. The Agent skill upstream boundary checkbox is unchecked and not explicitly marked not applicable. The Linked Issue uses 'Refs' rather than 'Fixes', which the template's comment says is insufficient for outside contributors. The author's contributor status is not stated. The Checklist section is not ticked.

Resolution

Optionally: confirm whether the author is an outside contributor, because the template requires a 'Fixes #' issue link for outside contributors and this PR uses 'Refs #45831'. Tick or address the 'Agent skill upstream boundary' item, and tick the Checklist items that apply.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f32011dd-086b-40d3-bf0c-e1023c780b8e
Commits

Reviewing files that changed from the base of the PR and between 07fad4d and f902cdc.

Files selected for processing: 3

  • src/main/runtime/rpc/methods/bots-roster-paired-clients.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/paired-server-asks.test.ts
  • src/shared/rpc-contract/orchestration/orchestration-peer-mail-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@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

Additional comments: 1

src/cli/skills/bundled-skill-guides.ts-1004-1004: 1

1004-1004: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Use one message type in the example command.

If an agent copies --type question|handoff, the shell treats | as a pipeline and runs handoff as a separate command. Show a runnable command with --type question, then describe handoff as an alternative.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c63b263b-6ba2-4dbc-9b53-84a0edbba6f5
Commits

Reviewing files that changed from the base of the PR and between e1fb71d and 34f98d4.

Files selected for processing: 17

  • skill-guides/orca-cli/references/bots.md
  • src/cli/bots/bot.ts
  • src/cli/skills/bundled-skill-guides.ts
  • src/cli/specs/bot.ts
  • src/cli/specs/orchestration.ts
  • src/main/bots/bot-preamble.ts
  • src/main/runtime/orchestration/db/federation/paired-server-asks-store.ts
  • src/main/runtime/orchestration/federation/client-asks/client-ask-listeners-roster.test.ts
  • src/main/runtime/orchestration/federation/client-asks/client-ask-listeners.ts
  • src/main/runtime/orchestration/federation/paired-server-asks/paired-server-asks-loop.ts
  • src/main/runtime/orchestration/federation/peer-mail/peer-mail-relay.ts
  • src/main/runtime/rpc/methods/bots.ts
  • src/main/runtime/rpc/methods/orchestration/federation/paired-server-asks.test.ts
  • src/shared/bot-roster.ts
  • src/shared/bots/bot-mention-context.ts
  • src/shared/rpc-contract/orchestration/orchestration-peer-mail-params.ts
  • src/shared/rpc-contract/orchestration/orchestration-peer-mail-pull-bots.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/cli/skills/bundled-skill-guides.ts Resolved
@AmethystLiang
AmethystLiang merged commit 862d1ab into main Nov 27, 2026
61 checks passed
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