Skip to content

Commit d48fb15

Browse files
docs(skills): teach the script node's package rule in the automation skill (#32377)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} --> _Requested by **Irene** · [project thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67xLjjFkBgp6SaDhRAG3Lnvvj)_ Fixes #32264 ## 维护者速读 - 改了什么:`objectstack-automation` 技能「Valid-but-silently-wrong」第 3 条新增一段:`script` 节点的 `config.function` 按调用它的 flow 所属包解析(与 `subflow` 的 `flowName` 同一规则),平台函数(无包注册)对所有 flow 可达,`.custom` 覆盖按无包 flow 读取;附 `normalize_phone` 双包示例、失败形态(步骤以 guard 失败、`$error.code: 'RESOURCE_CONFLICT'`;经 flow 入口调用时 `400 FLOW_FAILED` 带 `error.details.innerRefusal`)和两种修法(声明依赖或改名)。 - 为什么改:PR #32257 已让 script 节点按包解析函数(ADR-0150 D3),技能原文只说「调用已注册函数」,作者照写会撞上平台的拒绝却不知原因。 - 风险与回滚:仅改技能文本、token 棘轮一行(6687 → 实测 6861,先削同文件一处复述)和一个 changeset,无运行时代码;回滚即撤回此 PR。 - 先看:`skills/objectstack-automation/SKILL.md` 第 3 条新增段落(下方 diff),以及「Card vs main」一节。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`(预期全部在天花板内),对照下表逐条看源码行。 - 需要你做的:本 PR 为 **Tier H**(`skills/**`),当前 head 还欠契约审查(contract review),之后需一位授权审批人 Approve,再由 skills 席位落地。 ## What changes Silently-wrong item 3 of `skills/objectstack-automation/SKILL.md` gains one paragraph on how a `script` node's `config.function` resolves since PR #32257, beside the item that already owns script-node behaviour. The `script` row of the node table (L97) already points at item 3 and is unchanged, so the rule has one home. The D3 steps themselves are not restated: the paragraph points at the `subflow` row (L76), which already teaches them, and adds only what differs for functions. ```diff 3. **`script` nodes call a registered function — nothing else.** `config.function` (**required**: an empty node refuses at execute, an unregistered name fails - loudly) names one registered via `defineStack({ functions: { my_fn: (ctx) => … } })`. + loudly) names one registered in `defineStack({ functions })` (below). + + **The name resolves from the flow's package, as `subflow`'s `flowName` + does**, the platform's function (registered under no package) in every + flow's reach; a `.custom` override reads as a package-less flow. `acme.crm` + and `acme.sales` both shipping `normalize_phone` each run their own (the boot + warns `Bare-name conflict at boot`). If the flow's package holds none, two + holders in reach (the platform's counts) or one only outside its + `dependencies` closure fail the step as a guard (no `fault` edge; + `$error.code: 'RESOURCE_CONFLICT'` in a `try_catch`); a flow door answers + `400 FLOW_FAILED`, `error.details.innerRefusal` naming each holder. Fix: + declare the dependency, or rename. ``` ## Taught claims and their source on `main` (`c7dd505de`) | Claim in the skill | Source | |:--|:--| | The node resolves its function for the calling flow's package | `packages/services/service-automation/src/builtin/screen-nodes.ts` L653 (`engine.resolveFunction(target, context)`); `packages/services/service-automation/src/engine.ts` L4520–L4527 (passes `flowCallerPackage(context)`) | | Same rule as `subflow`'s `flowName`: own, else the one holder in the `dependencies` closure plus `sys`; package-less flow reads environment-wide | `packages/core/src/package-scoped-resolution.ts` L623–L666 (`resolvePackageScopedHolders`, steps 1–3 at L644, L647, L660; environment-wide `resolveEnvironmentWide` L591); function adapter `packages/objectql/src/package-scoped-resolver.ts` L189–L199; bridge `packages/services/service-automation/src/function-package-scope.ts` L63–L75. `subflow` reads the same caller (`engine.ts` L7135) | | The platform's function (registered under no package) is in every flow's reach | `packages/objectql/src/engine-hooks-and-functions.ts` L262 (owner-less registration held under `null`), L303–L315 (`platformItem`, `environmentItem: () => undefined`); `package-scoped-resolution.ts` L602–L606 (package-less caller), L651–L654 (package caller holding none) | | An owner-less function alone answers; beside a reachable package holder it is refused | same lines; tests `flow-function-package-scope.test.ts` L228–L245 (refused, both callers), L334 (CONTROL, platform alone served) | | Own beats a closure holder; two packages each run their own | `package-scoped-resolution.ts` L644–L645; tests L138–L170 (both registration orders, own over closure) | | A `.custom` override (and an environment-authored flow) reads as a package-less flow | `engine.ts` L5706–L5712 (`flowCallerPackage`), L5732–L5736 (`armedFlowPackage` answers only for `source: 'package'`), L5717–L5721 (doc: undefined for the shipping package's declared `.custom` override and for a runtime body), L2602–L2606 (`'override'` = the paired `<package>.custom`); tests L354–L382 | | Two holders in reach, the platform's counting, refuse (`ambiguous-in-closure` / `ambiguous-in-environment`); a holder only outside the closure refuses (`outside-closure`) | `package-scoped-resolution.ts` L602–L610, L651–L658, L660–L665; tests L172–L245 | | Refusal fails the step as a guard, no `fault` edge routes it | `screen-nodes.ts` L640–L661 (`refuseNode`); test L289–L301 | | A flow door (trigger, resume, `/actions`, a declared `type: 'flow'` endpoint) answers `400 FLOW_FAILED` with `error.details.innerRefusal` naming each holder; a `record_change` or scheduled run has no such caller | `screen-nodes.ts` L657–L659 (`code`, `refusalCarriedBy`); `packages/runtime/src/flow-dispatch-status.ts` L264–L269 (`flowFailureDetails`, the four doors); refusal text names every candidate `package-scoped-resolution.ts` L497–L520; dogfood `packages/qa/dogfood/test/bare-name-one-holder-request-family.dogfood.test.ts` L289–L300 (no-package flow `400 FLOW_FAILED` carrying `RESOURCE_CONFLICT`) | | `$error.code` is `RESOURCE_CONFLICT` in a `try_catch` | `screen-nodes.ts` L658; test L247–L287 | | Fix: declare the dependency (outside-closure), or rename (two holders) | `package-scoped-resolution.ts` L508–L510 (outside-closure text: "Declare a dependency on the package that holds it"); `packages/objectql/src/registry.ts` L2913–L2920 (boot warning: "Rename the item in one package") | | An unregistered name still fails with "no function named … is registered" (unchanged first sentence) | `screen-nodes.ts` L662–L669; test L344 | ## Round 2 (contract review 6783849220, PASS at `8f2225441`) - Should-fix 1: `400 FLOW_FAILED` is now scoped to a flow door, and `details` reads `error.details`, as `skills/objectstack-api/SKILL.md` L365–L367 spells it. The step's guard failure and `$error.code` hold on every run; a `record_change` flow's failure is logged while the write answers normally (`packages/triggers/trigger-record-change/src/record-change-trigger.ts`), and a scheduled run has no HTTP caller. - Nit 3: "Holding none itself" now reads "If the flow's package holds none". - Nit 2 stays as the accepted deviation (the parenthetical names the boot). - Growth +37 bytes, with no same-file restatement left to cut: the ratchet row and its comment move to the new measurement, 6861, under amendment 6782965220. ## Card vs main - **The boot still warns (correction from `main`, not on the card).** The card says two packages shipping one function each run their own. That holds, but a function name is still one per deployment under the phase-1 rule: `function` is not in `NAMESPACE_SCOPED_BARE_NAME_TYPES` (`packages/core/src/package-scoped-resolution.ts` L143–L147), and `BARE_NAME_COLD_BOOT_MODE` is `'warn'` (`packages/objectql/src/bare-name-one-holder.ts` L379). Two packages that both ship `normalize_phone` boot with one `Bare-name conflict at boot` warning naming both and a rename (`registry.ts` L2913–L2920; dogfood test L212–L226), and a further package binding the name after the boot is refused (`registry-bare-name-one-holder-request-family.test.ts` L555–L567). So the skill says "the boot warns". - An overlay is taught as reading package-less, which covers both forms on `main`: the shipping package's declared `.custom` override and an environment-authored body (`engine.ts` L5717–L5721). ## The cut and its surviving home The file had 2 bytes of headroom. Paid first, one true same-file restatement: item 3's `defineStack({ functions: { my_fn: (ctx) => … } })` registration shape (−18 B net). Its surviving home is the same item's `defineStack({ functions: { 'helpdesk.aiTriageStub': (ctx) => …, 'billing.sync': { handler, effect: 'writes' } } })` block, ~30 lines below, which the new "(below)" points at. No test or script quotes the cut text (`git grep "my_fn: (ctx)"` over `packages/` and `scripts/`: no hit). No other same-file restatement survived a home check (the hook `runAs` callout, the CEL callout, the prerequisite table and § Verify your work each have no other home). ## Ratchet reading `node scripts/check-skills-token-ratchet.mjs`, `skills/objectstack-automation/SKILL.md` (priced = `wc -c` − 20, the stamp line): | | Priced bytes | Tokens | Ceiling | |:--|:--|:--|:--| | `origin/main` `c7dd505de` | 26746 | 6687 | 6687 | | this PR | 27443 (+715 −18) | 6861 | 6861 | The remainder, +174 tokens, is raised under the standing ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068), on the seat's surface widening (claim amendment 6782965220), with a dated comment on the row naming the cut, its home and the `wc -c` arithmetic. Only that row moves. ## Sweep `skills/objectstack-automation/**` (SKILL.md, `references/*.md`, `evals/*.json`) for sentences the rule makes false or incomplete: - SKILL.md L97 (`script` row): "Call a **registered** function named by `config.function` (see … #3)". Still true; it points at the home. Unchanged. - SKILL.md item 3, first sentence: "an unregistered name fails loudly". Still true (the not-found arm is unchanged). Unchanged. - SKILL.md § Failure routing, "Does NOT route" table: does not list the new guard refusal. Not false (the table lists examples); the new paragraph says "no `fault` edge". Listed, not edited. - `references/*.md`: no script-node function mention (`state-machines-and-approvals.md` L45 is a `script` validation rule, another thing). - Other skills, not edited (outside the surface), none restates the rule: `objectstack-api/SKILL.md` L133 and its eval `endpoints-auth-routes.json` L27 ("a `script` node names a stack function", the endpoint's own package); `objectstack-data/references/_index.md` L23 (schema pointer); `objectstack-data/references/data-hooks.md` L873–L879 (a hook's string handler, which the hook binder resolves among its own package's functions only, a different rule). **Eval reading:** `evals/flows-triggers-approvals.json` case 5 is the only script-node case. It covers the config shape and purity (`function:`, `outputVariable`, a following `update_record`) for the author's own function, not resolution across packages. The new rule does not fit its shape, so no case is extended. ## Verification Head `1debed236`, base `c7dd505de`. Full `pnpm build` exit 0 first; gate list run under `NODE_OPTIONS=--max-old-space-size=8192`. - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 64 commands, each run with its exit captured before any pipe: **64 exit 0**. `--ran` reconciliation: 64 derived, 64 run, 0 NOT-MEASURED, 0 UNRUN. Record: `/mnt/project-files/card-32264/gates-1debed23.txt` (round 1 at `8f2225441`: the same 64, all exit 0, `gates-8f222544.txt`). - `origin/main` moved to `91d88ec13` during the run (`scripts/regen-artifacts.mjs` changed). The list re-derived on a local merge of this head into it is identical (64 commands), and main's commits since the base touch none of this PR's three files. - Also run, the artifact-roster families whose roster sits under `scripts/` or `.changeset/`: `check-published-list-mirrors`, `check:changeset-fixed`, `check:engine-double-contract`, `check:i18n-stale-fill`, `check:published-readme-exports`, `check:skill-top-level-keys`: all exit 0. - `node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD`: exit 0. Contract review: `dispatch-gates --tier` mandates `CONTRACT_REVIEW_TIER` for `skills/**` (clause ①). The maintainer's standing order (2026-11-03) waives that tier for card threads; the seat runs the contract review of record at that tier. Changeset: `.changeset/32264-automation-script-node-package-rule.md`, `'@objectstack/skills': patch`. Clause-②: no Metadata-protocol: none <!-- signed: domain:skills#3 · huangyiirene · session_01J8VVAmAzSRKZHAn7T8sArV --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3c18783 commit d48fb15

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the automation skill teaches that a `script` node's function resolves from the calling flow's package
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Silently-wrong item 3 of `skills/objectstack-automation/SKILL.md` now says how a `script` node's `config.function` is resolved since the node reads functions by package (ADR-0150 D3): from the calling flow's package, as `subflow`'s `flowName` is, with the platform's owner-less function in every flow's reach, and a `.custom` override reading as a package-less flow. Two packages that both ship `normalize_phone` each run their own (the boot still warns about the shared name). If the flow's package holds none, two holders in reach, or one only outside its `dependencies` closure, fail the step as a guard (`$error.code: 'RESOURCE_CONFLICT'` in a `try_catch`); a flow door (trigger, resume, `/actions`, a declared `type: 'flow'` endpoint) answers `400 FLOW_FAILED` with `error.details.innerRefusal` naming each holder. The fix is to declare the dependency, or rename.
11+
12+
Paid first by one same-file restatement: the item's `defineStack({ functions: { my_fn: (ctx) => … } })` example, whose shape the same item's `'helpdesk.aiTriageStub'` block still shows. The automation SKILL.md token-ratchet row rises by the measured remainder only, 6687 → 6861.

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,26 @@ export const CEILINGS = new Map([
584584
// bytes -> ceil(26746 / 4) = 6687; the ceiling moves +119, the measured
585585
// remainder only. Pinned AT the measurement.
586586
// ceil(($(wc -c < skills/objectstack-automation/SKILL.md) - 20) / 4) == ceil(26746 / 4)
587-
['skills/objectstack-automation/SKILL.md', 6687],
587+
// 6687 -> 6861 (2026-11-11, card #32264, the ADR-0150 D3 skills follow-up of
588+
// #32073): silently-wrong item 3 teaches how a `script` node's
589+
// `config.function` resolves from the calling flow's package (as `subflow`'s
590+
// `flowName` does), the platform's owner-less function in every flow's reach,
591+
// a `.custom` override read package-less, the two-package `normalize_phone`
592+
// example (the boot still warns), the guard refusal (`$error.code:
593+
// 'RESOURCE_CONFLICT'`; a flow door's `400 FLOW_FAILED` with
594+
// `error.details.innerRefusal`) and the two fixes. Raise path the standing ruling 「A:先削重复,余额按实测提高」 (ruling
595+
// record 6513306068, letter B; seat amendment 6782965220). PAID DOWN FIRST —
596+
// one restatement cut: item 3's `defineStack({ functions: { my_fn: (ctx) => … } })`
597+
// example, whose surviving home is the same item's
598+
// `defineStack({ functions: { 'helpdesk.aiTriageStub': … } })` block.
599+
// Arithmetic in priced bytes (stamp line excluded), against `main`'s 26746
600+
// (headroom 2): the paragraph adds 715, the cut removes 18, so the LANDED
601+
// priced text is 27443 bytes -> ceil(27443 / 4) = 6861; the ceiling moves
602+
// +174, the measured remainder only (contract review's should-fix scoped the
603+
// status to a flow door: +37 bytes, no further restatement left to cut).
604+
// Pinned AT the measurement.
605+
// ceil(($(wc -c < skills/objectstack-automation/SKILL.md) - 20) / 4) == ceil(27443 / 4)
606+
['skills/objectstack-automation/SKILL.md', 6861],
588607
// 13783 -> 13892 (2026-08-31 app-repo-principles raise, see the block above).
589608
// The invariant-vs-transition-gate choice, placed in the field-conditional-rule
590609
// bullet list where the tool is actually picked. Both wrong picks are silent:

‎skills/objectstack-automation/SKILL.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,18 @@ Legal metadata authors get wrong; most are caught by `objectstack build`:
252252

253253
3. **`script` nodes call a registered function — nothing else.** `config.function`
254254
(**required**: an empty node refuses at execute, an unregistered name fails
255-
loudly) names one registered via `defineStack({ functions: { my_fn: (ctx) => … } })`.
255+
loudly) names one registered in `defineStack({ functions })` (below).
256+
257+
**The name resolves from the flow's package, as `subflow`'s `flowName`
258+
does**, the platform's function (registered under no package) in every
259+
flow's reach; a `.custom` override reads as a package-less flow. `acme.crm`
260+
and `acme.sales` both shipping `normalize_phone` each run their own (the boot
261+
warns `Bare-name conflict at boot`). If the flow's package holds none, two
262+
holders in reach (the platform's counts) or one only outside its
263+
`dependencies` closure fail the step as a guard (no `fault` edge;
264+
`$error.code: 'RESOURCE_CONFLICT'` in a `try_catch`); a flow door answers
265+
`400 FLOW_FAILED`, `error.details.innerRefusal` naming each holder. Fix:
266+
declare the dependency, or rename.
256267

257268
**A flow `function` is a PURE compute step — it does NOT read/write the
258269
database.** It receives `ctx.input` and **returns** a value; `config.outputVariable`

0 commit comments

Comments
 (0)