Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/33566-skills-position-rename-own-source.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 18 additions & 2 deletions scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
}
]
}
44 changes: 22 additions & 22 deletions skills/objectstack-data/rules/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand All @@ -75,7 +77,6 @@ none applies the policies restrict nothing — an
`select` policies.

```typescript
// in a permission set
rowLevelSecurity: [
{
name: 'own_records',
Expand Down Expand Up @@ -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.

<!-- os:check -->
```typescript
import { ObjectSchema } from '@objectstack/spec/data';
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Loading