Libra CodeHub

CedarCopilot/cedar-mail

Branch: staging

revert(mcp): restore per-tool intent capture, Manufact confirmed it's compliant

merged#2835CedarCopilot

CedarCopilot wants to merge 1 commit into staging from fix/restore-intent-tracking

Live on prod, watching, 2 days leftTimeline and evidence
  1. Opened
    Sep 20, 2026, 7:51 AM
  2. Merged
    Sep 20, 2026, 7:55 AM
  3. Live on prod
    Sep 20, 2026, 7:55 AM
  4. Observed 0 hours
    Sep 20, 2026, 7:55 AM
  5. Watching

    Live on prod, watching, 2 days left

    Sep 20, 2026, 7:55 AM
  6. Pipelines steady after this deploy
    Sep 20, 2026, 7:55 AM
  7. Sep 20, 2026, 7:57 AM

Behaviors Libra is checking

External chat persistence refuses to attach a message to an existing sessionId owned by another user.Not checked
prod
External MCP calls made while staff impersonation is active continue to receive ordinary tool telemetry but never persist the debugged user's human-readable intent.Not checked
prod
Intent capture persists an external-mcp user summary and assistant tool-call activity in chat_messages, stamps both the thread and message with the external-mcp source, mirrors conversation text to Redis working memory, and posts the activity to the #cedar-chat monitor.Not checked
prod
Each self-identity external MCP call with a non-empty user summary records the model-reported intent before the tool handler runs, including calls that later fail or are rejected.Not checked
prod
Chat and Slack intent persistence runs fire-and-forget so database or monitor failures do not fail or add persistence latency to the MCP tool call.Not checked
prod
Intent captures for the same user execute in arrival order while different users can capture concurrently, and a failed capture does not stall later captures for that user.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

PR #2834 removed the user_request_summary/is_new_request intent-capture fields from every external-MCP tool, reading Manufact's readiness-checklist finding as disqualifying for a required, admittedly-pure-telemetry field ("A tool may request a brief, task-specific user intent field only when it meaningfully improves execution...").

Manufact has since confirmed directly that this pattern is acceptable, so this restores the mechanism exactly as it was before that fix:

  • INTENT_FIELD_SHAPE, injectIntentFields, and the recordIntent capture branch in tool-call-observability.ts
  • the recordExternalMcpToolIntent/recordExternalChatMessage/runSerializedPerUser/resolveExternalMcpThreadId chain in chat-message-persistence.ts
  • the instrumentToolCalls call site + import in server.ts
  • every test/doc reference: tool-call-observability.test.ts, chat-message-persistence.test.ts, external-mcp.e2e.test.ts, flat-args.test.ts, no-bare-user-id-inputs.test.ts, mutating-actions-are-administrable.test.ts, tool-inputschema-size.test.ts, redact-secrets.ts, deprecated-record-shims.ts, docs/design/mcp-observability-and-plugin.md

Deliberately scoped

Only the intent-capture removal is reverted. The other three fixes from PR #2834 are untouched:

  • reworded, narrower server instructions (server.ts's purposeSentence)
  • external-only credential/secret redaction from config-read/systems-write schemas (external-capability-redaction.ts, scope-map.ts)
  • document-write.delete's new approval-ask gate (approval-policy.ts)

Confirmed no overlap by diffing this restoration file-by-file against PR #2834's own diff , external-capability-redaction.ts, scope-map.ts, documentTool.ts, approval-policy.ts, and the document-deletion docs are all untouched here. The three test files shared between fix #2 and fix #3 (flat-args.test.ts, no-bare-user-id-inputs.test.ts, mutating-actions-are-administrable.test.ts, tool-inputschema-size.test.ts) keep fix #2's externalFamilyTools() switch and additionally restore fix #3's injectIntentFields wrapping , both fixes coexist correctly in those files.

Verification

  • tsc -b clean
  • pnpm deps:check clean (no dependency violations, 1843 modules cruised)
  • Scoped vitest across all 11 affected/adjacent test files: 332/332 passing (tool-call-observability.test.ts, chat-message-persistence.test.ts, server.test.ts, flat-args.test.ts, no-bare-user-id-inputs.test.ts, mutating-actions-are-administrable.test.ts, tool-inputschema-size.test.ts, scope-map.test.ts, external-capability-redaction.test.ts, external-mcp.e2e.test.ts, approval.test.ts)

🤖 Generated with Claude Code

RetriggerConfidence Score: 2/5

The PR is not safe to merge until existing cached MCP schemas remain callable and free-text intent summaries are prevented from leaking sensitive content to persistence and Slack.

Findings

  1. P1 Cached schemas reject calls ▶
  2. P1 Security Intent summaries expose secrets <a hre
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/mcp/external/__tests__/flat-args.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/mutating-actions-are-administrable.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/no-bare-user-id-inputs.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/tool-call-observability.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/__tests__/tool-inputschema-size.test.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/deprecated-record-shims.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/server.tsno production surface mapped
  • apps/server/src/mastra/mcp/external/tool-call-observability.tsno production surface mapped
  • apps/server/src/mastra/utils/__tests__/chat-message-persistence.test.tsno production surface mapped
  • apps/server/src/mastra/utils/chat-message-persistence.tsno production surface mapped
  • apps/server/src/mastra/utils/redact-secrets.tsno production surface mapped
  • apps/server/src/routes/__tests__/external-mcp.e2e.test.tsno production surface mapped
  • docs/design/mcp-observability-and-plugin.mdno production surface mapped