Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

fix(before-meeting): pass orgAopId so org-level meeting-prep actually runs

merged#2501CedarCopilot

CedarCopilot wants to merge 0 commits into staging from fix/sherlock-before-meeting-orgaop-20260815-161351

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Aug 15, 2026, 4:26 PM
  2. Merged
    Aug 15, 2026, 4:37 PM
  3. Live on staging
    Aug 15, 2026, 4:37 PM
  4. Live on prod
    Aug 15, 2026, 4:37 PM
  5. Observed 0 hours
    Aug 15, 2026, 4:37 PM
  6. Unobserved

    Live on prod, no production signal yet

    Aug 15, 2026, 4:37 PM
  7. Pipelines steady after this deploy
    Aug 15, 2026, 4:37 PM
  8. Pipelines steady after this deploy
    Aug 15, 2026, 4:37 PM

Behaviors Libra is checking

The admin before-meeting subagent test path now also supplies the linked organization AOP, so manual/admin-triggered meeting-prep tests exercise the same organization-level playbook behavior as production.Inconclusivelow confidence

OTEL fallback found no prod spans matching adminSubagentRouter before_meeting execution since deploy.

staging, checked Aug 18, 2026, 4:26 AM
Scheduled before-meeting executions now pass the user AOP’s linked organization AOP so organization-level before-meeting playbook refs resolve and run instead of silently completing with no subagent work.Inconclusivelow confidence

OTEL fallback found no prod spans matching handleExecuteScheduledExecution → runPlaybookSectionExecution (triggerType=before_meeting) since deploy.

staging, checked Aug 18, 2026, 5:25 AM
Direct-fired playbook triggers that resolve no referenced subagents now emit a structured warning instead of being entirely silent.Inconclusivelow confidence

OTEL fallback found no prod spans matching runPlaybookSectionExecution (before-meeting/cron/webhook direct-fire) since deploy.

staging, checked Aug 18, 2026, 5:25 AM
Admin-triggered before-meeting subagent runs now also supply the linked org AOP, matching production behavior and allowing organization-level trigger references to resolve.Not checked
prod
Scheduled before-meeting runs now pass the user AOP's linked org AOP so organization-level before-meeting playbook references resolve and execute instead of silently doing nothing.Not checked
prod
Direct-fire playbook triggers that resolve no referenced subagents now emit a structured warning so silent no-op runs can be detected.Not checked
prod

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.

Symptom

Pre-meeting prep is configured at the org level (a <trigger type="before-meeting"> referencing the org meeting-prep subagent), the user has upcoming synced calendar meetings, agent execution is on, and post-meeting automations fire , yet no prep is ever produced. Diagnosed via Sherlock for Sam @ SimCare; affects every rep in the org (and any org that keeps before-meeting at org level).

Root cause

Scheduling is org-aware but execution was not.

  • Scheduling (getBeforeMeetingConfigsForUser, manifest-utils.ts) independently looks up orgAopId and merges the org manifest → the run gets scheduled. So runs fire (one user had 211 completed + 50 pending).
  • Execution (handleExecuteScheduledExecution.ts) called runPlaybookSectionExecution({ userId, orgId, aopId }) without orgAopId. resolvePlaybookContext only reads the org playbook when orgAopId is set (resolve-playbook-context.ts:197; org refs collected only if (orgCompiled …) at :235). With it null, the org's before-meeting <ref> (meeting-prep) never resolved → zero refs → legacy no-instruction path → silent no-op, and the parent is marked completed regardless.

Every other runPlaybookSectionExecution caller (cron cron-task-registry.ts, field-change conversations.ts, webhook playbook-webhook.ts) already passes orgAopId. The scheduled before-meeting path was the only one that dropped it , which is exactly why post-meeting / field-change / daily-agenda work but pre-meeting prep doesn't.

Evidence (prod)

  • 211 playbook-before-meeting executions completed for the user, across every month , all with null output, no child subagent runs, and zero meeting_prep documents.
  • Org playbook manifest beforeMeetingConfigs: [{stage:null, enabled:true, minutes:60}] (compiled); user manifest [].

Fix

  • handleExecuteScheduledExecution: resolve the AOP's linked orgAopId and pass it through; add a structured log at fire time.
  • admin-subagent test-before-meeting path: same fix, so the Playbook Editor "test" button matches prod.
  • runPlaybookSectionExecution: log a warning when a before-meeting/cron/webhook direct-fire resolves zero refs , so this class of silent no-op is visible in Axiom instead of hidden.
  • Tests: assert the before-meeting executor forwards orgAopId (and null when there's no linked org AOP). 5/5 pass.

Blast radius

Shared code path. Positively affects any org whose before-meeting trigger is org-level only (the standard multi-rep setup). No behavior change for orgs that already had a user-level before-meeting trigger (they were passing refs at user level). Typecheck clean on touched files.

How to verify after deploy

Watch for playbook-before-meeting executions that now spawn a meeting-prep child run and produce a Slack notification + prep doc, and for the new [executeScheduledExecution] Firing playbook before-meeting log carrying a non-null org_aop_id. The direct-fire resolved zero refs warning should stop appearing for these orgs.

🤖 Diagnosed & fixed by Sherlock. Generated with Claude Code

Greptile Summary

The PR propagates each user AOP’s linked organization AOP into scheduled and admin-triggered before-meeting execution so organization-level meeting-prep references resolve correctly.

  • Adds the organization-AOP lookup and structured fire-time logging to scheduled execution.
  • Aligns the admin before-meeting test path with production context resolution.
  • Adds zero-reference direct-fire diagnostics and regression coverage for linked and unlinked organization AOPs.

Confidence Score: 4/5

The PR appears safe to merge, with non-blocking cleanup needed for misleading zero-reference warnings and repository import conventions.

Organization-level playbook context is now propagated consistently in both production and admin before-meeting paths; the remaining findings affect

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/mastra/routeHandlers/event-execution/__tests__/before-meeting-execution-rsvp-gate.test.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/event-execution/handleExecuteScheduledExecution.tsno production surface mapped
  • apps/server/src/services/playbook/playbook-execution-triggers.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-subagent.tsno production surface mapped