Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

feat(crm): field-query skill + heal historical select/list drift

merged#2885CedarCopilot

CedarCopilot wants to merge 3 commits into staging from worktree-agent-a9ebefe25728061a4

What Libra verified

  • The field-query skill is available to chat agents

    Libra ran this behavior against the change and confirmed the check detects when it breaks.

    Technical evidence
    • the chat skill catalog includes field-query so chat agents can discover it before querying CRM field values
    • the catalog entry for field-query makes its discovery-before-query guidance available when chat agents select the skill

    Changed code: field-query.ts.

Live on prod, watching, 2 days leftTimeline and evidence
  1. Opened
    Sep 22, 2026, 4:51 PM
  2. Merged
    Sep 22, 2026, 8:41 PM
  3. Live on prod
    Sep 22, 2026, 8:41 PM
  4. Observed 3 hours
    Sep 22, 2026, 8:41 PM
  5. Watching

    Live on prod, watching, 2 days left

    Sep 22, 2026, 8:41 PM
  6. Pipelines steady after this deploy
    Sep 22, 2026, 8:41 PM
  7. Sep 22, 2026, 8:42 PM

Behaviors Libra is checking

Queries against background taxonomy fields retrieve the field's payload schema and scoring rubric before reading timeline, field-evolution, or search payload details.Not checked
prod
Comprehensive requests for all matching deals or companies scan every plausible field containing the concept with wide set-based queries rather than looping through individual deals.Not checked
prod
The agent compares row and distinct-conversation coverage across candidate fields and checks additional candidates when the leading field is sparse.Not checked
prod
When an external CRM is connected, field-query reports default to conversations linked to CRM opportunities via dealId and otherwise fall back to all Cedar conversations unless the user explicitly requests another scope.Not checked
prod
Matches found across duplicate or historical fields are merged by conversation_id while retaining evidence and values from every field that matched.Not checked
prod
CRM field queries first discover the relevant AOP fields and taxonomy fields before querying conversation field values instead of guessing a field ID.Not checked
prod

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

Summary

  • Adds the field-query skill (apps/server/.claude/skills/field-query/SKILL.md): mandatory discover-before-query order for crm_conversation_field_values (list-fields/taxonomy-fields before run-sql or conversation-read), a vocabulary-check step, and a standing rule to always state the search space used in the final answer. States plainly that extraction is a primitive capture layer with no notion of confidence or canonicalization , that judgment belongs to the querying agent, applied fresh every time.
  • Heals the 74 candidate (org, field) pairs found with real casing/punctuation drift against their declared select/list options, using the exact coerceToCanonicalOptionValue algorithm from #2883 ported to Python (this worktree has no node_modules). 61 of 74 had real drift; applied with per-row verification, 16,382 rows healed across 16 orgs. Originals preserved in metadata.healedFrom; a post-hoc sweep confirms zero healed row differs from its original by anything beyond case/whitespace/underscore.
  • Adds two eval harnesses under playbook-instruction-eval, reimplemented in Python, exercising the real chat agent against real DB reads (read-only run-sql/config-read):
    • field_query_corpus_eval.py , full agentic completions against real historical failure prompts.
    • field_query_fire_rate_eval.py , cheap targeted fire-rate measurement across the full 9-prompt real-customer corpus, isolating two specific behaviors instead of requiring full completions: discovery-before-query (22% baseline → 73% with skill) and search-space disclosure in the final answer (13% → 33%). Includes an explicit negative control that correctly stays at 0/5 in both conditions.

Honest status

  • Discovery-before-query effect is strong and consistent. Search-space-disclosure improved meaningfully but is still far from universal (33% with the skill) , real remaining gap, not fully solved.
  • Two of the 9 corpus prompts (Mihir/Invoice Butler's deal-source questions) stay weak even with the skill in the discovery-first test; plausibly because the compound question's first sub-answer (a plain count) doesn't need field discovery, so the measurement may be counting a legitimate non-field run-sql call as a miss. Flagged, not resolved.
  • Both scripts require DATABASE_URL (and ANTHROPIC_API_KEY for the evals) in the environment , no secrets committed.

Test plan

  • Healing script dry-run spot-checked across dozens of mappings (including all of Warp's affected fields) before apply , confirmed pure formatting changes only, never a merge of two distinct option values.
  • Applied for real with per-row verification; post-hoc DB sweep confirms 16,380 healed rows are all case/whitespace/underscore-only diffs from their originals.
  • Fire-rate eval run against the real chat-agent framing + real tools across all 9 corpus prompts, both variants, 5 trials each.
  • Not yet run against the full chat-agent server process (dry Python reimplementation of the prompt/tool shape, not a live E2E call to the running server).

šŸ¤– Generated with Claude Code

RetriggerConfidence Score: 2/5

The PR is not safe to merge until live customer CRM data is removed and the outstanding SQL tenant-scope and healing-verification defects are addressed.

Findings

  1. P1Ā <img alt="Security" src="h
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/field-query/SKILL.mdno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/_arie_fire_rate.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/_diag_arie.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/_diag_rippling.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/dump-skills-catalog.tsno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/field_query_completion_test.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/field_query_corpus_eval.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/field_query_discoverability_eval.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/field_query_fire_rate_eval.pyno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/arie_diagnostic.logno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/arie_fire_rate.jsonno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/arie_fire_rate.logno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/arie_fire_rate_with_semantic_search.jsonno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/corpus_run.logno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/discoverability_run.logno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/field_query_completion_results.jsonno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/field_query_discoverability_results.jsonno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/results/rippling_diagnostic_run2_PASS.logno production surface mapped
  • apps/server/.claude/skills/playbook-instruction-eval/search-field-values-bridge.tsno production surface mapped
  • apps/server/.claude/skills/run-sql/SKILL.mdno production surface mapped
  • apps/server/scripts/heal-select-list-option-drift.pyno production surface mapped
  • apps/server/src/mastra/agents/chat-agent.tsno production surface mapped
  • apps/server/src/mastra/skills/crm/field-query.tsno production surface mapped
  • apps/server/src/mastra/skills/index.tsno production surface mapped
  • apps/server/src/mastra/skills/types.tsno production surface mapped