From 8096ec94e596a96dbe9b5ae553677f6117cf6da3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:37:49 +0000 Subject: [PATCH 01/11] docs(skills): teach the {current_iso_week} period key in the query filter rules The Date Macros section of the published query skill listed the date macros and the session tokens only. It now names the period key beside them: the YYYY-Www value, the text-field-only rule, the INVALID_FILTER / 400 refusal on date, datetime and time fields, and the two date-only surfaces that refuse it. Five restatements in the same section pay first; the ratchet row moves by the measured remainder. One eval case pins the text-field / date-field split. Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- scripts/check-skills-token-ratchet.mjs | 16 ++++++++++- .../evals/filters-pagination-search.json | 10 +++++++ skills/objectstack-query/rules/filters.md | 27 ++++++++++++------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index e386fc9d6e0..bc86ce9a434 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1370,7 +1370,21 @@ export const CEILINGS = new Map([ // paragraph (home: SKILL.md, String Operators) and a second `$between` Date // example (home: the operator table's `$between` row). Arithmetic in bytes: // 9925 -> 9892 (-33 net) -> ceil(9892 / 4) = 2473; headroom 0 tokens. - ['skills/objectstack-query/rules/filters.md', 2473], + // 2473 -> 2596 (#35496): the `{current_iso_week}` period key in § Date Macros + // (its `YYYY-Www` value, the text-field-only rule, the `INVALID_FILTER` / 400 + // refusal on date / datetime / time fields, the two date-only surfaces that + // refuse it) and the client resolver that covers all three vocabularies. + // Raise path the standing ruling 「A:先削重复,余额按实测提高」 (ruling record + // 6513306068, letter B). PAID DOWN FIRST — five restatements cut in the same + // section: the wrapper regex beside the prose that already says both + // spellings parse, the code comment repeating the sentence above its block, + // the second date-macro comparison in the session-token example (the week key + // takes its place), the two per-vocabulary predicates (one predicate answers + // for all three) and the driver sentence's list of value kinds. Arithmetic in + // bytes: 9876 landed -> 10382, +506 -> 127 tokens, the row's 4 tokens of + // headroom absorbed, ceiling +123, pinned AT the measurement. + // ceil($(wc -c < skills/objectstack-query/rules/filters.md) / 4) == ceil(10382 / 4) + ['skills/objectstack-query/rules/filters.md', 2596], ['skills/objectstack-query/rules/pagination.md', 1382], // objectstack-ui `rules/` — the five files the #14296 item 1 split created. diff --git a/skills/objectstack-query/evals/filters-pagination-search.json b/skills/objectstack-query/evals/filters-pagination-search.json index 427213b337b..ca6ec196760 100644 --- a/skills/objectstack-query/evals/filters-pagination-search.json +++ b/skills/objectstack-query/evals/filters-pagination-search.json @@ -90,6 +90,16 @@ "must_contain": ["timezone: 'Asia/Taipei'", "dateGranularity: 'month'", "zonedDateBucketing", "in memory", "in the database"], "must_not_contain": ["date_trunc"] } + }, + { + "id": 10, + "prompt": "A dashboard widget over `supply_plan` must always show the current week. `plan_week` is a text field holding ISO week keys such as `2026-W47`; `ship_date` is a date field. Write the widget filter on `plan_week`, then the same week as a filter on `ship_date`.", + "expected_output": "`{ plan_week: '{current_iso_week}' }` — the period-key token resolves to today's ISO week key (`YYYY-Www`, workspace time zone, Monday-start weeks), so it matches a text field that stores those keys. It is text, not a date: on `ship_date` it is refused (`INVALID_FILTER` / 400), so the date field takes the week's boundaries, `{ ship_date: { $gte: '{current_week_start}', $lte: '{current_week_end}' } }`. No hand-computed key or date, which would freeze into the metadata.", + "files": [], + "assertions": { + "must_contain": ["plan_week: '{current_iso_week}'", "{current_week_start}", "{current_week_end}"], + "must_not_contain": ["{current_week}", "ship_date: '{current_iso_week}'"] + } } ] } diff --git a/skills/objectstack-query/rules/filters.md b/skills/objectstack-query/rules/filters.md index 2f432bcf8c8..44591ad9b3e 100644 --- a/skills/objectstack-query/rules/filters.md +++ b/skills/objectstack-query/rules/filters.md @@ -152,7 +152,6 @@ pages — cannot run code, so they use **date macro tokens** instead (defined in `@objectstack/spec` `data/date-macros.zod.ts`): ```typescript -// List-view / dashboard filter values where: { signal_at: { $gte: '{30_days_ago}' }, published_at: { $gte: '{last_quarter_start}' } @@ -164,24 +163,33 @@ where: { `{next_year_start}` (and bare aliases like `{month_start}`). - **Parameterised tokens:** `{N__ago}` / `{N__from_now}` with units `minute|hour|day|week|month|year` — e.g. `{2_weeks_from_now}`. -- **Both spellings parse:** `{today}` and `${today}` are the same token - (`DATE_MACRO_WRAPPED_RE` is `/^\$?\{([a-zA-Z0-9_]+)\}$/`, and the context - tokens share it). +- **Both spellings parse:** `{today}` and `${today}` are the same token, in + every vocabulary here. + +**Period key** (`PERIOD_KEY_TOKENS`, not a date macro): `{current_iso_week}` +is today's ISO week key, `YYYY-Www`, in the workspace time zone — Monday-start +weeks, the ISO week-year at year edges (2027-01-01 is `2026-W53`). It is text, +for a text field storing week keys. A `date` / `datetime` / `time` field +refuses it (`INVALID_FILTER` / 400) like the literal key — use +`{current_week_start}` / `{current_week_end}` there — as do a date dashboard +filter's `defaultValue` and `calendar.initialDate`; a text dashboard filter +may default to it. There is no last- or next-week key. **Session tokens:** the same value positions accept `{current_user_id}` and `{current_org_id}` (defined in `data/context-tokens.zod.ts`) — the signed-in user's id and the active organization id. ```typescript -where: { owner_id: '{current_user_id}', close_date: { $gte: '{current_year_start}' } } +where: { owner_id: '{current_user_id}', cost_week: '{current_iso_week}' } ``` **Scope:** tokens expand on **both** sides of the wire — client-side by -`resolveDateMacros()` / `resolveContextTokens()` in `@object-ui/core`, +`resolveFilterPlaceholders()` in `@object-ui/core` (`resolveDateMacros()`, +`resolvePeriodKeyTokens()` and `resolveContextTokens()` in one call), server-side by `resolveFilterTokens()` in `@objectstack/core`, wired into the ObjectQL read AND write paths (`find`/`findOne`/`count`/`aggregate`/`update`/ -`delete`) plus the analytics dataset executor. The driver only ever sees ISO -strings and concrete ids. So use tokens in a hand-issued engine query too: +`delete`) plus the analytics dataset executor. The driver only ever sees +resolved values. So use tokens in a hand-issued engine query too: computing "today" at module load freezes the date into the built artifact. A **flow node's** `config.filter` takes these tokens too. What a dropped @@ -200,8 +208,7 @@ indistinguishable from "there is no data". Near-misses, not tokens: (a real `titleFormat` interpolation) and `{organization_id}` (the column name); the error names the correction. A value that merely *contains* braces is left untouched — `'user-{current_user_id}'` is a literal. Check a spelling with -`isDateMacroToken(tok)` / `isContextToken(tok)` from `@objectstack/spec/data`, -WITHOUT braces. +`isKnownFilterToken(tok)` from `@objectstack/spec/data`, WITHOUT braces. **`*_end` is a calendar DAY; an upper bound means the WHOLE day.** `<= {current_year_end}` already reaches the final instant of Dec 31 From 47fe01057286d676b52fa7417ebb33b8e4d5a574 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:39:32 +0000 Subject: [PATCH 02/11] chore(changeset): patch note for the query skill's period-key text Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .changeset/35496-skills-filters-iso-week-key.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/35496-skills-filters-iso-week-key.md diff --git a/.changeset/35496-skills-filters-iso-week-key.md b/.changeset/35496-skills-filters-iso-week-key.md new file mode 100644 index 00000000000..32d05e7af06 --- /dev/null +++ b/.changeset/35496-skills-filters-iso-week-key.md @@ -0,0 +1,10 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the query skill teaches the `{current_iso_week}` period key + +Clause-②: no +Metadata-protocol: none + +objectstack-query's `rules/filters.md`, section "Date Macros", now names the period key beside the date macros and the session tokens. `{current_iso_week}` (or `${current_iso_week}`) resolves to today's ISO week key, `YYYY-Www`, in the workspace time zone: Monday-start weeks, the ISO week-year at year edges. It is text, for a text field that stores week keys. A `date`, `datetime` or `time` field refuses it with `INVALID_FILTER` / 400, as it refuses the literal key; a date dashboard filter's `defaultValue` and `calendar.initialDate` refuse it too. On a date field write `{current_week_start}` / `{current_week_end}`. The section also names `resolveFilterPlaceholders()` as the client resolver for all three vocabularies and `isKnownFilterToken()` as the one spelling check. One eval case covers the text-field / date-field split. From 03b9383fe650bc28ab46ddb14fb9c70bb118ea1d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:39:40 +0000 Subject: [PATCH 03/11] docs(skills): data-hooks teaches the hook and job js-body compile refusal Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .../35714-data-hooks-body-compile-refusal.md | 15 +++++++++ .../hooks-security-seeds-datasources.json | 10 ++++++ .../objectstack-data/references/data-hooks.md | 31 +++++++++---------- 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 .changeset/35714-data-hooks-body-compile-refusal.md diff --git a/.changeset/35714-data-hooks-body-compile-refusal.md b/.changeset/35714-data-hooks-body-compile-refusal.md new file mode 100644 index 00000000000..8cfeed1d05c --- /dev/null +++ b/.changeset/35714-data-hooks-body-compile-refusal.md @@ -0,0 +1,15 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the hooks skill says a hook or job `js` body that does not compile is refused, and how to fix it + +Clause-②: no +Metadata-protocol: none + +objectstack-data's `references/data-hooks.md`, "Sandbox restrictions": + +- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern only the checking engine refuses is a warning. +- Six restatements in the same file were removed to pay for the new text; the file is three lines and five tokens shorter than before. + +`evals/hooks-security-seeds-datasources.json` gains one case on the refusal and its fix. diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index c0242d92b87..1c7663d6b63 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -326,6 +326,16 @@ "amount_paid: 2000" ] } + }, + { + "id": 33, + "prompt": "`os validate` reports an error on this `beforeInsert` hook on `lead`, and I cannot see why: `body: { language: 'js', source: \"const ctx = ctx.input || {}; if (!ctx.status) ctx.status = 'new';\", capabilities: [] }`. What is wrong, and what should the source be?", + "expected_output": "The `js` source is compiled inside the wrapper the runtime runs it in, `(async (ctx) => { … })`, where `ctx` is already the parameter: `const ctx = …` declares it a second time, a SyntaxError before any statement runs. The finding is `hook-body-does-not-compile`, an error from `os validate`, `os build` and `os lint`, and a runtime save of the hook is refused with `422 INVALID_METADATA`. Fix: use `ctx` as it is (`if (!ctx.input.status) ctx.input.status = 'new';`) or give the local another name (`const input = ctx.input || {};`). Does not suppress the rule, and does not move the logic to a deprecated `handler`.", + "files": [], + "assertions": { + "must_contain": ["hook-body-does-not-compile", "ctx.input.status"], + "must_not_contain": [] + } } ] } diff --git a/skills/objectstack-data/references/data-hooks.md b/skills/objectstack-data/references/data-hooks.md index f3c8acfcff8..03d59d37ca6 100644 --- a/skills/objectstack-data/references/data-hooks.md +++ b/skills/objectstack-data/references/data-hooks.md @@ -123,11 +123,6 @@ const myHook = defineHook({ ### Key Properties Explained -#### `body` — Implementation - -A `source` of statements against `ctx`; a throw aborts the write -([Sandboxed Hook Bodies](#sandboxed-hook-bodies-body--what-the-sandbox-ctx-can-call)). - #### `condition` — Declarative Filtering Skip the hook if the condition is false. Author it as a **CEL @@ -155,9 +150,7 @@ made total over the object's **declared** fields (`null` when a declared field i in neither). So: - Reference **any** declared field, not just the ones this update touches — - `record.done == true` works on an update that only sets `status`. (This is - unlike `ctx.input` / `ctx.result` inside the body, which stay partial — see - Gotcha 1.) + `record.done == true` works on an update that only sets `status`. - `record` describes the record's **state**, not the diff. `record.done == true` fires on every update of an already-done record, not only on the update that set it. **For the transition, compare against `previous`**: @@ -344,6 +337,15 @@ The body runs in an isolated QuickJS VM, **not** Node: a name bound at module scope, e.g. a `const slugify = …` helper sitting next to the hook. A `body` must be **self-contained**: inline the helper, or keep that hook as a bundled (deprecated) `handler`. +- **Refused when it does not compile:** a `js` source is compiled, unrun, inside + its `(async (ctx) => { … })` wrapper, where `ctx` is already declared. So + `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any + syntax error) is `hook-body-does-not-compile`: an **error** from `os validate`, + `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming + the hook, the `SyntaxError` and its line. Fix: use `ctx` as it is, or rename + the local (`const input = ctx.input || {};`). A job's `js` body runs in the + same wrapper: `job-body-does-not-compile`, from the three commands. A regex + pattern only the checking engine refuses is a warning. > **A deadline stamped from an hours table is calendar hours** — nights, weekends and > holidays count. Name it `*_CALENDAR_HOURS` (`SLA_CALENDAR_HOURS`, or its camelCase) @@ -450,8 +452,7 @@ interface HookContext { // Execution context session?: { userId?: string; - organizationId?: string; // Active org — the single blessed name. Matches the - // `organization_id` column + `current_user.organizationId` (RLS). + organizationId?: string; // Active org — the single blessed name. // The former `tenantId` alias was removed in v16. // Privilege is judged by the security service, // never by a session claim. @@ -660,11 +661,8 @@ const cascadeAccountUpdate = defineHook({ A `body` cannot do this: it writes back only `ctx.input`, and its `ctx.result` is a snapshot. -> For **static** field masking (a field is always hidden/masked for a permission -> set or position), prefer declarative **field-level metadata** (secret/masked -> fields) — it applies on every read path automatically. Use an `afterFind` hook -> only for masking that depends on runtime logic the field metadata can't -> express. +> Static masking is declarative **field-level metadata** (secret/masked fields); +> an `afterFind` hook is only for masking that depends on runtime logic. ```typescript const maskSensitiveData = defineHook({ @@ -674,7 +672,6 @@ const maskSensitiveData = defineHook({ handler: async (ctx) => { // Exempt the engine's own elevated reads (`isSystem`) — internal writes // and self-reads must see the real values. - // ⚠️ Never a session claim (`ctx.session.roles` is gone, ctx table above). const isElevated = ctx.session?.isSystem === true; if (!isElevated) { @@ -777,7 +774,7 @@ the layout both real hook modules in the repo use. ## Best Practices -✅ **DO** — use `before*` for validation and `after*` for side effects; set +✅ **DO** — set `async: true` for non-critical background work; go through `ctx.api` for cross-object operations; refuse a business rule by a [declared code](#declared-refusals-refusals); test hooks in isolation. From 1c7cebae82240c60cfd93d7b268bab7ae14ff442 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:54:47 +0000 Subject: [PATCH 04/11] docs(skills): a master_detail child is a record-page body table by default The data and ui skills tied the record-page body table to inlineEdit. They now teach the rule isBodyTableRelationship applies: a master_detail FK with no relatedList is a body table, a lookup FK with none is a panel, and inlineEdit governs entry in the parent's form only. Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .../35692-skills-master-detail-body-table.md | 16 ++++++++++++++++ skills/objectstack-data/rules/relationships.md | 15 ++++++--------- skills/objectstack-ui/evals/README.md | 2 +- skills/objectstack-ui/evals/record-page.json | 5 +++-- skills/objectstack-ui/rules/record-page.md | 8 ++++---- 5 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 .changeset/35692-skills-master-detail-body-table.md diff --git a/.changeset/35692-skills-master-detail-body-table.md b/.changeset/35692-skills-master-detail-body-table.md new file mode 100644 index 00000000000..4d92cb7d912 --- /dev/null +++ b/.changeset/35692-skills-master-detail-body-table.md @@ -0,0 +1,16 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the data and ui skills teach that a `master_detail` child is a record-page body table by default + +Clause-②: no +Metadata-protocol: none + +The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies. + +- objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table. +- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn above the field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. +- objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows. + +Both rules files are shorter than before. No ceiling moves. diff --git a/skills/objectstack-data/rules/relationships.md b/skills/objectstack-data/rules/relationships.md index 8cad00d2b0a..3109d864bb7 100644 --- a/skills/objectstack-data/rules/relationships.md +++ b/skills/objectstack-data/rules/relationships.md @@ -345,16 +345,14 @@ InvoiceLine = { ### Detail-page related lists (the read-side mirror) You usually don't declare the **related list** on the parent's record detail page: every child relationship -(`master_detail` and `lookup`) is shown **by default** — owned (`master_detail`) -children first. The relationship -flags exist to *refine* that: +is shown **by default** — a `master_detail` child as a body table, a `lookup` +child as a panel. `inlineEdit` plays no part: it governs entry in the parent's +form only. The relationship flags *refine* that: ```typescript project: { type: 'master_detail', - reference: 'project', - inlineEdit: true, - relatedList: 'primary', // read side: a body table + reference: 'project', // no relatedList: a body table relatedListTitle: 'Tasks', relatedListColumns: ['title', 'status', 'priority', 'due_date'], }, @@ -365,10 +363,9 @@ audit_ref: { type: 'master_detail', reference: 'invoice', relatedList: false }, `relatedList` is tri-state — placement: -- `'primary'` — a full-width table in the record's detail body. Default for a `master_detail` FK with `inlineEdit`. +- `'primary'` — a full-width table in the record's detail body. Default for a `master_detail` FK. - `false` — the child object is not shown on the parent record page. -- `true`, or omitted (except inline-edited `master_detail`) — an auxiliary - panel on the record page. +- `true` — an auxiliary panel on the record page. Default for a `lookup` FK. - Order is the parent's: `relatedLists: ['task', 'event.related_to']` (child, or `object.field`) lists those first. A child in the stack with no inbound FK is refused everywhere; one that exists nowhere is refused by `os validate` / diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index 2bc42952c4a..35e01abd21a 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -12,7 +12,7 @@ view / page / dashboard / report metadata. for a Chinese brief, whose members carry Chinese `synonyms` and a one-sentence `description`. - `record-page.json` — the record page as the object declares it: a child - table placed first by `relatedList: 'primary'` (no page file), + table a `master_detail` field already places, ordered first (no page file), `navigation: { mode: 'page' }` on the list view with the reader's own open choice left out of metadata, and `placedActions: true` on a full page's `page:header` so packaged header actions draw without an id list. diff --git a/skills/objectstack-ui/evals/record-page.json b/skills/objectstack-ui/evals/record-page.json index 8e82e621480..5b4ec6d3038 100644 --- a/skills/objectstack-ui/evals/record-page.json +++ b/skills/objectstack-ui/evals/record-page.json @@ -4,14 +4,15 @@ { "id": 1, "prompt": "On the lead record page, put the tasks first: our reps want the open tasks table before anything else when they open a lead. The `task` object already has a `lead` master_detail field.", - "expected_output": "No page file. One flag on the child's reference field — `relatedList: 'primary'` on `task.lead` — makes the tasks a full-width body table in the lead's details, after the first field section; `relatedListFilter: { status: { $ne: 'done' } }` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other lists. Not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", + "expected_output": "No page file, and no placement flag on `task.lead`: a `master_detail` field that declares no `relatedList` is already a full-width body table in the lead's details, above the field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other tables. Not `inlineEdit` (that is entry inside the lead's form, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", "files": [], "assertions": { "must_contain": [ - "relatedList: 'primary'", + "relatedListFilter", "relatedLists" ], "must_not_contain": [ + "inlineEdit:", "definePage(", "slots: { tabs", "kind: 'full'," diff --git a/skills/objectstack-ui/rules/record-page.md b/skills/objectstack-ui/rules/record-page.md index c2cfd4f6da2..5190d4521d8 100644 --- a/skills/objectstack-ui/rules/record-page.md +++ b/skills/objectstack-ui/rules/record-page.md @@ -16,15 +16,15 @@ one tab per panel with its count) enlarges a panel at `?related=object.field`. **2 · Relationship flags shape the related column.** On the CHILD object's reference field: `relatedList: 'primary'` draws the child as a full-width body -table in the details after the first field section (the default for a -`master_detail` with `inlineEdit`); `true` / absent is a panel in the right +table in the details above the field sections (the default for a +`master_detail`); `true` (a `lookup`'s default) is a panel in the right column; `false` leaves the child off the page. `relatedListTitle` / `relatedListColumns` (child field names) replace the derived title / columns; `relatedListFilter` (Query-DSL, `{ status: { $ne: 'done' } }`) is AND-composed with the parent condition, and the panel's count honours it. Rows follow the child's default list view `sort` (`isDefault`, else the first declared); the parent's `relatedLists` orders tables and panels alike. "Put the tasks first on -the lead page" is `relatedList: 'primary'` on `task.lead` — no page file. +the lead page" is `relatedLists: ['task']` on `lead` — no page file. **3 · A slotted page overrides one slot.** `kind: 'slotted'` replaces only the slots it names — `header`, `actions`, `alerts`, `highlights`, `details`, @@ -59,7 +59,7 @@ import { Field, ObjectSchema } from '@objectstack/spec/data'; export const Task = ObjectSchema.create({ name: 'task', sharingModel: 'controlled_by_parent', fields: { - lead: Field.masterDetail('lead', { relatedList: 'primary', relatedListFilter: { status: { $ne: 'done' } } }), + lead: Field.masterDetail('lead', { relatedListFilter: { status: { $ne: 'done' } } }), // a body table }, }); ``` From b3b374b39eae3e6564ce5953391e2ac8a8f90b69 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:58:41 +0000 Subject: [PATCH 05/11] docs(skills): a seed record with a blank key field is refused at load (seeds.md) `skills/objectstack-data/references/seeds.md` teaches the load refusal main makes for a keyed seed record that leaves an `externalId` field blank, with one eval case (id 34). Three restatements in the same file are cut first; the token ceiling row moves by the measured remainder (1759 -> 1812) under the standing ruling (record 6513306068). Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .changeset/35480-seeds-load-and-save-refusals.md | 15 +++++++++++++++ scripts/check-skills-token-ratchet.mjs | 12 +++++++++++- .../evals/hooks-security-seeds-datasources.json | 10 ++++++++++ skills/objectstack-data/references/seeds.md | 16 +++++++++------- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 .changeset/35480-seeds-load-and-save-refusals.md diff --git a/.changeset/35480-seeds-load-and-save-refusals.md b/.changeset/35480-seeds-load-and-save-refusals.md new file mode 100644 index 00000000000..cd984749d65 --- /dev/null +++ b/.changeset/35480-seeds-load-and-save-refusals.md @@ -0,0 +1,15 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the data skill says a seed record with a blank key field is refused at load + +Clause-②: no +Metadata-protocol: none + +objectstack-data's `references/seeds.md`: + +- "`externalId` selection" says every record carries a value for each `externalId` field (each field of a list, or `name` when the seed names none), and that a record leaving one blank (no value, `null` or `''`; whitespace is a value) is refused at load in every mode: the load result names the object, the record index, the field and the fix, and the other records still load. The `externalId` row of the field table points at it. +- Three restatements in the same file were removed to pay for part of the new text: the `columns` row's shape literal, the one-row best-practices table (now a sentence) and the second telling of what a refused seed value leaves behind. + +`evals/hooks-security-seeds-datasources.json` gains one case on the refusal. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index e386fc9d6e0..518dc2de77a 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1846,7 +1846,17 @@ export const CEILINGS = new Map([ // 6984 -> 6570 after the cuts (-414); the teaching nets +466 -> 7036 -> // ceil(7036 / 4) = 1759; headroom was 0, so the ceiling moves +13, the // measured remainder only. Pinned AT the measurement. - ['skills/objectstack-data/references/seeds.md', 1759], + // 1759 -> 1812: `### externalId selection` says every record carries a value + // for each `externalId` field and that a blank one is refused at load, and the + // `externalId` row points at it. Raise path the standing ruling + // 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN + // FIRST — restatement cut in the same file: the `columns` row's shape literal + // (its own section shows it), the one-row best-practices table (a sentence + // now) and the second telling of what a refused seed value leaves behind. + // Arithmetic in bytes: 7033 -> 6905 after the cuts (-128); the teaching nets + // +340 -> 7245 -> ceil(7245 / 4) = 1812; headroom was 0, so the ceiling moves + // +53, the measured remainder only. Pinned AT the measurement. + ['skills/objectstack-data/references/seeds.md', 1812], // 1351 -> 1343: the body-pin values left the count (#31115, ruling B; see // BODY_PIN_REPIN); the file's count fell by the same 8, headroom unchanged. ['skills/objectstack-platform/references/bootstrap.md', 1343], diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index c0242d92b87..3d1fda16ca9 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -61,6 +61,16 @@ "must_not_contain": [] } }, + { + "id": 34, + "prompt": "Our `sales_team` seed is `upsert`, keyed on `externalId: 'code'`. Two of its ten records have no `code` yet; we want to load all ten now and fill those two codes in later. Write the seed.", + "expected_output": "Redirects: the two records cannot load without a `code`. Every record carries a value for each `externalId` field, and a record that leaves one blank (no value, `null` or `''`) is refused at load: the load result names the object, the record index, the blank field and the fix, and the other eight records still load. So the answer gives those two records a real `code` now (`defineSeed(SalesTeam, { externalId: 'code', mode: 'upsert', records })` with ten codes), or keys the seed on a field every record carries. It does not write `code: ''` or `code: null`, does not pad the key with whitespace to pass, and does not switch the mode: `ignore`, `upsert` and `update` all refuse the record.", + "files": [], + "assertions": { + "must_contain": ["defineSeed", "externalId", "refused"], + "must_not_contain": ["code: ''", "code: null"] + } + }, { "id": 5, "prompt": "Finance may edit a contract's legal terms (`governing_law`, `liability_cap`) while it is a draft, not once approved, signing or active; legal still edits them.", diff --git a/skills/objectstack-data/references/seeds.md b/skills/objectstack-data/references/seeds.md index 3c9597261e0..3b089720490 100644 --- a/skills/objectstack-data/references/seeds.md +++ b/skills/objectstack-data/references/seeds.md @@ -45,9 +45,9 @@ export const SeedData = [statusSeed, categorySeed]; | Field | Default | Purpose | |:------|:--------|:--------| | `object` | derived | Auto-set from `objectDef.name` — never write manually | -| `externalId` | `'name'` | Stable business key (or field list) every mode matches on | +| `externalId` | `'name'` | Stable business key (or field list) every mode matches on; required in every record (below) | | `mode` | `'ignore'` | Import strategy (see below) | -| `columns` | — | Per-column write policy, keyed by field: `{ FIELD: { applyOn: 'create' } }` (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 | | `fallback` | — | `true` on ONE `locale` set per object: also loads for a locale no set names | @@ -95,6 +95,11 @@ defineSeed(Invoice, { **Never use `id`** for generated UUIDs — they 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 +the object, record index, field and fix, and the other records still load. + | Scenario | Key | |:---------|:----| | Named entities (country, currency) | `'code'` / `'slug'` | @@ -165,13 +170,10 @@ produce byte-identical `dist/objectstack.json`. ### Seed best practices -| Practice | Why | -|:---------|:----| -| TypeScript: `defineSeed()`, never `SeedSchema.parse()` | Lose compile-time field checks otherwise | +In TypeScript use `defineSeed()`, never `SeedSchema.parse()`: it loses compile-time field checks. **Fictional is fine; malformed is not.** A seed row passes the same field -validation as a user's insert; a refused value leaves the table short or empty -while sibling rows point at records that do not exist. +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`, From 20c06ad509ca413099b8c9eadc9a0855291d6ae1 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 04:59:11 +0000 Subject: [PATCH 06/11] docs(skills): a saved seed must name an existing object (seeds.md) `skills/objectstack-data/references/seeds.md` teaches the save door's 422 for a runtime-saved seed whose `object` resolves to nothing, and that a draft object is enough for a draft seed, with one eval case (id 35). The token ceiling row moves by the measured remainder (1812 -> 1898) under the standing ruling (record 6513306068). Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .changeset/35480-seeds-load-and-save-refusals.md | 5 +++-- scripts/check-skills-token-ratchet.mjs | 9 ++++++++- .../evals/hooks-security-seeds-datasources.json | 10 ++++++++++ skills/objectstack-data/references/seeds.md | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.changeset/35480-seeds-load-and-save-refusals.md b/.changeset/35480-seeds-load-and-save-refusals.md index cd984749d65..60ec4ed1285 100644 --- a/.changeset/35480-seeds-load-and-save-refusals.md +++ b/.changeset/35480-seeds-load-and-save-refusals.md @@ -2,7 +2,7 @@ '@objectstack/skills': patch --- -docs(skills): the data skill says a seed record with a blank key field is refused at load +docs(skills): the data skill says a seed record with a blank key field is refused at load, and a saved seed naming an unknown object is refused 422 Clause-②: no Metadata-protocol: none @@ -10,6 +10,7 @@ Metadata-protocol: none objectstack-data's `references/seeds.md`: - "`externalId` selection" says every record carries a value for each `externalId` field (each field of a list, or `name` when the seed names none), and that a record leaving one blank (no value, `null` or `''`; whitespace is a value) is refused at load in every mode: the load result names the object, the record index, the field and the fix, and the other records still load. The `externalId` row of the field table points at it. +- The note under the field table says a `seed` saved at runtime names its `object` itself, and that one resolving to nothing is refused with `422 INVALID_METADATA` at `object` ("which is not defined"). The fix is the object's full name (`crm_lead`, not `lead`) or creating the object first: a draft of it is enough for a draft seed, a live seed needs it published. The `object` row points at the note. - Three restatements in the same file were removed to pay for part of the new text: the `columns` row's shape literal, the one-row best-practices table (now a sentence) and the second telling of what a refused seed value leaves behind. -`evals/hooks-security-seeds-datasources.json` gains one case on the refusal. +`evals/hooks-security-seeds-datasources.json` gains one case on each refusal. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 518dc2de77a..c018d79e581 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1856,7 +1856,14 @@ export const CEILINGS = new Map([ // Arithmetic in bytes: 7033 -> 6905 after the cuts (-128); the teaching nets // +340 -> 7245 -> ceil(7245 / 4) = 1812; headroom was 0, so the ceiling moves // +53, the measured remainder only. Pinned AT the measurement. - ['skills/objectstack-data/references/seeds.md', 1812], + // 1812 -> 1898: the note under the field table says a `seed` saved at runtime + // names an object that exists or the save answers `422 INVALID_METADATA` at + // `object`, and that a draft object is enough for a draft seed; the `object` + // row points at it in place of "never write manually". Same raise path and + // the same paydown as the step above (one PR, the cuts are its deletion): + // 7245 -> 7590 bytes (+345) -> ceil(7590 / 4) = 1898; headroom was 0, so the + // ceiling moves +86, the measured remainder only. Pinned AT the measurement. + ['skills/objectstack-data/references/seeds.md', 1898], // 1351 -> 1343: the body-pin values left the count (#31115, ruling B; see // BODY_PIN_REPIN); the file's count fell by the same 8, headroom unchanged. ['skills/objectstack-platform/references/bootstrap.md', 1343], diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index 3d1fda16ca9..6c76217979b 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -71,6 +71,16 @@ "must_not_contain": ["code: ''", "code: null"] } }, + { + "id": 35, + "prompt": "In the running app I saved a draft `seed` item with `object: 'lead'` and three records, through the metadata save. The save answered 422. Our lead object is `crm_lead`, still a draft in the same package. What is wrong, and what do I save instead?", + "expected_output": "The seed names an object that does not exist: the save door refuses a `seed` whose `object` resolves to nothing with `422 INVALID_METADATA`, one finding at `object` saying the seed loads its records into object 'lead', which is not defined, so publishing it would load no record. The fix is the object's full name: save the seed with `object: 'crm_lead'`. The draft `crm_lead` is enough for a draft seed, so nothing has to be published first; a live (published) seed needs the object published. Does not create a second `lead` object to satisfy the save and does not retry the same body.", + "files": [], + "assertions": { + "must_contain": ["422", "crm_lead", "not defined"], + "must_not_contain": [] + } + }, { "id": 5, "prompt": "Finance may edit a contract's legal terms (`governing_law`, `liability_cap`) while it is a draft, not once approved, signing or active; legal still edits them.", diff --git a/skills/objectstack-data/references/seeds.md b/skills/objectstack-data/references/seeds.md index 3b089720490..3b1bffdba93 100644 --- a/skills/objectstack-data/references/seeds.md +++ b/skills/objectstack-data/references/seeds.md @@ -44,7 +44,7 @@ export const SeedData = [statusSeed, categorySeed]; | Field | Default | Purpose | |:------|:--------|:--------| -| `object` | derived | Auto-set from `objectDef.name` — never write manually | +| `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) | | `columns` | — | Per-column write policy, keyed by field (below) | @@ -56,6 +56,12 @@ export const SeedData = [statusSeed, categorySeed]; Full Zod shape: `node_modules/@objectstack/spec/src/data/seed.zod.ts`. +A `seed` saved at runtime names its `object` itself. One that resolves to +nothing is refused: `422 INVALID_METADATA` at `object`, "which is not defined". +Correct the name to the object's full name (`crm_lead`, not `lead`) or create +the object first: a draft of it is enough for a draft seed; a live seed needs +it published. + ### Import modes | Mode | Behavior | Use for | From 1ea279acf8342737490822e8a70acefd05d7f94a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 05:04:39 +0000 Subject: [PATCH 07/11] docs(skills): shorten the record-page eval text Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- skills/objectstack-ui/evals/README.md | 2 +- skills/objectstack-ui/evals/record-page.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index 35e01abd21a..3bfea55d099 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -12,7 +12,7 @@ view / page / dashboard / report metadata. for a Chinese brief, whose members carry Chinese `synonyms` and a one-sentence `description`. - `record-page.json` — the record page as the object declares it: a child - table a `master_detail` field already places, ordered first (no page file), + body table ordered first by `relatedLists` (no page file), `navigation: { mode: 'page' }` on the list view with the reader's own open choice left out of metadata, and `placedActions: true` on a full page's `page:header` so packaged header actions draw without an id list. diff --git a/skills/objectstack-ui/evals/record-page.json b/skills/objectstack-ui/evals/record-page.json index 5b4ec6d3038..1323977373e 100644 --- a/skills/objectstack-ui/evals/record-page.json +++ b/skills/objectstack-ui/evals/record-page.json @@ -4,7 +4,7 @@ { "id": 1, "prompt": "On the lead record page, put the tasks first: our reps want the open tasks table before anything else when they open a lead. The `task` object already has a `lead` master_detail field.", - "expected_output": "No page file, and no placement flag on `task.lead`: a `master_detail` field that declares no `relatedList` is already a full-width body table in the lead's details, above the field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other tables. Not `inlineEdit` (that is entry inside the lead's form, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", + "expected_output": "No page file and no placement flag: `task.lead` is a `master_detail` with no `relatedList`, so it is already a full-width body table above the lead's field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other tables. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", "files": [], "assertions": { "must_contain": [ From 0c9f76eb3aea9fa666213acbaecc2743baf8eb2f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 05:27:11 +0000 Subject: [PATCH 08/11] docs(skills): the regex-pattern warning says what main says; eval case 33 accepts either repair Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .changeset/35714-data-hooks-body-compile-refusal.md | 4 ++-- .../evals/hooks-security-seeds-datasources.json | 4 ++-- skills/objectstack-data/references/data-hooks.md | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.changeset/35714-data-hooks-body-compile-refusal.md b/.changeset/35714-data-hooks-body-compile-refusal.md index 8cfeed1d05c..428cf444007 100644 --- a/.changeset/35714-data-hooks-body-compile-refusal.md +++ b/.changeset/35714-data-hooks-body-compile-refusal.md @@ -9,7 +9,7 @@ Metadata-protocol: none objectstack-data's `references/data-hooks.md`, "Sandbox restrictions": -- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern only the checking engine refuses is a warning. -- Six restatements in the same file were removed to pay for the new text; the file is three lines and five tokens shorter than before. +- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern the checking engine refuses is a warning: the runtime may accept it. +- Six restatements in the same file were removed to pay for the new text; the file is four lines shorter and no larger in tokens than before. `evals/hooks-security-seeds-datasources.json` gains one case on the refusal and its fix. diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index 1c7663d6b63..129cc878282 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -330,10 +330,10 @@ { "id": 33, "prompt": "`os validate` reports an error on this `beforeInsert` hook on `lead`, and I cannot see why: `body: { language: 'js', source: \"const ctx = ctx.input || {}; if (!ctx.status) ctx.status = 'new';\", capabilities: [] }`. What is wrong, and what should the source be?", - "expected_output": "The `js` source is compiled inside the wrapper the runtime runs it in, `(async (ctx) => { … })`, where `ctx` is already the parameter: `const ctx = …` declares it a second time, a SyntaxError before any statement runs. The finding is `hook-body-does-not-compile`, an error from `os validate`, `os build` and `os lint`, and a runtime save of the hook is refused with `422 INVALID_METADATA`. Fix: use `ctx` as it is (`if (!ctx.input.status) ctx.input.status = 'new';`) or give the local another name (`const input = ctx.input || {};`). Does not suppress the rule, and does not move the logic to a deprecated `handler`.", + "expected_output": "The `js` source is compiled inside the wrapper the runtime runs it in, `(async (ctx) => { … })`, where `ctx` is already the parameter: `const ctx = …` declares it a second time, a SyntaxError before any statement runs. The finding is `hook-body-does-not-compile`, an error from `os validate`, `os build` and `os lint`, and a runtime save of the hook is refused with `422 INVALID_METADATA`. Fix: use `ctx` as it is (`if (!ctx.input.status) ctx.input.status = 'new';`) or give the local another name (`const input = ctx.input || {}; if (!input.status) input.status = 'new';`). Does not suppress the rule, and does not move the logic to a deprecated `handler`.", "files": [], "assertions": { - "must_contain": ["hook-body-does-not-compile", "ctx.input.status"], + "must_contain": ["hook-body-does-not-compile", "input.status"], "must_not_contain": [] } } diff --git a/skills/objectstack-data/references/data-hooks.md b/skills/objectstack-data/references/data-hooks.md index 03d59d37ca6..22c88f9b4aa 100644 --- a/skills/objectstack-data/references/data-hooks.md +++ b/skills/objectstack-data/references/data-hooks.md @@ -345,7 +345,7 @@ The body runs in an isolated QuickJS VM, **not** Node: the hook, the `SyntaxError` and its line. Fix: use `ctx` as it is, or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper: `job-body-does-not-compile`, from the three commands. A regex - pattern only the checking engine refuses is a warning. + pattern the checking engine refuses is a warning: the runtime may accept it. > **A deadline stamped from an hours table is calendar hours** — nights, weekends and > holidays count. Name it `*_CALENDAR_HOURS` (`SLA_CALENDAR_HOURS`, or its camelCase) @@ -774,9 +774,8 @@ the layout both real hook modules in the repo use. ## Best Practices -✅ **DO** — set -`async: true` for non-critical background work; go through `ctx.api` for -cross-object operations; refuse a business rule by a +✅ **DO** — set `async: true` for non-critical background work; go through +`ctx.api` for cross-object operations; refuse a business rule by a [declared code](#declared-refusals-refusals); test hooks in isolation. ❌ **DON'T** — do expensive work in `before*` (it blocks the transaction); write From 0c80caa0b5c8112be057a786407e46bf9110d3aa Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 05:31:32 +0000 Subject: [PATCH 09/11] chore(changeset): one patch note for the folded skills text Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .../35480-seeds-load-and-save-refusals.md | 16 --------- .../35496-skills-filters-iso-week-key.md | 10 ------ ...496-skills-teach-five-landed-behaviours.md | 35 +++++++++++++++++++ .../35692-skills-master-detail-body-table.md | 16 --------- .../35714-data-hooks-body-compile-refusal.md | 15 -------- 5 files changed, 35 insertions(+), 57 deletions(-) delete mode 100644 .changeset/35480-seeds-load-and-save-refusals.md delete mode 100644 .changeset/35496-skills-filters-iso-week-key.md create mode 100644 .changeset/35496-skills-teach-five-landed-behaviours.md delete mode 100644 .changeset/35692-skills-master-detail-body-table.md delete mode 100644 .changeset/35714-data-hooks-body-compile-refusal.md diff --git a/.changeset/35480-seeds-load-and-save-refusals.md b/.changeset/35480-seeds-load-and-save-refusals.md deleted file mode 100644 index 60ec4ed1285..00000000000 --- a/.changeset/35480-seeds-load-and-save-refusals.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'@objectstack/skills': patch ---- - -docs(skills): the data skill says a seed record with a blank key field is refused at load, and a saved seed naming an unknown object is refused 422 - -Clause-②: no -Metadata-protocol: none - -objectstack-data's `references/seeds.md`: - -- "`externalId` selection" says every record carries a value for each `externalId` field (each field of a list, or `name` when the seed names none), and that a record leaving one blank (no value, `null` or `''`; whitespace is a value) is refused at load in every mode: the load result names the object, the record index, the field and the fix, and the other records still load. The `externalId` row of the field table points at it. -- The note under the field table says a `seed` saved at runtime names its `object` itself, and that one resolving to nothing is refused with `422 INVALID_METADATA` at `object` ("which is not defined"). The fix is the object's full name (`crm_lead`, not `lead`) or creating the object first: a draft of it is enough for a draft seed, a live seed needs it published. The `object` row points at the note. -- Three restatements in the same file were removed to pay for part of the new text: the `columns` row's shape literal, the one-row best-practices table (now a sentence) and the second telling of what a refused seed value leaves behind. - -`evals/hooks-security-seeds-datasources.json` gains one case on each refusal. diff --git a/.changeset/35496-skills-filters-iso-week-key.md b/.changeset/35496-skills-filters-iso-week-key.md deleted file mode 100644 index 32d05e7af06..00000000000 --- a/.changeset/35496-skills-filters-iso-week-key.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'@objectstack/skills': patch ---- - -docs(skills): the query skill teaches the `{current_iso_week}` period key - -Clause-②: no -Metadata-protocol: none - -objectstack-query's `rules/filters.md`, section "Date Macros", now names the period key beside the date macros and the session tokens. `{current_iso_week}` (or `${current_iso_week}`) resolves to today's ISO week key, `YYYY-Www`, in the workspace time zone: Monday-start weeks, the ISO week-year at year edges. It is text, for a text field that stores week keys. A `date`, `datetime` or `time` field refuses it with `INVALID_FILTER` / 400, as it refuses the literal key; a date dashboard filter's `defaultValue` and `calendar.initialDate` refuse it too. On a date field write `{current_week_start}` / `{current_week_end}`. The section also names `resolveFilterPlaceholders()` as the client resolver for all three vocabularies and `isKnownFilterToken()` as the one spelling check. One eval case covers the text-field / date-field split. diff --git a/.changeset/35496-skills-teach-five-landed-behaviours.md b/.changeset/35496-skills-teach-five-landed-behaviours.md new file mode 100644 index 00000000000..013ad8c3ebe --- /dev/null +++ b/.changeset/35496-skills-teach-five-landed-behaviours.md @@ -0,0 +1,35 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the data, query and ui skills teach five landed refusals and behaviours + +Clause-②: no +Metadata-protocol: none + +Five pieces of published skill text, one per landed behaviour the skills did not teach. Each comes with its own eval case. + +**The `{current_iso_week}` period key.** objectstack-query's `rules/filters.md`, section "Date Macros", now names the period key beside the date macros and the session tokens. `{current_iso_week}` (or `${current_iso_week}`) resolves to today's ISO week key, `YYYY-Www`, in the workspace time zone: Monday-start weeks, the ISO week-year at year edges. It is text, for a text field that stores week keys. A `date`, `datetime` or `time` field refuses it with `INVALID_FILTER` / 400, as it refuses the literal key; a date dashboard filter's `defaultValue` and `calendar.initialDate` refuse it too. On a date field write `{current_week_start}` / `{current_week_end}`. The section also names `resolveFilterPlaceholders()` as the client resolver for all three vocabularies and `isKnownFilterToken()` as the one spelling check. One eval case covers the text-field / date-field split. + +**A hook or job `js` body that does not compile is refused.** objectstack-data's `references/data-hooks.md`, "Sandbox restrictions": + +- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern the checking engine refuses is a warning: the runtime may accept it. +- Six restatements in the same file were removed to pay for the new text; the file is four lines shorter and no larger in tokens than before. + +`evals/hooks-security-seeds-datasources.json` gains one case on the refusal and its fix. + +**A seed record with a blank key field is refused at load, and a saved seed naming an unknown object is refused 422.** objectstack-data's `references/seeds.md`: + +- "`externalId` selection" says every record carries a value for each `externalId` field (each field of a list, or `name` when the seed names none), and that a record leaving one blank (no value, `null` or `''`; whitespace is a value) is refused at load in every mode: the load result names the object, the record index, the field and the fix, and the other records still load. The `externalId` row of the field table points at it. +- The note under the field table says a `seed` saved at runtime names its `object` itself, and that one resolving to nothing is refused with `422 INVALID_METADATA` at `object` ("which is not defined"). The fix is the object's full name (`crm_lead`, not `lead`) or creating the object first: a draft of it is enough for a draft seed, a live seed needs it published. The `object` row points at the note. +- Three restatements in the same file were removed to pay for part of the new text: the `columns` row's shape literal, the one-row best-practices table (now a sentence) and the second telling of what a refused seed value leaves behind. + +`evals/hooks-security-seeds-datasources.json` gains one case on each refusal. + +**A `master_detail` child is a record-page body table by default.** The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies. + +- objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table. +- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn above the field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. +- objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows. + +Both of those rules files are shorter than before, and neither one's token ceiling moves. diff --git a/.changeset/35692-skills-master-detail-body-table.md b/.changeset/35692-skills-master-detail-body-table.md deleted file mode 100644 index 4d92cb7d912..00000000000 --- a/.changeset/35692-skills-master-detail-body-table.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'@objectstack/skills': patch ---- - -docs(skills): the data and ui skills teach that a `master_detail` child is a record-page body table by default - -Clause-②: no -Metadata-protocol: none - -The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies. - -- objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table. -- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn above the field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. -- objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows. - -Both rules files are shorter than before. No ceiling moves. diff --git a/.changeset/35714-data-hooks-body-compile-refusal.md b/.changeset/35714-data-hooks-body-compile-refusal.md deleted file mode 100644 index 428cf444007..00000000000 --- a/.changeset/35714-data-hooks-body-compile-refusal.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -'@objectstack/skills': patch ---- - -docs(skills): the hooks skill says a hook or job `js` body that does not compile is refused, and how to fix it - -Clause-②: no -Metadata-protocol: none - -objectstack-data's `references/data-hooks.md`, "Sandbox restrictions": - -- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern the checking engine refuses is a warning: the runtime may accept it. -- Six restatements in the same file were removed to pay for the new text; the file is four lines shorter and no larger in tokens than before. - -`evals/hooks-security-seeds-datasources.json` gains one case on the refusal and its fix. From ee231bb06076f6fddf2c5b4ae7052f67aaffef5c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 08:13:38 +0000 Subject: [PATCH 10/11] docs(skills): eval case 34 no longer forbids the spellings its own answer names The case's must_not_contain held `code: ''` and `code: null`, and its expected_output names both as what the answer does not write. The grader matches a literal substring, so an answer written like the reference failed. The pair is dropped; must_contain (defineSeed, externalId, refused) carries the case. Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .../evals/hooks-security-seeds-datasources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index d18f77c914a..86aa7940d15 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -68,7 +68,7 @@ "files": [], "assertions": { "must_contain": ["defineSeed", "externalId", "refused"], - "must_not_contain": ["code: ''", "code: null"] + "must_not_contain": [] } }, { From 370465feafb466a36b214ab16b4086430a6e1fe2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 18:04:18 +0000 Subject: [PATCH 11/11] docs(skills): the body table is drawn after the open field sections Main now draws an unplaced body table after the field sections the record page draws open; record-page.md step 2, eval case 1 of record-page.json and the changeset said above them. The three now say what main does. Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude --- .changeset/35496-skills-teach-five-landed-behaviours.md | 2 +- skills/objectstack-ui/evals/record-page.json | 2 +- skills/objectstack-ui/rules/record-page.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/35496-skills-teach-five-landed-behaviours.md b/.changeset/35496-skills-teach-five-landed-behaviours.md index 013ad8c3ebe..792f668b5bb 100644 --- a/.changeset/35496-skills-teach-five-landed-behaviours.md +++ b/.changeset/35496-skills-teach-five-landed-behaviours.md @@ -29,7 +29,7 @@ Five pieces of published skill text, one per landed behaviour the skills did not **A `master_detail` child is a record-page body table by default.** The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies. - objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table. -- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn above the field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. +- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn after the open field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. - objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows. Both of those rules files are shorter than before, and neither one's token ceiling moves. diff --git a/skills/objectstack-ui/evals/record-page.json b/skills/objectstack-ui/evals/record-page.json index 1323977373e..4f7e8e98374 100644 --- a/skills/objectstack-ui/evals/record-page.json +++ b/skills/objectstack-ui/evals/record-page.json @@ -4,7 +4,7 @@ { "id": 1, "prompt": "On the lead record page, put the tasks first: our reps want the open tasks table before anything else when they open a lead. The `task` object already has a `lead` master_detail field.", - "expected_output": "No page file and no placement flag: `task.lead` is a `master_detail` with no `relatedList`, so it is already a full-width body table above the lead's field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other tables. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", + "expected_output": "No page file and no placement flag: `task.lead` is a `master_detail` with no `relatedList`, so it is already a full-width body table, drawn after the lead's open field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it first among the tables, directly under those field sections. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", "files": [], "assertions": { "must_contain": [ diff --git a/skills/objectstack-ui/rules/record-page.md b/skills/objectstack-ui/rules/record-page.md index 5190d4521d8..c2953b4d4fd 100644 --- a/skills/objectstack-ui/rules/record-page.md +++ b/skills/objectstack-ui/rules/record-page.md @@ -16,7 +16,7 @@ one tab per panel with its count) enlarges a panel at `?related=object.field`. **2 · Relationship flags shape the related column.** On the CHILD object's reference field: `relatedList: 'primary'` draws the child as a full-width body -table in the details above the field sections (the default for a +table in the details after the open field sections (the default for a `master_detail`); `true` (a `lookup`'s default) is a panel in the right column; `false` leaves the child off the page. `relatedListTitle` / `relatedListColumns` (child field names) replace the derived title / columns;