Skip to content

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

Merged
evereq merged 1 commit into
developfrom
fix/0.24.1-greptile-lease-logout
Nov 21, 2026
Merged

evereq merged 1 commit into
developfrom
fix/0.24.1-greptile-lease-logout

Conversation

@evereq

@evereq evereq commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

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, release(stage): v0.24.1 (Ever Connect / Ever ID race fixes, Maintenance operations and My data exports in the webapp) #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, release(stage): v0.24.1 (Ever Connect / Ever ID race fixes, Maintenance operations and My data exports in the webapp) #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 release(stage): v0.24.1 (Ever Connect / Ever ID race fixes, Maintenance operations and My data exports in the webapp) #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.

Written for commit addbef3. Summary will update on new commits.

View guided diff Turn on auto-fix

…fore resends

- signInWithOidc: pass the sign-in start time on the existing-account path too, so a
  subject-only logout that lands during the code exchange or account lookup ends it
  (Greptile P1 on #642)
- runDue: check and renew the lease before each saved-result delivery, stop once it is
  lost (Greptile P2 on #642)
- person-link round also stops once the connection is no longer the active one
- refreshIntegrations: warn when the retries are exhausted
- e2e: sort with localeCompare (Sonar S2871); changelog 0.24.1 entries + no-migrations note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@evereq

evereq commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Ever Works AI review — ever-co/ever-traduora#644

Approved pending confirmation of callback scoping and async lease handling. Touched critical paths: Ever ID sign-in cutoff in auth.controller.ts and Ever Connect lease/round logic in ever-connect-managed.service.ts and ever-connect-scheduler.service.ts. No exposed secrets; change is small.

File notes:

  • api/src/controllers/auth.controller.ts — Verify that signedInAt is in scope at this point in signInWithOidc and that signOidcUserToken accepts a fifth Date parameter and uses it to enforce the subject-logout cutoff; otherwise the call will fail at runtime or silently ignore the argument.
  • api/src/ever-connect/ever-connect-managed.service.ts — Confirm stillCurrent is defined in scope before this loop and that returning 0 from runDue also skips the subsequent due-work portion of the round, matching the stated 'stops the whole round' behavior.
  • api/src/ever-connect/ever-connect-scheduler.service.ts — The person-link lease callback is now async () => (await this.renew()) && (await this.isCurrent(connection.kid)); verify syncLinks awaits this callback so an isCurrent failure actually interrupts the round instead of being fire-and-forget.
  • api/src/ever-connect/ever-connect-managed.service.spec.ts — The test asserts runDue returns 0 when the lease is lost after the first send; ensure runDue's return value semantics (number sent vs status code) are consistent with other callers and documented.
  • api/test/ever-connect-managed.e2e-spec.ts — .sort((a, b) => a.localeCompare(b)) still lacks an explicit locale; pass the project's default locale (e.g. 'en') to fully satisfy Sonar S2871 across environments.
  • api/test/ever-id.e2e-spec.ts — The mock revokes the identity then delegates to the original findIdentity; confirm revokeIdentity reliably produces session_ended in signOidcUserToken and that the test cleans up so later sign-in tests are not affected.
  • api/src/ever-connect/ever-connect.service.ts — Verify attempt starts at 0 so the warning log on the third exhausted attempt is accurate; if it starts at 1, this logs on the fourth attempt instead.
  • docs/changelog.md — Changelog entries are added under 0.24.1 as stated; verify they follow the project's newest-first ordering and that 'No database migrations' matches the empty migration diff.

Work: Ever Traduora

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Signing out during an Ever ID sign-in now prevents that in-progress attempt from creating a session. Sign-ins started after signing out can still proceed normally.
    • Background processing now stops sending saved results and running due work when its connection is no longer active.
    • Sign-in sessions for linked OIDC identities now use the original sign-in start time.
  • Documentation
    • Updated the 0.24.1 changelog with these changes and confirmed that the release includes no database migrations.

Walkthrough

The pull request updates the existing OIDC sign-in path and adds a test for logout during sign-in. It also adds lease and connection checks to Ever Connect operations, logs incomplete integration refreshes, and adjusts a backup-result assertion.

Changes

Ever ID sign-in

Layer / File(s) Summary
Linked-identity sign-in and logout race
api/src/controllers/auth.controller.ts, api/test/ever-id.e2e-spec.ts, docs/changelog.md
The existing linked-identity sign-in passes its start time to the token helper. An end-to-end test checks that an in-flight sign-in fails with session_ended after subject-only logout, while a later sign-in succeeds and its token remains usable. The changelog records the behavior.

Ever Connect operations

Layer / File(s) Summary
Lease-guarded maintenance operations
api/src/ever-connect/ever-connect-managed.service.ts, api/src/ever-connect/ever-connect-managed.service.spec.ts, api/src/ever-connect/ever-connect-scheduler.service.ts, docs/changelog.md
runDue checks the connection before each saved-result delivery and stops if it is no longer current. Person-link synchronization checks both the lease and active connection. The test covers stopping and resuming saved-result delivery, and the changelog records these changes.
Refresh logging and backup assertion
api/src/ever-connect/ever-connect.service.ts, api/test/ever-connect-managed.e2e-spec.ts
refreshIntegrations logs a warning when changes remain after retries. The backup-result key assertion sorts keys with localeCompare.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to addbe

This change closes a race in which a logout arriving during sign-in could still produce a session. It also makes maintenance result delivery stop once the lease or connection is lost. No migrations or API changes are involved. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main fixes: ending in-flight Ever ID sign-ins on subject logout and renewing the lease before saved-result resends. It also names the release version 0.24.1. The changeset matc…
Description check Passed The description ties directly to the changeset. It explains the sign-in logout fix in auth.controller.ts, the runDue lease check in ever-connect-scheduler and managed service, the person-link connecti…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main fixes: ending in-flight Ever ID sign-ins on subject logout and renewing the lease before saved-result resends. It also names the release version 0.24.1. The changeset matches these points. Some secondary items (refreshIntegrations warning, sort change, changelog) are not in the title, which is acceptable.

Full details: Description check

Explanation

The description ties directly to the changeset. It explains the sign-in logout fix in auth.controller.ts, the runDue lease check in ever-connect-scheduler and managed service, the person-link connection check, the refreshIntegrations warning, the sort change, and the changelog entry. It also lists tests that match the added specs.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

I’m a rabbit with a sign-in key,
I watch the lease before I hop.
A logout ends the waiting login,
A later one can start anew.
Saved results wait when leases fade,
Then reach their home when checks pass through.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 38fc1413-4e48-457a-87b7-2067008293e3
Commits

Reviewing files that changed from the base of the PR and between 3407575 and addbef3.

Files selected for processing: 8

  • api/src/controllers/auth.controller.ts
  • api/src/ever-connect/ever-connect-managed.service.spec.ts
  • api/src/ever-connect/ever-connect-managed.service.ts
  • api/src/ever-connect/ever-connect-scheduler.service.ts
  • api/src/ever-connect/ever-connect.service.ts
  • api/test/ever-connect-managed.e2e-spec.ts
  • api/test/ever-id.e2e-spec.ts
  • docs/changelog.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR closes two gaps in Ever ID logout and Ever Platform background work.

  • Ever ID sign-ins now honor subject logouts that arrive mid-flight.
  • Ever Connect rounds stop when the lease or active connection changes.
  • Integration refreshes now warn when local changes outlast three attempts.
  • Release notes and a backup test now spell out maintenance details.

This review checked the code and tests; it did not run the test suites.

Reviews (1) · Last reviewed commit: "fix: end in-flight Ever ID sign-ins on s..." · Reviewed by Greptile

@evereq

evereq commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Bot pass on addbef3: Greptile 5/5 with no findings, CodeRabbit had nothing actionable, and the SonarCloud PR gate passed (0 new issues). Answers to the Ever Works AI notes, each checked in the code:

  • auth.controller.ts: signedInAt is set at the top of signInWithOidc (const signedInAt = Date.now(), before verifyOidcCode). signOidcUserToken(…, signedInAt?: Date) passes it on to openSession, which refuses the session when the subject's logout cutoff is >= that time. The new e2e test exercises exactly this path.
  • runDue: stillCurrent is the 4th parameter (default async () => true). The return 0 sits inside the saved-result loop, so the due-work query and loop below it never run. The return value is still "how many due operations were taken" (the existing tests assert 0/1 the same way), and its only caller in the scheduler ignores it.
  • Scheduler person-link callback: syncLinks awaits it in leaseHeld() (if (!keepLease || (await keepLease())) return true; leaseLost = true; return false;) before each call, and returns early when it is false.
  • localeCompare without a locale: the keys are fixed ASCII identifiers (artefact_ref, size_bytes, status), so every locale orders them the same. This is the form Sonar S2871 asks for.
  • e2e cleanup: jest.spyOn(...).mockImplementationOnce applies to one call only, and the suite's afterEach runs jest.restoreAllMocks() and closes the app. Each test starts its own app on a fresh migrated database.
  • refreshIntegrations: attempt starts at 0 and the retries run at 0, 1 and 2. The warning fires only when the call with attempt === 2 still saw changes, so 3 attempts in total, as logged.
  • Changelog: entries are appended to the 0.24.1 section, which is not released yet. "No database migrations" matches git diff master develop -- api/src/migrations (empty).

Waiting for the in-cluster ci.yml run (pr644-ever-traduora-addbef3-cda3c: unit, e2e on sqlite/postgres/mysql, webapp) before merging. CircleCI test is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant