From b27a9339b9e1e74167774748498cb8930e131c82 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 06:03:48 +0000 Subject: [PATCH 1/2] docs(skills): four published skills follow merged code (audit sealing, compareTo date key, i18n wording, nested relation conditions) Spec and client docblocks name the runtime HTTP dispatcher as the mounter of the i18n routes. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgWxqfFaGCWssNvt6hh --- .../33773-skills-follow-merged-code-a.md | 18 +++ packages/client/src/index.ts | 3 +- .../spec/src/system/i18n-resolver.test.ts | 10 +- packages/spec/src/system/i18n-resolver.ts | 8 +- .../evals/objects-fields-relationships.json | 2 +- skills/objectstack-data/rules/lifecycle.md | 109 +++++++----------- skills/objectstack-i18n/SKILL.md | 30 ++--- skills/objectstack-query/SKILL.md | 51 ++++---- skills/objectstack-query/rules/filters.md | 96 +++++++-------- skills/objectstack-ui/rules/dashboards.md | 56 +++++---- 10 files changed, 180 insertions(+), 203 deletions(-) create mode 100644 .changeset/33773-skills-follow-merged-code-a.md diff --git a/.changeset/33773-skills-follow-merged-code-a.md b/.changeset/33773-skills-follow-merged-code-a.md new file mode 100644 index 00000000000..ebf162bb029 --- /dev/null +++ b/.changeset/33773-skills-follow-merged-code-a.md @@ -0,0 +1,18 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): four published skills follow merged code — audit sealing, the compare widget's date key, i18n wording, nested relation conditions + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-data/rules/lifecycle.md` § Sealing: each sealed hour becomes one checkpoint, or consecutive checkpoints of at most 10,000 rows, per organization chain; `chainField` (optional, default `tenant_id`) names the chain column and is fixed once checkpoints exist; `os audit verify` exits 1 on a changed row or a chain fault, `listed_twice` included. The graded eval case in `evals/objects-fields-relationships.json` says the same. + +`skills/objectstack-ui/rules/dashboards.md` § `compareTo`: a compare widget's window reaches the dataset query as a time dimension named after the date-range field, so the dataset declares a date dimension of that name (or one over a related-record date path), else `400 INVALID_FIELD`. + +`skills/objectstack-i18n/SKILL.md`: the stale aside about the schema docstring is gone (activity-milestone summaries keep their `{field}` tokens); the wiring sentence is a statement again ("You do not need to wire this plugin"); `getSourceLocale()` returns the declared locale only, else `undefined`; the i18n routes answer signed-in callers, and the locales answer carries the declared `fallbackChain`. + +`skills/objectstack-query/SKILL.md` and `rules/filters.md`: on a read verb a single-valued relation condition is one in-database subquery per relationship, up to three relationships, on drivers declaring `readableIdsLeaf` (MongoDB and OData refuse it); the 1000-id cap stays only where ids are still read. `filters.md` § Operator Reference lists one example per operator; the SQL equivalents live in `SKILL.md` **Filter Operators**. + +No token ceiling moved: every addition is paid by a deletion in the same file. diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 028855d363d..2972ce64c69 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -8019,7 +8019,8 @@ export class ObjectStackClient { * * Speaks the path-param dialect (`/translations/:locale`) — the shape * `plugin-rest-api.zod.ts` declares and the ONLY shape any serving surface - * mounts (service-i18n's autonomous routes, the dispatcher's HTTP mounts). + * mounts (the runtime HTTP dispatcher's `/i18n` domain; service-i18n's own + * routes were retired by #23347). * The `?locale=` query form this used to send matched no route anywhere * and 404'd on the wire; the dispatcher's domain body accepts it, but * nothing ever routes a bare `/translations` to that body (#3636). diff --git a/packages/spec/src/system/i18n-resolver.test.ts b/packages/spec/src/system/i18n-resolver.test.ts index 92f8bb79bc9..53a15d16b60 100644 --- a/packages/spec/src/system/i18n-resolver.test.ts +++ b/packages/spec/src/system/i18n-resolver.test.ts @@ -3959,8 +3959,8 @@ describe('toLocaleDescriptors', () => { // The SUBSTANCE pin: producer output vs the DECLARED shape, both halves. // // `GetLocalesResponseSchema` described `label` as "Display name of the - // locale" while this helper — the ONLY producer, shared by the - // dispatcher's `/i18n` domain and service-i18n's route — echoed the code + // locale" while this helper — the ONLY producer, used by the runtime + // dispatcher's `/i18n` domain, which mounts the route — echoed the code // back. Declared ≠ enforced, one field wide (ADR-0049), and it misleads in // exactly one direction: a client that trusts the describe renders `th` // where `ไทย` belongs. objectui#4039 hit that and routed around the field @@ -3997,9 +3997,9 @@ describe('toLocaleDescriptors', () => { describe('normalizeSupportedLocales — the declared supportedLocales narrow the advertised set', () => { // The narrowing rule both providers of the `i18n` slot share. Held here, - // next to `toLocaleDescriptors`, because both of them can be the thing - // mounting `GET /i18n/locales` and a second copy is how that route came to - // answer in two shapes before. + // next to `toLocaleDescriptors`, because either can be the provider behind + // `GET /i18n/locales` (the runtime dispatcher mounts it), and a second + // copy is how that route came to answer in two shapes before. it('returns the declared codes in DECLARED order', () => { // Order is authored, so it is preserved: a picker rendering the app's own diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index 5b607100c9e..749e028fcc1 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -4586,7 +4586,8 @@ export function toLocaleDescriptors( * [#7679] Shared for the same reason `toLocaleDescriptors` above is: BOTH * providers of the `i18n` slot implement `setSupportedLocales` * (`createMemoryI18n` in core, `FileI18nAdapter` in service-i18n) and either - * one can be the thing mounting `GET /i18n/locales`. Two copies of "what + * one can be the provider behind `GET /i18n/locales`, which the runtime HTTP + * dispatcher mounts (#23347). Two copies of "what * counts as a declaration" is how the same route came to answer in two shapes * before (#3636), one narrowing rule over. * @@ -4629,8 +4630,9 @@ export function normalizeSupportedLocales( * "which fields does this locale translate at all", which is what the * endpoint returns and what no per-field lookup can produce. * - * Shared deliberately. Both serving surfaces derive this map — the dispatcher - * domain body and service-i18n's autonomous route — and they are the only + * Shared deliberately. Both serving surfaces once derived this map — the + * dispatcher domain body and service-i18n's own route, retired by #23347, so + * the runtime HTTP dispatcher now mounts the endpoint — and this is the only * path there is: `getFieldLabels` is optional on `II18nService` and NOTHING * implements it (neither `memory-i18n` nor `file-i18n-adapter`), so the * "dedicated method" branch both surfaces check first is dead and this diff --git a/skills/objectstack-data/evals/objects-fields-relationships.json b/skills/objectstack-data/evals/objects-fields-relationships.json index 5a6363b76d1..ba605742fd8 100644 --- a/skills/objectstack-data/evals/objects-fields-relationships.json +++ b/skills/objectstack-data/evals/objects-fields-relationships.json @@ -275,7 +275,7 @@ { "id": 16, "prompt": "Our `consent_change` audit log must show it if anyone edits, inserts or deletes rows directly in the database, but whatever proof is stored must not carry the consent text itself. How do I declare that?", - "expected_output": "Keep `lifecycle.class: 'audit'` with its bounding `retention` (or a `ttl` on `created_at`) and add `seal: { valueFields: ['consent_text'] }`: the audit plugin signs each `created_at` hour into one checkpoint per organization, chained to the one before, where `valueFields` columns enter as salted commitments and every other column in clear. The object declares its own `id` and a text or lookup `tenant_id` field; without that `tenant_id` (and with no `chainField` naming another chain column, such as the injected `organization_id`) it is refused at parse, and without `id` it parses but is not sealed, and the sealer reports it at `error` each hour. Refused at parse: `seal` on a class other than `audit`, `valueFields` naming `id`, `created_at` or an undeclared field, and beside `seal` a `retention` or `ttl` `onlyWhen`, a `ttl` on another field, or rotation `storage`. Signed expiry covers objects whose lifecycle is declared in packaged metadata, as this one is: its sealed rows leave only by whole checkpoints and read as `expired`. With no `archive`, a retention override below the declared window is rejected and the declared window applies; to keep rows for less time, shorten the declared window. On any other sealed object (one created at runtime) the sweeper still deletes sealed rows, which then read as missing. Field history is not tamper evidence.", + "expected_output": "Keep `lifecycle.class: 'audit'` with its bounding `retention` (or a `ttl` on `created_at`) and add `seal: { valueFields: ['consent_text'] }`: the audit plugin signs each `created_at` hour, per organization chain, into one checkpoint (or consecutive checkpoints of at most 10,000 rows), each chained to the one before, where `valueFields` columns enter as salted commitments and every other column in clear. The object declares its own `id` and a text or lookup `tenant_id` field; without that `tenant_id` (and with no `chainField` naming another chain column, such as the injected `organization_id`) it is refused at parse, as is a `chainField` naming a column the object lacks or one that cannot name an organization, and without `id` it parses but is not sealed, and the sealer reports it at `error` each hour. Refused at parse: `seal` on a class other than `audit`, `valueFields` naming `id`, `created_at` or an undeclared field, and beside `seal` a `retention` or `ttl` `onlyWhen`, a `ttl` on another field, or rotation `storage`. Signed expiry covers objects whose lifecycle is declared in packaged metadata, as this one is: its sealed rows leave only by whole checkpoints and read as `expired`. With no `archive`, a retention override below the declared window is rejected and the declared window applies; to keep rows for less time, shorten the declared window. On any other sealed object (one created at runtime) the sweeper still deletes sealed rows, which then read as missing. `os audit verify` checks the ledger and exits 1 on a changed, missing or unsealed row or a chain fault. Field history is not tamper evidence.", "files": [], "assertions": { "must_contain": [ diff --git a/skills/objectstack-data/rules/lifecycle.md b/skills/objectstack-data/rules/lifecycle.md index f2372b2de9a..120553946c7 100644 --- a/skills/objectstack-data/rules/lifecycle.md +++ b/skills/objectstack-data/rules/lifecycle.md @@ -17,8 +17,8 @@ expired rows under a system context, and reclaims driver space. ## Lifecycle Classes | Class | Contract | Typical use | -|:------|:---------|:------------| -| `record` | Business truth — permanent; policies FORBIDDEN | accounts, orders, invoices | +|:-|:-|:-| +| `record` | Business truth — permanent; policies FORBIDDEN | accounts, orders | | `audit` | Compliance ledger — retain → archive → delete | audit trails | | `telemetry` | High-frequency log — rotation / short retention | activity streams, run history | | `transient` | Ephemeral state — TTL auto-expire | receipts, codes, sessions | @@ -34,58 +34,33 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; export const ApiCallLog = ObjectSchema.create({ name: 'api_call_log', sharingModel: 'private', - lifecycle: { - class: 'telemetry', - retention: { maxAge: '14d' }, // reap past 14 days (created_at) - storage: { strategy: 'rotation', shards: 14, unit: 'day' }, - }, - fields: { - endpoint: Field.text({}), - status: Field.number({}), - }, + // reap past 14 days (created_at) + lifecycle: { class: 'telemetry', retention: { maxAge: '14d' }, storage: { strategy: 'rotation', shards: 14, unit: 'day' } }, + fields: { endpoint: Field.text({}), status: Field.number({}) }, }); // ✅ Ephemeral token: TTL on its own expiry field export const ImportTicket = ObjectSchema.create({ name: 'import_ticket', sharingModel: 'private', - lifecycle: { - class: 'transient', - ttl: { field: 'expires_at', expireAfter: '1d' }, // reap 1 day after expires_at - }, - fields: { - expires_at: Field.datetime({}), - }, + // reap 1 day after expires_at + lifecycle: { class: 'transient', ttl: { field: 'expires_at', expireAfter: '1d' } }, + fields: { expires_at: Field.datetime({}) }, }); // ✅ Compliance ledger: hot window, then cold storage export const ConsentLog = ObjectSchema.create({ name: 'consent_log', sharingModel: 'private', - lifecycle: { - class: 'audit', - retention: { maxAge: '90d' }, - archive: { after: '90d', to: 'archive', keep: '7y' }, - }, - fields: { - subject: Field.text({}), - }, + lifecycle: { class: 'audit', retention: { maxAge: '90d' }, archive: { after: '90d', to: 'archive', keep: '7y' } }, + fields: { subject: Field.text({}) }, }); -// ✅ MIXED table: terminal history is telemetry, but paused rows are live -// workflow state — `onlyWhen` scopes the age sweep to the declared filter +// ✅ Mixed table: paused rows are live workflow state — `onlyWhen` scopes the age sweep export const AutomationRun = ObjectSchema.create({ name: 'sys_automation_run', - lifecycle: { - class: 'telemetry', - retention: { - maxAge: '30d', - onlyWhen: { status: { $in: ['completed', 'failed'] } }, - }, - }, - fields: { - status: Field.select(['running', 'paused', 'completed', 'failed'], {}), - }, + lifecycle: { class: 'telemetry', retention: { maxAge: '30d', onlyWhen: { status: { $in: ['completed', 'failed'] } } } }, + fields: { status: Field.select(['running', 'paused', 'completed', 'failed'], {}) }, }); ``` @@ -100,20 +75,15 @@ lifecycle: { class: 'telemetry' } // ❌ archive.after must equal retention.maxAge lifecycle: { class: 'audit', retention: { maxAge: '90d' }, archive: { after: '30d', to: 'archive' } } -// ❌ onlyWhen + rotation/archive — shard DROPs and the Archiver act on age -// alone and would destroy/move rows the filter protects -lifecycle: { - class: 'telemetry', - retention: { maxAge: '14d', onlyWhen: { status: 'done' } }, - storage: { strategy: 'rotation', shards: 14, unit: 'day' }, -} +// ❌ onlyWhen + rotation/archive: both act on age alone, destroying/moving rows the filter protects +lifecycle: { class: 'telemetry', retention: { maxAge: '14d', onlyWhen: { status: 'done' } }, storage: { strategy: 'rotation', shards: 14, unit: 'day' } } ``` ## Safety Semantics - **Archive-then-delete**: an object declaring `archive` is never - hot-deleted before the copy to the archive datasource succeeded. If no - datasource is registered under the `archive.to` name, rows are retained. + hot-deleted before the copy to the archive datasource succeeded. No + datasource registered under the `archive.to` name ⇒ rows are retained. - **Rotation** time-shards the table on SQLite (writes hit the current shard, reads go through a view under the object's name, expired shards are DROPped). Other dialects enforce the same window with an @@ -123,39 +93,38 @@ lifecycle: { ## Sealing (`seal`) -`seal` makes an `audit` ledger tamper-evident (ADR-0154): an edit, insert or -delete outside the platform breaks its signed checkpoints. Ten minutes after each `created_at` -hour, `@objectstack/plugin-audit` signs its rows into a chained checkpoint -per organization (`tenant_id`; rows with none share a deployment chain); late -rows get a `late` checkpoint. Columns enter in clear, `valueFields` as salted -commitments. +`seal` makes an `audit` ledger tamper-evident (ADR-0154): `os audit verify` +exits 1 on a row edited, inserted or deleted outside the platform and on a +chain fault (a link, a signature, a row `listed_twice`). + +Ten minutes after each `created_at` hour, `@objectstack/plugin-audit` signs +its rows, per organization chain (plus one chain for rows about no +organization), into one checkpoint, or consecutive checkpoints of at most +10,000 rows; late rows get a `late` checkpoint. Columns enter in clear, +`valueFields` as salted commitments. + +`chainField` (optional, default `tenant_id`) names the chain column: a text +or lookup column holding the organization id, e.g. the injected +`organization_id`. Fixed once checkpoints exist: a change reads `listed_twice`. ```typescript import { ObjectSchema, Field } from '@objectstack/spec/data'; -// ✅ The sealer needs declared `id` and `tenant_id` +// ✅ The sealer needs declared `id` and `tenant_id` (stamped on insert) export const PolicyChangeLog = ObjectSchema.create({ name: 'policy_change_log', sharingModel: 'private', lifecycle: { class: 'audit', retention: { maxAge: '1y' }, seal: { valueFields: ['new_value'] } }, - fields: { - id: Field.text({}), - tenant_id: Field.lookup('sys_organization', {}), // stamped on insert - new_value: Field.textarea({}), - }, + fields: { id: Field.text({}), tenant_id: Field.lookup('sys_organization', {}), new_value: Field.textarea({}) }, }); ``` -```typescript -// ❌ Refused at parse time: id / created_at order the leaves -seal: { valueFields: ['created_at'] } -``` - -Also refused: `seal` off class `audit`, an undeclared `valueFields` name, no -text `tenant_id` outside `valueFields` (or `chainField: 'organization_id'`), -and beside `seal` any `onlyWhen`, a `ttl` not on `created_at`, or rotation -`storage`. Unsealed, `error` hourly: no declared `id`; a `password`, +Refused at parse: `seal` off class `audit`, a `valueFields` name that is +undeclared, `id` or `created_at` (they order the leaves), a chain column (`chainField`, else `tenant_id`) the object lacks or that +cannot name an organization (not one text value, `id`, `created_at`, or in +`valueFields`), and beside `seal` any `onlyWhen`, a `ttl` not on +`created_at`, or rotation `storage`. Unsealed, `error` hourly: no declared `id`; a `password`, `secret`, `formula`, `summary`, `image`, `file`, `avatar`, `video` or `audio` column; no `cryptoProvider` on `AuditPlugin`. @@ -169,9 +138,9 @@ runtime) the sweeper still deletes sealed rows, which then read as missing. ## Operations | Knob | Where | Effect | -|:-----|:------|:-------| +|:-|:-|:-| | `enabled` | `lifecycle` settings namespace | Runtime master switch | -| `retention_overrides` | settings, **tenant-scoped** | Per-object window overrides — a regulated tenant sets `'2y'` while dev keeps days; sealed objects: see § Sealing | +| `retention_overrides` | settings, **tenant-scoped** | Per-object window overrides; sealed objects: see § Sealing | | `quotas` / `quota_defaults` | settings | Row ceilings; breaches ALERT (never delete beyond declared policy) | | `growth_alert_rows` | settings | Per-sweep growth spike alert | | `OS_LIFECYCLE_DISABLED=1` | env | Disables sweeping entirely | diff --git a/skills/objectstack-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index 7e8df630000..f8826c1a5fe 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -32,12 +32,12 @@ export default defineStack({ supportedLocales: ['en', 'zh-CN', 'ja-JP', 'es-ES'], fallbackLocale: 'en', }, - // translations: [MyTranslations], ← register your bundles here (see below) + // translations: [MyTranslations], ← register your bundles here (see below) }); ``` | Property | Type | Required / Default | Description | -|:---------|:-----|:-------------------|:------------| +|:-|:-|:-|:-| | `defaultLocale` | `string` | **required** | The locale a user who has not chosen one gets | | `sourceLocale` | `string` | optional, defaults to `defaultLocale` | The language inline `label:` text is written in: a request in it is served that text; read by `os lint`, `os i18n check`, `os i18n extract` | | `supportedLocales` | `string[]` | **required** | All supported locales | @@ -149,7 +149,7 @@ All translatable content for a single object is aggregated under `objects.{object_name}` with these sub-keys: | Sub-key | Holds | -|:--------|:------| +|:-|:-| | `label` / `pluralLabel` / `description` | Object-level text (every key optional) | | `fields.{field_name}` | `label`, `help`, `placeholder`, `options` (option value → label), `inlineTitle` (the heading of the inline child grid a `master_detail` field draws on its parent's form — the field lives on the child object, so the key is the child's; untranslated it keeps its authored text, never the child's plural label), `relatedListTitle` (likewise, the title of the related list a `lookup` or `master_detail` field draws on its parent's record page) per field | | `_views.{view_name}` | `label`, `description`, `title` (a form view's own heading — only a form that authors one is translated; a list view has none), `submitBehavior.title` / `submitBehavior.message` (the thank-you panel of a form whose `submitBehavior` is `kind: 'thank-you'`; only the copy the form authors is translated, and the other kinds carry none), `emptyState.title` / `emptyState.message`, `bulkActions.{def_name}` (`label`, `confirmText`, `confirmLabel`, `params`) | @@ -209,7 +209,7 @@ the platform declares one, so an app bundle carrying it is refused by name. ## Naming Conventions | Context | Convention | Example | -|:--------|:-----------|:--------| +|:-|:-|:-| | Locale codes | BCP-47 | `en`, `en-US`, `zh-CN`, `pt-BR` | | Object keys in `objects.*` | `snake_case` | `objects.project_task`, `objects.support_case` | | Field keys | `snake_case` | `fields.first_name`, `fields.due_date` | @@ -270,8 +270,8 @@ exact Zod shape is `TranslationItemSchema` in Both shipped adapters substitute **double-brace** `{{variable}}` placeholders only — single braces pass through -unchanged. (The schema docstring mentions `{variable}` notation, but that is not -what the runtime implements.) +unchanged. An activity-milestone summary (`_milestones.{field}.{value}`) +keeps its authored `{field}` tokens. ```json { @@ -292,9 +292,9 @@ There is no ICU MessageFormat engine. To pluralize, select the form in applicati ### `os i18n check` ```bash -os i18n check # every locale found in the config -os i18n check --locales=zh-CN # scope to specific locales -os i18n check --strict --threshold=95 # CI gate: locale parity + minimum coverage +os i18n check # every locale found in the config +os i18n check --locales=zh-CN # scope to specific locales +os i18n check --strict --threshold=95 # CI gate: locale parity + minimum coverage ``` It compares registered bundles against source metadata and reports missing keys @@ -355,7 +355,7 @@ registers when no i18n plugin is present): with `{{param}}` interpolation and fallback-locale lookup - **`getTranslations(locale)`** — a locale's full snapshot - **`loadTranslations(locale, data)`** — programmatic load (deep-merge) -- **`getLocales()`** / **`setSupportedLocales()`** / **`getDefaultLocale()`** / **`setDefaultLocale()`** / **`getSourceLocale()`** / **`setSourceLocale()`** +- **`getLocales()`** / **`setSupportedLocales()`** / **`getDefaultLocale()`** / **`setDefaultLocale()`** / **`getSourceLocale()`** (the declared one only, else `undefined`) / **`setSourceLocale()`** The in-memory fallback additionally resolves locale codes through `resolveLocaleAmong` (`@objectstack/spec/system`), the one ladder `resolveBundleLocale` also runs: exact → @@ -368,12 +368,12 @@ points for a custom workbench or TMS adapter. ### Registration -Don't wire this plugin: `os serve` registers `I18nServicePlugin` itself whenever the +You do not need to wire this plugin: `os serve` registers `I18nServicePlugin` itself whenever the stack config carries `translations` or `i18n` (kernel bootstrap is **objectstack-platform → Runtime Boot Sequence**). The runtime's HTTP dispatcher, -which `os serve` composes, mounts `GET /api/v1/i18n/locales`, `/translations/:locale` and +which `os serve` composes, mounts for signed-in callers `GET /api/v1/i18n/locales`, `/translations/:locale` and `/labels/:object/:locale`, served from the i18n service; the locales -answer marks the default locale (`isDefault`) and names `sourceLocale` (the declared one, else the default). +answer marks the default locale (`isDefault`) and names `sourceLocale` (the declared one, else the default) and the declared `fallbackChain`, if any. --- @@ -483,8 +483,8 @@ top-level `locale`, and `_actions.confirmMessage` → `_actions.confirmText`. ## Verify your work ```bash -os i18n check # coverage: which keys are missing, per locale -os validate # the bundle conforms to the protocol schema +os i18n check # coverage: which keys are missing, per locale +os validate # the bundle conforms to the protocol schema ``` For the build and scaffold diff --git a/skills/objectstack-query/SKILL.md b/skills/objectstack-query/SKILL.md index d70c08eaac6..aefec4ca4ce 100644 --- a/skills/objectstack-query/SKILL.md +++ b/skills/objectstack-query/SKILL.md @@ -111,7 +111,7 @@ The simplest filter — field equals value: ### Comparison Operators | Operator | Purpose | SQL Equivalent | Types | -|:---------|:--------|:---------------|:------| +|:-|:-|:-|:-| | `$eq` | Equal | `=` | Any | | `$ne` | Not equal | `<>` | Any | | `$gt` | Greater than | `>` | Number, Date | @@ -127,7 +127,7 @@ The simplest filter — field equals value: ### Set & Range Operators | Operator | Purpose | SQL Equivalent | -|:---------|:--------|:---------------| +|:-|:-|:-| | `$in` | In list | `IN (...)` | | `$nin` | Not in list | `NOT IN (...)` | | `$between` | Inclusive range | `BETWEEN ? AND ?` | @@ -140,7 +140,7 @@ The simplest filter — field equals value: ### String Operators | Operator | Purpose | SQL Equivalent | -|:---------|:--------|:---------------| +|:-|:-|:-| | `$contains` | Contains substring | `LIKE '%?%'` | | `$notContains` | Does not contain | `NOT LIKE '%?%'` | | `$startsWith` | Starts with prefix | `LIKE '?%'` | @@ -162,14 +162,14 @@ Full table, `$like` portability and the `$ilike` boundary: **[filter rules](./ru ### Null & Existence Operators | Operator | Purpose | SQL / NoSQL | -|:---------|:--------|:------------| +|:-|:-|:-| | `$null` | Is null check | `IS NULL` / `IS NOT NULL` | | `$exists` | Has a value | `IS NOT NULL` / `IS NULL` | | `$empty` | Is empty by the field's declared type | `IS NULL`, plus `''` (text types) or `[]` (multi-value) | ```typescript { where: { deleted_at: { $null: true } } } -{ where: { notes: { $empty: true } } } // false = has content +{ where: { notes: { $empty: true } } } // false = has content ``` A view filter's `is_empty` / `is_not_empty` lowers to `$empty`. A face that judges @@ -185,14 +185,7 @@ Combine conditions with `$and`, `$or`, and `$not`: { where: { $or: [{ status: 'active' }, { revenue: { $gt: 1000000 } }] } } // AND + OR combined -{ - where: { - $and: [ - { type: 'enterprise' }, - { $or: [{ region: 'us' }, { region: 'eu' }] }, - ] - } -} +{ where: { $and: [{ type: 'enterprise' }, { $or: [{ region: 'us' }, { region: 'eu' }] }] } } // NOT: exclude closed accounts { where: { $not: { status: 'closed' } } } @@ -200,10 +193,14 @@ Combine conditions with `$and`, `$or`, and `$not`: ### Filtering by a related record -`{ customer: { country: 'US' } }` beneath a lookup is served in `where`: the -engine reads the related object as the caller and matches its ids. The limits -(one level, forward only, `where` only, 1000 ids, the caller's permissions) and -the two-step route past them: **[filter rules → Relation Filters](./rules/filters.md)**. +`{ customer: { country: 'US' } }` beneath a lookup is served in `where`, read +as the caller: on `find` / `findOne` / `count` / `aggregate` a single-valued +relation is one in-database subquery per relationship — no id list, no cap — +and a relation key may carry its own condition, up to three relationships. +The driver it needs (`DriverCapabilities.readableIdsLeaf`; MongoDB and OData +refuse it), the limits (forward only, `where` only, the 1000-id cap where ids +are still read, the caller's permissions at every hop) and the two-step route +past them: **[filter rules → Relation Filters](./rules/filters.md)**. ### Cross-field comparisons @@ -221,10 +218,7 @@ Sort with `orderBy` — an array of sort nodes: import type { QueryInput } from '@objectstack/spec/data'; const query: QueryInput = { object: 'account', - orderBy: [ - { field: 'priority', order: 'desc' }, - { field: 'name', order: 'asc' }, // Secondary sort - ] + orderBy: [{ field: 'priority', order: 'desc' }, { field: 'name', order: 'asc' }], // name: secondary sort }; ``` @@ -268,8 +262,6 @@ const rows = await engine.aggregate('deal', { { function: 'count', alias: 'deal_count' }, ], }); -// SQL: SELECT region, SUM(amount) AS total_revenue, COUNT(*) AS deal_count -// FROM deal GROUP BY region ``` `fields` and `orderBy` are NOT in `ENGINE_AGGREGATE_OPTION_KEYS` — do not put @@ -288,14 +280,11 @@ key in `fields`** — the relation is carried by that column: import type { IDataEngine } from '@objectstack/spec/contracts'; declare const engine: IDataEngine; const tasks = await engine.find('task', { - fields: ['title', 'status', 'owner_id', 'project'], // the FK columns stay + fields: ['title', 'status', 'owner_id', 'project'], // the FK columns stay expand: { owner_id: { object: 'user', fields: ['name', 'email'] }, - project: { - object: 'project', - fields: ['name'], - expand: { org: { object: 'org', fields: ['name'] } }, // nested expand - }, + // nested expand + project: { object: 'project', fields: ['name'], expand: { org: { object: 'org', fields: ['name'] } } }, }, }); ``` @@ -369,9 +358,9 @@ related record's column, `where: { relation: { column: value } }`; to *display* ### Cross-Object Queries: Which Tool to Use? | Scenario | Use | -|:---------|:----| +|:-|:-| | Load lookup fields for display | `expand` | -| Filter rows by their lookup target's column | `{ lookup: { column: value } }` in `where`, up to 1000 related ids; past the cap query the target, then `{ lookup: { $in: ids } }` — `$contains` per id when `multiple` | +| Filter rows by their lookup target's column | `{ lookup: { column: value } }` in `where`; past the 1000-id cap where ids are still read, query the target, then `{ lookup: { $in: ids } }` — `$contains` per id when `multiple` | | Filter parent by child conditions | Query the child with `fields: [lookup]`, then `{ id: { $in: those ids } }` on the parent | | **Keyword-search by a related record's title** | **Mirror the title into a stored field on this object and search that** — `search` never traverses | | Paginate/sort a parent's related records | Query the related object directly | diff --git a/skills/objectstack-query/rules/filters.md b/skills/objectstack-query/rules/filters.md index 44591ad9b3e..cfa7b5043ef 100644 --- a/skills/objectstack-query/rules/filters.md +++ b/skills/objectstack-query/rules/filters.md @@ -4,29 +4,29 @@ Every block below is a `where` fragment, so `check:skill-examples` skips it. ## Operator Reference -| Category | Operator | SQL Equivalent | Example | -|:---------|:---------|:---------------|:--------| -| Equality | `$eq` | `=` | `{ status: { $eq: 'active' } }` | -| Equality | `$ne` | `<>` | `{ status: { $ne: 'deleted' } }` | -| Comparison | `$gt` | `>` | `{ age: { $gt: 18 } }` | -| Comparison | `$gte` | `>=` | `{ amount: { $gte: 100 } }` | -| Comparison | `$lt` | `<` | `{ price: { $lt: 50 } }` | -| Comparison | `$lte` | `<=` | `{ score: { $lte: 100 } }` | -| Set | `$in` | `IN (...)` | `{ status: { $in: ['active', 'pending'] } }` | -| Set | `$nin` | `NOT IN (...)` | `{ role: { $nin: ['guest'] } }` | -| Range | `$between` | `BETWEEN ? AND ?` | `{ age: { $between: [18, 65] } }` | -| String | `$contains` | `LIKE %?%` | `{ name: { $contains: 'john' } }` | -| String | `$notContains` | `NOT LIKE %?%` | `{ email: { $notContains: 'spam' } }` | -| String | `$startsWith` | `LIKE ?%` | `{ code: { $startsWith: 'PRJ-' } }` | -| String | `$endsWith` | `LIKE %?` | `{ file: { $endsWith: '.pdf' } }` | -| String | `$icontains` | `LIKE %?%`, case-blind | `{ name: { $icontains: 'john' } }` | -| String | `$like` | `LIKE ?` — caller binds `%` / `_` | `{ code: { $like: 'PRJ-%-26' } }` | -| String | `$ilike` | `$like`, case-blind | `{ code: { $ilike: 'prj-%' } }` | -| Null | `$null` | `IS NULL` / `IS NOT NULL` | `{ deleted_at: { $null: true } }` | -| Null | `$exists` | `IS NOT NULL` / `IS NULL` | `{ metadata: { $exists: true } }` | -| Null | `$empty` | `IS NULL`, `''` or `[]` by type | `{ notes: { $empty: true } }` | - -Case sensitivity: SKILL.md, **String Operators**. `$like`/`$ilike` match the +An example of each operator: + +- `{ status: { $eq: 'active' } }` +- `{ status: { $ne: 'deleted' } }` +- `{ age: { $gt: 18 } }` +- `{ amount: { $gte: 100 } }` +- `{ price: { $lt: 50 } }` +- `{ score: { $lte: 100 } }` +- `{ status: { $in: ['active', 'pending'] } }` +- `{ role: { $nin: ['guest'] } }` +- `{ age: { $between: [18, 65] } }` +- `{ name: { $contains: 'john' } }` +- `{ email: { $notContains: 'spam' } }` +- `{ code: { $startsWith: 'PRJ-' } }` +- `{ file: { $endsWith: '.pdf' } }` +- `{ name: { $icontains: 'john' } }` +- `{ code: { $like: 'PRJ-%-26' } }` +- `{ code: { $ilike: 'prj-%' } }` +- `{ deleted_at: { $null: true } }` +- `{ metadata: { $exists: true } }` +- `{ notes: { $empty: true } }` + +Purpose, SQL equivalent, case sensitivity: SKILL.md, **Filter Operators**. `$like`/`$ilike` match the WHOLE value, so a pattern with no wildcard is an exact comparison, not a substring search. Their reach is narrower than the rest of the table: the SQL family, `driver-memory` and `@objectstack/formula` answer them, while @@ -43,9 +43,7 @@ unpaired backslash is refused by every face. ```typescript // ✅ Projects that ran over budget -where: { - actual_cost: { $gt: { $field: 'budget' } } -} +where: { actual_cost: { $gt: { $field: 'budget' } } } ``` Legal in a **comparison** position only. As an `$in` / `$nin` member or a @@ -61,10 +59,8 @@ reference there. ```typescript // ✅ Overdue by each record's own grace period: due_at < now + grace_days_offset, -// the number field holding the grace period as NEGATIVE days -where: { - due_at: { $lt: { $now: true, addDays: { $field: 'grace_days_offset' } } } -} +// the number field holding the grace period as NEGATIVE days +where: { due_at: { $lt: { $now: true, addDays: { $field: 'grace_days_offset' } } } } ``` `addDays` is **required** and always ADDED: an integer of any sign (`-30` @@ -81,22 +77,33 @@ answers it — not a stored formula field plus a hook. ## Relation Filters A condition on a related record's fields beneath a relation field (`lookup`, -`master_detail`, `user`, `tree`) is served in `where`: the engine reads the -related object with it **as the caller**, then matches the field against the -ids it returns (`$in`; any member when `multiple: true`). +`master_detail`, `user`, `tree`) is served in `where`, each hop read **as the caller**. On `find` / +`findOne` / `count` / `aggregate` a single-valued relation is matched with one +in-database subquery per relationship — no id list, no cap — on drivers +declaring `DriverCapabilities.readableIdsLeaf` (every `driver-sql` dialect, +Turso; `driver-memory` evaluates it in process); a driver without it +(MongoDB, OData) refuses the condition before anything is read, +`INVALID_FILTER` / 400. ```typescript // ✅ Orders whose customer is in the US where: { customer: { country: 'US' } } ``` -Limits — one level: every key a field the related object declares, no relation -or dotted key inside; forward only: never a parent by its children; `where` -only: an aggregation's `filter` and `having` refuse it, `INVALID_FILTER` / 400; -at most 1000 related ids, refused past that, `INVALID_FILTER` / 400, never -truncated; as the caller: the related object's row scope and field permissions -apply, so a field the caller cannot read is refused, `PERMISSION_DENIED` / 403, -never an empty result. Past the cap, run the two steps yourself — filter the +Limits — up to three relationships (ADR-0071's hop limit): every key a field the related object +declares, and a relation key may carry its own condition +(`{ customer: { owner: { region: 'NA' } } }`); a fourth, and a dotted key +inside, are refused, `INVALID_FILTER` / 400; forward only: never a parent by +its children; `where` only: an aggregation's `filter` and `having` refuse it, +`INVALID_FILTER` / 400; where ids are read and matched (`$in`; any member when `multiple: true`) — a +multi-valued relation, `update` / `delete`, and on a read verb a +related object on another datasource, federated, shaped by a middleware or +`afterFind` hook, or read under different driver options — at most 1000, +refused past that, `INVALID_FILTER` / 400, never truncated; as the caller, at +every hop: the related object's row scope and field permissions apply, so a +field the caller cannot read is refused, `PERMISSION_DENIED` / 403, never an +empty result, and a related record the caller cannot read excludes the row, +`$ne` included. Past the cap, run the two steps yourself — filter the related object, then `$in` its ids: ```typescript @@ -140,9 +147,7 @@ State absence with `$null`: `null` is not an ordering comparand For **ad-hoc queries in application code**, compute the date yourself: ```typescript -where: { - created_at: { $gte: new Date('2025-01-01') } -} +where: { created_at: { $gte: new Date('2025-01-01') } } ``` ### Date Macros (declarative filter metadata) @@ -152,10 +157,7 @@ pages — cannot run code, so they use **date macro tokens** instead (defined in `@objectstack/spec` `data/date-macros.zod.ts`): ```typescript -where: { - signal_at: { $gte: '{30_days_ago}' }, - published_at: { $gte: '{last_quarter_start}' } -} +where: { signal_at: { $gte: '{30_days_ago}' }, published_at: { $gte: '{last_quarter_start}' } } ``` - **Fixed tokens:** `{today}`, `{yesterday}`, `{tomorrow}`, `{now}`, plus diff --git a/skills/objectstack-ui/rules/dashboards.md b/skills/objectstack-ui/rules/dashboards.md index c4f3d3dc5e4..dab4c776429 100644 --- a/skills/objectstack-ui/rules/dashboards.md +++ b/skills/objectstack-ui/rules/dashboards.md @@ -19,7 +19,7 @@ A widget's `type` is its **chart type** (`ChartTypeSchema`; defaults to `metric`) — there are no separate `list` / `calendar` / `custom` widget kinds: | Family | `type` values | -|:-------|:--------------| +|:--|:--| | Single value | `metric`, `kpi`, `gauge`, `solid-gauge`, `bullet` (all render the number today; gauge variants gain a dial when a gauge renderer lands) | | Comparison | `bar`, `horizontal-bar`, `column` | | Trend | `line`, `area` | @@ -152,21 +152,21 @@ export const SalesDashboard: Dashboard = { label: 'Sales Performance', columns: 12, gap: 4, - refreshIntervalSeconds: 180, // auto-refresh cadence + refreshIntervalSeconds: 180, // auto-refresh cadence header: { showTitle: true, actions: [ - { label: 'New Opportunity', icon: 'Plus', actionType: 'modal', actionUrl: 'crm_create_opportunity' }, - { label: 'Forecast', icon: 'TrendingUp', actionType: 'url', actionUrl: '/reports/forecast' }, - { label: 'Export', icon: 'Download', actionType: 'script', actionUrl: 'crm_export_dashboard_pdf' }, + { label: 'New Opportunity', icon: 'Plus', actionType: 'modal', actionUrl: 'crm_create_opportunity' }, + { label: 'Forecast', icon: 'TrendingUp', actionType: 'url', actionUrl: '/reports/forecast' }, + { label: 'Export', icon: 'Download', actionType: 'script', actionUrl: 'crm_export_dashboard_pdf' }, ], }, // Date-range scrubber bound to a field on the underlying objects: dateRange: { field: 'close_date', defaultRange: 'this_quarter', allowCustomRange: true }, - // Filters applied to ALL widgets: + // Filters applied to ALL widgets globalFilters: [ { field: 'owner', label: 'Sales Rep', type: 'lookup', scope: 'dashboard', optionsFrom: { object: 'user', valueField: 'id', labelField: 'name' } }, @@ -179,11 +179,10 @@ export const SalesDashboard: Dashboard = { dataset: 'crm_opportunity_metrics', values: ['total_amount'], filter: { stage: { $nin: ['closed_won', 'closed_lost'] } }, layout: { x: 0, y: 0, w: 3, h: 2 }, - colorVariant: 'success', // the accent only + colorVariant: 'success', // the accent only compareTo: { kind: 'previousPeriod' }, }, - // Chart widget with comparison overlay. { id: 'revenue_vs_last_year', type: 'line', title: 'Revenue — This Year vs Last', @@ -227,23 +226,14 @@ const widgets: DashboardWidget[] = [ ### Period-over-period — `compareTo` -Set `compareTo` on any data-bound widget to add a second query against a -shifted time window. - -`compareTo` is `{ kind, dimension? }`. +`compareTo: { kind, dimension? }` on any data-bound widget adds a second +query against a shifted time window. | Key | Value | Behaviour | |:--|:--|:--| | `kind` | `'previousPeriod'` | The equal-length window immediately before the resolved one. | | `kind` | `'previousYear'` | The same window shifted back one calendar year. | -| `dimension` | dimension name, **optional** | Which time dimension's window to shift. Omit it when the selection dates exactly one — the executor resolves it. With zero or several it errors, naming the candidates; it never guesses. | - -The two bare `compareTo:` lines are a fragment, so `check:skill-examples` skips them. - -```typescript -compareTo: { kind: 'previousPeriod' } // one dated dimension -compareTo: { kind: 'previousYear', dimension: 'close_date' } // several — say which -``` +| `dimension` | dimension name, **optional** | Which time dimension's window to shift. Omit it when the selection dates exactly one — the executor resolves it. With zero or several it errors, naming the candidates; it never guesses: `{ kind: 'previousYear', dimension: 'close_date' }`. | * **Metric widgets** — a delta arrow plus a trend label from the kind (`vs previous period`). Its colour follows `polarity` (the measure's; an inline @@ -258,8 +248,14 @@ compareTo: { kind: 'previousYear', dimension: 'close_date' } // several — * **Requirements** — a comparison needs a **dated window** to shift. When the selection carries no time dimension with a date range (no resolvable date macro in the widget `filter`, no dashboard `dateRange`), the executor says so - rather than rendering a silently empty comparison column. The shifted query + rather than render an empty comparison column. The shifted query reuses the original `filter` shape and replaces only the date-bound clauses. +* **Date key** — the window travels to the dataset query as a time dimension + named after the date-range field (`dateRange.field`, default `created_at`), + so the dataset must declare a date dimension with that name; else the query + is refused `400 INVALID_FIELD`, naming the remedy. For a related-record date + path, declare a date dimension over it (`field: 'account.signed_at'`) + under any name. No author-time check catches it yet. ```typescript @@ -403,9 +399,9 @@ export const PipelineCoverageReport = defineReport({ label: 'Pipeline Coverage (Quarter)', type: 'matrix', dataset: 'crm_opportunity_metrics', - rows: ['forecast_category'], // down axis - columns: ['close_date'], // across axis — matrix pivots rows × columns - values: ['amount_sum'], // measures placed in the cells + rows: ['forecast_category'], // down axis + columns: ['close_date'], // across axis — matrix pivots rows × columns + values: ['amount_sum'], // measures placed in the cells runtimeFilter: { stage: { $ne: 'closed_lost' } }, // Period: ONE `type: 'date'` dataset dimension, not a dashboard-style raw `field`. dateRange: { dimension: 'close_date', defaultRange: 'this_year' }, @@ -454,18 +450,18 @@ import { defineCube } from '@objectstack/spec/data'; export const opportunityCube = defineCube({ name: 'crm_opportunity', title: 'Opportunities', - sql: 'opportunity', // underlying object name (snake_case) + sql: 'opportunity', // underlying object name (snake_case) public: true, measures: { - count: { label: 'Count', type: 'count', sql: '*' }, - amount: { label: 'Total Amount', type: 'sum', sql: 'amount', format: 'currency' }, + count: { label: 'Count', type: 'count', sql: '*' }, + amount: { label: 'Total Amount', type: 'sum', sql: 'amount', format: 'currency' }, }, dimensions: { - stage: { label: 'Stage', type: 'string', sql: 'stage' }, - close_date: { label: 'Close', type: 'time', sql: 'close_date', + stage: { label: 'Stage', type: 'string', sql: 'stage' }, + close_date: { label: 'Close', type: 'time', sql: 'close_date', granularities: ['day', 'week', 'month', 'quarter', 'year'] }, account_industry: { label: 'Industry', type: 'string', sql: 'account.industry' }, - owner: { label: 'Owner', type: 'string', sql: 'owner' }, + owner: { label: 'Owner', type: 'string', sql: 'owner' }, }, }); ``` From baf48948bbc2db9e6eea0743029578cd35908461 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 06:54:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?docs(skills):=20review=20fixes=20=E2=80=94?= =?UTF-8?q?=20audit=20verify=20exit=20wording,=20operator=20pointers,=20mi?= =?UTF-8?q?lestone=20token=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgWxqfFaGCWssNvt6hh --- packages/spec/src/system/i18n-resolver.ts | 5 +++-- .../objectstack-data/evals/objects-fields-relationships.json | 2 +- skills/objectstack-data/rules/lifecycle.md | 4 ++-- skills/objectstack-i18n/SKILL.md | 4 ++-- skills/objectstack-query/SKILL.md | 2 +- skills/objectstack-query/rules/filters.md | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index 749e028fcc1..dcf489fb230 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -4635,8 +4635,9 @@ export function normalizeSupportedLocales( * the runtime HTTP dispatcher now mounts the endpoint — and this is the only * path there is: `getFieldLabels` is optional on `II18nService` and NOTHING * implements it (neither `memory-i18n` nor `file-i18n-adapter`), so the - * "dedicated method" branch both surfaces check first is dead and this - * derivation always runs. Keeping one copy each is how the dispatcher was + * "dedicated method" branch the dispatcher checks first (as service-i18n's + * route did) is dead and this derivation always runs. Keeping one copy each + * was how the dispatcher was * left scanning the retired flat `o..fields.` dialect after * #3778 converged the tree on nested `objects..fields..label` * and fixed only service-i18n's copy — a scan that cannot match a real bundle, diff --git a/skills/objectstack-data/evals/objects-fields-relationships.json b/skills/objectstack-data/evals/objects-fields-relationships.json index ba605742fd8..81c2a084142 100644 --- a/skills/objectstack-data/evals/objects-fields-relationships.json +++ b/skills/objectstack-data/evals/objects-fields-relationships.json @@ -275,7 +275,7 @@ { "id": 16, "prompt": "Our `consent_change` audit log must show it if anyone edits, inserts or deletes rows directly in the database, but whatever proof is stored must not carry the consent text itself. How do I declare that?", - "expected_output": "Keep `lifecycle.class: 'audit'` with its bounding `retention` (or a `ttl` on `created_at`) and add `seal: { valueFields: ['consent_text'] }`: the audit plugin signs each `created_at` hour, per organization chain, into one checkpoint (or consecutive checkpoints of at most 10,000 rows), each chained to the one before, where `valueFields` columns enter as salted commitments and every other column in clear. The object declares its own `id` and a text or lookup `tenant_id` field; without that `tenant_id` (and with no `chainField` naming another chain column, such as the injected `organization_id`) it is refused at parse, as is a `chainField` naming a column the object lacks or one that cannot name an organization, and without `id` it parses but is not sealed, and the sealer reports it at `error` each hour. Refused at parse: `seal` on a class other than `audit`, `valueFields` naming `id`, `created_at` or an undeclared field, and beside `seal` a `retention` or `ttl` `onlyWhen`, a `ttl` on another field, or rotation `storage`. Signed expiry covers objects whose lifecycle is declared in packaged metadata, as this one is: its sealed rows leave only by whole checkpoints and read as `expired`. With no `archive`, a retention override below the declared window is rejected and the declared window applies; to keep rows for less time, shorten the declared window. On any other sealed object (one created at runtime) the sweeper still deletes sealed rows, which then read as missing. `os audit verify` checks the ledger and exits 1 on a changed, missing or unsealed row or a chain fault. Field history is not tamper evidence.", + "expected_output": "Keep `lifecycle.class: 'audit'` with its bounding `retention` (or a `ttl` on `created_at`) and add `seal: { valueFields: ['consent_text'] }`: the audit plugin signs each `created_at` hour, per organization chain, into one checkpoint (or consecutive checkpoints of at most 10,000 rows), each chained to the one before, where `valueFields` columns enter as salted commitments and every other column in clear. The object declares its own `id` and a text or lookup `tenant_id` field; without that `tenant_id` (and with no `chainField` naming another chain column, such as the injected `organization_id`) it is refused at parse, as is a `chainField` naming a column the object lacks or one that cannot name an organization, and without `id` it parses but is not sealed, and the sealer reports it at `error` each hour. Refused at parse: `seal` on a class other than `audit`, `valueFields` naming `id`, `created_at` or an undeclared field, and beside `seal` a `retention` or `ttl` `onlyWhen`, a `ttl` on another field, or rotation `storage`. Signed expiry covers objects whose lifecycle is declared in packaged metadata, as this one is: its sealed rows leave only by whole checkpoints and read as `expired`. With no `archive`, a retention override below the declared window is rejected and the declared window applies; to keep rows for less time, shorten the declared window. On any other sealed object (one created at runtime) the sweeper still deletes sealed rows, which then read as missing. `os audit verify` checks the ledger and exits 1 on a changed, missing or unsealed row or a chain fault such as a row `listed_twice`. Field history is not tamper evidence.", "files": [], "assertions": { "must_contain": [ diff --git a/skills/objectstack-data/rules/lifecycle.md b/skills/objectstack-data/rules/lifecycle.md index 120553946c7..420fe3d0b41 100644 --- a/skills/objectstack-data/rules/lifecycle.md +++ b/skills/objectstack-data/rules/lifecycle.md @@ -94,8 +94,8 @@ lifecycle: { class: 'telemetry', retention: { maxAge: '14d', onlyWhen: { status: ## Sealing (`seal`) `seal` makes an `audit` ledger tamper-evident (ADR-0154): `os audit verify` -exits 1 on a row edited, inserted or deleted outside the platform and on a -chain fault (a link, a signature, a row `listed_twice`). +(read-only) exits with code 1 on a changed, missing or unsealed row or a chain fault (a +link, a signature, a row `listed_twice`). Ten minutes after each `created_at` hour, `@objectstack/plugin-audit` signs its rows, per organization chain (plus one chain for rows about no diff --git a/skills/objectstack-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index f8826c1a5fe..6c44b8b1fa2 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -270,8 +270,8 @@ exact Zod shape is `TranslationItemSchema` in Both shipped adapters substitute **double-brace** `{{variable}}` placeholders only — single braces pass through -unchanged. An activity-milestone summary (`_milestones.{field}.{value}`) -keeps its authored `{field}` tokens. +unchanged. A milestone summary (`_milestones...summary`) keeps its +single-brace `{field}` tokens. ```json { diff --git a/skills/objectstack-query/SKILL.md b/skills/objectstack-query/SKILL.md index aefec4ca4ce..7e3e3eb2c0a 100644 --- a/skills/objectstack-query/SKILL.md +++ b/skills/objectstack-query/SKILL.md @@ -157,7 +157,7 @@ only). So the user-facing cases want `$icontains`: { where: { email: { $icontains: '@company.com' } } } ``` -Full table, `$like` portability and the `$ilike` boundary: **[filter rules](./rules/filters.md)**. +All examples, `$like` portability and the `$ilike` boundary: **[filter rules](./rules/filters.md)**. ### Null & Existence Operators diff --git a/skills/objectstack-query/rules/filters.md b/skills/objectstack-query/rules/filters.md index cfa7b5043ef..9554684749d 100644 --- a/skills/objectstack-query/rules/filters.md +++ b/skills/objectstack-query/rules/filters.md @@ -28,7 +28,7 @@ An example of each operator: Purpose, SQL equivalent, case sensitivity: SKILL.md, **Filter Operators**. `$like`/`$ilike` match the WHOLE value, so a pattern with no wildcard is an exact comparison, not -a substring search. Their reach is narrower than the rest of the table: the SQL +a substring search. Their reach is narrower than the other operators': the SQL family, `driver-memory` and `@objectstack/formula` answer them, while `driver-mongodb`, objectql `having` and service-analytics each keep an operator allowlist that omits them and refuse — `Unsupported filter operator`,