Skip to content

ADR β€” PR #1033

2026-05-19 10:30 β€” Remove unused import β€˜eq’ from impersonate.ts

Section titled β€œ2026-05-19 10:30 β€” Remove unused import β€˜eq’ from impersonate.ts”

2026-05-19 10:31 β€” Remove unused import β€˜gte’ from impersonate-end.ts

Section titled β€œ2026-05-19 10:31 β€” Remove unused import β€˜gte’ from impersonate-end.ts”

2026-05-19 10:32 β€” Verify structured logging implementation

Section titled β€œ2026-05-19 10:32 β€” Verify structured logging implementation”

2026-05-19 10:33 β€” Fix transaction safety in impersonate.ts

Section titled β€œ2026-05-19 10:33 β€” Fix transaction safety in impersonate.ts”

2026-05-19 10:34 β€” Fix transaction safety in impersonate-end.ts

Section titled β€œ2026-05-19 10:34 β€” Fix transaction safety in impersonate-end.ts”

2026-05-20 β€” Close lookup/update race in impersonate-end.ts (PR #1053 CR feedback)

Section titled β€œ2026-05-20 β€” Close lookup/update race in impersonate-end.ts (PR #1053 CR feedback)”
  • Comment: CodeRabbit on PR #1053 β€” single-session path had a race: findFirst β†’ batch update was not atomic, so two concurrent end-impersonation requests could both write sys_admin.impersonate.end audit rows for the same already-terminated session.
  • Priority: must-fix
  • Decision: accept
  • Rationale: Replaced the find-then-batch-update pattern with a single conditional UPDATE ... WHERE is_active = true RETURNING id, target_user_id. The audit row is only inserted when RETURNING yields rows, so a race-loser issues no duplicate audit and gets the 404 path. Both single-session and multi-session branches now use UPDATE-with-RETURNING as the source of truth for what was actually terminated.