You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(bots): a bot woken by its own background work in a Slack thread is told to post itself - #49406
Someone asks a bot in a Slack thread to do something. The bot starts a worker in the background and ends its turn. Later the background command finishes, for example because the worker failed to start, and the bot wakes up in a new turn on its own. Orca doesn't post anything from that turn to Slack, but the bot's rules said "your final message is posted there for you", so the bot thought the thread had heard it. It hadn't.
Now the bot is told the truth. A turn that starts on its own stays in Orca. If the bot wants the thread to hear something, it posts the message itself with Orca's reply command, and when it starts a worker it is told which thread that start came from. The bot decides whether to post and what to say; Orca still posts nothing on its own.
This is the first stage and covers Slack thread chats. Slack direct messages are a planned later stage.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$99
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$99
Prod
8
$\color{#1a7f37}{\Huge{\mathbf{+}}}$122
$\color{#cf222e}{\Huge{\mathbf{−}}}$12
$\color{#1a7f37}{\Huge{\mathbf{+}}}$110
What Changed
Rules fact:
The rule "Your final message is posted there for you" gains the exception: in a turn that started on its own (something run in the background finished), the final message stays in Orca, and orca bot reply is how anything from it reaches the thread.
The quiet-note rule lists that turn as one whose final message stays in Orca.
Worker-start note:orca orchestration worker-start run from a bot's Slack thread chat prints one line to stderr: [Orca: this start came from <thread>. A turn that starts on its own when this command finishes in the background stays in Orca; orca bot reply --text "..." posts there.]
It is printed on success and on failure, for local and --on starts alike, because the command runs on the bot's own computer.
It is read first, before the start, while the starting turn still runs.
It appears only when Orca can prove the thread. All of these must hold, otherwise nothing is printed and nothing is guessed:
Orca's own record shows a Slack message started or joined the running turn;
the turn answers this thread's delivery;
the turn's origin record (the one items already use) names the same channel;
the chat is the bot's own thread chat, and not a thread inside a DM.
New RPC connector.wakeReplyPlace, caller-verified like the other connector post methods. Older hosts lack it, and the CLI then prints no note.
Unchanged and confirmed:bot reply already works in a thread chat's self-started turn. Orca's checks pass, and the connector service posts it as a plain message in that thread. Nothing else posts on its own.
Why
The rules told the bot its final message is always posted, which is false for a turn it started itself, so a failed worker start reached only Orca. Orca can't tell what in such a turn is safe for the thread, so it still posts nothing by itself. Instead the bot is told the fact and the thread, and it decides. The thread is taken when the start happens, from the record items already use, and never guessed later.
The chat's history alone can't tell what started a turn: a turn that starts on its own looks as if the last message started it. So the note also requires Orca's own record of which messages reached the running turn.
Linked Issue
Internal item; no public issue.
Visual Proof
No UI is added. The new text is one line in a CLI result, which the bot reads in its chat's tool output, plus two rule sentences. Below is the real chat tool line, rendered with the real CLI output from this branch (light | dark).
Worker-start note in the chat's tool line (3 cases) and the rules text
Thread proven: the note is shown. The note prints first, before the receipt, because it is written when the start call settles.
Worker started:
Worker failed to start (the case this fixes):
Thread not proven, or an older Orca host: no note. The output is exactly as on main today. Both cases look the same.
Rules text the bot reads (added sentences):
After "Your final message is posted there for you. Anything before it … goes through orca bot reply ….":
A turn that started on its own (something you ran in the background finished) is the exception: its final message stays in Orca, and orca bot reply is how anything from it reaches the thread.
In the list of places where a final message stays in Orca, "a turn that started on its own" is added: "(your Home Chat when this turn answers no Slack, GitHub, Linear or Discord message, a turn that started on its own, a look-around run, or mail whose Orca note says your final message stays in Orca)".
Testing
connector-wake-reply.test.ts: the thread is named only for a turn a delivery of that thread started, with Orca's delivery record set and a matching origin, asked by the chat itself. It is not named for a self-started turn, another channel, another chat, the bot's Chat, or a DM. Each of those checks makes the test fail when it is removed.
The connector service side was checked with a throwaway test against its current source: a reply for a turn it was never told started posts into the thread.
Reviewer steps: pnpm test src/main/runtime/rpc/methods/connectors/connector-wake-reply.test.ts. Platforms: macOS (tests). The change has no platform-specific code; Linux and Windows are covered by CI.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Known limits:
Slack DMs (the bot's Chat) are a later stage. A self-started turn there stays in Orca as today, and no DM is named.
It depends on the bot choosing to post. Private input in the chat can shape what the bot writes, like any post the bot makes.
Only orca orchestration worker-start prints the note. Another background command gets only the rules fact. In a thread chat bot reply still reaches the chat's own thread.
A worker started from a self-started turn, or after a restart, prints no note. That is a missed note, never a wrong thread.
Unchanged here: where a remote start's later failure mail is routed belongs to separate work.
Performance
None, because the new work runs once per worker start from a native chat. It is one RPC: a session lookup and, for a bot's thread chat whose turn a Slack delivery opened, the same bounded newest-turn read that adding an item already does. There are no timers, polls, stored state or renderer changes.
Risk
Low. The worker-start note is printed only when every check above passes, so the failure mode is a missing note, not a wrong thread. The rules change is text the bot reads. Older hosts print no note. A plain revert undoes it.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
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)
brennanb2025
changed the title
fix(bots): a bot woken by its own background work is told where to post
fix(bots): a bot woken by its own background work in a Slack thread is told to post itself
Nov 26, 2026
…s told to post itself
A turn that starts on its own (a background command finished) posts nothing to
Slack, but the rules said its final message is posted. The rule now states the
fact, and worker-start names the Slack thread it came from when Orca can prove
it, so the bot can tell that thread with bot reply. Slack DMs are a later stage.
Performance scan (independent reviewer, head 45d4942)
Perf-scan: stablyai/orca #49406 (head 45d4942e090, base origin/main84bd7ed4198)
Findings
None. The PR adds no new P0 or P1. I didn't take any runtime timing, CPU or heap measurements. Everything below comes from tracing the source and counting the work.
One correction to the brief: src/main/bots/bot-wake-reply-place.ts contains no map at the head commit. There is no Map, Set, registry or module state in it. It exports one pure async function, wakeReplyPlace(botId, target, delivered, readOrigin). So there is no per-entity retention to check there.
New work (trigger → owner/thread → work → bound → fleet price)
Trigger: each orca orchestration worker-start invocation, in the CLI process.
Work:
It reads an env var and returns at once when there is no injected session id.
Otherwise it makes 1 connector.wakeReplyPlace RPC. A failure is caught and becomes null; a host that predates the method fails fast with unknown-method.
On success it formats a string and writes it to stderr at most once. The two tellWake() calls sit on mutually exclusive paths: the throw path and the success path.
Bound: 1 RPC per worker-start, with no loop or retry.
Fleet price: worker-start is a one-shot command an agent runs per handed-off task, not a polled one. Even at "a dozen agents calling the CLI every few seconds", if every call were a worker-start, that is ≤ ~4 extra RPCs/s. Each one is an O(1) host lookup (see 2). On SSH/remote hosts it adds one round trip per command.
Verdict: small, constant and non-recurring per command. Not a finding.
Main RPC connector.wakeReplyPlace (src/main/runtime/rpc/methods/connectors/connector.ts:125-144)
Trigger: item 1 only. It is the sole caller; I grepped for others and found none.
Thread: Electron main. It runs these steps in order, and each gate is checked before the costlier work:
runtime.bots.enabled(): flag.
botOfSession (src/main/bots/bot-session-tabs.ts:16): 1 store.getConversation(sessionId) keyed lookup, then botOfHomeWorkspace(bots.list(), ws). That is linear in the number of bots, which is a handful, not worktrees, terminals or agents.
seam.replyTarget(chatPaneKey): goes to ConversationEvents.replyTarget (external-conversation-events.ts:322). That does findLinkForPane through the indexed link store (external-conversation-links.ts:87-92, createExternalConversationLinkIndex), plus turnOpener, which reads publishedWork(sessionId).activeTurnOpener from memory. Both are O(1).
seam.deliveredTurn (external-conversation-seam.ts:131): already exists on main; two Set.has checks.
wakeReplyPlace gates (bot-wake-reply-place.ts:19-31): delivered, answerDeliveryId, same bot, Slack source, thread present, not a DM. All are O(1) string checks.
Only thenreadBotTurnOrigin (bot-turn-origin.ts:16). It calls readNewestBotActingTurn(..., widen=false) with latestTurns: 1, anchorsOnly, indexedOnly. The widen=false path makes exactly one operationWindow read (bot-acting-turn-read.ts:25-47 exits on the first pass when !widen). That read is the newest turn by index alone, plus db.getBotRequest by id for that turn's anchors. Its cost doesn't grow with journal history.
Precedent:bots-items-add.ts:95 already calls the same bounded read per RPC.
Bound: constant per call, independent of worktrees, terminals, agents, chat history size and refs.
Fleet price: ≤ ~4 calls/s worst case × O(1) lookups. The journal read happens only for a bot chat whose running turn a Slack-thread delivery opened, so in practice the rate is far lower.
CONNECTOR_POST_METHOD_NAMES gets one more entry (src/shared/connector-action-contract.ts:15)
Consumers: the allowlists built at module load in orchestration-session-caller.ts:67 and orchestration-compatibility-envelope.ts:41.
Cost: +1 constant entry. No per-call cost change.
Preamble text (src/main/bots/bot-preamble.ts:61,72)
About 250 more characters of static rules text, built once per bot session prompt.
No new computation. Not a perf concern.
Schema and generated catalog
One zod object plus one catalog entry, evaluated at module load.
No new imports of SDKs or adapters.
Production callers traced
readBotTurnOrigin:connector.ts:140 (new, behind all the gates above) and bots-items-add.ts:95 (existing). It is not called from any render, poll, event or stream path.
replyTarget: the new call is the RPC handler only. The existing callers (readBotTurnOrigin, the cancel turnIsCurrent check in the seam) are unchanged.
botOfSession: the new call is the RPC handler, once per call. Existing callers (runsForBot, tab close) are unchanged.
deliveredTurn: already on main. The new RPC is a read-only caller.
wakeReplyPlace: the RPC handler only (plus the test).
Regression classes the diff touches
Class
Disposition
Expensive code newly reachable past a gate
Matched and disproved. The new path does reach a journal read on main. It sits behind bots enabled → bot session → self-caller → delivered → Slack thread (not DM) → same bot, and the read itself is index-only, newest turn, no widening, 1 pass. It is the same bounded read bots-items-add already does per RPC. Price: ≤ 1 per worker-start.
Sync fs or SQLite on Electron main per RPC
Matched and disproved. One indexed operationWindow read plus getBotRequest by id, per worker-start. Constant per call, no history scan. The CLI invocation rate caps it (see 1).
Subprocess per item or per event
No matching code: no spawns.
Fixed-cadence poll / new idle wakeups
No matching code: no timers, intervals or subscriptions. Idle wakeups/s on main, renderer and daemon are unchanged (0 added).
Per-entity state outlives the entity
No matching code. The new module has no map or set (correcting the brief).
Unbounded fan-out
No matching code: one awaited call, no Promise.all.
Eager startup imports
Matched and disproved. The new imports are local modules already on the RPC graph (bot-turn-origin, slack-mirror-state, bot-wake-reply-place). No SDK or adapter is added.
No matching code. Read-only, no renderer code, no store mutation, no emit.
Six questions
Unused work before the skip gate: reviewed. The CLI skips the RPC when there is no injected session id. On the host, every O(1) gate runs before the one journal read, and the string is formatted only when a place exists.
Ownership multiplies work: not applicable. There is one call per CLI command and no per-row, per-pane or per-worktree owner or listener.
Which thread pays: reviewed. Electron main pays O(1) lookups plus at most one indexed journal read per worker-start. The CLI process pays one RPC. No added serialization beyond a small JSON answer.
What grows / does the next attempt advance: reviewed. Nothing grows: no retained state, no retries. The read is fixed at the newest turn regardless of history size (tens of GB of journal included).
Execution host: reviewed. On SSH/remote runtimes it costs one extra round trip per worker-start. A host that predates the method returns an error that becomes null, with no fallback scan. No platform-specific code.
Obsolete work stops: reviewed. There is no background work, timer or handle. The RPC promise ends with the command, and the read result is dropped after the call.
Coverage and residual gaps
I graded the non-test files listed below and inspected the paths reached from them. Hosts considered: local, SSH/remote runtime, and an older host without the method.
I did not run a runtime timing of readBotTurnOrigin on a large real-shaped profile. The bound comes from the source (widen=false → a single latestTurns:1, indexedOnly pass), and the same read already ships via bots-items-add.
The bot preamble now covers autonomous turns that keep their final message in Orca and use bot reply to send content to a thread. A new connector RPC returns a place for qualifying delivered Slack thread replies with a matching bot origin. Worker start reads that place and reports a formatted wake note after the mutation attempt, including when the mutation succeeds, is recovered, or throws.
Merge Risk: Low · up to ae552 · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 3 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Description check
The description follows the repository template closely. It covers ELI5, What Changed, Why, Visual Proof, Testing, Performance, Risk (Low, with a revert path), the checklist, and the upstream boundary…
1. In Linked Issue, either link the existing internal tracking item (for example 'Fixes #NNN' or a tracker URL) or state why no issue exists and confirm it is an exempt maintainer change. 2. Fill in AI Disclosure: state whether an AI model …
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title is a conventional-commit style fix line that names the main change: a bot woken by its own background work in a Slack thread is told to post itself. The changeset does this by changing the b…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title is a conventional-commit style fix line that names the main change: a bot woken by its own background work in a Slack thread is told to post itself. The changeset does this by changing the bot rules, adding the worker-start note, and adding the connector.wakeReplyPlace RPC. The title is slightly misleading, though. The code does not tell the bot to post. It tells the bot that its final message stays in Orca and that it may post with bot reply. The title therefore states the reverse of the intended behavior. The PR's own description says Orca posts nothing on its own. The title is specific, but its wording conflicts with the change. This is a partial match, so the check passes with a suggested rewording.
Resolution
Consider rewording the title so it matches the behavior. For example: "fix(bots): tell a bot woken by its own background work in a Slack thread that its final message stays in Orca". This is optional. The current title is related to the change.
Full details: Description check
Explanation
The description follows the repository template closely. It covers ELI5, What Changed, Why, Visual Proof, Testing, Performance, Risk (Low, with a revert path), the checklist, and the upstream boundary attestation. The Linked Issue section says 'Internal item; no public issue' and gives no 'Fixes #' reference. The template asks for an issue link, and a maintainer exception applies only to pre-existing issues, so this is a gap. The AI Disclosure section is empty. The Testing section names one test file and gives a reviewer command, but the 'manually tested' box is checked without listing the manual steps. The Visual Proof section gives before/after images for each case.
Resolution
In Linked Issue, either link the existing internal tracking item (for example 'Fixes #NNN' or a tracker URL) or state why no issue exists and confirm it is an exempt maintainer change. 2. Fill in AI Disclosure: state whether an AI model was used and which one, or confirm that the author is an internal StablyAI team member and that the section should be ignored. 3. In Testing, describe the manual steps that were run locally (for example, the Slack thread scenario and the worker-start command output), and name the platform used for those steps. 4. Under Notes, confirm the checklist items on Security, SSH, and Mobile, since the PR body says these were considered but the mobile smoke check is failing.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Review status (head 45d4942, stage 1: Slack thread chats)
Problem: a bot started from a Slack thread kicks off background work. When that work finishes (for example, a worker fails to start), the bot wakes in a turn Orca didn't start from Slack, and nothing reaches the thread. Its rules also told it that its final message is always posted.
User-facing change:
The bot's rules now say that such a turn stays in Orca, and that orca bot reply reaches the thread.
orca orchestration worker-start names the thread it came from, only when Orca can prove it.
The bot decides whether to post. Orca posts nothing on its own.
Slack direct messages are a planned later stage.
Reviews:
Independent Claude review: ready. Its four minor findings were fixed in 45d4942 and confirmed by a fresh repair check. One was left as is: the rule wording is accurate for thread chats.
Blinded regression audit on the change merged onto main: SAFE.
The note is read before anything else in the command.
Threads inside direct messages are excluded.
A misplaced doc comment was moved back.
The earlier direct-message design was removed from this PR and moved to a later stage. Reviews found that Orca can't yet prove which messages reached a turn in the shared direct-message chat.
Verified:
connector-wake-reply.test.ts: each check behind the note makes the test fail when removed.
The connector service posts a reply from a self-started turn into the thread (checked against its source with a throwaway test).
Deferred:
The direct-message stage.
Other background commands get only the rules fact, not the note.
QA: covered by tests. The change is CLI and host decision logic with no UI, process-lifecycle or platform-specific behavior.
CI: 43 checks pass. "orcad terminal smoke" (and the "PR checks passed" summary that depends on it) fails because the mobile web bundle is about 1.4 KB over its size budget. This PR changes no mobile code, and other open PRs (#49670, #49671) fail the same check the same way on current main.
Performance scan (independent reviewer, head 6ff4806)
I found no perf regressions in PR #49406. Here is the full audit.
Findings
None. The new work runs only when someone runs orca orchestration worker-start from an agent chat. It adds no timers, polls, subscriptions, store writes, emits or retained state.
Scope
Refs: head 6ff4806295f, base origin/main0025e661ff7, diff git diff origin/main...HEAD.
Not graded: the test file connector-wake-reply.test.ts.
About "the new map" in bot-wake-reply-place.ts: there is none. The file holds one stateless async function, wakeReplyPlace, with no Map, Set, cache or module state. The only lookup tables it touches are existing ones on the connector seam (chatDeliveries.sending/delivered, through deliveredTurn), and those are only read.
New work: trigger → owner → work per event → bound
CLI, readWorkerStartWakeNote (worker-start-wake-note.ts:10, called at worker-launch-handler.ts:36)
Trigger: one call per worker-start run that has an injected agent session id. Plain shells return at once with no RPC.
Owner: the short-lived CLI process, which already exists for worker-start and already makes several RPCs.
Work: one extra RPC round trip, run one after another with the start. On SSH or remote routes that is one more round trip per command. If an older host refuses it, .catch(() => null) handles that.
Fleet price: even if all of a dozen agents ran worker-start every few seconds (the real rate is far lower), that is about 4 extra RPCs/s, each O(1) on the host. It doesn't grow with worktrees, terminals or history.
Retention: none. It prints one stderr line in .finally.
botOfSession (bot-session-tabs.ts:16): one in-memory store.getConversation(sessionId) and a scan of bots.list(). That list holds the bots (a handful to dozens), not worktrees or chats.
the caller-session check
session-caller verification, which already runs for every CONNECTOR_POST_METHOD_NAMES method (orchestration-session-caller.ts:62-68), once per call
Non-bot chats (most of the 100+ agents) stop after these steps.
Bot chats:seam.replyTarget(chatPaneKey(id)) does an indexed findLinkForPane and turnOpener lookup (external-conversation-events.ts:322). deliveredTurn checks two in-memory sets (external-conversation-chat-delivery.ts:120). All of this is O(1).
Main, wakeReplyPlace (bot-wake-reply-place.ts:10)
Pure checks on the target: delivered, answerDeliveryId, same bot, Slack source, a thread, and not a DM.
Only if every check passes does it call readOrigin().
readBotTurnOrigin (existing code, already used by bots-items-add.ts:95)
Calls readNewestBotActingTurn(..., widen=false) with latestTurns: 1, anchorsOnly and indexedOnly. That is one indexed read of the newest turn's anchors through the journal's WAL snapshot on its reader worker (journal-sql-reads.ts:119), not main.
The db.getBotRequest lookups are sync SQLite on main, by primary key, and bounded by how many message anchors the newest turn has. They don't grow with history.
It runs at most once per qualifying start. A JournalWindowNotIndexed error falls back to null and nothing retries.
bot-preamble.ts: two rules strings get longer, by about 230 bytes on bot preamble text that is already built. Constant size, no new trigger.
Matched and disproved.readBotTurnOrigin gains a caller from worker-start, behind six cheap gates plus bot, caller and delivered checks. It costs one indexed one-turn read on a reader worker plus primary-key getBotRequest lookups. That cost is fixed per start and doesn't scale with chats, transcripts or worktrees. No existing gate was removed or loosened.
Sync fs or SQLite on Electron main
Matched and disproved.getBotRequest is a primary-key lookup on main, bounded by the newest turn's anchors, once per qualifying worker-start. That is not per keystroke, per poll or per status update. The journal read itself runs on the reader worker.
Per-entity state outlives the entity
No matching code. No new Map, Set or listener; the "new map" doesn't exist (see Scope).
Fixed-cadence poll / new idle wakeups
No matching code. No timer, interval, rAF or subscription.
Subprocess per item or per event
No matching code. No child processes spawned.
Unbounded fan-out or queues
No matching code. One RPC per command, awaited, no retry loop.
Re-reading unchanged input
Matched and disproved. One read per call, the command doesn't repeat it, and a later worker-start is a new decision.
Update published when nothing changed / whole-snapshot publish
No matching code. The handler is read-only and emits nothing.
Eager startup imports
Matched and disproved.connector.ts now imports bot-turn-origin and bot-wake-reply-place. Both are internal; bot-turn-origin is already on the RPC graph through bots-items-add.ts, and bot-wake-reply-place only pulls slack-mirror-state, which the Slack connector code already uses. The new CLI imports (agent-session-caller-env, agent-view) are existing CLI modules. No SDK or adapter is added.
Six questions
Unused work before the skip gate: reviewed. The cheap in-memory gates (bots enabled, botOfSession, caller match, delivered, target shape, Slack thread, not a DM) all run before the only expensive step, readOrigin. The CLI skips the RPC entirely when there is no session id.
Ownership multiplying work: reviewed. One call per CLI start, with no per-row, per-pane or per-worktree owners and no listeners.
Which thread pays: reviewed. The CLI pays one awaited round trip. Main pays O(1) in-memory lookups plus a few primary-key SQLite reads. The journal window read runs on the reader worker.
What grows: reviewed. The read is capped at the newest turn (latestTurns: 1, widen=false, so no widening loop) and has no retry. Nothing grows with history, chats or worktrees.
Execution host: reviewed. On remote or SSH routes it adds one round trip per worker-start, which is a one-time cost per command. A remote host that doesn't know the session refuses or fails, and the CLI treats that as null. Behaviour is the same on mac, Linux and Windows; there are no platform probes or spawns.
Obsolete work stops: reviewed. The work is a single awaited request inside a short-lived CLI process, so nothing is left behind. The .finally only writes to stderr and holds no handles or timers.
Evidence and gaps
All counts above come from reading the source. I did not take runtime timings or profiles, and I make no millisecond claims. The paths I examined were the CLI worker-start, the main RPC handler, the connector seam reads (replyTarget, deliveredTurn, conversationTurn), readBotTurnOrigin → readNewestBotActingTurn → operationWindow, and session-caller resolution. The one remaining unknown is the reader worker's latency for operationWindow on a very large journal. That cost already exists through bots-items-add and is indexed and capped at one turn here.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Performance scan (independent reviewer, head ae552bf)
Findings
None. I found no P0 or P1 perf regression in this diff.
I compared head ae552bf059a against base origin/main0025e661ff7, using git diff origin/main...HEAD. All citations are to head code. My evidence comes from reading the source and counting the work per trigger. I did not run the app or take timings, so I make no millisecond or CPU claims.
New work: trigger, population and bound
CLI orca orchestration worker-start makes one new RPC call (src/cli/orchestration/workers/worker-start-wake-note.ts:12-27, called at worker-launch-handler.ts:36).
Trigger: once per worker-start call made from a process that has ORCA_AGENT_SESSION_ID set. Any other process returns at :14-16 and makes no call.
Population: every agent session's worker starts, not just bot sessions. At the reference fleet (100+ agents, a dozen calling the CLI every few seconds), worker-start is a small share of those calls. The worst case is still 1 RPC per start.
Bound: one sequential round trip before the start is sent, on the local socket or on the transport to a paired or SSH host. It is capped at 5 s (WAKE_NOTE_TIMEOUT_MS), and a failure becomes null.
What doesn't happen: it never loops or retries, and the .finally only writes stderr once.
Cost: one extra round trip per worker start, paid on the CLI process. It does not repeat and does not grow with fleet size. The 5 s worst case needs the host to be unresponsive, and in that state the orchestration.workerStart call that follows would stall too.
Main-process handler connector.wakeReplyPlace (src/main/runtime/rpc/methods/connectors/connector.ts:125-144), which runs on Electron main.
Production callers: only the CLI path in item 1 (I grepped src for wakeReplyPlace).
Gates, in order:
If bots.enabled() is false, the handler stops.
botOfSession (src/main/bots/bot-session-tabs.ts:16): a getConversation lookup plus bots.list().find(...), linear in the bot count (a handful).
The caller session must match sessionId, or it returns {place:null}.
Bot sessions only:
seam.replyTarget → findLinkForPane. This uses the cached link index in external-conversation-link-index.ts:259-272, which is invalidated on writes and already shared with connector.reply and others.
chats.turnOf and turnOpener, which existing reply paths already use.
deliveredTurn → chatDeliveries.pending, two Set/Maphas checks (external-conversation-chat-delivery.ts:120-122).
Cost before the expensive gate: O(1) map lookups plus O(bots).
wakeReplyPlace (src/main/bots/bot-wake-reply-place.ts) is a pure function. It runs synchronous checks first: delivered, answerDeliveryId, own bot, Slack source, then slackPlaceOf, a single split(':') plus regexes (slack-mirror-state.ts:104), and the thread / not-DM check.
Only once all of those pass does it call readOrigin().
About "the new map": this file has no Map, Set, listener, timer or module state, so nothing is retained per entity.
readBotTurnOrigin (.../orchestration/messaging/bot-turn-origin.ts:16) is an existing function with an existing caller (bots-items-add.ts:95).
New reach: it is now also called from item 2, but only for a bot thread chat on Slack (not a DM) whose current turn came from a connector delivery, once per worker start.
Work:
readNewestBotActingTurn(..., widen=false) does one operationWindow({latestTurns:1, turnShape, anchorsOnly, indexedOnly}).
With widen=false, it passes newestTurns=null to readBotActingTurnWithin, so it settles on the first pass (bot-acting-turn-read.ts:25-46) and does not widen 1→4→16.
It does one db.getBotRequest / botRequestActsFor primary-key lookup per request id in that single turn.
Bound: the anchor rows of one turn. It does not depend on chat history size, transcript count or worktree count.
Failure handling: a JournalWindowNotIndexed throw is caught (.catch(() => null)), and the start does not retry it.
Caller-identity resolution. Adding connector.wakeReplyPlace to CONNECTOR_POST_METHOD_NAMES puts it in SESSION_EVIDENCE_METHODS on both the CLI (orchestration-compatibility-envelope.ts:41) and main (orchestration-session-caller.ts:67). That adds the existing per-request session-caller binding once per call of item 2, so it has the same trigger and bound as items 1–2.
bot-preamble.ts rule text: two rule strings grow by about 250 bytes in total. They are constant-size string literals built where the preamble is already built. There is no new trigger, and the size does not grow with any fleet dimension.
Regression classes the diff touches
Class
Disposition
Sync fs or SQLite on Electron main
Matched and disproved.getBotRequest primary-key lookups and an indexed one-turn journal window run on main. They are reached once per worker start, only for a bot Slack thread turn from a delivery, and bounded by one turn's request ids. Nothing runs per poll, keystroke or status update.
Expensive code newly reachable past a gate
Matched and disproved.readBotTurnOrigin gets a new caller. It sits behind 8 cheap gates (bots enabled, bot session, caller match, delivered, answering delivery, own bot, Slack thread, not a DM) and uses the existing unwidened single-turn read. With the old code as the control, base made 0 calls of this per worker start and head makes at most 1, bounded by one turn's rows at both N and 10N.
Per-entity state outlives the entity
No matching code. The diff adds no Map, Set or listener, including in bot-wake-reply-place.ts.
Fixed-cadence poll / new idle wakeups
No matching code. There is no timer, interval or subscription. The 5 s value is a per-call RPC timeout, not a schedule. Idle wakeups per second are unchanged before and after: main 0→0 new, renderer 0→0, daemon 0→0.
Re-reading unchanged input
Matched and disproved. Each worker start makes one read. The trigger is a user or agent command, not a poll, so caching wouldn't save repeated work.
Subprocess per item or event
No matching code. The diff spawns no process.
Unbounded fan-out or queues
No matching code. Exactly one call is in flight per CLI invocation.
Eager startup imports
Matched and disproved. The new imports in connector.ts (bot-turn-origin, bot-wake-reply-place) are modules already in the main graph (bot-turn-origin is already imported by bots-items-add). slack-mirror-state is shared and already loaded. The CLI import (agent-session-caller-env, agent-view) is already in the orchestration graph. No SDKs are added.
The renderer and store classes (store writes, selectors, per-row derivation, streaming, publish) have no matching code: the diff touches no renderer code.
Six questions
Unused work before the skip gate: Reviewed. Every cheap gate runs before the journal or SQLite read (bot-wake-reply-place.ts:18-30). For non-bot sessions the handler stops at bots.enabled() / botOfSession. On the CLI, processes without a session id make no RPC. One small waste: the RPC runs before refuseAgentServerRoute (worker-launch-handler.ts:36-37), so a refused route still pays one round trip. That is once per command and never repeats, so it is not a finding.
Ownership multiplying work: Not applicable. There is no per-row, per-pane or per-mount owner. Each command runs it once.
Thread and storage layer: Reviewed. The handler runs on Electron main. It does O(1) index lookups, then at most one single-turn indexed journal window and a few node:sqlite primary-key lookups, only on the gated bot Slack thread path. The CLI side is async with no sync I/O.
Growth and progress: Reviewed. Cost does not depend on worktrees, transcripts, history bytes or refs. The unwidened read is fixed at 1 turn, and there are no retries or cursors.
Execution host: Reviewed. For remote, paired or SSH hosts it costs one round trip, capped at 5 s. An older host without the method fails fast and returns null, with no per-item round trips. It is not platform-specific.
Obsolete work stops: Reviewed. On timeout the CLI stops waiting and nothing is kept: the .finally closure only holds a string. On main, a late handler completion runs to its bounded end and keeps no state.
Coverage and residual gaps
Paths examined: the CLI worker-start handler and its note reader, the connector.wakeReplyPlace handler, botOfSession / botOfHomeWorkspace, ExternalConversationSeam.replyTarget / deliveredTurn, ConversationEvents.replyTarget, the link index cache, chatDeliveries.pending, slackPlaceOf, readBotTurnOrigin → readNewestBotActingTurn(widen=false) → readBotActingTurnWithin, the caller-evidence method sets, and the preamble rules. Hosts: local main, with the remote/SSH transport reasoned from source.
Residual gaps:
I did not measure the one-turn journal window or the RPC round-trip latency (I made no runtime measurement).
I did not inspect operationWindow's internal SQL, which is pre-existing and shared with bots-items-add.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…schema (#50170)
* fix(i18n): drop the stale Traditional Chinese MCP remove message on the phone
#49475 replaced mobile mcpServers.removeMessage; #50002 then translated the old key, failing mobile locale validation on main.
* fix(connectors): build the wake reply place schema lazily
#49406 added an eager schema to connector-params.ts while #50160 set its ratchet baseline, failing ratchets on main.
joei4cm
added a commit
to joei4cm/orca
that referenced
this pull request
Nov 27, 2026
stablyai#49406 added this schema bare on top of stablyai#49897's lazy migration, leaving
the eager-schema ratchet one over baseline: every PR touching src/main or
src/shared now fails the ratchets job. Wrap it like its siblings.
Co-Authored-By: Claude Code <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Someone asks a bot in a Slack thread to do something. The bot starts a worker in the background and ends its turn. Later the background command finishes, for example because the worker failed to start, and the bot wakes up in a new turn on its own. Orca doesn't post anything from that turn to Slack, but the bot's rules said "your final message is posted there for you", so the bot thought the thread had heard it. It hadn't.
Now the bot is told the truth. A turn that starts on its own stays in Orca. If the bot wants the thread to hear something, it posts the message itself with Orca's reply command, and when it starts a worker it is told which thread that start came from. The bot decides whether to post and what to say; Orca still posts nothing on its own.
This is the first stage and covers Slack thread chats. Slack direct messages are a planned later stage.
What Changed
orca bot replyis how anything from it reaches the thread.orca orchestration worker-startrun from a bot's Slack thread chat prints one line to stderr:[Orca: this start came from <thread>. A turn that starts on its own when this command finishes in the background stays in Orca; orca bot reply --text "..." posts there.]--onstarts alike, because the command runs on the bot's own computer.connector.wakeReplyPlace, caller-verified like the other connector post methods. Older hosts lack it, and the CLI then prints no note.bot replyalready works in a thread chat's self-started turn. Orca's checks pass, and the connector service posts it as a plain message in that thread. Nothing else posts on its own.Why
The rules told the bot its final message is always posted, which is false for a turn it started itself, so a failed worker start reached only Orca. Orca can't tell what in such a turn is safe for the thread, so it still posts nothing by itself. Instead the bot is told the fact and the thread, and it decides. The thread is taken when the start happens, from the record items already use, and never guessed later.
The chat's history alone can't tell what started a turn: a turn that starts on its own looks as if the last message started it. So the note also requires Orca's own record of which messages reached the running turn.
Linked Issue
Internal item; no public issue.
Visual Proof
No UI is added. The new text is one line in a CLI result, which the bot reads in its chat's tool output, plus two rule sentences. Below is the real chat tool line, rendered with the real CLI output from this branch (light | dark).
Worker-start note in the chat's tool line (3 cases) and the rules text
Thread proven: the note is shown. The note prints first, before the receipt, because it is written when the start call settles.
Worker started:
Worker failed to start (the case this fixes):
Thread not proven, or an older Orca host: no note. The output is exactly as on main today. Both cases look the same.
Rules text the bot reads (added sentences):
orca bot reply ….":Testing
connector-wake-reply.test.ts: the thread is named only for a turn a delivery of that thread started, with Orca's delivery record set and a matching origin, asked by the chat itself. It is not named for a self-started turn, another channel, another chat, the bot's Chat, or a DM. Each of those checks makes the test fail when it is removed.The connector service side was checked with a throwaway test against its current source: a reply for a turn it was never told started posts into the thread.
Reviewer steps:
pnpm test src/main/runtime/rpc/methods/connectors/connector-wake-reply.test.ts. Platforms: macOS (tests). The change has no platform-specific code; Linux and Windows are covered by CI.Known limits:
orca orchestration worker-startprints the note. Another background command gets only the rules fact. In a thread chatbot replystill reaches the chat's own thread.Performance
None, because the new work runs once per worker start from a native chat. It is one RPC: a session lookup and, for a bot's thread chat whose turn a Slack delivery opened, the same bounded newest-turn read that adding an item already does. There are no timers, polls, stored state or renderer changes.
Risk
Low. The worker-start note is printed only when every check above passes, so the failure mode is a missing note, not a wrong thread. The rules change is text the bot reads. Older hosts print no note. A plain revert undoes it.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)