Repository navigation
Commit 4890cd0
fix(objectql): platformSystemApi on the api ObjectRepository.execute hands the dispatched action keeps the 'action' mark (#35733)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao6bxiPKCvVuzoFTExumbxoz)_
Fixes #35434
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:用户无感;宿主代码里一个动作再去调用另一个动作时,被调用的动作若把自己拿到的接口交给「平台自用系统接口」函数,拿回的接口仍带动作标记,改成员、岗位、权限集分配、邀请会像权限文档写的那样被拒。
- 为什么做:补上上一轮「动作处理器保留动作标记」修复在文档里注明「不覆盖」的那条路,让权限文档对动作的承诺在动作链式调用时也成立。
-
出错会怎样:最坏是某个宿主动作经动作链调用、再经此函数写身份分配对象时被拒;仓库里目前没有这样的调用方,审计写入路径不变,回滚本次合并即可撤回。
- 要你做什么:无。
## What changes
Route B of the card (an origin flag set by `execute` and copied by
`derive`, held in a facet module, never in `engine.ts`).
- `packages/objectql/src/engine-object-repository.ts`: a module-local
`WeakSet` keyed by `ScopedContext` instance, the dispatched action's
origin flag, with `markDispatchedActionApi` / `isDispatchedActionApi`.
`ObjectRepositoryFacet.execute` flags the api it hands the dispatched
action. Neither helper is re-exported from either package entry.
- `packages/objectql/src/engine-scoped-context.ts`: `derive` copies the
flag to the child (so `sudo()`, `withRunAs(...)`, a transaction's
context, the seeds' and `platformSystemApi`'s results keep it);
`platformSystemApi`'s facet body answers a flagged api with that api's
own `sudo()`, as it already does for an app-authored api. Mark and
`flowRunId` are kept.
- `packages/objectql/src/platform-system-api.ts` header and row 1b of
`content/docs/permissions/system-context.mdx`: the "not covered" clause
is dropped, nothing else in that prose.
- `engine.ts` is not touched, so the `check:facade-delegation-only`
ceiling (ruling 6897467376) is unchanged. No published signature
changes: `ObjectRepository`'s constructor is exported from both entries,
so route A (threading the calling api into it) would have changed a
published signature; it would also not have kept the mark on the reach
path, because runtime's action-door layer passes repositories through
unchanged and objectql only ever sees the inner `ScopedContext`, which
carries neither flag.
- The flag is not the app-authored flag: the dispatched handler's
permanent delete (ADR-0148 D3) still runs. The audit writer's hook api
(`buildHookApi`, a fresh `ScopedContext`, never derived from a flagged
api) is unchanged: `platformSystemApi` still takes the mark off there.
## Tests
New
`packages/runtime/src/execute-dispatched-action-platform-system-api-35434.integration.test.ts`
(real `ObjectQL`, SQL driver, real `SecurityPlugin`):
- dispatched from the action door's api (`buildActionApi`, an action
handler chaining another) and from a bare engine api: an insert into
each of the four identity-assignment objects through
`platformSystemApi(ctx.api)`, `platformSystemApi(ctx.api.sudo())` and
`platformSystemApi(trx)` is refused `PERMISSION_DENIED` / 403 naming an
action body, and nothing lands; the handler's own `sudo()` as a control;
- its insert into an ordinary object is owner-stamped with the caller;
- CONTROL: a hook registered in code, fired by the dispatched handler's
write, still takes the mark off and its platform write lands;
- CONTROL: the dispatched handler's permanent delete still runs.
<details><summary>Red before the fix, green after, two
ablations</summary>
- Before the fix (head a7af719): `Tests 9 failed | 2 passed (11)`, each
failure `insert on OBJECT through direct was not refused` (OBJECT per
case) and the owner stamp `owner_id: null`. Premise held.
- After (head 532c6f3, merged with main): `Test Files 2 passed (2) ·
Tests 21 passed (21)` (this file plus
`action-door-platform-system-api.integration.test.ts`).
- Ablation 1, `execute` stops flagging (`api: new
ScopedContext(executionContext, this.engine),`): `ablation-replace`
landed (anchor 1 -> 0), objectql rebuilt, `ablation-dist-preflight`
marker present in 4 built files; `Tests 9 failed | 2 passed (11)`.
Restore: blob == HEAD, `git diff HEAD` empty, rebuilt, `--absent` clean,
`Tests 11 passed (11)`.
- Ablation 2, `derive` stops copying the flag: landed, present in 4
built files; `Tests 8 failed | 3 passed (11)` (the `sudo()` and
transaction routes red, the direct route and controls green). Restore:
blob == HEAD, `--absent` clean, `Tests 11 passed (11)`.
</details>
<details><summary>Package suites</summary>
- `pnpm --filter @objectstack/objectql test` at 532c6f3: `Test Files
616 passed (616) · Tests 13907 passed (13907)`.
- `pnpm --filter @objectstack/objectql typecheck` and `pnpm --filter
@objectstack/runtime typecheck`: exit 0; `check:test-typecheck: OK` on
both.
</details>
## Acceptance notes
- The claim's file surface lists `engine-scoped-context.ts` "only if
route A needs it". Route B needs it too: `derive` and the
`platformSystemApi` facet body live there. #35541, the open PR that
touched it at claim time, has since merged; `overlap-check` answered
clean.
- The pending changeset
`.changeset/35174-action-api-platform-system-api-mark.md` (unreleased)
said the `execute` path is not covered. It is edited here as a seat
amendment (its "Not covered" bullet is dropped); see DELIBERATE
CORRECTION below.
- The two enumerations kept in the header ("two of the apis") and in row
1b name the app-authored hook api and the action door's api; per the
card's fence only the "not covered" clause was dropped, and the third
api is documented at the flag (`engine-object-repository.ts`).
## Verification
Read first, by risk: `packages/objectql/src/engine-scoped-context.ts`
(`derive`, `platformSystemApi`), then `engine-object-repository.ts`
(`execute`).
Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run
--maxWorkers=2
src/execute-dispatched-action-platform-system-api-35434.integration.test.ts`
after building objectql, expect `Tests 11 passed (11)`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7)_
## DELIBERATE CORRECTION
DELIBERATE CORRECTION:
`.changeset/35174-action-api-platform-system-api-mark.md` (pending, from
#35174 / PR #35383) drops one bullet, which this PR makes false:
> - Not covered: the api `ctx.api.object(o).execute(name)` hands the
action it dispatches is built by the engine, not the action door, so
`platformSystemApi` still takes the mark off there.
After: the bullet is removed; no other sentence of that note changed.
This PR closes that path. The `check-empty-changeset` red is by design
for this class; the seat confirms the correction by its same-head
at-tier contract-review record (landing-operations.md), not by a
maintainer wait.
<!-- signed: repo:objectstack#7 · os-tesla ·
session_01L9qibwJEh7hMPPvagWM1g7 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 509289c commit 4890cd0
7 files changed
Lines changed: 292 additions & 18 deletions
File tree
- .changeset
- content/docs/permissions
- packages
- objectql/src
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 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 | + | |
38 | 67 | | |
39 | 68 | | |
40 | 69 | | |
| |||
134 | 163 | | |
135 | 164 | | |
136 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
137 | 169 | | |
138 | 170 | | |
139 | 171 | | |
| |||
144 | 176 | | |
145 | 177 | | |
146 | 178 | | |
147 | | - | |
| 179 | + | |
148 | 180 | | |
149 | 181 | | |
150 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
85 | | - | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
127 | | - | |
128 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
129 | 134 | | |
130 | | - | |
131 | | - | |
| 135 | + | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
0 commit comments