Repository navigation
Commit d48fb15
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
- .changeset
- scripts
- skills/objectstack-automation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
588 | 607 | | |
589 | 608 | | |
590 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
256 | 267 | | |
257 | 268 | | |
258 | 269 | | |
| |||
0 commit comments