Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

fix(slack): keep the lapse claim exclusive as well as reclaimable

merged#2637CedarCopilot

CedarCopilot wants to merge 1 commit into staging from fix/slack-lapse-claim-exclusive

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Aug 31, 2026, 10:24 AM
  2. Merged
    Aug 31, 2026, 10:36 AM
  3. Live on prod
    Aug 31, 2026, 10:36 AM
  4. Observed 0 hours
    Aug 31, 2026, 10:36 AM
  5. Unobserved

    Live on prod, no production signal yet

    Aug 31, 2026, 10:36 AM
  6. Pipelines steady after this deploy
    Aug 31, 2026, 10:36 AM
  7. Aug 31, 2026, 11:01 AM

Behaviors Libra is checking

Slack integration behavior from slack/slack-connection-health.ts keeps working in prod.Not checked
prod

Libra has verdicts on 0 of 1 tracked behaviors on prod; 1 is still being checked. Libra checks hourly for 3 days after each deploy.

Summary

Follow-up to #2633, which merged before this last Greptile finding was addressed.

That PR made an undelivered lapse claim reclaimable so a failed send could not silently consume the rep's only notice. Greptile correctly pointed out that this cost the claim its exclusivity: a broken Slack token fails every channel in the same drain tick, so simultaneous reports for one user are the normal shape of a break rather than a rare interleaving , and a predicate admitting any lapse not yet marked delivered admits every one of them. The rep gets one mail per failing channel.

The claim now readmits a lapse only once it is undelivered and older than the abandoned-claim window:

  • Concurrent reports in one tick see a fresh undelivered claim and stay quiet β†’ exactly one mail.
  • A claim genuinely abandoned by a thrown send, a failed notified stamp, or a dead process is retried once the window passes β†’ the rep still gets told.

The window only has to outlast an in-flight send, so it is set to 15 minutes.

The delivered-stamp is also scoped to the exact lapse the claim returned, rather than to "there is a lapse". Without that, a slow sender could mark a newer, still-undelivered lapse as notified , the one case where the rep is silently owed a mail that never arrives.

Test plan

Two new tests, both of which fail without the change:

  • four channels reporting one break together mail once;
  • a delayed send closes only the lapse it claimed, leaving a newer break still owed its retry.

The existing retry test now asserts the fuller shape: undelivered β†’ not immediately reclaimable β†’ reclaimable once the window passes.

Validated as part of the full gate before #2633 merged (pnpm run autofix:local: oxlint --deny-warnings, deps:check, 313 mail suites / 2,946 tests, 764 server files / 8,375 tests). The cherry-pick onto current staging is byte-identical to that validated version and is the only delta.

πŸ€– Generated with Claude Code

Greptile Summary

The PR restores exclusivity for Slack lapse-notification claims while keeping abandoned claims reclaimable after a 15-minute window.

  • Prevents concurrent channel failures from each sending a notification for the same Slack outage.
  • Restricts the delivered stamp to the exact lapse generation claimed by the sender.
  • Adds database-backed coverage for concurrent claims, delayed retries, and replacement-lapse handling.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security defects identified in the changed behavior.

The conditional update keeps fresh claims exclusive, stale undelivered claims reclaimable, and successful delivery scoped to the exact claimed lapse; the added real-SQL tests cover the principal concurrency and replacement-generation cases.

Important Files Changed

FilenameOverview
apps/server/src/services/integrations/slack/slack-connection-health.tsAdds a stale-claim lease and generation-specific delivery stamp to preserve exclusive, recoverable Slack lapse notifications.
apps/server/src/services/integrations/slack/tests/slack-connection-health.test.tsExpands real-SQL coverage for immediate exclusion, delayed reclamation, concurrent channel failures, and exact lapse closure.

Sequence Diagram

rendering diagram…

Reviews (1): Last reviewed commit: ["fix(slack): keep the lapse claim exclusi..

Show production surfaces and changed-file mapping

Production surfaces

Libra has not measured any production surfaces for this change yet.

Changed files β†’ surfaces

  • apps/server/src/services/integrations/slack/__tests__/slack-connection-health.test.tsno production surface mapped
  • apps/server/src/services/integrations/slack/slack-connection-health.tsno production surface mapped