You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(connectors): a restart-resumed turn's answer reaches its Slack thread - #46048
When Orca restarts while a bot is answering a Slack message, Orca resumes the work afterwards, but the bot's final answer never reached Slack. Now the resumed work's answer is posted to the thread that asked, once. An answer that is too old to be useful is closed quietly instead.
Files
Added
Deleted
Net
Test
7
$\color{#1a7f37}{\Huge{\mathbf{+}}}$943
$\color{#cf222e}{\Huge{\mathbf{−}}}$3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$940
Prod
21
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1235
$\color{#cf222e}{\Huge{\mathbf{−}}}$159
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1076
What Changed
A cut turn counts as finished. A restart saves the cut turn as interrupted with no outcome. Reply recovery only read the outcome field, so it treated that turn as still running and left its Slack request open forever. It now reads the derived verdict.
The continuation names what it resumes. Orca's restart continuation now carries a host-only restartOf: the turn, the cut turn's row, or the send it resumes. The provider never sees it, and a client's send can't carry it because SendBody is strict. Recovery verifies the binding and fills the original request with the continuation's answer, in its own thread. The checks: same session and epoch, exactly one match, an interruption, no other root turn in between, and at most 4 hops. Anything else binds nothing.
A cut request waits for its continuation. It waits while a restart offer for that work stands (pending, in progress, or failed and open to a retry) or while a verified continuation exists. Offers are read before the journal, because a continuation is journaled before its offer settles. A hold is capped at 24 h from the cut; another turn starting doesn't end it.
Stale answers aren't posted. A recovered fill posts only if its answer ended within 1 h and its request is under 24 h old. Otherwise the request is closed quietly (quiet, no post), with a local expired_reason column, a warn line and a counter. The limits are named constants in connector-reply-policy.ts. They are deliberately conservative and easy to tune.
A mirrored continuation isn't posted twice. If the chat's Slack mirror already posts the continuation turn, its inherited request closes quietly, so the thread gets one answer.
Why
A restart left the reply outbox row open forever and the continuation's answer unattached. Fixing both in recovery keeps the live turn-end path unchanged. Checked against how comparable products handle this.
Visual Proof
N/A: no UI. The change is which answer the reply outbox sends to Slack after a restart, and the tests below cover it.
Testing
21 new tests fail on origin/main and pass here. They cover:
the binding matrix (turn, cut-turn row, send, a send that became a turn, no match or two matches, a non-interrupted turn, a root in between, a 4-hop chain, a 5th hop, a client send);
holds against the real recovery capsule (pending, in progress, failed then rollback, dismiss, superseded, a reclaimed lease, an offer read racing the journal, subscribing before the first read);
durable freshness across reboots;
the five request shapes stuck on a real machine, which all close quietly;
the mirror and the outbox in both orders, with exactly one post;
the upgrade of an older reply table.
pnpm tc and oxlint, oxfmt and ast-grep on the changed files pass. The related suites pass, except three files that fail identically on origin/main on this host.
Tested on macOS.
Performance
No new polling and no extra reads on the live turn end. Recovery adds one offers-file read per settle of a chat with unfilled rows, plus lookups inside the window it already reads, and one timer per held chat at its durable deadline.
Review
AI-assisted change (Claude). Cross-platform: no platform-specific code; paths come from the existing capsule. SSH/remote: unchanged; recovery runs where the journal lives. Agents and integrations: the provider payload and send fingerprints exclude restartOf, and only the Slack reply outbox changes. Mobile and older builds: columns are added by ALTER, with no user_version change; older builds ignore them and the new body field. Security: no new input surface. Client sends still go through the strict SendBody.
Risk
Level: Medium.
A cut request now waits up to 24 h if a restart offer for its work stays open and nothing else happens, then closes quietly.
A request closed quietly shows as done in Slack, with no post. A dedicated cloud expired outcome is a follow-up.
Not fixed here: a turn end whose live journal read fails can still post an answer through both the turn end and the outbox. That is follow-up item 969.
A plain revert restores the previous behaviour. The two added nullable columns stay and are unused.
…read
When Orca restarts mid-turn, the turn is saved as interrupted with no
outcome, and Orca sends a restart continuation to finish it. Reply
recovery read only the raw outcome, so it treated the cut turn as still
running and kept its Slack request open forever; the continuation carried
no binding to that request, so its final answer was never attached.
- Recovery reads the derived verdict: a cut turn is finished (interrupted).
- A restart continuation names what it resumes (restartOf: a turn, a cut
turn's row, or a send). Recovery verifies it in the same session and
epoch (one match, an interruption, nothing in between, at most four
hops) and fills the original request with the continuation's answer.
- A cut request waits while a restart offer for its work stands (pending,
in an action, or failed and open to a retry) or a verified continuation
exists, capped at 24 h from the cut. Offers are read before the journal.
- A recovered fill posts only if its answer ended within 1 h and its
request is under 24 h old; otherwise it closes quietly (no post) with a
local expired_reason, a warn line and a counter.
- A continuation the chat's Slack mirror already posts closes its
inherited request quietly, so the thread gets one answer.
The change adds restart-continuation references to journal messages and reads standing recovery offers from recovery capsules. Connector reply recovery now binds continuations to earlier work, holds interrupted replies while continuation conditions apply, and settles rows using journal evidence and expiry rules. Reply admission times and quiet-expiry reasons are persisted. Tests cover restart binding, offer timing, expiry, and Slack mirror posting.
Merge Risk: Moderate · up to b38b8
A restart-resumed turn that has no connector rows can lose its answer event. A recovery pass that is still running when the service shuts down can recreate watches and timers afterward. An offer published during a row read can still be missed, which would close the original request as interrupted before the continuation can answer it. These affect the Slack delivery path this change is meant to fix, so they should be addressed before merge.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Description check
The description follows the repository template. It has ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing, Risk with level, Review, and Performance sections. The Linked Issue section is…
Add the linked issue number in the 'Fixes #' line, or confirm that a maintainer has no pre-existing issue to attach. Expand the Why section to explain the alternatives considered. Tick the Testing and Checklist items that the author has com…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the main change: a restart-resumed turn's answer is delivered to its Slack thread. The changeset adds restart-continuation binding (restartOf), reply-recovery holds, and delivery of th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a restart-resumed turn's answer is delivered to its Slack thread. The changeset adds restart-continuation binding (restartOf), reply-recovery holds, and delivery of the resumed answer to the original Slack request. The title is concise and specific, and it follows the conventional commit style used in the repository.
Full details: Description check
Explanation
The description follows the repository template. It has ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing, Risk with level, Review, and Performance sections. The Linked Issue section is empty: it has 'Fixes #' with no issue number, and the template requires a linked issue for outside contributors. The AI Disclosure section is filled in with the model name. The Agent skill upstream boundary checkbox is unchecked and the Checklist is not ticked. The Testing checkboxes are also not ticked. The Why section gives only a brief rationale and does not compare the alternatives considered. The description also contains an auto-generated LoC block that must stay as-is.
Resolution
Add the linked issue number in the 'Fixes #' line, or confirm that a maintainer has no pre-existing issue to attach. Expand the Why section to explain the alternatives considered. Tick the Testing and Checklist items that the author has completed, and state in the Agent skill upstream boundary section whether the change copies any upstream skill-installer source. Keep the generated LoC block unchanged.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
…swer reaches the thread
Follow-up to the review of the restart reply recovery (C1, CodeRabbit).
- The continuation's envelope fingerprint is computed over the fields the
host's send plan hashes, which leave out restartOf. It hashed the whole
body before, so the host refused every continuation that named its work.
- A read the restart binding needs that fails is now unknown, not
"binds nothing": the pass decides nothing by absence, holds what may be
resumed and settles the chat again in 30 s, so one failed alias read no
longer closes the request as unattributed or interrupted.
- A continuation the agent rejected binds nothing, and a failed restart
action no longer holds, so the cut request is told how it ended instead
of waiting a day and closing quietly.
- The request is answered with the whole reply: the prose the restart cut
partway through, then the continuation's. A heard continuation's own
turn end tells only the turn's state (unless the Slack mirror holds it),
so the thread gets that answer once.
- A restart chain past its fourth hop binds nothing at all, so the
original request releases at once instead of holding 24 h.
- A pass that saw the restart offers change after it read them (a crash
cut's offer is recorded at startup) fills no cut; the next pass decides.
- A failed settle, including one at a hold's deadline, is retried in 30 s.
- Only person messages typed before the continuation's turn ended count
as ones the Slack mirror posts with that turn.
- The capsule tests wait for the fill they assert, not a fixed number of
pauses.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Quick win
Prevent a successful pass from restoring work after disposal.
If dispose() runs while operationWindow is pending, a successful completion can still reach this block. It restores the journal watch and schedules another hold deadline. The captured generation protects only the error handler.
Pass the generation into settleOnce and reject stale completions before they restore watches or timers. Keep scheduling enabled for passes from the current generation.
Based on learnings, cancelling timers does not stop in-flight work from restoring obsolete scheduled work.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Recheck the hold after the awaited row read.
If no offer exists, turnHeld returns false. The following journal.read can then wait while an eligible offer is published. That publication increments offerChanges, but this pass does not check it again before filling the request as interrupted. The next pass cannot undo the first fill.
Revalidate the offer-change state after awaited reads and before expiry or fill. If the state changed, retain the request for another pass. Preserve immediate interruption settlement when no offer appears.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Keep the answer event when a restart continuation has no connector stamps.
The restart branch returns true before the empty-stamps fallback runs. A continuation with no connector stamps therefore emits only the turn state. Reply recovery fills outbox rows only from connector stamps, so no row delivers the answer. Before this branch, empty stamps returned false, and the normal answer event was emitted.
Suppress the answer only when recovery holds rows that cover this conversation. Otherwise, the answer must still be emitted through the normal path.
…uietly, and a restart continuation answers with the whole reply
Follow-up to the restart reply recovery that landed in #46044, #46068 and
#47898, carrying the two parts of #46048 main does not have.
- A fill recovery makes from a turn that ended over an hour ago, or any
recovery or restart-continuation fill of a request admitted over a day
ago, closes the request quietly (no post) instead of posting it. Rows now
record when they were admitted (admitted_at) and, locally, why a fill
closed quietly (expired_reason); each such close logs a warn line and
counts. A row with no date, and a request a usage-limit pause told its
thread to wait for, are never closed this way.
- A restart continuation's claimed requests are answered with the reply
the restart cut partway (each cut of a chain, oldest first, up to four),
then the continuation's own. A turn cut inside a tool call adds nothing,
and a failed read leaves the continuation's answer alone.
- The reply matrix harness reads cut replies as the app does, and its rows
carry real clock times.
Closing as superseded. Main fixed the core of this PR with a different design: #46044 (151f776), #46068 (1e2d5fb) and #47898 (d8747bb). A restart continuation now claims its cut's requests through a host-written connectorClaim, and recovery waits on continuationsSettled instead of offer-based holds. The two parts main lacked, quiet closes for answers too old to post and the whole answer after a restart, continue in #48642, rebuilt on main's design.
The open review findings are moot on main. None was waived; this is what replaced each one:
Finding
Status on main
r4650638618: the envelope hashed restartOf, so the host refused the continuation
restartOf does not exist on main. #46068 hashes the continuation envelope over agentSessionMessagePayload(body), which strips the host-written connectorClaim as every send does (structured-agent-session-restart-continuation-envelope.ts).
r4649431659: a person typing after the continuation ended counted as mirrored, so the answer was lost
The continuation_mirrored quiet close and personMessagesDuring are gone. #46068 decides the mirror from the cut opener's own mirrorPosts state (external-conversation-restart-cuts.ts), not from later messages.
r4649431664: an offer published between reads closed the row as interrupted
Main reads no offers. A cut row stays owed until this start's continuations settle (continuationsSettled, #46068), and the claim commits in the continuation's admission transaction.
r4649431661: a failed deadline read left the row open beyond 24 h
Main has no 24 h hold or deadline timer. Rows wait on continuationsSettled and the journal watch (#46068).
CodeRabbit r4650669024: disposal restored work after a pending read
The hold-deadline timers this was about don't exist on main. Main's dispose() clears the watches and settle timers it owns.
CodeRabbit r4650669028: hold re-check after the row read
No offer-based hold on main (see r4649431664).
CodeRabbit r4650669030: a restart continuation with no stamps lost its answer event
That branch of turn-ends.ts was removed. On main, #46044 makes a turn end state-only only when its stamps name the conversation; otherwise it keeps the full end.
…uietly, and a restart continuation answers with the whole reply
Follow-up to the restart reply recovery that landed in #46044, #46068 and
#47898, carrying the two parts of #46048 main does not have.
- A fill recovery makes from a turn that ended over an hour ago (a held
empty-turn answer judged by when its turn ended), or a fill of a request
admitted before this process started and over a day old, closes the
request quietly (no post). A live turn's request, a hidden retry's
included, never starts the request clock; a row with no admission date
never ages by it on any path; a row a usage-limit pause ever owed keeps
a paused mark through later cuts, claims and retry holds, and never
ages by it either.
- A quiet close fills under its own delivery id, and the answer of the
requests filled with it never keys on that id, so the outbox sends
disjoint events. Rows record admitted_at and, locally, expired_reason;
each close is counted and logged only once the journal shows it written.
- A restart continuation's claimed requests, and every request it answers
in that thread, get the whole reply: each cut of the chain's partial
prose, oldest first, then its own. The prose rides on the continuation's
claim, built from the read that already builds the claim, so the fill
reads no journal; over the answer cap the earlier part is cut with the
existing note.
- A recovery pass still reading when the host changes or connectors stop
writes, watches and schedules nothing once its read returns.
- The reply matrix harness carries real clock times and a process start.
Correction to the mapping above: the disposal finding (CodeRabbit r4650669024) is not fully moot. Its hold-deadline timers are gone on main. But a recovery pass still reading when the host changed or connectors stopped could re-attach a journal watch on the old host once its read returned, and a later publication could then arm the 2 s settle timer. #48642 fixes it at b70334c: each pass carries the dispose generation it began in, and writes, watches and schedules nothing once that is stale. It is tested across a host change and a connectors-off. The other six mappings stand.
…uietly
Follow-up to the restart reply recovery that landed in #46044, #46068 and
#47898 (refs #46048).
- A fill recovery makes from a turn that ended over an hour ago (a held
empty-turn answer judged by when its turn ended), or a fill of a request
admitted before this process started and over a day old, closes the
request quietly (no post). A live turn's request, a hidden retry's
included, never starts the request clock; a row with no admission date
never ages by it on any path; a row a usage-limit pause ever owed keeps
a paused mark through later cuts, claims and retry holds, and never
ages by it either.
- A quiet close fills under its own delivery id, and the answer of the
requests filled with it never keys on that id, so the outbox sends
disjoint events. Rows record admitted_at and, locally, expired_reason.
- Each quiet close is written in its own call, so its own commit result
says whether it closed; it is counted and logged only then. A call that
threw is looked up once by key, and an unconfirmed close is logged as
such, never counted.
- Recovery work begun before a dispose (another host, connectors off)
writes, watches and schedules nothing once it resumes: boot's first
read, each pass, a fill nested in it and a claim are bound to the
generation they began in, and a reply write queued on the journal's
lane asks whether it is still current when the writer takes it. A boot
asking to open a chat while a pass runs gets its pass run again opened.
- The reply matrix harness carries real clock times and a process start.
…uietly
Follow-up to the restart reply recovery that landed in #46044, #46068 and
#47898 (refs #46048).
- A fill recovery makes from a turn that ended over an hour ago (a held
empty-turn answer judged by when its turn ended), or a fill of a request
admitted before this process started and over a day old, closes the
request quietly (no post). A live turn's request, a hidden retry's
included, never starts the request clock; a row with no admission date
never ages by it on any path; a row a usage-limit pause ever owed keeps
a paused mark through later cuts, claims and retry holds, and never
ages by it either.
- A quiet close fills under its own delivery id, and the answer of the
requests filled with it never keys on that id, so the outbox sends
disjoint events. Rows record admitted_at and, locally, expired_reason.
- A fill's rows are written as one command in one writer transaction that
returns each row's result, so a batch commits whole or not at all. A
quiet close is counted and logged only when its row changed. A call that
fails probes its quiet closes once by key: one this attempt wrote wakes
the sender before the error is rethrown. A failed recovery pass is
settled again, and a live fill that throws still hands its rows to
recovery.
- Work begun before a dispose (another host, connectors off), and a live
turn end since reset, writes, holds, asks, watches, schedules and wakes
nothing: boot, each pass and nested fill, claims, the live fill and its
retry hold and send, the turn-end and retry callbacks, and the reply
write's admit, asked just before it is posted to the writer worker.
…uietly
Follow-up to the restart reply recovery that landed in #46044, #46068 and
#47898 (refs #46048).
- A fill recovery makes from a turn that ended over an hour ago (a held
empty-turn answer judged by when its turn ended), or a fill of a request
admitted before this process started and over a day old, closes the
request quietly (no post). A live turn's request, a hidden retry's
included, never starts the request clock; a row with no admission date
never ages by it on any path; a row a usage-limit pause ever owed keeps
a paused mark through later cuts, claims and retry holds, and never
ages by it either.
- A quiet close fills under its own delivery id, and the answer of the
requests filled with it never keys on that id, so the outbox sends
disjoint events. Rows record admitted_at and, locally, expired_reason.
- A fill's rows are written as one command in one writer transaction that
returns each row's result, so a batch commits whole or not at all. A
quiet close is counted and logged only when its row changed. A call that
fails probes its quiet closes once by key: one this attempt wrote wakes
the sender before the error is rethrown. A failed recovery pass is
settled again, and a live fill that throws still hands its rows to
recovery.
- Work begun before a dispose (another host, connectors off), and a live
turn end since reset, writes, holds, asks, watches, schedules and wakes
nothing: boot, each pass and nested fill, claims, the live fill and its
retry hold and send, the turn-end and retry callbacks, and the reply
write's admit, asked just before it is posted to the writer worker.
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
When Orca restarts while a bot is answering a Slack message, Orca resumes the work afterwards, but the bot's final answer never reached Slack. Now the resumed work's answer is posted to the thread that asked, once. An answer that is too old to be useful is closed quietly instead.
What Changed
interruptedwith no outcome. Reply recovery only read the outcome field, so it treated that turn as still running and left its Slack request open forever. It now reads the derived verdict.restartOf: the turn, the cut turn's row, or the send it resumes. The provider never sees it, and a client's send can't carry it becauseSendBodyis strict. Recovery verifies the binding and fills the original request with the continuation's answer, in its own thread. The checks: same session and epoch, exactly one match, an interruption, no other root turn in between, and at most 4 hops. Anything else binds nothing.quiet, no post), with a localexpired_reasoncolumn, a warn line and a counter. The limits are named constants inconnector-reply-policy.ts. They are deliberately conservative and easy to tune.Why
A restart left the reply outbox row open forever and the continuation's answer unattached. Fixing both in recovery keeps the live turn-end path unchanged. Checked against how comparable products handle this.
Visual Proof
N/A: no UI. The change is which answer the reply outbox sends to Slack after a restart, and the tests below cover it.
Testing
origin/mainand pass here. They cover:pnpm tcand oxlint, oxfmt and ast-grep on the changed files pass. The related suites pass, except three files that fail identically onorigin/mainon this host.Performance
No new polling and no extra reads on the live turn end. Recovery adds one offers-file read per settle of a chat with unfilled rows, plus lookups inside the window it already reads, and one timer per held chat at its durable deadline.
Review
AI-assisted change (Claude). Cross-platform: no platform-specific code; paths come from the existing capsule. SSH/remote: unchanged; recovery runs where the journal lives. Agents and integrations: the provider payload and send fingerprints exclude
restartOf, and only the Slack reply outbox changes. Mobile and older builds: columns are added byALTER, with nouser_versionchange; older builds ignore them and the new body field. Security: no new input surface. Client sends still go through the strictSendBody.Risk
Level: Medium.
expiredoutcome is a follow-up.