From dfeb033ce7bf3729a939f7a764fd45d68ce7f913 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 04:47:57 +0000 Subject: [PATCH 1/2] docs(skills): objectstack-data teaches that os validate and os build refuse seed records a validation rule refuses Claude-Session: https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr Co-authored-by: Claude --- ...58-skills-seed-rows-refused-at-validate.md | 10 +++++ skills/objectstack-data/references/seeds.md | 43 +++++++++---------- 2 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 .changeset/37158-skills-seed-rows-refused-at-validate.md diff --git a/.changeset/37158-skills-seed-rows-refused-at-validate.md b/.changeset/37158-skills-seed-rows-refused-at-validate.md new file mode 100644 index 00000000000..08c95c8f4f8 --- /dev/null +++ b/.changeset/37158-skills-seed-rows-refused-at-validate.md @@ -0,0 +1,10 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): objectstack-data says `os validate` and `os build` refuse a seed record its object's validation rules refuse + +Clause-②: no +Metadata-protocol: none + +`references/seeds.md` said `os validate` does not run an object's validation rules on seed rows. Both commands now run them: each exits 1 (`--json` too) on a record a rule refuses, naming the record's location (`data[0].records[1]`), the object, the record index and the rule. A rule the record's literal values cannot decide (it reads a reference, a default, a formula or roll-up, or the object has a `beforeInsert` hook, or the dataset is `update`) is counted and never refused; the load still judges it, and `os verify` still fails on each dropped row. The `externalId` section now says a blank key field fails `os validate` / `os build` as well as the load. Text only; restatement elsewhere in the file is cut to pay for it. diff --git a/skills/objectstack-data/references/seeds.md b/skills/objectstack-data/references/seeds.md index 5c16a9b4f6d..6efb8d579a5 100644 --- a/skills/objectstack-data/references/seeds.md +++ b/skills/objectstack-data/references/seeds.md @@ -1,10 +1,7 @@ ## Seed Data & Fixtures (`defineSeed()`) -Object definition and seed data live together — a `*.object.ts` usually -pairs with a `*.seed.ts`. - -> The factory is `defineSeed` — **not** `defineDataset`, which is the -> unrelated ADR-0021 analytics semantic layer (`@objectstack/spec/ui`). +> The factory is `defineSeed` — **not** `defineDataset`, the unrelated +> analytics semantic layer (`@objectstack/spec/ui`). > ⛔ `sys_organization` is platform-bootstrapped — never a seed target; the > deployment posture decides how many exist (`rules/security.md` @@ -13,7 +10,6 @@ pairs with a `*.seed.ts`. ### Quick start ```typescript -// src/data/index.ts import { defineSeed } from '@objectstack/spec/data'; import { Status } from '../objects/status.object'; import { Category } from '../objects/category.object'; @@ -23,8 +19,8 @@ export const statusSeed = defineSeed(Status, { externalId: 'code', mode: 'upsert', records: [ - { code: 'active', label: 'Active', color: '#2ecc71' }, - { code: 'inactive', label: 'Inactive', color: '#95a5a6' }, + { code: 'active', label: 'Active' }, + { code: 'inactive', label: 'Inactive' }, ], }); @@ -45,8 +41,8 @@ export const SeedData = [statusSeed, categorySeed]; | Field | Default | Purpose | |:------|:--------|:--------| | `object` | derived | Auto-set from `objectDef.name`; hand-written only in a runtime save (below) | -| `externalId` | `'name'` | Stable business key (or field list) every mode matches on; required in every record (below) | -| `mode` | `'ignore'` | Import strategy (see below) | +| `externalId` | `'name'` | Stable business key (or field list) every mode matches on (below) | +| `mode` | `'ignore'` | Import strategy (below) | | `columns` | — | Per-column write policy, keyed by field (below) | | `env` | `['prod','dev','test']` | Environments where the seed loads | | `locale` | — (every locale) | BCP-47 tags it loads for; a locale no set of the object names gets none | @@ -78,7 +74,7 @@ A seed replays on each boot, install and re-publish. AppPlugin's boot and organi replays (not a publish or package install) do not re-insert a keyed row a person deleted; `seed-replayer` with `{ reseed: true }` restores it. -### Columns the app owns after the first load — `columns.FIELD.applyOn` +### Columns the app owns — `columns.FIELD.applyOn` For a column a job or an admin advances after the first load, declare `applyOn: 'create'`: written when the seed creates the row, left as the row @@ -103,7 +99,8 @@ differ across environments. Every record carries a value for each `externalId` field (each field of a list; `name` when the seed names none). One left blank (no value, `null` or -`''`; whitespace is a value) is refused at load in every mode: the result names +`''`; whitespace is a value) fails `os validate` / `os build` and is refused +at load in every mode: the result names the object, record index, field and fix, and the other records still load. | Scenario | Key | @@ -121,14 +118,13 @@ only breaks ties). > If a lookup value matches no natural key, the loader falls back to > resolving it as the target's `id`. Rely on it only for records you didn't -> seed (e.g. a system user). +> seed. ```typescript const contacts = defineSeed(Contact, { externalId: 'email', records: [{ email: 'john@acme.example.com', - first_name: 'John', account: 'Acme Corporation', }], }); @@ -140,8 +136,12 @@ object, one no dataset of the load seeds (misspelt, or `env`/`locale`-scoped out), or a cycle refuses the whole load; nothing is written. **Seed rows obey the object's validation rules** (all but `state_machine`); a -refused row never lands. `os validate` does not run them on seed rows; -`os verify` fails on each dropped row. A rule reading a parent roll-up +refused row never lands. `os validate` / `os build` exit 1 (`--json` too) on +each record a rule refuses, naming its location (`data[0].records[1]`), object, +index and rule. A rule the record's literals cannot decide (it reads a +reference, default, formula or roll-up; the object has a `beforeInsert` hook; +an `update` set) is counted, never refused: the load judges it, and +`os verify` fails on each dropped row. One reading a parent roll-up (`record.invoice.amount_paid`) sees the total earlier rows left, so children must fit in record order. ⛔ Never seed the roll-up: a seeded `amount_paid` is never stored (a warning per dataset); the child rows compute it. @@ -149,9 +149,9 @@ never stored (a warning per dataset); the child rows compute it. ### Dynamic values (CEL) Any field value may be a CEL expression evaluated at install time against -a single per-load pinned `now`. This is the **only** correct way to author -time-based or identity-derived seed values — `new Date()` ships the package -author's clock to every customer. +a single per-load pinned `now`. The **only** correct way to author time-based +or identity-derived values: `new Date()` ships the author's clock to every +customer. ```typescript import { cel } from '@objectstack/spec'; @@ -180,9 +180,8 @@ In TypeScript use `defineSeed()`, never `SeedSchema.parse()`: it loses compile-t **Fictional is fine; malformed is not.** A seed row passes the same field validation as a user's insert; a refused value drops the row its siblings point at. -`os validate` / `os build` refuse such a value first, at the -record's field — run them before trusting the load. So never mask or -placeholder a sample value: no `138****4207`, +`os validate` / `os build` refuse such a value first, at the record's field. +So never mask or placeholder a sample value: no `138****4207`, `***`, `XXX`, `N/A`, `—`, `TBD`. Invent a plausible well-formed one — `+86 138 0013 8000` for a `phone`, `liyy@example.com` for an `email`, `https://example.com/a` for a `url`; a `select` value is an option `value`, From 756c7b6bd6816d2ca3b433a0630b557f372b341a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 08:46:32 +0000 Subject: [PATCH 2/2] docs(skills): seeds.md names the literal values that decide a seed record's validation rule Text, number, boolean and single-select literals decide a rule; a date, JSON, multi-valued, reference or CEL value is counted, never refused. Paid by cutting restatement in the same file. Claude-Session: https://claude.ai/code/session_01QSeKYkpft1pGsKsE6d4mKS Co-authored-by: Claude --- ...37158-skills-seed-rows-refused-at-validate.md | 2 +- skills/objectstack-data/references/seeds.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.changeset/37158-skills-seed-rows-refused-at-validate.md b/.changeset/37158-skills-seed-rows-refused-at-validate.md index 08c95c8f4f8..e0acb062f2b 100644 --- a/.changeset/37158-skills-seed-rows-refused-at-validate.md +++ b/.changeset/37158-skills-seed-rows-refused-at-validate.md @@ -7,4 +7,4 @@ docs(skills): objectstack-data says `os validate` and `os build` refuse a seed r Clause-②: no Metadata-protocol: none -`references/seeds.md` said `os validate` does not run an object's validation rules on seed rows. Both commands now run them: each exits 1 (`--json` too) on a record a rule refuses, naming the record's location (`data[0].records[1]`), the object, the record index and the rule. A rule the record's literal values cannot decide (it reads a reference, a default, a formula or roll-up, or the object has a `beforeInsert` hook, or the dataset is `update`) is counted and never refused; the load still judges it, and `os verify` still fails on each dropped row. The `externalId` section now says a blank key field fails `os validate` / `os build` as well as the load. Text only; restatement elsewhere in the file is cut to pay for it. +`references/seeds.md` said `os validate` does not run an object's validation rules on seed rows. Both commands now run them: each exits 1 (`--json` too) on a record a rule refuses, naming the record's location (`data[0].records[1]`), the object, the record index and the rule. Only text, number, boolean and single-select literal values (or a field absent or `null` with no default) decide a rule. Anything else it reads (a date, JSON, multi-valued, reference or CEL value, an empty string, a formula or roll-up field), a `beforeInsert` hook on the object or an `update` dataset leaves the rule counted and never refused; the load still judges it, and `os verify` still fails on each dropped row. The `externalId` section now says a blank key field fails `os validate` / `os build` as well as the load. Text only; restatement elsewhere in the file is cut to pay for it. diff --git a/skills/objectstack-data/references/seeds.md b/skills/objectstack-data/references/seeds.md index 6efb8d579a5..2b9a7289b2c 100644 --- a/skills/objectstack-data/references/seeds.md +++ b/skills/objectstack-data/references/seeds.md @@ -14,7 +14,6 @@ import { defineSeed } from '@objectstack/spec/data'; import { Status } from '../objects/status.object'; import { Category } from '../objects/category.object'; -// Reference data — every environment export const statusSeed = defineSeed(Status, { externalId: 'code', mode: 'upsert', @@ -24,7 +23,6 @@ export const statusSeed = defineSeed(Status, { ], }); -// Demo data — dev/test only export const categorySeed = defineSeed(Category, { externalId: 'slug', env: ['dev', 'test'], @@ -40,7 +38,7 @@ export const SeedData = [statusSeed, categorySeed]; | Field | Default | Purpose | |:------|:--------|:--------| -| `object` | derived | Auto-set from `objectDef.name`; hand-written only in a runtime save (below) | +| `object` | derived | Auto-set from `objectDef.name` | | `externalId` | `'name'` | Stable business key (or field list) every mode matches on (below) | | `mode` | `'ignore'` | Import strategy (below) | | `columns` | — | Per-column write policy, keyed by field (below) | @@ -98,7 +96,7 @@ defineSeed(Invoice, { differ across environments. Every record carries a value for each `externalId` field (each field of a -list; `name` when the seed names none). One left blank (no value, `null` or +list). One left blank (no value, `null` or `''`; whitespace is a value) fails `os validate` / `os build` and is refused at load in every mode: the result names the object, record index, field and fix, and the other records still load. @@ -138,10 +136,12 @@ out), or a cycle refuses the whole load; nothing is written. **Seed rows obey the object's validation rules** (all but `state_machine`); a refused row never lands. `os validate` / `os build` exit 1 (`--json` too) on each record a rule refuses, naming its location (`data[0].records[1]`), object, -index and rule. A rule the record's literals cannot decide (it reads a -reference, default, formula or roll-up; the object has a `beforeInsert` hook; -an `update` set) is counted, never refused: the load judges it, and -`os verify` fails on each dropped row. One reading a parent roll-up +index and rule. Only text, number, boolean and single-select literals (or a +field absent or `null` with no default) decide a rule. Anything else it reads +(a date, JSON, multi-valued, reference or CEL value, `''`, a formula or +roll-up field), a `beforeInsert` hook on the object or an `update` set leaves +it counted, never refused: the load judges it, and `os verify` fails on each +dropped row. One reading a parent roll-up (`record.invoice.amount_paid`) sees the total earlier rows left, so children must fit in record order. ⛔ Never seed the roll-up: a seeded `amount_paid` is never stored (a warning per dataset); the child rows compute it.