Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

fix(agents): sync documents.description on every agent-creation write path

merged#2710CedarCopilot

CedarCopilot wants to merge 2 commits into staging from fix/sync-agent-description-column

Live on prod, 1 of 6 behaviors degradedTimeline and evidence
  1. Opened
    Sep 6, 2026, 9:03 PM
  2. Sep 6, 2026, 11:23 PM
  3. Merged
    Sep 7, 2026, 8:33 AM
  4. Live on prod
    Sep 7, 2026, 8:33 AM
  5. Observed 3 days
    Sep 7, 2026, 8:33 AM
  6. Pipelines steady after this deploy
    Sep 7, 2026, 8:33 AM
  7. Mixed signals

    Live on prod, 1 of 6 behaviors degraded

    Sep 10, 2026, 8:20 AM

Behaviors Libra is checking

The description backfill compares frontmatter and column values after truncating to 200 characters and updates only documents.description for mismatches without rewriting content, metadata, version, or other document columns.Degradedmedium confidence

Strict CloudWatch fallback found 537 prod failure log lines for [UpdateExternalCrmWorkflow] Driver update failed (Step updateOpportunityField failed: HTTP 401: [{\) in the last 24h while checking update, backfill-agent-description-column.test, backfill-agent-description-column.

prod, checked Sep 10, 2026, 8:20 AM
Creating or editing an agent through authorSubagentDoc synchronizes documents.description with the effective description parsed from the content being saved, while leaving the column unchanged when no description is present.Inconclusivehigh confidence

Since the deploy, there are 0 OTEL spans matching authorSubagentDoc, writeDocumentGuarded, writeResourceGuarded, or admin.subagent.author, and 0 concrete CloudWatch executions/successes/errors for that surface. The only related-looking span was 1 execute_tool run-subagent event.

prod, checked Sep 9, 2026, 9:22 PM
The backfill reports documents with a stale top-level description but no usable frontmatter description instead of clearing or guessing the column value.Inconclusivehigh confidence

No production execution evidence was found for the deployed backfill since 2026-09-07T15:33:23Z (~61h). CloudWatch returned 0 rows for the exact [agent-description] scope, per-document warning, subagent-count, and DONE tokens. The script is log-only and emits no OTEL spans, so.

prod, checked Sep 9, 2026, 9:23 PM
The backfill operation repairs mismatched descriptions on non-deleted, exact-shape subagent documents with default operator-only scope, optional email or all-account scope, and a dry-run mode that performs no writes.Inconclusivelow confidence

Verification reached its budget before a verdict.

prod, checked Sep 9, 2026, 10:21 PM
writeResourceGuarded forwards supplied descriptions on existing-document patch and append operations so generic document-listing views do not retain stale descriptions after agent resource edits.Inconclusivehigh confidence

Since 2026-09-07T15:33:23Z, telemetry shows 5 successful execute_tool write-document calls from 1 user, with p95 latency about 1.30s overall. The calls covered ordinary conversation/coaching paths only: 2 patch and 3 upsert; there were 0 append calls and 0 calls to playbook.

prod, checked Sep 9, 2026, 11:22 PM
Playbook migration and seeding upserts populate documents.description from the prepared frontmatter or the effective placeholder/subagent description on every migrated agent write path.Inconclusivehigh confidence

No production telemetry since 2026-09-07T15:33:23Z positively identifies migrateToPlaybook, filesMigrated, or seed-playbook executions. CloudWatch returned 0 matching rows for those exact operation tokens. OTEL shows 5 successful execute_tool write-document spans (p95 1300.4.

prod, checked Sep 10, 2026, 12:22 AM

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

Summary

Traced every current place that creates or edits a subagent document, prompted by a review question on the when_to_use/model retirement PR. documents.description is a separate, generic top-level column (used by generic document-listing routes like documents.ts/kb.ts , not the agent-specific UI/dispatch surfaces, which all read frontmatter fresh) that writeDocument only updates when a caller explicitly passes it. Neither of the two real, active agent-creation paths did:

  • author-subagent.ts's authorSubagentDoc , the single writeDocumentGuarded call site (handles both create and edit) is used by agent-create.ts (the primary create-agent entrypoint) and the repair/edit flow. Now passes the effective description parsed fresh from the content actually being saved.
  • seed-playbook.ts's migrateToPlaybook , all three subagent-doc writes (default system agents, the no-instructions placeholder, and the full custom-agent write) now pass description too.

Confirmed empirically against production: 845 of 854 real subagent docs have this column out of sync with their actual frontmatter description.

Backfill

New backfill-agent-description-column.ts, DRY_RUN-verified against production: 845 to sync, 8 already in sync, 1 skipped (a malformed doc with no frontmatter description at all , correctly reported rather than guessed at, since writeDocument's description param has no way to explicitly clear a stale column value, only to leave it alone). Not run for real yet , flagging for an explicit decision given the scale.

Self-caught during review

My first-pass comment in author-subagent.ts claimed the verification gate "requires" a description to be present before this write. Traced into verify-subagent-doc.ts and found description_present is only a warning-severity check, not an error one , dryReport.ok does not actually guarantee that. Fixed the comment to describe the real (still safe) behavior instead of a false guarantee.

Verified

  • pnpm --filter @zero/server run types , clean.
  • oxlint --deny-warnings , clean on all 6 files.
  • deps:check , clean (1774 modules).
  • Full playbook/agent-workspace test directories plus the new test file , 1364 tests, all pass.
  • DRY_RUN=1 BACKFILL_ALL=1 against the real production database (confirmed on primary via pg_is_in_recovery()).
  • Thermo-reviewed , šŸ”“ Blocking: none.

Known gap, not fixed here

migrateToPlaybook's three write-call fixes have no new dedicated test coverage , this legacy migration function has no existing test file to extend (confirmed by search), and the fix is mechanically identical to the pattern tested thoroughly in author-subagent.test.ts/agent-create.test.ts. Flagging rather than claiming coverage that isn't there.

šŸ¤– Generated with Claude Code

https://claude.ai/code/session_01E3AhwqADAFeqe9wEhz6Mk7

Greptile Summary

This PR propagates agent frontmatter descriptions into the generic documents.description column, adds a bulk synchronization script, and expands tests around the primary authoring path.

  • New-agent and migration writes now supply a top-level description.
  • The backfill plans synchronization against the column's 200-character stored representation.
  • Existing-agent edits still lose the description argument in the guarded patch layer.
  • The backfill can trigger broader subagent reconciliation than its description-only contract suggests.

Confidence Score: 4/5

The PR is not yet safe to merge because existing-agent edits still leave documents.description stale, and the explicit assertion rule must also be satisfied.

The new argument reaches the guarded-write boundary but is omitted from the actual patch sent to writeDocument, leaving the principal edit path functionally incomplete; the bulk backfill also needs protection against unintended reconciliation side effects.

**Files Ne

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/db/migrations/scripts/__tests__/backfill-agent-description-column.test.tsno production surface mapped
  • apps/server/src/db/migrations/scripts/backfill-agent-description-column.tsno production surface mapped
  • apps/server/src/services/agent-workspace/__tests__/agent-create.test.tsno production surface mapped
  • apps/server/src/services/playbook/__tests__/author-subagent.test.tsno production surface mapped
  • apps/server/src/services/playbook/__tests__/guarded-write.test.tsno production surface mapped
  • apps/server/src/services/playbook/author-subagent.tsno production surface mapped
  • apps/server/src/services/playbook/guarded-write.tsno production surface mapped
  • apps/server/src/services/playbook/seed-playbook.tsno production surface mapped