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): name the answering turn in legacy /replies drains - #50275
When Orca restarts and then sends a saved bot answer back to Slack through the older delivery route, it labelled the answer with the time the answer was written instead of the conversation turn it belongs to. The cloud could not match the answer to its turn, so it could not credit it to the person who asked or cancel a duplicate fallback post. Now the answer carries the right turn label, the same way the newer route already does.
What Changed
src/main/connector-cloud/connector-reply-outbox.ts: the kill-switch /replies drain (ConnectorReplyOutbox.post, used when the hello does not list replies.outbox) now sends turnId: turnStartedAt ?? filledAt instead of turnId: filledAt. turnStartedAt is the start time already saved on the fill by fix(connectors): name the answering turn on a reply, and settle requests by the turn that answered them #47320, and replyEventsOf (the outbox route) already sends it.
Before: after a restart, every drained reply was labelled with its fill time.
After: each reply is labelled with the turn that answered it. Rows with no known turn start (for example, fills made by boot recovery) still fall back to filledAt.
The reply ID (from deliveryId) and answerDeliveryId are unchanged, so retries across the upgrade stay idempotent. No schema or migration change.
src/main/external-conversations/connector-reply-restart-matrix.test.ts: a new case in describe('the reply names the turn that answered it'). It uses a real SQLite journal with real admission and fillTurn, closes and reopens the DB, then drains through the real outbox with outbox: false and captures the post at the network boundary. It covers one row with a known turn start and one row that uses the fallback.
Why
The /replies contract defines turnId as the at time of the answering turn-started event. The orca reply RPC and the reply-events route both follow it. Only the legacy drain sent the fill time. Reusing the field that is already saved fixes the mismatch without another migration or a new way to attribute replies.
Refs #49891 (related investigation; not closed by this PR, because its real transport route and the hosted Working-message cleanup are still unverified).
Visual Proof
N/A. This changes the payload sent by a background main-process drain, not the renderer or any interaction. The before/after evidence is the regression test:
On main: expected [['d1', 1800000000000], …] to deeply equal [['d1', 1799999970000], …]. The fill time was sent instead of the turn start.
With the fix: both rows pass. d1 gets its turn start and d2 gets the fill-time fallback.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
With only the outbox line reverted to main, the new case fails as shown above. A separate 4-row probe got the fill time for every row on main, and the correct start times with the fix.
oxlint, oxfmt --check, the anti-slop and native code-quality oxlint configs, ast-grep, and the changed-code quality gate are all clean on both files.
Platform: macOS, local modules and SQLite. The change is pure data with no paths or shells. The real Slack/cloud round trip was not exercised.
Performance
None, because this is one extra field read with ?? on the kill-switch drain. That is a cold path that makes one awaited network post per row. Microbench over a 200-row page: about 0.12 us before and 0.35 us after, against at least one network round trip per row. No new I/O, timers, polling or sync work.
Risk
Level: Low
On Slack, a reply drained through the kill-switch route after a restart can now get the asker's member stamp. That stamp can wake other bots in the thread, and it lets the cloud cancel the duplicate turn-end fallback post. This matches what the reply-events route already does, but it is a visible change in behaviour. Several rows from one turn now share a turnId, which the orca reply RPC already does. Both routes validate turnId with the same EpochMsSchema, so the change cannot cause a new 400. A plain revert backs this out; no migration is involved.
Review
One production line plus one regression case. No UI, auth, schema, path or platform-specific code. The same outbox runs on local and remote hosts, and the payload shape is unchanged, so mixed-version peers are unaffected.
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
Original fix by @LuisQin01 in #50275. Their authorship is preserved on the commit. The maintainer folded the regression test into the existing restart matrix (the separate connector-reply-turn-identity.test.ts file was dropped) and destructured turnStartedAt alongside the other fill fields.
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)
No actionable comments were generated in the recent review.
Walkthrough
The legacy /replies payload now uses the persisted turnStartedAt as turnId when available. If it is absent, the payload uses filledAt. A restart test checks both cases after reopening the journal and draining the outbox.
Severity of issue fixed: Low
Merge Risk: Minimal · up to 4ea28
The legacy /replies payload now reports the answering turn's start time as turnId, with the fill time as the fallback when none was recorded. No schema or identifier changes accompany it, and the change adds no performance cost. No merge-blocking risk remains beyond normal CI approval.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Directly linked issue #50267 requires legacy /replies to send the persisted answering turn start as turnId when known, and to keep the filledAt fallback otherwise. At the current head 4ea2804, t…
Out of Scope Changes check
The production change is a single-line payload change in the outbox that directly implements #50267, and the destructuring addition supports it. The test change is confined to the reply-restart matrix…
Title check
The title names the change: the legacy /replies drain now sends the answering turn as turnId instead of the fill time. It is specific and matches the main change in the changeset. The fix: connector-r…
Description check
The description follows the repository template and fills every required section: ELI5, What Changed, Why, Linked Issue (Fixes #50267), Visual Proof (N/A with reason), Testing, Performance, Risk with …
Full details: Linked Issues check
Explanation
Directly linked issue #50267 requires legacy /replies to send the persisted answering turn start as turnId when known, and to keep the filledAt fallback otherwise. At the current head 4ea2804, the whole-PR diff against merge base 33dfd04 changes src/main/connector-cloud/connector-reply-outbox.ts in the client.post payload from turnId: filledAt to turnId: turnStartedAt ?? filledAt. The destructuring now reads turnStartedAt from row.fill. This implements both the known-start and fallback behavior. The added regression in src/main/external-conversations/connector-reply-restart-matrix.test.ts fills one reply with a known TURN_AT and one without a start, closes and reopens the SQLite journal, drains through ConnectorReplyOutbox with a captured client.post, and asserts [answerDeliveryId, turnId] equals [d1, TURN_AT] and [d2, NOW]. Schemas, reply IDs, and delivery IDs are unchanged in the diff. #49891 is context only and is correctly not closed. Residual uncertainty: the PR description names connector-reply-turn-identity.test.ts, which is absent at head; the regression is in the restart-matrix file instead. Live Slack/cloud behavior is not verified, and the issue does not require it.
Full details: Out of Scope Changes check
Explanation
The production change is a single-line payload change in the outbox that directly implements #50267, and the destructuring addition supports it. The test change is confined to the reply-restart matrix test file and adds one regression case covering the same objective. It adds the ConnectorReplyOutbox and ConnectorReplyBody imports it needs. No schema, UI, authentication, file path, or migration change appears in the inspected diffs. Documentation gap only: the PR description cites src/main/external-conversations/connector-reply-turn-identity.test.ts, which does not exist at head. This is a traceability mismatch, not an out-of-scope change.
Full details: Title check
Explanation
The title names the change: the legacy /replies drain now sends the answering turn as turnId instead of the fill time. It is specific and matches the main change in the changeset. The fix: connector-reply-outbox.ts uses turnStartedAt ?? filledAt, with a regression test in the restart matrix.
Full details: Description check
Explanation
The description follows the repository template and fills every required section: ELI5, What Changed, Why, Linked Issue (Fixes #50267), Visual Proof (N/A with reason), Testing, Performance, Risk with level, Review, the upstream boundary checkbox, Notes, and Checklist. It gives a concrete before/after and a regression-test failure output. Gaps: the AI Disclosure section is left as the template comment, which the template says to skip for internal contributors. The final checklist item for pnpm lint/typecheck/test/build is unchecked, and the Testing section says the changed-file gate passed but does not confirm the full suite.
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; 9 remain after this review.
The local changed-file gate passed all 28 checks after rebasing, and CodeRabbit completed successfully with no actionable comments. Those results do not substitute for Actions. The PR remains limited to #50267; the new NO_REPLY observation in #49891 is being investigated separately.
The kill-switch /replies drain sent turnId: filledAt, but the contract
defines turnId as the answering turn-started time. Send the persisted
fill.turnStartedAt, as the reply-events route already does, and fall
back to filledAt when no turn start was recorded (boot-recovery fills).
Fixesstablyai#50267
Co-authored-by: Neil <[email protected]>
nwparker
changed the title
fix(connectors): preserve answering turn identity in legacy replies
fix(connectors): name the answering turn in legacy /replies drains
Nov 27, 2026
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 and then sends a saved bot answer back to Slack through the older delivery route, it labelled the answer with the time the answer was written instead of the conversation turn it belongs to. The cloud could not match the answer to its turn, so it could not credit it to the person who asked or cancel a duplicate fallback post. Now the answer carries the right turn label, the same way the newer route already does.
What Changed
src/main/connector-cloud/connector-reply-outbox.ts: the kill-switch/repliesdrain (ConnectorReplyOutbox.post, used when the hello does not listreplies.outbox) now sendsturnId: turnStartedAt ?? filledAtinstead ofturnId: filledAt.turnStartedAtis the start time already saved on the fill by fix(connectors): name the answering turn on a reply, and settle requests by the turn that answered them #47320, andreplyEventsOf(the outbox route) already sends it.filledAt.deliveryId) andanswerDeliveryIdare unchanged, so retries across the upgrade stay idempotent. No schema or migration change.src/main/external-conversations/connector-reply-restart-matrix.test.ts: a new case indescribe('the reply names the turn that answered it'). It uses a real SQLite journal with real admission andfillTurn, closes and reopens the DB, then drains through the real outbox withoutbox: falseand captures the post at the network boundary. It covers one row with a known turn start and one row that uses the fallback.Why
The
/repliescontract definesturnIdas theattime of the answeringturn-startedevent. Theorca replyRPC and the reply-events route both follow it. Only the legacy drain sent the fill time. Reusing the field that is already saved fixes the mismatch without another migration or a new way to attribute replies.Linked Issue
Fixes #50267
Refs #49891 (related investigation; not closed by this PR, because its real transport route and the hosted Working-message cleanup are still unverified).
Visual Proof
N/A. This changes the payload sent by a background main-process drain, not the renderer or any interaction. The before/after evidence is the regression test:
expected [['d1', 1800000000000], …] to deeply equal [['d1', 1799999970000], …]. The fill time was sent instead of the turn start.d1gets its turn start andd2gets the fill-time fallback.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
pnpm exec vitest run src/main/external-conversations/connector-reply-restart-matrix.test.ts src/main/connector-cloud/: 15 files, 190 tests passed.With only the outbox line reverted to main, the new case fails as shown above. A separate 4-row probe got the fill time for every row on main, and the correct start times with the fix.
oxlint,
oxfmt --check, the anti-slop and native code-quality oxlint configs, ast-grep, and the changed-code quality gate are all clean on both files.Platform: macOS, local modules and SQLite. The change is pure data with no paths or shells. The real Slack/cloud round trip was not exercised.
Performance
None, because this is one extra field read with
??on the kill-switch drain. That is a cold path that makes one awaited network post per row. Microbench over a 200-row page: about 0.12 us before and 0.35 us after, against at least one network round trip per row. No new I/O, timers, polling or sync work.Risk
Level: Low
On Slack, a reply drained through the kill-switch route after a restart can now get the asker's member stamp. That stamp can wake other bots in the thread, and it lets the cloud cancel the duplicate turn-end fallback post. This matches what the reply-events route already does, but it is a visible change in behaviour. Several rows from one turn now share a
turnId, which theorca replyRPC already does. Both routes validateturnIdwith the sameEpochMsSchema, so the change cannot cause a new 400. A plain revert backs this out; no migration is involved.Review
One production line plus one regression case. No UI, auth, schema, path or platform-specific code. The same outbox runs on local and remote hosts, and the payload shape is unchanged, so mixed-version peers are unaffected.
Agent skill upstream boundary
Notes
Original fix by @LuisQin01 in #50275. Their authorship is preserved on the commit. The maintainer folded the regression test into the existing restart matrix (the separate
connector-reply-turn-identity.test.tsfile was dropped) and destructuredturnStartedAtalongside the other fill fields.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)