docs: distribution and reconciliation architecture map (#537) - #636
Merged
thlpkee20-wq merged 2 commits intoJul 29, 2026
Merged
Conversation
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
force-pushed
the
docs/architecture-distribution-reconciliation
branch
from
July 28, 2026 22:45
dfa79d3 to
836dd0d
Compare
|
@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! 🚀 |
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.
Summary
Author
docs/architecture/distribution-reconciliation.mdas 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
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, reconciliationisBalanced), 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.src/services/distributionEngine.tssrc/services/distributionScheduler.tssrc/services/revenueReconciliationService.tssrc/services/reconciliationScheduler.tssrc/services/outboxDispatcher.tssrc/db/repositories/distributionRepository.tssrc/db/repositories/revenueReportRepository.tssrc/db/repositories/outboxRepository.tssrc/routes/distributions.tssrc/routes/reconciliationRoutes.tsBehavioural change
None. Only JSDoc
@seeblocks and one new markdown file. No runtime code paths touched.Validation
npx tsc --noEmit— pre-existing TS1005 errors indistributionScheduler.test.ts:763andstatementDataProvider.ts:157exist onmasterand are unrelated to this commit (verified by stashing and checking master).npx jestagainst the 9 affected suites — 65 pre-existing failures, 201 passing. Identical onmaster(verified). No new failures introduced.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
withTransactionblock).Follow-ups (tracked as separate issue suggestions, not in this PR)
distribution_runs.statusstate machine currently listspendingas the initial state, butDistributionEngine.distributeWithBatchcreates runs withstatus: "processing"directly. Either droppendingfrom the diagram or annotate that it is reserved for direct repository insertion.revenue_reports.distribution_statusstate machine conflates thestatus(approval) anddistribution_status(distribution progress) columns. Split into two diagrams or annotate the claim query's preconditions.Issue
Closes #537.