Skip to content

docs(automation): hooks-vs-flows 决策指引 — flow 是应用默认面,hook 是系统兜底 - #4272

Merged
os-zhuang merged 2 commits into
mainfrom
claude/unknown-key-stripping-strictness-h3a3zt
Jul 31, 2026
Merged

docs(automation): hooks-vs-flows 决策指引 — flow 是应用默认面,hook 是系统兜底#4272
os-zhuang merged 2 commits into
mainfrom
claude/unknown-key-stripping-strictness-h3a3zt

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

动机

「flow 是应用逻辑的默认面、hook 是系统兜底」这个分层共识,此前只存在于 #4271 的定题讨论里——作者(尤其 AI 作者)在 hooks / flows 两页文档里读不到任何选层指引,两个面在 record 触发逻辑上完全重叠,选错层的代价(hook body 写集静态全盲 vs flow 结构化 config 有 lint)也没有写在作者会看的地方。

改动

content/docs/automation/hooks.mdx — 紧跟页首概念段新增 Hooks vs flows 一节:

  • 任务→层的决策表:存后副作用 / 可暂停节点(审批、屏幕、定时)/ 定时与日期相对扫描 → flow;同一写事务内改动待存记录 / 跨对象全写路径不变量 / 读侧拦截(beforeFind/afterFind,flow 无读事件)→ hook;
  • 两条结构性理由:flow 的写是可校验的元数据(update_record.fieldsos validate 检查:readonly、模板方言、表达式槽),hook body 的写集静态不可见(链接到 hook-bodies 页已有的 accepted-gap 锚点);flow 以数据形态可 diff 可审,hook body 只能按代码审;
  • 收尾指出「需要代码也不必是 hook」:flow script 节点 + defineStack({ functions }) 让编排留在受检元数据里。

content/docs/automation/flows.mdx — Related 列表加反向链接指到新节。

.changeset/hook-vs-flow-path-guidance.md — 空 changeset(docs-only 惯例,不发版)。

核实

  • 表中每条能力主张都对照了两页现有内容:flow 的 schedule/timeRelative/暂停语义、script 节点两种形态、hook 的读侧事件与 inline 执行(不可暂停);
  • 写集 gap 的措辞与 hook-body.zod.ts:134-140 的 schema 注释一致,锚点 #not-statically-checked-the-write-set 已验证存在;
  • 纯散文 + 表格,无新增 os:check 代码示例,零 schema 漂移面。

关联:#4271(写集 lint 设计 issue)、#4001(母 issue)。


Generated by Claude Code

… default surface, hook the backstop

The framing settled while scoping #4271 existed only in an issue thread:
flows are the default application surface (structural config that os
validate checks; reviews as data; can pause), hooks are the system
backstop (in-write mutation, cross-object invariants, read-side events —
but a statically opaque body). Land it where authors look: a task→layer
table plus the two structural reasons on hooks.mdx, a reverse link from
flows.mdx Related. Docs only; empty changeset per repo convention.

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

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 31, 2026 1:48am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling size/s labels Jul 31, 2026
…lary

check:role-word flags any NEW prose use of the word; rephrasing beats a
baseline entry for a sentence that never meant authorization.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147tNF4Snk7Ry1KGt4a5PY4
@os-zhuang
os-zhuang marked this pull request as ready for review July 31, 2026 01:51
@os-zhuang
os-zhuang merged commit 92a5e68 into main Jul 31, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/unknown-key-stripping-strictness-h3a3zt branch July 31, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants