Repository navigation
feat(spec): validateControlFlow throws FlowRegionShapeError carrying the container path and node id - #29789
Conversation
…the container path and node id Each of validateControlFlow's three throw sites (invalid region, region analysis error, a parallel with fewer than two branches) now throws the exported FlowRegionShapeError. It carries the faulty container's key path, spelled as collectFlowGraphs' FlowGraph.path plus ['nodes', i] over the raw list, and its node id. The message is unchanged byte for byte. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzj9yXiuW9h8YrpyLMy
…ShapeError; add its changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzj9yXiuW9h8YrpyLMy
📓 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 — 168 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 bcc476fe2083d8bece6737f7a95cb5ba790bfce6 && git checkout bcc476fe2083d8bece6737f7a95cb5ba790bfce6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 601832b1a667992e73d54bf11643849836a6f778 78d8ed02eeeeb32b7a5a71199d4cc2ddeb8b2a1e && git checkout -B drift-repro 601832b1a667992e73d54bf11643849836a6f778 && git merge --no-ff 78d8ed02eeeeb32b7a5a71199d4cc2ddeb8b2a1e
node scripts/docs-audit/affected-docs.mjs --json 601832b1a667992e73d54bf11643849836a6f778
|
|
domain:spec#3 · os-support-ai · session_01WGufzfgvGexKn9vLHsy89K Contract-review-claim: session_01WGufzfgvGexKn9vLHsy89K · head 78d8ed0 · 2026-11-03T04:53Z |
|
domain:spec#3 · os-support-ai · session_01WGufzfgvGexKn9vLHsy89K Contract reviewServed-tier: Inputs read: card #29719 body and all four comments (triage 6594281149, the seat's claims 6594908365 and 6594934995, os-dev-report 6595772995; ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Generated rows ( Test file — holds: every throw site pinned red-first with Changeset — holds: level and both declaration lines match ②; body states the unchanged accept set and message. Implemented-by: VERDICT: PASS |
|
domain:spec#3 · os-support-ai · session_01WGufzfgvGexKn9vLHsy89K 维护者速读
席位意见:一处新公开导出,接受集不动,路径与 席位核对 — ACCEPT · domain:spec#3 · head
|
domain:spec#3 · os-support-ai · session_01WGufzj9yXiuW9h8YrpyLMy
Requested by Yibo Wang · project thread
Fixes #29719
Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: none —
skills/**has 0 hits forvalidateControlFlow; no skill teaches the refusal's type, and the message every skill-facing surface prints is unchanged维护者速读
validateControlFlow拒收一个流程时,抛出的不再是裸Error,而是新导出的FlowRegionShapeError,错误上带两项数据:出错容器节点在流程里的路径path(如['nodes', 1, 'config', 'try', 'nodes', 0])和该节点的nodeId。错误文字一个字节都没变。flow-region-shape-invalid(lint: flow-region-shape-invalid anchors the whole flow; point the finding at the region container at fault #29558)只能把问题挂在整个流程上;要定位到具体容器就得去解析报错句子,那是第二套判定写法,而且嵌套在别的容器里的parallel句子根本不带外层位置。现在读err.path即可。status)都不变;类继承Error,读err.message或instanceof Error的调用方无感。回滚即还原本 PR。packages/spec/src/automation/control-flow.zod.ts(新类与containerPathOf:索引按原始列表取,不按过滤后的graph.nodes)、packages/spec/src/automation/control-flow.test.ts(末尾 5 个新 pin)、.changeset/29719-flow-region-shape-error.md。pnpm --filter @objectstack/spec exec vitest run src/automation/control-flow.test.ts,应见 56 个用例全绿;把control-flow.zod.ts换回origin/main版本再跑,新增 5 个用例全红。What changes
validateControlFlow(packages/spec/src/automation/control-flow.zod.ts) throws the new exportedFlowRegionShapeErrorat all three of its throw sites. The class extendsErrorand adds two readonly fields:path: readonly (string | number)[]: the key path from the flow root to the container node that owns the fault. It is aFlowGraph.paththatcollectFlowGraphshands out, plus['nodes', i], so a reader that already anchors on a graph's path can use it as is. Examples:['nodes', 1]for a top-level container,['nodes', 1, 'config', 'try', 'nodes', 0]for a container inside atryregion,['nodes', 1, 'config', 'branches', 1, 'nodes', 1]for one inside parallel branch 1.nodeId: string: that container'sid.Name and precedent.
FlowRegionShapeError, the seat's call under the veto window (claim 6594934995). Shape mirrored fromListViewGroupQueryError(src/ui/view-grouping-query.ts): anErrorsubclass with readonly data fields,this.nameset to the class name, the message passed through unchanged, andpathas a(string | number)key path. LikeMigrationFloorError(src/migrations/chain.ts) it carries no ADR-0112code/status. That is deliberate: the runtime'sflowDefinitionRefusal(packages/runtime/src/domains/automation.ts) keeps a thrown error's own.statuswhen it has one, so a declared status would overrule the door's 400 classification. Not mirrored:ListViewGroupQueryError's closedreason. The card asks for path and node id only, and a refusal vocabulary would be one more export to review.The index is the raw list's.
collectFlowGraphsdrops a non-record member from thenodesit hands out, whileFlowGraph.pathkeeps indexing the raw list.containerPathOftherefore reads the raw list back throughgraph.pathand finds the node by identity (the walk filters and never copies), so a dropped member before the container does not renumber it. The lookup runs only on a refusal, so the accepting path does no extra work.One judge, one spelling. No new validation path: the same loop, the same three conditions and the same sentences. The only edits are
new Error(m)→new FlowRegionShapeError(path, id, m)and the docblock.Throw sites
origin/main3eeb81d1control-flow.zod.ts:651parallel 'ID': a parallel block needs at least 2 branchesError; the sentence names no enclosing scopepathto theparallelnode, at any depth;nodeIdcontrol-flow.zod.ts:657WHERE: invalid region — ZOD ISSUES(the slot's schema refuses it)Error; location in prose onlypathto the container that owns the slot;nodeIdcontrol-flow.zod.ts:665WHERE: ANALYSIS ERRORS(analyzeRegion: entry/exit/cycle/ids/edges)Error; location in prose onlypathto the container that owns the slot;nodeIdcontrol-flow.zod.ts:532findRegionEntrymalformed control-flow region: …Error:532is a separate judge, not onvalidateControlFlow's path (the PM assumption, measured).validateControlFlownever callsfindRegionEntry. Its one production caller is the engine'srunRegioninpackages/services/service-automation/src/dag-traversal.ts:761, at run time, and it receives a bare region with no flow around it, so it has no flow path or container id to carry. A flow that reaches it registered already. This PR leaves it as it is.Tests
control-flow.test.tsgainsvalidateControlFlow throws FlowRegionShapeError with the container path and id. Every case assertsinstanceof FlowRegionShapeError,instanceof Error,name,path,nodeIdand the full message:pathnodeIdtry_catchwith an unknown region key['nodes', 1]tctry_catch 'tc' try: invalid region —+FlowRegionSchema's own issue messagesloopbody, inside parallel branch 1['nodes', 1, 'config', 'branches', 1, 'nodes', 1]sweepparallel 'fan' branch 1 → loop 'sweep' body:+analyzeRegion's errors (plus a literalregion must be single-entry but has 2: x, y;lead)parallelwith 1 branch, top level['nodes', 0]pparallelinside atryregion (the draft-publish-verdict fixture shape)['nodes', 1, 'config', 'try', 'nodes', 0]fanparallel 'fan': a parallel block needs at least 2 branchesnullbefore the container in the list['nodes', 2]pThe first four also assert one spelling:
pathminus its last two keys is a path thatcollectFlowGraphs(flow)hands out, and the second-to-last key is'nodes'.Red first. With
control-flow.zod.tschecked out fromorigin/main, the five new cases fail (Tests 5 failed | 51 passed (56), lock VERDICT command-exit 1). Restored withgit checkout HEAD --: blob hash equal to HEAD's,git diff HEADempty.Ablation of the raw index (
scripts/ablation-replace.mjs, anchor hit 1 → 0, blob0ac7eeaa→370278a2):raw.indexOf(node)→graph.nodes.indexOf(node). Only the raw-index case fails (Tests 1 failed | 55 passed (56)). Restore checked by blob equal to HEAD and an emptygit diff HEAD. The spec suite importssrc/directly, so nodist/is involved.Message parity, measured. A one-off probe (not committed) ran
origin/main'svalidateControlFlowand this head's over six refused flows: the five cases above plus a multi-exit loop body. Result:byte-identical messages: 6/6.The pinned sentence holds.
packages/metadata-protocol/src/protocol.draft-publish-verdict.test.tspins"Flow 'nested_region' would be refused at registration: parallel 'fan': a parallel block needs at least 2 branches". The@objectstack/metadata-protocolsuite ran green on this head against a specdistbuilt from it (see Verification).Acceptance notes
patch, not the dispatch's assumedminor. AGENTS.md Post-Task step 3: "The level follows the kind alone: a kind takes at leastminor…,nonetakespatch". An exported error class is not authorable metadata, soMetadata-protocol: noneand@objectstack/spec: patch.check-changeset-no-majoron this body: see Verification. The control withminoris refusednone-minor. Precedent:.changeset/26464-mcp-metadata-write-scope.md(Clause-②: yes (widening),none, specpatch).check:generatedreported it fresh (check:declaration-map ✓). Onlyapi-surface/automation.jsonandexport-origins/automation.jsonmoved, one line each.err.pathwhen present, else keeps the flow as the anchor.packages/lint/**is untouched here.Verification
All on head
78d8ed02, underos-verify-lock.spec local suite + typecheck, metadata-protocol suite
pnpm --filter '@objectstack/metadata-protocol^...' run build: exit 0 (specdistbuilt from this head).pnpm --filter @objectstack/spec test:Test Files 803 passed (803),Tests 23805 passed | 1 todo (23806), exit 0.pnpm --filter @objectstack/spec typecheck: exit 0.pnpm --filter @objectstack/metadata-protocol test:Test Files 310 passed | 4 skipped (314),Tests 22292 passed | 26 skipped (22318), exit 0. This includesprotocol.draft-publish-verdict.test.tsand its pinned nested-parallel sentence.VERDICT command-exit 0 · held the lock 843s.test:repowas not run locally (CI'sTest Coreowns it). The diff edits norepo-project test, and the derived list does not name it.generated artifacts
pnpm --filter @objectstack/spec build && … check:generated:✗ 2 of 14 artifact(s) stale(check:api-surface,check:export-origins).check:generated --fixrewrote those two, one line each. The re-check printed all 14✓,check:declaration-mapincluded. Lock VERDICT command-exit 0.check-changeset-no-major with this body as the event
GITHUB_EVENT_NAME=pull_request node scripts/check-changeset-no-major.mjs --base origin/main --event EVENT: exit 0,✓ LEVEL AXIS: … metadata-protocol none … a non-protocol change at patch.@objectstack/spec: minor, same body): exit 1,Check Changeset (level axis): metadata-protocol declares none while a changeset entry is graded minor or above.derived gates (dispatch-gates --commands, 80 families)
check-plugin-teardown-shape --self-testneeded its pinned fixture commit621a4876in this shallow clone.check:dual-build-cjs-loadsandcheck:lean-entry-closureread built output of packages outside the closure.git fetch origin 621a4876…and a fullpnpm turbo run build --concurrency=2(Tasks: 118 successful, 118 total, lock VERDICT command-exit 0), all three exited 0.dispatch-gates --ran:✓ 80 derived famil(ies) accounted for — 80 run, 0 NOT-MEASURED.Generated by Claude Code