Repository navigation
Commit badf24d
fix(core): count and hand over the injected owner_id in a banned user's assigned work (#30677)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DKzfSXJ79oXBZ9JNgjMFa6R)_
Fixes #30646
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:封禁用户时「他手上有多少记录」的计数和「批量转交」现在会算上平台给每个业务对象注入的负责人字段
`owner_id`;`created_by` / `updated_by` 仍不计、不转。
- 为什么改:原逻辑跳过所有 `system: true` 的字段,而注入的 `owner_id` 正是 `system:
true`(但不是只读),导致绝大多数对象上「拥有」恒为 0、转交也不移交负责人。
- 风险与回滚:只改字段筛选一行,排除依据从「system 或
readonly」改为「readonly」;访问控制不变(计数和转交仍以调用者身份读写)。回滚即 revert 本 PR。
- 先看:`packages/core/src/security/user-assigned-work.ts` 第 102
行附近的筛选条件;其次 `user-assigned-work.test.ts` 的 fixture(改用真实的
`OWNER_FIELD_DEF` / `AUDIT_FIELD_DEFS`)。
- 两分钟验证:`pnpm --filter @objectstack/core exec vitest run --project local
src/security/user-assigned-work.test.ts`,预期 12 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
`userAssignedWorkFields` (the field picker both the count and the
hand-over read) skipped any user reference with `readonly: true` OR
`system: true`. The platform's injected `owner_id` (`OWNER_FIELD_DEF` in
`packages/spec/src/data/injected-system-column-provenance.ts`) is
`system: true`, `readonly: false`, so on every object that did not
declare `owner_id` itself, owned records were neither counted nor handed
over. The picker now excludes by `readonly` only. The audit lookups
`created_by` / `updated_by` are `readonly: true` both as injected
(`AUDIT_FIELD_DEFS`) and when an author declares them
(`applyAuditFieldGovernance` forces `readonly` / `system` over a
declared audit field), so they stay out. `sys_*` objects, `managedBy`
objects and unprovisioned injected columns are excluded exactly as
before. The module header now says why `system` alone does not exclude a
field.
A repo grep for user references (`reference: 'sys_user'`) carrying
`system: true` finds only the injected owner and the two audit lookups,
so no other field changes classification.
Access control is untouched: every count, read and write still runs
under the caller's own context.
## Tests
- The test fixture now builds `owner_id`, `created_by` and `updated_by`
from the real `OWNER_FIELD_DEF` / `AUDIT_FIELD_DEFS`, so the existing
count and hand-over cases pin the injected owner; the seed row also
holds the banned user in `created_by` / `updated_by`, and the hand-over
case asserts those stay unchanged.
- New case: an object carrying only `OWNER_FIELD_DEF` plus the four
audit columns yields exactly `owner_id`, and the case asserts the
premise (`system: true`, `readonly: false`).
Ablation (head `90919afc`, fix committed first, mutation via
`scripts/ablation-replace.mjs`, restore proven by blob == HEAD and empty
`git diff HEAD`):
- Put the `system === true` skip back: `Tests 9 failed | 3 passed (12)`;
the new pin fails with `expected [] to deeply equal [ { object: 'deal',
… } ]`, and the count and hand-over cases fail.
- Control leg, delete the `readonly` skip instead (nothing excluded by
field flags): `Tests 5 failed | 7 passed (12)`; the new pin and the
count and hand-over cases fail because `created_by` / `updated_by` get
picked.
## Acceptance notes
- None beyond the card's scope.
## Verification
All on head `90919afc`.
- `pnpm --filter @objectstack/core test`: Test Files 136 passed, Tests
3087 passed (exit 0).
- `pnpm --filter @objectstack/core typecheck`: exit 0.
- `pnpm lint`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands`: 60 families derived;
`--ran` reconciliation: 59 run with exit 0, 1 NOT MEASURED (`pnpm
check:dual-build-cjs-loads`, PREREQUISITE NOT MET: needs a full `pnpm
build`; CI's `Lint & Repo Gates` runs it).
`check-plugin-teardown-shape.mjs --self-test` and
`check:lean-entry-closure` first exited 3 on prerequisites, then exited
0 after fetching the pinned fixture commit and building
`@objectstack/objectql`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cytLmJxfAmgPVjUbbW
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9d5ec25 commit badf24d
3 files changed
Lines changed: 36 additions & 9 deletions
File tree
- .changeset
- packages/core/src/security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | | - | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
40 | 53 | | |
41 | 54 | | |
42 | 55 | | |
| |||
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
101 | | - | |
| 114 | + | |
102 | 115 | | |
103 | 116 | | |
104 | 117 | | |
| |||
157 | 170 | | |
158 | 171 | | |
159 | 172 | | |
160 | | - | |
| 173 | + | |
161 | 174 | | |
| 175 | + | |
162 | 176 | | |
163 | 177 | | |
164 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | | - | |
102 | | - | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
0 commit comments