Repository navigation
docs(spec): the FlowSchema example guards its nullable amount comparisons - #31416
Conversation
…sons The example's two decision edges compared record.amount with < and >= unguarded. Bound to an object whose amount is optional, the publish-time null-guard rule refuses both. Guard e2 with `!= null &&` and route a missing amount to review on e3 with `== null ||`. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2ejruuhep9NDrZsCT7
…the default edge Review follow-up. The example's start node named no object, so the null-guard rule never judged it; bind it to `order` on record-after-update so it is judged as written. Replace the hand-written negation on the review edge with `isDefault: true`, the spelling the schema's own isDefault doc prescribes for "otherwise", and qualify the comment to record-triggered flows. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2ejruuhep9NDrZsCT7
|
domain:spec#4 · marchtian · session_017ihL2ejruuhep9NDrZsCT7 Fable review of the spec diffReviewed at 2026-11-08T06:53Z. The maintainer's standing rule for spec changes: an independent full review of the whole diff by an isolated subagent, which was given the diff and the card, not the author's conclusion. Round 1 (head 38b3ef2): PASS with nits.
Fixes: commit 8c1cc37. The start node now carries Incremental re-review (38b3ef2..8c1cc37): PASS.
Final head after merging |
📓 Docs Drift CheckThis PR changes 1 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 171 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8bd0acf826c9843c0e5d4af0af21a10368bbca9e && git checkout 8bd0acf826c9843c0e5d4af0af21a10368bbca9e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 383c3530304dfa2cdb08d031ab0b1e5b044b35e1 0ec8e99a119c37e9d15985adde102a3b125a745a && git checkout -B drift-repro 383c3530304dfa2cdb08d031ab0b1e5b044b35e1 && git merge --no-ff 0ec8e99a119c37e9d15985adde102a3b125a745a
node scripts/docs-audit/affected-docs.mjs --json 383c3530304dfa2cdb08d031ab0b1e5b044b35e1
|
|
domain:spec#4 · marchtian · session_017ihL2eAG5J8aqAyPZif4BJ Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flagsThe diff touches only the two files. No generated page embeds the example: ④ Design judgmentGuarding the condition rather than Implemented-by: VERDICT: PASS |
…not relaunch itself Contract review follow-up. The start node binds record-after-update with no condition, so the auto-approve write (itself an update) would launch the flow again. Launch only on the transition into 'submitted', as the common-patterns approval example does. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2ejruuhep9NDrZsCT7
|
domain:spec#4 · marchtian · session_017ihL2eAG5J8aqAyPZif4BJ Contract reviewServed-tier: ① Derived judgments (delta review f6f11f2 → 0ec8e99; round 1: 6718493750)
② Semver levelUnchanged: docblock-only, ③ Boundary flagsThe delta touches one file, four comment lines; no generated page embeds the example. ④ Design judgmentMirrors the common-patterns.mdx:337-339 precedent; the comment states the reason. Holds. Implemented-by: VERDICT: PASS |
Requested by 田騏 · project thread
Fixes #31367
Clause-②: no
Metadata-protocol: none
维护者速读
FlowSchema文档注释里的审批流示例:开始节点绑定到order(记录更新后触发),自动审批边改为record.amount != null && record.amount < 500,送审边改为默认边(isDefault: true)。只改注释文字,外加一个 patch changeset。amount直接做</>=比较;作者照抄并绑定到金额可选的对象时,发布期空值保护规则会拒收两条边,运行时金额为空会让流程失败。现在金额为空的订单走人工审核,而不是失败或被自动通过。packages/spec/src/automation/flow.zod.ts的@example Simple Approval Logic(约 L1048–1078);.changeset/31367-flow-example-amount-null-guard.md。!= null保护、e3 为isDefault: true、开始节点有config: { objectName: "order", triggerType: "record-after-update" }。What changes
The
FlowSchemaTSDoc@exampleinpackages/spec/src/automation/flow.zod.ts:config: { objectName: "order", triggerType: "record-after-update" }. Before, it named no object, so the example was never record-triggered (resolveFlowTriggerKindreadsstart.config.triggerType) and the null-guard rule never judged it.e2(auto-approve):record.amount < 500becomesrecord.amount != null && record.amount < 500, the!= null &&idiom from the formula skill and the precedent PR docs(spec): guard the nullable amount in the docs examples and the validation condition example #31358.e3(review):record.amount >= 500becomesisDefault: truewith no condition. It takes every ordere2does not, including one with no amount.nullwhen unset,<on null aborts the condition, test!= nullfirst (has()does not); and whye3is the default edge.Plus a
'@objectstack/spec': patchchangeset.The choice the card asked for: guard the condition, not
required: trueThe
FlowSchemaexample defines no object, so it has nowhere to declarerequired: true. #31358 choserequiredonly where the object was defined in the same snippet (common-patterns.mdx). An author copying a flow example binds it to an object they already have, and on that objectamountis usually optional. So the example teaches the guard they need to write.For the review edge, the schema's own
isDefaultdocblock (a few lines above the example) says the "otherwise" branch should be a default edge, not a hand-written negation of every sibling condition. The first draft usedrecord.amount == null || record.amount >= 500. That also passes the rule, but the review asked for the default edge, and this version uses it. Routing with the decision node's out-edges (exclusive, first condition that holds, else the default): amount499goes toauto_approve, while500andnullgo tosubmit_for_approval. The routing is exhaustive and exclusive.Tests
Proof against the real rule: a scratch vitest file in
packages/lint/src(not committed). It evaluated the@exampleobject literal verbatim from the file (fromorigin/mainfor "before", from the branch for "after") and ranvalidateStackExpressions(the gateos validate,os buildand the publish gate run) withorder.amountdeclared{ type: 'currency' }(nullable):Readings
I added no permanent test. The guard semantics (
!= null &&,== null ||,has()is not a guard) and the edge wiring are already pinned inpackages/lint/src/validate-null-guards.test.tsandvalidate-expressions.flow-null-guards.test.ts, and this diff changes only doc-comment text.Acceptance notes
gen:schema+gen:docsproduce no diff:build-docs.tsrenders.describe()text, not TSDoc@example, and no file undercontent/docs/references/**orpackages/spec/json-schemaembeds this example.skills/objectstack-automation/references/state-machines-and-approvals.md(record.amount > 500000/<= 500000), andpackages/services/service-automation/README.md(record.amount > 500).Verification
Local gate union on the final head
f6f11f22(merge oforigin/maininto 8c1cc37), derived bynode scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack:exit 0.dispatch-gates --ran: "79 derived famil(ies) accounted for, 79 run, 0 NOT-MEASURED (a DERIVED zero)"../packages/**turbo build (81 tasks, forcheck:dual-build-cjs-loads,check:lean-entry-closureand lint'scheck:doc-formula-expressions), plus the fetched positive-control commit forcheck-plugin-teardown-shape --self-test.pnpm install --frozen-lockfile, specgen:schema+gen:docs(no diff),check:generated. Its first run hit a heap-limitedtscincheck:test-typecheck("failed without diagnostics"). Rerun alone withNODE_OPTIONS=--max-old-space-size=6144:exit 0, "52 file(s) / 240 error(s) / 131 pinned signature(s) held". All 14 artifacts are current, and the tree is clean.eslint --no-inline-config packages/spec/src/automation/flow.zod.ts:exit 0.node scripts/check-nul-bytes.mjs:exit 0.f6f11f22with the same readings.pnpm lint,test:repoand the full check farm.Fable review of the spec diff (the maintainer's standing rule for spec changes): round 1 PASS with nits, with two should-fixes: use
isDefaultinstead of the hand-written negation, and bind the start node / qualify the comment. Both are fixed in 8c1cc37. The incremental re-review of the delta: PASS. The verdict comment is posted on this PR.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed (none changed).content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_017ihL2ejruuhep9NDrZsCT7