Real external adapters (BankApi/PartyDocumentApi/DocumentAnalyzer) + activate sync/analysis in apps/api #50

Closed
opened 2026-07-04 12:11:45 +00:00 by momsse · 1 comment
Owner

Migré depuis viziertronic/octant#112 — ouvert le 2026-06-27 par @momsse.

Follow-up from #48 (epic #42).

#48 composed the matcher backend into apps/api and activated the port-free pieces (the matching/supersede/supporting/creation/last-check saga projections, the reconcile + accounting-period daemons, all repositories/queries/migrations). The pieces that depend on the still-unimplemented external ports were deliberately left unwired rather than bound to test doubles in production (a stub DocumentAnalyzer would irreversibly archive every document).

Deferred until real adapters exist:

  • BankApi adapter → wire SynchroniseBankAccountUseCase + SynchroniseBankAccountsDaemonLayer.
  • PartyDocumentApi adapter → wire SynchronizePartyDocumentsUseCase + SynchronizePartyDocumentsDaemonLayer.
  • DocumentAnalyzer adapter → wire DocumentAnalysisSaga projection.

Work

  • Implement real adapters (HTTP/aggregator for BankApi & PartyDocumentApi — see #32/#35; a real analyzer for DocumentAnalyzer).
  • Add their Live layers and re-introduce the five pieces into apps/api/src/di/matcher.layer.ts (MatcherExternalPortsLayer, the analysis projection, the two sync use-cases, the two sync daemons).

Also surfaced in the #48 review (track separately if desired): per-package *ProjectionLayer exports for the matcher sagas (the cross-context transaction-matching sagas need a home — possibly a postgres-transaction-matching package), and a multi-projector projection runner so two sagas over one aggregate stream don't double-poll.

> _Migré depuis [viziertronic/octant#112](https://github.com/viziertronic/octant/issues/112) — ouvert le 2026-06-27 par @momsse._ Follow-up from #48 (epic #42). #48 composed the matcher backend into apps/api and activated the **port-free** pieces (the matching/supersede/supporting/creation/last-check saga projections, the reconcile + accounting-period daemons, all repositories/queries/migrations). The pieces that depend on the still-unimplemented external ports were **deliberately left unwired** rather than bound to test doubles in production (a stub `DocumentAnalyzer` would irreversibly archive every document). Deferred until real adapters exist: - **BankApi** adapter → wire `SynchroniseBankAccountUseCase` + `SynchroniseBankAccountsDaemonLayer`. - **PartyDocumentApi** adapter → wire `SynchronizePartyDocumentsUseCase` + `SynchronizePartyDocumentsDaemonLayer`. - **DocumentAnalyzer** adapter → wire `DocumentAnalysisSaga` projection. ## Work - Implement real adapters (HTTP/aggregator for BankApi & PartyDocumentApi — see #32/#35; a real analyzer for DocumentAnalyzer). - Add their `Live` layers and re-introduce the five pieces into `apps/api/src/di/matcher.layer.ts` (`MatcherExternalPortsLayer`, the analysis projection, the two sync use-cases, the two sync daemons). Also surfaced in the #48 review (track separately if desired): per-package `*ProjectionLayer` exports for the matcher sagas (the cross-context transaction-matching sagas need a home — possibly a `postgres-transaction-matching` package), and a multi-projector projection runner so two sagas over one aggregate stream don't double-poll.
Author
Owner

@momsse — 2026-06-27 (commentaire migré) :

Sign convention dependency from #47: amountsMatch now requires bank debits to carry a negative amountMinor (matched against positive document amounts). The real BankApi adapter wired here must emit debits as negative and credits as positive accordingly — otherwise no outgoing-payment match candidate is produced in production. (Today nothing enforces it; the test-only adapter and saga fixtures are sign-agnostic.)

> _@momsse — 2026-06-27 (commentaire migré) :_ Sign convention dependency from #47: `amountsMatch` now requires bank debits to carry a **negative** `amountMinor` (matched against positive document amounts). The real `BankApi` adapter wired here must emit debits as negative and credits as positive accordingly — otherwise no outgoing-payment match candidate is produced in production. (Today nothing enforces it; the test-only adapter and saga fixtures are sign-agnostic.)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
momsse/octant#50
No description provided.