Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

[2026-09-20] merging staging to main

merged#2838CedarCopilot

CedarCopilot wants to merge 1 commit into main from staging

Not deployedTimeline and evidence
  1. Opened
    Sep 20, 2026, 10:30 AM
  2. Sep 20, 2026, 10:34 AM
  3. Merged
    Sep 20, 2026, 10:43 AM
  4. Live on staging, live on prod, observed
    Pending
  5. Not deployed

    Not deployed

    Pending

Libra has no production signal for this change yet because it has not deployed. Libra checks hourly for 3 days after each deploy.

RetriggerConfidence Score: 2/5

Do not merge until the reproduced unlinking, backfill traversal, and conversion-reporting failures are fixed, along with the two explicit repository requirements.

Findings

  1. P1 Account unlink removes records
  2. P1 Backfill cannot pass caps
  3. P1 Conversions include non-Deals
  4. P2 Validate metadata at boundary
  5. P2 Use shared form controls
Fix with agent prompt
### Issue 1
apps/mail/modules/conversations/components/CrmAgentBadge.tsx:207-213
For a non-Deal CRM entry with both a record link and account metadata, clicking Account unlink sends no record or deal identifier. The server interprets that as removal of same-provider entries without a deal ID, which includes the displayed Lead or custom-record link. Users can silently lose the record association while trying to unlink only the account.

### Issue 2
apps/server/scripts/backfill-crm-object-records.ts:104-116
When a provider returns more matching records than its capped first result, every pass uses the same `since` value and fetches that same first page. After those records are linked, the next pass enqueues nothing and exits even though later records were never fetched. This leaves older CRM records permanently unbackfilled unless the operator changes the query; advance a provider cursor or an equivalent persisted partition before treating the result as exhausted.

### Issue 3
apps/server/src/services/crm/deal-metrics.ts:404-420
This classifier collapses a resolved AOP with no object binding and a deleted or unresolved AOP into `null`, then treats every transition from a custom-object AOP to either state as a conversion to Deal. Moves from Lead-bound AOPs to Spam, Vendor, another unbound AOP, or a missing AOP therefore inflate the Lead-to-Opportunity conversion rate. Count conversions only when the destination is the resolved Deal/Opportunity AOP.

### Issue 4
apps/server/src/cron/process-external-crm-sync.ts:71-74
This new boundary accepts `connectionMetadata` as `unknown` and immediately asserts that it is a record before reading it. That bypasses the repository directive requiring runtime narrowing or validation for untyped boundary values instead of using a type assertion to silence TypeScript. Validate the metadata or use an inferred typed value; this repository requirement must be satisfied before merging.

### Issue 5
apps/mail/modules/integrations/crm-integration-card.tsx:1108-1128
The new AOP selector manual
Show production surfaces and changed-file mapping

Production surfaces

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

Changed files → surfaces

  • apps/mail/modules/conversations/components/ConversationOverviewCard.tsxno production surface mapped
  • apps/mail/modules/conversations/components/CrmAgentBadge.tsxno production surface mapped
  • apps/mail/modules/conversations/components/conversationFieldRenderers.tsxno production surface mapped
  • apps/mail/modules/crm/types/index.tsno production surface mapped
  • apps/mail/modules/integrations/crm-integration-card.tsxno production surface mapped
  • apps/server/.claude/skills/cedar-configuration/fields-and-values.mdno production surface mapped
  • apps/server/scripts/backfill-crm-object-records.tsno production surface mapped
  • apps/server/src/cron/__tests__/process-external-crm-sync.test.tsno production surface mapped
  • apps/server/src/cron/process-external-crm-sync.tsno production surface mapped
  • apps/server/src/db/aop-schema.tsno production surface mapped
  • apps/server/src/db/crm-schema.tsno production surface mapped
  • apps/server/src/db/migrations/add_aop_bound_object_api_name.sqlno production surface mapped
  • apps/server/src/db/migrations/add_crm_conversation_updates_object_api_name.sqlno production surface mapped
  • apps/server/src/mastra/mcp/external/cedar-staff-debug-tool.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/deprecated-record-shims.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/load-brain-skills-tool.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/load-skill-tool.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/server.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/event-execution/__tests__/handleExecuteExternalCrm.test.tsno production surface mapped
  • apps/server/src/mastra/routeHandlers/event-execution/handleExecuteExternalCrm.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/applyConfigChangeTool.reconciliation.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/__tests__/applyConfigChangeTool.test.tsno production surface mapped
  • apps/server/src/mastra/skills/account-config/tools/applyConfigChangeTool.tsno production surface mapped
  • apps/server/src/mastra/tools/config/config-propagate-tool.tsno production surface mapped
  • apps/server/src/mastra/tools/conversation/__tests__/findCRMConversationsTool.default-aop-scope.test.tsno production surface mapped
  • apps/server/src/mastra/tools/conversation/__tests__/updateConversationFieldsTool.unchanged-approval.test.tsno production surface mapped
  • apps/server/src/mastra/tools/conversation/findCRMConversationsTool.tsno production surface mapped
  • apps/server/src/mastra/workflows/chat/chat-org-rules.tsno production surface mapped
  • apps/server/src/mastra/workflows/event-execution/pre-execution-setup.tsno production surface mapped
  • apps/server/src/mastra/workflows/sync/__tests__/update-external-crm-workflow.test.tsno production surface mapped
  • apps/server/src/mastra/workflows/sync/update-external-crm-workflow.tsno production surface mapped
  • apps/server/src/routes/__tests__/external-mcp.e2e.test.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/adhoc-chat-aop-scope.test.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/bound-object-resolution.test.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/no-hardcoded-deals-aop-comparison.test.tsno production surface mapped
  • apps/server/src/services/aop/__tests__/propagate-mapping.test.tsno production surface mapped
  • apps/server/src/services/aop/adhoc-chat-aop-scope.tsno production surface mapped
  • apps/server/src/services/aop/bound-object-resolution.tsno production surface mapped
  • apps/server/src/services/aop/linked-deal-output-policy.tsno production surface mapped
  • apps/server/src/services/aop/propagate-mapping.tsno production surface mapped
  • apps/server/src/services/aop/utils.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/active-deal.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/before-meeting-prep-floor.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/conversations.stage-required-fields-object-scope.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-conversation-updates-object-api-name.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-deal-auto-link.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-discover-new-deals.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-field-sync-full.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-pull-refresh.record-refresh.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-reconcile-deals.account-only-object.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/crm-sync-watermark.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/deal-audit.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/deal-metrics.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/deal-timeline.test.tsno production surface mapped
  • apps/server/src/services/crm/__tests__/external-crm-events.test.tsno production surface mapped
  • apps/server/src/services/crm/active-deal.tsno production surface mapped
  • apps/server/src/services/crm/before-meeting-prep-floor.tsno production surface mapped
  • apps/server/src/services/crm/conversations.tsno production surface mapped
  • apps/server/src/services/crm/crm-deal-auto-link.tsno production surface mapped
  • apps/server/src/services/crm/crm-discover-new-deals.tsno production surface mapped
  • apps/server/src/services/crm/crm-field-sync.tsno production surface mapped
  • apps/server/src/services/crm/crm-pull-refresh.tsno production surface mapped
  • apps/server/src/services/crm/crm-reconcile-deals.tsno production surface mapped
  • apps/server/src/services/crm/crm-sync-watermark.tsno production surface mapped
  • apps/server/src/services/crm/deal-audit.tsno production surface mapped
  • apps/server/src/services/crm/deal-facts.tsno production surface mapped
  • apps/server/src/services/crm/deal-link-metrics.tsno production surface mapped
  • apps/server/src/services/crm/deal-metrics.tsno production surface mapped
  • apps/server/src/services/crm/deal-status.tsno production surface mapped
  • apps/server/src/services/crm/deal-timeline.tsno production surface mapped
  • apps/server/src/services/crm/external-crm-events.tsno production surface mapped
  • apps/server/src/services/integrations/__tests__/connection-config.test.tsno production surface mapped
  • apps/server/src/services/integrations/connection-config.tsno production surface mapped
  • apps/server/src/services/integrations/crm/__tests__/attio-object-binding.test.tsno production surface mapped
  • apps/server/src/services/integrations/crm/__tests__/field-mapping-writer.test.tsno production surface mapped
  • apps/server/src/services/integrations/crm/__tests__/hubspot-object-binding.test.tsno production surface mapped
  • apps/server/src/services/integrations/crm/__tests__/salesforce-object-binding.test.tsno production surface mapped
  • apps/server/src/services/integrations/crm/attio.tsno production surface mapped
  • apps/server/src/services/integrations/crm/driver.tsno production surface mapped
  • apps/server/src/services/integrations/crm/field-mapping-writer.tsno production surface mapped
  • apps/server/src/services/integrations/crm/hubspot.tsno production surface mapped
  • apps/server/src/services/integrations/crm/salesforce.tsno production surface mapped
  • apps/server/src/services/mail/initial-sync/__tests__/assign-event-aop-correction.test.tsno production surface mapped
  • apps/server/src/services/mail/initial-sync/__tests__/resolve-aop-step.test.tsno production surface mapped
  • apps/server/src/services/mail/initial-sync/finalize-steps.tsno production surface mapped
  • apps/server/src/services/mail/initial-sync/handlers.tsno production surface mapped
  • apps/server/src/trpc/routes/__tests__/integrations-update-write-settings.test.tsno production surface mapped
  • apps/server/src/trpc/routes/crm.tsno production surface mapped
  • apps/server/src/trpc/routes/integrations.tsno production surface mapped
  • docs/design/crm-custom-object-linkage-leads.mdno production surface mapped