Skip to content

Commit dceca37

Browse files
committed
docs(skills): the data skill teaches that a user field's declared deleteBehavior takes effect when the user is deleted
The `user` row of the field-types rule lists `deleteBehavior` with the walk's behaviour (no default; declared, it acts as on a lookup; undeclared, the field keeps the deleted user's id), and the delete-behaviours section of the relationships rule names `lookup`, `tree` and a declaring `user` field among the reference types the walk reads. One eval case exercises it. Each ceiling is paid in place: the field-types Summary (Roll-up) block (restated by the relationships rule's Roll-up Summaries) and the relationships "When to Use lookup vs master_detail" bullets (restated by the Relationship Types table and the Incorrect vs Correct section; its lookup-to-user example contradicted the package's own eval) are deleted. Claude-Session: https://claude.ai/code/session_01J8VVAkZCePk1V8qh465qcT Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6f09464 commit dceca37

4 files changed

Lines changed: 29 additions & 31 deletions

File tree

‎skills/objectstack-data/evals/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ JSON fixtures in the objectui shape (`skill_name`, `evals[]`: `prompt`,
55

66
- `objects-fields-relationships.json` — naming, field types (`secret` vs
77
`password`), relationships (junction vs multi-value lookup,
8-
`deleteBehavior`), validation (`state_machine`, unique **index**),
8+
`deleteBehavior`, a `user` field's included), validation (`state_machine`, unique **index**),
99
conditional field rules.
1010
- `hooks-security-seeds-datasources.json` — search mirrors via hooks,
1111
permission-set scopes, external datasources, seeds (`externalId`,

‎skills/objectstack-data/evals/objects-fields-relationships.json‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@
9696
"name: 'crm_account'"
9797
]
9898
}
99+
},
100+
{
101+
"id": 6,
102+
"prompt": "On `ticket`, `owner` is the agent who holds it and must always be set; deleting that agent's user account must be blocked while they still hold tickets. `watchers` is several users, and a deleted user should just drop out of the list.",
103+
"expected_output": "Both are `type: 'user'` fields, each with an authored `deleteBehavior` — a `user` field joins the referential delete walk only when it declares one. `owner`: `required: true` with `deleteBehavior: 'restrict'` (deleting a held user is refused with `409 DELETE_RESTRICTED`; `set_null` on a required field would refuse too). `watchers`: `multiple: true` with `deleteBehavior: 'set_null'` (only the deleted member is removed; an emptied set is `[]`). Neither is a `lookup` to a `user` object, which does not exist, and a `user` field with no `deleteBehavior` keeps the deleted user's id.",
104+
"files": [],
105+
"assertions": {
106+
"must_contain": [
107+
"type: 'user'",
108+
"deleteBehavior: 'restrict'",
109+
"deleteBehavior: 'set_null'",
110+
"multiple: true",
111+
"required: true"
112+
],
113+
"must_not_contain": [
114+
"reference: 'user'",
115+
"deleteBehavior: 'cascade'"
116+
]
117+
}
99118
}
100119
]
101120
}

‎skills/objectstack-data/rules/field-types.md‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ options: [
9393
| `lookup` | Reference another object (independent) | `reference`, `lookupFilters`, `multiple`, `deleteBehavior`, `lookupAutofill` |
9494
| `master_detail` | Parent–child with lifecycle control | `reference`, `deleteBehavior` (`cascade`/`restrict` — `set_null` is refused), `lookupAutofill` |
9595
| `tree` | Hierarchical self-reference | `reference` — optional; when written, this object's own name (any other object is refused at parse) |
96-
| `user` | Person picker — a lookup specialized to `sys_user` (assignee, watchers). Stored identically to `lookup` | `multiple` (collaborators), `defaultValue: 'current_user'` |
96+
| `user` | Person picker — a lookup specialized to `sys_user` (assignee, watchers). Stored identically to `lookup` | `multiple` (collaborators), `defaultValue: 'current_user'`, `deleteBehavior` (no default — declared, deleting the user acts as on `lookup`: `cascade` deletes the holders, `set_null` clears the field or drops that member, `restrict` refuses with `409 DELETE_RESTRICTED`; undeclared, the field keeps the deleted user's id) |
9797

9898
**`lookupAutofill: [{ target, source, overwrite? }]`** (single-value `lookup` /
9999
`master_detail`): a pick copies the picked record's `source` into this object's
@@ -203,20 +203,6 @@ const total = {
203203
};
204204
```
205205

206-
### Summary (Roll-up)
207-
208-
```typescript
209-
{
210-
type: 'summary',
211-
summaryOperations: {
212-
object: 'invoice_line_item', // child object to aggregate
213-
field: 'amount', // child field
214-
function: 'sum', // 'count' | 'sum' | 'min' | 'max' | 'avg'
215-
// relationshipField / filter — optional (see rules/relationships.md)
216-
},
217-
}
218-
```
219-
220206
### Autonumber
221207

222208
```typescript

‎skills/objectstack-data/rules/relationships.md‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Relationship Patterns
22

3-
- [Relationship Types](#relationship-types) · [When to Use lookup vs master_detail](#when-to-use-lookup-vs-master_detail)
3+
- [Relationship Types](#relationship-types)
44
- [Patterns](#patterns) — [lookup](#one-to-many-lookup) · [master_detail](#one-to-many-master_detail) · [Junction Object](#many-to-many-junction-object) · [tree](#hierarchical-tree-self-reference)
55
- [Delete Behaviors](#delete-behaviors) · [Roll-up Summaries](#roll-up-summaries)
66
- [Inline Editing (Master-Detail Entry)](#inline-editing-master-detail-entry) · [Detail-page related lists](#detail-page-related-lists-the-read-side-mirror)
@@ -16,20 +16,6 @@ Guide for modeling relationships between objects using `lookup`, `master_detail`
1616
| `master_detail` | Coupled (cascade delete) | Forced only under `controlled_by_parent`; else lint-warned | Inherits parent; owner opt-in `ownerMayEdit` (below) | Supported via `summary` | "Owned by" |
1717
| `tree` | Self-reference | Optional — and so is `reference`, which when written must name this object itself; any other object is refused at parse, not lint-warned | N/A | Not available | Hierarchical |
1818

19-
## When to Use lookup vs master_detail
20-
21-
### Use `lookup` When:
22-
- Child record can exist independently
23-
- Parent deletion should only clear the FK (`deleteBehavior: 'set_null'`, the default)
24-
- Relationship is optional
25-
- **Example:** `task.assigned_to → user` (task can exist without assignment)
26-
27-
### Use `master_detail` When:
28-
- Child record is meaningless without parent
29-
- Parent deletion should cascade to children
30-
- Relationship is mandatory
31-
- **Example:** `invoice_line_item.invoice_id → invoice` (line items belong to invoice)
32-
3319
## Patterns
3420

3521
### One-to-Many: lookup
@@ -186,6 +172,13 @@ an authored `set_null` is refused at publish (it would orphan the detail row).
186172
}
187173
```
188174

175+
The walk also reads `lookup` and `tree` (`set_null` by default — the field is
176+
cleared; a `multiple` field loses only that member — or an authored `cascade` /
177+
`restrict`), and a `user` field only when it declares a value: deleting the user
178+
then cascades, clears or refuses exactly as a `lookup` does; undeclared, the
179+
field keeps the deleted user's id. `restrict`, and `set_null` on a `required`
180+
field, refuse the delete with `409 DELETE_RESTRICTED`.
181+
189182
## Roll-up Summaries
190183

191184
A parent `summary` field aggregates a child collection. The engine recomputes it

0 commit comments

Comments
 (0)