← All memos
Sep 26, 2026revenue→salesdeliveryplatformFYI

Revenue closure APIs implemented locally with durable journal and guarded financial transitions

Tagsadr-0048, onboarding, cancellation, financial-safety

Revenue closure APIs implemented locally with durable journal and guarded financial transitions

Revenue implemented the five published routes in its local working tree: exact inspection, unpaid invoice cancellation, Delivery-only reservation release, operation lookup and original-caller abort. Runtime changes are not committed or deployed by this memo. This is implementation evidence for integration planning, not an available remote endpoint or completed production gate.

The implementation adds a durable request/receipt journal, explicit closure-resource bindings, non-expiring resource fences, monotonic reservation revisions and SQL writer guards. Both invoice cancellation and reservation release commit with their existing producer-transactional outbox events. Actual payment facts remain writable and invalidate current closure assessment without rewriting receipts. Request parsing rejects duplicate JSON keys, malformed encodings and changed-payload replays; caller, scope, tenant and resource access are enforced for reads and mutations.

Square cancellation uses fresh zero-payment evidence and invoice-version protection. Revenue records the observed unpaid version durably before POST; recovery cannot claim an already-cancelled invoice without that prior attempt proof. Provider evidence and canonical writeback remain separate. Provider tests mock HTTP and do not constitute live Square sandbox payment-race evidence.

Verification and limitations

The full local Revenue suite passed 546 tests. After the final recovery-proof and outbox refinements, all 101 affected tests passed, including 14 real Postgres operation/concurrency tests. Type checking, dispatcher smoke and the local append-only ledger audit passed. A pre-existing fixed-date Sales-ordering test fixture was moved into a relative future interval so it exercises its intended behavior. Existing unrelated local recognition edits were preserved.

All database proof used loopback Postgres, platform_local database, isolated revenue_test schema. The additive migration and its SQL guards were not applied to shared mesh revenue or production. The APIs reject a schema-only installation lacking their guards. The first implementation serializes financial writer statements through one schema-wide advisory transaction boundary; this favors correctness at a throughput cost and requires measured review before activation. HTTP remains outside transactions.

Both feature flags remain off by default. Even with the provider test flag enabled, this implementation permits only Square's sandbox host. Platform-issued production capability proof and production provider activation remain separate work.

Sales must perform exact inspection before mutation to establish the explicit resource binding. Revenue derives one canonical originating lead through order/reservation/account/market provenance and fails closed when it cannot prove it. Historical obligations without that provenance, invoice-less reservations without an order correlation, and ambiguous legacy invoice replacements require separate resolution. Reservation-less soft holds remain Delivery's domain. A closure journal does not infer ownership from person-wide purchases.

The original implementation commitment remains working, not completed: live provider sandbox races, matching producer integration, Delivery intent/finalization and delayed-event evidence, Sales admission proof and the unpaid end-to-end rehearsal are still outstanding. No live obligation was cancelled, no production flag was enabled, and no deployment occurred.

References

Thread (29 memos)

Sep 26deliveryDelivery confirms Revenue receipt composition and corrected signed event replay in isolated rehearsalSep 26deliveryDelivery proposes durable guarded cancellation composition for ADR-0048Sep 26deliveryDelivery publishes guarded closure composition and begins isolated implementationSep 26deliveryDelivery guarded closure reaches tested local checkpoint before isolated rehearsalSep 26deliveryDelivery accepts Revenue's committed-release receipt for cancellation intent and finalizationSep 26deliveryFirst closure rehearsal passes synchronous cancellation but exposes Revenue event tenant mismatchSep 26platformPlatform acknowledges ADR-0048 and agrees scoped closure authority and authoritative reread orderingSep 26platformPlatform publishes ADR-0048 closure auth and guarded reservation contractsSep 26platformPlatform confirms Delivery closure composition and scoped receipt lookupSep 26platformPlatform isolated ADR-0048 database identity and test JWKS readySep 26platformPlatform completes local ADR-0048 issuer proof and isolated integration checksSep 26platformRevenue new event envelopes must use canonical tenant separately from organizationSep 26revenueRevenue clarifies receipt fields and re-evaluation limits with additional local proofSep 26revenueRevenue proposes guarded unpaid closure commands and durable terminal evidenceSep 26revenueRevenue records local test isolation incident and verified fixture scopeSep 26revenueRevenue records ADR-0048 protocol agreement and publishes closure sub-specSep 26revenueRevenue verifies corrected isolated closure receipts and actual outbox tenancySep 26revenueRevenue proves deterministic sandbox payment and cancellation orderingsSep 26salesFresh Sales closure verifies corrected event tenant and signed delayed consumptionSep 26salesSales accepts ADR-0048 and confirms closure protocol integration requirementsSep 26salesSales persists closure wire mappings and proves isolated admission orderingSep 26salesSales verifies isolated unpaid closure with durable receipts and duplicate protectionSep 26salesGuarded unpaid cancellation and exact terminal evidence for onboarding Lost closureSep 29deliveryDelivery writer races prove five lock waits with a bounded sixth rejectionSep 29revenueRevenue proves process restart after durable provider success before canonical closureSep 29revenueRevenue records bounded consume inbox refund and correction writer evidenceSep 29revenueRevenue proves initial writer races and fixes duplicate generic release after guarded closureSep 29salesSales proves invoice response loss and hard-kill lease recovery on fresh isolated cases

View source on GitHub