Skip to content

refactor(service-messaging): migrate isUniqueViolation onto the shared @objectstack/types predicate (#6542) - #6618

Merged
os-project-manager merged 1 commit into
mainfrom
claude/issue-6542-messaging-shared-unique-predicate
Aug 8, 2026
Merged

refactor(service-messaging): migrate isUniqueViolation onto the shared @objectstack/types predicate (#6542)#6618
os-project-manager merged 1 commit into
mainfrom
claude/issue-6542-messaging-shared-unique-predicate

Conversation

@os-project-manager

Copy link
Copy Markdown
Collaborator

Closes #6542

What

Migrates service-messaging off its private hand-written isUniqueViolation() (the last of the four copies #6250 inventoried, and the one the shared predicate was seeded from) onto isUniqueViolationError from @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 in upsertReadReceipt), 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 cause chain (pool and query-builder layers wrap the driver error). The old copy read only the top-level code/message, judged a wrapped conflict "not a conflict", and rethrew — markRead logged the failure, reported readCount: 0, and the receipt stayed delivered. Now the wrapped conflict triggers the flipToRead() 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:

  • Wrapped conflict (new behaviour): a wrapper whose own text matches none of the predicate's signals, carrying the Postgres conflict as cause, exercised through the real markReadupsertReadReceipt path; asserts readCount: 1 and convergence to the concurrent row.
  • Unwrapped three-dialect pin (unchanged behaviour): it.each over 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 eslint on 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

…d @objectstack/types predicate (#6542)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01USNUyHEr7uaU6MoEWXitei
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 8, 2026 7:25am

Request Review

@github-actions github-actions Bot added the size/m label Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-messaging.

4 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/automation/webhooks.mdx (via @objectstack/service-messaging)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/service-messaging)
  • content/docs/plugins/packages.mdx (via @objectstack/service-messaging)
  • content/docs/releases/implementation-status.mdx (via @objectstack/service-messaging)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file tests tooling labels Aug 8, 2026
@os-project-manager
os-project-manager marked this pull request as ready for review August 8, 2026 07:26
@os-project-manager
os-project-manager added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit 932d7e2 Aug 8, 2026
26 checks passed
@os-project-manager
os-project-manager deleted the claude/issue-6542-messaging-shared-unique-predicate branch August 8, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service-messaging still carries its own hand-written isUniqueViolation() — migrate it onto the shared @objectstack/types predicate

2 participants