Skip to content

Commit 7ba0132

Browse files
docs(skills): objectstack-data teaches an object extension's fieldPatches
The Object Extension Model section gains one paragraph: relabel a vendor field with `fieldPatches` instead of redeclaring it in `fields`; the display keys it may carry, who wins, what is refused, and the `crm_account.industry` example. Paid for by deleting restatement in the same file (the search section's second refusal paragraph, the index blockquote and the validation type list, each already carried by the skill's rules files). A patch changeset for the published skills package. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2g7RyXa8ErM6GAkHyc
1 parent b48eeb1 commit 7ba0132

2 files changed

Lines changed: 31 additions & 23 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): objectstack-data teaches an object extension's `fieldPatches` — relabel a vendor field without redeclaring it in `fields`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Before.** `ObjectExtensionSchema.fieldPatches` is applied by the registry merge and refused at install and by `os validate` when it names nothing, but the published `objectstack-data` skill's *Object Extension Model* taught only `fields` / `priority`, so an agent that wanted a vendor field to read "Sector" instead of "Industry" redeclared the field in `fields` and took it over.
11+
- **Now.** The section carries one paragraph on `fieldPatches`: display keys only (`BASE_FIELD_DISPLAY_WHITELIST` — `label`, `description`, `inlineHelpText`, `placeholder`, and an option's `label` keyed by its stored `value`), type / values / rules stay the owner's, a tenant's edit wins, the higher `priority` wins between extensions, a patch naming a missing field or option is refused at install and by `os validate`, a `picklist`-bound field's options are not patchable — with the `crm_account.industry` example.
12+
- The file stays under its token ceiling: the new text is paid for by deleting restatement in the same file (the search section's second refusal paragraph, folded into its first; the index blockquote and the validation type list, each already carried by `rules/indexing.md` / `rules/validation.md`). No ceiling moves, no frontmatter, schema, key or behaviour changes.

‎skills/objectstack-data/SKILL.md‎

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ explicitly. Views may narrow it, never widen it.
122122
`$search` scans **the queried object's own columns**. A dotted path is never a
123123
search target: unlike `fields` / `sort` / `filters`, the search axis does not
124124
resolve traversal, and `project_id.name` in `searchableFields` (or in a
125-
`$searchFields` override) is **refused**, not silently dropped.
125+
`$searchFields` override) is **refused** (`os validate`
126+
`searchable-field-unknown`; a request, `400 INVALID_FIELD`), not silently dropped.
126127

127128
**This is the one prescription — emit it every time.** To search by a related
128129
record's title, copy that title into a **stored field on this object** and
@@ -168,13 +169,6 @@ fresh as whatever writes it. Cover both write paths:
168169
Rows written by a path that bypasses hooks (bulk import, direct SQL) need a
169170
one-off backfill. See [Lifecycle Hooks](./references/data-hooks.md).
170171

171-
Both spellings are refused loudly: `os validate` reports
172-
`searchable-field-unknown`, and a request naming the dotted path is `400
173-
INVALID_FIELD`. Each message carries its own prescription.
174-
175-
Cross-object search paths are rejected by design, not pending. Do not invent a
176-
per-project convention for this — the mirror field is the answer.
177-
178172
---
179173

180174
→ Moved verbatim to [references/examples-objects.md](./references/examples-objects.md) § Field Groups (MVP).
@@ -328,13 +322,8 @@ See [rules/relationships.md](./rules/relationships.md) for detailed examples.
328322
> validation predicate — so `record.due_date == null` matches an omitted field the
329323
> same as an explicit `null`. (On update, the prior record supplies it.)
330324
331-
The **complete** set of validation types (`ValidationRuleSchema` discriminators):
332-
- `script` — Formula expression (inverted logic)
333-
- `state_machine` — Legal state transitions
334-
- `format` — Regex or built-in format
335-
- `cross_field` — Compare values across fields
336-
- `json_schema` — Validate a JSON field against a JSON Schema
337-
- `conditional` — Apply a nested rule only `when` a predicate holds
325+
The **complete** set of types (`ValidationRuleSchema` discriminators): `script`,
326+
`state_machine`, `format`, `cross_field`, `json_schema`, `conditional`.
338327

339328
> **There is NO `unique` validation type** (removed from the spec).
340329
> Enforce uniqueness — including composite — with a **unique index**, and state
@@ -357,14 +346,10 @@ indexes: [
357346
]
358347
```
359348

360-
> `type` and `partial` were **retired at protocol 17** (a `tsc` and parse error;
361-
> `os migrate meta --from 16` lists the edits). A unique index **states its
362-
> scope** — `'organization'` or `'global'`: on a declared index bare `unique: true`
363-
> is the deprecated spelling of `'global'` and protocol 18 rejects it; on a FIELD
364-
> it means `'organization'` and stays valid.
365-
366-
See [rules/indexing.md](./rules/indexing.md) for composite indexes, unique scope,
367-
and how to build partial / gin / gist indexes at the database layer.
349+
See [rules/indexing.md](./rules/indexing.md) for composite indexes, unique scope
350+
(`'organization'` / `'global'` — on a declared index bare `unique: true` is
351+
refused), the retired `type` / `partial`, and partial / gin / gist indexes at the
352+
database layer.
368353

369354
→ Moved verbatim to [references/examples-objects.md](./references/examples-objects.md) § Lifecycle Hooks (the hooks reference itself is [references/data-hooks.md](./references/data-hooks.md)).
370355

@@ -380,6 +365,17 @@ as object-level `ownership` (the record-ownership enum
380365
`'user' | 'business_unit' | 'org' | 'none'`). Schema:
381366
`node_modules/@objectstack/spec/src/data/object.zod.ts` (`ObjectExtensionSchema`).
382367

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

385381
## Security & Access Control

0 commit comments

Comments
 (0)