Repository navigation
fix(mothership): serialize headless run admission with chat soft delete - #9107
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Critical impact] The PR appears safe to merge. SummaryThe PR makes headless run admission wait on the chat row so it cannot slip past a soft delete.
No actionable issues found. Tests were inspected but not run.
|
This branch was previously deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
createRunSegment: task wake, inbox, v2 chat, Slack, knowledge chat, benchmarks) neither locked nor checked the chat row. A run inserted after a soft delete's live-run query was never stopped by that delete. Chat-view admission (admitChatTurn) was already safe because it UPDATEs the chat withdeletedAt IS NULL.insertRunSegmentnow reads the chat rowFOR SHARE, after the run-admission advisory lock, which is the same orderadmitChatTurnuses.FOR SHAREconflicts with the soft delete's UPDATE, so either the delete commits first and the run is insertedcancelledwith tool admission closed atdeletedAt, or the delete waits and itsstopLiveRunsTxsees the run and stops it.createRunSegmentdirectly already treat acancelledadmission like a Stop that arrived before admission, without calling the worker. Slack was the exception: it ignored the status. It now ends the turn as that Stop would, so it never calls the worker.KEY SHARElock conflicts with the delete'sFOR UPDATE. Behaviour for live chats is unchanged. The cost is one extra indexed primary-key read per run-segment insert.Type of Change
Testing
removal-stops-runs.integration.ts(real Postgres and Redis):assistant.integration.ts: a Slack turn whose chat was deleted before admission never starts the worker.Checklist