diff --git a/.changeset/33566-skills-position-rename-own-source.md b/.changeset/33566-skills-position-rename-own-source.md new file mode 100644 index 00000000000..85f02718e51 --- /dev/null +++ b/.changeset/33566-skills-position-rename-own-source.md @@ -0,0 +1,10 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): renaming a position tells the author to re-point their own source, names the environment as an owner, and restores who may explain another user + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-data/rules/security.md`, the **Renaming a position** paragraph: the holder carry moves holders only and rewrites no other reference to the old name, Setup-authored ones included, so the author re-points their own package source that names the old position (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 for an administrator. The not-carried list now says an old name recorded under another owner, a package or the environment, since the activation ledger records the environment as an owner too. § Assigning a permission set to a user says again who may ask `GET /api/v1/security/explain` about another user: a holder of `manage_users`, an administrator of one of that user's organizations, or a delegated `adminScope` covering that user. One eval case asks the rename with a same-package sharing rule. The `tabPermissions` pointer to objectstack-ui `rules/navigation.md` is kept, shortened. The file pays by dropping text that is stated elsewhere, and its token ceiling moves by the measured remainder: the kernel-name list (now a reference to the placeholder table in the same file), the membership-tier list (at the linked docs anchor), the second definition of `outside-closure` / `ambiguous-in-closure` (now a reference to the queue bullet above it), and short restatements. No schema or runtime change. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 1befe1b5462..5914db2d453 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1078,8 +1078,24 @@ export const CEILINGS = new Map([ // § Platform-global objects. On `origin/main` the file was 15834 bytes // (3959 tokens, headroom 0); the LANDED file is 16164 bytes -> 4041 tokens, // ceiling +82, pinned AT the measurement, zero headroom. - // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(16164 / 4) - ['skills/objectstack-data/rules/security.md', 4041], + // 4041 -> 4068 (card #33566, the follow-up of the position-rename paragraph): + // a renamed position's holders are the only thing the boot carry rewrites, + // so the author re-points their own source that names the old position; an + // old name recorded under another owner, a package or the environment, is + // not carried; and who may explain another user (`manage_users`, an + // administrator of one of that user's organizations, or a delegated + // `adminScope` covering that user). Same standing ruling, tap A, verbatim + // and untranslated: 「A:先削重复,余额按实测提高」 (record 6513306068). PAID + // DOWN FIRST, 313 bytes: the kernel-name list of the membership-keys bullet + // (the placeholder table in the same file), the membership-tier list (the + // linked docs anchor), the second definition of the two closure refusals + // (the queue bullet above it), four restatements of a heading or a + // neighbouring sentence, and a shorter `tabPermissions` pointer. On + // `origin/main` the file was 16164 bytes (4041 tokens, headroom 0); the + // LANDED file is 16272 bytes -> 4068 tokens, ceiling +27, pinned AT the + // measurement, zero headroom. + // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(16272 / 4) + ['skills/objectstack-data/rules/security.md', 4068], // 3024 -> 3109 (2026-08-31 app-repo-principles raise, see the block above). // Severity Levels listed the three values and left the CHOICE unstated: a // block rests on a judgement a person made, so a machine-inferred signal — a diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index feb71e353c6..e70e3ce7b60 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -210,6 +210,16 @@ "must_contain": ["type: 'user'", "defaultValue: 'current_user'", "check: 'assignee == current_user.id'"], "must_not_contain": [] } + }, + { + "id": 22, + "prompt": "Our package `com.acme.crm` ships a position `sales_rep`, live at customers, and a sharing rule in the same package whose `sharedWith` is `{ type: 'position', value: 'sales_rep' }`. The next version must call the position `crm_sales_rep`. What changes in the package?", + "expected_output": "The position becomes `{ name: 'crm_sales_rep', label: 'Sales Rep', renamedFrom: ['sales_rep'], permissionSets: [...] }`: renamed in place with `renamedFrom`, never deleted and re-added, so at boot its holders (`sys_user_position`) move to the new name in every organization. Only holders move: no other reference to the old name is rewritten, so the package's own sharing rule is re-pointed in source to `sharedWith: { type: 'position', value: 'crm_sales_rep' }`, as is any approver, queue member, policy `positions` entry or `current_user.positions` predicate in the package that names `sales_rep`. Stored references in an installed environment (recipients, pending approvers, invitations) are listed by table in the boot log for an administrator to re-point in Setup.", + "files": [], + "assertions": { + "must_contain": ["renamedFrom: ['sales_rep']", "value: 'crm_sales_rep'"], + "must_not_contain": [] + } } ] } diff --git a/skills/objectstack-data/rules/security.md b/skills/objectstack-data/rules/security.md index 84e61f9793a..6708b473eae 100644 --- a/skills/objectstack-data/rules/security.md +++ b/skills/objectstack-data/rules/security.md @@ -29,7 +29,7 @@ export const salesUser = definePermissionSet({ (`security-anchor-high-privilege`) and the binding refuse it. With none, invited members get nothing until an admin assigns each; no gate counts them. Its `systemPermissions` may name only app capabilities declared under `capabilities:`. -- `tabPermissions` hides an app from the set's holders, never gates it: objectstack-ui → Navigation. +- `tabPermissions` hides an app, never gates it: objectstack-ui → Who sees or opens an app. ## Assigning a permission set to a user @@ -47,14 +47,16 @@ index (none on `driver-memory`) holds grants naming no package to one per user, organization. Name `permission_set_package` on insert when two packages hold the name, or the grant is refused `409 RESOURCE_CONFLICT`, naming each holder. -Assignment is one `POST /api/v1/data/sys_user_permission_set`. Only a tenant admin — -or a delegated `adminScope` carrying `manageAssignments` for that set and user -— may write it; plain CRUD bits on the table are not enough. +Only a tenant admin — or a delegated `adminScope` carrying `manageAssignments` +for that set and user — may `POST /api/v1/data/sys_user_permission_set`; plain +CRUD bits on the table are not enough. **Grant looks inert?** Check in order: the set is switched off; the validity window has passed; `organization_id` mismatch. `GET /api/v1/security/explain?object=&operation=&userId=` answers from the -enforcing code path. +enforcing code path. Explaining another user takes `manage_users`, +administering one of their organizations, or a delegated `adminScope` covering +them. ## Row-Level Security (RLS) @@ -75,7 +77,6 @@ none applies the policies restrict nothing — an `select` policies. ```typescript -// in a permission set rowLevelSecurity: [ { name: 'own_records', @@ -119,8 +120,6 @@ traversal or subqueries — those are a compile error (ADR-0055), never silently ## Membership keys — a `current_user.KEY` set the roster object declares -Declare the set on the **roster** object, not one policy per record. - ```typescript import { ObjectSchema } from '@objectstack/spec/data'; @@ -157,9 +156,8 @@ rowLevelSecurity: [ - With `id` the set is the ids of the caller's own roster rows; it grants nothing by itself. Tested against a column not referencing the roster, or another object's `id`, it is refused (`rls-predicate-membership-key-target`). -- One name per stack: a key on two objects, a kernel name (`id`, - `organization_id`, `positions`, `org_user_ids`, `accessible_org_ids`, - `email`, `queues`) and a key on an object extension are refused. +- One name per stack: a key on two objects, a kernel name (a fixed + placeholder above, `accessible_org_ids`) and a key on an object extension are refused. - Read once per request as a system read in the caller's organization, at most 1,000 values; more, a failed read or a `filter` that does not compile matches **no rows**. Whoever writes roster @@ -184,20 +182,18 @@ rowLevelSecurity: [ - A position distributes **only** the sets its `permissionSets` names (ADR-0131 D3/D4): `{ name: 'crm_sales_rep', label: 'Sales Rep', permissionSets: ['crm_sales_user'] }`. A set that merely shares the position's name is reported, - never granted; a name matching no set, or refused below, confers nothing. + never granted; a name matching no set confers nothing. - A package's position reads each name as its package's set, else the one holder in its declared `dependencies` closure plus `sys`; else it is refused. It still loads; the boot's catalog reference report logs each refusal with every candidate, and the position grants nothing through that name (its other sets - still do). `outside-closure`: only a non-dependency holds it or only the - environment (a set authored in Setup). `ambiguous-in-closure`: two holders - it reaches (a second package shipping a name is refused at install). Fix: - declare the dependency. Stored grants, + still do). `outside-closure` / `ambiguous-in-closure` as for a queue above + (the environment: a set authored in Setup; a second package shipping a name + is refused at install). Fix: declare the dependency. Stored grants, environment-authored positions, admin overlays of a package position and the `everyone`/`guest` anchors resolve environment-wide. - A portal or partner user is an organization member on the `external` - membership tier (closed list `owner`, `admin`, `delegated_admin`, `member`, - `external`, one per member — + membership tier (one per member — https://objectstack.ai/docs/permissions/authentication#membership-tiers-are-a-closed-list). The `everyone` baseline does not reach it, it sees no member directory and holds no business unit, and every org-wide default is @@ -328,7 +324,11 @@ what changed and what an administrator re-checks after upgrading. **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: the boot log lists other references (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 package, switched off, or a disabled claimant. +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.