Skip to content

feat(events): add transactional booking outbox - #171

Open
fredericklamar342-prog wants to merge 6 commits into
DocForum:mainfrom
fredericklamar342-prog:fix/issue-94-transactional-outbox
Open

fredericklamar342-prog wants to merge 6 commits into
DocForum:mainfrom
fredericklamar342-prog:fix/issue-94-transactional-outbox

Conversation

@fredericklamar342-prog

Copy link
Copy Markdown

Summary

  • Add a PostgreSQL outbox written in the same transaction as booking and audit records; appointment.booked is the first event producer.
  • Dispatch events after commit using FOR UPDATE SKIP LOCKED, lease stale claims, and apply bounded exponential retries with dead-lettering after five attempts.
  • Make booking notifications idempotent with a unique notification source-event id; expose sanitized dead-letter metadata only to admins.
  • Document the at-least-once contract, migration, worker, and API.

Shared prerequisite

This branch includes the notification inbox implementation from PR #167, which is required for the booking notification handler. Please merge #167 first. After it lands, this branch may need rebasing to remove the shared prerequisite commit from this PR's diff.

Tests

Passed locally:

  • npm run prisma:generate
  • npm run audit:prod
  • npm run typecheck
  • npm test (96 passed)
  • npm run test:integration (171 passed)
  • npm run build

The broad npm run test:all command also includes the separate live-testnet payments suite; its setup fails when its external-network tests are skipped. The CI workflow uses the unit and self-contained integration commands listed above and does not include that directory.

Architecture and migration

Adds OutboxEvent and a nullable unique Notification.sourceEventId field. Apply the new Prisma migration with the normal migration deploy process. Events are at-least-once; handlers must remain idempotent. Dead-letter responses omit payloads and expose only stable error codes and event metadata.

Closes #94

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@fredericklamar342-prog Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@fredericklamar342-prog Thanks for the PR. It can't be merged yet. To unblock it:

Merge conflicts: this branch conflicts with main. Please rebase onto the latest main (git fetch upstream && git rebase upstream/main), resolve the conflicts (often ROADMAP.md, ARCHITECTURE*.md or prisma/schema.prisma), and force-push.

Push to this same branch and CI will re-run. Once it's green and conflict-free, it'll be reviewed for merge.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 20, 2026
@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 21, 2026
@fredericklamar342-prog
fredericklamar342-prog force-pushed the fix/issue-94-transactional-outbox branch from 574330e to 9742a35 Compare October 21, 2026 09:43
@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 21, 2026
@github-actions

Copy link
Copy Markdown

@fredericklamar342-prog This PR now has merge conflicts with main, most likely because #173 (feat(payments): consolidate payment history, testnet validation, and payout privacy prototype) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@github-actions github-actions Bot added needs-rebase Has merge conflicts with main; the author needs to rebase and removed needs-rebase Has merge conflicts with main; the author needs to rebase labels Oct 22, 2026
@github-actions

Copy link
Copy Markdown

@fredericklamar342-prog This PR now has merge conflicts with main, most likely because #148 (feat(payments): SEP-10 Stellar Web Authentication server: challenge a…) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 27, 2026
@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@fredericklamar342-prog CI is failing at npm run typecheck with a syntax error:

src/modules/notifications/controllers/index.ts(90,1): error TS1005: '}' expected.

The notifications controller is missing a closing brace (it looks like a merge leftover). Please fix it, run npm run typecheck in backend/, and push.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 27, 2026
@github-actions

Copy link
Copy Markdown

@fredericklamar342-prog This PR now has merge conflicts with main, most likely because #164 (Implement cancellation policy (issue #56), waitlist with time-boxed offers (issue #55), and reschedule (issue #54)) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 29, 2026
@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@fredericklamar342-prog This push merged main but still has the syntax error from my earlier comment: src/modules/notifications/controllers/index.ts(90,1): error TS1005: '}' expected. The controller is missing a closing brace. Please run npm run typecheck in backend/ locally before pushing.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

@fredericklamar342-prog This PR now has merge conflicts with main, most likely because #257 (feat(pharmacy-orders, facilities): clean recovery of Phase 5 partial fulfillment + facility distance sorting) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Has merge conflicts with main; the author needs to rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase 6] Transactional outbox for domain events so notifications survive crashes

2 participants