fix(api): Ever Connect / Ever ID races found in the 0.24.0 release review

Merged
EV
2d ago
+225-20

The four findings Greptile left on release PR #636 (answered there as "tracked for 0.24.1"), all in off-by-default modules:

  1. Person deletion vs a sign-in (ever-connect-person.service.ts): deleteIdentities locks each matched account's row (sorted, no deadlock) before ending sessions and removing identities, the lock openSession/unlink take.
  2. Subject-only logout vs a pending sign-up (ever-id-session.service.ts): revokeIdentity records a per issuer+subject cutoff row (sub-<hash> in ever_id_session, kept for the pending TTL); the sign-up confirmation passes when the person signed in with the provider, and a sign-in before the cutoff opens no session. No migration.
  3. Refresh vs operator switch-off (refreshIntegrations): rows whose local decision (updatedAt, state, pendingRemoteRevoke, consentId) changed while Ever Platform was read are not overwritten.
  4. Lease expiry in long rounds (ever-connect-scheduler.service.ts, syncLinks): the lease is renewed before the person-link round and before each call in it; the round stops once another process holds it.

Tests: one regression test each (pending sign-up after logout; refresh during switch-off; lease lost mid-round); deletion locking reuses the existing deletion tests. Changelog next updated. Prettier 3.5.3 clean.

🤖 Generated with Claude Code


Summary by cubic

Fixes the four races found in the 0.24.0 release review, all in off-by-default modules.

Bug Fixes

  • Person deletion locks each account row (sorted, so two deletions never deadlock) before ending sessions and removing identities, matching the lock a sign-in takes.
  • A logout naming only the subject records a per issuer+subject cutoff; a sign-up confirmation whose provider sign-in predates the logout opens no session.
  • refreshIntegrations never overwrites a row a local decision changed while Ever Platform was read (conditional write, so the switch-off wins); a refresh that met a concurrent change reads again, twice at most, so a newer remote state (a revoked consent) isn't left behind.
  • The scheduler renews its lease before the person-link and managed rounds and before each call in them, and a round stops once another process holds it.
  • Adds one regression test for each race; deletion locking reuses the existing deletion tests and the changelog next is updated.