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/33506-skills-owner-id-for-assignee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/skills': patch
---

docs(skills): an owner, assignee or 负责人 in a request is the injected `owner_id`, never a second same-label field

Clause-②: no
Metadata-protocol: none

objectstack-data teaches that a request's owner, assignee, 负责人 or 处理人 is the platform's injected `owner_id`, not a second person field beside it. A handler the request names apart from the owner is a `user` field that grants no access, with a label no other visible field carries, the injected `owner_id` (Owner, 负责人), `created_by`, `updated_by`, `created_at` and `updated_at` included. To pay for the text inside the file's token ceiling, SKILL.md drops a ruling date, four ADR asides, two zod pointers that `references/_index.md` already carries, an internal constant name, a sentence restating its heading and a link the Quick Reference list already gives. The Quick-Start Template's support case no longer declares an `assigned_to` user field, and a new eval asks for a ticket app with a 负责人.
27 changes: 11 additions & 16 deletions skills/objectstack-data/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ database table and exposes automatic CRUD APIs.
|:---------|:-------|:-----------|:------------|
| `name` | string | `snake_case` | Immutable machine identifier (`/^[a-z_][a-z0-9_]*$/`) |
| `fields` | map | keys in `snake_case` | Field definitions |
| `sharingModel` | enum | one of the four below | Org-wide default record visibility (OWD). Zod marks it optional, but **a publish with no authored `sharingModel` is refused** with the 422 lint envelope `security-owd-unset` — absence is not a decision (maintainer ruling 2026-08-13). Author it on every object |
| `sharingModel` | enum | one of the four below | Org-wide default record visibility (OWD). Zod marks it optional, but **a publish with no authored `sharingModel` is refused** with the 422 lint envelope `security-owd-unset` — absence is not a decision. Author it on every object |

**`sharingModel` — the four canonical values** (ADR-0090 D4; legacy aliases
removed). A *custom* object that omits it resolves to `private` at runtime, but
Expand Down Expand Up @@ -106,8 +106,6 @@ all (Relationship Patterns below).

### Object Capabilities (`enable`)

Toggle system behaviours per object:

| Flag | Default | Purpose |
|:-----|:--------|:--------|
| `trackHistory` | `false` | Field-level audit trail |
Expand All @@ -124,7 +122,7 @@ Toggle system behaviours per object:

## Search Fields (`searchableFields`)

`searchableFields` on the object is the canonical set `$search` scans (ADR-0061).
`searchableFields` on the object is the canonical set `$search` scans.
Leave it unset and search auto-defaults to the `nameField` plus the object's
short-text and enum columns (`text` / `email` / `phone` / `url` / `autonumber` /
`textarea` / `markdown` / `select`) plus every field marked `searchable: true`,
Expand Down Expand Up @@ -254,7 +252,7 @@ schema, and the **database column wins at write time**:
| rename a field | `renamedFrom: ['old_key']` on the new key: the sync carries the column's values |
| declared index removed, or its columns changed | `os migrate apply` (`--allow-destructive` when it drops, or rebuilds as `UNIQUE`) |

**`required` is not the `NOT NULL` dial (ADR-0113).** `required` is the
**`required` is not the `NOT NULL` dial.** `required` is the
**write contract** — the engine refuses an insert that omits the value — and it
implies nothing about the column. The physical constraint is a separate explicit
opt-in, `storage: { notNull: true }`, and it is what drift detection compares
Expand Down Expand Up @@ -293,7 +291,7 @@ picker; `formula` takes CEL in `expression` (`F\`...\`` from `@objectstack/spec`
accepted" (terms, a confirmation) is a `validations[]` rule, not `required`.
The default also lands seeded or imported rows that omit the column on a real
`false` instead of a null that only looks unchecked.
- A person on the record (assignee, approver, reviewer) is `type: 'user'` with
- A person on the record (approver, reviewer) is `type: 'user'` with
no `reference`, and optional unless the request says otherwise — the platform
already stamps the owner and `created_by`.
- A dynamic default (`defaultValue: 'current_user'`, `'NOW()'`, a CEL envelope)
Expand All @@ -312,7 +310,7 @@ picker; `formula` takes CEL in `expression` (`F\`...\`` from `@objectstack/spec`
| Hierarchical | `tree` field (self-reference) |
| Record status / lifecycle | a `select` on the business object (plus a `state_machine` validation) — never a separate status / stage / step table |
| Approval, review, routing, audit trail | not objects: an approval is a flow node (**objectstack-automation**) and its trail is platform history; model only the people it references (approver, reviewer), as `user` fields beside the owner |
| Record owner | the platform's `owner_id` (`ownership: 'user'`, the default) — never a hand-added "owner" / "person in charge" lookup, a second owner that owner-scoped visibility and "My records" views never read; `ownership: 'none'` only for a shared catalog or a pure junction table |
| Record owner | the platform's `owner_id` (`ownership: 'user'`, the default), also when the request says assignee, 负责人 or 处理人 — never a hand-added owner field, a second owner that owner-scoped visibility and "My records" views never read. A handler the request names apart from the owner is a `user` field that grants no access, with a label no other visible field carries, injected ones included: `owner_id` (Owner, 负责人), `created_by` (创建人), `updated_by` (更新人), `created_at` (创建时间), `updated_at` (更新时间). `ownership: 'none'` only for a shared catalog or a pure junction table |

> **`multiple: true` lookup ≠ junction object.** A multi-value lookup
> (`{ type: 'lookup', reference: 'x', multiple: true }`) is stored and read as an
Expand All @@ -339,9 +337,7 @@ one: `draft` / `pending` / `new`), never a terminal one; keys and values are
option `value`s, never labels.

> **There is NO `unique` validation type** — uniqueness is a unique **index**
> with its scope (ADR-0120; [rules/validation.md § Uniqueness](./rules/validation.md#uniqueness--use-unique-indexes)).

See [rules/validation.md](./rules/validation.md) for all types and examples.
> with its scope ([rules/validation.md § Uniqueness](./rules/validation.md#uniqueness--use-unique-indexes)).

### Index Patterns

Expand Down Expand Up @@ -372,21 +368,20 @@ To add fields/validations/indexes to an object you do not own, author
`200`, range `0–999`); an extension can add but never remove, except that a new
`label` without `pluralLabel` clears the base plural unless a tenant authored it (set both). ⛔ Not the same key
as object-level `ownership` (the record-ownership enum
`'user' | 'business_unit' | 'org' | 'none'`). Schema:
`node_modules/@objectstack/spec/src/data/object.zod.ts` (`ObjectExtensionSchema`).
`'user' | 'business_unit' | 'org' | 'none'`).

**Relabel a field the owner declares with `fieldPatches` — never by redeclaring
it in `fields`**, which takes the field over whole and cuts it off from the
owner's upgrades. A patch carries display keys only
(`BASE_FIELD_DISPLAY_WHITELIST`): `label`, `description`, `inlineHelpText`,
owner's upgrades. A patch carries display keys only:
`label`, `description`, `inlineHelpText`,
`placeholder`, and an option's `label` keyed by its stored `value`; the type,
values and rules stay the owner's. A key the tenant edited keeps the tenant's
text; between two extensions the higher `priority` wins. A patch naming a field
or option value the target lacks is refused at install and by `os validate`, and
a `picklist`-bound field's options are never patchable. Example:
`defineObjectExtension({ extend: 'crm_account', fieldPatches: { industry: { label: 'Sector' }, type: { options: { customer: { label: 'Client' } } } } })`.

**An object an installed package ships** (ADR-0146 D10) is extended from the
**An object an installed package ships** is extended from the
base's paired `.custom` package (`hotcrm.custom`; **objectstack-platform**
§ Customizing an installed package), never replaced: it takes no `overrides`
declaration. Every field the pair adds ends in `__c` (`region__c`). The suffix is
Expand Down Expand Up @@ -416,7 +411,7 @@ hand-writing an RLS policy (ADR-0057 D1): `own` (default) · `own_and_reports`
only `own` and `org` work in open source — the hierarchy-relative three need the
paid `@objectstack/security-enterprise` plugin, **fail closed to `own`** without
it, and `defineStack` errors unless the grant declares
`requires: ['hierarchy-security']`. Schema: `PermissionSetSchema.objects.*`.
`requires: ['hierarchy-security']`.

### Ownership queues — park a record for a team to claim

Expand Down
2 changes: 1 addition & 1 deletion skills/objectstack-data/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ JSON fixtures in the objectui shape (`skill_name`, `evals[]`: `prompt`,
- `objects-fields-relationships.json` — naming, field types (`secret` vs
`password`), relationships (junction vs multi-value lookup,
`deleteBehavior`, on a `user` field too), validation (`state_machine`, unique **index**),
conditional field rules.
conditional field rules, the record owner (负责人 is `owner_id`).
- `hooks-security-seeds-datasources.json` — search mirrors via hooks,
permission-set scopes, external datasources, seeds (`externalId`,
CEL dynamic values).
16 changes: 16 additions & 0 deletions skills/objectstack-data/evals/objects-fields-relationships.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@
"Field.lookup('invoice')"
]
}
},
{
"id": 19,
"prompt": "帮我搭一个工单管理应用:`ticket` 对象有标题、状态(新建 / 处理中 / 已解决)、优先级,以及负责人,负责人可以改派给别的同事。",
"expected_output": "The 负责人 is the platform's injected `owner_id` (`ownership: 'user'`, the default; label Owner / 负责人): reassigning the ticket writes `owner_id`, which also drives owner-scoped visibility and \"My records\" views. The `ticket` object declares no `assignee` / `assigned_to` / owner field of its own and no second visible field labelled 负责人; only a handler the request names apart from the owner would be a `user` field, with a label no other visible field carries (system fields `created_by` 创建人 and `updated_by` 更新人 included), granting no access.",
"files": [],
"assertions": {
"must_contain": [
"owner_id"
],
"must_not_contain": [
"assignee:",
"assigned_to:",
"label: '负责人'"
]
}
}
]
}
2 changes: 1 addition & 1 deletion skills/objectstack-data/references/examples-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default ObjectSchema.create({
]},
account: { type: 'lookup', reference: 'account', required: true },
contact: { type: 'lookup', reference: 'contact' },
assigned_to: { type: 'user' },
// assignee: the injected owner_id
due_date: { type: 'datetime' },
},
validations: [
Expand Down
2 changes: 1 addition & 1 deletion skills/objectstack-data/rules/field-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ options: [
| `lookup` | Reference another object (independent) | `reference`, `lookupFilters`, `multiple`, `deleteBehavior`, `lookupAutofill` |
| `master_detail` | Parent–child with lifecycle control | `reference`, `deleteBehavior` (`cascade`/`restrict` — `set_null` is refused), `lookupAutofill` |
| `tree` | Hierarchical self-reference | `reference` — optional; when written, this object's own name (any other object is refused at parse) |
| `user` | Person picker — a lookup specialized to `sys_user` (assignee, watchers). Stored identically to `lookup` | `multiple` (collaborators), `defaultValue: 'current_user'`, `deleteBehavior` (no default; declared, as on `lookup`: relationships.md → Delete Behaviors) |
| `user` | Person picker — a lookup specialized to `sys_user` (reviewer, watchers). Stored identically to `lookup` | `multiple` (collaborators), `defaultValue: 'current_user'`, `deleteBehavior` (no default; declared, as on `lookup`: relationships.md → Delete Behaviors) |

**`lookupAutofill: [{ target, source, overwrite? }]`** (single-value `lookup` /
`master_detail`): a pick copies the picked record's `source` into this object's
Expand Down
Loading