You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0593356
Browse filesBrowse the repository at this point in the historyBrowse files
fix(objectql,runtime)!: a package-less action is kept on its own owner key, and a route serves the one on its key (#33821)
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — `skills/**` and `content/docs/**` already teach that
an action is keyed by its package, its object and its name, and that the
router reaches an action bound to the object before an object-less one;
no authored key, value or meaning changes.
## 维护者速读
- 改了什么:注册表为无包 action 按「归属对象」各留一格:平台绑定 `lead` 的 action 与环境的无对象 action
同名时两者都保留,不论注册先后;`/actions/lead/NAME` 读绑定 `lead` 的那条,其它路由读环境的无对象那条。
- 为什么改:action 的身份是(归属方、归属对象、名称),同名不同键是两条
action;路由判定所用的声明和派发执行的处理器必须来自同一条。
- 风险与回滚:只动 `action` 类型的无包槽位与 action 路由的选取,单条无包 action
的存储与读法不变(有对照测试);回滚即 revert 本 PR。
-
先看:`packages/objectql/src/registry.ts`(`keepPackagelessActionOwnerKeys`
与移除时的
`packagelessActionEntryToRetire`)、`packages/runtime/src/action-execution.ts`(`packagelessActionOnRouteBeside`)、`packages/runtime/src/action-package-addressing.test.ts`
末尾的新 describe。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/action-package-addressing.test.ts -t "own key"`,预期 12 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
Rule: an action is identified by `(owner, owning object, name)`
(ADR-0150 D4). The platform's package-less action bound to `lead` and
the environment's object-less action of the same name are two items
under two keys, never one contested name. Binding first, then owner:
`/actions/lead/NAME` serves the platform's item bound to `lead`; the
environment's object-less item serves every other route; ADR-0150 D3's
environment-first applies within one key, so the environment changes
`lead` by authoring `NAME` bound to `lead`. On every route the
declaration the gates judge and the handler the dispatch runs are one
item's.
- `packages/objectql/src/registry.ts`: a package-less action registered
over the bare slot keeps the slot's present item when its owner key is
another, in that key's own slot (`keepPackagelessActionOwnerKeys`). One
key keeps one item, the later registration; a stored row replaces the
name's stored row on any key (the environment's store holds one row of a
name). The bare-slot readers (`bareSlotEntriesOf`, `boundServedActions`)
see each key's item; the removal of a stored row retires that row, never
the platform's item of another key, and the next key's item takes the
bare slot. New `getEnvironmentScopedActions(name)`: the
environment-scoped action items of a name, one per owner key.
- `packages/objectql/src/action-package-addressing.ts`,
`package-scoped-resolver.ts`: the owner-key view
(`actionOwnerScopedRegistry`) reads the environment-scoped action on its
own key; `PackageScopedRegistry` gains the optional
`getEnvironmentScopedActions`.
- `packages/runtime/src/action-execution.ts`: the bare route takes the
package-less action on its own key, bound first, then object-less
(`packagelessActionOnRouteBeside`), where the by-name read answered
another key's; beside one package holder the platform's item alone on
the bound rung is served (`platformItemOnBoundRung`); the environment
address `/actions/_env/OBJECT/NAME` answers `404` where another
package-less action of the name is bound to `OBJECT`.
- Not changed: one package-less action of a name (stored and read as
before); beside two package holders elsewhere, `/actions/lead/NAME`
answers what the platform's `lead`-bound item alone answers there (no
declaration); the caller-package route; the stored-row (`sys_metadata`)
model.
## Tests
- `packages/objectql/src/action-package-addressing.test.ts`, new
top-level describe "the registry keeps one package-less action per owner
key": 6 cases (4 pins, 1 one-key pin that holds on main, 1 control).
- `packages/runtime/src/action-package-addressing.test.ts`, new
top-level describe "a route serves the package-less action on its own
key, and runs that item's handler": 12 cases — `lead` serves the
platform's item and runs its handler, and its `requiredPermissions` gate
`lead` (`403 PERMISSION_DENIED`), each in both registration orders
beside 0 and 1 package holders; the environment's object-less item
serves every other route in both orders beside 0, 1 and 2 holders (the
0-holder case a control); beside 2 holders `lead` answers no
declaration; the environment address; controls: one key keeps one item,
each package-less item alone.
## Acceptance notes
- Ablations, one per guard, each through `scripts/ablation-replace.mjs`
(anchor 1 to 0, blob changed), restored to the HEAD blob with `git diff
HEAD` empty:
- registry keep (objectql rebuilt; `ablation-dist-preflight` marker
absent from 8 built files, present in 4 after the restore build):
objectql 4 red / 2 green (the one-key pin and the control), runtime 8
red / 4 green (the controls and the one-key pin).
- the bare route's own-key pick: runtime 2 red (`lead`, 0 holders), 10
green.
- the bound-rung platform pick: runtime 2 red (`lead`, 1 holder), 10
green.
- the environment address: runtime 1 red, 11 green.
- Two existing pins on the two-holder route (`[#32751]`, and `case 2` of
`[#32365]`) keep their answers; the change is scoped so they hold.
- Overlap: PR #33621 edited `packages/objectql/src/registry.ts` in the
object-extension follow area; it has merged and this branch carries it;
no hunk is shared. None of the 55 open pull requests read before the
open touches the seven files of this diff.
## Verification
All readings on head `8f2c22d91d` (after merging `origin/main`) unless
named.
<details><summary>Package suites and typechecks</summary>
```text
@objectstack/objectql test Test Files 596 passed (596) · Tests 13142 passed (13142)
@objectstack/runtime test Test Files 603 passed (603) · Tests 10918 passed | 19 skipped (10937)
objectql + runtime typecheck tsc --noEmit clean · check:test-typecheck OK for both
@objectstack/spec check:generated All 14 generated artifacts are up to date
before the merge (1f51a01) objectql 596/596 · 13116 passed; runtime 603/603 · 10886 passed | 19 skipped
```
</details>
<details><summary>Derived gate families (dispatch-gates --commands,
reconciled with --ran)</summary>
```text
head 8f2c22d · 73 derived, 72 exit 0, 1 NOT MEASURED
NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: exit 3 PREREQUISITE NOT MET (reads every package's dist/; this tree built the runtime closure only); CI's Lint & Repo Gates run measures it
dispatch-gates --ran: 73 derived famil(ies) accounted for — 72 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)
```
</details>
<details><summary>Dogfood battery</summary>
```text
8f2c22d · os-verify-lock VERDICT command-exit 0
pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test
Test Files 467 passed | 3 skipped (470)
Tests 3958 passed | 42 skipped (4000)
no failures
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_
<!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(objectql,runtime)!: a package-less action is kept on its own owner key, and a route serves the one on its key, so the declaration it judges and the handler it runs are one item's (ADR-0150 D4)
7
+
8
+
Clause-②: no (narrowing) — `/actions/OBJECT/NAME` answers with the declaration of the package-less action bound to `OBJECT` (its `requiredPermissions` and every other gate) wherever the platform binds `NAME` to `OBJECT` beside the environment's object-less `NAME`, in either registration order; a caller those requirements refuse is refused `403 PERMISSION_DENIED`. Widened beside it: the environment's object-less `NAME` answers every other route in both registration orders, where one order answered no declaration there. No export is removed; `SchemaRegistry.getEnvironmentScopedActions` is added.
9
+
Metadata-protocol: none
10
+
Skills-docs: none — `skills/**` and `content/docs/**` already teach that an action is keyed by its package, its object and its name, and that the router reaches an action bound to the object before an object-less one; no authored key, value or meaning changes.
11
+
12
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any authorable schema is added, removed, renamed or re-shaped and no stored row changes: what moves is which of two registered items a route reads, so there is nothing for `objectstack migrate meta` to rewrite. -->
13
+
14
+
**The rule.** An action is identified by `(owner, owning object, name)` (ADR-0150 D4). The platform's package-less action bound to `lead` and the environment's object-less action of the same name are two items under two keys, never one contested name:
15
+
16
+
- The metadata registry keeps both, in either registration order. One owner key keeps one item: the later registration of that key stays, as before. A stored row saved again bound to another object replaces the name's stored row, since the environment's store holds one row of a name.
17
+
- Binding first, then owner: `/actions/lead/NAME` serves the platform's item bound to `lead`, and the environment's object-less item serves every other route. ADR-0150 D3's environment-first applies within one key: to change `lead`, the environment authors `NAME` bound to `lead`.
18
+
- On every route, the declaration the gates judge and the handler the dispatch runs are one item's.
19
+
20
+
`@objectstack/objectql`: `SchemaRegistry` keeps a package-less action of another owner key than the bare slot's in that key's own slot; `getEnvironmentScopedActions(name)` lists the environment-scoped action items of a name, one per owner key, and the owner-key view of the package resolver (`actionOwnerScopedRegistry`) reads the item on its own key. The removal of a stored row retires that row, never the platform's item of another key. `@objectstack/runtime`: the action route reads the package-less action on its own key.
21
+
22
+
**BREAKING** — who moves: a caller of `/actions/OBJECT/NAME` on a deployment where host code or a plugin registers a package-less `NAME` bound to `OBJECT` and the environment stores an object-less `NAME`. That route now always answers with the platform item's declaration, so a caller must hold that item's `requiredPermissions`. No first-party composition registers such a pair, so no answer changes in this repository.
23
+
24
+
The fix, for an environment that meant its object-less `NAME` to answer `OBJECT` too:
25
+
26
+
- FROM an object-less `NAME` expected to answer `/actions/OBJECT/NAME` beside the platform's `NAME` bound to `OBJECT`, TO the environment's `NAME` saved bound to `OBJECT` (`objectName: 'OBJECT'`), which answers that route as the environment's own item. The environment stores one row of a name, so that row then answers `OBJECT` alone; an environment action meant for every other route as well takes a second name.
0 commit comments