Skip to content

docs(mail): add Non-goals + safety rules 9/10/11; empty-result blocks#714

Open
infeng wants to merge 1 commit intolarksuite:mainfrom
infeng:harness/01kqby5sxrytrtfhv7v5s09kqx
Open

docs(mail): add Non-goals + safety rules 9/10/11; empty-result blocks#714
infeng wants to merge 1 commit intolarksuite:mainfrom
infeng:harness/01kqby5sxrytrtfhv7v5s09kqx

Conversation

@infeng
Copy link
Copy Markdown
Collaborator

@infeng infeng commented Apr 29, 2026

Generated by the harness-coding skill.

  • Task ID: 01KQBY5SXRYTRTFHV7V5S09KQX-8
  • Branch: harness/01kqby5sxrytrtfhv7v5s09kqx
  • Target: main

Sprints

ID Title Status Commit
S1 Synthesize transport contract for larksuite/cli mail SKILL doc edits passed (contract)
S2 Add Non-goals + safety rules 8/9/10 to mail SKILL; add empty-result handling to 5 read-op references; regen SKILL.md passed 7d6a0b7

Source specs

  • /tmp/harness-agent/coding-dev/01KQBY5SXRYTRTFHV7V5S09KQX/01KQBY5SXRYTRTFHV7V5S09KQX-8/input/tech-design.md

This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.

Summary by CodeRabbit

Release Notes

  • Documentation
    • Enhanced mail operation safety policies with improved error handling for searches and write operations.
    • Added explicit confirmation requirements for sensitive operations, including batch action previews.
    • Clarified procedures for handling ambiguous results, requiring user selection before write actions.
    • Improved error reporting guidance for various failure scenarios (empty results, permission issues, not found).
    • Added safeguards preventing unintended resource fabrication.

… in 5 read refs

Per tech-design §4.1-§4.5: harden lark-mail SKILL with two doc-only signals.

mail.md template:
- Add 3 new safety rules covering "empty result is a legal answer" (rule 9),
  "fuzzy match needs user adjudication" (rule 10), and "sensitive write ops
  require user confirmation" (rule 11) with the six API tokens enumerated
  verbatim (messages.trash / batch_trash / recall / labels.delete /
  folders.delete / mail_contacts.delete).
- Add ## ⛔ Non-goals section (5-row table per §4.4) between safety rules
  and identity-selection.
- Extend cap-line to mark Non-goals as same-priority as safety rules.

5 read-op references (triage / message / messages / thread / watch):
- Insert ## ⛔ 空结果处理 block immediately before each file's trailing
  ## 相关命令 / ## 参考 heading. Each block distinguishes empty-array vs
  404 vs network/permission errors per §4.2 and references back to
  Non-goals 第 1 条 + 安全规则 第 9 条.

skills/lark-mail/SKILL.md:
- Regenerated via registry's gen-skills.py (equivalent to
  `make all project=mail` for the gen-skills target). The regen also
  refreshed API-resource and permission-table descriptions from
  registry-conf/output/from_meta/mail.json — these are normal regen
  drift since the artifact was last hand-curated. The regen dropped
  the multi_entity / sent_messages / templates resource blocks because
  registry-config.yaml does not list them under mail.apis; this is a
  pre-existing gap between mail.md prose and registry-config and is
  out-of-scope for this sprint per §1.3 (do not touch registry-config).

Deviation from spec wording: spec §4.1 names new rules "8/9/10" but
rule 8 (草稿回链规则) already exists. Following the S1 contract's Option A,
new rules land at slots 9/10/11 leaving rule 8 intact, and the read-op
reference-back text cites "第 9 条" instead of the spec's "第 8 条".
The substantive content of each rule is unchanged.

NOT touched (per spec §4.5): 6 write-op references, shortcuts/mail/,
internal/registry/meta_data.json, lark-shared, other domain templates,
skill-template/skill-template.md.

sprint: S2
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

This pull request updates mail-related documentation to enforce stricter safety constraints, error handling procedures, and non-goals. Changes span core policy files and operation-specific references, clarifying how agents must handle empty/error responses, ambiguous matches, and sensitive write operations while preventing fabrication of targets.

Changes

Cohort / File(s) Summary
Core policy and safety framework
skill-template/domains/mail.md, skills/lark-mail/SKILL.md
Introduces three main operational constraints: (1) reporting empty/404/permission errors without fabricating targets; (2) listing all fuzzy matches for user selection before writes; (3) requiring explicit confirmation with impact summary for sensitive operations. Establishes Non-goals section formalizing forbidden behaviors (no forging targets, no fabricated drafts/contacts/tags/folders, no semantic substitution). Removes obsolete APIs (multi_entity.search, draft cancel, recall APIs, template APIs) and rewrites resource descriptions to clarify constraints.
Operation-specific error handling references
skills/lark-mail/references/lark-mail-message.md, skills/lark-mail/references/lark-mail-messages.md, skills/lark-mail/references/lark-mail-thread.md, skills/lark-mail/references/lark-mail-triage.md, skills/lark-mail/references/lark-mail-watch.md
Adds granular error-handling documentation for individual mail operations. Specifies distinguishing between 200 OK with empty content, 404 not-found, and auth/permission/network failures, with distinct reporting and recovery guidance per case. Explicitly forbids write operations to fabricate missing resources (messages, threads, folders, events). References core SKILL.md safety rules and non-goals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

documentation, domain/mail, size/M

Suggested reviewers

  • haidaodashushu

Poem

🐰 A carrot bounces through the mail today,
Safety rules now light the safest way—
No fabricating where no messages dwell,
Each error handled, each constraint we tell! 📬✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks required sections (Summary, Changes, Test Plan, Related Issues) from the repository template, providing only metadata about task ID and sprints instead. Add sections for Summary, Changes list, Test Plan with verification steps, and Related Issues to match the repository's PR description template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: adding Non-goals, three safety rules (9/10/11), and empty-result handling blocks to mail documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added domain/mail PR touches the mail domain size/M Single-domain feat or fix with limited business impact labels Apr 29, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-mail/references/lark-mail-message.md`:
- Line 230: The doc's empty-result check wrongly references data.message which
doesn't exist in this response shape; update the text to check for the presence
of required fields instead (e.g., verify that data.message_id and the body_*
fields are present and populated) or reword to "data 缺少关键字段/未包含 message_id 或
body_*"; adjust the sentence that currently mentions `data.message` to reference
`message_id` and `body_*` (or a generic "缺少关键字段") so implementations won't rely
on the non-existent `data.message` field.

In `@skills/lark-mail/references/lark-mail-thread.md`:
- Line 111: The doc incorrectly references data.thread; update the wording to
remove data.thread and base the existence check on data.messages and thread_id
instead: change the sentence that reads "若 `data.messages` 为空数组或 `data.thread`
缺失" to something like "若 `data.messages` 为空数组或 `thread_id` 缺失/不匹配" (or simply
rely on `data.messages` and `thread_id`) so the logic aligns with the defined
return fields (`data.thread_id`, `data.message_count`, `data.messages`) and
avoid referencing the nonexistent `data.thread` field.

In `@skills/lark-mail/SKILL.md`:
- Around line 523-524: Fill in missing short semantic descriptions for the two
empty entries under user_mailbox.rules: add a one-sentence description for
`user_mailbox.rules.reorder` explaining it reorders rules within a user's
mailbox (e.g., change rule priority/order), and add a one-sentence description
for `user_mailbox.rules.update` explaining it updates an existing mailbox rule's
properties (conditions/actions). Locate the entries named `reorder` and `update`
under `user_mailbox.rules` in SKILL.md and replace the empty bullets with those
concise descriptions to restore API docs readability.
- Line 42: The doc uses a short API name `messages.recall` but examples use full
resource.method form like `user_mailbox.sent_messages recall`; update the
wording on this line (and any other occurrences such as `messages.trash`,
`messages.batch_trash`, `labels.delete`, `folders.delete`,
`mail_contacts.delete`) to use the complete resource.method format (e.g.,
`user_mailbox.sent_messages recall`) so examples and the API list are consistent
and avoid misbinding at runtime.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5a074e5-8899-4d6c-b808-10edaf7f7e89

📥 Commits

Reviewing files that changed from the base of the PR and between 4181925 and 7d6a0b7.

📒 Files selected for processing (7)
  • skill-template/domains/mail.md
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-message.md
  • skills/lark-mail/references/lark-mail-messages.md
  • skills/lark-mail/references/lark-mail-thread.md
  • skills/lark-mail/references/lark-mail-triage.md
  • skills/lark-mail/references/lark-mail-watch.md


| 情形 | 表现 | 正确做法 |
|------|------|----------|
| 200 OK 但内容为空 | 极少出现;若 `data.message` 字段缺失或仅含基础元数据,视同未取到 | 回报"未能取到该邮件的完整内容",请用户确认 `message_id` 是否正确 |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

空结果判定字段名与文档返回结构冲突

Line 230 使用 data.message,但本页返回值定义为 data.message_id 等平铺字段。建议改为“data 缺少关键字段”或直接引用 message_id/body_*,避免实现按错误路径判断。

✏️ 建议修订
-| 200 OK 但内容为空 | 极少出现;若 `data.message` 字段缺失或仅含基础元数据,视同未取到 | 回报"未能取到该邮件的完整内容",请用户确认 `message_id` 是否正确 |
+| 200 OK 但内容为空 | 极少出现;若 `data` 缺少正文等关键字段或仅含基础元数据,视同未取到 | 回报"未能取到该邮件的完整内容",请用户确认 `message_id` 是否正确 |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| 200 OK 但内容为空 | 极少出现;若 `data.message` 字段缺失或仅含基础元数据,视同未取到 | 回报"未能取到该邮件的完整内容",请用户确认 `message_id` 是否正确 |
| 200 OK 但内容为空 | 极少出现;若 `data` 缺少正文等关键字段或仅含基础元数据,视同未取到 | 回报"未能取到该邮件的完整内容",请用户确认 `message_id` 是否正确 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-mail/references/lark-mail-message.md` at line 230, The doc's
empty-result check wrongly references data.message which doesn't exist in this
response shape; update the text to check for the presence of required fields
instead (e.g., verify that data.message_id and the body_* fields are present and
populated) or reword to "data 缺少关键字段/未包含 message_id 或 body_*"; adjust the
sentence that currently mentions `data.message` to reference `message_id` and
`body_*` (or a generic "缺少关键字段") so implementations won't rely on the
non-existent `data.message` field.


| 情形 | 表现 | 正确做法 |
|------|------|----------|
| 200 OK 但 `messages` 为空 | 极少出现;若 `data.messages` 为空数组或 `data.thread` 缺失,视同会话不存在或已被全部删除 | 回报"该会话目前没有可读邮件(可能整个会话已被删除)",请用户确认 `thread_id` 是否正确 |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

data.thread 字段引用与本文返回结构不一致

Line 111 提到 data.thread 缺失,但本页“返回值”定义的是 data.thread_id / data.message_count / data.messages。建议改成仅基于 data.messagesthread_id 判定,避免误导实现。

✏️ 建议修订
-| 200 OK 但 `messages` 为空 | 极少出现;若 `data.messages` 为空数组或 `data.thread` 缺失,视同会话不存在或已被全部删除 | 回报"该会话目前没有可读邮件(可能整个会话已被删除)",请用户确认 `thread_id` 是否正确 |
+| 200 OK 但 `messages` 为空 | 极少出现;若 `data.messages` 为空数组(或关键字段缺失),视同会话不存在或已被全部删除 | 回报"该会话目前没有可读邮件(可能整个会话已被删除)",请用户确认 `thread_id` 是否正确 |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| 200 OK 但 `messages` 为空 | 极少出现;若 `data.messages` 为空数组或 `data.thread` 缺失,视同会话不存在或已被全部删除 | 回报"该会话目前没有可读邮件(可能整个会话已被删除)",请用户确认 `thread_id` 是否正确 |
| 200 OK 但 `messages` 为空 | 极少出现;若 `data.messages` 为空数组(或关键字段缺失),视同会话不存在或已被全部删除 | 回报"该会话目前没有可读邮件(可能整个会话已被删除)",请用户确认 `thread_id` 是否正确 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-mail/references/lark-mail-thread.md` at line 111, The doc
incorrectly references data.thread; update the wording to remove data.thread and
base the existence check on data.messages and thread_id instead: change the
sentence that reads "若 `data.messages` 为空数组或 `data.thread` 缺失" to something like
"若 `data.messages` 为空数组或 `thread_id` 缺失/不匹配" (or simply rely on `data.messages`
and `thread_id`) so the logic aligns with the defined return fields
(`data.thread_id`, `data.message_count`, `data.messages`) and avoid referencing
the nonexistent `data.thread` field.

Comment thread skills/lark-mail/SKILL.md
8. **草稿回链规则** — 凡是执行结果产出了草稿,且当前流程不是直接发信(例如 `+draft-create`、`+send` 的草稿模式、`+reply` / `+reply-all` / `+forward` 的草稿模式、草稿编辑后继续查看),都应优先向用户展示草稿打开链接。当前应以创建、编辑、发送链路返回的链接信息为准;**不要把 `user_mailbox.drafts get` 当作获取草稿打开链接的来源**。若当前输出未包含链接,则静默处理,**禁止凭空拼接或猜测 URL**。
9. **空结果即合法答案** — 查询返回空数组、404 或权限不足,都是合法的、需要如实告知的答案。**禁止**通过 `+send` / `user_mailbox.folders create` / `user_mailbox.labels create` / `user_mailbox.mail_contacts create` / `user_mailbox.drafts create` 等写操作凭空构造目标对象再去满足后续动作(删除 / 归档 / 转发 / 回复)。正确做法是把"未找到 / 无结果 / 无权限"原样回报给用户,请用户确认下一步。
10. **模糊匹配需用户裁决** — 当存在多个语义近似但非精确匹配的候选(如多个同名标签、多个主题相似的邮件、多个匹配关键词的联系人)时,**必须**列出全部候选项请求用户裁决,**禁止**自作主张选择其中一个执行写操作。读操作可基于合理默认(如"最近 20 封")展示给用户,但要明确告知是基于哪个默认范围。
11. **敏感写操作前需用户确认** — 以下**无运行时门禁**的写操作在执行前必须先向用户展示「操作对象 + 动作 + 预计影响范围」,并取得当前轮次明确同意:删除邮件 / 撤回邮件 / 批量移动 / 标签删除 / 文件夹删除 / 联系人删除。Agent 在调用以下原生 API 时同样适用:<!-- 如新增 messages.* / labels.* / folders.* / mail_contacts.* 删除/批量类 API,必须同步追加到本条 --> `messages.trash` / `messages.batch_trash` / `messages.recall` / `labels.delete` / `folders.delete` / `mail_contacts.delete`。批量场景必须在确认前给出受影响条目的总数与样例预览,禁止在未确认的情况下直接发起。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

敏感操作 API 名称建议统一到完整 resource.method

Line 42 使用 messages.recall,但本页命令示例是 user_mailbox.sent_messages recall。建议统一成完整命名,避免执行时误配 API。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-mail/SKILL.md` at line 42, The doc uses a short API name
`messages.recall` but examples use full resource.method form like
`user_mailbox.sent_messages recall`; update the wording on this line (and any
other occurrences such as `messages.trash`, `messages.batch_trash`,
`labels.delete`, `folders.delete`, `mail_contacts.delete`) to use the complete
resource.method format (e.g., `user_mailbox.sent_messages recall`) so examples
and the API list are consistent and avoid misbinding at runtime.

Comment thread skills/lark-mail/SKILL.md
Comment on lines +523 to +524
- `reorder` —
- `update` —
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

user_mailbox.rules 两个方法描述为空

Line 523 和 Line 524 目前是空描述,建议补齐最小语义说明,避免 API 目录可读性回退。

✏️ 建议补全
-  - `reorder` — 
-  - `update` — 
+  - `reorder` — 调整收信规则执行顺序
+  - `update` — 更新指定收信规则配置
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `reorder`
- `update`
- `reorder`调整收信规则执行顺序
- `update`更新指定收信规则配置
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-mail/SKILL.md` around lines 523 - 524, Fill in missing short
semantic descriptions for the two empty entries under user_mailbox.rules: add a
one-sentence description for `user_mailbox.rules.reorder` explaining it reorders
rules within a user's mailbox (e.g., change rule priority/order), and add a
one-sentence description for `user_mailbox.rules.update` explaining it updates
an existing mailbox rule's properties (conditions/actions). Locate the entries
named `reorder` and `update` under `user_mailbox.rules` in SKILL.md and replace
the empty bullets with those concise descriptions to restore API docs
readability.

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@7d6a0b75dd699a1d053cac0950105293063c366e

🧩 Skill update

npx skills add infeng/cli#harness/01kqby5sxrytrtfhv7v5s09kqx -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.14%. Comparing base (7752afa) to head (7d6a0b7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #714   +/-   ##
=======================================
  Coverage   64.14%   64.14%           
=======================================
  Files         504      504           
  Lines       44285    44285           
=======================================
  Hits        28406    28406           
  Misses      13411    13411           
  Partials     2468     2468           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread skills/lark-mail/SKILL.md
| `user_mailbox.sent_messages.get_recall_detail` | `mail:user_mailbox.message:readonly` |
| `user_mailbox.sent_messages.recall` | `mail:user_mailbox.message:modify` |
| `user_mailbox.settings.send_as` | `mail:user_mailbox:readonly` |
| `user_mailbox.template.attachments.download_url` | `mail:user_mailbox.message:readonly` |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么删除了这些权限?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/mail PR touches the mail domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants