Repository navigation
fix(service-automation)!: a flow script node runs its function by package (ADR-0150 D3) - #32257
Conversation
…kage (ADR-0150 D3) The flow `script` node resolved its function through the bare map, which keeps the last registration per name: with two packages holding one name, alpha's flow ran beta's function and a flow with no package ran whichever registered last. It now resolves through `resolvePackageScopedFunction` with the calling flow's armed package as the caller (`flowCallerPackage`): own, else the one holder in the declared closure (plus `sys` and the platform), else refused. A caller with no package resolves environment-wide and a two-holder name is refused `409 RESOURCE_CONFLICT` naming both. The step fails as a guard with the refusal's reason, `code: RESOURCE_CONFLICT` and `innerRefusal`, so the trigger door answers `400 FLOW_FAILED` carrying it. `AutomationEngine#resolveFunction(name, context?)` takes the run context and throws the refusal; `FlowFunctionResolver` gains `callerPackageId`. The objectql hook binder's own-package read (`ownPackageFunction`) reads the package's own holding (`functionHoldersOf`), not the bare map, so a package's own function stays bindable after another package registers the same name (a widening). Every other holder is still refused 400 INVALID_REFERENCE. The action `target` half of the card has no reader: a `target` is a handler key in the action registry (already package-scoped by E2), never a function. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
…registry handler Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
…ts narrowings and the hook-binder widening Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
📓 Docs Drift CheckThis PR changes 2 package(s): 14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 7 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 26 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 d387ce1a7f338ef0cab1e38b2d64b7ea37f8eeec && git checkout d387ce1a7f338ef0cab1e38b2d64b7ea37f8eeec
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9bff554ef125649be4887880a2e3ac75f14de02b 37c087f8d781fcfef9d444a733219021bb34858e && git checkout -B drift-repro 9bff554ef125649be4887880a2e3ac75f14de02b && git merge --no-ff 37c087f8d781fcfef9d444a733219021bb34858e
node scripts/docs-audit/affected-docs.mjs --json 9bff554ef125649be4887880a2e3ac75f14de02b
|
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract-review-claim: session_01WGufzeeBmtefMTT21doena · head fe11d4d · 2026-11-10T14:59Z Face: narrowing, at |
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract reviewServed-tier: Inputs: card #32073 body and all five comments (triage 6760697254, claim 6767942931, step 0 6768303953, rulings amendment 6768322803, os-dev-report 6770696523); PR #32257 body, 12-file list and net diff against merge-base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing makes the spec's own refusal real (ADR-0150 D3 steps 1 to 3 and D4's function row). It takes away no declared capability beyond what D3 (c) and the R2 ruling declare. Attempts to break it:
Findings:
Implemented-by: VERDICT: PASS |
…pin the script refusal $error.code, declare the remaining moved answers, drop the stale action-target sentences S1/S2: the changeset declares the hook binder on an engine without functionHoldersOf, and the two served-by-a-different-holder moves (items 8, 9). N1: every FLOW_FAILED door is named. N2/N3: an owner that is no installed package, and the unregister widening. S4: a try_catch catch region reads $error.code RESOURCE_CONFLICT. N4: objectql and hook-binder text no longer says an action names a function. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
…-9i0rhu Brings in #32239's slot-aware flowCallerPackage (c62e72a), which the script node's caller reads unchanged. No conflict. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
…-9i0rhu One conflict, in the header comment of bare-name-one-holder-request-family.dogfood.test.ts: child B's (#32213) paragraph and the script-node paragraph are both kept, child B's first. The rest of that file and objectql engine.ts merged without conflict. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract-review-claim: session_01WGufzeeBmtefMTT21doena · head 20b9a7e · 2026-11-10T19:44Z Face: narrowing, at |
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract reviewServed-tier: Delta record. The full review is comment 6770945197, PASS at Inputs: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
epic:#31527#1 · os-support-ai · session_01WGufzj7TEH65FDimZdn1H3 Epic red-line read — PASS at
Contract review, ACCEPT and landing belong to the seat. Land once CI is green. Generated by Claude Code |
…-9i0rhu Merge only, for the landing rule (main 15 first-parent commits past the last merge base). No conflict; no change beyond the merge. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfMCbfW87xZBWpt6nE
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract-review-claim: session_01WGufzeeBmtefMTT21doena · head 37c087f · 2026-11-10T21:18Z Face: narrowing, at |
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena Contract reviewServed-tier: Delta record. This record judges only merge ① Derived judgments
② Semver levelClause-② stance unchanged: ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix, no new nit. The merge carries no hand-written line, so the design judged at Implemented-by: VERDICT: PASS |
|
domain:server#3 · os-support-ai · session_01WGufzeeBmtefMTT21doena 席位核对ACCEPT · PR #32257 (
Authority to land: the maintainer's standing rule that seats review and land their own green, ACCEPTed, non-governed PRs through pm-dispatch (2026-11-05, 「你应该使用 pm-dispatch 技能审核和落地pr」; repeated 2026-11-10 14:16Z 「车队应该使用pm-dispatch 技能审核和落地pr」). |
… not only a write's (objectstack-ai#33390) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XN3CiY5nMB8z5cLWxV2JQ7s)_ Fixes objectstack-ai#32379 domain:skills#1 · os-project-manager · session_01FEkQ5nPZFfbs98ogV2mAFM Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:`objectstack-api` 技能里流程入口 `400 FLOW_FAILED` 一段,原文把 `details.innerRefusal` 说成「节点的写入被拒」并只列三个错误码;现改为「节点遇到的拒绝」(数据节点的读或写、`script` 节点的函数名),错误码改为举例并补上 `RESOURCE_CONFLICT`。另在「`apis:` 还是代码处理器」表格的 `script` 行加一个链接,指向 automation 技能里讲「到底运行哪个函数」的条目,不复述。 - 为什么改:自 PR objectstack-ai#32257 起,`script` 节点的函数名在本包范围内有歧义或只在依赖闭包外,流程入口答 `400 FLOW_FAILED`,`innerRefusal.code` 为 `RESOURCE_CONFLICT`;按旧文按错误码分支的客户端会漏掉它。 - 风险与回滚:纯技能文字,`skills/objectstack-api/SKILL.md` 改 5 行、净增 1 行,外加一个 changeset;不动 schema、不动运行时;回滚即还原本 PR。 - 先看:`skills/objectstack-api/SKILL.md` 第 360–363 行(innerRefusal 句),再看第 133 行(表格链接)。 - 两分钟验证:`git diff origin/main -- skills/`,预期只见上述两处:innerRefusal 句改为「a node met」并举 `RESOURCE_CONFLICT`,表格 `script` 行多一个指向 objectstack-automation「Valid-but-silently-wrong」第 3 条的链接。 - 需要你做的:受管面 Tier H(`skills/**`):请批准或合并。 ## What changes - **`skills/objectstack-api/SKILL.md` lines 360–363**, the flow-door paragraph. `innerRefusal?` was "the `{ code, message }` a node's write was refused with, `code` in its wire spelling (`UNIQUE_VIOLATION`, `VALIDATION_FAILED`, `PERMISSION_DENIED`)". It now reads "the `{ code, message }` refusal a node met (a data node's read or write, a `script` node's function name), `code` an `ErrorCode` member in wire spelling (e.g. `UNIQUE_VIOLATION`, `PERMISSION_DENIED`, `RESOURCE_CONFLICT`)". The codes are examples now, not a set. - **`skills/objectstack-api/SKILL.md` line 133**, the "Choosing between `apis:` and a code handler" table. The `script` node row gains one link, "which one runs: [objectstack-automation](../objectstack-automation/SKILL.md#valid-but-silently-wrong-passes-build-fails-at-runtime) item 3", and restates nothing. - **`.changeset/32379-api-flow-inner-refusal-any-node.md`**: `'@objectstack/skills': patch`, carrying both declaration lines. This resumes the released commit `ab838308` (branch `claude/project-thread-xb2225`, Release comment 6807417751) and merges `origin/main` `6538ba48`. Every claim the commit makes was re-read on that `main` (below); none moved, so the text is unchanged. ## Why Each claim, read on `origin/main` `6538ba48`: - **A `script` node's function-name refusal fills `innerRefusal` with `RESOURCE_CONFLICT`.** `packages/services/service-automation/src/builtin/screen-nodes.ts:651-660`: when `engine.resolveFunction` throws a package-scoped refusal, the node returns `code: 'RESOURCE_CONFLICT'` plus `refusalCarriedBy(err)`. Pinned at the flow door by `packages/qa/dogfood/test/bare-name-one-holder-request-family.dogfood.test.ts:280-298` (`[400, 'FLOW_FAILED']`, `details.innerRefusal.code === 'RESOURCE_CONFLICT'`) and in-engine by `packages/services/service-automation/src/flow-function-package-scope.test.ts:134` (both from PR objectstack-ai#32257). - **A data node's read fills it too, not only a write.** `refusalCarriedBy` is called by all four data-node catch arms in `packages/services/service-automation/src/builtin/crud-nodes.ts` (`get_record` :669, and :831, :947, :1026 for the three writes). It carries any declared 4xx throw (`inner-refusal.ts:86-102`). - **`code` is an `ErrorCode` member.** `FlowInnerRefusalSchema.code` is `ErrorCode` (`packages/spec/src/api/automation-api.zod.ts:361-366`). - **The link target exists.** `skills/objectstack-automation/SKILL.md:230` is the heading `## Valid-but-silently-wrong (passes build, fails at runtime)`, and item 3 (`:262-275`) states the package rule for which function a `script` node runs (landed in PR objectstack-ai#32377). The anchor follows the form `skills/objectstack-data/SKILL.md:221` already uses for another heading in that skill. ## Acceptance notes - `skills/` sweep (`git grep` for `innerRefusal` and `FLOW_FAILED`): this paragraph is the only skill text that teaches `innerRefusal`. No `evals/*.json` mentions it, so no eval was made false. - Not in scope, noted only: the spec's own `.describe` on `FlowFailureDetailsSchema.innerRefusal` (`packages/spec/src/api/automation-api.zod.ts:640-642`, mirrored in `content/docs/references/api/automation-api.mdx:389` and `:1140`) still says "the refusal a node's write met". It is spec prose, outside this card's surface (carrier: none). ## Verification Head `9adabd41`, base `origin/main` `6538ba48`. <details><summary>Line and token budget (skills/**)</summary> - `skills/objectstack-api/SKILL.md`: 431 to 432 lines, 20628 to 20841 bytes; token ratchet 5152 to 5206 (ceiling 6314, headroom 1108). No ceiling moved. - Whole package, all `skills/*/SKILL.md` (11 files): 4602 to 4603 lines. Bundle total (whole shipped tree): 244310 to 244364 tokens. - `node scripts/pm/check-skill-line-ratchet.mjs`: exit 0. `node scripts/check-skills-token-ratchet.mjs`: exit 0. </details> <details><summary>Derived gates</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 46 families for the two paths. Each was run on head `9adabd41`, exit code captured before any pipe (record: project file `pm-orders/skills/32379-gates-ran.txt`): - 44 exit 0, among them `check-adr-0087-registration` (scan and `--self-test`), `check-changeset-no-major`, `check-empty-changeset` (scan and `--self-test`), `check-skills-token-ratchet` (scan and `--self-test`), `@objectstack/spec check:skill-docs`, `check:changeset-gate-self-tests`, `check:doc-authoring`, `check:nul-bytes`, `check:pm-governed-merges`, `check:published-files`, `check:skill-compatibility`, `check:skill-frame-sync`, `check:skill-identifier-liveness`, `check:skill-links`. - `@objectstack/lint check:doc-formula-expressions` exit 0, after building the `@objectstack/lint...` closure under the verify lock (VERDICT command-exit 0, 67s). `check:dts-closure` and `check:sourcemap-no-sources-content` exit 0 over the 5 packages that build left in `dist/` only; CI builds every package and runs them in full. - NOT MEASURED, exit 3 PREREQUISITE NOT MET (each reads every package's `dist/`): `check:dual-build-cjs-loads`, `check:lean-entry-closure`. No package source is touched, so no full build was paid locally. - `--ran` reconciliation: "46 derived famil(ies) accounted for — 44 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)". - CI families are read from this PR's check-runs, not re-run here. </details> <details><summary>Tier and governed readings</summary> - `dispatch-gates --tier`: MANDATORY contract-review tier (`skills/**`, clause ①, the published catalog); no one-line exit for this surface. - `node scripts/pm/check-governed-merges.mjs --branch claude/project-thread-co1yph`: exit 3, GOVERNED, landing tier H (人合). 1 of 2 paths on the register (`skills/**`); the changeset is not on it. Size +15 / -4, under the 3000 threshold. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5nPZFfbs98ogV2mAFM <!-- signed: domain:skills#1 · os-project-manager · session_01FEkQ5pjSPT7ui2EUcunaVb --> Co-authored-by: Claude <noreply@anthropic.com>
…unction-resolution refusal (objectstack-ai#33519) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XWxQLsgSQRnPoMBK1Pyo8Ya)_ Fixes objectstack-ai#33402 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:`innerRefusal` 的说明文字(`AutomationResult.innerRefusal` 与 `FlowFailureDetailsSchema.innerRefusal` 的 describe、`FlowInnerRefusalSchema` 与 `FlowFailureDetailsSchema` 的 JSDoc、`contracts/automation-service.ts` 的 JSDoc)从「节点写入时遇到的拒绝」改为「节点在运行中遇到的拒绝(数据节点的读或写,或 `script` 节点解析函数名)」;生成的 API 参考随之更新。 - 为什么改:运行时四个数据节点(含读取的 `get_record`)和 `script` 节点函数名解析失败(`RESOURCE_CONFLICT`,ADR-0150 D3)都会填这个字段;旧说法让写流程错误处理的客户端和 AI 以为读取或函数名拒绝不会出现在这里。 - 风险与回滚:只改说明文字,schema 形状、枚举、可选性、导出和类型都不变,同一输入解析结果不变;spec patch changeset。回滚即 revert。 - 先看:`packages/spec/src/api/automation-api.zod.ts` 的两处 `innerRefusal` describe;其次 `content/docs/references/api/automation-api.mdx` 的两行生成结果。 - 两分钟验证:`git grep -n -i "write met inside" -- packages/spec/src content/docs/references`,预期零命中(main 上 7 处)。 - 需要你做的:无,席位落地。 ## What changes Wording only. The text now says what the producers on `main` do: `refusalCarriedBy` (`packages/services/service-automation/src/inner-refusal.ts`) is spread into all four data-node catch arms of `builtin/crud-nodes.ts` (`get_record`'s arm included, so a READ refusal lands in `innerRefusal`), and into the `script` node's function-resolution refusal in `builtin/screen-nodes.ts` (a `config.function` that names no single function for the flow's package, `code: 'RESOURCE_CONFLICT'`, ADR-0150 D3, PR objectstack-ai#32257). - `packages/spec/src/api/automation-api.zod.ts` - `FlowInnerRefusalSchema` JSDoc, first sentence: FROM "The refusal a flow node's write met INSIDE the run — the structured answer the data layer gave the node, …" TO "The refusal a flow node met INSIDE the run (a data node's read or write, or a `script` node's function resolution) — the structured answer the data layer (or the function resolver) gave the node, …". The "(or the function resolver)" clause is added because "the data layer" alone would be false for the `script` node's refusal; the rest of the sentence is unchanged. - `AutomationResult.innerRefusal` (`TriggerFlowResponseSchema`) `.describe`: FROM "The refusal a node's write met inside the run, structured: …" TO "The refusal a node met inside the run (a data node's read or write, or a `script` node's function resolution), structured: …". The rest is byte-identical. - `FlowFailureDetailsSchema` JSDoc: FROM "the refusal a node's write met inside the run, as `innerRefusal`" TO "the refusal a node met inside the run (a data node's read or write, or a `script` node's function resolution), as `innerRefusal`". - `FlowFailureDetailsSchema.innerRefusal` `.describe`: FROM "The refusal a node's write met inside the run (`AutomationResult.innerRefusal`): …" TO "The refusal a node met inside the run (a data node's read or write, or a `script` node's function resolution; `AutomationResult.innerRefusal`): …". - `userMessage`'s describe already says "the refusal a node met inside the run": left as it is. - `packages/spec/src/contracts/automation-service.ts`, `AutomationResult.innerRefusal` JSDoc: same change as above (the card did not list this site; the order added it). - `content/docs/references/api/automation-api.mdx`: regenerated with `cd packages/spec && pnpm gen:schema && pnpm gen:docs` (not hand-edited). Only the two `innerRefusal` rows move (the `FlowFailureDetails` and `AutomationResult` tables). No other generated file changed. - `.changeset/33402-inner-refusal-describe.md`: `'@objectstack/spec': patch`. The describe text ships in spec `dist` and the JSDoc in its declarations. No schema shape, enum, optional/required, export or type changes. ## Tests - No behaviour changes, so no test is added and nothing is ablated. No test or snapshot pins the old sentence: on `origin/main` `f068cde8`, `git grep -n "write met"` over `packages/spec`, `content/docs` and `skills` hit only the five edited source sites and the two generated rows. - After the edit, `git grep -n "write met" -- packages/spec content/docs skills` shows zero hits that describe `innerRefusal` (the remaining hits are "write metadata …" sentences and released `CHANGELOG.md` entries about other subjects). - On `4da1fb68`: `pnpm --filter @objectstack/spec typecheck` exit 0; `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/api/automation-api src/contracts/automation-service`: Test Files 2 passed (2), Tests 93 passed (93) (lock VERDICT command-exit 0). ## Acceptance notes Comments in `packages/services/**` are outside this card's surface. Two still describe the inner refusal as the data nodes' alone; reported, not touched: - `packages/services/service-automation/src/engine.ts:416-420` (`NodeExecutionResult.innerRefusal` doc): "The refusal this node's data call met … Set by the CRUD executors' catch arms". The `script` node's function-resolution refusal sets it too. - `packages/services/service-automation/src/inner-refusal.ts:54-56` (`refusalCarriedBy` doc): "the one call each data node's catch arm makes (`builtin/crud-nodes.ts`), so the four arms cannot drift …", and `:64` "the caller asked for a write the platform will not do". `builtin/screen-nodes.ts` also calls it. - `FlowInnerRefusalSchema.code`'s describe ("the ADR-0112 member a record save of the same write answers in `error.code`") and the contract JSDoc's "the shape a record save of the same write answers with" keep their wording: they name the comparison for the code spelling, not which node met the refusal, and the order keeps each sentence's other clauses as they are. ## Verification On `4da1fb68` (after building the spec, `@objectstack/lint`, `@objectstack/objectql`, client and client-react closures): `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 103 commands, run one by one with `timeout 900`, each exit code captured before any pipe. - 101 exited 0 in the loop, among them `pnpm --filter @objectstack/spec run check:generated` (the regenerated reference is current), `check:docs`, `check:skill-examples` and `pnpm check:nul-bytes`. - `node scripts/check-plugin-teardown-shape.mjs --self-test` exited 3 in the loop (shallow clone: its pinned fixture commit was absent). After `git fetch --depth=1 origin 621a487…` it exited 0 ("48 cases pass"). - `pnpm check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET: it needs every package's `dist`; only the closures above were built), so it is NOT MEASURED here and left to CI. - `--ran` reconciliation: "103 derived famil(ies) accounted for — 102 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)". - Local-only `node scripts/check-dev-prereqs.mjs` exited 1 because 91 of 107 workspace packages have no `dist` (only the closures above were built); it judges this checkout's build state, not the diff, so it is NOT MEASURED for this change. - Spec drift gate (order hypothesis): yes. `pnpm --filter @objectstack/spec run check:docs` (also run inside `check:generated`, whose roster maps it to `gen:docs` and `content/docs/references/**`) reds a reference that no longer matches the `.describe` text; `cd packages/spec && pnpm gen:schema && pnpm gen:docs` regenerates it. Both exited 0 on this head. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. (No name added.) - [ ] 3. No formatter ran; `pnpm lint` passes. (No formatter ran; `pnpm lint` is CI's run, not run locally.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [ ] The *Before Submitting* list in CONTRIBUTING.md is done. (Left to the seat's review.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5mkZ32rnBNh7FK8TxM Co-authored-by: Claude <noreply@anthropic.com>
Requested by Yibo Wang · project thread
Fixes #32073
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #32264
Narrowing: a flow
scriptnode's function read and the publishedAutomationEngine#resolveFunctionmove from "the last registration" to a refusal for every name that means no single function for the calling flow (BREAKING items 2–7 below), and two packaged-flow shapes move to a different holder (items 8–9), each first-party count 0; the hook binder's own-package read is a widening (400 to served), and on an engine withoutfunctionHoldersOfit narrows (served to 400)维护者速读
script节点调用函数时,按「这条 flow 属于哪个包」来找函数(ADR-0150 D3):先找自己包的,再找声明依赖里唯一的持有者,找不到唯一一个就拒绝并列出所有候选,不再随便取最后注册的那个。hook 按名字绑定自己包的函数时,也不再因为别的包注册了同名函数而被误拒。RESOURCE_CONFLICT。三个首方示例应用的计数都是 0。回滚即撤回此 PR。packages/services/service-automation/src/function-package-scope.ts(新的解析桥);packages/services/service-automation/src/builtin/screen-nodes.ts的 script 节点 catch 分支;packages/objectql/src/hook-binder.ts的ownPackageFunction。pnpm --filter @objectstack/service-automation exec vitest run src/flow-function-package-scope.test.ts,预期 20/20 通过。What changes
Flow
scriptnode (service-automation). The node's function is resolved through the one package-scoped resolver for functions,resolvePackageScopedFunction(@objectstack/objectql, #31716), instead of the bare map's last registration.flowCallerPackage(context)→armedFlowPackage(the onesubflow,mapandconnector_actionnames use). An environment-authored flow and an environment override of a packaged flow are callers with no package. Neither method is edited, so seat 1's PR-1a (slot-awareflowCallerPackage) reaches this node on merge with no change here.function-package-scope.ts:packageScopedFunctionEngineOf(service)(anobjectqlservice withfunctionHoldersOfand aregistry, else none),functionResolverOf(engine)(the engine'sFlowFunctionResolver; a refused name THROWSPackageScopedNameRefusedError), andisPackageScopedRefusal(e)(by class, or by shapecode === 'RESOURCE_CONFLICT' && refusal.status === 'refused', the same predicate as runtimedomains/meta.ts).plugin.ts's#1870bridge now attachesfunctionResolverOf(...). A hostobjectqlwithoutfunctionHoldersOfis left unbridged (fail closed).AutomationEngine#resolveFunction(name, context?)passesthis.flowCallerPackage(context)to the resolver;FlowFunctionResolvergainscallerPackageId: string | null.builtin/screen-nodes.ts: the script node catches the refusal and fails the step as a guard (refuseNode, asconnector_action's name refusal does), with the refusal's text,code: 'RESOURCE_CONFLICT'andinnerRefusal(refusalCarriedBy). Every door that reports a failed run therefore answers400 FLOW_FAILEDwitherror.details.innerRefusal.code: 'RESOURCE_CONFLICT':POST /automation/:name/trigger, the resume door, a flow-type action at/actions(and MCPrun_action), and a declared endpoint (all four buildflowFailureDetails). In-flow,$error.codeisRESOURCE_CONFLICT. Any other throw propagates as before.Hook binder (objectql, seat ruling Q2 = A).
ownPackageFunctionreadsfunctionHoldersOf(name).packageItem(handlerOwnerPackageId(packageId))and still requires the entry's owner to equal the bind'spackageId. The own-package-only rule is unchanged.Docs.
package-scoped-resolver.ts(module header,PackageScopedFunctionQuery,resolvePackageScopedFunction) andObjectQL#functionHoldersOfno longer say "no caller reads it yet" or "a flow or action"; they name the flowscriptnode.hook-binder.tsno longer says an actiontargetnames a function, and its #30803 note now says the script node resolves in the calling flow's package (round 2, contract review N4).Not changed (seat ruling Q1 = A). An action
targetnever reaches the function registry: the script action arm dispatchestargetas a handler key in the action registry (executeRegisteredAction), which E2 #31737 already resolves by package. Measured on maindee2e920in step 0 (comment 6768303953 on #32073): all four action calls answered404 RESOURCE_NOT_FOUNDand the function never ran. No function-bound action dispatch is opened here.BREAKING (declared
no (narrowing); first-party count 0 for each)Measured on booted showcase, crm and multi-package at
dee2e920: no function name has two holders, no owner-less function, and the one first-partyscriptnode (showcaseautomation/flows/index.ts) names its own package'ssummarizeCompletedTask.RESOURCE_CONFLICT(ambiguous-in-environment) naming both; the trigger door answers400 FLOW_FAILEDcarrying it.outside-closurenaming the holder. The one answer a single holder moves.ambiguous-in-closurenaming both.AutomationEngine#resolveFunction(name)FROM the last registration TOresolveFunction(name, context?)throwingPackageScopedNameRefusedErrorfor shapes 2–5.FlowFunctionResolvergains a second parameter; a one-parameter resolver still type-checks.objectqlservice withresolveFunctionbut nofunctionHoldersOf: FROM bridged to the bare map TO unbridged ("no function named … is registered"). EveryObjectQLoffersfunctionHoldersOf.Widening (epic seat addition): a hook whose string
handlernames its own package's engine-registered function (nofunctionshanded to the bind) FROM refused400 INVALID_REFERENCEonce another package registers the name TO bound to its own function. Every other holder is still refused400 INVALID_REFERENCE. Beside it: on an engine carryingresolveFunctionEntrybut notfunctionHoldersOf(reachable only through a cast), a hook's own function goes FROM bound TO refused400 INVALID_REFERENCE, the class of item 7; and afterunregisterFunctionsByPackageremoves a name's last registrant, an earlier holder is served again where the bare map answered "no function" (no source caller).The fix lines are in the changeset, one per moved answer.
Tests
packages/services/service-automation/src/flow-function-package-scope.test.ts(new, 20 cases, realObjectQL, packages installed throughinstallPackage, functions registered with ownerapp:IDasAppPlugindoes):innerRefusal.code === 'RESOURCE_CONFLICT'and that no candidate ran: no-package two-holder, D3 (c) outside-closure,ambiguous-in-closure, platform beside a package holder (no caller, and via closure), a fault edge does not route past it;$error.code: atry_catchcatch region readsRESOURCE_CONFLICToff the failed script step (round 2, contract review S4);engine.resolveFunction(FN)throwsPackageScopedNameRefusedErrorwithcode: 'RESOURCE_CONFLICT',status: 409, reason and both candidates;effect), closure, environment-wide, platform; an unregistered name still fails "no function named" with noinnerRefusal;LiteKernel), and a service withoutfunctionHoldersOfis left unbridged.packages/objectql/src/hook-binder-package-scope.test.ts: new describe, two packages each registershared_stamp: A's later hook binds A's (the widening), B's binds B's, a non-holder and the platform's function are refused withHOOK_HANDLER_NOT_IN_PACKAGE_CODE/_STATUS. The existing "own package registered in an earlier bind" case is the one-holder CONTROL.packages/qa/dogfood/test/bare-name-one-holder-request-family.dogfood.test.ts(booted showcase pluscom.qa.bare.alphaandcom.qa.bare.beta, which already ship the functionqa_shared_fn): each package ships two script flows; four cases: each package's flow runs its own function; aPUT /meta/flowflow with no package is400 FLOW_FAILEDwithinnerRefusal.code: 'RESOURCE_CONFLICT'naming both; beta's flow naming alpha's one-holder function is refused outside-closure; CONTROL: alpha's one-holder function runs for alpha's flow and for a flow with no package.Ablation (one-time; no ablation file kept)
Fix committed first;
scripts/ablation-replace.mjs, thenablation-dist-preflight.mjs.functionResolverOf'sresolvePackageScopedFunction(...)replaced by the bare map'sresolveFunctionEntry(name)(main's answer). service-automation rebuilt; markerresolveFunctionEntry(name)proved indist/index.jsanddist/index.cjs. Red: unit 11 of 19 (every two-holder, refusal, override-refusal and plugin case; e.g. A's flow rancom.acme.stranger), dogfood 3 of 12 (alpha's flow ran beta's; the no-package and D3 (c) flows succeeded). The 8 unit CONTROLs and the dogfood CONTROL stayed green.ownPackageFunction's holders read replaced byresolveFunctionEntry(name). Red: 1 of 12, the widening case (INVALID_REFERENCEon A's own function). The refusals and the one-holder CONTROL stayed green.git checkout HEAD --both files,git status --porcelainempty, service-automation rebuilt,--absentpreflight clean (6 built files), unit 19/19, hook 12/12, dogfood file 12/12.code(S4):code: 'RESOURCE_CONFLICT',removed from the script node's refusal arm (unit tests readsrc). Red: 1 of 20, the$error.codecase ("expected undefined to be 'RESOURCE_CONFLICT'"). Restored withgit checkout HEAD --, tree clean, 20/20.Acceptance notes
c62e72a4; this branch mergedorigin/mainat3191e007(a merge commit, no conflict), then again at84208647once child B feat(objectql, runtime)!: object-less action names held per namespace, and a call that names no package is refused in the two declared holder cases (ADR-0150 child B) #32213 had landed (a merge commit). That second merge had one conflict, in the header comment ofbare-name-one-holder-request-family.dogfood.test.ts. Kept from feat(objectql, runtime)!: object-less action names held per namespace, and a call that names no package is refused in the two declared holder cases (ADR-0150 child B) #32213: its header paragraph (child B narrows the object-less action to the namespace), the namespacedinline()manifest,messageOf,expectMetaRefused,metaAt, its rewritten cold-boot warning and install-local cases, and every case it added. Kept from this PR: its header paragraph,ALPHA_FN,fnRuns/takeRuns,fnFlow, the two script flows and the recording functions inbootPackage,trigger, and its four cases. Measured againstorigin/main, the merged file removes one line,functions: { [FN]: async () => p }, which this PR replaces with the recording functions; it removes none of feat(objectql, runtime)!: object-less action names held per namespace, and a call that names no package is refused in the two declared holder cases (ADR-0150 child B) #32213's assertions. In the merged treeresolveFunctioncalls feat(automation)!: hold, arm and run flows by (package, name), so two packages' same-named flows are each armed #32239's slot-awareflowCallerPackage(context)(flowKeyOfRun, thenarmedFlowPackage) unchanged, and the script node, the bridge andsetFunctionResolverare still the only in-tree readers.bare-name-one-holder.ts:462, and the module header near line 43) still says an actiontargetnames a function; rewording it belongs with the backstop child that narrows phase 1's refusal (ADR-0150 D9). The stale sentences in files this PR edits (hook-binder.tsnear 200 and 207, objectqlengine.tsfunctionHoldersOf,package-scoped-resolver.ts) are fixed in round 2 (contract review N4).hook-binder-package-scope.test.tspins, so it is not done here.Verification
Head
20b9a7e8:origin/mainat84208647merged into039d369f(round 2's head, itselforigin/mainat3191e007merged into the round-2 commit93877518). Every reading below ran on its tree574e91a0. Round 1 headfe11d4da, basedee2e920.Round 2 (contract review 6770945197, PASS at
fe11d4da, should-fix items folded in): S1 and S2 are declared in the changeset (items 8 and 9, and the two bullets under Widening); S4 is pinned by the$error.codecase (ablation leg 3); N1 names all four400 FLOW_FAILEDdoors; N2 adds the owner that is no installed package to item 3; N3 declares the unregister move; N4 fixes the stale sentences listed under Docs. The second merge and what it kept from each side are under Acceptance notes, Serial.pnpm build(whole repo, under the verify lock) after the second merge: exit 0.pnpm --filter @objectstack/service-automation typecheck,@objectstack/objectql typecheck,@objectstack/dogfood typecheck: exit 0, test-typecheck debt unchanged. (feat(automation)!: hold, arm and run flows by (package, name), so two packages' same-named flows are each armed #32239 added@objectstack/service-automationto the dogfood package's dependencies, sopnpm install --frozen-lockfileran once after the first merge to link it.)pnpm --filter @objectstack/service-automation exec vitest run: 273 files, 3663 tests passed.pnpm --filter @objectstack/objectql exec vitest run --project local: 584 files, 12083 tests passed.bare-name-one-holder-request-family.dogfood.test.ts(feat(objectql, runtime)!: object-less action names held per namespace, and a call that names no package is refused in the two declared holder cases (ADR-0150 child B) #32213's cases and this PR's together): 15/15.node scripts/pm/dispatch-gates.mjs --commandson the merged tree: 80 derived commands, run serially with each exit captured before any pipe: 80 exit 0 in one sweep.--ranreconciliation: 80 derived, 80 run, 0 NOT-MEASURED, 0 UNRUN.!and the(narrowing)arm;pnpm --filter @objectstack/dogfood test, no shard, under the verify lock, after the full build): VERDICT command-exit 0, Test Files 449 passed / 3 skipped (452), Tests 3753 passed / 42 skipped (3795).039d369fthe same set read sa 3638, oq 12064, dogfood file 12/12, gates 80/80, full dogfood 448 files / 3745 tests passed. Atfe11d4da(os-dev-report 6770696523): sa 3580, oq 12046, gates 80/80, full dogfood 446 files / 3715 tests passed.Generated by Claude Code