Skip to content

Add transactional outbox table for vault lifecycle events in db/migrations and src/services/eventProcessor.ts #464

@1nonlypiece

Description

@1nonlypiece

Add transactional outbox table for vault lifecycle events in db/migrations and src/services/eventProcessor.ts

Description

src/services/eventProcessor.ts writes vault state and triggers notifications in the same flow, which loses notifications if the process crashes between the DB commit and the queue push. Add a transactional outbox: write events to a vault_outbox table within the same Prisma transaction, and let a separate worker dispatch them at-least-once.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • New Knex migration creating vault_outbox(id, type, payload_json, created_at, dispatched_at)
  • Add OutboxDispatcher worker in src/jobs/handlers.ts
  • Add src/tests/outboxDispatcher.test.ts
  • Update docs/event-processing.md
  • Reuse retry strategy from src/utils/retry.ts

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/vault-outbox
  • Implement changes
    • Add migration and Prisma model
    • Update event processor
    • Add tests and docs
  • Test and commit
    • Run npm run migrate:latest && npm test
    • Include test output and notes

Example commit message

feat: transactional outbox for vault lifecycle events

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendDisciplr API serverdatabaseintegrationCross-service integration

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions