Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat(pipeline-review): windowed reconcile + executable on-demand subagent run

merged#2467CedarCopilot

CedarCopilot wants to merge 0 commits into staging from feat/pipeline-review-fast-run

Live on prod, no production signal yetTimeline and evidence
  1. Opened
    Aug 13, 2026, 10:52 AM
  2. Merged
    Aug 13, 2026, 1:28 PM
  3. Live on prod
    Aug 13, 2026, 1:28 PM
  4. Observed 3 hours
    Aug 13, 2026, 1:28 PM
  5. Pipelines steady after this deploy
    Aug 13, 2026, 1:28 PM
  6. Unobserved

    Live on prod, no production signal yet

    Aug 13, 2026, 4:35 PM

Behaviors Libra is checking

Background jobs behavior from agent-action-queue/subagent-dispatch.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback saw 567 success-shaped log lines matching /subagent-dispatch.ts, reconciledealswithprovidertool, reconciledealswithprovidertool.test, subagent-dispatch.test, subagent-dispatch, but no tied operation was present, so Libra is not calling this working.

prod, checked Aug 13, 2026, 2:35 PM
Chat workflow behavior from conversation/reconcileDealsWithProviderTool.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 1 prod failure log lines for mirror.upsertEmailThread failed (write CONNECT_TIMEOUT aws-1-us-east-2.pooler.supabase.com:6543), but this domain-wide failure family is not tied to this intent.

prod, checked Aug 13, 2026, 2:35 PM
CRM integration behavior from crm/crm-reconcile-deals.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback found 5 recent prod failure log lines for [UpdateExternalCrmWorkflow] Driver update failed (Step updateDeal failed: HTTP 400: {\), but the same failure had 9 log lines in the comparable pre-deploy baseline. Libra is not blaming this PR intent without.

prod, checked Aug 13, 2026, 3:36 PM
Pipeline analytics behavior from agent-defaults/pipeline-review.ts keeps working in prod.Inconclusivelow confidence

Strict CloudWatch fallback saw 887 success-shaped log lines matching pipeline, analytics, quota, aop, but no tied operation was present, so Libra is not calling this working.

prod, checked Aug 13, 2026, 4:35 PM

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

Two changes to make the weekly pipeline review fast and non-destructive. Motivated by an on-demand pipeline-review run that (a) took minutes and (b) overwrote ~119 of a rep's deals' Cedar fields with sparser Salesforce values.

1. Windowed "recently modified" reconcile (the main fix)

Pipeline-review Step 1 called reconcile-deals-with-provider, whose by-id refresh re-pulled every linked deal from live Salesforce and re-applied field mappings , even for deals that hadn't changed. openStatuses (already on staging) narrowed that to the open pipeline, but that's still ~all open deals (~137 for a large book): slow, and it clobbers fresh Cedar values on unchanged deals.

  • reconcileProviderDeals gains windowedRefreshOnly + windowDays. When windowedRefreshOnly is set, the by-id refresh is scoped to only the deals the provider returned in the fetch window (modified in the last windowDays), composing with openStatuses. New/changed opps are still gap-filled; account-only linking still runs.
  • The tool now defaults recentOnly=true / windowDays=7, so a pipeline review refreshes just what changed since last week. Unchanged deals stay exactly as the hourly sync left them , no overwrite.
  • The nightly full reconcile (service default, windowedRefreshOnly=false, no windowing) is unchanged , it still does whole-book orphan cleanup. Admin/workflow callers of the service are unaffected.
  • Pipeline-review agent-default Step 1 prose updated to describe the windowed behavior.

2. Executable on-demand single-subagent run (cron)

admin.subagent.run --trigger cron --name <slug> --execute now actually runs just that one subagent (via runSingleSubagent, in-process so --no-send/--deliver-to hold) instead of returning plan-only; 'cron' added to EXECUTABLE_TRIGGERS. This is what lets an on-demand pipeline-review run server-side against a deployed environment rather than requiring a local server. (This code existed as uncommitted local WIP; this commits it cleanly off staging.)

Tests

  • subagent-dispatch.test.ts: cron is now executable alongside before_meeting.
  • New reconcileDealsWithProviderTool.test.ts: the tool defaults to windowedRefreshOnly:true / windowDays:7, and honors recentOnly:false + windowDays overrides while forwarding openStatuses.
  • 12/12 pass; @zero/server typecheck + oxlint clean on changed files.

Notes

  • Willem's already-deployed pipeline-review subagent doc will pick up the windowed behavior automatically via the tool default (it passes no recentOnly), no doc edit required.
  • Follow-on: once merged + deployed, the on-demand cedar-cli subagent run --trigger cron --name pipeline-review --execute --no-send --deliver-to <you> path works without a local server.

🤖 Generated with Claude Code

Greptile Summary

The PR limits pipeline-review reconciliation to recently modified CRM deals by default and adds executable, isolated cron subagent runs with optional notification capture and relay.

  • Adds configurable reconcile windowing while preserving the service’s full-reconcile default.
  • Makes cron an executable trigger and introduces an in-process single-subagent runner.
  • Extends the admin route to execute cron runs, capture notification output, and optionally relay it.
  • Adds parameter-forwarding and trigger-executability tests.

Confidence Score: 4/5

The PR should not merge until isolated org-level execution resolves the linked org AOP ID; the relative-import cleanup is non-blocking.

The new level=org path deterministically searches the organization playbook under a user AOP identifier, causing valid org subagents to be reported as missing, while the reconcile windowing itself remains consistent with the documented nightly full-reconcile fallback.

Files Needing Attention: apps/server/src/services/playbook/run-single-subagent.ts and apps/server/src/trpc/routes/admi

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/.claude/skills/playbook-authoring/SKILL.mdno production surface mapped
  • apps/server/.claude/skills/subagent-runner/SKILL.mdno production surface mapped
  • apps/server/src/mastra/tools/conversation/__tests__/reconcileDealsWithProviderTool.test.tsno production surface mapped
  • apps/server/src/mastra/tools/conversation/reconcileDealsWithProviderTool.tsno production surface mapped
  • apps/server/src/services/agent-action-queue/__tests__/subagent-dispatch.test.tsno production surface mapped
  • apps/server/src/services/agent-action-queue/subagent-dispatch.tsno production surface mapped
  • apps/server/src/services/crm/crm-reconcile-deals.tsno production surface mapped
  • apps/server/src/services/playbook/agent-defaults/pipeline-review.tsno production surface mapped
  • apps/server/src/services/playbook/run-single-subagent.tsno production surface mapped
  • apps/server/src/trpc/routes/admin-subagent.tsno production surface mapped
  • docs/design/on-demand-subagent-cli.mdno production surface mapped