Skip to content

refactor(sales): Send Email and the activity actions add mail and timeline entries through the platform's doors - #2455

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-n22vzg
Nov 13, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-n22vzg

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Refs objectstack-ai/objectstack#32004

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:联系人上的「发送邮件」把邮件交给平台的邮件服务(ctx.email.send),时间线条目交给平台的活动服务(ctx.activity.append);各销售对象上的「记录通话 / 记录会议 / 安排会议」(共 15 个)也改为通过活动服务写时间线。应用的操作不再自己写邮件日志或活动流;发件人、操作人、组织和来源由平台记录。
  • 为什么改:邮件日志和活动流是平台服务写入的只追加对象,应用自动化应通过平台声明的入口写入(#32004 只追加裁定的第 2 步)。同时去掉了操作体里自己查 sys_user 拼显示名的旧做法,改由平台写入显示名。
  • 风险与回滚:用户能看到的变化有一处:「发送邮件」发出的邮件改为从部署配置的发件地址发出,发件人显示名里带上业务代表的名字(「代表名 via 组织名」),不再从代表自己的邮箱发出;回复仍回到代表的邮箱(reply-to)。邮件的时间线条目不再链接到邮件日志(销售代表本来就打不开),改在详情里记下邮件 id;销售代表在联系人时间线上照常能看到这条。通话/会议条目详情里的备注只保留前 4000 个字符,完整备注仍在活动记录上。回滚即撤销本 PR。
  • 先看:src/sales/actions/contact.actions.ts 的 Send Email 操作体,src/sales/actions/activity-actions.ts 第 3 步(时间线条目),以及 test/script-bodies.test.ts 里新加的「代表能在联系人时间线看到」和「没有操作体直接写只追加对象」两个用例。
  • 两分钟验证:npx vitest run test/script-bodies.test.ts test/global-actions.test.ts,应全部通过(130 个)。
  • 需要你做的:无需决策,由席位复审并落地。

Description

The contact's Send Email action and the fifteen generated activity actions (Log a Call, Log a Meeting, Schedule a Meeting on every sales object) hand their mail and timeline entries to the platform's declared doors, ctx.email.send and ctx.activity.append, which ship in @objectstack 18.4.0. No app action body writes an append-only object itself; the platform's writers record the sender or actor, the organization and the entry's origin.

Type of Change

  • Code refactoring
  • Documentation update

Related Issues

Refs objectstack-ai/objectstack#32004 (step 2 of the append-only ruling). The platform half, objectstack-ai/objectstack#33110 (a hook's published body description says a hook body cannot send mail), has merged.

Changes Made

  • src/sales/actions/contact.actions.ts (Send Email): the message goes to ctx.email.send with the contact as its related record and the rep's address as reply-to; the timeline entry goes to ctx.activity.append. Capabilities api.write, email.send, activity.append. The entry names the contact and carries the mail log row's id in its metadata (email_id), not as its source: the door reads a source in the caller's scope, and a sales rep cannot read the mail log. email_id is not a metadata key the door reserves for the platform.
  • src/sales/actions/activity-actions.ts: step 3 of the generated body adds the entry through ctx.activity.append, with the event as its source; the summary and label are held to the timeline's bounds and the notes in the metadata hint to 4,000 characters (the event keeps the full notes). Capabilities api.write, activity.append; api.read is gone with the body's own sys_user read. The shared actor-name resolution block (ACTOR_NAME_RESOLUTION_SOURCE) is retired: the door stamps the actor and the platform's display name.
  • test/script-bodies.test.ts: Send Email's pin reads what the doors stored: queued handover, rep as sender of record, configured sender with the rep in the display name, rep as reply-to, the contact as related record, no source, metadata.email_id equal to the mail row, the action as origin. New: the rep reads the entry on the contact's timeline through the record page (POST /data/crm_contact/:id/page), as the rep; and a guard that no shipped body addresses an append-only object (the set is read from the booted registry) and that every timeline writer uses the door. Retired: the four pins of the body's own sys_user lookup and its splice guard.
  • test/global-actions.test.ts: the actor test also checks each entry's origin names its own action; a new pin that no activity body resolves an actor; the twins comparison leaves out origin, which names each twin's own action. Retired: the three pins of the body's sys_user lookup and its fault cases, and their read watcher.
  • test/freeze-guard-reference-cleanup.test.ts: a comment no longer cites the retired splice guard.
  • content/docs/guides/email-and-calendar{,.zh-Hans,.zh-Hant}.mdx: Send Email's steps 2 and 3 say where the mail goes out from, where replies go, and what the timeline entry carries.
  • .changeset/mail-and-timeline-through-platform-doors.md (hotcrm: patch).

Testing

Run on this branch with main merged in (35f230d, @objectstack 18.4.0; the docs commit 238251d touches docs only, and the 45 suites that read content/docs were run again after it: 1056 passed, 6 skipped):

  • pnpm changeset status --since=origin/main: hotcrm patch.
  • pnpm validate, pnpm typecheck, pnpm lint (objectstack lint --strict), pnpm hygiene, pnpm hygiene:tokens, pnpm build: exit 0.
  • pnpm test: 268 files, 5106 passed, 7 skipped, 0 failed.
  • Docs app (apps/docs): pnpm types:check exit 0 (compiles the edited MDX).
  • The two changed suites plus the comment-only one: 130/130.
  • Ablations, each red as expected and restored: a reserved metadata key (old) in place of email_id is refused by the door; a mail-log source on the email entry is refused for the rep (the door reads it in the rep's scope); a direct sys_email write in the body trips the new guard.

Checklist

  • I have added a changeset: .changeset/mail-and-timeline-through-platform-doors.md (hotcrm: patch).
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published: @objectstack 18.4.0 is on npm and hotcrm runs on it (feat: run on @objectstack 18.4.0 #2443).

Acceptance notes

  • Behaviour change, stated as the rule: mail sent with Send Email goes out from the deployment's configured sender, with the rep named in the display name, not from the rep's own address. The rep's address is the reply-to, so replies still reach the rep.
  • The timeline looks as before and names the rep by display name. The email entry no longer links to the mail log row; it carries the message id in its details. A call's or meeting's entry keeps the first 4,000 characters of its notes in its details.
  • Tests: 7 that pinned the retired body-side name lookup are removed with it, and 3 that pin the door path are added.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibwzNRpkoiCFn1kQpUh

…eline entries through the platform's doors

Send Email hands its message to ctx.email.send and its timeline entry to
ctx.activity.append; the fifteen generated activity actions add their entry
through ctx.activity.append. No app action body writes an append-only
object itself: the platform's writers stamp the sender or actor, the
organization and the origin.

Mail now goes out from the deployment's configured sender, with the rep
named in the display name; the rep's address is the reply-to. An email's
timeline entry carries the mail log id in its metadata (email_id) instead
of a source, because the door reads a source in the caller's scope and a
sales rep cannot read the mail log. The bodies no longer resolve the
actor's display name themselves; the shared resolution block and its
splice guard are gone, replaced by a guard that no shipped body addresses
an append-only object and that every timeline writer uses the door.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwzNRpkoiCFn1kQpUh
…ts timeline entry carries

The mail goes out from the deployment's configured sender address with the
rep's name in the display name, and a reply comes back to the rep. The
contact's timeline entry carries the message id in its details instead of
linking to the mail log row. English, Simplified and Traditional Chinese.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwzNRpkoiCFn1kQpUh
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hotcrm Ignored Ignored Nov 13, 2026 3:18pm UTC

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd CI plumbing and the verification pipeline backend Server-side behaviour — hooks, flows, actions labels Nov 13, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-tesla · session_01L9qibwMmGJKaQ52CgHqNu2

ACCEPT · 2026-11-13T15:40Z · PR #2455 · head 238251d4

  1. Shape: Refs objectstack-ai/objectstack#32004 (step 2 of ruling 6796076408, hotcrm half; no public card), base main, 9 files: the two sales action bodies (contact.actions.ts, activity-actions.ts), their three test files, the email-and-calendar guide in three locales, one changeset (patch). Clause-②: no. Assignee os-tesla. Branch is 0 behind main.
  2. Premise: the card thread's measurement named two first-party sites in this repository that wrote an append-only object while elevated. Both now go through the declared doors: mail through ctx.email.send and the timeline entry through ctx.activity.append, each with the capability that door needs. No door is widened, and no insert is refused yet (that is step 3).
  3. Contract review: not owed. No packages/spec surface or governed path is touched, and Clause-② is no.
  4. Prose faces, read sentence by sentence: the changeset says what an end user sees change (mail now goes from the configured sender with reply-to set to the rep, and it needs platform 18.4.0), which matches the diff. The three guide edits say the same thing in each locale.
  5. Gates / check-runs: dev gates in /mnt/project-files/security-seat-2/r2026-11-13/out/9p4r-s2-hotcrm-gates.md. On head 238251d4: 10 runs, 10 success, 0 failed, 0 running; mergeable_state clean.
  6. Landing: no governed path (AGENTS.md, CLAUDE.md, .claude/** untouched). Every check has finished and none failed, so the seat readies the PR and arms auto-merge under the maintainer's standing word 「车道经理应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-13).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 13, 2026 15:41
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 92519d8 Nov 13, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side behaviour — hooks, flows, actions ci/cd CI plumbing and the verification pipeline documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants