From 7487e69fed58a101e391ec86a90077d1ca26f3ff Mon Sep 17 00:00:00 2001 From: Ryan Min Date: Mon, 26 Oct 2026 21:47:29 +0900 Subject: [PATCH] test: pin legal-hold applied_at to the closure test timeline AccountClosurePersistenceIntegrationTest inserted legal holds without applied_at, so the column took the database clock, then released them at fixed instants derived from REQUESTED (2026-08-03). Once the wall clock passed 2026-10-02 the release violated account_legal_hold_release_after_apply (released_at >= applied_at), so two tests have failed on every run since: - activeHeldAccountDoesNotStarveLaterActionableAccountAndReleaseRequeuesIt - retentionHonorsExactIdentifierBoundaryAndLegalHoldBeforeAtomicRelease Both holds now carry an explicit applied_at on the test's own timeline. Production queries read only the hold status, so no runtime code changes. Verified: the class passes 17/17 with the fix and still fails 2/17 without it; the full suite passes (1054 tests, 0 failures, 1 opt-in skip). Co-Authored-By: Claude Opus 5.5 --- .../AccountClosurePersistenceIntegrationTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/backend-persistence/src/test/java/com/idea2strategy/backend/persistence/identity/AccountClosurePersistenceIntegrationTest.java b/modules/backend-persistence/src/test/java/com/idea2strategy/backend/persistence/identity/AccountClosurePersistenceIntegrationTest.java index 965bd054..88ba255d 100644 --- a/modules/backend-persistence/src/test/java/com/idea2strategy/backend/persistence/identity/AccountClosurePersistenceIntegrationTest.java +++ b/modules/backend-persistence/src/test/java/com/idea2strategy/backend/persistence/identity/AccountClosurePersistenceIntegrationTest.java @@ -597,11 +597,13 @@ void retentionHonorsExactIdentifierBoundaryAndLegalHoldBeforeAtomicRelease() { Integer.class, accountId)).isOne(); Instant eligible = DEADLINE.plus(Duration.ofDays(30)); + // applied_at defaults to the database clock; keep it on this test's fixed timeline so the + // release below satisfies released_at >= applied_at whatever day the suite runs. jdbc.update(""" insert into identity.account_legal_holds - (account_id, data_category, blocks_identifier_reuse, basis_reference, applied_by) - values (?, 'CONTACT_IDENTIFIER', true, 'test-hold', 'test') - """, accountId); + (account_id, data_category, blocks_identifier_reuse, basis_reference, applied_by, applied_at) + values (?, 'CONTACT_IDENTIFIER', true, 'test-hold', 'test', ?) + """, accountId, eligible.minusSeconds(1).atOffset(ZoneOffset.UTC)); UUID legalHoldId = jdbc.queryForObject(""" select id from identity.account_legal_holds where account_id = ? and data_category = 'CONTACT_IDENTIFIER' and status = 'ACTIVE' @@ -855,9 +857,9 @@ void activeHeldAccountDoesNotStarveLaterActionableAccountAndReleaseRequeuesIt() """, heldClosedAt.atOffset(ZoneOffset.UTC), actionableAccount); jdbc.update(""" insert into identity.account_legal_holds - (account_id, data_category, blocks_identifier_reuse, basis_reference, applied_by) - values (?, 'CONTACT_IDENTIFIER', true, 'starvation-test', 'test') - """, heldAccount); + (account_id, data_category, blocks_identifier_reuse, basis_reference, applied_by, applied_at) + values (?, 'CONTACT_IDENTIFIER', true, 'starvation-test', 'test', ?) + """, heldAccount, heldClosedAt.atOffset(ZoneOffset.UTC)); Instant dueAt = heldClosedAt.plus(Duration.ofDays(30)); assertThat(retention.findDueAccounts(10_000, dueAt))