CedarCopilot wants to merge 0 commits into staging from fix/sherlock-org-cron-representative-connection-20260817-202652
Live on prod, no production signal yet
OTEL fallback found no prod spans matching getPlaybookCronConfigs / org-level playbook cron trigger since deploy.
OTEL fallback found no prod spans matching pickOrgCronRepresentative / getPlaybookCronConfigs since deploy.
OTEL fallback found no prod spans matching [getPlaybookCronConfigs] org cron representative selected since deploy.
OTEL fallback found no prod spans matching getPlaybookCronConfigs / org-level playbook cron since deploy.
OTEL fallback found no prod spans matching pickOrgCronRepresentative / org-level playbook cron since deploy.
OTEL fallback found no prod spans matching [getPlaybookCronConfigs] org cron representative selected since deploy.
Libra has verdicts on 0 of 3 tracked behaviors on prod; 3 are still being checked. Libra checks hourly for 3 days after each deploy.
Org-level cron automations (a cron trigger in an org PLAYBOOK.md , e.g. Pirros' weekly "barriers to buy" report) fire once per tick under a single "representative" linked user. getPlaybookCronConfigs picked that representative with SELECT … WHERE org_aop_id = … LIMIT 1 , no ordering, no connection-health check.
If the arbitrarily-picked representative has an expired/revoked Google connection, building the run's automation context (runPlaybookSectionExecution → buildAutomationContext → generatePreamble → getUserContext) throws "No valid connection tokens found for user …", and the org's entire scheduled report dies before any execution row is created. The failure is near-invisible (it escapes the per-task catch; nothing user-facing is logged).
0a6c401c) has never produced an execution row.[getUserContext] Could not get active connection for user ZOrHUjz… (<email>): No valid connection tokens , stack: getUserContext → generatePreamble → buildAutomationContext → runPlaybookSectionExecution → processAopAutomations.account row for Peter: Google access token expired 2026-07-30, never refreshed since Jul 22 (he owns the account but doesn't actively use Cedar).RspInxFG8…, tx5YJRft…) , this is systemic, not Pirros-specific.apps/server/src/services/playbook/manifest-utils.ts:
pickOrgCronRepresentative(db, orgAopId, now) , joins linked AOPs to their Google account, collapses to one candidate per user, and picks the healthiest representative.rankOrgCronCandidates() , orders by: (1) currently-valid access token, (2) freshest token expiry, (3) most-recently-refreshed account, (4) stable aopId tiebreak (so the choice doesn't churn across ticks).getPlaybookCronConfigs now uses it and logs the chosen representative ([getPlaybookCronConfigs] org cron representative selected) so the selection is auditable.Against Pirros' real data the ranking yields zane > kas > keenan > brett > xander > ross > peter , the two dead reps sort last, and a healthy rep is always chosen when one exists.
pnpm --filter @zero/server exec vitest run src/services/playbook/__tests__/org-cron-representative.test.ts (5 cases, incl. the real Pirros expired-vs-valid scenario).[getPlaybookCronConfigs] org cron representative selected naming a rep with a live token, and an execution row for the org report agent.This removes the common failure (a known-dead rep is never chosen when a healthy one exists). It does not add a runtime fallback if the chosen rep's token is revoked between selection and execution , a belt-and-suspenders retry across candidates could be added later if needed.
🤖 Generated with Claude Code
The PR replaces arbitrary org-cron representative selection with deterministic ranking based on Google account metadata and adds focused ranking tests and selection logging. However, the ranking reads a different persistence model from the runtime connection-validity check, so disconnected users can still be selected.
The representative selection sh
Libra has not measured any production surfaces for this change yet.