Repository navigation
Commit 2c96e0d
docs(skills): renaming a position tells the author to re-point their own source, names the environment owner, and restores the explain gate (#34105)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9RTAWwDs8gd2Z3ErxN5LrxK)_
Fixes #33566
domain:skills#2 · os-steve · session_01ADHkmTSWHtysbqqYGcsTP1
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`objectstack-data` 技能 security 规则里「Renaming a
position(岗位改名)」一段补三处:作者要自己改掉包源码里仍写旧岗位名的地方(共享规则接收方、审批人、队列成员、策略
`positions`、`current_user.positions` 谓词);「被另一方记录」的拒绝条件把环境(Setup
创建,`sys_metadata`)也列为所有者;明说改名搬运只改写持有人行,其他引用旧名的地方一概不改写(含 Setup 里写的)。同时把
PR #33480 删掉的运维规则补回:用 explain 查看别人的权限需要
`manage_users`、该用户所在组织的管理员身份,或覆盖该用户的委派 `adminScope`。另追加一条评测用例。
-
为什么改:原文只说「启动日志为管理员列出其他引用」,读起来像作者什么都不用做;实际上搬运从不改写包里的共享规则、审批槽位等,作者不改源码,新版本上线后这些引用仍指向已不存在的旧名。
- 风险与回滚:只动已发布技能文字、评测夹具、changeset 和 token 上限行,不动运行时与契约;先就地删重复付账,余额按实测抬棚(本
PR 净增 108 字节;与 #34019 合并后 16164 → 16272 字节,上限 4041 → 4068 token,零余量)。回滚即
revert 本 PR。
- 先看:① `skills/objectstack-data/rules/security.md` 末尾「Renaming a
position」段(新增句是否与 `position-renamed-holder-carry.ts` 一致);② 同文件 §
Assigning a permission set 的 explain 句;③ 本文件的删减处与
`scripts/check-skills-token-ratchet.mjs` 的 security.md 行。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期
`skills/objectstack-data/rules/security.md is 4068 tokens (ceiling 4068;
headroom 0)` 且以 ✓ 收尾。
- 需要你做的:落地档 Tier H,需 GOVERNED_APPROVERS 审批;复审 6899620269 的 FAIL 已由 delta
6900037119 关闭,#34019 合入后的串行返工(head 464f620)增量复审由席位交 review#2。
## What changes
`skills/objectstack-data/rules/security.md`, the **Renaming a position**
paragraph now reads:
> **Renaming a position:** declare `renamedFrom: ['old_name']` on the
renamed position, never delete and re-add (holders lose its sets). At
boot its holders (`sys_user_position`) move to the new name in every
organization, idempotently. Only holders: no other reference to the old
name is rewritten, Setup-authored ones included. Re-point your own
source naming the old one: a `type: 'position'` sharing recipient, queue
member or approver, a policy's `positions`, a `current_user.positions`
predicate. The boot log lists stored references by table (sharing, queue
and share recipients, pending approvers, invitations) for an admin. Not
carried (warned): an old name still a position anywhere, claimed twice,
recorded under another owner (a package or the environment), switched
off, or a disabled claimant.
Card items, each re-checked against main `63db7240` first; none was
already said, so all four were written:
1. The author re-points their own package source. Beyond the card's
three examples (sharing recipient, approval `position:NAME` slot, RLS
over `positions`), the sentence also names a queue member and a
`current_user.positions` predicate, both real authoring sites
(`skills/objectstack-data/SKILL.md` § Ownership queues `members`; the
placeholder table in the same file).
2. "recorded under another package" → "recorded under another owner (a
package or the environment)".
3. "no other reference to the old name is rewritten, Setup-authored ones
included" (the card's premise said Setup-authored bodies are carried;
the code rewrites none of them). The carry does READ every position's
`renamedFrom`, environment positions included, so the sentence says what
is not rewritten, not what is not read (review 6899620269 M-1).
4. § Assigning a permission set to a user, after "`GET
/api/v1/security/explain?object=&operation=&userId=` answers from the
enforcing code path.": "Explaining another user takes `manage_users`,
administering one of their organizations, or a delegated `adminScope`
covering them." PR #33480 had cut "(explaining another user needs
`manage_users`)"; the restored rule states the whole gate the code runs,
not only `manage_users`.
`skills/objectstack-data/evals/hooks-security-seeds-datasources.json`:
one appended case, id 22 (#34019 holds id 21; a package renames
`sales_rep` → `crm_sales_rep` while its own sharing rule names
`sales_rep`; the answer declares `renamedFrom` and re-points the rule in
source).
`.changeset/33566-skills-position-rename-own-source.md`:
`@objectstack/skills` patch.
`scripts/check-skills-token-ratchet.mjs`: the `rules/security.md` row
4041 → 4068 (+27, on top of #34019's 3959 → 4041, whose comment is
kept), pinned at the measurement, comment `ceil(16272 / 4)`. Standing
ruling 「A:先削重复,余额按实测提高」: the cuts below were paid first (313 bytes), the
measured remainder raises the row.
The `tabPermissions` pointer is kept, shortened (103 → 94 bytes):
"`tabPermissions` hides an app, never gates it: objectstack-ui → Who
sees or opens an app." (dev open question answered B, restored: seat
ruling, review S-1).
Cuts, each with its surviving home:
| Cut (bytes) | Surviving home |
|:--|:--|
| `tabPermissions` pointer shortened (−9) | the same pointer, shorter;
the rule's home stays `skills/objectstack-ui/rules/navigation.md` § Who
sees or opens an app |
| Kernel-name list in the membership-keys bullet → "a fixed placeholder
above, `accessible_org_ids`" | the placeholder table in the same file
(`id`, `email`, `organization_id`, `org_user_ids`, `positions`,
`queues`); `accessible_org_ids` kept by name as it is not in the table |
| Membership-tier closed list (−73) | the docs anchor kept in the same
sentence (`#membership-tiers-are-a-closed-list`) |
| Second definition of `outside-closure` / `ambiguous-in-closure` in the
positions bullet → "as for a queue above" (−44) | the queue bullet in
the same section; the Setup-authored-set and install-refusal clauses are
kept |
| ", or refused below" (−19) | the next bullet: "the position grants
nothing through that name" |
| "Assignment is one `POST …`." merged into the next sentence (−28) |
the same sentence still names the POST path |
| "Declare the set on the **roster** object, not one policy per record."
(−70) | the section heading ("a `current_user.KEY` set the roster object
declares") and the "Choose by what the rows are keyed on" bullet |
| `// in a permission set` code comment (−23) | the RLS paragraph above
it ("policies on a **permission set / profile**") |
Authoring tier: `dispatch-gates --tier` answers MANDATORY
CONTRACT_REVIEW_TIER for `skills/**` (clause ①). The card thread is
served below that tier, so this diff was authored by an isolated os-dev
subagent pinned to CONTRACT_REVIEW_TIER on the same branch, as the card
delta orders, in both rounds (the fix round followed the seat's order on
review 6899620269); the thread merged main, ran the gates and the relay.
## Tests
No package source changes, so there is no package test to run. The eval
case is a fixture (measured, not ratcheted) and is self-consistent: both
`must_contain` strings (`renamedFrom: ['sales_rep']`, `value:
'crm_sales_rep'`) appear in its `expected_output`. `must_not_contain` is
empty: the earlier `value: 'sales_rep'` occurs in the prompt, so a
correct before/after answer would have failed (review S-2), and no
string only a wrong answer writes was found.
<details><summary>Size readings, before (merge base
<code>b8456ebd</code>) and after (<code>464f620f</code>)</summary>
| Reading | before | after |
|:--|:--|:--|
| `rules/security.md` lines / bytes | 334 / 16164 | 334 / 16272 |
| same file, priced tokens / ceiling | 4041 / 4041 | 4068 / 4068 |
| `evals/hooks-security-seeds-datasources.json` lines / bytes / tokens
(not ratcheted) | 215 / 19036 / 4759 | 225 / 20311 / 5078 |
| ratcheted (authored) bundle tokens / ceiling sum | 188580 / 194710 |
188607 / 194737 |
| eval fixtures tokens | 48379 | 48698 |
| bundle total tokens (whole shipped tree) | 248754 | 249100 |
No `SKILL.md` is touched. The before column is measured on `b8456ebd`
(#34019 landed: `rules/security.md` 4041, eval id 21 taken); this PR's
own delta is unchanged from the earlier rounds (+108 bytes / +27 tokens
on `security.md`, one eval case).
</details>
## Acceptance notes
Each sentence was checked against the code on `63db7240`, not against
the card.
<details><summary>Items 1 and 3: the carry rewrites holders
only</summary>
`packages/plugins/plugin-security/src/position-renamed-holder-carry.ts`,
module doc, "What it names and never writes" (lines 78-80):
```ts
* Holders only (ruling A1). Every other stored reference to an old name stays
* as it is and is listed by table, so an administrator can re-point it in
* Setup: sharing-rule, queue-member and record-share recipients of type
```
"What it is not" (lines 89-91):
```ts
* Not a downgrade path: a version that drops the rename does not carry the
* holders back. Not a metadata rewrite: Setup-authored bodies that name an
* old position are not read.
```
So a package's own sharing rule, approver or policy naming the old
position keeps naming it until the author changes the source; the boot
log lists stored rows by table for an administrator. An environment
position's own `renamedFrom` is still judged and its holders carried
(`position-renamed-holder-carry.test.ts` lines 347-361: `{ from:
'old_rep', to: 'env_rep', packageId: null, rows: 1 }`), and the carry
reads every position's `renamedFrom` ("What it does", lines 23-25). That
is why the sentence says what is not rewritten rather than what is not
read (review 6899620269 M-1; the first round's "no metadata is read" was
wrong for exactly this case).
</details>
<details><summary>Item 2: the environment as recorded owner</summary>
Module doc, `owned-by-other` (lines 63-65): "a row carrying the
environment's sentinel (`sys_metadata`) records the environment as the
owner, so a package's claim is refused and an environment position's is
not." Line 173: `const OVERLAY_PROVENANCE_SENTINEL = 'sys_metadata';`,
mapped at line 618:
```ts
const pkg = raw === null ? null : raw === OVERLAY_PROVENANCE_SENTINEL ? ENVIRONMENT_OWNER : raw;
```
Test rows 214 and 216 refuse `owned-by-other` both ways (an environment
position claiming a name the ledger records under a package; a package
claiming a name the ledger records as the environment's), hence "another
owner (a package or the environment)".
</details>
<details><summary>Item 4: the explain gate</summary>
`packages/plugins/plugin-security/src/security-plugin-explain-access.ts`,
`mayDescribeAnotherUser` (lines 145-165), asked by `explain` and by
`describeEffectiveAccess` alike:
```ts
if (callerContext?.isSystem === true) return true;
const callerSets = await this.resolvePermissionSetsForContext(callerContext).catch(() => []);
const held = this.permissionEvaluator.getSystemPermissions(callerSets);
if (held.has('manage_users')) return true;
const organizationLevel = this.delegatedAdminGate
? await this.delegatedAdminGate
.organizationAdminCoversUser(callerSets, userId, callerContext)
```
…then `scopesCoverUser` for a delegated `adminScope`. The denial (line
196): "explaining another user's access requires the 'manage_users'
capability, organization administration of an organization that user is
a member of, or a delegated adminScope covering that user (ADR-0090
D6/D12)." The routes are `GET` / `POST {basePath}/security/explain`
(`packages/rest/src/security-routes.ts`). The system-caller arm is left
out as not an operator fact.
</details>
## Verification
<details><summary>Derived gates on <code>464f620f</code> (serial rework
after #34019): 64 derived, 64 run, all exit 0</summary>
Head `464f620f` = `b9479f0d` plain-merged with `origin/main` `b8456ebd`
(#34019). Two conflicts, resolved mechanically by the thread (no new
teaching): the eval case renumbered 21 → 22; the ratchet row re-pinned
at the merged measurement (16272 bytes → 4068), #34019's comment kept
above it. `rules/security.md` merged without conflict. `pnpm install`
exit 0; packages built under the verify lock (`os-verify-lock: VERDICT
command-exit 0`, 81 of 81 tasks). `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` listed 64 commands (4
paths vs merge base `b8456ebd4`); each ran with `< /dev/null`, exit
recorded as `CMD :: exit N`, reconciled:
```
Run reconciliation — 64 derived, 64 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 64 derived famil(ies) accounted for — 64 run, 0 NOT-MEASURED (a DERIVED zero — all 64 recorded an exit code and none of them is 3).
```
Also run, each exit 0: `pnpm --filter @objectstack/spec
check:skill-docs`, `check:skill-refs`, `check:skill-examples` ("347
prose examples type-check across 3 surface(s)"), and the seven
unmatched-roster gates the derivation flags as living in a directory
this diff touches (`check-dts-references --self-test`,
`check-published-list-mirrors` + `--self-test`, `check:changeset-fixed`,
`check:engine-double-contract`, `check:i18n-stale-fill`,
`check:published-readme-exports`).
Token ratchet: 57 authored bundle files within their ceilings;
`rules/security.md` 4068 / 4068; `--self-test` 104 cases pass.
Earlier rounds: `b9479f0d` 63 derived, all exit 0; `169a40a0` 45
derived, all exit 0.
</details>
<details><summary>Governed-surface reading</summary>
`node scripts/pm/check-governed-merges.mjs --pr 34105` on `464f620f`: "2
of 4 path(s) hit the register" (`skills/**` ×2; the changeset and
`scripts/check-skills-token-ratchet.mjs` are not on the register),
landing tier **H**. The low-risk skills arm refuses on two counts: "a
path outside skills wording and prose:
scripts/check-skills-token-ratchet.mjs" and "a catalog path that names
security, auth or permission". Size 84 changed lines (+60 / -24), under
the 3000 human-merge threshold. Landing waits for a GOVERNED_APPROVERS
approval.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmTSWHtysbqqYGcsTP1
<!-- signed: domain:skills#2 · os-steve ·
session_01ADHkmTSWHtysbqqYGcsTP1 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9e7c695 commit 2c96e0d
4 files changed
Lines changed: 60 additions & 24 deletions
File tree
- .changeset
- scripts
- skills/objectstack-data
- evals
- rules
| 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 | |
|---|---|---|---|
| |||
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | | - | |
1082 | | - | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1083 | 1099 | | |
1084 | 1100 | | |
1085 | 1101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
213 | 223 | | |
214 | 224 | | |
215 | 225 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
| |||
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
| |||
184 | 182 | | |
185 | 183 | | |
186 | 184 | | |
187 | | - | |
| 185 | + | |
188 | 186 | | |
189 | 187 | | |
190 | 188 | | |
191 | 189 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
196 | 193 | | |
197 | 194 | | |
198 | 195 | | |
199 | | - | |
200 | | - | |
| 196 | + | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
| |||
328 | 324 | | |
329 | 325 | | |
330 | 326 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
0 commit comments