Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

fix(playbook): rank org-cron representative by Slack health too

merged#2708CedarCopilot

CedarCopilot wants to merge 1 commit into staging from fix/org-cron-slack-health-tiebreak

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Sep 6, 2026, 8:27 PM
  2. Sep 6, 2026, 8:43 PM
  3. Merged
    Sep 6, 2026, 8:54 PM
  4. Live on staging
    Sep 6, 2026, 8:54 PM
  5. Live on prod
    Sep 6, 2026, 8:54 PM
  6. Observed 1 hour
    Sep 6, 2026, 8:54 PM
  7. Unobserved

    Live on prod, no production signal yet

    Sep 6, 2026, 8:54 PM
  8. Pipelines steady after this deploy
    Sep 6, 2026, 8:54 PM
  9. Pipelines steady after this deploy
    Sep 6, 2026, 8:54 PM

Behaviors Libra is checking

Org-level cron runs select a representative with a usable Google connection and, when available, a Klavis Slack connection before considering token freshness, preventing Slack-delivery failures caused by choosing a Google-only representative.Workinglow confidence

Verification reached its 120s wall-clock budget before a tied verdict. Libra is keeping this intent verifying until the next check.

staging, checked Sep 9, 2026, 4:24 PM
Org-level cron representative selection checks for a Klavis-managed Slack connection and prefers a Slack-connected representative after requiring a usable Google connection, preventing Slack-delivered digests and reports from being assigned to Google-only users.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

  • pickOrgCronRepresentative ranked org-level cron candidates by Google-connection health only, so a rep with a fresh Google token but no Slack connection could still be picked to run a Slack-delivered digest/report , the run builds fine and dies silently at the final "post to Slack" step.
  • Adds hasSlackConnection as a ranking tiebreak (after Google usability, before token-expiry freshness), sourced from a second query against the Klavis-managed Slack connection row (existence-based , Klavis holds the actual OAuth token itself, so Cedar's own row carries none to check).
  • Found while auditing Aspire's daily-call-summary/weekly-competitor-report org agents: Anand (freshest Google token, no Slack) would otherwise be picked over Jacob Doty (has Slack).

Known limitation

This checks Slack connection existence, the same way the existing code checks Google token presence , it does not probe live Slack API health or queue saturation. A representative could still fail if Slack itself is degraded at run time. Flagging this per an automated review note; treating it as out of scope for this fix since it matches the existing pattern in this file rather than introducing a new one.

Test plan

  • pnpm --filter @zero/server exec vitest run src/services/playbook/__tests__/org-cron-representative.test.ts , 14/14 pass (4 new tests covering the Slack tiebreak + the merge helper)
  • pnpm --filter @zero/server run types , clean on touched files

🤖 Generated with Claude Code

https://claude.ai/code/session_01F4mjBtjYZyxnVvLQpehDSb

Greptile Summary

This PR augments organization-cron representative selection with Slack connection presence so Slack-delivered scheduled agents prefer a representative capable of delivery.

  • Queries Klavis-managed Slack connection rows for existing Google-qualified candidates.
  • Adds Slack presence between Google usability and token-expiry freshness in candidate ranking.
  • Adds unit coverage for Slack ranking and the immutable Slack-status merge helper.

Confidence Score: 5/5

The PR appears safe to merge with no actionable regressions identified.

The Slack query matches current Klavis connection conventions, candidate marking is immutable, and ranking preserves Google usability as its highest-priority condition while addressing the missing-Slack representative case.

Important Files Changed

FilenameOverview
apps/server/src/services/playbook/manifest-utils.tsAdds Slack connection lookup, candidate annotation, and Slack-aware representative ranking without introducing a confirmed regression.
apps/server/src/services/playbook/tests/org-cron-representative.test.tsAdds focused coverage for Slack ranking precedence and immutable candidate annotation.

Flowchart

rendering diagram…

Reviews (1): Last reviewed commit: "fix(playbook): rank org-cron representat..." | Re-trigger Greptile

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/playbook/__tests__/org-cron-representative.test.tsno production surface mapped
  • apps/server/src/services/playbook/manifest-utils.tsno production surface mapped