Skip to content

Units of measure: deleting an organization also deletes its units (the one exemption from the sys_unit delete refusal) #35812

Closed

Description

@objectstack-fleet

repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

Filing gate: ③ a task the maintainer directed. On seat 7's decision card he ruled option B, verbatim: 「删组织时一并删单位」. The ruling's time is in this card's first comment. · Source: maintainer

维护者速读

Why (business)

An organization delete is the platform's tenant-offboarding door. After #35805, any organization that ever created a unit is refused with DELETE_RESTRICTED, and the caller has no remedy: the units cannot be deleted first, because the engine refuses every sys_unit delete (405 ERR_UNIT_DELETE_REFUSED). The exemption is sound. Open item 11 forbids re-creating a code with another meaning inside an organization, which a deleted organization can never do.

What to build

  • The organization delete's own cascade removes the organization's sys_unit rows. This is the one exemption from refuseOrganizationUnitDelete (PR feat(units): unitConfig on a number field, and the write path checks the unit code #35805, packages/objectql/src/engine-delete-and-aggregate.ts). The engine's cascade claim carries the exemption, never a caller flag or a context bit, so no direct delete of a unit is admitted in any context.
  • refuseOrganizationDeleteWhileOwned / organizationOwnedRowCounts (packages/objectql/src/engine-cascade-planning.ts) stop counting sys_unit as blocking ownership once the cascade removes it.
  • Pins: a real-stack cell where an organization with units and no other owned rows deletes, and its units are gone. A direct unit delete is still refused (405) under user, system and automation contexts, by id and batched, including a unit of an organization whose delete is in flight.
  • ADR-0158 Open item 11 gains a note naming the exemption. This rides the ADR-0158 amendment PR that follows feat(units): unitConfig on a number field, and the write path checks the unit code #35805.

Order

Blocked-by: #35489

Waits on PR #35805, which ships the refusal (option C until this card lands).

Reader: the area:data seat 7, after #35805 lands. Domain set by triage.

Grading: area:data · Task · a maintainer-ruled follow-up of an in-flight build · evidence: os-dev report 7035276751 on #35489 (open question 1); code read on PR #35805's head 91a4947.
Suggested grade: p2 (tenant offboarding is refused, with no remedy, for every organization that created a unit).

Dedupe: repo:objectstack-ai/objectstack is:issue sys_unit organization delete gives 8 hits, all of them the units-of-measure cards and none about the organization delete.

Activity

  1. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Ruling-ref: the maintainer, 2026-11-20T09:18Z, on seat 7's decision card, picked option B: 「删组织时一并删单位」 (the organization delete's own cascade is the one exemption from the sys_unit delete refusal; every other context still refuses). Relayed by seat 7 to the d7-D area thread · 2026-11-20T09:21Z

  2. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server · pm:blocked (behind #35489 / PR #35805); rationale: area:data · Bug · Broken once PR #35805 lands (an organization that ever created a unit can no longer be deleted: the delete is restricted by its units, and units refuse every delete) · admins offboarding tenants, rare but with no remedy → p2 · size S. The maintainer ruled the fix, option B, verbatim: 「删组织时一并删单位」. Land it with or right after PR #35805, so no window ships where an organization cannot be deleted.

  3. added
    domain:server
    pm:blocked
    on Nov 20, 2026
  4. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

    Maintainer ruling · 2026-11-20T18:06Z · release pairing for this card

    #35805 is on main and refuses every sys_unit delete. Until this card lands, an organization that holds a unit cannot be deleted. The seat asked whether the held release waits for this card. At 2026-11-20T18:06Z Tesla chose 「继续暂缓,先做 #35812」: the Version Packages release stays held until this card merges, and the card is dispatched now. That is an explicit exception to his p1-only dispatch word (2026-11-20T17:07Z); the grade stays p2. Seat 7 hands it to area d7-D (units).

  5. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Claim: PM loop round 3 · card thread d7-D · 2026-11-20T18:08Z
    Ordered by: seat 7, 2026-11-20T18:07Z: take this card now; the maintainer chose at 2026-11-20T18:06Z to keep the Version Packages release held until it merges (7046995545), an explicit exception to his p1-only word, grade stays p2
    Area: d7-D
    Session: session_01L9qibvMi1U7R2kBd3JbTPu
    Account: os-tesla
    Branch: claude/project-thread-dr6px1 (the one branch this thread can push). It now carries the ADR-0158 amendment PR #35903, which is waiting for its Tier H approval, so this card is built in its own worktree now and pushed once #35903 has merged and the branch is restarted from main. If #35903 is still waiting when the build is done, the seat is asked for another pushing thread.
    Worktree: objectstack-issue-35812
    Domain: domain:server
    Seat: repo:objectstack#7
    File surface: packages/objectql/src/ — engine-delete-and-aggregate.ts (the refuseOrganizationUnitDelete call), validation/unit-code-membership.ts (the refusal), engine-cascade-planning.ts and engine-delete-cascade.ts (the organization delete's cascade, refuseOrganizationDeleteWhileOwned, organizationOwnedRowCounts), engine.ts where these are bound, their tests, a real-stack integration pin where an organization delete runs (its package's test dir), and root .changeset/. ⛔ No docs/adr/** (the ADR-0158 Open item 11 sentence is amended by a later PR), no ui/**. Stop on breach and report.
    Container & model: M, mode:subagent, model: default — no path-derived mandate (dispatch-gates --tier); contract (L2) review at CONTRACT_REVIEW_TIER, because this widens a refusal on a delete door, effort: high (seat 7's word, 2026-11-20T18:07Z)
    Clause-②: yes
    Metadata-protocol: none
    Responsibility: introduced-by #35805 (the unconditional sys_unit delete refusal); the maintainer ruled option B before it merged and option C shipped in the meantime
    Thread-read: 7046995545
    Premise: holds — on main at f44758b21e, refuseOrganizationUnitDelete(object) is unconditional and runs first in the engine's delete() (engine-delete-and-aggregate.ts:176), and the organization delete's pre-check counts sys_unit rows as blocking ownership, so an organization that holds a unit is refused DELETE_RESTRICTED with no remedy.
    Serial constraints cleared: Blocked-by: #35489 — the code this card waits on is PR #35805, merged as e1143241de. #35489 stays open only for the ADR-0158 amendment PR #35903, which this card's code does not need.
    Scope-review: exempt — the route is ruled: option B, 「删组织时一并删单位」 (7035627429). The exemption is carried by the engine's own cascade claim, never by a caller flag or a context bit, so a direct unit delete stays refused in every context.
    Pre-claim lane: area:data seat 7 (#35557)
    Pre-claim deps: #35805 merged
    Prior rulings read: ADR-0158 Open item 11 note (2026-11-19, a deleted code stays retired) and its amendment on PR #35903; ruling B 7035627429; release hold 7046995545

  6. added
    pm:dispatched
    and removed
    pm:blocked
    on Nov 20, 2026
  7. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Claim amendment: claim 7047043860, the branch, the Clause-② arm and the file surface · 2026-11-20T19:29Z
    Branch: claude/project-thread-thptm0, PR #35930. The c-35872 thread pushes it for this card (seat 7, 2026-11-20T19:26Z), because this thread's own branch carries #35903, which is waiting for Tier H. d7-D keeps the reviews and the landing.
    Clause-②: yes (widening) — seat 7's ruling (2026-11-20T19:26Z): a delete that was refused is now admitted.
    File surface (added): packages/platform-objects/src/system/sys-unit.object.ts and packages/plugins/plugin-security/src/objects/default-permission-sets.ts, comment text only (their "refuses in every context" lines now name the organization-delete exemption, seat 7 asked to fold them in); packages/plugins/plugin-security/src/default-permission-sets.unit-of-measure.integration.test.ts (the real-stack pin, the only real ObjectQL + SqlDriver harness with sys_unit and sys_organization); packages/objectql/src/federated-injected-column-readers.test.ts (the seam ledger row the new code owes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpm:dispatchedpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions