Repository navigation
Commit a752057
fix(runtime)!: an action authored in the environment on a packaged object is the environment's, so MCP list_actions lists it once and its face runs (#33071)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DSjp6ipSHAQH44qGrSqV3mJ)_
Fixes #33029
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — the docs already state the rule this change makes
true: `content/docs/api/client-sdk.mdx` (Addressing an item by its
package) says a namespace names the holding package and `'_env'` names
an item authored in the environment, which no package holds; no skill
teaches calling an environment action under a package's namespace.
## 维护者速读
- **改了什么**:管理员在环境里(不带 `?package=`)给某个包自带的对象写的动作,现在算「环境自己的动作」。AI
助手(MCP)的动作列表只列它一次、不挂包的命名空间,按列表给的名字(`对象-动作`)就能运行。
- **为什么改**:之前同一个动作被列两次,其中一次错挂在 showcase 包名下;列表给的运行名被判「两个动作共用」而拒绝,AI
按列表去运行会 404。
- **风险与回滚**:三处收窄(席位已按方向 A 裁定):① ② 用「那个包的命名空间」去点名这个环境动作,MCP 和 REST
带命名空间的地址现在回 404,以前能跑,改用列表名、裸名或 `/actions/_env/...` 即可;③
这种环境动作如果是流程动作、目标流程名又被两个包同时持有,现在回 409 并列出两个包,以前默认跑对象所在包的那个流程,改法是用
`?package=`
把动作绑到一个可写包(该包自己的流程,或它唯一依赖的那个包的流程就是想要的那个),或换一个只有一个包持有的流程名。回滚就是 revert 这个
PR,运行时只改一个文件。
- **先看**:`packages/runtime/src/action-execution.ts` 的
`embeddedActionPackageOf`(新函数,6 行)及它在
`collectActionDeclarations`、`actionDeclaringPackage` 的两处调用;再看
`packages/qa/dogfood/test/mcp-list-actions-environment-authored-holder.dogfood.test.ts`
的收窄钉子(两个 404、一个 409)。
- **两分钟验证**:`pnpm --filter @objectstack/dogfood exec vitest run
test/mcp-list-actions-environment-authored-holder.dogfood.test.ts`,预期 8
条全过;「naming `showcase` … answer 404」和「… refused 409 naming both」两条就是收窄面。
- **需要你做的**:确认这处收窄可以随下一个版本发出(带 BREAKING 说明),然后由席位落地。
## What changes
The protocol's merged listings, which the MCP bridge reads, serve an
action an administrator saved with no `?package=` twice: once in the
`action` listing, with no package, and once inside the served object's
`actions` in the `object` listing, where the registry attaches it
(`attachBoundActions`, #28356) by reference, unstamped and
tenant-authored (`_provenance: 'org'`). `collectActionDeclarations`
filed every unstamped embedded action under the object's package, so the
ADR-0150 D4 dedupe, keyed on the holder, kept both copies.
`embeddedActionPackageOf` (new,
`packages/runtime/src/action-execution.ts`) is the one rule for an
embedded action's holder: its own stamp; else, when it is
tenant-authored (`isTenantAuthored`, `@objectstack/metadata-core`, the
registry's own test), no package; else the object's. The collector and
`actionDeclaringPackage` both read it.
Narrowing, measured and ruled by the seat (direction A, the holder fixed
in resolution, not a list-only dedupe), in three places:
1. MCP `run_action` with `namespace` set to the object's package answers
`RESOURCE_NOT_FOUND` (404) for such an action. It ran it before, because
the embedded copy was filed under that package.
2. `POST /actions/NAMESPACE/OBJECT/NAME` with that namespace answers the
same 404.
3. (Contract review 6847350544, M1.) A flow action of that kind whose
`target` flow name two packages hold answers `RESOURCE_CONFLICT` (409)
naming both, on its face, its bare name and `_env`. The action has no
package (ADR-0150 D3), so `actionDeclaringPackage` gives the flow arm no
caller package and the target is read by the no-package rule. Before, it
ran the object's package's flow. The caller's fix: bind the action with
`?package=` to a writable package whose own flow, or whose one
dependency's flow, is meant, or target a flow name one package holds.
`list_actions` lists that row without `params`, and `resume_run` no
longer admits it for a paused run of either package's flow, by the same
reading.
A flow target ONE package holds is unchanged (pinned). The changeset
carries the BREAKING banner, the FROM → TO for all three, and the
ADR-0087 disposition.
## Tests
`packages/qa/dogfood/test/mcp-list-actions-environment-authored-holder.dogfood.test.ts`
(new, isolated): the stock showcase with `MCPServerPlugin`, an admin
session, the live MCP transport and the REST actions door.
- The card's shape: one row, no namespace, face
`showcase_task-qa_env_authored_action`, no refused face; `run_action`
runs it by that face.
- The narrowing: `namespace: 'showcase'` on MCP and
`/actions/showcase/...` on REST answer 404.
- CONTROL: the bare name and `/actions/_env/...` still run it.
- CONTROL: an environment-authored flow action whose `target` names a
showcase-shipped flow (`showcase_recalc_task_estimate`, one holder) by
bare name runs on REST and MCP, before and after (measured by the
ablation below: at base it failed only at the listing assertion, after
both runs passed).
- The third narrowing: the derived showcase also ships `qa_shared_flow`,
and a second code package (`com.example.qatwin`, namespace `qatwin`,
booted with `AppPlugin`) ships the same name. An environment-authored
flow action targeting it is refused 409 `RESOURCE_CONFLICT` naming both
packages on the bare REST route, `/actions/_env/...` and the MCP face.
(A Studio-created package cannot author that twin: the metadata door
seals a name a managed package holds, 403.)
- CONTROL: a package-shipped action on the same object
(`showcase_mark_done`, made AI-exposed in a derived configuration) lists
once under `showcase` and runs by its face.
- CONTROL: an action authored with `?package=` (a Studio-created package
that depends on the showcase) lists once under its namespace and runs by
it.
## Acceptance notes
- Measured how each kind arrives (reading before the fix, stock showcase
at 64c426a): the package-shipped action arrives embedded unstamped and
standalone stamped `com.example.showcase`; the `?package=` action
arrives stamped with its package in both places; the environment's
action arrives standalone with no package and embedded unstamped with
`_provenance: 'org'`. Nothing is dropped: the embedded copy of every
kind is still collected.
- `?package=com.example.showcase` is refused 422
(`WRITABLE_PACKAGE_REQUIRED`, the package is read-only), so the
`?package=` control uses a Studio-created package.
- Not measured: an action an administrator writes INLINE in an overlay
of a packaged object's body (`PUT /meta/object/...` with `actions`).
Such an action carries no per-action provenance, so it is still filed
under the object's package. Noted, not filed.
- `packagelessOriginOf` classes the surviving embedded row by the
store's `embedded` set (actions of package-less OBJECT rows), so beside
another holder it reads as the platform's; on an object-bound key the
first declaration still answers, so nothing moves today (contract review
nit). Left as is: no answer depends on it.
- The `#32437` one-row-per-bound-object pin
(`packages/mcp/src/mcp-action-tools.test.ts`) stays green: 25/25.
## Verification
Package tests, lint and the full dogfood run read head `a5bdc1d4`
(origin/main `64c426ab` merged). Head `dc67e074` adds the third
narrowing's pin, two docblocks and the changeset text, and changes no
executed runtime line. Head `c4c1aa31` changes text only (the caller's
fix for the third narrowing, delta review S2). On it: the new dogfood
file 8/8, both ablations above, and the derived gates re-run.
<details><summary>Package tests and typecheck</summary>
- `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2`:
Test Files 600 passed (600), Tests 11916 passed, 19 skipped. Lock
verdict `command-exit 0`.
- `pnpm --filter @objectstack/runtime typecheck`: exit 0.
- `pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2
src/mcp-action-tools.test.ts` (the #32437 pins): 25 passed.
- The new dogfood file: 8 passed at `dc67e074`.
</details>
<details><summary>Ablations (two, each committed first, each rebuilt and
proven in dist)</summary>
Each leg: `scripts/ablation-replace.mjs` (anchor hit, blob moved), `pnpm
--filter @objectstack/runtime build`, `ablation-dist-preflight.mjs`
found the marker in `dist/index.js` and `dist/index.cjs`; restored to
HEAD (`git diff HEAD` empty), rebuilt, `--absent` preflight clean.
1. The whole rule (`embeddedActionPackageOf` back to the object's
package, marker `ABLATE_33029`, head `dc67e074`): 5 failed, 3 passed.
Red: the one-row listing, the face run, the two 404s, the one-holder
flow control (at its listing assertion, after both of its runs passed,
so that target runs at base too), and the two-holder 409. Green, as
controls should be: the bare and `_env` runs, the package-shipped
action, the `?package=` action.
2. The `actionDeclaringPackage` hunk ALONE (its call back to the
object's package, collector fix kept, marker `ABLATE_ADP_33029`): 1
failed, 7 passed. Red: the two-holder 409 pin; the bare REST route
answered 200 running `showcase shared flow`, the object's package's
flow, which is the BASE behaviour of the third narrowing.
</details>
<details><summary>Derived gates and lint</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` at `dc67e074`: 70
families, all run with exit codes recorded; `--ran` reconciliation: 68
run, 2 NOT MEASURED (exit 3, prerequisite): `check-plugin-teardown-shape
--self-test` (needs an unshallow clone) and `check:dual-build-cjs-loads`
(needs a whole-tree build). CI runs both. (At `a5bdc1d4`: 67 run,
`check:type-check-debt` also exit 3 then, waiting on the verify lock;
exit 0 now.)
- `check-adr-0087-registration --base origin/main`: exit 0.
`check-changeset-no-major --base origin/main`: exit 0.
- `pnpm lint`: exit 0.
</details>
<details><summary>Full dogfood (owed by the narrowing arm)</summary>
`pnpm --filter @objectstack/dogfood test` at head `a5bdc1d4`, under the
verify lock: Test Files 459 passed, 3 skipped (462); Tests 3851 passed,
42 skipped (3893); lock verdict `command-exit 0`. Not re-run at
`dc67e074`, whose runtime change is docblocks only.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4czLj1eeZBYHELaRH6v)_
<!-- signed: domain:server#8 · os-elon-musk ·
session_016WV4czLj1eeZBYHELaRH6v -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 181ad7d commit a752057
3 files changed
Lines changed: 279 additions & 6 deletions
File tree
- .changeset
- packages
- qa/dogfood/test
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
0 commit comments