Skip to content

Commit d86cdc3

Browse files
committed
chore(cli,spec): list sys_assignment_rule in the platform-object roster, the organization-ownership inventory and the tenancy census, and add the changeset
PLATFORM_PROVIDED_OBJECT_NAMES gains sys_assignment_rule under plugin-sharing, between sys_assignment_cursor and sys_queue. The organization-ownership inventory lists it as an attribution-fate table (its organization column is required, so no NULL row has a producer), and the platform-object tenancy census picks up the new object. The changeset declares Clause-② yes (widening), Metadata-protocol added and the Skills-docs follow-up. Claude-Session: https://claude.ai/code/session_016WV4d14C8K4gMehVb6jBvA Co-authored-by: Claude <noreply@anthropic.com>
1 parent b0458ed commit d86cdc3

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/objectql': minor
4+
'@objectstack/plugin-sharing': minor
5+
'@objectstack/cli': minor
6+
---
7+
8+
feat(objectql,plugin-sharing): an organization authors its own assignment rules in Setup, as `sys_assignment_rule` records
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: added
12+
Skills-docs: follow-up owed — content/docs/automation/queues-and-assignment-rules.mdx, skills/objectstack-automation/SKILL.md
13+
14+
Until now only a package could declare an assignment rule, so routing new records differently meant a package release. An organization can now write its own rules in Setup (Access Control → Assignment Rules), on the same two-source model sharing rules and queues already follow: the rules packages declare keep working, and the organization's own rules sit beside them.
15+
16+
- **`@objectstack/plugin-sharing`**: a new object, `sys_assignment_rule`. One row is one rule: when a new record of the chosen object matches the condition (a CEL expression over `record`, empty for every record), it goes to a queue or to one person, and a queue target may pick a member by `round_robin` or `least_loaded` (which needs its open-work expression, `load`). Each row belongs to one organization (`organization_id` is required). The table's save guard refuses, naming each field at fault: a name that is not snake_case or that a package rule already holds (one name means one rule); an object that does not exist or whose records have no owner; an entry shape the stack schema refuses for a declared rule; a condition or open-work expression the engine cannot compile; a person who is not an active member of the organization; a rule that would land in no organization. A boot report logs, at `error`, an organization's rule whose name a later-installed package now declares. Setup gains an "Assignment Rules" entry beside Queues.
17+
- **`@objectstack/objectql`**: the engine evaluates an object's organization rules first, ascending by `sort_order` and then by name, and the rules packages declare as the fallback; the first match decides. A user target, from either source, now owns the record only while the user is an active member of the record's organization and is not banned. One that no longer resolves leaves the record ownerless, the way a queue that no longer resolves does, and is logged once; the insert is never refused. When an organization's rules cannot be read, its new records are written as they stood rather than routed by the package rules its own would have overtaken. New exports for the save guard: `ASSIGNMENT_RULE_OBJECT`, `assignmentExpressionRefusals`, `organizationMemberStanding`.
18+
- **`@objectstack/spec`**: `PLATFORM_PROVIDED_OBJECT_NAMES` lists `sys_assignment_rule` under `plugin-sharing`, and the `AssignmentRuleSchema` documentation says how the two sources combine. No key, shape or validation changes.
19+
- **`@objectstack/cli`**: the organization-ownership inventory lists `sys_assignment_rule`, so `os migrate organization-ownership` plans it instead of refusing it as an uninventoried platform table.
20+
21+
Upgrading: a package rule whose entry names a user id (the `assignment-rule-user-target` lint warning) stops assigning in an organization where that user is not a member; the engine logs the lapse once per rule, user and organization. Route such a rule to a queue whose members are positions.

‎packages/cli/src/utils/organization-ownership-inventory.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,14 @@ export const ORGANIZATION_OWNERSHIP_INVENTORY: readonly InventoryEntry[] = [
794794
{ object: 'sys_mail_message', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach); the message's mailbox carries the organization`, anchors: [parent('mailbox_id', 'sys_mailbox')] },
795795
{ object: 'sys_mail_association', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach); the association's message carries the organization`, anchors: [parent('mail_message_id', 'sys_mail_message')] },
796796
// Ownership queues (`@objectstack/plugin-sharing`, ADR-0142): an organization
797-
// authors its queues and their members, and the assignment engine writes its
798-
// cursor, each under that organization. A member and a cursor name their
799-
// queue or rule by name, not by id, so no parent anchors them.
797+
// authors its queues, their members and its own assignment rules, and the
798+
// assignment engine writes its cursor, each under that organization. A
799+
// member, a cursor and a rule name their queue or rule by name, not by id,
800+
// so no parent anchors them.
800801
{ object: 'sys_queue', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] },
801802
{ object: 'sys_queue_member', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach); names its queue by name, not by id; ${D10_SINGLE}`, anchors: [] },
802803
{ object: 'sys_assignment_cursor', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach); names its rule by name, not by id; ${D10_SINGLE}`, anchors: [] },
804+
{ object: 'sys_assignment_rule', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); its organization column is required, so no NULL row has a producer; ${D10_SINGLE}`, anchors: [] },
803805
// Exchange rates (`@objectstack/platform-objects`, #27185): an organization's
804806
// administrators author its own rate table; no parent row anchors a rate.
805807
{ object: 'sys_exchange_rate', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] },

‎packages/spec/src/system/constants/platform-object-names.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export const PLATFORM_OBJECTS_BY_PACKAGE: Readonly<Record<string, readonly strin
116116
/** `@objectstack/plugin-sharing` — record shares & share links; ownership queues and the assignment cursor (ADR-0142). */
117117
'plugin-sharing': [
118118
'sys_assignment_cursor',
119+
'sys_assignment_rule',
119120
'sys_queue',
120121
'sys_queue_member',
121122
'sys_record_share',

‎scripts/platform-object-tenancy-census.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"predicate": "resolveTenantFieldName(registered schema) !== null, where the registered schema is the authored schema plus the columns resolveInjectedSystemColumns says the registration injects (the applySystemFields pass). Both functions are loaded from source and executed; neither is re-spelled here.",
2727
"population": "every object registered by a tracked packages/**/*.object.ts module whose name carries a platform prefix (sys_ / cloud_ / ai_). The cloud repository's own cloud_ objects are not in this tree and so not in this census.",
2828
"totals": {
29-
"registered": 93,
30-
"inReach": 47,
29+
"registered": 94,
30+
"inReach": 48,
3131
"outOfReach": 46
3232
},
3333
"reasonTotals": {
@@ -105,6 +105,13 @@
105105
"tenantField": "organization_id",
106106
"reasons": []
107107
},
108+
{
109+
"name": "sys_assignment_rule",
110+
"file": "packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts",
111+
"reach": "in",
112+
"tenantField": "organization_id",
113+
"reasons": []
114+
},
108115
{
109116
"name": "sys_attachment",
110117
"file": "packages/platform-objects/src/audit/sys-attachment.object.ts",

0 commit comments

Comments
 (0)