Skip to content

docs: distribution and reconciliation architecture map (#537) - #636

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
sladeoj:docs/architecture-distribution-reconciliation
Jul 29, 2026
Merged

docs: distribution and reconciliation architecture map (#537)#636
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
sladeoj:docs/architecture-distribution-reconciliation

Conversation

@sladeoj

@sladeoj sladeoj commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Author docs/architecture/distribution-reconciliation.md as the single, authoritative end-to-end architecture map of how offerings, revenue reports, the distribution engine, the reconciliation service, and the transactional webhook outbox interlock. Cross-link TSDoc added to every relevant service / route / repository file.

What changed

  • New doc: docs/architecture/distribution-reconciliation.md — 10 sections: subsystem map, end-to-end sequence diagrams (distribution run + reconciliation), four state machines (distribution_runs.status, revenue_reports.distribution_status, webhook_outbox.status, reconciliation isBalanced), database table ownership matrix, cross-reference matrix, security assumptions, failure-mode index, CI hooks, maintenance rules. All diagrams rendered from committed Mermaid sources so they diff-review cleanly.
  • Cross-link JSDoc headers added to the top of:
    • src/services/distributionEngine.ts
    • src/services/distributionScheduler.ts
    • src/services/revenueReconciliationService.ts
    • src/services/reconciliationScheduler.ts
    • src/services/outboxDispatcher.ts
    • src/db/repositories/distributionRepository.ts
    • src/db/repositories/revenueReportRepository.ts
    • src/db/repositories/outboxRepository.ts
    • src/routes/distributions.ts
    • src/routes/reconciliationRoutes.ts

Behavioural change

None. Only JSDoc @see blocks and one new markdown file. No runtime code paths touched.

Validation

  • npx tsc --noEmit — pre-existing TS1005 errors in distributionScheduler.test.ts:763 and statementDataProvider.ts:157 exist on master and are unrelated to this commit (verified by stashing and checking master).
  • npx jest against the 9 affected suites — 65 pre-existing failures, 201 passing. Identical on master (verified). No new failures introduced.
  • Code-reviewer pass: APPROVED (3 minor non-blocking notes captured as follow-ups).

Security notes

The doc explicitly enumerates the trust boundary (raw Stellar RPC errors never cross the API), the source of truth for payouts (on-chain Stellar tx), the lock ownership invariant (transaction-scoped advisory locks cannot leak), and the outbox atomicity requirement (outbox row + domain row must share a withTransaction block).

Follow-ups (tracked as separate issue suggestions, not in this PR)

  1. distribution_runs.status state machine currently lists pending as the initial state, but DistributionEngine.distributeWithBatch creates runs with status: "processing" directly. Either drop pending from the diagram or annotate that it is reserved for direct repository insertion.
  2. revenue_reports.distribution_status state machine conflates the status (approval) and distribution_status (distribution progress) columns. Split into two diagrams or annotate the claim query's preconditions.

Issue

Closes #537.

Author docs/architecture/distribution-reconciliation.md as the single,
authoritative map of how offerings, distributions, reconciliation, and the
webhook outbox interlock. Renders sequence diagrams and state machines
from committed Mermaid sources, and cross-links from every relevant
service / route / repository file.

No runtime behaviour changed; only JSDoc @see headers and a new markdown
file. The 65 pre-existing jest failures and 2 TS errors observed during
validation are present on master and unrelated to this commit.
@sladeoj
sladeoj force-pushed the docs/architecture-distribution-reconciliation branch from dfa79d3 to 836dd0d Compare July 28, 2026 22:45
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@sladeoj 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

@thlpkee20-wq
thlpkee20-wq merged commit 6ef30a1 into RevoraOrg:master Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: architecture overview for distribution + reconciliation subsystems

2 participants