refactor(service-messaging): migrate isUniqueViolation onto the shared @objectstack/types predicate (#6542) - #6618
Merged
os-project-manager merged 1 commit intoAug 8, 2026
Conversation
…d @objectstack/types predicate (#6542) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01USNUyHEr7uaU6MoEWXitei
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 4 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-project-manager
marked this pull request as ready for review
August 8, 2026 07:26
os-project-manager
enabled auto-merge
August 8, 2026 07:26
os-project-manager
deleted the
claude/issue-6542-messaging-shared-unique-predicate
branch
August 8, 2026 07:52
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.
Closes #6542
What
Migrates
service-messagingoff its private hand-writtenisUniqueViolation()(the last of the four copies #6250 inventoried, and the one the shared predicate was seeded from) ontoisUniqueViolationErrorfrom@objectstack/types(landed in PR #6541).packages/services/service-messaging/src/messaging-service.ts— import swap at the single call site (the inbox read-receipt check-then-act race fallback inupsertReadReceipt), local function deleted.packages/services/service-messaging/package.json— the card said the dep was already present; re-verification showed it was NOT, so@objectstack/types(workspace) is added here, with the lockfile entry. This is the one deviation from the card's premise, and it was declared in scope by dispatch for exactly this case.The one behaviour change, tested at the call site
The shared predicate additionally follows a bounded number of steps down the
causechain (pool and query-builder layers wrap the driver error). The old copy read only the top-levelcode/message, judged a wrapped conflict "not a conflict", and rethrew —markReadlogged the failure, reportedreadCount: 0, and the receipt stayeddelivered. Now the wrapped conflict triggers theflipToRead()convergence, same as a bare driver error. That is the direction the call site wants: a wrapped conflict is still a conflict.Tests added in
messaging-service.test.ts:cause, exercised through the realmarkRead→upsertReadReceiptpath; assertsreadCount: 1and convergence to the concurrent row.it.eachover plain Postgres (23505), MySQL (ER_DUP_ENTRY/errno 1062), and SQLite (UNIQUE constraint failed) error shapes through the same path — each converges identically to before.Reverse verification (direction decided beforehand)
With the old local predicate temporarily restored at the call site: exactly the wrapped-conflict test goes red (1 failed) and the three dialect pins plus the rest of the file stay green (51 passed). Restored, all green.
Verification
pnpm --filter '@objectstack/service-messaging' test— 16 files, 199 passed, 0 failed (main had 195; +4 new).pnpm --filter '@objectstack/service-messaging' typecheck— clean.npx eslinton both touched source files — exit 0.node scripts/check-nul-bytes.mjs— OK.Changeset:
.changeset/messaging-shared-unique-violation-predicate.md(patch,@objectstack/service-messaging).🤖 Generated with Claude Code
https://claude.ai/code/session_01USNUyHEr7uaU6MoEWXitei
Generated by Claude Code