Repository navigation
Commit b440ffb
docs(skills): name the ctx.email.send and ctx.activity.append body doors in the data-hooks reference (#33078)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao4mxVDvLfhyeEEmRuW5tvnb)_
Fixes #33033
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`objectstack-data` 技能的 `data-hooks.md` 现在点名 #32966 发布的两个脚本体入口:沙箱
`ctx` 表加 `ctx.email` / `ctx.activity` 两行,「Capabilities — the complete
list」加 `email.send` / `activity.append` 两行,并把过时的「exactly five」改为「exactly
seven」(`HookBodyCapability` 在 main 上是七个值)。
- 为什么改:按原文写钩子的 agent 找不到这两个入口,还可能在钩子体里发邮件——这在解析时就被拒(裁决 #32004
6843314411)。规则只陈述一次:钩子体不能持有 `email.send`(解析与绑定时拒收),记录变更时的邮件走 action、job
或 flow;`activity.append` 随运行脚本体的那次写入一起提交或回滚;`type` 只能用应用自己的值(平台类型 403
拒收),且不得在 `ctx.api.transaction` 内调用(409)。另把「async
钩子用于发邮件」改为「发通知」,免得与新规则矛盾。
- 风险与回滚:只改已发布技能文字,无代码改动;token 10007 / 10011(同文件删复述付账,不抬上限)。回滚即 revert。
- 先看:`skills/objectstack-data/references/data-hooks.md` 第 355–356
行(`ctx` 表两行)、第 426–436 行(能力表两行 + seven),第 197 行(async 用途)。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs | grep
data-hooks`,预期 `10007 / 10011` 且退出 0。
- 需要你做的:本 PR 触及 `skills/**`(Tier H)。契约复审在现 head 已 PASS(r1 评论
6849613993,r2 增量 6849985798,Head-sha
`dc05d1b0a91dd4c9d89f6fe6b558114e54f03818`),请以 os-zhuang 批准。⛔ 18.4.0
合并冻结中(#32908 6848983225):本 PR 带 changeset,批准后请勿入队,席位在解冻后落地。
- 席位意见:同意落地。两个钩子体入口、解析/绑定两处拒收、两个入参 schema 逐一对过;r1 的两个
should-fix(activity.append 的 type 与事务内调用会被拒;async 段落仍教「发邮件」)已在 r2 修掉;余两个
nit 作为接受的偏差。
## What changes
- **`ctx` table:** `ctx.email` (`{ send }`, gated by `email.send`, not
in a hook body) and `ctx.activity` (`{ append }`, gated by
`activity.append`).
- **Capabilities — the complete list:** "exactly five" → "exactly seven"
(it was stale: `HookBodyCapability` on `main` b232220 lists `api.read`,
`api.write`, `api.transaction`, `crypto.uuid`, `log`, `email.send`,
`activity.append`), plus two rows:
- `email.send`: `ctx.email.send({ to, subject, text })`, mail via the
mail service with sender, user and organization stamped
(`BodyMailSendInputSchema`); not in a hook body, refused at parse and at
bind, because a message cannot be taken back if the hook's write rolls
back; mail on a record change goes through an action, a job or a flow.
- `activity.append`: `ctx.activity.append({ object, recordId, type,
summary })`, one record-timeline entry with actor and origin stamped
(`BodyActivityAppendInputSchema`); commits or rolls back with the write
that runs the body. `type` is the app's own, never a
`SYS_ACTIVITY_PLATFORM_TYPES` value (403 `PERMISSION_DENIED`, aborting
the write under `onError: 'abort'`), and the call is never made inside
`ctx.api.transaction` (409 `RESOURCE_CONFLICT`).
- **`async` section:** "Sending emails/notifications" → "Sending
notifications", so no line sends an author to mail from a hook.
- **Truth sources read on `main` b232220:**
`packages/spec/src/data/hook-body-doors.zod.ts` (both input schemas and
their descriptions), `packages/spec/src/data/hook-body.zod.ts`
(`HookBodyCapability` JSDoc), `packages/spec/src/data/hook.zod.ts`
`refuseHookBodyMailGrant` (parse-side refusal; its block comment names
the bind-side refusal in `hookBodyRunnerFactory`),
`content/docs/automation/hook-bodies.mdx` rows for both doors,
`content/docs/kernel/runtime-services/email-service.mdx`. The skill text
claims nothing those do not say; the required input keys named are the
schema's required keys (`text` stands for "`text` or `html`").
- **Budget paid by same-file restatement cuts, no ratchet raise:**
- the `body` vs `handler` table's "Ships as" row and the paragraph after
the table ("Because a `body` is pure metadata …") — both restate the
Shape/Status rows and the section intro;
- the Hook Context API callout's tail "including the `where` query shape
and the `update({ id, … })` pattern" — the linked section already titles
both;
- the "What Are Hooks?" four-bullet list, which restates the Before vs
After table (now linked) and the `ctx` table;
- the Cross-Object API paragraph's second link to the sandbox section
and its "additionally require `api.read` / `api.write`" sentence — the
callout at the top of the same `## Hook Context API` section links the
sandbox section, and the capability table states the tokens.
## Tests
Teaching text only; no tested behaviour changed, so no ablation.
## Acceptance notes
- Readings (published `skills/**`):
`skills/objectstack-data/references/data-hooks.md` lines 953 → 943,
tokens 9987 → 10007 (ceiling 10011) at head dc05d1b.
- No out-of-scope findings.
## Verification
<details><summary>Gates: CI on dc05d1b 44 check-runs, 28 success, 16
skipped, 0 failed; local derived list at e7336ef, skill-text gates
re-run on dc05d1b</summary>
- Derivation: `node scripts/pm/dispatch-gates.mjs --commands` (45
commands) plus `pnpm check:changeset-fixed` (roster under `.changeset`,
flagged by the derivation). `@objectstack/lint...` built first for
`check:doc-formula-expressions`.
- `main` b232220 merged before opening: no-op. Skill-text gates re-run
on e7336ef, each exit 0: `check-skills-token-ratchet` (10007 / 10011),
spec `check:skill-refs`, spec `check:skill-docs`,
`check:skill-identifier-liveness`, `check:skill-links`.
- Re-run on dc05d1b, 16 commands, each exit 0 (token ratchet 10007 /
10011, spec `check:skill-refs` / `check:skill-docs`, skill identifier
liveness, skill links, doc authoring, changeset gates, closing-keyword
parity, …).
- NOT MEASURED locally (exit 3, prerequisite: whole-workspace dists):
`check:dual-build-cjs-loads`, `check:lean-entry-closure`. The diff is
one markdown file and a changeset, which cannot move built dists; CI's
`Build Core` ran both on dc05d1b: success.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibzqxVnBg8FjZXM1fQu)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibzqxVnBg8FjZXM1fQu
<!-- signed: domain:skills#2 · os-tesla ·
session_01L9qibvXzthnUYrxzphgFgW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2c98485 commit b440ffb
2 files changed
Lines changed: 17 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
29 | 24 | | |
30 | 25 | | |
31 | 26 | | |
| |||
199 | 194 | | |
200 | 195 | | |
201 | 196 | | |
202 | | - | |
| 197 | + | |
203 | 198 | | |
204 | 199 | | |
205 | 200 | | |
| |||
316 | 311 | | |
317 | 312 | | |
318 | 313 | | |
319 | | - | |
320 | 314 | | |
321 | 315 | | |
322 | 316 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | 317 | | |
328 | 318 | | |
329 | 319 | | |
| |||
362 | 352 | | |
363 | 353 | | |
364 | 354 | | |
| 355 | + | |
| 356 | + | |
365 | 357 | | |
366 | 358 | | |
367 | 359 | | |
| |||
431 | 423 | | |
432 | 424 | | |
433 | 425 | | |
434 | | - | |
| 426 | + | |
435 | 427 | | |
436 | 428 | | |
437 | 429 | | |
| |||
440 | 432 | | |
441 | 433 | | |
442 | 434 | | |
| 435 | + | |
| 436 | + | |
443 | 437 | | |
444 | 438 | | |
445 | 439 | | |
| |||
559 | 553 | | |
560 | 554 | | |
561 | 555 | | |
562 | | - | |
563 | | - | |
| 556 | + | |
564 | 557 | | |
565 | 558 | | |
566 | 559 | | |
| |||
727 | 720 | | |
728 | 721 | | |
729 | 722 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
| 723 | + | |
734 | 724 | | |
735 | 725 | | |
736 | 726 | | |
| |||
0 commit comments