Skip to content

Commit 5ebea45

Browse files
committed
fix(objectql): declare the widening arm and name the org-delete exemption in the unit comments
Clause-② is `yes (widening)`, as the seat ruled: a delete that was refused is now admitted. The sys_unit object header and the default permission set comment now say the engine refuses a DIRECT unit delete in every context, and that the organization's own delete removes its units. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
1 parent ac14915 commit 5ebea45

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎.changeset/35812-org-delete-removes-units.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
'@objectstack/objectql': patch
3+
'@objectstack/platform-objects': patch
4+
'@objectstack/plugin-security': patch
35
---
46

57
fix(objectql): deleting an organization also deletes its units of measure, the one exemption from the `sys_unit` delete refusal
68

7-
Clause-②: yes
9+
Clause-②: yes (widening)
810
Metadata-protocol: none
911

1012
An organization that had ever created a unit of measure could not be deleted: the delete was refused with 409 `DELETE_RESTRICTED` naming `sys_unit`, and the units could not be removed first, because the engine refuses every delete of a unit (405 `ERR_UNIT_DELETE_REFUSED`). Now the organization delete's own cascade removes that organization's `sys_unit` rows, retired ones included, through the engine's delete path, after the delete has been admitted, so no unit row is left naming a deleted organization. `organizationOwnedRowCounts` (the question plugin-auth's organization delete asks first) and the engine's own refusal no longer count units as records the organization still owns.

‎packages/platform-objects/src/system/sys-unit.object.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,12 @@ const DIMENSION_LABELS: Record<(typeof UNIT_DIMENSIONS)[number], string> = {
9090
* a retired row keeps its code, so the code can never be created again with
9191
* another dimension, ratio or label, and resting quantities never take a
9292
* stranger's meaning. A hard delete is not served (`apiMethods` has no
93-
* `delete`) and the engine refuses one in every context, a system writer's
94-
* and an automation run's included (`ERR_UNIT_DELETE_REFUSED`); a retired
95-
* unit cannot be brought back, and a new save with a retired code is
96-
* refused (`ERR_UNIT_CODE_RETIRED`).
93+
* `delete`) and the engine refuses a direct one in every context, a system
94+
* writer's and an automation run's included (`ERR_UNIT_DELETE_REFUSED`). The
95+
* one exemption is the organization's own delete, whose cascade removes
96+
* every unit of that organization (#35812). A retired unit cannot be
97+
* brought back, and a new save with a retired code is refused
98+
* (`ERR_UNIT_CODE_RETIRED`).
9799
* - **Tenancy** — no tenancy opt-out, so `organization_id` is injected and the
98100
* Layer 0 tenant wall (ADR-0095 D1) scopes every read and write.
99101
* - **Who reads, who writes** — every member READS it (`member_default` names

‎packages/plugins/plugin-security/src/objects/default-permission-sets.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,9 @@ const baseDefaultPermissionSets: PermissionSet[] = [
450450
// created, relabelled, re-rated and retired here, never deleted.
451451
// Retiring is the delete, and a removed row would free its code to be
452452
// created again with another meaning, so the effective map offers no
453-
// delete, and the engine refuses one in every context
454-
// (`ERR_UNIT_DELETE_REFUSED`, `@objectstack/objectql`). WITHOUT the
453+
// delete, and the engine refuses a direct one in every context
454+
// (`ERR_UNIT_DELETE_REFUSED`, `@objectstack/objectql`); only the
455+
// organization's own delete removes its units (#35812). WITHOUT the
455456
// superuser bits: `modifyAllRecords` grants delete on its own, and the
456457
// derived no-bypass variant inherits this line. Units carry no owner
457458
// scope for an administrator (the owner-only floor binds `org_member`),

0 commit comments

Comments
 (0)