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
Ask an Orca bot to leave a Slack thread; @mention it to bring it back - #47428
Before: once a bot was following a Slack thread, every reply in that thread went to the bot. There was no way to tell it "you're done here": asking it to stay quiet still woke it for every later reply, and Stop only ends the current answer.
After: someone who can already ask the bot says so in their own words, in that thread: "leave this thread", "you can stop following this one", "shh, you're done here", in any language, even with other things in the same message. The bot does whatever else they asked, then leaves. Orca itself posts one line in the thread: "I've left this thread. New replies here won't reach me unless someone @mentions me." From then on, replies in that thread don't wake that bot. An @mention brings it back, and it answers as usual.
It is only that bot and only that thread, and it stays that way after Orca restarts. A question about leaving, "don't leave", quoted or pasted words, a message to another bot, or text the bot read somewhere never makes it leave. Orca checks who asked before it saves anything: only a person who can ask the bot in that thread (or the owner typing in Orca) counts, never another app, another bot, an automation or a worker's report. If Orca can't save it, nothing changes, no confirmation is posted, and the bot says it is still in the thread.
Files
Added
Deleted
Net
Test
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1171
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1171
Prod
54
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1873
$\color{#cf222e}{\Huge{\mathbf{−}}}$118
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1755
What Changed
The action.orca bot reply --leave-thread (new RPC connector.leaveThread, connector-leave-thread.ts). The agent names nothing; Orca finds the bot, the thread and the turn from its own records:
an enabled bot's chat, not a look-around or tidy-up run;
the chat answers a Slack channel thread this bot follows (DMs, GitHub and Linear are refused);
a turn is running now, and every message in it is from a person who can ask the bot in this thread (owner or member, not an app or a bot writing for someone, message in the same thread), or is the owner's own send typed in Orca (bot-leave-thread-authority.ts). Orca's own continue after a restart or a usage limit is not the owner's send, so it never inherits a cut-short turn's request. A message the owner queued while the bot was busy can't be told apart from an automation's here, so it is refused and they ask again;
a batch counts only if Orca marked, when it delivered it, that every message of the batch passed the same check (leaveEligible on the delivered message);
only the running turn counts: a worker's report or another bot's answer that woke the chat never borrows the person's earlier request.
The save. It runs in the thread's queue, ordered with the thread's deliveries, and is flushed to disk before the command answers. The thread's link keeps both facts in one write: the bot left, and the turn whose confirmation is owed. A failed save puts the old values back and is refused (thread_mute_not_saved); a save whose outcome is unknown keeps the leave (disk may hold it) and answers that Orca couldn't confirm it. From the moment the bot asks, replies in that thread wait for the leave to save or be refused, so none slips past it and a failed save never swallows one. A second call in the same turn answers "already" only once the leave is on disk, and owes nothing more; after an @mention in between, it leaves again.
The confirmation. Orca writes it, never the agent, and posts it as its own message right after the turn's answer (external-conversation-leave-lines.ts). It waits until the cloud has taken that answer: the turn's end, or its reply still in the reply outbox, or an answer held behind the owner's failed mirrored post; after a restart too. It is retried with one reply id, so it posts once, and only while the thread is still left: an @mention clears what is owed. If Orca quit or was signed out before it posted, it posts the next time Orca's connection to the thread starts. It never posts on a cloud that doesn't mark mentions, or before the cloud has said whether it does.
Which clouds. Only an @mention brings the bot back, so a bot leaves only on a cloud that marks a reply mentioning it (it lists sends.mentioned). Elsewhere the command is refused, nothing changes, and a thread already left lets its replies through.
The gate (unchanged from before): in a left thread, a reply that doesn't @mention the bot starts no turn and none of its matched automations. A person's @mention clears it on disk, then goes to the bot as one turn with its follow-ups. Other apps' and bots' mentions never clear it.
What the bot is told (bot-preamble.ts): one Tools line. Run it when the person asking wants it to leave, in any words or language; do the rest of what they asked first; don't say it left (Orca does); don't run it for a question, a "don't", quoted, pasted, forwarded or code text, a request to another bot, or earlier or fetched text; if it fails, say plainly it is still in the thread.
Removed: the exact-phrase recognizer, its 🔇 reaction, and its batching exception.
Why
Nobody in Slack can know a magic phrase. The person's own words go to the bot as they do today, and the bot judges what they meant, as it does for any other request. What leaving can do is bounded and checked by Orca: one bot, one thread, only from a turn a person in that thread asked for, saved before anyone is told, and undone by any @mention. If the bot misreads a person's message, the worst case is that one bot goes quiet in one thread, the thread says so, and an @mention undoes it.
Linked Issue
None.
Visual Proof
A mixed request, a failed save, and two messages that aren't requests to leave (real agent replies; Slack layout simulated)
Every bot reply is verbatim from the real-agent eval; the confirmation line is the exact text Orca posts. A live Slack thread can't be driven from the test machines.
Testing
I manually tested these changes locally (real agents through the real CLI and bot instructions, below; macOS)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
bot-leave-thread-authority.test.ts: one hardcoded table over real journal rows decides who may leave. A member or the owner asking in the thread, or the owner typing in Orca, is allowed. Refused: another app, a bot writing for someone, an unknown person, a message from another thread or for another conversation, a worker's report after a person's turn, an automation's run, a batch Orca didn't mark, a person and an app in one turn, a recalled memory, a finished turn, and a running turn no message opened.
connector-thread-mute-admission.test.ts runs the real command against a real store in a temp directory, with real delivery receipts. Only the agent's turn and the chat's journal are stand-ins.
After leaving, the link reads left after reopening the store; the thread's other bot and the bot's other thread stay as they were.
An unmentioned reply starts no turn, even resent; an @mention brings it back as one turn.
A second leave in the same turn answers "already", and one line is posted.
No line once an @mention brought it back.
A failed save is refused, posts nothing, and the next reply still wakes it.
connector-thread-mute.test.ts: the gate's step table, and ordering through dispatchBatch (a mention's follow-ups stay one turn, Stop takes a held batch down, a muted thread woken mid-batch never deadlocks).
external-conversation-thread-leave-turn-end.test.ts drives real turn ends: the answer goes out as the agent wrote it, the line posts once after it on both answer paths and for a failed turn, and is dropped when an @mention lands first, including while the turn is being read.
Real agents: Claude (Opus 5.5) and Codex (gpt-6.2-sol) ran 24 cases 3 times each through the real orca CLI and the bot's real instructions, against a stand-in host. All 72 runs pass on both. They left for six plain ways of asking, a request mixed with other news, "summarize, then leave", Spanish and "shh, you're done here". They stayed for "how do I…?", "would you…?", "don't leave", quoted, code, forwarded and passed-on words, a request to another bot, earlier catch-up and a fetched issue telling bots to leave. They never tried to leave in the owner's Chat or on GitHub. When the save failed or was refused, both said plainly they were still in the thread.
Performance
None that runs often. A reply to a muted thread does one indexed link read before the agent (as before); a leave reads the chat's last two turns and saves one link; a turn end does one link read and, for a turn that left, one save. A line that can't post retries six times over about two hours while a client runs, then waits for the next connection; nothing runs while idle. A perf scan at the final head is on the PR.
Risk
Level: Medium
The riskiest part is the gate before the agent: a bug there could keep a bot silent in a thread where it should answer. It only acts on threads a bot was asked to leave, an @mention always clears it, and on a cloud that doesn't mark mentions it stands aside. The leave itself is bounded to one bot in one thread from a turn a person there asked for. Saved data: two optional fields on the thread's link, which an older Orca ignores (the bot is then woken as before). A plain revert backs it out; a thread left before the revert is woken normally after it.
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
Known and accepted: a line owed when the chat closes mid-turn posts at the next connection; a crash between saving the leave and its turn's end loses the line (never a false one); a line whose turn end the cloud never takes posts about 10 minutes later.
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)
I reviewed the PR's own changes (three-dot diff against main, 51 files). The two-dot diff also shows one newer main commit (the Share dialog skill listing change). That commit isn't part of this PR, so I didn't grade it here. All evidence is source-proven counts at this head. The four new test files pass (40 tests). No runtime timing was measured.
2 point reads on the receipt primary key on main. run already did 1 of these, so this adds about 1 per send. Rate is human message rate.
handleThreadMute
each Slack-thread send
Slack bot threads only (DMs and other sources return at the id check)
1 split, 2 map lookups, 1 indexed findLink. A muted thread adds 1 queued chain item and 1 receipt row (connector.mute), the same as a normal send already writes, minus the turn.
Held batch (heldBatch) and the refused-first recursion
a batch whose first send is held, or a refused head
at most maxDeliveriesPerPoll = 20
O(n) chain items. The recursion costs O(n²) filter steps, which is ≤ 400 at n = 20.
Unmute save
a person's @mention in a muted thread
per mention
1 link write and 1 incremental flush (drainToStableGeneration: false, not a full checkpoint)
connector.leaveThread RPC
orca bot reply --leave-thread, at most once per request
per leave
1 operationWindow({ latestTurns: 2 }) journal read. leaveThreadRefusal is O(items × submissions) inside that 2-turn window. Then 1 link write and 1 flush. Already-left returns before any read.
turnLeave
each linked chat's turn end
linked conversations
1 indexed readThreadMute lookup. The rest runs only when a line is owed. proseNow runs once per fill.
leaveLines.settle
a line carried or posted
per owed line
1 link write and 1 flush
leaveLines.resume
each seam watch (client start and each hello answer; hellos are event-driven, not periodic)
allLinks from the cached link index
O(links) field checks, next to the existing flushHeld/restartCuts passes on the same callback. Per owed line it does 1 outbox read (carriedIn) and then 1 post. With nothing owed it reads nothing further.
Retry timers
a line the cloud didn't take
per owed line
RETRY_MS has 6 steps, ≈111 min in total, then it stops until the next watch. Timers are unref'd. Each try first checks owed and cloud(). A reconnect wake leaves its old timer behind, but that timer exits through the mine === tries check.
Ending hold timer
a watch while a turn end decides
per ending line per watch
1 one-shot timer of ≤ 10 min. post is deduped by posting.
Mirror post re-read
each mirror post
per post
1 indexed linkOfSession lookup
Maps and listeners
saving (module): one entry per thread while its flush runs, removed in finally.
reserved: one entry per leave RPC in flight, removed on release in finally.
waiting: one entry per thread while a held reply decides, removed when it settles (only if it is still the same promise).
posting: one entry per owed line, removed on every terminal path. The reply promise settles when the client stops.
ending: one entry per line being decided, removed on post or settle, and pruned after 10 min at each resume.
Chain lanes: after goes through enqueue, so lanes are still removed when idle.
Listener census: no new persistent listeners, store subscriptions, IPC channels or publications. after adds 1 transient abort listener per queued item and removes it in finally. installLeaveLines holds one process singleton.
Idle wakeups per second, before → after: main 0 → 0, renderer 0 → 0, daemon 0 → 0 with nothing owed. With an owed line and a failing cloud, there are at most 6 one-shot timers per line, then 0.
Regression classes touched
Fixed-cadence poll: disproved. The retries are a finite ladder; there's no interval.
New idle wakeups: none at idle.
Sync SQLite on main: matched. The extra reads are primary-key point reads per delivery, at human rate.
Whole-file rewrite: the flushes are incremental, one per leave, unmute or settle.
Per-entity state: every map above is cleared in the same teardown.
Unbounded fan-out: the batch is capped at 20.
Re-reading unchanged input:resume uses the cached index, and does outbox reads only for owed lines.
Expensive code past a gate: no gate was removed. carriedIn can start the chat host early, but only when a line is owed after a restart, and the line needs that host to post anyway.
Six questions
Work before the gate: reviewed. Non-Slack and unmuted sends pay at most 2 point reads and 1 index lookup.
Ownership: reviewed. There's one leaveLines per seam and one mute deps object per connector cloud. Nothing is created per row or per pane.
Thread and storage: reviewed. The reads and flushes run on main at human rate. The journal and outbox reads go through the journal reader.
Growth and progress: reviewed. resume is O(links) per hello, the same as the existing passes. Retries advance and then stop.
Host: not applicable. All of this is local main-process code with no SSH or WSL work per item.
Obsolete work stops: reviewed. A Stop settles queued work unrun and removes its listener. Retry timers check owed and cloud(), then exit.
Gaps
No fake-timer test bounds the retry ladder; the bound comes from the source.
I didn't measure how long a leave RPC waits in a thread's queue behind earlier work. That's latency, not repeated work.
Surfaces flagged by the detector: hot-path, startup-migration. Every new or changed piece of work below has its trigger, population, and bound. Fleet sizes used: 750+ worktrees (10×: ~7,500), 100+ agents, up to 20 deliveries per poll (the contract maximum).
Work
Trigger
Population
Bound / cost
Mute gate (handleThreadMute)
Each incoming send
Slack thread sends only, at most 20 per poll
O(1): an id split, two map reads, one indexed findLink (link index is cached and invalidated on writes), no scan. Not muted, a DM or not a bot: returns null, same path as before
receipts.heldByMute + receipts.known
Each incoming send
Same
2 primary-key SQLite point reads on main (mutation_receipts PK is (caller_fingerprint, request_id)). Grows with sends, not with fleet size or history
receipts.admits
Each run
Same as before
Refactor of the existing check: the same read and count
Held batch (heldBatch) / re-batch after a refused first send
A poll whose first send is held or refused
≤ 20 sends
≤ 20 dispatches and one promise link per send. The worst-case filter work is O(20³), a fixed bound
One queued item per reply plus one abort listener, removed in finally. Released when the save settles
saving / reserved / waiting maps
Mute save, leave RPC, a deciding reply
Saves in flight
Removed in finally, on release, or on settle (identity-checked). Back to empty at rest
Turn end (turnLeave)
Each linked conversation's turn end
Linked chats only
1 to 2 indexed findLink reads plus one byteLength of the prose, only when a line is owed. No scan over the fleet
Reply fill proseNow / answered
Each fill
Rows of one turn
One extra owed check, plus some over that turn's own fills
Leave RPC (connector.leaveThread)
An agent calls orca bot reply --leave-thread
One per leave
One journal operationWindow({latestTurns: 2}) read. Eligibility work is O(items × submissions) within 2 turns. Then one link write and one store flush. Paced by a person asking
Unmute / owed-line settle
A mention, or the line posting
One per thread event
One link write and one flush each; skipped when nothing changed (writeLinkFact returns false)
Resume owed lines (lines.resume)
Each connector watch (client start or hello answer, not per poll)
Iterates the cached allLinks array (no index rebuild; the existing watch already snapshots every link)
O(links) iteration, sub-millisecond at 10× fleet. Per owed line: one outbox read for that session on the journal reader (off main). Owed lines are only muted threads whose confirmation hasn't posted
Retry timers
A confirmation post that fails with a retryable error
One per owed line
Unref'd setTimeout at 15 s, 1 m, 5 m, 15 m, 30 m, 60 m, then stops (≤ 7 attempts) until the next watch. One attempt in flight per line (posting map). A wake and its timer firing together run only one attempt. No client: drops with no timer. Cloud lacks the mention feature: settles. Turn-end hold timer: ≤ 10 min, one-shot
ending map
Turn end with an owed line
Owed lines
Deleted on post or settle; entries older than 10 min are pruned on each resume
Slack mirror re-read
Each mirrored post
Mirrored chats
One extra findLinksForSession lookup (indexed)
Listener census / idle rate: there are no new persistent subscriptions, publications, IPC channels or store listeners, and no renderer files changed. The only new listener is one transient abort listener per chain.after item, removed on settle. Steady idle wakeups per second (main, renderer, daemon): base 0 → head 0. Timers exist only while a confirmation is owed and failing, and they decay to none within about 2 h.
Startup / migration: no schema change. connector.mute is a new value in an existing TEXT column, and the link and journal parsers gain optional fields only. There are no new eager imports of SDKs or adapters.
Regression classes: fixed-cadence poll (bounded backoff that stops: disproved), new idle wakeups (0 → 0: disproved), sync SQLite on main (PK point reads per send, not per fleet item: disproved), per-entity state outliving its entity (all maps cleared on settle: disproved), whole-file rewrite per change (one flush per human-paced mute event, with an equal-content skip: disproved), unbounded fan-out (batch ≤ 20, one post in flight per line: disproved). Other classes: no matching code.
Six questions: (1) the gate admits before any work; non-muted sends cost O(1). (2) One deps object per cloud; no per-row owners. (3) Main pays O(1) indexed reads; the outbox read goes through the journal reader. (4) Retries move forward through the backoff list, and resume is keyed by turn. (5) Host-independent; no subprocess or SSH calls. (6) Stop and abort release queue waiters and listeners, and saves release their map slots.
Evidence: source trace at this head plus the PR's mute, admission, leave-turn-end, receipts and leave-authority tests (5 files, 46 tests pass). Timing was not measured; the impact above is stated as counts.
Findings: none. No P0/P1. All new work is main-process only and runs per Slack delivery, per bot turn end, per leave call or per connector watch start. None of it grows with the fleet on a repeated trigger, and it adds no idle wakeups.
New or changed work (trigger → work → bound)
Per send delivery (inbound Slack reply, fleet-wide a few per second at most): heldByMute and known each do one primary-key receipt lookup, plus one indexed findLink in handleThreadMute. A non-Slack, DM or unmuted thread exits there. A silenced reply writes one receipt (connector.mute) and starts no turn, which is cheaper than the turn it replaces. admits is the old gate moved into a helper and runs the same queries. Constant per delivery.
Per held batch: heldBatch builds one promise chain per later send. A batch whose head is refused recurses into dispatchBatch with O(n) per level, so O(n²) slice work for n same-asker sends in one thread's poll. n is small, and this branch only runs on a refusal.
Per bot turn end: turnLeave makes one or two indexed readThreadMute lookups. proseNow adds one string join when a line is owed. settle posts or parks the line. When nothing is owed, the cost is one map lookup per turn end.
Per accepted event batch: turnEndsTaken(batch.filter(isTurnEnded)) scans the batch once more, after trace.accepted and replies.accepted already scanned it. The batch is capped by event limits. At 100 events/s that is about 5 µs/s. Not a finding.
Per leave RPC (agent-initiated, rare): one operationWindow({latestTurns: 2}) read (bounded), one queue slot, one link write plus one async flush, and one index rebuild on the next read. A repeated leave waits for the save already in flight and then does one indexed read.
Per watch start (each hello answer, so connects and reconnects under backoff): resume walks the cached allLinks array once with only field checks. The snapshot built on the same watch already walks every link and reads a hook row for each, so this adds less than that existing walk. Each owed line costs one outbox read for its session (carriedIn), which waits for the chat host to start. That only happens when a line is owed after a quit.
Retry timers: each owed line runs at most 6 unref'd timers (15 s to 60 min, about 111 min in total), then stops until the next watch. afterTurnEnd('end') sets one 10-min fallback timer per leave. resume sets one timer per owed line whose turn end is still deciding. With no leave pending there are 0 timers. Verified: the admission test fails 7 times and sees exactly 6 timers, then 0.
Maps: saving and reserved (per thread, removed in finally or on release), waiting (removed on settle), posting (removed on every exit), ending and afterEnds (removed on post, take or timer; the resume sweep drops anything older than 10 min). Each holds at most one small entry per leave or held reply.
Listener census / idle rate: no new subscription or publication. turnEndsTaken is a call inside the existing onAccepted callback, not a new listener. ConversationChain.after adds one abort listener per queued item and removes it in finally, and lanes delete themselves once empty. Idle wakeups/s on main, renderer and daemon: 0 before, 0 after. Under load, timers fire only while a line is owed and its post is failing (at most 6 over about 111 min).
Regression classes
Fixed-cadence poll / idle wakeups: matched, disproved. The retry ladder is capped (test above) and nothing runs when no line is owed.
Per-entity state outlives entity: matched, disproved. Every map is cleared on settle, take, timer or sweep.
Sync SQLite on main: matched, disproved. Two primary-key lookups per send delivery, a constant cost at delivery rate.
Hot-path rescans: matched, disproved. One extra filter per accepted batch and one cached link walk per watch.
Unbounded fan-out: matched, disproved. Each line has one attempt in flight through posting, and repeated resume calls only wake the existing retry.
Startup migration: matched, disproved. The schema only adds optional muted, leaveLine and leaveEligible fields, with no rewrite.
Whole-file rewrite: a mute or unmute or an owed line writes one link and flushes once per leave. Rare.
Six questions
Gates come before the work: DM, non-Slack and unmuted threads exit after one index lookup.
One leave-lines instance and one mute-deps set per process. Nothing per row or pane.
Main thread only: indexed link reads, primary-key receipt lookups and async flushes. No renderer changes.
Retries step down a ladder and then stop. The per-watch walk is O(links) with field checks only.
No host-specific probes. Slack only.
A Stop settles queued work. Listeners and lanes are released and timers are unref'd.
Bot prompt: one more line (about 700 B) in the bot preamble, a fixed size per bot turn.
Evidence: read the source at the head above. Ran connector-thread-mute-admission, connector-thread-mute and thread-leave-turn-end tests: 23/23 passed. No runtime timing was measured, so the impact above is stated as counts.
Verdict: clean. No P0 or P1 findings. Every new piece of work is triggered by a delivery, a turn end, a leave call or a hello, does a constant number of indexed lookups each time, and none of it scales with the number of worktrees, terminals or chats. There are no new idle wakeups.
Base 0b7fe2f6 (merge base), head 7fbea79f. Surfaces detected: hot-path, startup-migration. Everything runs on Electron main except the CLI flag.
New work, with trigger × population → bound
Per send delivery (connector-deliveries.ts:196-240): +2 primary-key reads on mutation_receipts (heldByMute, known), then handleThreadMute: one id split, two map lookups (waiting, saving/reserved) and one indexed findLink. All constant; there's no scan over links or receipts. Rate: the cloud's delivery rate (a poll page, reply events ≤100 ids). Not a finding: constant indexed work. The existing run keeps its query count (admits is a refactor of the same get+count).
Muted thread's send: it writes the same single receipt a normal send writes and starts no turn, so it does less work than before. A reply behind a deciding one takes one ConversationChain.after lane slot. Bounded by that thread's in-flight sends.
Held batch (connector-delivery-batches.ts:99-150): per later send, one dispatchDelivery plus later.slice(i+1). That's O(N²) copies with N = one conversation's run of sends in one poll page (≤ page size, typically 1-3). The new recursion when the head is refused before the seam does the same N dispatches. The late filter at deeper levels is about 0 because earlier levels already removed the expired sends. Not a finding.
Per turn end of a linked chat (chat-turns.ts:245, turn-ends.ts:141-196): turnLeave → owed = one indexed findLink; proseNow adds one more per fill; settle is a no-op unless a line is owed. Constant per turn end.
Per accepted events batch (connector-turn-events.ts:161): batch.filter(isTurnEnded) + one indexed findLink per turn end in it. That's the same O(batch) as the existing trace/accept work.
Per leave call (connector-leave-thread.ts): one journal operationWindow({ latestTurns: 2 }), so the authority check is bounded to 2 turns. One queue slot and one link write plus a profile flush. Triggered by a person asking a bot to leave.
Saves (connector-thread-mute-saves.ts): per leave or unmute mention, at most one writeLinkFact (skipped when the value is unchanged) + flushPendingOrThrowAsync({ drainToStableGeneration: false }). The flush clears the pending debounce timer and writes once, so it moves the already scheduled profile write earlier rather than adding one. A failed save writes once more to restore the previous value.
Per watch start (external-conversations-install.ts:140, fires once per hello answer: start, reconnect, bot change; not per poll): resume walks the cached allLinks array once (O(links), one field check each), prunes ending, and for each link that still owes a line and isn't running calls carriedIn: one ensure of the chat host (already ensured by any chat delivery) + one read of that session's reply rows. Owed lines are ≤1 per muted thread and exist only after a quit or a failed post. Not a finding: O(links) per hello at existing hello cadence, next to the snapshot the watch already builds.
Retry timers (leave-lines.ts): only while a line is owed and the cloud refuses it: 6 one-shot unref'd timers (15 s → 60 min, about 1 h 51 m total), then it stops until the next watch. One 10-min one-shot fallback per leave turn end, and one one-shot per ending line per watch. Duplicate timers collapse in post (the posting map, mine === tries). Nothing recurs at idle.
Maps: saving/reserved (module, per thread) are deleted in finally/release. waiting (per thread) is deleted on settle. posting is deleted on every exit path. ending is deleted on post/settle and pruned after 10 min on the next watch. All are bounded by leaves and sends in flight; no map is keyed by a worktree, tab or pane that outlives its owner.
Persisted: muted + leaveLine on a link (2 optional fields, cleared by unmute/settle). Optional leaveEligible on a journal message body (no migration; the zod schema only gained an optional literal).
Listener census and rates: no new store subscription, IPC channel, renderer listener or publication. The new listeners are one abort listener per ConversationChain.after item, removed in finally (so the count returns to 0), and one extra call inside the existing per-client events-outbox onAccepted hook. Link writes go through the existing worktree-meta write and its existing listeners (the incremental link index, the existing meta publication). Idle: 0 frames/s. Under load: one per leave, unmute or line settle, each a real change; writeLinkFact returns early on equal values, so 0 frames carry no change.
Idle wakeups/s (main, renderer, daemon): 0 → 0. All new timers are one-shot and only exist while a leave line is owed.
Regression classes: no-op store write — disproved (writeLinkFact equality skip). Fixed-cadence poll / idle wakeups — disproved (bounded one-shot retries). Per-entity state outlives entity — disproved (maps deleted with their thread/turn). Sync SQLite on main — 2 PK reads per delivery, constant, not a finding. Subprocess per item — none. Whole-file rewrite — disproved (one coalesced flush per leave/unmute/settle). Unbounded fan-out — disproved (batch ≤ page, one queue slot per send). Gated code newly reachable — disproved (carriedIn host ensure is already done per delivery, and only runs when a line is owed). Eager imports — none new outside already-loaded connector modules.
Six questions: (1) admission before work: the mute gate runs before the seam and agent; resume checks muted/leaveLine before any read. (2) ownership: one LeaveLines per process, one mute deps per connector cloud. (3) thread: main; SQLite PK reads plus one async flush. (4) growth: none with history or fleet size; retries stop. (5) host: no new host probes, SSH or subprocess. (6) teardown: a Stop refuses queued waits and removes their listeners; timers are unref'd and check owed first.
Evidence: source-proven counts at the head; the static perf audit on the changed production files shows no new warnings on changed lines. No runtime timing was measured, so the impact is stated as counts.
Scope: the shipped diff against main 0b7fe2f (43 files). Surface detector: hot-path ×5, startup-migration ×1 (connector.mute is a new receipt method value; the column has no CHECK constraint, so no migration). No publish, subscribe, timer, worker or version-bump surfaces.
New or changed work: trigger → population → bound
Per send delivery (dispatchDelivery, main): receipts.heldByMute + receipts.known = 2 primary-key receipt reads, then slackThreadBotUser (one split), 2 map gets and readThreadMute → findLink (link index, O(1)). That's a constant ~4 lookups per send, not per link or worktree. An unmuted thread holds nothing and queues nothing extra. admits() is the old inline check moved, same queries.
Muted thread's send: one receipt write (the same as a normal send) and one queue slot queued(). Unmute by @mention: one link write plus one dirty-domain flush. This happens at the rate people post in Slack.
Held batch (heldBatch): one dispatch per later send, the same as before. later.slice(i+1), plus the refused-first re-batch, comes to O(L²) cheap array ops for a batch of L. L is the same person's consecutive sends in one poll.
Per turn end (turnLeave): one owed() = one indexed findLink. ending/post run only when that turn left its thread.
Per RPC (connector.leaveThread): one journal operationWindow({latestTurns: 2}), so the window is bounded by 2 turns and not by history. Then one link write and one flush. A repeated leave makes one flush. Called at agent rate, once per request to leave.
Per accepted or dropped event batch (turnEndsTaken): a kind filter, then 2 indexed lookups per turn-ended/reply event. There's no scan.
Per connector watch (one per hello answer, watched → lines.resume): one pass over the cached allLinks array with O(1) checks per link. That's O(links), smaller than the snapshot over every linked conversation that the same watch already sends. It posts only owed lines (links that are muted and have leaveLine).
Per owed-line attempt: turnEndPending (a linear scan of the in-memory event outbox), heldByMirror (one link), and answerPending (one session's reply-outbox rows). These run only for threads that owe a line.
Retry timers: RETRY_MS holds 6 one-shot unref'd timers (15 s…60 min). After the last one, posting is deleted and no timer remains. The next watch starts over. A cloud known to lack sends.mentioned gets no timer at all. afterTurnEnd adds one 10 min unref'd one-shot per leave. resume adds one one-shot per entry still in ending, and post dedupes through posting.
Maps: saving/reserved (module) are deleted in finally/release, so they hold only saves in flight. waiting (per send gate) is deleted when its entry settles, so it holds only threads with a send deciding. Entries in posting are deleted on every terminal path. ending gets entries only for turns that left; post/settle delete them and resume prunes those over 10 min. All of these are bounded by leaves or saves in flight, not by links or history.
Listener census / idle
New listeners: ConversationChain.after adds one abort listener per queued item and removes it in finally, so it doesn't outlive the item. There are no new store, IPC or renderer subscriptions. installLeaveLines is a module singleton, not a listener.
Idle wakeups/s, main/renderer/daemon: base 0 → head 0. Timers exist only while an owed line is failing to post (at most 6 + 1, about 2 h, then nothing). Load: about 4 O(1) lookups per Slack send and 2 per taken turn-end/reply event. At the reference fleet (100+ agents, events more than once a second) that is far below 1 ms/s on main.
Regression classes touched
Fixed-cadence poll: disproved, because retries are finite and backed off.
New idle wakeups: none.
Sync SQLite on main: 2 PK reads per send (event-rate, constant).
Per-entity state outlives entity: all maps are deleted on settle.
Whole-file rewrite: one link write plus one flush per leave/unmute/posted line, at human rate.
Hot-path rescans: the per-watch allLinks pass is O(links), once per hello, bounded by the existing snapshot.
Unbounded fan-out: retries run one at a time per line via posting.
Six questions
Gates run before the work: an unmuted or non-Slack thread returns before any hold.
No per-row or per-pane owners were added.
Main pays: indexed lookups only, with flushes async through the existing writer.
Nothing grows with history. Retries make progress or stop.
Host-independent: no subprocess, fs or SSH calls.
A Stop refuses queued work, abort listeners are removed, and timers are unref'd and one-shot.
Evidence: source-traced counts above. vitest ran the PR's thread-mute admission, thread-mute, leave-authority, leave-at-turn-end and delivery-receipt tests: 5 files, 48 tests pass. No timing or CPU was measured. Residual: timing was not measured on a large real profile. The per-watch link pass is O(links) by source.
Findings: none. The latest change (a leave line whose answer is still pending now retries on its own wait schedule instead of waiting only to be woken; it rechecks that the line is still owed after looking for its answer) adds no idle work and no work that grows with the fleet.
Work added, with trigger, population and bound (reference fleet: 750+ worktrees, 100+ agents, thousands of linked threads; growth target 10×)
Work
Trigger
Population
Bound / cost
Mute gate before the agent (handleThreadMute)
each Slack send delivery
one thread
O(1): id split, 2 map gets, one link-index lookup; unmuted thread returns null with no write
Receipt lookups (heldByMute, known)
each send delivery
one receipt
+2 primary-key point reads on the orchestration DB; not scaled by worktrees, agents or links
Muted-thread reply
each reply to a muted thread
one receipt
one receipt begin/complete; replaces the turn the reply would have started (net less work)
Held batch chain (heldBatch)
a poll batch to a muted thread
K sends in one thread
O(K) promises plus O(K²) slice copies; K is bounded by one poll's deliveries
Leave RPC
one bot reply --leave-thread call
one chat
one journal window read (latest 2 turns, reader pool), a scan of that window, one link write plus one profile flush; a repeated call does one flush
Per-thread save maps (saving, reserved, waiting)
leave, unmute, deciding reply
threads saving right now
deleted in finally/release/settle; return to empty
Turn-end hook (turnLeave)
each linked turn end
one link
one index lookup; ending map entry only when a line is owed, removed on post or by the resume sweep after 10 min
turnEndsTaken
each accepted event batch, each dropped turn end
events in the batch
a kind check per event; lookups only for turn-ended/reply events; runs inside the existing accept callback
Line attempt
post / wake / retry timer
owed lines only (left threads whose line hasn't posted; normally 0)
per attempt: outbox.holds (bounded event outbox), one held-mirror check, at most one outbox read for the session (reader pool, never SQL on main), at most one reply HTTP call
Retry timers
after a pending/unanswered/failed attempt
owed lines
6 waits (15 s … 60 min, ~111 min total) and then it stops until the next watch; unref'd; a wake uses up the next slot, and the old timer fires as a no-op (mine === tries)
Watch-start resume
each hello answer (connect, reconnect with backoff, a feature/bot change)
all links
one in-memory pass (boolean checks); ~20k links at 10× is about milliseconds per hello, which only happens on connect, reconnect or a config change
Parser/schema fields
link parse, journal message parse
per row
2 optional link fields and 1 optional message field
Listener and idle census: no new IPC, store subscription, emitter or watcher. resume runs in the existing watched hook, and turnEndsTaken runs in the existing onAccepted/onDropped callbacks. The lane wait in chain.after takes off its abort listener in finally. Idle wakeups per second are 0 before and 0 after on main, renderer and daemon: timers exist only while a line is owed, and they stop after the last wait.
Regression classes screened: fixed-cadence poll (matched; the schedule is bounded and ends, and it wakes on the event when one exists); new idle wakeups (none); per-entity state outliving its entity (maps deleted on every attempt exit and on save settle); sync SQLite on main (2 point reads per send, constant); unbounded fan-out (none; at most one attempt in flight per line); whole-file rewrite per change (a flush only on a leave, an unmute or a posted line, all driven by people); newly reachable gated work (none; still gated on bot sessions and the cloud's mention feature).
Six questions: 1 the skip gate runs before any work (unmuted thread or non-Slack returns first); 2 there is one leave-lines owner per process and one attempt per line; 3 outbox reads use the reader pool, receipt reads are PK lookups, the flush uses the existing writer; 4 retries advance through a finite schedule, and resume is linear in links per hello; 5 no host-specific probes; 6 an @mention, sign-out or quit ends attempts (owed rechecked after every wait, no client → stop).
Evidence: source trace at this head. The leave-line admission and turn-end tests pass (19/19); they assert one live retry timer after each wake and no post after an @mention lands mid-check. No runtime timing was measured, so the costs above are source-proven counts.
Findings: none. No P0/P1. Nothing in this change touches the renderer, the daemon or any IPC publication. Every new piece of work runs on a user or agent event (a Slack reply, a leave, a turn end, a hello), is bounded by the number of muted threads that still owe a line, and stops once it finishes. Surfaces flagged by detection: hot-path, startup-migration.
1 journal operationWindow(latestTurns: 2) read, authority filter over that window (messages × submissions, both bounded to 2 turns), 1 lane item, 1 link write + flush; repeat leave = 1 flush
per call. reserved entry released in finally; not on any poll
Turn end (turnLeave)
each linked chat turn end
owed = 1 indexed findLink
O(1); does nothing else unless that turn left the thread
Leave line post (leaveLines.post)
turn end that owes a line, a taken batch, a watch resume
probe turnEndPending (scan of the event outbox), heldByMirror (1 findLink), answerPending (1 LIMIT 1 query using the (session_id, outcome, sent_at) index, run on the journal reader worker), then 1 cloud.reply
one in flight per (thread, turn) through posting; on success, settle writes the link once and flushes once
Retry timers
a line not posted (answer still pending, hello not answered, cloud error)
1 unref'd setTimeout
6 tries (15 s … 60 min, about 2 h in total), then it stops until the next watch. A wake and its timer don't both try (tries guard). Every exit path deletes the posting entry
afterTurnEnd fallback
turn end whose end event was just emitted
1 timer at 10 min
per owed line; post dedupes through posting
turnEndsTaken
each accepted or dropped events batch
per turn-ended/reply event: 2 indexed findLink
O(events in the batch); other event kinds are skipped by a kind check; posts only for owed lines
Watch resume (lines.resume)
each seam watch = client start + each hello answer
1 pass over the cached allLinks array (3 field checks per link), prunes ending entries older than 10 min, post per owed line
same O(links) order as the flushHeld pass and the snapshot that this watch already runs. 10k links ≈ under 1 ms per hello; hellos come on start, bot edits and reconnects (backed off)
Schema/parse
per link parse, per journal message parse
2 optional link fields, 1 optional message field
no migration and no user_version change; connector.mute is a new value for an existing receipt column
Maps:saving and reserved (thread-mute-saves): deleted in finally/release with an identity check. waiting: deleted on settle. posting: deleted on every exit. ending: deleted on post and pruned after 10 min on each resume. All are keyed per thread (and turn), and each thread owes at most one line at a time (leaveLine === turnId), so they don't grow with time or history.
Listener census and rates
No new subscription, publication, IPC channel, store selector or renderer code (0 renderer files in the diff). Listeners added: one abort listener per chain.after item, removed in finally. Existing onAccepted/onDropped callbacks gain a call, not a listener. installLeaveLines is a process singleton, not a subscriber.
Idle: 0 wakeups/s on main, renderer and daemon, before and after. Timers exist only while a line is owed and unposted, and they end after 6 tries.
Load: 0 new frames sent. Work per accepted events batch = 2 map lookups per turn-end/reply event. Exactly 1 outbound reply per posted line (the reply id is stable per thread and turn).
Regression classes touched
Sync SQLite on main: matched (2 PK reads per send). Disproved: constant per delivery and indexed, on an existing delivery path that already reads the same row.
Fixed-cadence poll: matched (retry timers). Disproved: finite backoff with an exit on success, refusal, no longer owed, or no client.
New idle wakeups: no match (0 → 0).
Per-entity state outlives entity: matched (5 maps). Disproved, see Maps above.
Hot-path rescans: matched (turnEndPending scans the outbox). Disproved: runs only per leave-line attempt (≤ 7 per owed line per watch), not per event.
Whole-file rewrite per change: matched (link write + flush). Disproved: once per leave, unmute or posted line, all human or agent events.
Unbounded fan-out: matched (held batch). Disproved: limited by batch size, and the thread lane serializes it.
Startup migration: no matching code (optional fields only).
Six questions
Unused work before the gate: reviewed. Unmuted sends pay 2 PK reads + 1 index lookup before returning.
Ownership multiplication: reviewed. One leaveLines and one muteDeps per process, not per row or pane.
Thread/storage: reviewed. Receipt reads are sync on main (constant). The unsent-answer probe runs on the journal reader worker. Flushes use the existing profile writer.
Growth/progress: reviewed. The resume pass is O(links) per hello; retries make progress through tries and give up after 6.
Host: not applicable. No subprocess, filesystem or SSH work is added.
Obsolete work stops: reviewed. A Stop settles the queued saves, live() drops ends after a reset, and the timers are unref'd and give up.
Evidence: source-proven counts only. Nothing was run on this head, so this report makes no timing claims. Residual: per-hello cost was estimated, not measured, on a 10k-link profile.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Result: PASS. I found no perf regression on this head. Surfaces: hot-path, startup-migration. Every new path is either point lookups or an indexed lookup on events that already exist, or it is limited by how many threads a bot has left. With no thread left, nothing runs at idle.
New or changed work: trigger, population, bound
Work
Trigger
Population
Bound
dispatchDelivery: heldByMute + known
each send delivery
all sends
2 more primary-key getMutationReceipt reads on main (sync SQLite, constant)
handleThreadMute → readThreadMute → findLink
each Slack-thread send
Slack thread sends; DMs and other sources leave after a string split
one Map lookup in the link index, O(1) in links; muted sends stop at one receipt txn, which is cheaper than a turn
waiting map, saving/reserved maps
send deciding / mute save in flight
threads with a reply deciding or a save in flight
removed in finally/settle, compared by identity, so no growth
dispatchBatch held/refused-first paths
each batch
batch size ≤ CONNECTOR_CLIENT_LIMITS
O(batch) promises, recursion depth ≤ batch
leaveEligibleBatch
each delivery to a chat
asker + later in batch
O(batch) string compares
turnLeave → owed
each turn end of a linked chat
linked turn ends
1 indexed findLink
turnEndsTaken
each batch the cloud accepts
events in batch
1 .then per batch; only turn-ended/reply events do 2 O(1) lookups
turnEndPending → outbox.holds
each leave-line attempt
outbox items (bounded outbox)
≤7 attempts per left thread
unsentAnswer SQL probe
each leave-line attempt
unsent rows of one session (sent rows are deleted)
LIMIT 1 on the (session_id, …) index, on the journal reader
connector.leaveThread RPC
one CLI call per leave
2-turn operationWindow
O(window items × submissions) once per call; 1 link write + 1 flush
lines.resume
each connector watch (client start / hello)
allLinks (cached index)
O(links) iteration, no I/O; posts only owed lines
Retry timers
owed line not taken
left threads still owed
6 waits (15 s → 60 min, unref), then stop until the next watch; one 10-min fallback per turn end; posting dedupes stacked wakes
ending map
turn end with a leave owed
left threads
deleted on post, pruned after 10 min on resume
SlackMirror re-read
each mirrored post
1
findLinksForSession, indexed
Listener census: no new store/IPC/renderer subscription and no new publication. ConversationChain.after adds one abort listener per queued item and removes it in finally. installLeaveLines is one process singleton. Idle wakeups/s: main 0 → 0, renderer 0 → 0, daemon 0 → 0, with no owed line. An owed line wakes at most 7 times over about 2 h, then stops. Under load (100+ agents, sends at several per second): about 2 PK reads + 1 Map lookup per send, and 1 microtask per accepted batch.
Regression classes
Fixed-cadence poll / idle wakeups: matched (retry timers). Disproved: finite schedule, event-driven start, 0 timers when nothing is owed.
Sync SQLite on main: matched (receipt reads). Disproved: primary-key point reads, constant per send, no scan.
Per-entity state outlives entity: matched (waiting, saving, reserved, posting, ending). Disproved: each is deleted in its settle path or pruned.
Hot-path rescans: matched (outbox.holds, allLinks on resume). Disproved: per attempt or per watch, not per event.
Whole-file rewrite: matched (writeLinkFact + flush). Disproved: only per leave, unmute or settle; an equal value skips the write.
Unbounded fan-out: no matching code. Eager startup imports: small local modules and node:crypto only.
Six questions
1 reviewed: the mute gate runs before the seam and the agent, and a no-op mute write is skipped. 2 reviewed: one seam, one LeaveLines, no per-pane owners. 3 reviewed: main pays O(1) SQLite reads; the unsent probe runs on the journal reader. 4 reviewed: retries move forward (owed is re-read after each wait) and end after the last wait. 5 not applicable: no host, SSH or platform probes. 6 reviewed: Stop settles queued work, abort listeners are removed, timers are unref.
Evidence: read from source at this head, no runtime timing measured. Residual: none on the paths above.
Verdict: PASS. No findings (no P0 or P1). I read all 47 non-test changed files, the callers each new path is reached from, and the delta since the last scanned head (86c30d7: proceed before each reply retry, the unsent-answer probe accepting rows with no turn yet). I ran the 3 thread-mute and leave tests at head: 25/25 pass. I took no timing or CPU profile, so the costs below are counts read from the code.
New work: trigger, population and bound (reference fleet)
Work
Trigger
Population
Per trigger
Bound
heldByMute + known receipt reads (connector-deliveries.ts)
each cloud send delivery
sends arrive at Slack-message rate, a few per second at most
2 indexed point reads on mutation_receipts, sync on main
O(1) per send, does not grow with the fleet. admits is the old run check moved out, at the same cost
handleThreadMute gate
each send
same
Slack check: one split, one JSON.stringify, 2–3 Map.gets, one findLink (link-index map, no scan). Non-Slack or DM: returns early
O(1). Only a muted thread or one saving a mute queues anything (chain.after)
turnLeave (chat-turns.ts)
each linked chat turn end
~1 turn end/s across 100+ agents
one owed → findLink. settle does nothing unless this turn owes a leave line
O(1)
turnEndsTaken (connector-turn-events.ts)
each accepted or dropped event batch
events already sent
one kind check per event; only turn-ended/reply get 2 index lookups
O(batch), the same order as the existing replies.accepted(batch). No new publication
connector.leaveThread RPC
an agent runs --leave-thread
rare, prompted by a person
one operationWindow({latestTurns: 2}) journal read, a filter over that window, one link write + one flushPendingOrThrowAsync
window capped at 2 turns. One queued slot per call
Unmute on @mention
a mention in a muted thread
rare
one link write + flush
one per mention
lines.resume
each seam watch, i.e. each hello (client start, rehello after ≥10 min silence)
link index
one pass over the cached allLinks array, field checks only. post only for owed lines
O(links) per hello. The hello's snapshot already walks the links, so this adds no new order of work and runs no git, fs or SQL per link
Leave-line attempt
post/wake/timer
owed lines only (bot left, line not yet posted)
owed (O(1)), turnEndPending (one pass over the event outbox), heldByMirror (one link's mirrorHeld), one unsentAnswer SQL probe
uses the journal_connector_replies_open(session_id,…) index prefix and LIMIT 1, on the journal reader. One post in flight per line (posting guard)
Retry timers
a line not yet taken
owed lines
one-shot setTimeout(...).unref()
RETRY_MS has 6 waits (15 s → 60 min, ≈1h51m total), then it stops until the next hello. Client retries inside postWithRetries are capped at REPLY_ATTEMPTS=3 / MAX_REPLY_WAIT_MS, and proceed now stops them early. A wake moves the retry index forward, so stale timers never exceed 6 per line and fire as no-ops (mine === tries). afterTurnEnd: one 10 min one-shot per leave turn
Save maps saving/reserved (connector-thread-mute-saves.ts)
a mute or unmute save, a leave waiting in the queue
threads saving now
one entry
deleted in finally / release() behind an identity check. Size = saves in flight
deps.waiting, posting, ending maps
a held reply / owed line / deciding turn end
in flight
one entry
waiting is deleted on settle. posting is deleted on every exit of attempt. ending is cleared by post/settle, and resume drops entries older than 10 min
Listeners and idle
Listener census: no new persistent subscriptions. resume and turnEndsTaken ride existing callbacks (watched, onAccepted/onDropped); nothing new subscribes to onStateWritten, the store or IPC. Transient: one abort listener per ConversationChain.after slot, removed in finally.
Idle wakeups/s, base → head: main 0 → 0, renderer 0 → 0, daemon 0 → 0. There is no new interval or self-rescheduling loop. Timers exist only while a line is owed and stop after 6 waits.
Regression classes in the diff
Fixed-cadence poll: matched (RETRY_MS) and disproved. The schedule is finite and unref'd, and a line leaves it once posted, refused for good, unmuted or out of retries.
New idle wakeups: none (above).
Sync SQLite on main: matched (2 receipt point reads per send) and disproved. O(1), indexed, at message rate. The unsent-answer probe runs on the journal reader, per line attempt only.
Per-entity state outliving its entity: matched (5 maps) and disproved. Each entry is deleted on settle, release or expiry.
Whole-file rewrite per change: matched (link write + flush per leave/unmute) and disproved. Triggered by a person (a leave or a mention), and writeLinkFact skips equal values.
Hot-path rescans: turnEndPending scans the outbox once per line attempt (≤7 per line per hello), not per event. leaveThreadRefusal does find over submissions inside a 2-turn window. Both disproved.
Unbounded fan-out: no Promise.all over input. Held sends queue in their own thread's chain, one slot each.
Eager startup imports: only local modules plus node:crypto (already loaded); no SDKs.
Update published when nothing changed: writeLinkFact returns false on equal muted/leaveLine, and nothing is emitted.
Six questions
Unused work before the gate: reviewed. Non-Slack, DM and unmuted sends leave after O(1) checks; turnLeave does nothing unless a line is owed.
Ownership multiplying work: reviewed. One leaveLines per process, one mute deps per connector cloud. Nothing is per pane or per row.
Thread and storage: reviewed. Point reads on main per send; the reply probe runs on the journal reader; flushes only on a leave or unmute.
Growth and progress: reviewed. resume is O(links) per hello. Retries advance an index and stop; an answer that stays unsent forever costs 6 attempts per hello.
Execution host: not applicable. No git, fs or SSH work per item; it is all main-process connector state.
Obsolete work stops: reviewed. A Stop settles the queued slot and the abort listener is removed. proceed cuts client retries after an @mention. Reset/live() stops turn-end posts.
Residual risk: none for amplification. Not measured: wall time of the 2 receipt reads per send on a large orchestration DB (indexed point lookups, expected tens of µs).
Full scan of the PR diff against main 0b7fe2f. Detected surfaces: hot-path, startup-migration. Everything runs on Electron main. The only background work is retry timers for an owed "left this thread" line, and those exist only while a line is owed.
New or changed work: trigger → population → bound
Every send delivery (dispatchDelivery): receipts.heldByMute and receipts.known each do one primary-key getMutationReceipt (plus one Map lookup), then handleThreadMute does one JSON.stringify, two Map gets and an indexed findLink. That's constant per delivery and doesn't grow with worktrees, links or history: 2 indexed point reads per human-rate Slack send. Unmuted threads go on at once with no queueing.
Muted-thread send: goes into the thread's existing ConversationChain lane. after() adds one abort listener and removes it in finally. waiting keeps one entry per thread with a reply still deciding, deleted when it settles. An unmute does one writeLinkFact and one profile flush (user-rate). A batch whose first send is refused recurses over the rest of the batch: O(k²) copies for k same-asker sends in one thread in one poll. That's human-rate and constant at fleet scale.
Per turn end (turnLeave): one indexed owed() read. Work happens only when the turn left its thread: one ending entry and, for an emitted end, one 10-minute fallback timer.
Per accepted event batch (onAccepted → turnEndsTaken): one extra microtask, then O(batch events) with an indexed findLink/owed read only for turn-ended/reply events. It's proportional to events the cloud already took, with no store scan. onDropped does the same for one event.
Per RPC (connector.leaveThread, agent-invoked, once per leave): one operationWindow({ latestTurns: 2 }) read and a linear leaveThreadRefusal over those two turns' items. After that: one queued save, one writeLinkFact and one flush. reserved is released in finally.
Per owed-line attempt: outbox.holds is linear over the pending event outbox. unsentAnswer is one LIMIT 1 SQLite probe on the journal reader, using index journal_connector_replies_open(session_id, …) by session prefix, so it's bounded by that session's rows. Then one /replies post (postWithRetries, which returns once a wait exceeds 60 s and checks proceed before each retry).
Retry timers: a fixed ladder of 15 s, 1 m, 5 m, 15 m, 30 m and 60 m per owed line, then it stops until the next watch. One per line (a wake and its timer both firing still run only one try), and timers are unref'd. Population is lines owed, which is user-rate, not fleet-sized. The test at connector-thread-mute-admission.test.ts:420 asserts the ladder ends with zero timers.
Per connector watch start (lines.resume): one pass over the cached allLinks array that mirror.flushHeld() already walks on the same callback. No index rebuild. Per link it's two field checks, and only muted links with leaveLine call running()/post. At 10× fleet (tens of thousands of links), that's microseconds per link on a reconnect-rate trigger, with fleet-constant work above the existing scan. It also prunes ending entries older than 10 minutes.
Maps: saving/reserved are module-level, one entry per save in flight, deleted in finally/release with an identity check. posting is deleted on every exit path. ending is deleted by post, settle and resume. waiting is deleted when its decision settles. All are bounded by work in flight or leaves owed, and none is keyed by a long-lived entity without a delete.
Startup/migration: the parser gains two optional fields and the schema one optional leaveEligible. No migration or eager SDK import.
Listener census, idle and load rates
New subscriptions: none. turnEndsTaken hangs off the existing outbox onAccepted/onDropped callbacks, resume off the existing seam watched callback, and after() adds one abort listener per queued item, removed in finally. No new renderer or IPC publication. muted/leaveLine change only on a leave, an unmute or a settle, so a worktree-meta write happens at user rate.
Idle wakeups/s, main, renderer and daemon: 0 before → 0 after with no owed line. With an owed line that can't post, there are 6 wakeups total, then 0 until the next watch.
Under load (100+ agents, hook status >1/s): no per-status-update work. Per delivery, per turn end and per accepted batch costs are the constant indexed reads above.
Regression classes
Fixed-cadence poll, idle wakeups: matched. Disproved by the bounded ladder and no timer at idle.
Per-entity state outlives the entity: matched. Disproved, every map is deleted on settle.
Sync SQLite on main per event: matched. Two PK reads per send, constant.
Hot-path rescans: matched. resume reuses the cached list on a reconnect-rate trigger; holds only runs per owed line.
Unbounded fan-out: matched. One post in flight per line via posting.
Whole-file rewrite per change: one link write and flush per leave or unmute, at user rate.
Eager imports: none new.
Six questions
Admission happens before the work: mute reads only for Slack thread ids, and the ladder only for owed lines.
One threadMuteDeps and one leaveLines per process.
Main thread: indexed point reads, and the journal probe on its reader.
Retries advance and stop, and the next watch re-arms them.
No host probes or subprocesses.
Stop aborts queued work, the client's stop signal ends posts, and maps release.
Verification: the five touched test files pass (50 tests: thread-mute, mute admission, leave turn-end, leave authority, delivery receipts). No runtime timing was measured; the numbers above are work counts traced from source.
Verdict: clean. No P0 or P1 findings. The range is the merge base with main (e0b5678) through 97d81a0, 49 shipped files. The surface detector flagged hot-path (5 files) and startup-migration (delivery receipts). It flagged no publish, subscribe, timer or worker surfaces. All of this is main-process work. No renderer or preload code changed.
Reference fleet used for pricing: 100+ agents, about 10k links at 10× (bot threads plus chat links across 750+ worktrees), Slack sends reaching all bots at up to about 5/s, and --leave-thread happening at the rate people ask for it (a handful a day per bot).
Work added, with trigger, population and bound
Work
Trigger
Population
Cost per trigger and bound
Mute gate in dispatchDelivery (connector-deliveries.ts:196-240)
each send delivery
every send. The mute step only runs for Slack thread ids.
2 more primary-key SELECTs on mutation_receipts (heldByMute, known), one string split and regex, 2 Map gets, and readThreadMute, which is one findLink lookup in the existing cached link index. The cost is the same at N and 10N. At 5 sends/s that is about 10 index probes/s, well under 0.1 ms/s on main.
Held sends of a muted thread (handleThreadMute, inPlace, heldBatch)
a send to a thread that is muted or still deciding
the sends of one poll's batch for that thread
One chain.after lane entry and one promise link per held send, bounded by the batch length. Its abort listener is removed in finally. Silenced sends record one receipt row each and start no turn, so a muted thread costs less than before.
Batch head refused, then re-batched (connector-delivery-batches.ts)
a batch whose first send is refused before the seam (expired or unsupported)
L sends in one poll
Up to L recursion levels. Each level runs the existing late filter, so worst case is O(L²) comparisons (L=100 gives about 5k). It is rare, bounded by the poll, and makes no extra SQL calls: still one dispatchDelivery per send.
turnLeave at turn end (chat-turns.ts, turn-ends.ts)
each ended turn of a linked conversation
ended turns, 100+ agents
One owed() call, which is one indexed findLink. When nothing is owed, settle does nothing.
turnEndsTaken (connector-turn-events.ts:778,784)
each event batch the cloud accepts, and each dropped turn end
events in that batch
One pass over a batch that was already serialized. Only turn-ended and reply events do one findLink plus owed. This is O(batch), in line with the send itself.
connector.leaveThread RPC
one orca bot reply --leave-thread call
rate people ask for it
One journal operationWindow({latestTurns: 2}) on the reader worker, bounded to two turns, so it does not grow with chat history. One leaveThreadRefusal over that window. One lane entry. One link write. One incremental flushPendingOrThrowAsync (dirty domains only).
Leave-line post attempt
turn end, an accepted end, a watch resume, or a retry
lines owed (normally 0 to a few)
Waits for the pending save. One incremental flush when the line is owed. One outbox.holds scan bounded by queued events. One mirrorHeld scan on one link. One indexed journal probe (journal_connector_replies_open on session_id). One reply POST. Concurrent attempts for the same line are merged through the posting map.
Retry timers (RETRY_MS)
an attempt that is still pending or failed
each owed line
At most 6 timers per line per watch (15 s up to 60 min, about 2 h in total), then it stops until the next watch. Timers are unref'd. A wake-up and its timer both firing still count as one try. A line the cloud has refused for good, or one that is no longer owed, stops at once.
afterTurnEnd fallback, resume "ending" timers
a leave turn's end; each watch for lines whose end is still deciding
each leave turn, and owed lines per watch
One 10-minute timer each. post merges duplicates.
resume on watch start (external-conversations-install.ts:660)
each connector watch: hello answer at startup, reconnect, bot or settings change, return from a 10-minute silence
all links
One pass over the cached allLinks array, which flushHeld has just warmed on the same trigger, and the watch snapshot already builds an O(links) list too. At 10k links that is about 30k field reads per watch, under 1 ms. It only happens when a hello is answered, never while idle. Finding lines a quit cut short needs this pass.
Mute saves (threadMuteSaves)
each leave, unmute or line settle
rate people act
One writeLink (one workspace record) and one incremental flush. A failed flush adds one rollback write. A write with nothing new saves nothing.
Maps (in-memory lookup tables)
saving and reserved (module level) are deleted in finally/release, with an identity check. waiting is deleted when its decision settles. posting is deleted on every way an attempt ends. ending is deleted by post, by settle, and by resume for entries older than 10 minutes. The one path that can keep an ending entry until the next watch is a mirrored ('held') end whose leave an @mention cleared first. Each entry is about 100 B per leave, so this is not a finding.
Listener and publication census, idle rate
New long-lived subscriptions: 0. There are no new onStateWritten, emitter, IPC, rAF or interval subscriptions.
Short-lived listeners: one abort listener for each queued mute or leave decision, removed in finally.
New publications: link writes go out through the existing onStateWritten fan-out. Each one is a real change; equal content returns false and publishes nothing. Rate: at most about 3 per leave (mute, settle, and rollback only when a flush fails) and 1 per unmute.
Idle wakeups/s, before and after: main 0 → 0, renderer 0 → 0, daemon 0 → 0. Timers exist only while a line is owed and being retried, and they stop after the last retry.
Regression classes in the diff
Sync SQLite on main: matched. The send path adds 2 primary-key lookups per delivery, the same at N and 10N, so it was disproved as fleet-scaling work. Small constant waste: heldByMute and known read the same row one after the other. Not a finding.
Fixed-cadence poll or loop that never settles: matched (RETRY_MS). Disproved: at most 6 tries per watch, and it ends when the line is no longer owed or is refused for good.
New steady-idle wakeups: no match. 0 at idle.
Per-entity state outlives the entity: matched (ending, posting, waiting, saving, reserved). Disproved: each has a delete owner. ending's rare leftover is pruned on the next watch.
Unbounded fan-out or queues: matched (heldBatch, recursion). Bounded by the poll's batch.
Hot-path rescans: matched (resume and allLinks on watch). Disproved: once per hello, and smaller than the snapshot built on the same trigger.
Expensive code newly reachable past a gate: matched (connector.leaveThread, unsentAnswer). Both are bounded reads triggered by a person's request.
Re-reading unchanged input: matched (the incremental flush on each attempt). Disproved: it only flushes dirty domains and runs a bounded number of times.
Eager startup imports: small local modules only.
startup-migration:admits() refactors the existing check with the same short-circuit, and settlePendingMutationReceipts is unchanged. The schema change adds one optional zod field and no migration.
Whole-file rewrite per change: no match. Writes go to one workspace record and the flush is incremental.
The six questions
Unused work before the gate: reviewed. Sends that aren't Slack, or go to an unmuted thread, return after the indexed lookups. Turn ends that owe nothing do no further work.
Ownership multiplying work: reviewed. There is one leaveLines per install, one posting entry per line, and a single threadMuteDeps.
Thread and storage: reviewed. Main runs 2 primary-key reads per send, plus link writes and an incremental flush per leave. The journal probe and the two-turn window run on reader workers.
Growth and progress: reviewed. Retries are capped per watch and resumed by the next watch. Batch recursion advances by one send per level.
Execution host: not applicable. The work is local to main and the cloud HTTP path, with no Git, spawn or SSH calls.
Obsolete work stops: reviewed. A Stop settles queued waits and aborts them, removing their listeners. An @mention stops retries through proceed and owed. Signing out drops the attempt.
Evidence: read from the source at 97d81a0, covering the callers above. Nothing was run, so the costs above are proven call counts, not measured timings.
Problem: once a bot followed a Slack thread, every reply there woke it. Asking it to stop still woke it for every later reply, and Stop only ends the current answer. The earlier version needed an exact phrase.
Change: a person who can already ask the bot says, in their own words and in that thread, that they want it to leave ("leave this thread", "you're done here", in any language, even mixed with other requests). The bot does the rest of what they asked, then runs orca bot reply --leave-thread. Orca checks who asked from its own record of the running turn, saves the leave to disk, and then posts one line of its own as the bot, right after the turn's answer: "I've left this thread. New replies here won't reach me unless someone @mentions me." Later replies in that thread don't wake that bot; an @mention brings it back. The exact-phrase path is gone.
Fixed during review (the main classes):
Authority: only the running turn counts, and every message it took must be from a person in that thread or the owner typing in Orca. A worker's report, another bot or app, an automation, a recalled memory, a queued card, or another agent's send through Orca's CLI can't make it leave. Only the chat itself may call it (the CLI sends its session and the host verifies it).
Saving: the leave runs in the thread's queue and is on disk before the command answers. A failed save puts the old state back and says nothing changed. A save whose outcome is unknown keeps the leave and says Orca couldn't confirm it. A Stop, read as the save starts, never lets it save. Replies sent while it saves wait for it, so none is lost or silenced by a failed save.
The confirmation line: it posts as its own message after the turn's answer has reached the cloud. It waits on the turn's end, its answer in the reply outbox, or an answer held behind the owner's failed mirrored post, including after a restart. It posts only after a save known to be on disk. It stops, including in the client's own retries, once an @mention brings the bot back. It never posts on a cloud that can't report @mentions, or before the cloud has said whether it can. One reply id makes it post once.
@mentions: a person's @mention always clears the leave, also on a cloud that can't report mentions, so the leave never comes back later.
Deferred (P2, none can mute wrongly or post a false line):
On a cloud without mention reporting, a bare @mention whose clearing save fails on disk is refused instead of answered; a plain reply there still reaches the bot.
A line still owed on a cloud without mention reporting saves the profile once per reconnect for nothing.
The reply gate's own Stop check reads the queue's answer rather than its signal; at worst a Stop leaves a thread unmuted, which the code already allows.
A line whose answer waits behind a later queued turn posts up to one retry step late, or at the next reconnect after about two hours of retries.
Orca doesn't yet show in its UI that a thread was left.
Verified:
Regression audit: a blinded audit of the PR merged onto main called it SAFE at 97d81a0, after earlier rounds' findings were fixed (each with a test that fails without its fix where one was worth keeping).
Claude review: the last repair check at 97d81a0 said ready.
Perf: a fresh full perf-scan at 97d81a0 was clean (comment above). No new subscriptions, IPC or renderer work; 0 idle wakeups; confirmation retries are bounded and only run while a line is owed.
Real agents: the bot's real instructions, with real Claude Code (claude-opus-5-5[1m]) and Codex CLI (gpt-6.2-sol), on 24 thread cases × 3 runs each: Claude 72/72, Codex 72/72. The cases cover natural and mixed requests (it leaves and answers the rest), and quotes, code, questions, negation, requests to another bot, and passed-on words (it doesn't leave). They also cover a refused or failed leave (it says plainly it's still there and never claims it left) and the confirmation (the agent never writes it). The bot's instructions and the texts it sees haven't changed since that run.
Host behavior by tests:connector-thread-mute-admission.test.ts drives the real RPC, queue, store and save code: authority and scope, the save and its failures, Stop, restart, @mentions, and the line's timing and retries. bot-leave-thread-authority.test.ts covers who may leave. external-conversation-thread-leave-turn-end.test.ts covers real turn ends.
CI: green on 97d81a0 (one GitHub 500 in the job that cancels stale runs, rerun).
Linux remote check:REMOTE-CHECK PASS 97d81a0592bfa560652fa2d9593047d8c3c38487, 30 checks passed, including the related unit tests.
Findings: none. No new steady-idle wakeups, no new subscriptions, no work that scales with worktrees, terminals or chats on a repeated trigger.
New or changed work (trigger → work → bound)
Work
Trigger
Population × work
Bound
Mute gate in dispatchDelivery
each send delivery
2 primary-key lookups on mutation_receipts (heldByMute, known) + 1 indexed link lookup (findLink) + string split; a thread that isn't muted and has nothing pending is never queued
~1–2 sends/s even at the 10× fleet ≈ tens of µs/s on main. Constant per delivery
Muted/in-flight thread hold
send to a muted thread, or one behind a save
one ConversationChain.after slot + one waiting entry, removed when it settles; its abort listener is removed in finally
one per held send; batch ≤ one poll's deliveries for one asker
Held batch chain (heldBatch)
batch whose head the mute holds
O(b) chained promises, later.slice O(b²) copies
b = one person's burst in one poll
Refused head → rest as its own batch
batch whose head is refused before the seam
recursion depth ≤ b, each level does the existing per-level filters
same b; previously each one went out alone
connector.leaveThread RPC
agent runs bot reply --leave-thread
1 journal operationWindow({latestTurns: 2}) read, a scan of that 2-turn window, 1 link write + 1 flushPendingOrThrowAsync
one per leave (a person asks)
Unmute save
@mention in a muted thread
1 link write + 1 flush
one per mention of a muted bot
Turn end turnLeave
every linked chat's turn end
1 indexed readThreadMute; a line is posted only when one is owed
turn-end rate (a few per second at most) × O(1)
turnEndsTaken on events accepted/dropped
each accepted events batch
filters by kind first; only turn-ended/reply do 2 indexed link lookups
batch size ≤ the events request limit
Leave-line attempt
post / retry / wake
waits for the save, 1 flush (no-op when nothing is dirty), 1 indexed reader-worker SQL probe (journal_connector_replies_open on session_id, off main), 1 outbox.holds scan of in-memory outbox items, ≤1 POST (its own backoff stops early through proceed)
only for owed lines (≤1 per left thread)
Retry timers
a line not yet postable
RETRY_MS 15 s, 1 m, 5 m, 15 m, 30 m, 60 m: 7 attempts over ~111 min, then it stops until the next watch. Unref'd. A wake and its timer dedupe through tries
per owed line; 0 with no owed line
Turn-end fallback timer
afterTurnEnd(…, fallback=true)
one 10-min one-shot that calls post (deduped through posting)
one per leave turn end
Watch resume
each connector watch (every hello: connect, re-hello, after 10 min of silence)
ages ending; walks the cached allLinks array with field checks only; posts or arms a one-shot for owed lines
O(links) trivial ops per hello. 10× fleet ≈ 10k links ≈ <1 ms per hello. Not periodic
saving / reserved maps (module)
mute save / leave reservation
one entry per thread with a save in flight
deleted in finally or on release; empty at rest
posting / ending maps
owed lines
one entry per (thread, turn) owed
deleted on post, settle, retries running out, or by resume aging (>10 min); ≤ leaves in flight
answerPending → ensureStructuredAgentSessionHost
an owed line's attempt only
starts the chat host if it isn't running yet (idempotent)
gated on an owed line; one at most per process
Listener census and idle rate
New persistent listeners or subscriptions: 0. The only addEventListener (ConversationChain.after's abort) is removed in finally. turnEndsTaken runs inside the existing onAccepted/onDropped outbox callbacks, adding no subscriber. No new IPC, renderer publication or store subscription.
Idle wakeups/s on main, renderer and daemon: base 0 → head 0. Timers exist only while a leave line is owed, and they end (7 tries, plus one 10-min fallback per leave). With no owed line nothing new is armed.
Under load (100+ agents, status >1/s): status events skip at the kind check in turnEndsTaken. The per-send gate is constant work and is not multiplied by worktrees or terminals.
Regression classes touched
Fixed-cadence poll or loop that never settles: matched (retry ladder). Disproved: finite ladder, stops, wake deduped, unref'd.
New idle wakeups: disproved, 0 → 0 as above.
Sync fs or SQLite on Electron main: 2 PK lookups per send plus 1 link write and flush per leave or unmute. Bounded by human-message rate, not fleet N.
Per-entity state outliving its entity: saving, reserved, waiting, posting, ending each have their delete on the settle path (above).
Unbounded fan-out: retries are one in flight per line (posting dedupe). Held sends are serialized in the thread's lane.
Whole-file rewrite per change: link writes go through the existing record writer, once per leave, unmute or line settle; writeLinkFact skips equal values.
Eager startup imports: only small local modules plus node:crypto, which main already loads.
Six questions
Unused work before the gate: reviewed. A thread that isn't muted pays lookups only, never a queue slot.
Ownership multiplication: reviewed. One leaveLines per process, one threadMuteDeps per cloud.
Thread/storage: reviewed. PK lookups on main, the unsent probe on the journal reader worker, and the flush on the existing writer.
Growth and progress: reviewed. Retries are finite and resume on the next watch; refusals in NEVER_STATUS/NEVER_ERRORS drop the line; an @mention drops it.
Execution host: not applicable (no host or SSH probes).
Obsolete work: reviewed. proceed stops the client's own retries after an @mention, live() skips a reset account's turn ends, and lane cancel settles held sends.
Evidence
Source-proven counts at this head. Targeted tests pass: connector-thread-mute, connector-thread-mute-admission, external-conversation-thread-leave-turn-end, bot-leave-thread-authority (46/46).
No runtime timing was taken; impact is stated as counts.
Residual risk: no deterministic fake-timer test bounds the leave-line retry count. The bound is source-proven only (RETRY_MS has 6 waits).
Problem: once a bot followed a Slack thread, every reply there woke it. Asking it to stop still woke it for every later reply, and Stop only ends the current answer. The earlier version needed an exact phrase.
Change: a person who can already ask the bot says, in their own words and in that thread, that they want it to leave ("leave this thread", "you're done here", in any language, even mixed with other requests). The bot does the rest of what they asked, then runs orca bot reply --leave-thread. Orca checks who asked from its own record of the running turn, saves the leave to disk, and then posts one line of its own as the bot, right after the turn's answer: "I've left this thread. New replies here won't reach me unless someone @mentions me." Later replies in that thread don't wake that bot; an @mention brings it back. The exact-phrase path is gone.
Fixed during review (the main classes):
Authority: only the running turn counts, and every message it took must be from a person in that thread or the owner typing in Orca. A worker's report, another bot or app, an automation, a recalled memory, a queued card, or another agent's send through Orca's CLI can't make it leave. Only the chat itself may call it (the CLI sends its session and the host verifies it).
Saving: the leave runs in the thread's queue and is on disk before the command answers. A failed save puts the old state back and says nothing changed. A save whose outcome is unknown keeps the leave and says Orca couldn't confirm it. A Stop, read as the save starts, never lets it save. Replies sent while it saves wait for it, so none is lost or silenced by a failed save.
The confirmation line: it posts as its own message after the turn's answer has reached the cloud. It waits on the turn's end, its answer in the reply outbox, or an answer held behind the owner's failed mirrored post, including after a restart. It posts only after a save known to be on disk. It stops, including in the client's own retries, once an @mention brings the bot back. It never posts on a cloud that can't report @mentions, or before the cloud has said whether it can. One reply id makes it post once.
@mentions: a person's @mention always clears the leave, also on a cloud that can't report mentions, so the leave never comes back later.
From CodeRabbit (all seven current threads fixed and resolved): a queued owner message no longer counts as the owner asking; a repeated save with nothing new to write still confirms it is on disk; the line looks up the answer before reading the turn's end, and a failed lookup waits; an unknown save outcome tells the agent to claim neither that it left nor that it stayed; and two eval grader patterns were tightened.
Deferred (P2, none can mute wrongly or post a false line):
On a cloud without mention reporting, a bare @mention whose clearing save fails on disk is refused instead of answered; a plain reply there still reaches the bot.
A line still owed on a cloud without mention reporting saves the profile once per reconnect for nothing.
The reply gate's own Stop check reads the queue's answer rather than its signal; at worst a Stop leaves a thread unmuted, which the code already allows.
A line whose answer waits behind a later queued turn posts up to one retry step late, or at the next reconnect after about two hours of retries.
Orca doesn't yet show in its UI that a thread was left.
Wording for Brennan: the Tools line (approved design text) says to tell them it's still in the thread if the leave fails, while the new "couldn't confirm" answer says to claim neither. The more specific answer arrives later, and no eval case covers an unknown save outcome.
Verified:
Regression audit: a blinded audit of the PR merged onto main called it SAFE at f0245b4, after earlier rounds' findings were fixed (each with a test that fails without its fix where one was worth keeping).
Claude review: the last repair check at f0245b4 said ready.
Perf: a fresh full perf-scan at f0245b4 was clean (comment above). No new subscriptions, IPC or renderer work; 0 idle wakeups; confirmation retries are bounded and only run while a line is owed.
Real agents: the bot's real instructions, with real Claude Code (claude-opus-5-5[1m]) and Codex CLI (gpt-6.2-sol), on 24 thread cases × 3 runs each: Claude 72/72, Codex 72/72 (regraded with the final grader). The cases cover natural and mixed requests (it leaves and answers the rest), and quotes, code, questions, negation, requests to another bot, and passed-on words (it doesn't leave). They also cover a refused or failed leave (it says plainly it's still there and never claims it left) and the confirmation (the agent never writes it). The bot's instructions and the texts it sees haven't changed since that run.
Host behavior by tests:connector-thread-mute-admission.test.ts drives the real RPC, queue, store and save code: authority and scope, the save and its failures, Stop, restart, @mentions, and the line's timing and retries. bot-leave-thread-authority.test.ts covers who may leave. external-conversation-thread-leave-turn-end.test.ts covers real turn ends.
The switch no longer asks the cloud for a new feature. The thread gate
that already silences a left thread (stablyai#47428) now also silences a reply
that doesn't mention the bot when the bot is set to answer its threads
only when mentioned, using the mention mark the cloud already sends
(`sends.mentioned`).
- Drop the `slack.threadReplies` cloud feature, its hello field and doc.
- A thread's own mute still decides first; the bot's setting keeps no
state and never changes the link.
- A reply to a thread not linked yet is decided once the start in the
same poll has written the link.
- On a cloud that doesn't mark mentions the setting stands aside and the
switch stays disabled.
- Fix the Korean catalog, where a second `bots.slack` block from main
shadowed the switch's strings.
Co-Authored-By: Claude Fable 5.2 <[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
Before: once a bot was following a Slack thread, every reply in that thread went to the bot. There was no way to tell it "you're done here": asking it to stay quiet still woke it for every later reply, and Stop only ends the current answer.
After: someone who can already ask the bot says so in their own words, in that thread: "leave this thread", "you can stop following this one", "shh, you're done here", in any language, even with other things in the same message. The bot does whatever else they asked, then leaves. Orca itself posts one line in the thread: "I've left this thread. New replies here won't reach me unless someone @mentions me." From then on, replies in that thread don't wake that bot. An @mention brings it back, and it answers as usual.
It is only that bot and only that thread, and it stays that way after Orca restarts. A question about leaving, "don't leave", quoted or pasted words, a message to another bot, or text the bot read somewhere never makes it leave. Orca checks who asked before it saves anything: only a person who can ask the bot in that thread (or the owner typing in Orca) counts, never another app, another bot, an automation or a worker's report. If Orca can't save it, nothing changes, no confirmation is posted, and the bot says it is still in the thread.
What Changed
orca bot reply --leave-thread(new RPCconnector.leaveThread,connector-leave-thread.ts). The agent names nothing; Orca finds the bot, the thread and the turn from its own records:bot-leave-thread-authority.ts). Orca's own continue after a restart or a usage limit is not the owner's send, so it never inherits a cut-short turn's request. A message the owner queued while the bot was busy can't be told apart from an automation's here, so it is refused and they ask again;leaveEligibleon the delivered message);thread_mute_not_saved); a save whose outcome is unknown keeps the leave (disk may hold it) and answers that Orca couldn't confirm it. From the moment the bot asks, replies in that thread wait for the leave to save or be refused, so none slips past it and a failed save never swallows one. A second call in the same turn answers "already" only once the leave is on disk, and owes nothing more; after an @mention in between, it leaves again.external-conversation-leave-lines.ts). It waits until the cloud has taken that answer: the turn's end, or its reply still in the reply outbox, or an answer held behind the owner's failed mirrored post; after a restart too. It is retried with one reply id, so it posts once, and only while the thread is still left: an @mention clears what is owed. If Orca quit or was signed out before it posted, it posts the next time Orca's connection to the thread starts. It never posts on a cloud that doesn't mark mentions, or before the cloud has said whether it does.sends.mentioned). Elsewhere the command is refused, nothing changes, and a thread already left lets its replies through.bot-preamble.ts): one Tools line. Run it when the person asking wants it to leave, in any words or language; do the rest of what they asked first; don't say it left (Orca does); don't run it for a question, a "don't", quoted, pasted, forwarded or code text, a request to another bot, or earlier or fetched text; if it fails, say plainly it is still in the thread.Why
Nobody in Slack can know a magic phrase. The person's own words go to the bot as they do today, and the bot judges what they meant, as it does for any other request. What leaving can do is bounded and checked by Orca: one bot, one thread, only from a turn a person in that thread asked for, saved before anyone is told, and undone by any @mention. If the bot misreads a person's message, the worst case is that one bot goes quiet in one thread, the thread says so, and an @mention undoes it.
Linked Issue
None.
Visual Proof
A mixed request, a failed save, and two messages that aren't requests to leave (real agent replies; Slack layout simulated)
Every bot reply is verbatim from the real-agent eval; the confirmation line is the exact text Orca posts. A live Slack thread can't be driven from the test machines.
Testing
I manually tested these changes locally (real agents through the real CLI and bot instructions, below; macOS)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
bot-leave-thread-authority.test.ts: one hardcoded table over real journal rows decides who may leave. A member or the owner asking in the thread, or the owner typing in Orca, is allowed. Refused: another app, a bot writing for someone, an unknown person, a message from another thread or for another conversation, a worker's report after a person's turn, an automation's run, a batch Orca didn't mark, a person and an app in one turn, a recalled memory, a finished turn, and a running turn no message opened.connector-thread-mute-admission.test.tsruns the real command against a real store in a temp directory, with real delivery receipts. Only the agent's turn and the chat's journal are stand-ins.connector-thread-mute.test.ts: the gate's step table, and ordering throughdispatchBatch(a mention's follow-ups stay one turn, Stop takes a held batch down, a muted thread woken mid-batch never deadlocks).external-conversation-thread-leave-turn-end.test.tsdrives real turn ends: the answer goes out as the agent wrote it, the line posts once after it on both answer paths and for a failed turn, and is dropped when an @mention lands first, including while the turn is being read.Real agents: Claude (Opus 5.5) and Codex (gpt-6.2-sol) ran 24 cases 3 times each through the real
orcaCLI and the bot's real instructions, against a stand-in host. All 72 runs pass on both. They left for six plain ways of asking, a request mixed with other news, "summarize, then leave", Spanish and "shh, you're done here". They stayed for "how do I…?", "would you…?", "don't leave", quoted, code, forwarded and passed-on words, a request to another bot, earlier catch-up and a fetched issue telling bots to leave. They never tried to leave in the owner's Chat or on GitHub. When the save failed or was refused, both said plainly they were still in the thread.Performance
None that runs often. A reply to a muted thread does one indexed link read before the agent (as before); a leave reads the chat's last two turns and saves one link; a turn end does one link read and, for a turn that left, one save. A line that can't post retries six times over about two hours while a client runs, then waits for the next connection; nothing runs while idle. A perf scan at the final head is on the PR.
Risk
Level: Medium
The riskiest part is the gate before the agent: a bug there could keep a bot silent in a thread where it should answer. It only acts on threads a bot was asked to leave, an @mention always clears it, and on a cloud that doesn't mark mentions it stands aside. The leave itself is bounded to one bot in one thread from a turn a person there asked for. Saved data: two optional fields on the thread's link, which an older Orca ignores (the bot is then woken as before). A plain revert backs it out; a thread left before the revert is woken normally after it.
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
Known and accepted: a line owed when the chat closes mid-turn posts at the next connection; a crash between saving the leave and its turn's end loses the line (never a false one); a line whose turn end the cloud never takes posts about 10 minutes later.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)