fix(api): Ever ID unlink ends sessions; stale feed pages never end a new connection; stats link follows identity reset
Merged
EV
3d ago+199+199+012345678901234567890123456789-41-41-01234567890123456789
Fixes the three Greptile findings on the 0.24.0 release PR #634 before it goes to stage:
- Disconnected Ever ID tokens survived (
ever-id-session.service.ts):unlinknow ends the account's open Ever ID sessions in the same transaction that removes the identity. Sessions record the account, not the identity (asrevokeIdentityalready does for a subject-only logout). Password, API client and Google tokens carry nosidand are not affected. Test: the session is revoked after unlink; another account's session stays. - Old responses ending new connections (
ever-connect-scheduler.service.ts,refreshSelf): the connection key read with the page goes toendedByPlatformforinstance.revoked/instance.disconnected, the 410 re-read, the feed error path andrefreshSelf;endedByPlatformalready ignores a key that is not the current one. Test: disconnect + connect while the long poll waits, then the old page'sdisconnectedevent leaves the new connection active. - Stats link stale after an identity reset (
refreshIntegrations/linkStats): the stored config records the linkedstatsInstanceId; a different current identity is linked again. Existing{ linked: true }rows are linked once more. Test: reset → a secondstatsLinkcall with the new id.
Prettier 3.5.3 clean on the changed files.
🤖 Generated with Claude Code
Summary by cubic
Fixes three review findings on the 0.24.0 release before it goes to stage, and closes the races found in those fixes.
- Unlinking an Ever ID identity now ends the account's open Ever ID sessions in the same transaction; sessions record the account, not the identity, so a later subject-only logout can no longer find them. A sign-in now opens its session only while that identity is still the account's, with the account's row locked, so a disconnect can no longer miss a session opened just before it.
- Feed pages, 410 re-reads, and state reads for a connection replaced by a reconnect no longer end the new connection — the connection key is carried to
endedByPlatform, which matches the key and state it read in the same transaction that deletes the connection's rows, so another process's disconnect + connect is never overwritten. A 410 re-read stores its continue cursor only for the connection and the cursor it started at. - The statistics link now records the linked statistics instance ID and is checked on every scheduler tick, so an identity the operator reset is linked again without waiting for an event, since
{ linked: true }rows previously stayed linked to the old identity. Its send writes only thestats_linkconfig, and only while the same consent is still enabled and not pending a remote revoke.
Each fix has a test: session revocation on unlink, a stale page leaving the new connection active, and a second stats link after a reset.