Repository navigation
Commit 4550091
fix(showcase): notify slots on an optional user field complete the run when it is empty (#29099)
domain:server#5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XRzFmxNqPSgstp8DRYyn2mP)_
Fixes #29028
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:showcase 里 8
个流程的通知在负责人/经办人字段为空时也能跑完,外加预算审批流程的启动条件先判空再比较。关于记录本身的提醒(任务完成、项目结项、并行通知、紧急任务的系统写入、嵌套循环提醒)改发给组织所有者(`role:owner`);只对经办人本人说的话("你被分配了"、"请更新任务"、"任务快到期")没有经办人就直接结束,不发。
- 为什么改:`has(FIELD) ? FIELD : null` 在空字段上返回 null(触发记录上空字段是 null,`has()`
为真),通知没有收件人就让整个运行失败,谁也收不到。参考应用教的正是这种无效写法。
- 风险与回滚:只动示例应用(私有包,不发布),不碰引擎、CEL 和通知节点,通知节点"至少一个收件人"的拒收不变。回滚即 revert。
- 先看:`examples/app-showcase/src/automation/flows/index.ts`(三个
`has_assignee` 决策节点、`role:owner` 兜底、紧急任务的嵌套三元式);新测试
`examples/app-showcase/test/notify-recipient-optional-fields.test.ts`;从
#29018 测试抽出的共用 `test/showcase-flow-run.testkit.ts`。
- 两分钟验证:`pnpm --filter @objectstack/example-showcase exec vitest run
test/notify-recipient-optional-fields.test.ts`,预期 `Tests 20 passed
(20)`。
- 需要你做的:无,席位落地。
## What changes
`examples/app-showcase/src/automation/flows/index.ts`, one row per
measured notify slot (an empty field, the row as stored, on base
`6b3ba82c`):
| Flow | Node | Field | Base | Reading | Fix |
|:--|:--|:--|:--|:--|:--|
| `showcase_task_completed` | `notify` | `record.assignee` | fails | a
notice about the record | `isBlank(record.assignee) ? 'role:owner' :
record.assignee` |
| `showcase_task_assigned_notify` | `notify_assignee` |
`record.assignee` | fails (unassigning a task) | "you have been
assigned": assignee only | `has_assignee` decision,
`!isBlank(record.assignee)` edge, `isDefault` edge to `end` |
| `showcase_task_follow_up` | `remind` | `record.assignee` | fails
(after the wait resumes) | "please update its status": assignee only |
`has_assignee` decision after the wait, same shape |
| `showcase_project_closure` | `notify_owner` | `record.owner` | fails
(after sign-off) | the decision needs a reader | `isBlank(record.owner)
? 'role:owner' : record.owner` |
| `showcase_batch_reminders` | `send_reminder` | `task.owner` |
completes | each iteration sits in its `try_catch`, by design | none |
| `showcase_fan_out_notify` | `notify_owner` | `record.assignee` | fails
(the failed branch fails the block, the Slack post with it) | a notice
about the record | `isBlank(record.assignee) ? 'role:owner' :
record.assignee` |
| `showcase_nested_fan_out_reminders` | `notify_owner` | `task.owner` |
fails (ends the sweep) | loop rows are caller data, so the key may be
absent | `has(task.owner) && !isBlank(task.owner) ? task.owner :
'role:owner'` |
| `showcase_nested_fan_out_reminders` | `notify_watcher` |
`task.watcher` | fails | same | same spelling on `task.watcher` |
| `showcase_task_due_reminder` | `remind_owner` | `record.assignee` |
fails | "your task is due": assignee only | `has_assignee` decision,
same shape |
| `showcase_urgent_task_alert` | `alert` | `record.assignee` | completes
on a user's write (`current_user` is the second recipient); fails on a
system write | a notice about the record | `!isBlank(record.assignee) ?
record.assignee : current_user == null ? 'role:owner' : null` (a user's
write still alerts that user, unchanged) |
- `showcase_project_escalation`: #29018 left no `has()` slot.
- The guarded notifies after a `has_assignee` decision read plain
`record.assignee`, as #29018's `alert_owner` does. The notify node's
required-recipient refusal is unchanged.
- Start conditions: `showcase_budget_approval`'s `budget > 100000 &&
budget != previous.budget` faults (`no such overload`) when a budget is
cleared (`null` against a previous value); it is now `budget != null &&
budget > 100000 && budget != previous.budget`.
`showcase_committee_quorum`'s `total_amount >= 5000` is fine: the sum
summary stores `0` on a report with no lines, measured.
- Field writes left alone (order ruling 3): `showcase_task_completed`
`summarize.inputs.priority`; `showcase_task_done_notify_owner`
`call_notify.input.ownerId`; `showcase_inbound_task_webhook`
`create_task.fields.assignee` and `.project`. Writing `null` is the
correct answer there.
- `examples/app-showcase/test/showcase-flow-run.testkit.ts` (new):
#29018's harness moved out of its test file, unchanged in behaviour, so
both files share one kit (order: reuse it, no second harness).
`project-escalation-optional-fields.test.ts` now imports it.
## Tests
- New
`examples/app-showcase/test/notify-recipient-optional-fields.test.ts`,
20 cases on the shared kit: per fixed flow an empty-field case (asserts
the stored row reads `null` first, the run completes, and the fallback
audience or no notify) and a filled-field control that still notifies
the field's user; plus the batch-reminders, quorum and urgent user-write
readings that were already fine.
- `showcase_project_closure` runs with a stand-in
`showcase_closure_signoff` that decides at once (same name and
variables), because the real one waits on a manager approval; the parent
flow and its notify are real.
- `showcase_task_follow_up` is run, parks at its timer wait, and is
resumed with `automation.resume(runId)`.
- **Red on base** (flows file at `6b3ba82c`, tests kept): 9 failed / 11
passed. Failing nodes: `notify`, `notify_assignee`, `remind`,
`notify_owner`, `fan_out` (branch `notify_owner`), `remind_owner`,
`alert` (system write), `fan_out_audiences` (branch `notify_owner`),
each `notify: at least one recipient is required …`; and `condition
failed to evaluate as CEL` (budget). Restored: blob `9f537eab` equal to
HEAD, `git diff HEAD` empty.
- **Ablations** (`scripts/ablation-replace.mjs`, each anchor hit once,
each restored to blob `9f537eab` with `git diff HEAD` empty), one guard
per fixed flow, each run with `-t FLOW`: task_completed fallback →
`record.assignee`: 1 failed; task_assigned edge → `true`: 1 failed;
follow_up edge → `true`: 1 failed; closure fallback → `record.owner`: 1
failed; fan_out fallback → `record.assignee`: 1 failed; nested owner →
`task.owner`: 1 failed; due_reminder edge → `true`: 1 failed; urgent →
`… : null`: 1 failed; budget start guard dropped: 1 failed.
- No `dist/` on the path: the tests import the flows from `src`.
## Acceptance notes
- `pnpm validate` still warns `flow-loop-body-uncontained` on
`showcase_nested_fan_out_reminders` (no `try_catch` in the loop body).
That is the flow's deliberate shape (its docblock: containment would
retag the branch steps); with the fallback an empty recipient no longer
fails a row, so the warning's failure mode no longer comes from these
slots.
- `showcase_task_done_notify_owner` hands `ownerId:
has(record.project.owner) ? record.project.owner : null` to the
`showcase_notify_owner` subflow, whose notify then has no recipient on a
project with no owner. Left alone per order ruling 3 (named as a field
write); not measured here.
## Verification
Every run here and above is on `fb792a78` (branch base `6b3ba82c`), each
test command under `os-verify-lock` (`VERDICT command-exit 0`). The head
`7538f3e3` merges `origin/main` on top; that merge changes nothing under
`examples/app-showcase/`.
- `pnpm --filter @objectstack/example-showcase test`: Test Files 44
passed (44); Tests 538 passed (538). Then `pnpm validate`: exit 0.
- `pnpm --filter @objectstack/example-showcase typecheck`: exit 0.
- `eslint --no-inline-config` on the four touched files: exit 0.
- Derived gates (`dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, derived on this diff): NOT MEASURED
locally, reason: the maintainer asked to wrap up; CI runs the families.
- Changeset: none. `@objectstack/example-showcase` is `"private": true`,
so nothing here ships; `skip-changeset` rides the create.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5kD3ghfUkHD1rTdWYc)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3d848df commit 4550091
4 files changed
Lines changed: 556 additions & 107 deletions
File tree
- examples/app-showcase
- src/automation/flows
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | | - | |
| 193 | + | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
| |||
197 | 201 | | |
198 | 202 | | |
199 | 203 | | |
200 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
| |||
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
239 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
240 | 249 | | |
241 | 250 | | |
242 | 251 | | |
| |||
663 | 672 | | |
664 | 673 | | |
665 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
666 | 678 | | |
667 | 679 | | |
668 | 680 | | |
669 | 681 | | |
670 | 682 | | |
671 | 683 | | |
672 | | - | |
| 684 | + | |
673 | 685 | | |
674 | 686 | | |
675 | 687 | | |
| |||
681 | 693 | | |
682 | 694 | | |
683 | 695 | | |
684 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
685 | 699 | | |
686 | 700 | | |
687 | 701 | | |
| |||
886 | 900 | | |
887 | 901 | | |
888 | 902 | | |
889 | | - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
890 | 907 | | |
891 | 908 | | |
892 | 909 | | |
| |||
1039 | 1056 | | |
1040 | 1057 | | |
1041 | 1058 | | |
1042 | | - | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1043 | 1063 | | |
1044 | 1064 | | |
1045 | 1065 | | |
| |||
1116 | 1136 | | |
1117 | 1137 | | |
1118 | 1138 | | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
1122 | 1144 | | |
1123 | 1145 | | |
1124 | 1146 | | |
| |||
1164 | 1186 | | |
1165 | 1187 | | |
1166 | 1188 | | |
1167 | | - | |
| 1189 | + | |
1168 | 1190 | | |
1169 | 1191 | | |
1170 | 1192 | | |
| |||
1181 | 1203 | | |
1182 | 1204 | | |
1183 | 1205 | | |
1184 | | - | |
| 1206 | + | |
1185 | 1207 | | |
1186 | 1208 | | |
1187 | 1209 | | |
| |||
2012 | 2034 | | |
2013 | 2035 | | |
2014 | 2036 | | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
2015 | 2040 | | |
2016 | 2041 | | |
2017 | 2042 | | |
| |||
2021 | 2046 | | |
2022 | 2047 | | |
2023 | 2048 | | |
2024 | | - | |
| 2049 | + | |
2025 | 2050 | | |
2026 | 2051 | | |
2027 | 2052 | | |
| |||
2032 | 2057 | | |
2033 | 2058 | | |
2034 | 2059 | | |
2035 | | - | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
2036 | 2063 | | |
2037 | 2064 | | |
2038 | 2065 | | |
| |||
2078 | 2105 | | |
2079 | 2106 | | |
2080 | 2107 | | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
2084 | 2111 | | |
2085 | | - | |
| 2112 | + | |
2086 | 2113 | | |
2087 | 2114 | | |
2088 | 2115 | | |
| |||
0 commit comments