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
12 changes: 12 additions & 0 deletions .changeset/36541-skills-custom-arrangement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/skills': patch
---

Clause-②: no
Metadata-protocol: none

The `objectstack-data` skill teaches the whole-arrangement keys of the paired `.custom` package's object extension:

- Object Extension Model: only the object extension of a base's paired `.custom` package may write `fieldGroups` and `relatedLists`, in the shape an object declares them. A written key replaces that arrangement whole (the owner's and every `place`); an unlisted field shows after the last group, an unnamed tab still shows after the listed ones, and `{ list: 'crm_note', hidden: true }` hides a tab. Outside a `.custom` package both keys are refused at save, publish and install and by `os validate` / `os build`, with the prescription to use `place`.
- Eval: a new `objectstack-data` case moves an installed object's tab arrangement from an add-on package's extension, where it is refused, to the pair's extension, and names `place` as what the add-on package writes. The `place` case no longer says an extension has neither key.
- Five restatements in the same file are cut to pay for the paragraph; each one's content stays in the bundle (`rules/validation.md`, `rules/indexing.md`, `rules/lifecycle.md`, `references/lint-rules.md`, the object JSON example).
19 changes: 9 additions & 10 deletions skills/objectstack-data/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ metadata:
- **[Relationships](./rules/relationships.md)** — lookup vs master_detail, junction patterns, delete behaviors
- **[Validation Rules](./rules/validation.md)** — All validation types, script inversion, severity levels
- **[Index Strategy](./rules/indexing.md)** — btree/gin/gist/fulltext, composite indexes, partial indexes
- **[Data Lifecycle & Retention](./rules/lifecycle.md)** — `lifecycle` classes (record/audit/telemetry/transient/event), retention/TTL/rotation/archive policies; ❗ append-only objects must declare one (distinct from lifecycle *hooks* below); plus the **save notice** a hook hands the saver (`ctx.notice`)
- **[Data Lifecycle & Retention](./rules/lifecycle.md)** — `lifecycle` classes (record/audit/telemetry/transient/event), retention/TTL/rotation/archive policies (distinct from lifecycle *hooks* below); plus the **save notice** a hook hands the saver (`ctx.notice`)
- **[Lifecycle Hooks](./references/data-hooks.md)** — the lifecycle events, the sandboxed `body` (ctx + capability contract; the inline `handler` is deprecated), registration, canonical patterns
- **[Datasources & Federation](./rules/datasources.md)** — `defineDatasource`, external/federated objects (`remoteName`/`columnMap`), auto-connect gating, credentials; ❌ no `field.columnName` on external objects
- **[Security & Access Control](./rules/security.md)** — permission sets, assignment rows, RLS policies, `secret` / `requiredPermissions`, `tenancy`, platform-global posture
Expand Down Expand Up @@ -68,8 +68,7 @@ same literal goes inside `ObjectSchema.create({...})`):
| `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. Author it on every object |

**`sharingModel` — the four canonical values** (ADR-0090 D4; legacy aliases
removed):
**`sharingModel` — the four canonical values:**

| Value | Who can read / write |
|:--|:--|
Expand All @@ -91,7 +90,7 @@ all (Relationship Patterns below).
| Property | Default | Description |
|:---------|:--------|:------------|
| `label` | Auto from `name` | Human-readable singular label |
| `pluralLabel` | — | Plural form (e.g., "Accounts"); author it alongside `label` |
| `pluralLabel` | — | Plural form; author it alongside `label` |
| `icon` | — | Icon for nav, list headers and lookup pickers; give every object one |
| `color` | `gray` | Tile colour, one of `gray` `blue` `teal` `green` `amber` `orange` `red` `pink` `purple` (no hex); the console draws `icon` white on it. Give every object one; avoid repeats in one app |
| `highlightFields` | derived | Ordered field keys used as a record's compact face: the columns a **related list** renders on the parent's detail page, and what a lookup picker shows. Declare it on the CHILD object (see [Relationships](./rules/relationships.md)) |
Expand Down Expand Up @@ -317,10 +316,6 @@ picker; `formula` takes CEL in `expression` (a `{ dialect: 'cel', source }` enve

**⚠️ Script validation is inverted:** Validation **fails** when expression is `true`.

> On **insert**, an optional field omitted from the payload reads as `null` in a
> validation predicate — so `record.due_date == null` matches an omitted field the
> same as an explicit `null`. (On update, the prior record supplies it.)

The **complete** set of types (`ValidationRuleSchema` discriminators): `script`,
`state_machine`, `format`, `cross_field`, `json_schema`, `conditional`.

Expand All @@ -335,8 +330,7 @@ keys and values are option `value`s, never labels.

### Index Patterns

**The whole declaration surface is `fields` / `unique` / `name`.** `unique`
defaults to `false`; omit it when that is what you mean.
**The whole declaration surface is `fields` / `unique` / `name`.**

```typescript
indexes: [
Expand Down Expand Up @@ -389,6 +383,11 @@ declaration. Every field the pair adds ends in `__c` (`region__c`). The suffix i
reserved to the pair, so a `__c` field in any other package, or an unsuffixed
field in a `.custom` extension, is refused at save, publish and install and by
`os validate` / `os build`.
Only the pair's extension may also write `fieldGroups` and `relatedLists`, shaped
as on an object. A written key replaces that arrangement whole (the owner's and
every `place`): an unlisted field shows after the last group, an unnamed tab
still shows after the listed ones, and `{ list: 'crm_note', hidden: true }` hides
a tab. Outside a `.custom` package both keys are refused at those doors: use `place`.
Studio's **Add field** on a base object writes the same extension, as an
`object_extension` item of the pair.

Expand Down
3 changes: 2 additions & 1 deletion skills/objectstack-data/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ JSON fixtures in the objectui shape (`skill_name`, `evals[]`: `prompt`,
`password`), relationships (junction vs multi-value lookup,
`deleteBehavior`, on a `user` field too), validation (`state_machine`, unique **index**),
conditional field rules, the record owner (负责人 is `owner_id`), an
object extension placing what it brings (`place`).
object extension placing what it brings (`place`), the `.custom` pair's
whole arrangement (`relatedLists`, `{ list, hidden: true }`).
- `hooks-security-seeds-datasources.json` — search mirrors via hooks,
permission-set scopes, external datasources, seeds (`externalId`,
CEL dynamic values).
Expand Down
22 changes: 21 additions & 1 deletion skills/objectstack-data/evals/objects-fields-relationships.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
{
"id": 26,
"prompt": "Our add-on package `acme_contracts` depends on HotCRM (`hotcrm`, namespace `crm`). Its extension of `crm_account` adds a `tax_id` text field, and the package ships an `acme_contract` object whose `account` lookup points at `crm_account`. On the account record page, show Tax ID right after Industry in the Basic section, and the Contracts tab right after Opportunities. `crm_account` declares `fieldGroups: [{ key: 'basic', label: 'Basic', fields: ['name', 'industry', 'website'] }]` and `relatedLists: ['crm_contact', 'crm_opportunity', 'crm_lead', 'sys_activity']`. We cannot edit HotCRM.",
"expected_output": "Two `place` entries on the package's own object extension, registered in its stack's `objectExtensions`: `defineObjectExtension({ extend: 'crm_account', fields: { tax_id: Field.text({ label: 'Tax ID' }) }, place: [{ field: 'tax_id', group: 'basic', after: 'industry' }, { list: 'acme_contract', after: 'crm_opportunity' }] })`. `place` arranges only what the extension brings (its own field, its package's child list), each right after (or `before`) an item the account already has, and it applies here because the account declares `fieldGroups` and `relatedLists`. Without it the field arrives after the account's own and the Contracts tab at the end of the tabs, before the activity stream. The extension does not carry `fieldGroups` or `relatedLists` of its own (an extension has neither key), does not redeclare the account, and nothing in HotCRM is edited.",
"expected_output": "Two `place` entries on the package's own object extension, registered in its stack's `objectExtensions`: `defineObjectExtension({ extend: 'crm_account', fields: { tax_id: Field.text({ label: 'Tax ID' }) }, place: [{ field: 'tax_id', group: 'basic', after: 'industry' }, { list: 'acme_contract', after: 'crm_opportunity' }] })`. `place` arranges only what the extension brings (its own field, its package's child list), each right after (or `before`) an item the account already has, and it applies here because the account declares `fieldGroups` and `relatedLists`. Without it the field arrives after the account's own and the Contracts tab at the end of the tabs, before the activity stream. The extension does not carry `fieldGroups` or `relatedLists` of its own (only the object extension of HotCRM's paired `hotcrm.custom` package writes those keys; here they are refused), does not redeclare the account, and nothing in HotCRM is edited.",
"files": [],
"assertions": {
"must_contain": [
Expand All @@ -465,6 +465,26 @@
"overrides:"
]
}
},
{
"id": 27,
"prompt": "We installed HotCRM (`hotcrm`, namespace `crm`) and cannot edit it. Its `crm_account` declares `relatedLists: ['crm_contact', 'crm_opportunity', 'crm_lead', 'sys_activity']`. On the account record page our admins want Opportunities before Contacts and the Leads tab gone, for every user. Our add-on package `acme_contracts` already extends `crm_account`, so a colleague put `relatedLists: ['crm_opportunity', 'crm_contact', { list: 'crm_lead', hidden: true }]` on that extension, and `os validate` refused it. Where does this arrangement go, and what may `acme_contracts` write instead?",
"expected_output": "The arrangement goes on the object extension of HotCRM's paired customization package `hotcrm.custom`, registered in that stack's `objectExtensions`: `defineObjectExtension({ extend: 'crm_account', relatedLists: ['crm_opportunity', 'crm_contact', { list: 'crm_lead', hidden: true }] })`. Only the pair's extension writes `relatedLists` (and `fieldGroups`), in the shape an object declares them. The key it writes replaces the tab list whole (HotCRM's own list and every other extension's `place`); a tab it does not name still shows after the listed ones (the activity stream here), so hiding is written, as `{ list: 'crm_lead', hidden: true }`; `fieldGroups`, not written, keeps the groups as they were. `acme_contracts` is not a `.custom` package, so both keys are refused there at save, publish and install and by `os validate` / `os build`, and the refusal prescribes `place`: that package places only what it brings, e.g. `place: [{ list: 'acme_contract', after: 'crm_opportunity' }]`, and cannot reorder or hide HotCRM's tabs. The account is not redeclared, takes no `overrides` declaration, and nothing in HotCRM is edited.",
"files": [],
"assertions": {
"must_contain": [
"hotcrm.custom",
"defineObjectExtension",
"extend: 'crm_account'",
"relatedLists",
"hidden: true",
"place:"
],
"must_not_contain": [
"name: 'crm_account'",
"overrides:"
]
}
}
]
}
Loading