Repository navigation
fix(j5): a refused new message in a shared conversation leaves no author record - #863
Merged
Merged
Conversation
…hor record A person's new message, and a launch's first message, recorded its author, note and stored prefix while J5 admitted it, before upstream dispatched it. If upstream refused it, the record stayed with no message behind it, and a retry under the same message id kept the old prefix and note. stampMessage now checks the message id is the author's at admission, as before, and returns its record write instead of running it. SharedConversation.dispatch runs that write after upstream accepts, as it does for edits since #739, and the write is conditional on the stored text being exactly this message's. Launches go through a new SharedConversation.launch, wrapped around upstream's launch in ws.ts as dispatch is, and its write runs whether upstream's launch succeeds or fails, because a launch can store the message and then fail. Closes #740 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
This review includes 8 billable files and costs up to $2.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 9 minutes for your next included review. View limit details
|
…efusal Review of #863 found that writing a new message's author record only after upstream accepted it dropped the reservation that refuses a second sender under the same message id, and broke the timeline's assumption that a message's record exists before the message does. The record is written at admission again, exactly as on j5/main. If upstream's dispatch or launch fails, the record is deleted, but only while upstream stored no message under that id, so a request that fails after upstream committed the message keeps its record. A retry under the same id after a refusal then records afresh. Queued edits keep #739's deferred, conditional write. The launch still needs the callback shape in ws.ts to release on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #863 found that two overlapping attempts by the same person under the same message id share one record: the second finds the first's row, and if the second then failed, its release deleted that row, so the first committed with no record. recordAuthor now reports whether its insert wrote the row, and a message's release does nothing unless this attempt wrote it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully 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.
Problem
In a shared conversation,
stampMessagewrites a new message's author record (author, note, stored prefix) while J5 admits it, before upstream dispatches it. If upstream refused the message, the record stayed with no message behind it. Because the insert isON CONFLICT … DO NOTHING, a retry under the same message id kept the old prefix and note, so the platform's lines might not be stripped and the note might be wrong. A launch's first message had the same problem, and clients send a stable draftmessageIdon launch.Closes #740
What changed
The fix reserves the record at admission and releases it if upstream refuses.
SharedConversation.dispatchdeletes the record, but only while upstream holds no message under that id (DELETE … AND NOT EXISTS (SELECT 1 FROM orchestration_v2_projection_messages WHERE message_id = …), one statement). So a request that fails after upstream committed the message keeps its record. A refused message's row, with itstold_json, goes away, so a retry under the same id records afresh with the current name, prefix and note.SharedConversation.admitLaunchbecomesSharedConversation.launch(personId, input, upstreamLaunch), andCommandAdmission.admitLaunchbecomeslaunchThread(input, upstreamLaunch).ws.tsnow wraps upstream's launch handler the way it already wraps dispatch, so a failed launch releases its first message's record under the same condition.An attempt releases only a record it wrote itself:
recordAuthornow reports whether its insert wrote the row (RETURNING). So a retry that overlaps a pending send under the same id finds the first attempt's row, and if the retry fails it leaves that row in place.A failure to release is logged. That message's record then stays as it was, which is the behaviour before this PR.
Tests (on upstream's real orchestrator, in
SharedConversation.integration.test.ts):OrchestratorDispatchError). No record and no stored message remain. She is renamed, sends again under the same id, and the record names "Priya Shah" with a prefix equal to the stored text's.ThreadLaunchError), and no record remains. The relaunch under the same message id records the current name and the matching prefix.conversation.launchwith upstream's real launch, and also checks that the record's prefix matches the stored text.Upstream impact
apps/server/src/ws.ts, FORK.md case 78: theorchestration.launchThreadentry inadmittedHandlersis nowj5Commands.launchThread(input, upstream's handler), which replacesadmitLaunch(input).pipe(Effect.flatMap(…)). The launch needs this callback shape to release on failure. It is one line shorter. The case 78 text in FORK.md is updated to match. Its file-table row already lists 78.Review
GPT-6-Astra and Claude Fable 5.1 reviewed the first version, which deferred a conditional insert until upstream accepted the message. That dropped the id reservation: two senders under one id could both pass admission. It also broke the timeline's assumption that a message's record exists before the message. This version restores the eager write and releases it on refusal instead. Astra's second round found that an overlapping retry's release could delete the first attempt's row. Each attempt now releases only a row it wrote.
Checklist
lastToldalready ignored run-less messages), and the regression tests drive upstream's real orchestrator and launch with their real refusals.FORK.md(case text and file-table row) in this PRorchestration.dispatchCommandandorchestration.launchThreadviaCommandAdmission, which web, desktop and mobile all use. Agents and service sessions have no person and were never stamped. No contract change.vp run check:changedpasses: format, lint, knip, typecheck of 3 packages, and the tests beside changes. All 28 test files that import the changed modules pass (205 tests).Built by Claude Opus 5.5 in Claude Code (J5 Code).
🤖 Generated with Claude Code