fix: end in-flight Ever ID sign-ins on subject logout, renew lease before result resends (0.24.1)

Merged
EV
2d ago
+68-6

Fixes the two Greptile findings on the 0.24.1 release PR #642, before it is merged to stage. Part of 0.24.1 (no version change; changelog entries added under 0.24.1).

Changes

  • Sign-in survives logout (Greptile P1, #642 auth.controller.ts ~866). signInWithOidc records signedInAt before the code exchange, but the existing-account branch called signOidcUserToken without it, so openSession skipped the subject-logout cutoff. It now passes new Date(signedInAt), as the sign-up confirmation path already did. A sign-in that starts after the logout works as before.
    Test: test/ever-id.e2e-spec.ts "ends a sign-in to an existing account when a logout naming only the subject lands while it is under way" (the logout is injected during the account lookup → 400 session_ended, no session row; the next sign-in → 201 and a working token).
  • Result retries skip lease checks (Greptile P2, #642 ever-connect-scheduler.service.ts ~198 / runDue). runDue now calls the lease callback before each saved-result (unsentResult) delivery and stops the whole round (no due work either) once the lease or the connection is lost; the next round that holds the lease sends the rest.
    Test: ever-connect-managed.service.spec.ts "checks the lease before each saved result it sends again, and stops once another process holds it".
  • From the Ever Works review on #642: the person-link round's callback now also checks that the connection is still the active one (as the maintenance round does), and refreshIntegrations logs a warning when its 3 attempts are exhausted. Changelog 0.24.1 says "No database migrations" (verified: git diff master develop -- api/src/migrations is empty).
  • Sonar S2871 (critical, new code on develop): sort() with localeCompare in test/ever-connect-managed.e2e-spec.ts.

Verified locally (Node 24, SQLite)

  • Unit: ever-connect-managed, ever-connect-person, ever-connect.service, ever-id-session specs: 4 suites, 68 tests passed.
  • E2E: ever-id, ever-connect-managed, ever-connect-person, ever-connect: 4 suites, 31 tests passed.
  • prettier --check on every changed .ts.

CircleCI and in-cluster ci.yml (unit, e2e on sqlite/postgres/mysql, webapp) run on this PR.

No migrations, no new settings, no public API change.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes the two Greptile findings on the 0.24.1 release before it merges to stage, for Ever ID sessions and Ever Connect lease handling.

  • Ever ID sign-in to an existing account now ends if a logout naming only the subject lands during the code exchange or account lookup; previously only a sign-up waiting for confirmation was ended.
  • Ever Connect renews the lease before each saved-result delivery and stops the round once the lease or the connection is lost; the next round holding the lease sends the rest.
  • The person-link round also stops once the connection is no longer the active one.
  • refreshIntegrations logs a warning when its 3 retries are exhausted.
  • Fixes a Sonar S2871 critical on sort() in an e2e spec and adds 0.24.1 changelog entries. No database migrations.