Repository navigation
Commit e003ebb
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DYHwnzH3Wsm7FkVeU3Pz4b3)_
Fixes #33019
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:流程回答里的
`droppedFields`(哪些字段因只读没写进去)现在也带上「逐条处理(map)」每条子运行丢掉的字段,以及暂停后再恢复的子流程丢掉的字段,不论恢复时调用方给的是父流程的运行号还是子流程自己的。三条路共用同一个折叠函数,仍按对象+原因合并成一条。折叠函数同时加固:外部注册的节点交回格式不对的
`droppedFields` 时直接跳过,不会把已完成的运行变成失败或重试。
- 为什么改:#33007 之后,回答里 `summary` 写着「改了 N 条」,这 N 条包括 map 每条子运行和恢复过的子流程写的,但
`droppedFields` 只算流程自己的写步骤和不暂停的子流程。最常见的「对每一行提交」场景(map 里每条都写只读的
`status`)回答里一个字都没有。
- 风险与回滚:放宽(回答在这两种形状下多出事件,成员形状不变,没丢字段时仍不出现)。剩下的两个缺口写进了说明:失败的子运行不报丢弃字段(被
`try_catch` / 故障边接住时,回答里没有该成员不能当作「没丢」);暂停后被操作员取消的 map 条目也不报(map
在该条目位置放「已取消」标记继续)。回滚即 revert。
-
先看:`packages/services/service-automation/src/run-dropped-fields.ts`(`foldDropEvents`:唯一的折叠
+ 跳过格式不对的输入);`run-resume.ts`(`creditChildRun`
把子运行的丢弃字段记到等待它的那一步,两个恢复路径都走它);`builtin/map-node.ts`(map
四个出口带上本轮已完成条目的丢弃字段)。
- 两分钟验证:`pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2 src/run-dropped-fields.test.ts`,应见 `Tests 18 passed
(18)`。
- 需要你做的:无,席位落地。本 PR 关 #33019;它也是 #32861 的一部分,#32861 还等控制台那一半
#33009,所以不在这里关。
## What changes
This is the delegated half of #32861 (Part of #32861, which stays open
for its console half #33009). The contract review of PR #33007 (record
6843734657, should-fix S1; delta 6844555869) measured that `summary`
credits a child run's writes from a `subflow` and from each `map` item,
on the synchronous leg and on both resumed legs, while `droppedFields`
rolled up only from a `subflow` child that completed without pausing.
Re-read at `c54a23d2` (main, with #33007 merged): `builtin/map-node.ts`
never read a child's `droppedFields`, and the delegated resume leg and
`bubbleToParent` carried `output` and `summary` only.
Every leg that credits a child run's writes to the parent's `summary`
now folds the child's `droppedFields` into the parent's answer, through
one fold:
- **`run-dropped-fields.ts`**: the fold body moves into
`foldDropEvents(lists)`, and `dropEventsOf(steps)` becomes the fold over
the steps' lists. There is no second copy; `run-resume.ts`'s terminal
exit computes `dropEventsOf(steps)` once and uses it for both its answer
and its up-bubble.
- **`builtin/map-node.ts`**: each entry collects the answers of the
items that completed synchronously and rolls them onto its step at all
four exits (completion, the exit that suspends on a pausing item,
failure, refusal), beside the totals those exits already carry. The
failure exit keeps the earlier items' drops because a `try_catch` or
`fault` edge that contains the failure lets the run complete, and its
answer folds that step.
- **`run-resume.ts` `creditChildRun`** takes the child's drop events and
folds them onto the same awaiting step its totals land on. Both callers
pass them: the up-bubble (`childDroppedFields`, a new trailing
`resumeInternal` parameter) and the delegated leg
(`childRes.droppedFields`).
- **`engine.ts` `bubbleToParent`** takes the completing child's drop
events (the ones its own answer carries) and hands them to the parent's
`resumeInternal`. The refusal arm passes none: a refused run's answer
carries none, the same as the synchronous `subflow` / `map` refusal
arms.
- **Hardening (review nit N1)**: the fold checks each list with
`Array.isArray` and each event with
`DroppedFieldsEventSchema.safeParse`, and skips what fails. The callers
run inside the `try` whose `catch` reads a throw as a node or run
failure, so a host-registered executor's malformed `droppedFields` can
no longer turn a completed run into a failed or retried one.
- **Published sentences**: the
`TriggerFlowResponseSchema.data.droppedFields` describe and the
`AutomationResult.droppedFields` jsdoc drop the "do not yet" sentence
and state the rule as built. The "absent is not proof" clause is
narrowed, not removed, because two delegated legs still do not report: a
child run that FAILED answers no drops, while `summary` still credits
its writes; and a `map` item whose paused run an operator cancelled
(#27971) answers none, as it is credited to `summary` nowhere either.
The regenerated `content/docs/references/api/automation-api.mdx` row
equals the describe. Card ids stay in the adjacent `//` comment
(`check:doc-authoring`).
## Tests
`packages/services/service-automation/src/run-dropped-fields.test.ts` (8
→ 18):
- `map` items that each drop `status` answer one event on the parent,
with `summary.acted: 3`.
- A `map` item that paused and was resumed through its own run id rolls
its drop up (the up-bubble).
- A `map` item that completed before a later item paused keeps its drop
(the map's suspend exit). The later item drops nothing, so the parent
can only learn of the drop from that exit.
- A `map` whose first item drops and whose second item fails under a
`fault` edge: the run completes and the first item's drop reaches the
answer through the map's failure exit.
- A paused child's drops merge with the drops its awaiting step already
holds: item `a` drops `amount` synchronously, item `b` pauses and,
resumed, drops `memo`; the answer holds one event with both fields.
- A `subflow` child that paused, resumed through the parent's run id
(the delegated leg), rolls its drop up.
- A `subflow` child that paused, resumed through its own run id (the
up-bubble), rolls its drop up.
- A host executor's malformed events (`null`, a string, `fields` not a
list, an unknown `reason`) are skipped: the run completes and the
well-typed event beside them still answers.
- A `droppedFields` that is array-like but not a list (it reaches the
step, and iterating it would throw) leaves the run completed with no
member.
- `foldDropEvents` is total, does not mutate its inputs, and answers
`undefined` when nothing well-typed remains.
The children that pause write `status` only after their resume, so each
resumed-leg case can pass only if the resumed child's drops reach the
parent. The up-bubble cases park the parent once more on a `hold` node
after the `subflow` / `map`, so the parent's own answer (given on its
resume) is the thing asserted.
<details><summary>Ablation: each leg cut alone (the test imports src, so
no rebuild is involved)</summary>
All on committed heads, through `scripts/ablation-replace.mjs`, each
restored with `blob == HEAD` and `git diff HEAD` empty.
- A. `map` synchronous exit (`itemDrops.push(child.droppedFields);` x1
-> x0): `Tests 1 failed | 14 passed (15)`, the map synchronous case red.
- B. up-bubble credit (`childDroppedFields` removed from
`resumeInternal`'s `creditChildRun` call): `Tests 2 failed | 13 passed
(15)`, the map up-bubble and subflow up-bubble cases red.
- C. delegated credit (`childRes.droppedFields` removed): `Tests 1
failed | 14 passed (15)`, the subflow delegated case red.
- D. `bubbleToParent` hand-off (`droppedFields` removed from its
`resumeInternal` call): `Tests 2 failed | 13 passed (15)`, the same two
up-bubble cases red.
- E. `map` suspend exit (`...rolledDrops()` removed there): `Tests 1
failed | 15 passed (16)`, the earlier-item case red.
- F. fold `safeParse` guard (raw event used as-is): `Tests 2 failed | 14
passed (16)`, the malformed-event engine case and the `foldDropEvents`
unit case red.
- G. fold `Array.isArray` guard: `Tests 11 failed | 5 passed (16)`. The
direction is broader than the not-a-list case: the guard also skips the
`undefined` list every step without drops carries, so every engine case
that reaches a terminal exit reds.
- H. `map` failure exit (`...rolledDrops()` removed there; on
`4bc2b134`): `Tests 1 failed | 17 passed (18)`, the fault-edge case
alone red.
- I. `creditChildRun` merge (`foldDropEvents([steps[i].droppedFields,
childDroppedFields])` -> the child's list alone; on `4bc2b134`): `Tests
1 failed | 17 passed (18)`, the merge case alone red.
</details>
## Acceptance notes
- **What remains of the limit**: a child run that FAILED answers no
`droppedFields` (only a terminal success carries the member), so a
failed `subflow` child or `map` item contained by `try_catch` or a
`fault` edge contributes its writes to `summary` but its drops to
nothing. Carrying drops on a failed answer would widen
`AutomationResult`'s failure shape; not done here. And a `map` item
whose paused run an operator cancelled (#27971) answers none:
`continuePastCancelledMapItem` lets the map go on with the cancelled
marker in that item's `results` slot, and neither its totals nor its
drops reach the parent. Both clauses are published on the describe, the
jsdoc and the changeset.
- The #32861 changeset
(`.changeset/32861-flow-answer-dropped-fields.md`, not yet released)
still says a paused child and a `map` item "do not yet" roll up. It is
left as written; this PR's changeset states that it lifts that limit, so
the release notes read in order.
- `builtin/subflow-node.ts` is unchanged: its synchronous roll-up
already reads the child's answer, which is the fold's output.
- Clause-② `yes (widening)`: the answer carries more events in two
shapes; the member's shape and the omit-when-empty rule are unchanged,
so `Metadata-protocol: none` and a patch changeset for
`@objectstack/spec` and `@objectstack/service-automation`.
## Verification
Head `d7a8d98f`. Round 2 executes seat rulings 6846930076 item 1
(contract review record 6846914053, PASS on `fb720b6c`, should-fix S1
and S2) in one push of two commits: `4bc2b134` (the two S1 pins; the S2
clause on the describe, the jsdoc and the changeset) and `d7a8d98f` (the
regenerated reference page). No merge of `main` in this round.
<details><summary>Round 2 on `d7a8d98f`: affected tests and
gates</summary>
- Prerequisite: whole-tree `pnpm exec turbo run build --concurrency=2`
under the verify lock, exit 0 (rebuilds `packages/spec` for the changed
describe).
- `run-dropped-fields.test.ts`: `Tests 18 passed (18)`; `pnpm --filter
@objectstack/service-automation typecheck`: exit 0.
- spec `src/api/automation-api.zod.test.ts` + `src/contracts/`: `Test
Files 53 passed (53)`, `Tests 555 passed (555)`.
- The derivation is unchanged from `fb720b6c` (the same 116 commands).
The 67 that read `packages/spec`, docs, the changeset, issue citations,
NUL bytes or test sources were re-run: 67 exit 0, none exit 3. Record:
`gates-ran-affected-d7a8d98f.txt`.
</details>
Round 1, head `fb720b6c` (origin/main `c54a23d2` merged before the PR
opened; main had not moved). Every exit captured before any pipe.
<details><summary>Package tests and typecheck</summary>
- `pnpm --filter @objectstack/service-automation test`: `Test Files 279
passed (279)`, `Tests 3827 passed (3827)`.
- `pnpm --filter @objectstack/spec test`: `Test Files 839 passed (839)`,
`Tests 26796 passed | 1 todo (26797)`.
- `pnpm --filter @objectstack/service-automation typecheck` (`tsc
--noEmit` + `check:test-typecheck`): exit 0, `0 file(s) / 0 error(s)`.
- `run-dropped-fields.test.ts`: `Tests 16 passed (16)`.
- Prerequisites: whole-tree `pnpm exec turbo run build --concurrency=2`
under the verify lock, exit 0; the plugin-teardown fixture commit
fetched.
</details>
<details><summary>Derived gates (`dispatch-gates.mjs --commands`, 116)
and lint</summary>
`node scripts/pm/dispatch-gates.mjs --ran gates-ran-fb720b6c.txt`: `✓
dispatch-gates --ran: 116 derived famil(ies) accounted for — 116 run, 0
NOT-MEASURED (a DERIVED zero — all 116 recorded an exit code and none of
them is 3)`.
- 116 exit 0, none red, none exit 3.
- `pnpm --filter @objectstack/spec run check:generated` and `check:docs`
among them: the regenerated reference page is current.
- `pnpm lint` (`eslint . --no-inline-config`): exit 0 (recorded outside
the derivation).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cxDAXkDm3BEbMTZWFc)_
<!-- signed: domain:server#8 · os-elon-musk ·
session_016WV4cwqTK71kjQzHae8T5J -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8e3d4a5 commit e003ebb
9 files changed
Lines changed: 416 additions & 35 deletions
File tree
- .changeset
- content/docs/references/api
- packages
- services/service-automation/src
- builtin
- spec/src
- api
- contracts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1141 | 1141 | | |
1142 | 1142 | | |
1143 | 1143 | | |
1144 | | - | |
| 1144 | + | |
1145 | 1145 | | |
1146 | 1146 | | |
1147 | 1147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
| |||
261 | 275 | | |
262 | 276 | | |
263 | 277 | | |
| 278 | + | |
264 | 279 | | |
265 | 280 | | |
266 | 281 | | |
| |||
287 | 302 | | |
288 | 303 | | |
289 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
290 | 309 | | |
291 | 310 | | |
292 | 311 | | |
| |||
330 | 349 | | |
331 | 350 | | |
332 | 351 | | |
| 352 | + | |
333 | 353 | | |
334 | 354 | | |
335 | 355 | | |
| |||
340 | 360 | | |
341 | 361 | | |
342 | 362 | | |
| 363 | + | |
343 | 364 | | |
344 | 365 | | |
345 | 366 | | |
| |||
379 | 400 | | |
380 | 401 | | |
381 | 402 | | |
| 403 | + | |
382 | 404 | | |
383 | 405 | | |
384 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8573 | 8573 | | |
8574 | 8574 | | |
8575 | 8575 | | |
| 8576 | + | |
| 8577 | + | |
| 8578 | + | |
| 8579 | + | |
| 8580 | + | |
| 8581 | + | |
8576 | 8582 | | |
8577 | | - | |
| 8583 | + | |
| 8584 | + | |
| 8585 | + | |
| 8586 | + | |
| 8587 | + | |
| 8588 | + | |
8578 | 8589 | | |
8579 | | - | |
| 8590 | + | |
8580 | 8591 | | |
8581 | 8592 | | |
8582 | 8593 | | |
| |||
8592 | 8603 | | |
8593 | 8604 | | |
8594 | 8605 | | |
| 8606 | + | |
| 8607 | + | |
| 8608 | + | |
| 8609 | + | |
| 8610 | + | |
8595 | 8611 | | |
8596 | 8612 | | |
8597 | 8613 | | |
| |||
8604 | 8620 | | |
8605 | 8621 | | |
8606 | 8622 | | |
| 8623 | + | |
8607 | 8624 | | |
8608 | 8625 | | |
8609 | 8626 | | |
| |||
8635 | 8652 | | |
8636 | 8653 | | |
8637 | 8654 | | |
8638 | | - | |
| 8655 | + | |
8639 | 8656 | | |
8640 | 8657 | | |
8641 | 8658 | | |
| |||
8807 | 8824 | | |
8808 | 8825 | | |
8809 | 8826 | | |
| 8827 | + | |
| 8828 | + | |
| 8829 | + | |
| 8830 | + | |
| 8831 | + | |
8810 | 8832 | | |
8811 | 8833 | | |
8812 | 8834 | | |
| |||
8821 | 8843 | | |
8822 | 8844 | | |
8823 | 8845 | | |
8824 | | - | |
| 8846 | + | |
8825 | 8847 | | |
8826 | 8848 | | |
8827 | 8849 | | |
| |||
0 commit comments