Commit 2392e5d
`skills/objectstack-data/references/data-hooks.md` 的 `condition` CEL 绑定一节
仍按 #5038 之前教「`multi: true` 批量写只匹配 N 行、hook 只触发一次,`previous`
无从绑定」,并在结尾明令「never reach for `previous` in a hook that can fire on
insert or on a `multi: true` write」。这对 `before*` 成立,对 `after*` 不成立 ——
后者正是 #5038(ADR-0058 批量写增补)修掉的行为,平台现在按匹配行派发,并有
`packages/objectql/src/bulk-write-per-row-hooks.test.ts` 逐条钉死。危害方向是
skill **明令禁止**平台已支持且已 pin 的模式:按它写的 AI 作者会给批量写路径手工
绕开 transition condition,或干脆不给批量写挂 `after*` 审计/通知 hook —— 而
#5038 的原始动机恰恰是那类 automation「静默不发生」。
按 issue 的验收口径拆成三段,每句都对应仓内一条绿断言:
- `before*`(含批量)整批触发一次,`previous` 无从绑定 —— 保留,并补上「为什么」
(`before*` 仍可改写共享 payload,一个批次只有一份 payload)与该处 `record` 是
裸 payload 这一同源事实;读 `previous` 会被具名拒收并指向 after 事件。
- 新增一条:`after*` 在批量写上**按匹配行**派发,`previous` 是该行 pre-image,
`record` 是该行真实状态(非裸 payload),`input.id` 命名该行(#5038)——
transition condition 因此在 `afterUpdate` / `afterDelete` 上**可用**,写法与
单记录写完全一致。
- 插入事件(`beforeInsert` / `afterInsert`)`previous` 无从绑定 —— 保留,与批量
无关。
#4775 那段(不可求值的 condition 中止写入)语义未动;只把其中「the two bullets
above」改成按名指代(unbound-`previous` 与 `has(...)` 两条),因为上面由两条
bullet 变成了三条,计数指代会失真。
不新增测试没钉住的断言:三段措辞逐句对应
`bulk-write-per-row-hooks.test.ts`(按行派发、每行绑定、`record` 为真实状态、
`input.id` 命名该行)与 `hook-condition-bulk-previous.test.ts`(`before*` 批次
派发具名拒收 `bulk_write_previous_unbound`、`record` 为裸 payload 时的
`bulk_write_stored_state_unavailable`、仍然中止写入),两文件本次实测 44 条全绿。
Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent a2d9351 commit 2392e5d
1 file changed
Lines changed: 26 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
263 | 275 | | |
264 | 276 | | |
265 | 277 | | |
| |||
270 | 282 | | |
271 | 283 | | |
272 | 284 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
278 | 291 | | |
279 | 292 | | |
280 | | - | |
281 | | - | |
282 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
283 | 297 | | |
284 | 298 | | |
285 | 299 | | |
| |||
0 commit comments