Accepted — conditionally pending UFST HDP platform validation (TB-028-a)
Trigger: P058 (Modregning og Korrektionspulje) implementation added immudb writes from
opendebt-debt-service for offsetting records. The original ADR scoped immudb exclusively to
opendebt-payment-service. This amendment records the approved scope expansion.
Additional tables / records now written to immudb:
| Record | Service | Rationale |
|---|---|---|
ModregningEvent |
debt-service | Each set-off decision against a public disbursement (Nemkonto / GIL § 16 stk. 1) has legal standing. The decision amount, tier allocation, and klage-frist must be cryptographically non-repudiable for use in Rigsrevisionen audits and appeal proceedings. |
CollectionMeasure (SET_OFF type) |
debt-service | The SET_OFF collection-measure record links the legal collection step to the ledger posting in payment-service. Tamper-evidence is required for cross-service reconciliation auditability. |
Integration pattern: Same dual-write as payment-service.
ModregningService.initiateModregning() is annotated @Transactional. After the PostgreSQL
commit, ModregningService calls ImmuLedgerClient.appendAsync() with the ModregningEvent
record. The immudb key is the ModregningEvent.id (UUID bytes); the value is a
JSON-serialised record. PostgreSQL is never rolled back if the immudb write fails.
"Where immudb is NOT used" — correction: The catch-all "All other entities" row in
the original decision table no longer covers ModregningEvent and SET_OFF
CollectionMeasure records in debt-service. All other debt-service entities remain
outside immudb scope.
Deployment prerequisite unchanged: Full acceptance of this ADR remains conditional on TB-028-a (UFST HDP platform validation). This amendment does not change that condition.
Related artefacts: petitions/petition058-modregning-korrektionspulje-solution-architecture.md
(§ NFR-3), architecture/workspace.dsl (GOV-003 relationship comment).
Spike outcome (TB-028, 2026-03-26): All implementable sub-tasks completed on
branch spike/TB-028-immudb-financial-ledger-integrity. Key findings:
io.codenotary:immudb4j:1.0.1is on Maven Central and integrates with Spring Boot 3.5 / Java 21.- Netty version conflict (Spring Boot 3.5 → Netty 4.1.131 vs gRPC 1.44.1 → Netty 4.1.74) resolved
by excluding
grpc-nettyand substitutinggrpc-netty-shaded:1.44.1. - Dual-write pattern (PostgreSQL primary + immudb tamper-evidence) is operational in the demo stack.
DemoDataSeederseeds all 28 ledger entries to immudb on startup, confirmed via REST API and theimmudb-view.pyaudit viewer script.- Remaining platform sub-tasks (TB-028-a: HDP validation, TB-028-d: latency measurement, TB-028-e: proof verification demo, TB-028-f: HA/backup assessment) remain open and are prerequisites for moving to Fully Accepted.
Condition for full acceptance: TB-028-a must confirm that immudb can be scheduled on the UFST Horizontale Driftsplatform with a persistent volume and accessible gRPC port (3322). If this is not feasible, this ADR must be revisited.
See docs/spike/TB-028-findings.md for detailed findings and acceptance criteria per sub-task.
2026-03-25
OpenDebt's financial ledger (ledger_entries, debt_events in payment-service) records
every financial movement against a debt: registrations, payments, interest accruals,
offsetting, write-offs, refunds, and storno corrections. These records:
- Are the source of truth for outstanding balances and afstemning (reconciliation)
- May be referenced in legal proceedings (fogedretten, klagesager)
- Are subject to Rigsrevisionen audit
- Represent binding financial obligations under Danish public law
The ledger is already designed for immutability: the storno pattern (ADR-0018)
prohibits modification of posted entries; corrections are always reverse + repost.
The debt_events table is an append-only event timeline.
Despite this application-level immutability, a PostgreSQL SUPERUSER can issue
UPDATE or DELETE against ledger_entries without leaving a trace in the application
audit trail. This is a trust gap that cannot be closed within PostgreSQL alone.
The general audit_log tables (ADR-0022) are shipped to the UFST Common Logging System
(CLS) via Filebeat, which provides an external anchor for operational audit events.
However, CLS is an ELK stack optimised for log search — it provides no
cryptographic proof of record integrity that can be presented as evidence.
immudb (codenotary/immudb) is an open-source, tamper-evident database built on a Merkle tree with a cryptographically signed transaction log. Every write produces a verifiable proof. A verifier (auditor, court, Rigsrevisionen) can independently confirm that no record was ever modified or deleted, without trusting the database operator.
A spike (TB-028) is required before this ADR is accepted, to validate platform support and integration cost.
Financial ledger entries and legally significant offsetting records — specifically:
| Table / Record | Service | Rationale |
|---|---|---|
ledger_entries |
payment-service | Every financial posting; legal record of monetary movements |
debt_events |
payment-service | Immutable event timeline; source of truth for debt state |
ModregningEvent |
debt-service | Set-off decision against Nemkonto disbursement (GIL § 16 stk. 1); legally binding, Rigsrevisionen-auditable. See P058 amendment above. |
CollectionMeasure (SET_OFF) |
debt-service | Collection-measure record linking the legal step to the ledger posting. See P058 amendment above. |
The integration pattern is dual-write:
BookkeepingService.record*()
├── save LedgerEntryEntity → PostgreSQL (primary; queryable, operational)
└── append LedgerRecord → immudb (tamper-evident; verifiable proof)
PostgreSQL remains the operational system of record. immudb is the cryptographic integrity layer — it is never queried for normal operations.
Each immudb record mirrors the PostgreSQL row exactly, keyed by transactionId
(the shared UUID linking a DEBIT+CREDIT pair). A verifier can retrieve any
transactionId from immudb and prove the amount, account codes, and dates were
never altered after posting.
The BookkeepingService is the sole write path; dual-write is implemented there
using an ImmuLedgerClient (Spring @Component, wrapping immudb4j) that appends
asynchronously after the PostgreSQL transaction commits. If the immudb write fails,
it is retried with exponential backoff and logged; the PostgreSQL record is never
rolled back. This preserves eventual integrity without degrading ledger availability.
| Area | Reason |
|---|---|
audit_log tables (all services) |
CLS/Filebeat provides sufficient external anchor; operational audit, not financial proof |
payments table |
Payment status is operational data, not a final ledger posting |
interest_journal_entries (debt-service) |
Intermediate calculation state; final outcome lands in ledger_entries |
fees table (debt-service) |
Supporting reference data; the fee posting is recorded in ledger_entries |
| Person registry | GDPR PII — must not be replicated to additional stores |
| Keycloak / config data | Not financial records; no legal standing requirement |
| Case events | Operational workflow history; CLS covers this |
KorrektionspuljeEntry (debt-service) |
Pool accounting state; not a final legal determination — settlement re-enters ModregningEvent which is in scope |
RenteGodtgoerelseRateEntry (debt-service) |
Reference / configuration data; no individual legal standing |
| All other debt-service entities | Application-level immutability (storno, history tables, sys_period) is sufficient |
| All other entities (other services) | Application-level immutability (storno, history tables, sys_period) is sufficient |
The guiding principle: immudb is reserved for records where cryptographic non-repudiation has legal or regulatory significance. It is not a general-purpose audit store.
- Cryptographic non-repudiation — Any financial record can be independently verified by an auditor without trusting the database operator or the application team.
- Closes the DBA trust gap — PostgreSQL
SUPERUSERaccess cannot silently alter posted ledger entries. - Low architectural disruption — Dual-write is isolated to
BookkeepingService; no changes to query paths, APIs, or other services. - Aligns with existing design — The storno-based, append-only ledger maps naturally to immudb's write model.
- Legal defensibility — Supports use of ledger records in fogedretten proceedings and Rigsrevisionen audits with cryptographic proof.
- Additional operational dependency — immudb must be deployed, monitored, backed up, and included in the DR plan (ADR-0028).
- Dual-write consistency — Eventual consistency between PostgreSQL and immudb means a window (seconds) where a record exists in PostgreSQL but not yet in immudb. Acceptable for the proof layer; not acceptable if immudb were the primary store.
- SDK maturity —
immudb4jis maintained by codenotary but is less widely used than the PostgreSQL ecosystem. Requires evaluation during spike. - Backup scope — immudb's own data must be included in backup strategy; its tamper-evidence is only meaningful if the immudb state itself is preserved.
- immudb runs as an independent Kubernetes
Deploymentalongside the existing stack. - No changes to existing PostgreSQL schema, Flyway migrations, or API contracts.
- Verification tooling (CLI, SDK) can be run independently by auditors without application access.
// opendebt-payment-service — BookkeepingService
@Transactional
public LedgerTransaction recordPaymentReceived(UUID debtId, BigDecimal amount, ...) {
// 1. Post to PostgreSQL (primary)
LedgerEntryEntity debit = ledgerEntryRepository.save(buildDebit(...));
LedgerEntryEntity credit = ledgerEntryRepository.save(buildCredit(...));
// 2. Append to immudb (integrity layer) — after commit, async with retry
immuLedgerClient.appendAsync(debit, credit);
return new LedgerTransaction(debit, credit);
}// opendebt-payment-service — ImmuLedgerClient
@Component
public class ImmuLedgerClient {
private final ImmuClient immuClient; // immudb4j
@Async
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, multiplier = 2))
public void appendAsync(LedgerEntryEntity... entries) {
for (LedgerEntryEntity entry : entries) {
immuClient.set(
entry.getId().toString(),
LedgerImmuRecord.from(entry).toBytes()
);
}
}
}# docker-compose.yml addition
immudb:
image: codenotary/immudb:latest
ports:
- "3322:3322"
- "9497:9497" # metrics
volumes:
- immudb-data:/var/lib/immudbBefore this ADR is accepted, the following must be validated:
- Platform support — Confirm immudb runs on UFST HDP Kubernetes (resource limits, storage class, network policies).
- SDK integration — Validate
immudb4jwith Spring Boot 3.3 / Java 21. - Dual-write latency — Measure async append overhead under realistic ledger load.
- Proof verification — Demonstrate that tamper-evidence proof API can be called by an external auditor without application credentials.
- Backup and HA — Assess immudb replication and backup options within existing DR strategy (ADR-0028).
Spike outcome determines whether this ADR moves to Accepted or Rejected.
- ADR-0013: Enterprise PostgreSQL with Audit and History
- ADR-0018: Double-Entry Bookkeeping
- ADR-0022: Shared Audit Infrastructure
- ADR-0027: Offsetting merged into debt-service (context for the debt-service scope expansion)
- ADR-0028: Backup and Disaster Recovery
- immudb — codenotary/immudb
- immudb4j Java SDK
- immudb documentation
- Rigsrevisorernes retningslinjer for IT-revision
- ADR-0018: Double-Entry Bookkeeping (storno pattern)