diff --git a/.changeset/36290-field-history-values-default-on.md b/.changeset/36290-field-history-values-default-on.md new file mode 100644 index 00000000000..84faa5ed0ef --- /dev/null +++ b/.changeset/36290-field-history-values-default-on.md @@ -0,0 +1,29 @@ +--- +'@objectstack/spec': minor +'@objectstack/plugin-audit': minor +'@objectstack/platform-objects': patch +'@objectstack/metadata-core': patch +'@objectstack/driver-sql': patch +'@objectstack/cloud-connection': patch +'@objectstack/plugin-sharing': patch +'@objectstack/service-automation': patch +'@objectstack/service-messaging': patch +'@objectstack/service-realtime': patch +--- + +feat(audit): a record's activity stream shows each changed field's old → new values by default, with a new `fieldHistory` off switch on the object and the field, and a reader is served only the changes of fields they may read + +Clause-②: yes (widening) +Metadata-protocol: semantic + +A record's activity stream now shows `Field: old → new` for every changed field, on every object, unless the object or the field turns it off. Before, values showed only for a field that declared `trackHistory: true`. Every other change was named by its field label alone. + +- **New `enable.fieldHistory`, with no default.** Absent: values show. `false`: off for the object, and a change names its fields only. It has no default so that a parsed body never writes one. A built artifact or a stored definition therefore gets values when it is upgraded, with no rebuild. +- **`enable.trackHistory: false` alone no longer turns values off.** The flag keeps its meaning: with `true`, the default record page shows the compliance ledger's field changes to a reader the ledger serves, and the derived `history` API verb is served. To keep an object's activity free of values, write `enable: { fieldHistory: false }`. Every platform object that wrote `trackHistory: false` now also writes `fieldHistory: false`. +- **New field `fieldHistory`, with no default: the field's off switch.** Absent shows the values, `false` names the change without them, `true` shows them (a media or JSON type included). Under an object with `enable.fieldHistory: false`, values stay off whatever a field says. +- **Field `trackHistory: false` no longer means anything: it reads like absent, so the values show.** The field designer wrote it on every save while the key meant nothing, so a stored `false` cannot be told from a choice. `trackHistory: true` keeps one job: it opts a media or JSON field in. A credential field (`secret`, and `password` off better-auth objects) never shows values, because both sides are the same mask. A media or structured-JSON field (`image`, `file`, `avatar`, `video`, `audio`, `signature`, `composite`, `repeater`, `record`, `location`, `address`, `code`, `json`, `vector`) shows them only with an explicit `true` (`fieldHistory` or `trackHistory`). +- **The new field key is classified where every `FieldSchema` key is.** The SQL driver counts `fieldHistory` as a presentation key, so creating a column never reads it. The field-level-security scrub keeps it as written, because a boolean names no field. +- **Who reads a value:** the field-change code (`metadata.summary_message`) is now served to readers. It is narrowed change by change with the same field answer as `metadata.old` and `metadata.new`. A reference field's change is kept only for a reader served the referenced record's title. When a reader is not served some of a summary's changes, the summary is rebuilt from the changes they are served instead of being dropped whole. The full audit ledger is not widened. +- **A long value no longer fails the activity insert.** The stored summary is fitted to `sys_activity.summary`'s `maxLength` (500): each side is cut first, then trailing changes are left out. The code keeps every change, with each side capped at 1,000 characters. + +To keep an object's activity free of values, set `enable: { fieldHistory: false }` on it. For one field, set `fieldHistory: false` on that field; `trackHistory: false` does not turn values off. diff --git a/content/docs/data-modeling/fields.mdx b/content/docs/data-modeling/fields.mdx index 7e7509c9e49..e90558b2de1 100644 --- a/content/docs/data-modeling/fields.mdx +++ b/content/docs/data-modeling/fields.mdx @@ -618,7 +618,8 @@ Database indexes are declared at the object level in the object's `indexes[]` ar | Property | Type | Default | Description | | :--- | :--- | :--- | :--- | | `requiredPermissions` | `string[]` | — | Capabilities required to read/edit this field — masked on read, denied on write unless the caller holds all of them (ADR-0066 D3) | -| `trackHistory` | `boolean` | — | Render this field's value changes as entries on the record activity timeline | +| `trackHistory` | `boolean` | — | Opt a media or JSON field into old → new values on the record activity timeline; other fields show them already, and `false` does not hide them | +| `fieldHistory` | `boolean` | — | This field's old → new values on the record activity timeline: absent shows them, `false` turns them off | For values that must be encrypted at rest (API keys, tokens, DB passwords), use the `secret` field type — see the [Field Type Gallery](/docs/data-modeling/field-types#secret). diff --git a/content/docs/data-modeling/objects.mdx b/content/docs/data-modeling/objects.mdx index eca6eab7468..915f4228c2f 100644 --- a/content/docs/data-modeling/objects.mdx +++ b/content/docs/data-modeling/objects.mdx @@ -92,6 +92,7 @@ enable: { | Flag | Default | Description | | :--- | :--- | :--- | | `trackHistory` | `false` | Field history tracking for audit compliance | +| `fieldHistory` | — (on) | Field-change values (`old → new`) on the activity stream; `false` turns them off for the object | | `searchable` | `true` | Index records for global search | | `apiEnabled` | `true` | Expose object via automatic APIs | | `apiMethods` | all | Whitelist over the six primitives (`get/list/create/update/delete/bulk`); derived verbs (search/export/upsert/…) follow automatically. `undefined` = all, `[]` = none | diff --git a/content/docs/data-modeling/validation-rules.mdx b/content/docs/data-modeling/validation-rules.mdx index 0c307cdaf04..9c63ee95594 100644 --- a/content/docs/data-modeling/validation-rules.mdx +++ b/content/docs/data-modeling/validation-rules.mdx @@ -29,7 +29,8 @@ These properties apply to **all** field types and are validated by the base `Fie | `readonly` | `boolean` | `false` | Blocks user edits in UI forms; server-enforced on **both create and update** — a non-system write to the field is silently dropped from the payload (system-context writes such as import/seed/migration are exempt) | | `sortable` | `boolean` | `true` | Whether field appears in list view sort options | | `externalId` | `boolean` | `false` | Not read: nothing matches on it. A seed dataset names its match field in its own `externalId`, an import in its mapping's `upsertKey` | -| `trackHistory` | `boolean` | — | Render this field's value changes as entries on the record activity timeline | +| `trackHistory` | `boolean` | — | Opt a media or JSON field into old → new values on the record activity timeline; other fields show them already, and `false` does not hide them | +| `fieldHistory` | `boolean` | — | This field's old → new values on the record activity timeline: absent shows them, `false` turns them off | | `visibleWhen` | `string \| Expression` | — | CEL predicate; field is shown only when `TRUE` | | `readonlyWhen` | `string \| Expression` | — | CEL predicate; field is read-only when `TRUE` | | `requiredWhen` | `string \| Expression` | — | CEL predicate; field is required when `TRUE` | @@ -509,7 +510,8 @@ For sensitive data, use the properties and types the platform actually enforces: | Property | Type | Default | Description | |:---|:---|:---|:---| | `requiredPermissions` | `string[]` | — | Capabilities required to read/edit the field — masked on read, denied on write unless the caller holds all of them (ADR-0066 D3) | -| `trackHistory` | `boolean` | — | Render the field's value changes as entries on the record activity timeline | +| `trackHistory` | `boolean` | — | Opt a media or JSON field into old → new values on the record activity timeline; other fields show them already, and `false` does not hide them | +| `fieldHistory` | `boolean` | — | This field's old → new values on the record activity timeline: absent shows them, `false` turns them off | For reversible encrypted-at-rest values (API keys, tokens, DB passwords), use the `secret` field type — it is the type with an enforced encryption/masking code path diff --git a/content/docs/protocol/objectql/security.mdx b/content/docs/protocol/objectql/security.mdx index 1725c892fc6..9c50f992f8c 100644 --- a/content/docs/protocol/objectql/security.mdx +++ b/content/docs/protocol/objectql/security.mdx @@ -619,10 +619,10 @@ Set `deterministicEncryption: true` to allow equality queries on the ciphertext, ## 7. Auditing & Field History -Object- and field-level history is opt-in metadata, not a free-form `enable.audit` block. +Object- and field-level history is declared metadata, not a free-form `enable.audit` block. -- **Object history** — set `enable.trackHistory: true` on the object (the `ObjectCapabilities` block in `object.zod.ts`) to surface the record's field changes. On the default record page they join the one Timeline stream (its Changes filter); an assigned page shows them where it places a `record:history` block. -- **Per-field history** — set `trackHistory: true` on an individual field to render that field's value changes on the record activity timeline. (The former per-field `auditTrail` flag was pruned in 2026-06 — it had no runtime consumer.) +- **Field-change values** — a record's activity stream shows `Field: old → new` for every changed field by default. Set `enable.fieldHistory: false` on the object to name changes by their field label only, or `fieldHistory: false` on one field to do that for the field (`trackHistory: false` does not turn values off). Credential fields never show values, and media or structured-JSON fields show them only with `fieldHistory: true` or `trackHistory: true`. A reader is served only the changes of fields they may read. +- **Object history** — set `enable.trackHistory: true` on the object (the `ObjectCapabilities` block in `object.zod.ts`) to surface the compliance ledger's field changes. On the default record page they join the one Timeline stream (its Changes filter); an assigned page shows them where it places a `record:history` block. `enable.trackHistory` does not turn field-change values on or off. (The former per-field `auditTrail` flag was pruned in 2026-06 — it had no runtime consumer.) - **RLS audit** — removed (2026-07, ADR-0056 D8): the `RLSAuditConfigSchema`/`RLSAuditEventSchema` shapes were never emitted or read by the runtime RLS path and were deleted from the spec. Enforcement decisions surface today through the security plugin's fail-closed warnings and the standard audit log (`plugin-audit`), not a dedicated RLS event stream. ```yaml diff --git a/content/docs/references/api/metadata.mdx b/content/docs/references/api/metadata.mdx index f4ffb39f848..54df68fe613 100644 --- a/content/docs/references/api/metadata.mdx +++ b/content/docs/references/api/metadata.mdx @@ -968,7 +968,7 @@ Metadata query with filtering, sorting, and pagination | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | | **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | -| **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | +| **enable** | `{ trackHistory?: boolean; fieldHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | | **sharing** | `{ controlledByParent?: object }` | optional | Per-object sharing opt-ins that refine the org-wide default sharingModel declares. controlledByParent.ownerMayEdit: on a controlled_by_parent detail, the row's owner may update it with read access to the master (ADR-0055 §3 amendment). controlledByParent.writeRequiresMasterRead: anyone who reads the master may write the detail under the detail's own permissions. | | **defaultRowScope** | `{ name: string; label?: string; description?: string; operation: Enum<'select' \| 'insert' \| 'update' \| 'delete' \| 'all'>; … }` | optional | The object's default row scope: one row-level security policy, written like a permission set's `rowLevelSecurity` entry without `object` (the declaring object is implied; writing `object` is refused). The security plugin's row-policy collection, the one step every read, write and explain passes through, applies it when no permission set the caller holds carries a row policy for this object and the operation: a held policy for every object (`'*'`) counts, while one for another operation, switched off, or outside the caller's positions does not. A policy an authored set carries for the object is used as authored, with this default not added to it; a principal whose superuser bypass skips row policies is unaffected; an object that declares none keeps the behaviour it has without the key. The default is judged like a held policy: its `operation`, `positions` and `enabled` decide where it applies, and a `using` the row-filter compiler cannot lower makes every read it governs return no rows, with one warning in the server log. `os validate`, `os build` and `os lint` judge this predicate as they judge a permission set's policy and report one that cannot lower; saving the object through the server does not run that check, so keep it inside the lowerable subset. Explain names an applied default as the object's own, not a permission set's. | diff --git a/content/docs/references/data/field.mdx b/content/docs/references/data/field.mdx index 2a8e0bcb4a0..94b8fa424e1 100644 --- a/content/docs/references/data/field.mdx +++ b/content/docs/references/data/field.mdx @@ -105,7 +105,8 @@ const result = CurrencyConfigSchema.parse(data); | **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up an amount in the home currency (a child `currency` field in `dynamic` mode, a stored home amount included) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. | | **unitConfig** | `{ unitMode: 'fixed'; unit: Enum<'KGM' \| 'GRM' \| 'MGM' \| 'TNE' \| 'LBR' \| 'ONZ' \| 'MTR' \| 'MMT' \| 'CMT' \| 'KMT' \| …> } \| { unitMode: 'record'; unitField: string; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> } \| { unitMode: 'code'; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> }` | optional | Which unit a quantity is in, or that a text field holds a unit code (units of measure). On a `number` field: `{ unitMode: 'fixed', unit }`, one standard UN/ECE Recommendation 20 code checked at build (e.g. `KGM`, `MTR`, `H87`), or `{ unitMode: 'record', unitField, unitDimension? }`, where each record names its own unit in the sibling `text` field `unitField` names. On a `text` field that holds a unit code with no quantity pointing at it: `{ unitMode: 'code', unitDimension? }`. The quantity stays a bare number; a record stores the unit CODE in exact uppercase, never an id. At write, a code must be a standard code or one of the organization's own non-retired units (`sys_unit`), of the restricted dimension when one is declared, and a quantity beside a blank code is refused. Refused on every other field type, `formula` and `summary` included. Absent: the number has no unit. | | **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) | -| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. | +| **trackHistory** | `boolean` | optional | Opt a media or structured-JSON field into old → new values on the record activity timeline (ADR-0052 §5b). Every other field shows them already, so true changes nothing there. false and absent read the same: values show. false is not an off switch; turn a field's values off with fieldHistory: false. | +| **fieldHistory** | `boolean` | optional | This field's old → new values on the record activity timeline. Absent: they show (a media or structured-JSON type only with true). false: off, the change names the field's label only. true: on, a media or JSON type included. Off whatever this says when the object sets enable.fieldHistory: false; a credential field never shows values. Who reads a value is this field's read rule. | | **group** | `string` | optional | Older spelling of field-group membership, still read: the key of one of the object's fieldGroups (e.g. "contact_info"); the field joins that group in field declaration order. New metadata lists members on the group instead (fieldGroups[].fields), which also sets their order. A field a group lists may not name a different group here; a field naming a group whose fields list leaves it out follows the listed ones. | | **visibleWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is shown only when TRUE (else hidden). e.g. P`record.type == 'invoice'`. On a `required` field the server reads it on every write: where it is not TRUE (FALSE, or null such as an unset boolean) the field is not required for that write, and a predicate the server cannot evaluate counts as shown, so the field stays required. Reads the record's own columns, with `formula` fields computed over the record being written, as the form computes them over the record being edited; a read THROUGH a reference field, or a formula that reads through one, calls label(), calls can() on a write that picks no permission-gated option, or reads current_user on a system write with no user, cannot be evaluated there. | | **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is read-only when TRUE. e.g. P`record.status == 'paid'`. Reads the bound record's OWN columns: the field level never reads a related record, so a read THROUGH a reference field (`record.account.tier`) faults on every row and refuses every update that writes the field — `objectstack validate` refuses it. Put such a check in a `validations[]` `script` rule, whose `condition` is read one hop through a reference. | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index 37aea1488e0..0f8f3a27aa2 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -180,7 +180,7 @@ const result = ApiMethod.parse(data); | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | | **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | -| **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | +| **enable** | `{ trackHistory?: boolean; fieldHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | | **sharing** | `{ controlledByParent?: object }` | optional | Per-object sharing opt-ins that refine the org-wide default sharingModel declares. controlledByParent.ownerMayEdit: on a controlled_by_parent detail, the row's owner may update it with read access to the master (ADR-0055 §3 amendment). controlledByParent.writeRequiresMasterRead: anyone who reads the master may write the detail under the detail's own permissions. | | **defaultRowScope** | `{ name: string; label?: string; description?: string; operation: Enum<'select' \| 'insert' \| 'update' \| 'delete' \| 'all'>; … }` | optional | The object's default row scope: one row-level security policy, written like a permission set's `rowLevelSecurity` entry without `object` (the declaring object is implied; writing `object` is refused). The security plugin's row-policy collection, the one step every read, write and explain passes through, applies it when no permission set the caller holds carries a row policy for this object and the operation: a held policy for every object (`'*'`) counts, while one for another operation, switched off, or outside the caller's positions does not. A policy an authored set carries for the object is used as authored, with this default not added to it; a principal whose superuser bypass skips row policies is unaffected; an object that declares none keeps the behaviour it has without the key. The default is judged like a held policy: its `operation`, `positions` and `enabled` decide where it applies, and a `using` the row-filter compiler cannot lower makes every read it governs return no rows, with one warning in the server log. `os validate`, `os build` and `os lint` judge this predicate as they judge a permission set's policy and report one that cannot lower; saving the object through the server does not run that check, so keep it inside the lowerable subset. Explain names an applied default as the object's own, not a permission set's. | @@ -285,7 +285,8 @@ const result = ApiMethod.parse(data); | **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up an amount in the home currency (a child `currency` field in `dynamic` mode, a stored home amount included) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. | | **unitConfig** | `{ unitMode: 'fixed'; unit: Enum<'KGM' \| 'GRM' \| 'MGM' \| 'TNE' \| 'LBR' \| 'ONZ' \| 'MTR' \| 'MMT' \| 'CMT' \| 'KMT' \| …> } \| { unitMode: 'record'; unitField: string; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> } \| { unitMode: 'code'; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> }` | optional | Which unit a quantity is in, or that a text field holds a unit code (units of measure). On a `number` field: `{ unitMode: 'fixed', unit }`, one standard UN/ECE Recommendation 20 code checked at build (e.g. `KGM`, `MTR`, `H87`), or `{ unitMode: 'record', unitField, unitDimension? }`, where each record names its own unit in the sibling `text` field `unitField` names. On a `text` field that holds a unit code with no quantity pointing at it: `{ unitMode: 'code', unitDimension? }`. The quantity stays a bare number; a record stores the unit CODE in exact uppercase, never an id. At write, a code must be a standard code or one of the organization's own non-retired units (`sys_unit`), of the restricted dimension when one is declared, and a quantity beside a blank code is refused. Refused on every other field type, `formula` and `summary` included. Absent: the number has no unit. | | **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) | -| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. | +| **trackHistory** | `boolean` | optional | Opt a media or structured-JSON field into old → new values on the record activity timeline (ADR-0052 §5b). Every other field shows them already, so true changes nothing there. false and absent read the same: values show. false is not an off switch; turn a field's values off with fieldHistory: false. | +| **fieldHistory** | `boolean` | optional | This field's old → new values on the record activity timeline. Absent: they show (a media or structured-JSON type only with true). false: off, the change names the field's label only. true: on, a media or JSON type included. Off whatever this says when the object sets enable.fieldHistory: false; a credential field never shows values. Who reads a value is this field's read rule. | | **group** | `string` | optional | Older spelling of field-group membership, still read: the key of one of the object's fieldGroups (e.g. "contact_info"); the field joins that group in field declaration order. New metadata lists members on the group instead (fieldGroups[].fields), which also sets their order. A field a group lists may not name a different group here; a field naming a group whose fields list leaves it out follows the listed ones. | | **visibleWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is shown only when TRUE (else hidden). e.g. P`record.type == 'invoice'`. On a `required` field the server reads it on every write: where it is not TRUE (FALSE, or null such as an unset boolean) the field is not required for that write, and a predicate the server cannot evaluate counts as shown, so the field stays required. Reads the record's own columns, with `formula` fields computed over the record being written, as the form computes them over the record being edited; a read THROUGH a reference field, or a formula that reads through one, calls label(), calls can() on a write that picks no permission-gated option, or reads current_user on a system write with no user, cannot be evaluated there. | | **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is read-only when TRUE. e.g. P`record.status == 'paid'`. Reads the bound record's OWN columns: the field level never reads a related record, so a read THROUGH a reference field (`record.account.tier`) faults on every row and refuses every update that writes the field — `objectstack validate` refuses it. Put such a check in a `validations[]` `script` rule, whose `condition` is read one hop through a reference. | @@ -448,7 +449,8 @@ const result = ApiMethod.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **trackHistory** | `boolean` | optional (default: `false`) | Show the record's field changes (audit-trail UI): on the default record page they join the record's one timeline stream, under its Changes filter. On an authored page, a record:history or record:activity block shows the record's field changes from its own activity, and neither reads this flag. Pair with per-field trackHistory to pick which field diffs are summarized; audit capture itself is always on for compliance | +| **trackHistory** | `boolean` | optional (default: `false`) | Show the record's field changes (audit-trail UI): on the default record page they join the record's one timeline stream, under its Changes filter. On an authored page, a record:history or record:activity block shows the record's field changes from its own activity, and neither reads this flag. Whether the activity stream shows a changed field's old → new values is enable.fieldHistory's question, not this flag's; audit capture itself is always on for compliance | +| **fieldHistory** | `boolean` | optional | Field-change values on the record activity stream. Absent: each changed field's old → new values show (a field opts out with its own fieldHistory: false). false: off for this object, a change names its fields only, whatever a field says. Independent of trackHistory, which does not turn values off. Who reads a value is the field's read rule; a credential field never shows one | | **searchable** | `boolean` | optional (default: `true`) | Index records for global search | | **apiEnabled** | `boolean` | optional (default: `true`) | Expose object via automatic APIs | | **apiMethods** | `Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]` | optional | Whitelist of allowed API operations (six primitives; undefined = all, [] = none) | @@ -587,7 +589,8 @@ const result = ApiMethod.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **trackHistory** | `boolean` | optional (default: `false`) | Show the record's field changes (audit-trail UI): on the default record page they join the record's one timeline stream, under its Changes filter. On an authored page, a record:history or record:activity block shows the record's field changes from its own activity, and neither reads this flag. Pair with per-field trackHistory to pick which field diffs are summarized; audit capture itself is always on for compliance | +| **trackHistory** | `boolean` | optional (default: `false`) | Show the record's field changes (audit-trail UI): on the default record page they join the record's one timeline stream, under its Changes filter. On an authored page, a record:history or record:activity block shows the record's field changes from its own activity, and neither reads this flag. Whether the activity stream shows a changed field's old → new values is enable.fieldHistory's question, not this flag's; audit capture itself is always on for compliance | +| **fieldHistory** | `boolean` | optional | Field-change values on the record activity stream. Absent: each changed field's old → new values show (a field opts out with its own fieldHistory: false). false: off for this object, a change names its fields only, whatever a field says. Independent of trackHistory, which does not turn values off. Who reads a value is the field's read rule; a credential field never shows one | | **searchable** | `boolean` | optional (default: `true`) | Index records for global search | | **apiEnabled** | `boolean` | optional (default: `true`) | Expose object via automatic APIs | | **apiMethods** | `Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]` | optional | Whitelist of allowed API operations (six primitives; undefined = all, [] = none) | @@ -677,7 +680,8 @@ const result = ApiMethod.parse(data); | **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up an amount in the home currency (a child `currency` field in `dynamic` mode, a stored home amount included) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. | | **unitConfig** | `{ unitMode: 'fixed'; unit: Enum<'KGM' \| 'GRM' \| 'MGM' \| 'TNE' \| 'LBR' \| 'ONZ' \| 'MTR' \| 'MMT' \| 'CMT' \| 'KMT' \| …> } \| { unitMode: 'record'; unitField: string; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> } \| { unitMode: 'code'; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> }` | optional | Which unit a quantity is in, or that a text field holds a unit code (units of measure). On a `number` field: `{ unitMode: 'fixed', unit }`, one standard UN/ECE Recommendation 20 code checked at build (e.g. `KGM`, `MTR`, `H87`), or `{ unitMode: 'record', unitField, unitDimension? }`, where each record names its own unit in the sibling `text` field `unitField` names. On a `text` field that holds a unit code with no quantity pointing at it: `{ unitMode: 'code', unitDimension? }`. The quantity stays a bare number; a record stores the unit CODE in exact uppercase, never an id. At write, a code must be a standard code or one of the organization's own non-retired units (`sys_unit`), of the restricted dimension when one is declared, and a quantity beside a blank code is refused. Refused on every other field type, `formula` and `summary` included. Absent: the number has no unit. | | **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) | -| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. | +| **trackHistory** | `boolean` | optional | Opt a media or structured-JSON field into old → new values on the record activity timeline (ADR-0052 §5b). Every other field shows them already, so true changes nothing there. false and absent read the same: values show. false is not an off switch; turn a field's values off with fieldHistory: false. | +| **fieldHistory** | `boolean` | optional | This field's old → new values on the record activity timeline. Absent: they show (a media or structured-JSON type only with true). false: off, the change names the field's label only. true: on, a media or JSON type included. Off whatever this says when the object sets enable.fieldHistory: false; a credential field never shows values. Who reads a value is this field's read rule. | | **group** | `string` | optional | Older spelling of field-group membership, still read: the key of one of the object's fieldGroups (e.g. "contact_info"); the field joins that group in field declaration order. New metadata lists members on the group instead (fieldGroups[].fields), which also sets their order. A field a group lists may not name a different group here; a field naming a group whose fields list leaves it out follows the listed ones. | | **visibleWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is shown only when TRUE (else hidden). e.g. P`record.type == 'invoice'`. On a `required` field the server reads it on every write: where it is not TRUE (FALSE, or null such as an unset boolean) the field is not required for that write, and a predicate the server cannot evaluate counts as shown, so the field stays required. Reads the record's own columns, with `formula` fields computed over the record being written, as the form computes them over the record being edited; a read THROUGH a reference field, or a formula that reads through one, calls label(), calls can() on a write that picks no permission-gated option, or reads current_user on a system write with no user, cannot be evaluated there. | | **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is read-only when TRUE. e.g. P`record.status == 'paid'`. Reads the bound record's OWN columns: the field level never reads a related record, so a read THROUGH a reference field (`record.account.tier`) faults on every row and refuses every update that writes the field — `objectstack validate` refuses it. Put such a check in a `validations[]` `script` rule, whose `condition` is read one hop through a reference. | diff --git a/content/docs/references/system/migration.mdx b/content/docs/references/system/migration.mdx index 19c087dbc29..1acff62cf59 100644 --- a/content/docs/references/system/migration.mdx +++ b/content/docs/references/system/migration.mdx @@ -108,7 +108,8 @@ Add a new field to an existing object | **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up an amount in the home currency (a child `currency` field in `dynamic` mode, a stored home amount included) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. | | **unitConfig** | `{ unitMode: 'fixed'; unit: Enum<'KGM' \| 'GRM' \| 'MGM' \| 'TNE' \| 'LBR' \| 'ONZ' \| 'MTR' \| 'MMT' \| 'CMT' \| 'KMT' \| …> } \| { unitMode: 'record'; unitField: string; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> } \| { unitMode: 'code'; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> }` | optional | Which unit a quantity is in, or that a text field holds a unit code (units of measure). On a `number` field: `{ unitMode: 'fixed', unit }`, one standard UN/ECE Recommendation 20 code checked at build (e.g. `KGM`, `MTR`, `H87`), or `{ unitMode: 'record', unitField, unitDimension? }`, where each record names its own unit in the sibling `text` field `unitField` names. On a `text` field that holds a unit code with no quantity pointing at it: `{ unitMode: 'code', unitDimension? }`. The quantity stays a bare number; a record stores the unit CODE in exact uppercase, never an id. At write, a code must be a standard code or one of the organization's own non-retired units (`sys_unit`), of the restricted dimension when one is declared, and a quantity beside a blank code is refused. Refused on every other field type, `formula` and `summary` included. Absent: the number has no unit. | | **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) | -| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. | +| **trackHistory** | `boolean` | optional | Opt a media or structured-JSON field into old → new values on the record activity timeline (ADR-0052 §5b). Every other field shows them already, so true changes nothing there. false and absent read the same: values show. false is not an off switch; turn a field's values off with fieldHistory: false. | +| **fieldHistory** | `boolean` | optional | This field's old → new values on the record activity timeline. Absent: they show (a media or structured-JSON type only with true). false: off, the change names the field's label only. true: on, a media or JSON type included. Off whatever this says when the object sets enable.fieldHistory: false; a credential field never shows values. Who reads a value is this field's read rule. | | **group** | `string` | optional | Older spelling of field-group membership, still read: the key of one of the object's fieldGroups (e.g. "contact_info"); the field joins that group in field declaration order. New metadata lists members on the group instead (fieldGroups[].fields), which also sets their order. A field a group lists may not name a different group here; a field naming a group whose fields list leaves it out follows the listed ones. | | **visibleWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is shown only when TRUE (else hidden). e.g. P`record.type == 'invoice'`. On a `required` field the server reads it on every write: where it is not TRUE (FALSE, or null such as an unset boolean) the field is not required for that write, and a predicate the server cannot evaluate counts as shown, so the field stays required. Reads the record's own columns, with `formula` fields computed over the record being written, as the form computes them over the record being edited; a read THROUGH a reference field, or a formula that reads through one, calls label(), calls can() on a write that picks no permission-gated option, or reads current_user on a system write with no user, cannot be evaluated there. | | **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is read-only when TRUE. e.g. P`record.status == 'paid'`. Reads the bound record's OWN columns: the field level never reads a related record, so a read THROUGH a reference field (`record.account.tier`) faults on every row and refuses every update that writes the field — `objectstack validate` refuses it. Put such a check in a `validations[]` `script` rule, whose `condition` is read one hop through a reference. | @@ -361,7 +362,7 @@ Create a new object | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | | **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | -| **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | +| **enable** | `{ trackHistory?: boolean; fieldHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | | **sharing** | `{ controlledByParent?: object }` | optional | Per-object sharing opt-ins that refine the org-wide default sharingModel declares. controlledByParent.ownerMayEdit: on a controlled_by_parent detail, the row's owner may update it with read access to the master (ADR-0055 §3 amendment). controlledByParent.writeRequiresMasterRead: anyone who reads the master may write the detail under the detail's own permissions. | | **defaultRowScope** | `{ name: string; label?: string; description?: string; operation: Enum<'select' \| 'insert' \| 'update' \| 'delete' \| 'all'>; … }` | optional | The object's default row scope: one row-level security policy, written like a permission set's `rowLevelSecurity` entry without `object` (the declaring object is implied; writing `object` is refused). The security plugin's row-policy collection, the one step every read, write and explain passes through, applies it when no permission set the caller holds carries a row policy for this object and the operation: a held policy for every object (`'*'`) counts, while one for another operation, switched off, or outside the caller's positions does not. A policy an authored set carries for the object is used as authored, with this default not added to it; a principal whose superuser bypass skips row policies is unaffected; an object that declares none keeps the behaviour it has without the key. The default is judged like a held policy: its `operation`, `positions` and `enabled` decide where it applies, and a `using` the row-filter compiler cannot lower makes every read it governs return no rows, with one warning in the server log. `os validate`, `os build` and `os lint` judge this predicate as they judge a permission set's policy and report one that cannot lower; saving the object through the server does not run that check, so keep it inside the lowerable subset. Explain names an applied default as the object's own, not a permission set's. | @@ -547,7 +548,8 @@ Add a new field to an existing object | **currencyConfig** | `{ currencyMode?: Enum<'dynamic' \| 'fixed' \| 'record'>; defaultCurrency?: string; currencyField?: string; homeAmount?: object }` | optional | Which currency an amount is in: for a currency field, for a formula field whose returnType is currency, and for a summary that rolls up, through a master_detail, child amounts that follow this record's currency (`currencyMode: 'record'` naming this object's own code field). A summary that rolls up an amount in the home currency (a child `currency` field in `dynamic` mode, a stored home amount included) declares `currencyMode: 'dynamic'`, with no `defaultCurrency`, and shows in the organization's home currency. A summary may otherwise declare only `currencyMode: 'fixed'`, when every amount it reads is in that one currency; a `count` summary, any other `dynamic` summary and any other `record` roll-up are refused, by `defineStack` and by a single-object save or publish on a running server alike. Absent: dynamic mode, and no currency on a summary. | | **unitConfig** | `{ unitMode: 'fixed'; unit: Enum<'KGM' \| 'GRM' \| 'MGM' \| 'TNE' \| 'LBR' \| 'ONZ' \| 'MTR' \| 'MMT' \| 'CMT' \| 'KMT' \| …> } \| { unitMode: 'record'; unitField: string; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> } \| { unitMode: 'code'; unitDimension?: Enum<'mass' \| 'length' \| 'area' \| 'volume' \| 'time' \| 'count' \| 'package'> }` | optional | Which unit a quantity is in, or that a text field holds a unit code (units of measure). On a `number` field: `{ unitMode: 'fixed', unit }`, one standard UN/ECE Recommendation 20 code checked at build (e.g. `KGM`, `MTR`, `H87`), or `{ unitMode: 'record', unitField, unitDimension? }`, where each record names its own unit in the sibling `text` field `unitField` names. On a `text` field that holds a unit code with no quantity pointing at it: `{ unitMode: 'code', unitDimension? }`. The quantity stays a bare number; a record stores the unit CODE in exact uppercase, never an id. At write, a code must be a standard code or one of the organization's own non-retired units (`sys_unit`), of the restricted dimension when one is declared, and a quantity beside a blank code is refused. Refused on every other field type, `formula` and `summary` included. Absent: the number has no unit. | | **dimensions** | `integer` | optional | Vector dimensionality (e.g., 1536 for OpenAI embeddings) | -| **trackHistory** | `boolean` | optional | Render this field's value changes as human-readable entries on the record activity timeline (ADR-0052 §5b). Opt-in per field. | +| **trackHistory** | `boolean` | optional | Opt a media or structured-JSON field into old → new values on the record activity timeline (ADR-0052 §5b). Every other field shows them already, so true changes nothing there. false and absent read the same: values show. false is not an off switch; turn a field's values off with fieldHistory: false. | +| **fieldHistory** | `boolean` | optional | This field's old → new values on the record activity timeline. Absent: they show (a media or structured-JSON type only with true). false: off, the change names the field's label only. true: on, a media or JSON type included. Off whatever this says when the object sets enable.fieldHistory: false; a credential field never shows values. Who reads a value is this field's read rule. | | **group** | `string` | optional | Older spelling of field-group membership, still read: the key of one of the object's fieldGroups (e.g. "contact_info"); the field joins that group in field declaration order. New metadata lists members on the group instead (fieldGroups[].fields), which also sets their order. A field a group lists may not name a different group here; a field naming a group whose fields list leaves it out follows the listed ones. | | **visibleWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is shown only when TRUE (else hidden). e.g. P`record.type == 'invoice'`. On a `required` field the server reads it on every write: where it is not TRUE (FALSE, or null such as an unset boolean) the field is not required for that write, and a predicate the server cannot evaluate counts as shown, so the field stays required. Reads the record's own columns, with `formula` fields computed over the record being written, as the form computes them over the record being edited; a read THROUGH a reference field, or a formula that reads through one, calls label(), calls can() on a write that picks no permission-gated option, or reads current_user on a system write with no user, cannot be evaluated there. | | **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — field is read-only when TRUE. e.g. P`record.status == 'paid'`. Reads the bound record's OWN columns: the field level never reads a related record, so a read THROUGH a reference field (`record.account.tier`) faults on every row and refuses every update that writes the field — `objectstack validate` refuses it. Put such a check in a `validations[]` `script` rule, whose `condition` is read one hop through a reference. | @@ -665,7 +667,7 @@ Create a new object | **editMode** | `Enum<'modal' \| 'page'>` | optional | Edit-interaction intent for records of this object: 'modal' opens the edit form as a dialog over the current view; 'page' navigates to a dedicated full-page edit route. Absent = the renderer picks its own default (objectui defaults to modal). Cross-renderer intent, not pixel styling (family). | | **listViews** | `Record; type?: Enum<'grid' \| 'kanban' \| 'gallery' \| 'calendar' \| 'timeline' \| 'gantt' \| 'map' \| …>; data?: object \| object \| object; … }>` | optional | Built-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047) | | **searchableFields** | `string[]` | optional | Fields the `$search` query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields. Entries must name a STORED column: a virtual `formula` field is computed on read and materializes no column, so searching it can never match and it is refused — mirror the value onto a stored text field and declare that. | -| **enable** | `{ trackHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; apiMethods?: Enum<'get' \| 'list' \| 'create' \| 'update' \| 'delete' \| 'bulk'>[]; … }` | optional | Enabled system features modules | +| **enable** | `{ trackHistory?: boolean; fieldHistory?: boolean; searchable?: boolean; apiEnabled?: boolean; … }` | optional | Enabled system features modules | | **sharingModel** | `Enum<'private' \| 'public_read' \| 'public_read_write' \| 'controlled_by_parent'>` | optional | Org-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) \| public_read (everyone reads, owner writes) \| public_read_write (everyone reads+writes) \| controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1). | | **sharing** | `{ controlledByParent?: object }` | optional | Per-object sharing opt-ins that refine the org-wide default sharingModel declares. controlledByParent.ownerMayEdit: on a controlled_by_parent detail, the row's owner may update it with read access to the master (ADR-0055 §3 amendment). controlledByParent.writeRequiresMasterRead: anyone who reads the master may write the detail under the detail's own permissions. | | **defaultRowScope** | `{ name: string; label?: string; description?: string; operation: Enum<'select' \| 'insert' \| 'update' \| 'delete' \| 'all'>; … }` | optional | The object's default row scope: one row-level security policy, written like a permission set's `rowLevelSecurity` entry without `object` (the declaring object is implied; writing `object` is refused). The security plugin's row-policy collection, the one step every read, write and explain passes through, applies it when no permission set the caller holds carries a row policy for this object and the operation: a held policy for every object (`'*'`) counts, while one for another operation, switched off, or outside the caller's positions does not. A policy an authored set carries for the object is used as authored, with this default not added to it; a principal whose superuser bypass skips row policies is unaffected; an object that declares none keeps the behaviour it has without the key. The default is judged like a held policy: its `operation`, `positions` and `enabled` decide where it applies, and a `using` the row-filter compiler cannot lower makes every read it governs return no rows, with one warning in the server log. `os validate`, `os build` and `os lint` judge this predicate as they judge a permission set's policy and report one that cannot lower; saving the object through the server does not run that check, so keep it inside the lowerable subset. Explain names an applied default as the object's own, not a permission set's. | diff --git a/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index c66721e23d8..b13546f70b9 100644 --- a/docs/qa/platform-checklist/areas/records-forms.json +++ b/docs/qa/platform-checklist/areas/records-forms.json @@ -5799,10 +5799,10 @@ }, { "id": "records-forms.field-history-tracking", - "title": "Per-field trackHistory: a tracked edit lands the ADR-0052 §5b old→new timeline summary with display values, an untracked edit does not, and object-level enable.trackHistory gates the record page's sys_audit_log field-change read and derived history op both ways", + "title": "Field-change values: an edit lands the ADR-0052 §5b old→new timeline summary with display values unless the object or field turns them off (#36290), and object-level enable.trackHistory gates the record page's sys_audit_log field-change read and derived history op both ways", "since": "v15", "status": "active", - "revision": 15, + "revision": 16, "priority": "P1", "surface": "mixed", "personas": [ @@ -5834,9 +5834,9 @@ "evidence": "the sys_activity row + a timeline screenshot" }, { - "clause": "an UNtracked-field edit lands NO tracked-change summary — the activity (if any) falls back to the generic 'Updated ' with no per-field old→new for the untracked key (renderTrackedChangeSummary returns null when no tracked field changed)", + "clause": "an edit of a field that declares no trackHistory ALSO lands its old→new values: since #36290 they show for every changed field unless the object writes enable.fieldHistory: false or the field writes fieldHistory: false (a field's trackHistory: false reads like absent) (changeValuesShownFor, packages/plugins/plugin-audit/src/audit-writers.ts). The label-only frame of a turned-off field is the unit pins' (audit-writers.test.ts '[#36290]'), since no showcase object turns values off", "oracle": "api", - "verify": "post-edit sys_activity for the website-only edit carries no field-diff summary naming website", + "verify": "post-edit sys_activity for the website-only edit carries 'Website: → ', message key fieldChanges", "evidence": "the sys_activity read" }, { @@ -5859,7 +5859,7 @@ } ], "negative": [ - "an untracked edit producing an old→new diff in the sys_activity summary is a FAIL — trackHistory is opt-in per field (spec default false, object.zod.ts family note), and the per-field opt-in governs exactly that surface. ⛔ Not the timeline stream's audit-log lines (on a trackHistory object they fill the Changes chip, and the stream's sys_activity `updated` rows step aside for them: ui/packages/plugin-detail/src/recordTimelineStream.ts#mergeTimelineStream): they come from sys_audit_log (the compliance audit, ui/packages/app-shell/src/views/RecordDetailView.tsx), which records every field and is not per-field-gated, so 'Website old → new' there for the untracked field is correct; sys_activity.metadata also carries raw old/new for untracked fields by design — only the rendered summary is gated (QA runs #24616, #27438)", + "an edit of a field that declares no trackHistory landing WITHOUT its old→new values in the sys_activity summary is a FAIL (#36290: on unless the object writes enable.fieldHistory: false or the field writes fieldHistory: false), and so is a value from a field with fieldHistory: false. ⛔ Not the timeline stream's audit-log lines (on a trackHistory object they fill the Changes chip, and the stream's sys_activity `updated` rows step aside for them: ui/packages/plugin-detail/src/recordTimelineStream.ts#mergeTimelineStream): they come from sys_audit_log (the compliance audit, ui/packages/app-shell/src/views/RecordDetailView.tsx), which records every field and is not per-field-gated, so 'Website old → new' there for the untracked field is correct; sys_activity.metadata also carries raw old/new for untracked fields by design — only the rendered summary is gated (QA runs #24616, #27438)", "a sys_audit_log read on the task detail is a FAIL — per-field flags without the object-level opt-in must not summon the field-change history; judged on the network log, never on an empty Changes chip or a missing tab (acceptance[2].verify says why)", "a tracked select rendering raw option VALUES ('in_progress') instead of labels is a FAIL (#7289 closed exactly that). To stage it on showcase_task's status, walk its state machine: a direct backlog → in_progress PATCH answers 400 invalid_transition, so PATCH backlog → todo → in_progress (examples/app-showcase/src/data/objects/task.object.ts, transitions)" ], @@ -5869,11 +5869,11 @@ ], "automated": { "kind": "unit", - "ref": "packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts (reference titles + read plan); audit-option-label-summary.test.ts (option labels); ui/e2e/live/record-history-display.spec.ts (the record history's display contract, which the cross-ref in source[4] assigns to records-forms.crud-roundtrip. It runs only against the vite console dev server, LIVE_APP_URL, default http://localhost:5180 (ui/playwright.live.config.ts), never a built /_console boot: its page.goto paths are root-relative (/apps/…). At 1440×900, a column tier whatever the sidebar does, it opens the timeline stream's Changes chip on showcase_account in a browser, the enable.trackHistory object, so it holds acceptance[2]'s flag-true DOM half; it reads no network log and never opens the task detail, so the read gate both ways is driven by hand). packages/qa/dogfood/test/field-history-tracking-activity.dogfood.test.ts, at the REST doors of the showcase with AuditPlugin added as objectstack serve composes it: acceptance[0] and negative[2] (PATCH industry retail → finance lands a sys_activity row whose summary is exactly 'Industry: Retail → Finance', message key fieldChanges), acceptance[1] and negative[0] (a website-only PATCH lands the generic frame naming the Website label with no arrow and neither URL, message key activityUpdatedFields) and acceptance[3] (GET /api/v1/auth/me/permissions: showcase_account's apiOperations carry history, showcase_task's carry get and not history). acceptance[4] stays the unit pin's. acceptance[2]'s absence half and negative[1] (no sys_audit_log read from the task detail) stay live browser legs: they are judged on the network log of the rendered detail page, which no HTTP pin reaches, and the card's ruling adds no Playwright lane (#26573)" + "ref": "packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts (reference titles + read plan); audit-option-label-summary.test.ts (option labels); ui/e2e/live/record-history-display.spec.ts (the record history's display contract, which the cross-ref in source[4] assigns to records-forms.crud-roundtrip. It runs only against the vite console dev server, LIVE_APP_URL, default http://localhost:5180 (ui/playwright.live.config.ts), never a built /_console boot: its page.goto paths are root-relative (/apps/…). At 1440×900, a column tier whatever the sidebar does, it opens the timeline stream's Changes chip on showcase_account in a browser, the enable.trackHistory object, so it holds acceptance[2]'s flag-true DOM half; it reads no network log and never opens the task detail, so the read gate both ways is driven by hand). packages/qa/dogfood/test/field-history-tracking-activity.dogfood.test.ts, at the REST doors of the showcase with AuditPlugin added as objectstack serve composes it: acceptance[0] and negative[2] (PATCH industry retail → finance lands a sys_activity row whose summary is exactly 'Industry: Retail → Finance', message key fieldChanges), acceptance[1] and negative[0] (a website-only PATCH lands 'Website: https://before.example → https://after.example', message key fieldChanges, #36290) and acceptance[3] (GET /api/v1/auth/me/permissions: showcase_account's apiOperations carry history, showcase_task's carry get and not history). acceptance[4] stays the unit pin's. acceptance[2]'s absence half and negative[1] (no sys_audit_log read from the task detail) stay live browser legs: they are judged on the network log of the rendered detail page, which no HTTP pin reaches, and the card's ruling adds no Playwright lane (#26573)" }, "source": [ "packages/plugins/plugin-audit/src/audit-writers.ts#planTrackedLookupReads (planTrackedLookupReads), (renderTrackedChangeSummary — ADR-0052 §5b, #7230/#7289 localization), (zero-reads-by-default plan)", - "packages/spec/src/data/object.zod.ts#trackHistory (history derives from get ∧ trackHistory), (opt-in default false); packages/spec/src/data/api-derivation.ts", + "packages/spec/src/data/object.zod.ts#trackHistory (history derives from get ∧ trackHistory), (values on unless enable.fieldHistory: false, #36290); packages/spec/src/data/api-derivation.ts", "ui/packages/app-shell/src/views/RecordDetailView.tsx (historyEnabled, the three-precondition gate on the sys_audit_log read; record page v3 hands its rows to the timeline stream, #27055)", "examples/app-showcase/src/data/objects/account.object.ts (the deliberate both-halves fixture), examples/app-showcase/src/data/objects/task.object.ts#Task (its status and priority fields declare trackHistory)", "cross-ref records-forms.crud-roundtrip clause 5 (acceptance[4]) — it owns the record history's display contract on the create/update pair (option labels, localized dates, real actor); this item owns the tracked/untracked boundary and the two gating directions, so do not re-score that contract here" @@ -5968,6 +5968,12 @@ "date": "2026-11-22", "change": "steps[3] and acceptance[2].verify re-pointed after #35890 retired the right rail: the stream opens from the Activity tab or ?related=timeline, the first tab reads 详情 (Details), and the account's body tables keep its page from pinning (recordPagePinsDetails). The audit read at page load now rests on RecordDetailView's historyConsumerOnScreen (a laid-out synthesized page reads it at open) instead of the retired 最近动态 card; the drawer half, which named the rail, is dropped. No clause changed. Read from source at base 28ba01fe", "ref": "#36188" + }, + { + "revision": 16, + "date": "2026-11-22", + "change": "title, acceptance[1], negative[0], automated.ref and source[1] re-pointed: field-change values now show by default (ruling 7076513167). A field with no trackHistory lands old → new; enable.fieldHistory: false (object) or fieldHistory: false (field) turns them off, and a field's trackHistory: false reads like absent; enable.trackHistory keeps the ledger read and the history op. The dogfood pin's website leg reads the values. Read at base SHA c448c615", + "ref": "#36290" } ] }, diff --git a/packages/cloud-connection/src/sys-cloud-binding-credential.object.ts b/packages/cloud-connection/src/sys-cloud-binding-credential.object.ts index 917e8814de3..3485c1e59e3 100644 --- a/packages/cloud-connection/src/sys-cloud-binding-credential.object.ts +++ b/packages/cloud-connection/src/sys-cloud-binding-credential.object.ts @@ -129,6 +129,7 @@ export const SysCloudBindingCredential = ObjectSchema.create({ // Engine-owned: no generic data door at all. The token is masked on every // engine read regardless. trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/drivers/driver-sql/src/builtin-column-collision.ts b/packages/drivers/driver-sql/src/builtin-column-collision.ts index d6c234b06b0..26e299c6b66 100644 --- a/packages/drivers/driver-sql/src/builtin-column-collision.ts +++ b/packages/drivers/driver-sql/src/builtin-column-collision.ts @@ -114,6 +114,7 @@ export const FIELD_KEY_STORAGE_CLASS: Readonly> = searchable: 'presentation', sortable: 'presentation', trackHistory: 'presentation', // history rows live in their own object + fieldHistory: 'presentation', // whether this field's old → new values show on the activity timeline (#36290) — read by the audit writer, never by `createColumn` group: 'presentation', widget: 'presentation', hidden: 'presentation', diff --git a/packages/metadata-core/src/object-schema-fls-references.ts b/packages/metadata-core/src/object-schema-fls-references.ts index 6d4cac2f6df..a56596b643e 100644 --- a/packages/metadata-core/src/object-schema-fls-references.ts +++ b/packages/metadata-core/src/object-schema-fls-references.ts @@ -645,6 +645,9 @@ export const FIELD_REFERENCE_POSITIONS: Readonly> = { // A boolean facet of this lookup: it declares the target's name readable // by every reader of this record (#29171) and names no field. referenceNameVisible: keep, + // A boolean facet: whether this field's old → new values show on the + // record activity timeline (#36290). It names no field. + fieldHistory: keep, // The earlier keys of THIS field (cloud#3652 ruling D3): names of columns // the field had in earlier package versions. The parse refuses any entry // that is a key another field of the object still declares, so no entry diff --git a/packages/metadata-core/src/objects/sys-metadata-audit.object.ts b/packages/metadata-core/src/objects/sys-metadata-audit.object.ts index 26599bac5b1..32361df78d8 100644 --- a/packages/metadata-core/src/objects/sys-metadata-audit.object.ts +++ b/packages/metadata-core/src/objects/sys-metadata-audit.object.ts @@ -265,6 +265,7 @@ export const SysMetadataAuditObject = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, apiMethods: ['get', 'list'], diff --git a/packages/metadata-core/src/objects/sys-metadata-commit.object.ts b/packages/metadata-core/src/objects/sys-metadata-commit.object.ts index dbca34196fd..3e994559ef3 100644 --- a/packages/metadata-core/src/objects/sys-metadata-commit.object.ts +++ b/packages/metadata-core/src/objects/sys-metadata-commit.object.ts @@ -166,6 +166,7 @@ export const SysMetadataCommitObject = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, apiMethods: ['get', 'list'], diff --git a/packages/metadata-core/src/objects/sys-metadata-history.object.ts b/packages/metadata-core/src/objects/sys-metadata-history.object.ts index 2faeae41f05..369c65994ff 100644 --- a/packages/metadata-core/src/objects/sys-metadata-history.object.ts +++ b/packages/metadata-core/src/objects/sys-metadata-history.object.ts @@ -254,6 +254,7 @@ export const SysMetadataHistoryObject = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, apiMethods: ['get', 'list'], diff --git a/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts b/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts index d1125f946bc..af0c8800ded 100644 --- a/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts +++ b/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts @@ -401,8 +401,10 @@ describe('#17501 — /meta/types serves a real schema for `action`, and moves no // the object's icon tile in. // [#36425] `field` 84 → 85: `showOnCreate`, whether a field is asked for // when a record is created. + // [#36290] `field` 85 → 86: `fieldHistory`, the field's own switch for + // old → new values on the record activity timeline (false turns them off). const CARD_PROPERTY_COUNTS: Record = { - agent: 24, app: 24, dashboard: 21, dataset: 17, field: 85, flow: 24, + agent: 24, app: 24, dashboard: 21, dataset: 17, field: 86, flow: 24, hook: 24, object: 51, page: 28, position: 14, report: 24, skill: 17, tool: 14, }; diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index 589e791ac64..8c31e11ab83 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const arMetadataForms: NonNullable = { label: "اللغة", helpText: "لغة المحرر (مثل sql، javascript)" }, + "fields.fieldHistory": { + label: "قيم تغييرات الحقل", + helpText: "القيم القديمة → الجديدة لهذا الحقل في الخط الزمني لنشاط السجل. عدم التعيين يعني التشغيل، وإن بدا المفتاح مطفأً: لا تُكتب false إلا إذا شُغّل المفتاح ثم أُطفئ، وعندها يُذكر التغيير باسم الحقل فقط. عند التشغيل تظهر أيضًا قيم حقول الوسائط أو JSON." + }, "fields.trackHistory": { label: "تتبّع السجل", - helpText: "تلخيص هذا الحقل في الخط الزمني لنشاط السجل" + helpText: "يجعل حقل الوسائط أو JSON (صورة، ملف، json، …) يعرض القيم القديمة → الجديدة في الخط الزمني للنشاط. الحقول الأخرى تعرضها أصلًا، وإطفاؤه لا يخفيها: استخدم «قيم تغييرات الحقل»." }, "fields.visibleWhen": { label: "مرئي عندما", @@ -299,6 +303,10 @@ export const arMetadataForms: NonNullable = { "enable.trackHistory": { label: "تتبّع السجل" }, + "enable.fieldHistory": { + label: "قيم تغييرات الحقل", + helpText: "القيم القديمة → الجديدة للحقول المعدّلة في الخط الزمني لنشاط السجل. عدم التعيين يعني التشغيل، وإن بدا المفتاح مطفأً: لا تُكتب false إلا إذا شُغّل المفتاح ثم أُطفئ، وعندها لا يعرض الكائن كله أي قيم." + }, "enable.searchable": { label: "قابل للبحث" }, @@ -897,9 +905,13 @@ export const arMetadataForms: NonNullable = { label: "داخلي", helpText: "عدم إعادة قيمة هذا الحقل أبدًا على مسار البيانات العام: يحذف المحرك المفتاح من نتائج find/findOne ومن متون استجابات الإنشاء والتحديث، في الإسقاط الافتراضي وعندما يسمّي العميل الحقل في ?select=. لا يتأثر التخزين ولا التصفية ولا الفهرسة." }, + fieldHistory: { + label: "قيم تغييرات الحقل", + helpText: "القيم القديمة → الجديدة لهذا الحقل في الخط الزمني لنشاط السجل. عدم التعيين يعني التشغيل، وإن بدا المفتاح مطفأً: لا تُكتب false إلا إذا شُغّل المفتاح ثم أُطفئ، وعندها يُذكر التغيير باسم الحقل فقط. عند التشغيل تظهر أيضًا قيم حقول الوسائط أو JSON." + }, trackHistory: { label: "تتبّع السجل", - helpText: "عرض تغييرات قيمة هذا الحقل كإدخالات في الخط الزمني لنشاط السجل (ADR-0052 §5b). اشتراك اختياري لكل حقل." + helpText: "يجعل حقل الوسائط أو JSON (صورة، ملف، json، …) يعرض القيم القديمة → الجديدة في الخط الزمني للنشاط. الحقول الأخرى تعرضها أصلًا، وإطفاؤه لا يخفيها: استخدم «قيم تغييرات الحقل»." }, widget: { label: "عنصر الواجهة", diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index fe1f0660b87..dab28bdfd3f 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const deMetadataForms: NonNullable = { label: "Sprache", helpText: "Sprache des Editors (z. B. sql, javascript)" }, + "fields.fieldHistory": { + label: "Feldänderungswerte", + helpText: "Alte → neue Werte dieses Felds in der Aktivitätszeitleiste des Datensatzes. Nicht gesetzt bedeutet AN, auch wenn der Schalter aus wirkt: Nur ein ein- und wieder ausgeschalteter Schalter schreibt false, dann wird die Änderung nur mit dem Feldnamen genannt. Eingeschaltet zeigt auch ein Medien- oder JSON-Feld seine Werte." + }, "fields.trackHistory": { label: "Verlauf verfolgen", - helpText: "Dieses Feld in der Aktivitätszeitleiste des Datensatzes zusammenfassen" + helpText: "Lässt ein Medien- oder JSON-Feld (Bild, Datei, json, …) alte → neue Werte in der Aktivitätszeitleiste zeigen. Alle anderen Felder zeigen sie ohnehin, und Ausschalten verbirgt sie nicht: dafür gibt es Feldänderungswerte." }, "fields.visibleWhen": { label: "Sichtbar wenn", @@ -299,6 +303,10 @@ export const deMetadataForms: NonNullable = { "enable.trackHistory": { label: "Verlauf verfolgen" }, + "enable.fieldHistory": { + label: "Feldänderungswerte", + helpText: "Alte → neue Werte geänderter Felder in der Aktivitätszeitleiste des Datensatzes. Nicht gesetzt bedeutet AN, auch wenn der Schalter aus wirkt: Nur ein ein- und wieder ausgeschalteter Schalter schreibt false, dann zeigt das ganze Objekt keine Werte." + }, "enable.searchable": { label: "Durchsuchbar" }, @@ -897,9 +905,13 @@ export const deMetadataForms: NonNullable = { label: "Intern", helpText: "Den Wert dieses Felds nie über den allgemeinen Datenpfad zurückgeben: Die Engine lässt den Schlüssel in Ergebnissen von find/findOne und in den Antworttexten von create und update weg, bei der Standardprojektion und wenn ein Client das Feld in ?select= nennt. Speicherung, Filterung und Indizierung bleiben unberührt." }, + fieldHistory: { + label: "Feldänderungswerte", + helpText: "Alte → neue Werte dieses Felds in der Aktivitätszeitleiste des Datensatzes. Nicht gesetzt bedeutet AN, auch wenn der Schalter aus wirkt: Nur ein ein- und wieder ausgeschalteter Schalter schreibt false, dann wird die Änderung nur mit dem Feldnamen genannt. Eingeschaltet zeigt auch ein Medien- oder JSON-Feld seine Werte." + }, trackHistory: { label: "Verlauf verfolgen", - helpText: "Wertänderungen dieses Felds als Einträge in der Aktivitätszeitleiste des Datensatzes darstellen (ADR-0052 §5b). Pro Feld einzeln zu aktivieren." + helpText: "Lässt ein Medien- oder JSON-Feld (Bild, Datei, json, …) alte → neue Werte in der Aktivitätszeitleiste zeigen. Alle anderen Felder zeigen sie ohnehin, und Ausschalten verbirgt sie nicht: dafür gibt es Feldänderungswerte." }, widget: { label: "Widget", diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index 6ef3f5d1853..d765395e6a9 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const enMetadataForms: NonNullable = { label: "Language", helpText: "Editor language (e.g. sql, javascript)" }, + "fields.fieldHistory": { + label: "Field History", + helpText: "Old → new values for this field on the record activity timeline. Unset means ON, though the switch shows off: only a switch turned on and then off writes false, which names the change by label only. On also shows a media or JSON field's values." + }, "fields.trackHistory": { label: "Track History", - helpText: "Summarize this field on the record activity timeline" + helpText: "Opt a media or JSON field (image, file, json, …) into old → new values on the activity timeline. Every other field shows them already, and off does not hide them: use Field History." }, "fields.visibleWhen": { label: "Visible When", @@ -299,6 +303,10 @@ export const enMetadataForms: NonNullable = { "enable.trackHistory": { label: "Track History" }, + "enable.fieldHistory": { + label: "Field History", + helpText: "Old → new values of changed fields on the record activity timeline. Unset means ON, though the switch shows off: only a switch turned on and then off writes false, which turns values off for the whole object." + }, "enable.searchable": { label: "Searchable" }, @@ -897,9 +905,13 @@ export const enMetadataForms: NonNullable = { label: "Internal", helpText: "Never return this field's value on the generic data path: the engine omits the key from find/findOne results and from the create and update response bodies, on the default projection and when a client names the field in ?select=. Storage, filtering and indexing are untouched." }, + fieldHistory: { + label: "Field History", + helpText: "Old → new values for this field on the record activity timeline. Unset means ON, though the switch shows off: only a switch turned on and then off writes false, which names the change by label only. On also shows a media or JSON field's values." + }, trackHistory: { label: "Track History", - helpText: "Render this field's value changes as entries on the record activity timeline (ADR-0052 §5b). Opt-in per field." + helpText: "Opt a media or JSON field (image, file, json, …) into old → new values on the activity timeline. Every other field shows them already, and off does not hide them: use Field History." }, widget: { label: "Widget", diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index e34ef46fd4f..b5ecf10ae58 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const esESMetadataForms: NonNullable = label: "Idioma", helpText: "Lenguaje del editor (p. ej. sql, javascript)" }, + "fields.fieldHistory": { + label: "Valores de cambios de campo", + helpText: "Valores anterior → nuevo de este campo en la cronología de actividad del registro. Sin definir equivale a ACTIVADO, aunque el interruptor se vea apagado: solo un interruptor encendido y luego apagado escribe false, y entonces el cambio se nombra solo con la etiqueta. Encendido también muestra los valores de un campo multimedia o JSON." + }, "fields.trackHistory": { label: "Seguimiento de historial", - helpText: "Resume este campo en la cronología de actividad del registro" + helpText: "Hace que un campo multimedia o JSON (imagen, archivo, json, …) muestre valores anterior → nuevo en la cronología de actividad. Los demás campos ya los muestran, y apagarlo no los oculta: use Valores de cambios de campo." }, "fields.visibleWhen": { label: "Condición de visibilidad", @@ -299,6 +303,10 @@ export const esESMetadataForms: NonNullable = "enable.trackHistory": { label: "Seguimiento de historial" }, + "enable.fieldHistory": { + label: "Valores de cambios de campo", + helpText: "Valores anterior → nuevo de los campos modificados en la cronología de actividad del registro. Sin definir equivale a ACTIVADO, aunque el interruptor se vea apagado: solo un interruptor encendido y luego apagado escribe false, y entonces el objeto entero deja de mostrar valores." + }, "enable.searchable": { label: "Buscable" }, @@ -897,9 +905,13 @@ export const esESMetadataForms: NonNullable = label: "Interno", helpText: "Nunca devuelve el valor de este campo por la ruta de datos genérica: el motor omite la clave en los resultados de find/findOne y en los cuerpos de respuesta de creación y actualización, tanto en la proyección predeterminada como cuando un cliente la nombra en ?select=. El almacenamiento, el filtrado y los índices no se ven afectados." }, + fieldHistory: { + label: "Valores de cambios de campo", + helpText: "Valores anterior → nuevo de este campo en la cronología de actividad del registro. Sin definir equivale a ACTIVADO, aunque el interruptor se vea apagado: solo un interruptor encendido y luego apagado escribe false, y entonces el cambio se nombra solo con la etiqueta. Encendido también muestra los valores de un campo multimedia o JSON." + }, trackHistory: { label: "Registrar historial", - helpText: "Muestra los cambios de valor de este campo como entradas en la línea de actividad del registro (ADR-0052 §5b). Se activa campo a campo." + helpText: "Hace que un campo multimedia o JSON (imagen, archivo, json, …) muestre valores anterior → nuevo en la cronología de actividad. Los demás campos ya los muestran, y apagarlo no los oculta: use Valores de cambios de campo." }, widget: { label: "Control del campo", diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index da2a9d0b5ca..03177c0c40c 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const frMetadataForms: NonNullable = { label: "Langue", helpText: "Langage de l’éditeur (par ex. sql, javascript)" }, + "fields.fieldHistory": { + label: "Valeurs des modifications de champ", + helpText: "Valeurs ancienne → nouvelle de ce champ dans la chronologie d’activité de l’enregistrement. Non défini signifie ACTIVÉ, même si l’interrupteur paraît éteint : seul un interrupteur allumé puis éteint écrit false, et la modification n’est alors nommée que par son libellé. Allumé, il affiche aussi les valeurs d’un champ média ou JSON." + }, "fields.trackHistory": { label: "Suivre l’historique", - helpText: "Résumer ce champ dans la chronologie d’activité de l’enregistrement" + helpText: "Fait afficher à un champ média ou JSON (image, fichier, json, …) ses valeurs ancienne → nouvelle dans la chronologie d’activité. Les autres champs les affichent déjà, et l’éteindre ne les masque pas : utilisez Valeurs des modifications de champ." }, "fields.visibleWhen": { label: "Visible si", @@ -299,6 +303,10 @@ export const frMetadataForms: NonNullable = { "enable.trackHistory": { label: "Suivre l’historique" }, + "enable.fieldHistory": { + label: "Valeurs des modifications de champ", + helpText: "Valeurs ancienne → nouvelle des champs modifiés dans la chronologie d’activité de l’enregistrement. Non défini signifie ACTIVÉ, même si l’interrupteur paraît éteint : seul un interrupteur allumé puis éteint écrit false, et l’objet entier n’affiche alors plus de valeurs." + }, "enable.searchable": { label: "Recherchable" }, @@ -897,9 +905,13 @@ export const frMetadataForms: NonNullable = { label: "Interne", helpText: "Ne jamais renvoyer la valeur de ce champ par le chemin de données générique : le moteur omet la clé des résultats find/findOne et des corps de réponse de création et de mise à jour, avec la projection par défaut comme lorsqu’un client nomme le champ dans ?select=. Le stockage, le filtrage et l’indexation ne sont pas affectés." }, + fieldHistory: { + label: "Valeurs des modifications de champ", + helpText: "Valeurs ancienne → nouvelle de ce champ dans la chronologie d’activité de l’enregistrement. Non défini signifie ACTIVÉ, même si l’interrupteur paraît éteint : seul un interrupteur allumé puis éteint écrit false, et la modification n’est alors nommée que par son libellé. Allumé, il affiche aussi les valeurs d’un champ média ou JSON." + }, trackHistory: { label: "Suivre l’historique", - helpText: "Afficher les modifications de valeur de ce champ sous forme d’entrées dans la chronologie d’activité de l’enregistrement (ADR-0052 §5b). Activation par champ." + helpText: "Fait afficher à un champ média ou JSON (image, fichier, json, …) ses valeurs ancienne → nouvelle dans la chronologie d’activité. Les autres champs les affichent déjà, et l’éteindre ne les masque pas : utilisez Valeurs des modifications de champ." }, widget: { label: "Widget", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index ec59b0067fa..a34d3a918c9 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const jaJPMetadataForms: NonNullable = label: "言語", helpText: "エディター言語(例: sql, javascript)" }, + "fields.fieldHistory": { + label: "フィールド変更値", + helpText: "このフィールドの旧値 → 新値をレコードのアクティビティタイムラインに表示します。未設定はオンです(スイッチはオフに見えます)。一度オンにしてからオフにしたときだけ false が書かれ、変更は項目名だけで示されます。オンにするとメディアや JSON の項目も値を表示します。" + }, "fields.trackHistory": { label: "履歴追跡", - helpText: "レコードのアクティビティタイムラインでこのフィールドを要約する" + helpText: "メディアや JSON の項目(画像、ファイル、json など)で、アクティビティタイムラインに旧値 → 新値を表示します。他の項目はもともと表示され、オフにしても値は隠れません。隠すには「フィールド変更値」を使います。" }, "fields.visibleWhen": { label: "表示条件", @@ -299,6 +303,10 @@ export const jaJPMetadataForms: NonNullable = "enable.trackHistory": { label: "履歴追跡" }, + "enable.fieldHistory": { + label: "フィールド変更値", + helpText: "変更されたフィールドの旧値 → 新値をレコードのアクティビティタイムラインに表示します。未設定はオンです(スイッチはオフに見えます)。一度オンにしてからオフにしたときだけ false が書かれ、オブジェクト全体で値が表示されなくなります。" + }, "enable.searchable": { label: "検索可能" }, @@ -897,9 +905,13 @@ export const jaJPMetadataForms: NonNullable = label: "外部に返さない", helpText: "この項目の値を汎用データ経路では返しません。エンジンは find/findOne の結果と、作成・更新のレスポンスボディからこのキーを削除します。既定の射影でも、クライアントが ?select= で名指ししたときも同様です。保存・絞り込み・インデックスには影響しません。" }, + fieldHistory: { + label: "フィールド変更値", + helpText: "このフィールドの旧値 → 新値をレコードのアクティビティタイムラインに表示します。未設定はオンです(スイッチはオフに見えます)。一度オンにしてからオフにしたときだけ false が書かれ、変更は項目名だけで示されます。オンにするとメディアや JSON の項目も値を表示します。" + }, trackHistory: { label: "変更履歴を記録", - helpText: "この項目の値の変更を、レコードのアクティビティタイムラインの項目として表示します(ADR-0052 §5b)。項目ごとのオプトインです。" + helpText: "メディアや JSON の項目(画像、ファイル、json など)で、アクティビティタイムラインに旧値 → 新値を表示します。他の項目はもともと表示され、オフにしても値は隠れません。隠すには「フィールド変更値」を使います。" }, widget: { label: "ウィジェット指定", diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index b7211e1676d..7b0dcccb192 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const koMetadataForms: NonNullable = { label: "언어", helpText: "편집기 언어(예: sql, javascript)" }, + "fields.fieldHistory": { + label: "필드 변경 값", + helpText: "레코드 활동 타임라인에 이 필드의 이전 값 → 새 값을 표시합니다. 설정하지 않으면 켜져 있으며 스위치는 꺼진 것처럼 보입니다. 켰다가 다시 끈 경우에만 false가 기록되고, 변경은 필드 이름으로만 표시됩니다. 켜면 미디어나 JSON 필드도 값을 표시합니다." + }, "fields.trackHistory": { label: "기록 추적", - helpText: "레코드 활동 타임라인에 이 필드를 요약합니다" + helpText: "미디어나 JSON 필드(이미지, 파일, json 등)가 활동 타임라인에 이전 값 → 새 값을 표시하게 합니다. 다른 필드는 이미 표시하며, 꺼도 값이 숨겨지지 않습니다. 숨기려면 필드 변경 값을 사용하세요." }, "fields.visibleWhen": { label: "표시 조건", @@ -299,6 +303,10 @@ export const koMetadataForms: NonNullable = { "enable.trackHistory": { label: "기록 추적" }, + "enable.fieldHistory": { + label: "필드 변경 값", + helpText: "레코드 활동 타임라인에 변경된 필드의 이전 값 → 새 값을 표시합니다. 설정하지 않으면 켜져 있으며 스위치는 꺼진 것처럼 보입니다. 켰다가 다시 끈 경우에만 false가 기록되고, 객체 전체에서 값이 표시되지 않습니다." + }, "enable.searchable": { label: "검색 가능" }, @@ -897,9 +905,13 @@ export const koMetadataForms: NonNullable = { label: "내부", helpText: "일반 데이터 경로에서 이 필드의 값을 절대 반환하지 않습니다. 엔진은 기본 투영과 클라이언트가 ?select=에서 필드를 지정한 경우 모두, find/findOne 결과와 create, update 응답 본문에서 키를 생략합니다. 저장, 필터링, 색인에는 영향이 없습니다." }, + fieldHistory: { + label: "필드 변경 값", + helpText: "레코드 활동 타임라인에 이 필드의 이전 값 → 새 값을 표시합니다. 설정하지 않으면 켜져 있으며 스위치는 꺼진 것처럼 보입니다. 켰다가 다시 끈 경우에만 false가 기록되고, 변경은 필드 이름으로만 표시됩니다. 켜면 미디어나 JSON 필드도 값을 표시합니다." + }, trackHistory: { label: "기록 추적", - helpText: "이 필드의 값 변경을 레코드 활동 타임라인의 항목으로 렌더링합니다(ADR-0052 §5b). 필드별로 선택합니다." + helpText: "미디어나 JSON 필드(이미지, 파일, json 등)가 활동 타임라인에 이전 값 → 새 값을 표시하게 합니다. 다른 필드는 이미 표시하며, 꺼도 값이 숨겨지지 않습니다. 숨기려면 필드 변경 값을 사용하세요." }, widget: { label: "위젯", diff --git a/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts index 55ab3652c0b..a6d0b7ed1fa 100644 --- a/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts @@ -956,9 +956,16 @@ describe('#19403 round 8 — the population, DERIVED from the form and a shape', // switch (ruling 7000907189 point 1) — a label and a help text, two leaves, // all translated leaves authored by the same card. `advanced` reads // 104 → 106; `capabilities` is untouched. - expect(PANEL_LEAVES.length).toBe(117); + // 118 since #36290: the `enable` composite offers `fieldHistory` (the + // object's off switch for old → new values on the activity stream) — one + // label leaf, authored in every locale by the same card. `capabilities` + // reads 11 → 12; `advanced` is untouched. + // 119 since that card's L2 (S1) gave the `enable.fieldHistory` row a help + // text saying what an unset switch means — one leaf, authored in every + // locale. `capabilities` reads 12 → 13. + expect(PANEL_LEAVES.length).toBe(119); expect(PANEL_LEAVES.every((l) => l.prop === 'label' || l.prop === 'helpText')).toBe(true); - expect(PANEL_LEAVES.filter((l) => l.section === 'capabilities').length).toBe(11); + expect(PANEL_LEAVES.filter((l) => l.section === 'capabilities').length).toBe(13); expect(PANEL_LEAVES.filter((l) => l.section === 'advanced').length).toBe(106); }); @@ -995,7 +1002,10 @@ describe('#19403 round 8 — the population, DERIVED from the form and a shape', // 128 since #35985 gave `basics` the `color` row (the object's palette // colour) — label and help text, authored in every translated locale by // that card, so `openEchoes` stays at zero. - expect(OPEN_LEAVES.length).toBe(128); + // 130 since #36290 gave the `fields` repeater its `fieldHistory` sub-row + // (a field's off switch for old → new values) — label and help text, + // authored in every translated locale, so `openEchoes` stays at zero. + expect(OPEN_LEAVES.length).toBe(130); expect(PANEL_LEAVES.some((l) => l.path === 'fields.placeholder')).toBe(false); expect(OPEN_LEAVES.some((l) => l.path === 'fields.placeholder')).toBe(true); for (const path of ['name', 'label', 'fields', 'fields.valueDomain', 'fields.deleteBehavior', 'fields.expression']) { @@ -1117,14 +1127,15 @@ describe('#19403 round 8 — the population, DERIVED from the form and a shape', expect(flagged.length).toBe(PANEL_LEAVES.length); }); - it('⭐ the capability block is now DONE — zero of its 11 leaves echoes in any locale', () => { + it('⭐ the capability block is now DONE — zero of its 13 leaves echoes in any locale', () => { const capability = PANEL_LEAVES.filter((l) => l.section === 'capabilities'); const echoing = capability.filter((l) => TRANSLATED_LOCALES.some(([, forms]) => catalogLeaf(forms, l.path, l.prop) === l.en), ); expect(echoing.map((l) => `${l.path}.${l.prop}`)).toEqual([]); // Lit — and it really walked the section, which a zero alone would not show. - expect(capability.length).toBe(11); + // 13 since #36290 added `enable.fieldHistory` and its help text. + expect(capability.length).toBe(13); }); }); diff --git a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts index 932796c27ee..c85ff3d2ea4 100644 --- a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts @@ -1302,7 +1302,12 @@ describe('#19403 round 10 — the verdicts, on the live bundles', () => { // all three locales. // 756 since #35985: the object form's `basics` offers a `color` row, // whose label zh-CN translates. - expect(translated.length, `${locale} positive control`).toBe(756); + // 757 since #36290: the object form's `enable` composite offers + // `fieldHistory` — one row label, authored in all three locales. + // 759 since #36290's field off switch: the object form's `fields` + // repeater and the field form each offer a `fieldHistory` row — two + // row labels, authored in all three locales. + expect(translated.length, `${locale} positive control`).toBe(759); } // ⭐ DARK — the blindness, executable. On a synthetic two-locale catalog the // all-three predicate returns 0 while the per-locale one returns 1, so the diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 70a0a596e36..52efdf3c24c 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const ptBRMetadataForms: NonNullable = label: "Linguagem", helpText: "Linguagem do editor (por exemplo sql, javascript)" }, + "fields.fieldHistory": { + label: "Valores de alterações de campo", + helpText: "Valores antigo → novo deste campo na linha do tempo de atividades do registro. Não definido significa LIGADO, embora o interruptor pareça desligado: só um interruptor ligado e depois desligado grava false, e então a alteração é nomeada só pelo rótulo. Ligado também mostra os valores de um campo de mídia ou JSON." + }, "fields.trackHistory": { label: "Acompanhar histórico", - helpText: "Resumir este campo na linha do tempo de atividades do registro" + helpText: "Faz um campo de mídia ou JSON (imagem, arquivo, json, …) mostrar valores antigo → novo na linha do tempo de atividades. Os outros campos já os mostram, e desligar não os oculta: use Valores de alterações de campo." }, "fields.visibleWhen": { label: "Visível quando", @@ -299,6 +303,10 @@ export const ptBRMetadataForms: NonNullable = "enable.trackHistory": { label: "Acompanhar histórico" }, + "enable.fieldHistory": { + label: "Valores de alterações de campo", + helpText: "Valores antigo → novo dos campos alterados na linha do tempo de atividades do registro. Não definido significa LIGADO, embora o interruptor pareça desligado: só um interruptor ligado e depois desligado grava false, e então o objeto inteiro deixa de mostrar valores." + }, "enable.searchable": { label: "Pesquisável" }, @@ -897,9 +905,13 @@ export const ptBRMetadataForms: NonNullable = label: "Interno", helpText: "Nunca retornar o valor deste campo pelo caminho de dados genérico: o mecanismo omite a chave dos resultados de find/findOne e dos corpos de resposta de criação e atualização, na projeção padrão e quando um cliente nomeia o campo em ?select=. O armazenamento, a filtragem e a indexação não são afetados." }, + fieldHistory: { + label: "Valores de alterações de campo", + helpText: "Valores antigo → novo deste campo na linha do tempo de atividades do registro. Não definido significa LIGADO, embora o interruptor pareça desligado: só um interruptor ligado e depois desligado grava false, e então a alteração é nomeada só pelo rótulo. Ligado também mostra os valores de um campo de mídia ou JSON." + }, trackHistory: { label: "Acompanhar histórico", - helpText: "Exibir as alterações de valor deste campo como entradas na linha do tempo de atividades do registro (ADR-0052 §5b). Ativação opcional por campo." + helpText: "Faz um campo de mídia ou JSON (imagem, arquivo, json, …) mostrar valores antigo → novo na linha do tempo de atividades. Os outros campos já os mostram, e desligar não os oculta: use Valores de alterações de campo." }, widget: { label: "Widget", diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index 68a4d1c4dc5..a8a4606d227 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const ruMetadataForms: NonNullable = { label: "Язык", helpText: "Язык редактора (например, sql, javascript)" }, + "fields.fieldHistory": { + label: "Значения изменений поля", + helpText: "Старое → новое значение этого поля в ленте активности записи. Не задано — значит ВКЛЮЧЕНО, хотя переключатель выглядит выключенным: false записывается, только если переключатель включить и снова выключить, и тогда изменение называется только по имени поля. Включённый переключатель показывает и значения медиа- или JSON-поля." + }, "fields.trackHistory": { label: "Отслеживать историю", - helpText: "Отражать это поле в ленте активности записи" + helpText: "Позволяет медиа- или JSON-полю (изображение, файл, json, …) показывать старое → новое значение в ленте активности. Остальные поля показывают их и так, и выключение их не скрывает: для этого есть «Значения изменений поля»." }, "fields.visibleWhen": { label: "Видимо, когда", @@ -299,6 +303,10 @@ export const ruMetadataForms: NonNullable = { "enable.trackHistory": { label: "Отслеживать историю" }, + "enable.fieldHistory": { + label: "Значения изменений поля", + helpText: "Старые → новые значения изменённых полей в ленте активности записи. Не задано — значит ВКЛЮЧЕНО, хотя переключатель выглядит выключенным: false записывается, только если переключатель включить и снова выключить, и тогда весь объект перестаёт показывать значения." + }, "enable.searchable": { label: "Доступно для поиска" }, @@ -897,9 +905,13 @@ export const ruMetadataForms: NonNullable = { label: "Внутреннее", helpText: "Никогда не возвращать значение этого поля через общий путь данных: движок исключает ключ из результатов find/findOne и из тел ответов на создание и обновление — как в проекции по умолчанию, так и когда клиент указывает поле в ?select=. Хранение, фильтрация и индексирование не затрагиваются." }, + fieldHistory: { + label: "Значения изменений поля", + helpText: "Старое → новое значение этого поля в ленте активности записи. Не задано — значит ВКЛЮЧЕНО, хотя переключатель выглядит выключенным: false записывается, только если переключатель включить и снова выключить, и тогда изменение называется только по имени поля. Включённый переключатель показывает и значения медиа- или JSON-поля." + }, trackHistory: { label: "Отслеживать историю", - helpText: "Отображать изменения значения этого поля как записи в ленте активности записи (ADR-0052 §5b). Включается для каждого поля отдельно." + helpText: "Позволяет медиа- или JSON-полю (изображение, файл, json, …) показывать старое → новое значение в ленте активности. Остальные поля показывают их и так, и выключение их не скрывает: для этого есть «Значения изменений поля»." }, widget: { label: "Виджет", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index f1ce4b6dbe8..00ec730e688 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const zhCNMetadataForms: NonNullable = label: "语言", helpText: "编辑器语言(如 sql、javascript)" }, + "fields.fieldHistory": { + label: "字段修改值", + helpText: "在记录的活动时间线上显示该字段的旧值 → 新值。未设置即为开启,尽管开关显示为关:只有先打开再关闭才会写入 false,此时只写出字段名。打开时,媒体或 JSON 字段也会显示值。" + }, "fields.trackHistory": { label: "历史跟踪", - helpText: "在记录的活动时间线上概述该字段的变更" + helpText: "让媒体或 JSON 字段(图片、文件、json 等)在活动时间线上显示旧值 → 新值。其他字段本来就会显示,关掉它也不会隐藏值:请用「字段修改值」。" }, "fields.visibleWhen": { label: "可见条件", @@ -299,6 +303,10 @@ export const zhCNMetadataForms: NonNullable = "enable.trackHistory": { label: "历史跟踪" }, + "enable.fieldHistory": { + label: "字段修改值", + helpText: "在记录的活动时间线上显示被修改字段的旧值 → 新值。未设置即为开启,尽管开关显示为关:只有先打开再关闭才会写入 false,此时整个对象都不显示值。" + }, "enable.searchable": { label: "可搜索" }, @@ -897,9 +905,13 @@ export const zhCNMetadataForms: NonNullable = label: "不对外返回", helpText: "该字段的值永远不经通用数据通道返回:引擎会从 find/findOne 结果以及创建和更新的响应体中删除这个键——默认投影如此,客户端在 ?select= 中点名它时同样如此。存储、过滤和索引都不受影响。" }, + fieldHistory: { + label: "字段修改值", + helpText: "在记录的活动时间线上显示该字段的旧值 → 新值。未设置即为开启,尽管开关显示为关:只有先打开再关闭才会写入 false,此时只写出字段名。打开时,媒体或 JSON 字段也会显示值。" + }, trackHistory: { label: "记录变更历史", - helpText: "把该字段的值变更渲染为记录活动时间线上的条目(ADR-0052 §5b)。按字段逐个开启。" + helpText: "让媒体或 JSON 字段(图片、文件、json 等)在活动时间线上显示旧值 → 新值。其他字段本来就会显示,关掉它也不会隐藏值:请用「字段修改值」。" }, widget: { label: "控件覆盖", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index c4e3569d0a2..7805b868260 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -276,9 +276,13 @@ export const zhHantMetadataForms: NonNullable label: "語言", helpText: "編輯器語言(如 sql、javascript)" }, + "fields.fieldHistory": { + label: "欄位修改值", + helpText: "在記錄的活動時間軸上顯示該欄位的舊值 → 新值。未設定即為開啟,儘管開關顯示為關:只有先打開再關閉才會寫入 false,此時只寫出欄位名。打開時,媒體或 JSON 欄位也會顯示值。" + }, "fields.trackHistory": { label: "歷史追蹤", - helpText: "在記錄的活動時間軸上概述該欄位的變更" + helpText: "讓媒體或 JSON 欄位(圖片、檔案、json 等)在活動時間軸上顯示舊值 → 新值。其他欄位本來就會顯示,關掉它也不會隱藏值:請用「欄位修改值」。" }, "fields.visibleWhen": { label: "可見條件", @@ -299,6 +303,10 @@ export const zhHantMetadataForms: NonNullable "enable.trackHistory": { label: "歷史追蹤" }, + "enable.fieldHistory": { + label: "欄位修改值", + helpText: "在記錄的活動時間軸上顯示被修改欄位的舊值 → 新值。未設定即為開啟,儘管開關顯示為關:只有先打開再關閉才會寫入 false,此時整個物件都不顯示值。" + }, "enable.searchable": { label: "可搜尋" }, @@ -897,9 +905,13 @@ export const zhHantMetadataForms: NonNullable label: "不對外傳回", helpText: "該欄位的值永遠不經通用資料通道傳回:引擎會從 find/findOne 結果以及建立和更新的回應體中刪除這個鍵——預設投影如此,用戶端在 ?select= 中點名它時同樣如此。儲存、過濾和索引都不受影響。" }, + fieldHistory: { + label: "欄位修改值", + helpText: "在記錄的活動時間軸上顯示該欄位的舊值 → 新值。未設定即為開啟,儘管開關顯示為關:只有先打開再關閉才會寫入 false,此時只寫出欄位名。打開時,媒體或 JSON 欄位也會顯示值。" + }, trackHistory: { label: "記錄變更歷史", - helpText: "把該欄位的值變更呈現為記錄活動時間軸上的條目(ADR-0052 §5b)。依欄位逐個開啟。" + helpText: "讓媒體或 JSON 欄位(圖片、檔案、json 等)在活動時間軸上顯示舊值 → 新值。其他欄位本來就會顯示,關掉它也不會隱藏值:請用「欄位修改值」。" }, widget: { label: "控制項覆寫", diff --git a/packages/platform-objects/src/audit/sys-attachment.object.ts b/packages/platform-objects/src/audit/sys-attachment.object.ts index a0f4246a94f..3d31f5916ed 100644 --- a/packages/platform-objects/src/audit/sys-attachment.object.ts +++ b/packages/platform-objects/src/audit/sys-attachment.object.ts @@ -140,6 +140,7 @@ export const SysAttachment = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: true, apiEnabled: true, // [#2970 item 5 / ADR-0049] `trash` is `dead` in the liveness ledger (no diff --git a/packages/platform-objects/src/identity/sys-account.object.ts b/packages/platform-objects/src/identity/sys-account.object.ts index e9f3560fe69..9091b6c02a9 100644 --- a/packages/platform-objects/src/identity/sys-account.object.ts +++ b/packages/platform-objects/src/identity/sys-account.object.ts @@ -338,6 +338,7 @@ export const SysAccount = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // #1591 — reads only: writes are refused by the identity write guard diff --git a/packages/platform-objects/src/identity/sys-device-code.object.ts b/packages/platform-objects/src/identity/sys-device-code.object.ts index 10a228bd889..2cf77bbc268 100644 --- a/packages/platform-objects/src/identity/sys-device-code.object.ts +++ b/packages/platform-objects/src/identity/sys-device-code.object.ts @@ -168,6 +168,7 @@ export const SysDeviceCode = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // #1591 — reads only: writes are refused by the identity write guard diff --git a/packages/platform-objects/src/identity/sys-jwks.object.ts b/packages/platform-objects/src/identity/sys-jwks.object.ts index 8ee3bf73074..9159a1072f4 100644 --- a/packages/platform-objects/src/identity/sys-jwks.object.ts +++ b/packages/platform-objects/src/identity/sys-jwks.object.ts @@ -120,6 +120,7 @@ export const SysJwks = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-access-token.object.ts b/packages/platform-objects/src/identity/sys-oauth-access-token.object.ts index 24416665672..42ee1c7a220 100644 --- a/packages/platform-objects/src/identity/sys-oauth-access-token.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-access-token.object.ts @@ -171,6 +171,7 @@ export const SysOauthAccessToken = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-client-assertion.object.ts b/packages/platform-objects/src/identity/sys-oauth-client-assertion.object.ts index 1804426a1ed..2c6d7d69d6f 100644 --- a/packages/platform-objects/src/identity/sys-oauth-client-assertion.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-client-assertion.object.ts @@ -46,6 +46,7 @@ export const SysOauthClientAssertion = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-client-resource.object.ts b/packages/platform-objects/src/identity/sys-oauth-client-resource.object.ts index 2f4d57988cd..66aca06e090 100644 --- a/packages/platform-objects/src/identity/sys-oauth-client-resource.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-client-resource.object.ts @@ -114,6 +114,7 @@ export const SysOauthClientResource = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-consent.object.ts b/packages/platform-objects/src/identity/sys-oauth-consent.object.ts index 3f9d208553a..f3bb250fdd5 100644 --- a/packages/platform-objects/src/identity/sys-oauth-consent.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-consent.object.ts @@ -137,6 +137,7 @@ export const SysOauthConsent = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-refresh-token.object.ts b/packages/platform-objects/src/identity/sys-oauth-refresh-token.object.ts index 51a3d899002..120ac9316d9 100644 --- a/packages/platform-objects/src/identity/sys-oauth-refresh-token.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-refresh-token.object.ts @@ -187,6 +187,7 @@ export const SysOauthRefreshToken = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-oauth-resource.object.ts b/packages/platform-objects/src/identity/sys-oauth-resource.object.ts index 98ddf178ddb..6b7dfa0ae2f 100644 --- a/packages/platform-objects/src/identity/sys-oauth-resource.object.ts +++ b/packages/platform-objects/src/identity/sys-oauth-resource.object.ts @@ -162,6 +162,7 @@ export const SysOauthResource = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/identity/sys-personal-view.object.ts b/packages/platform-objects/src/identity/sys-personal-view.object.ts index 04bb5649d1f..c7aa3fc4dde 100644 --- a/packages/platform-objects/src/identity/sys-personal-view.object.ts +++ b/packages/platform-objects/src/identity/sys-personal-view.object.ts @@ -132,6 +132,7 @@ export const SysPersonalView = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // No `apiMethods` — default-open, like `sys_user_preference`. No shipped diff --git a/packages/platform-objects/src/identity/sys-session.object.ts b/packages/platform-objects/src/identity/sys-session.object.ts index 8688e6f3a3a..e6288f4f848 100644 --- a/packages/platform-objects/src/identity/sys-session.object.ts +++ b/packages/platform-objects/src/identity/sys-session.object.ts @@ -384,6 +384,7 @@ export const SysSession = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // #1591 — reads only: writes are refused by the identity write guard diff --git a/packages/platform-objects/src/identity/sys-two-factor.object.ts b/packages/platform-objects/src/identity/sys-two-factor.object.ts index cf954f83a3d..cd6c0150ea7 100644 --- a/packages/platform-objects/src/identity/sys-two-factor.object.ts +++ b/packages/platform-objects/src/identity/sys-two-factor.object.ts @@ -263,6 +263,7 @@ export const SysTwoFactor = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // #1591 — reads only: writes are refused by the identity write guard diff --git a/packages/platform-objects/src/identity/sys-user-preference.object.ts b/packages/platform-objects/src/identity/sys-user-preference.object.ts index 113760f0252..feeb71f3d05 100644 --- a/packages/platform-objects/src/identity/sys-user-preference.object.ts +++ b/packages/platform-objects/src/identity/sys-user-preference.object.ts @@ -146,6 +146,7 @@ export const SysUserPreference = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // No `apiMethods` — default-open (#3543 audit): the previous whitelist diff --git a/packages/platform-objects/src/identity/sys-verification.object.ts b/packages/platform-objects/src/identity/sys-verification.object.ts index 93946abbb5a..88d1744e2c3 100644 --- a/packages/platform-objects/src/identity/sys-verification.object.ts +++ b/packages/platform-objects/src/identity/sys-verification.object.ts @@ -184,6 +184,7 @@ export const SysVerification = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // #1591 — reads only: writes are refused by the identity write guard diff --git a/packages/platform-objects/src/system/sys-lifecycle-state.object.ts b/packages/platform-objects/src/system/sys-lifecycle-state.object.ts index d28da14a1b4..ea28b6fc3e2 100644 --- a/packages/platform-objects/src/system/sys-lifecycle-state.object.ts +++ b/packages/platform-objects/src/system/sys-lifecycle-state.object.ts @@ -86,6 +86,7 @@ export const SysLifecycleState = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, // Internal clock state — no data API at all. The sweeper reads and writes // it in process, under a system context. diff --git a/packages/platform-objects/src/system/sys-migration-journal.object.ts b/packages/platform-objects/src/system/sys-migration-journal.object.ts index a6cdf1bf632..c65941c36f6 100644 --- a/packages/platform-objects/src/system/sys-migration-journal.object.ts +++ b/packages/platform-objects/src/system/sys-migration-journal.object.ts @@ -184,6 +184,7 @@ export const SysMigrationJournal = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // Diagnostic read surface only. Writes go through the runner in system diff --git a/packages/platform-objects/src/system/sys-migration.object.ts b/packages/platform-objects/src/system/sys-migration.object.ts index 7cf9a21ccb3..0eddfaf30ab 100644 --- a/packages/platform-objects/src/system/sys-migration.object.ts +++ b/packages/platform-objects/src/system/sys-migration.object.ts @@ -167,6 +167,7 @@ export const SysMigration = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // Diagnostic read surface only — writes go through recordDataMigrationRun diff --git a/packages/platform-objects/src/system/sys-platform-setting-audit.object.ts b/packages/platform-objects/src/system/sys-platform-setting-audit.object.ts index ff2c6252296..b3baa53c96e 100644 --- a/packages/platform-objects/src/system/sys-platform-setting-audit.object.ts +++ b/packages/platform-objects/src/system/sys-platform-setting-audit.object.ts @@ -176,6 +176,7 @@ export const SysPlatformSettingAudit = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream // [ADR-0103] Engine-owned: appended by the settings service (SYSTEM_CTX), // never via the generic data API. Reads stay open for compliance review. apiMethods: ['get', 'list'], diff --git a/packages/platform-objects/src/system/sys-platform-setting.object.ts b/packages/platform-objects/src/system/sys-platform-setting.object.ts index 6ddbb74d22c..a9501f37b9c 100644 --- a/packages/platform-objects/src/system/sys-platform-setting.object.ts +++ b/packages/platform-objects/src/system/sys-platform-setting.object.ts @@ -140,6 +140,7 @@ export const SysPlatformSetting = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // Reads for a diagnostic grid; writes go through /api/settings/:namespace diff --git a/packages/platform-objects/src/system/sys-recycle-bin.object.ts b/packages/platform-objects/src/system/sys-recycle-bin.object.ts index f19a654efb3..dfca5d25650 100644 --- a/packages/platform-objects/src/system/sys-recycle-bin.object.ts +++ b/packages/platform-objects/src/system/sys-recycle-bin.object.ts @@ -118,6 +118,7 @@ export const SysRecycleBin = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: false, apiMethods: [], diff --git a/packages/platform-objects/src/system/sys-secret.object.ts b/packages/platform-objects/src/system/sys-secret.object.ts index f8af9ad0ae5..ab61c9d273e 100644 --- a/packages/platform-objects/src/system/sys-secret.object.ts +++ b/packages/platform-objects/src/system/sys-secret.object.ts @@ -181,6 +181,7 @@ export const SysSecret = ObjectSchema.create({ // its producer-scoped label, key id, algorithm and version — and keeps no // copy of the key material (plugin-audit `key-material-copy.ts`). trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream // [ADR-0103] Engine-owned: secrets are minted/rotated only by the settings / // secret service (SYSTEM_CTX), never via the generic data API. Locked to // reads (ciphertext only; decryption is a separate privileged path). Since diff --git a/packages/platform-objects/src/system/sys-seed-landed-key.object.ts b/packages/platform-objects/src/system/sys-seed-landed-key.object.ts index 901808849dc..0a704a9cf82 100644 --- a/packages/platform-objects/src/system/sys-seed-landed-key.object.ts +++ b/packages/platform-objects/src/system/sys-seed-landed-key.object.ts @@ -106,6 +106,7 @@ export const SysSeedLandedKey = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, // Internal state — no data API at all. The seed loader reads and writes // it in process, under the seed write context. diff --git a/packages/platform-objects/src/system/sys-setting-audit.object.ts b/packages/platform-objects/src/system/sys-setting-audit.object.ts index 421184f012a..4ce8fd66892 100644 --- a/packages/platform-objects/src/system/sys-setting-audit.object.ts +++ b/packages/platform-objects/src/system/sys-setting-audit.object.ts @@ -190,6 +190,7 @@ export const SysSettingAudit = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream // [ADR-0103] Engine-owned: appended by the settings service (SYSTEM_CTX), // never via the generic data API. Reads stay open for compliance review. apiMethods: ['get', 'list'], diff --git a/packages/platform-objects/src/system/sys-setting.object.ts b/packages/platform-objects/src/system/sys-setting.object.ts index 6da48e35bd5..3da52eba9a1 100644 --- a/packages/platform-objects/src/system/sys-setting.object.ts +++ b/packages/platform-objects/src/system/sys-setting.object.ts @@ -251,6 +251,7 @@ export const SysSetting = ObjectSchema.create({ // layer when needed) to avoid bloating sys_history with churn from // feature flags and similar high-frequency toggles. trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // Direct data API exposed for the admin grid view, but writes from diff --git a/packages/platform-objects/src/system/sys-trusted-key.object.ts b/packages/platform-objects/src/system/sys-trusted-key.object.ts index 9ec5035c56c..f9ae377ea9c 100644 --- a/packages/platform-objects/src/system/sys-trusted-key.object.ts +++ b/packages/platform-objects/src/system/sys-trusted-key.object.ts @@ -170,6 +170,7 @@ export const SysTrustedKey = ObjectSchema.create({ enable: { trackHistory: false, + fieldHistory: false, // [#36290] keeps this object's "no history": values off in the activity stream searchable: false, apiEnabled: true, // Diagnostic read surface only — writes go through `os plugin trust` diff --git a/packages/plugins/plugin-audit/src/activity-field-redaction.test.ts b/packages/plugins/plugin-audit/src/activity-field-redaction.test.ts index d3bf84e5b9f..1647847b8b4 100644 --- a/packages/plugins/plugin-audit/src/activity-field-redaction.test.ts +++ b/packages/plugins/plugin-audit/src/activity-field-redaction.test.ts @@ -235,9 +235,13 @@ describe('[#21081] sys_activity value-bearing columns are served through the sec expect(blob).not.toContain(V.masked2); }); - it('masked: a summary composed from that field is dropped, and one composed from served fields is kept', async () => { + it('masked: a milestone composed from that field is dropped, a field-change summary keeps only the served changes, and one composed from served fields is kept', async () => { const rows = byChange(await read(MASKED_READER)); - expect(rows.allTracked).not.toHaveProperty('summary'); + // [#36290] Re-composed from the changes this reader is served, never dropped whole. + expect(String(rows.allTracked?.summary)).toContain(V.open2); + expect(String(rows.allTracked?.summary)).toContain(V.unserved2); + expect(String(rows.allTracked?.summary)).not.toContain(V.masked2); + expect(String(rows.allTracked?.summary)).not.toContain('Masked'); expect(rows.milestone).not.toHaveProperty('summary'); expect(String(rows.openOnly?.summary)).toContain(V.open3); expect(String(rows.created?.summary)).toContain('item'); @@ -254,6 +258,49 @@ describe('[#21081] sys_activity value-bearing columns are served through the sec expect(tracked.new).toHaveProperty('f_open', V.open2); }); + // ── [#36290] the field-change code, served narrowed change by change ──── + + /** The served field-change code of a row, or `undefined`. */ + const codeOf = (row: Row | undefined) => + typeof row?.metadata === 'string' ? JSON.parse(row.metadata).summary_message : undefined; + + it('[#36290] at rest the field-change code names every changed field, with both values', async () => { + const code = codeOf(byChange(await read(SYS)).allTracked); + expect(code?.key).toBe('fieldChanges'); + expect(code.changes.map((c: Row) => c.field)).toEqual(['f_masked', 'f_unserved', 'f_open']); + expect(JSON.stringify(code)).toContain(V.masked2); + expect(JSON.stringify(code)).toContain(V.unserved2); + }); + + it('[#36290] masked: the code is served without the change of the field served masked', async () => { + const code = codeOf(byChange(await read(MASKED_READER)).allTracked); + expect(code?.key).toBe('fieldChanges'); + expect(code.changes.map((c: Row) => c.field)).toEqual(['f_unserved', 'f_open']); + expect(JSON.stringify(code)).not.toContain(V.masked1); + expect(JSON.stringify(code)).not.toContain(V.masked2); + }); + + it('[#36290] not served: the code and the summary are served without the change of the field not served', async () => { + const row = byChange(await read(UNSERVED_READER)).allTracked; + const code = codeOf(row); + expect(code.changes.map((c: Row) => c.field)).toEqual(['f_masked', 'f_open']); + expect(JSON.stringify(code)).not.toContain(V.unserved2); + expect(String(row?.summary)).toContain(V.masked2); + expect(String(row?.summary)).not.toContain(V.unserved2); + expect(String(row?.summary)).not.toContain('Unserved'); + }); + + it('[#36290] control: a reader served every field is served the whole code', async () => { + const code = codeOf(byChange(await read(CONTROL)).allTracked); + expect(code.changes.map((c: Row) => c.field)).toEqual(['f_masked', 'f_unserved', 'f_open']); + }); + + it('[#36290] a code other than a field-change code is still never served to a reader', async () => { + const rows = byChange(await read(CONTROL)); + expect(codeOf(rows.created)).toBeUndefined(); + expect(codeOf(byChange(await read(SYS)).created)?.key).toBe('activityCreated'); + }); + // ── a field not served ────────────────────────────────────────────────── it('not served: no row served to the reader carries a value of a field it may not read', async () => { @@ -315,7 +362,8 @@ describe('[#21081] sys_activity value-bearing columns are served through the sec const row = await engine.findOne(ACTIVITY, { where: { id: tracked.id }, context: MASKED_READER }) as Row; expect(row?.id).toBe(tracked.id); expect(JSON.stringify(row)).not.toContain(V.masked2); - expect(row).not.toHaveProperty('summary'); + // [#36290] Re-composed from the changes this reader is served. + expect(String(row?.summary)).toContain(V.open2); }); it('a row in the mirror’s earlier shape (no provenance) keeps no text for a restricted reader, and keeps it for the control', async () => { @@ -433,7 +481,9 @@ const refObjects = [ fields: { title: { name: 'title', label: 'Title', type: 'text' as const } }, }, { - name: REF_TITLED, label: 'Reference Titled', nameField: 'target', + // [#36290] Values off, so its update is summarized by the record label — + // the text this scene judges — not by a field change. + name: REF_TITLED, label: 'Reference Titled', nameField: 'target', enable: { fieldHistory: false }, fields: { name: { name: 'name', label: 'Name', type: 'text' as const }, target: refLookup(REF_TARGET) }, }, { @@ -623,8 +673,14 @@ describe('an activity text naming a referenced record by its title is served onl expect(String(control?.summary)).toContain(ids.unexposed); const withheld = await updatedAs(TITLE_WITHHELD); expect(withheld).toBeTruthy(); - expect(withheld).not.toHaveProperty('summary'); + // [#36290] Judged change by change: the change naming the exposed + // target's title is dropped, the one naming the unexposed target by its id + // (whose title field this reader IS served) is kept. + expect(String(withheld?.summary)).toContain(ids.unexposed); + expect(String(withheld?.summary)).not.toContain('Open'); expect(JSON.stringify(withheld)).not.toContain(T.one); + const code = JSON.parse(String(withheld?.metadata)).summary_message; + expect(code.changes.map((c: Row) => c.field)).toEqual(['hidden']); }); it('findOne: the by-id read is judged like the list', async () => { diff --git a/packages/plugins/plugin-audit/src/activity-field-redaction.ts b/packages/plugins/plugin-audit/src/activity-field-redaction.ts index 7441f1d1c3a..31edeea8b8b 100644 --- a/packages/plugins/plugin-audit/src/activity-field-redaction.ts +++ b/packages/plugins/plugin-audit/src/activity-field-redaction.ts @@ -40,6 +40,12 @@ * * - `metadata.old` / `metadata.new`: every key the reader is not served is * DROPPED, key by key — the approval snapshot's shape. + * - [#36290] `metadata.summary_message` of a field-change summary: every + * change of a field the reader is not served is DROPPED, change by change, + * by the same answer, and a reference field's change by the reference rule + * below; the summary is then re-composed from the changes kept instead of + * being dropped whole, so a reader reads the lines of the fields they may + * read and never a value of one they may not. * - `summary` / `record_label`: a text cannot be split back into fields, so * each one is served whole or DROPPED whole. The writer declares, in the * row's own `metadata`, which parent fields each was composed from @@ -223,6 +229,14 @@ import { */ export { resolveServedFields } from './served-fields.js'; import { omitSideCopyFromCopy, sideCopyColumnsOf } from './side-copy-columns.js'; +import { + ACTIVITY_SUMMARY_MESSAGE_KEY, + composeActivitySummary, + readActivitySummaryMessage, + type ActivitySummaryFieldChange, + type ActivitySummaryLocale, + type ActivitySummaryMessage, +} from './activity-summary-message.js'; const ACTIVITY_OBJECT = 'sys_activity'; const SYSTEM_CTX = { isSystem: true } as const; @@ -679,6 +693,10 @@ export async function redactActivityRows( * the middleware always hands it in; without it no source is judged as a * reference. */ referenceTitles?: ReferenceTitlesServedFor, + /** [#36290] The registered definition of a parent object, for the field + * labels a narrowed field-change summary is re-composed with; without it + * the summary names each field by its machine key. */ + getObjectDef?: (object: string) => unknown, ): Promise { const list = (Array.isArray(rows) ? rows : rows ? [rows] : []) as unknown[]; if (list.length === 0) return; @@ -733,12 +751,47 @@ export async function redactActivityRows( const servedWhole = (sources: string[] | 'unknown') => sourcesServed(sources, servedSet, () => restrictedOn(object, servedSet)); + /** [#36290] The field-change code, narrowed to this reader; `null` when the row has none to serve. */ + let narrowedChanges: Extract | null = null; if (metadata) { let changed = false; for (const side of ['old', 'new'] as const) { const snapshot = metadata[side]; if (isRecord(snapshot) && dropUnservedKeys(snapshot, servedSet)) changed = true; } + // [#36290, ruling 7076513167] The field-change code is served to a + // reader narrowed change by change, by the answer `old` / `new` are + // narrowed by: a change of a field this reader is not served is dropped, + // and a reference field's change is kept only for a reader served the + // referenced record's title ({@link referenceTitlesPerRead}), the rule + // the summary text is judged by. A code this version cannot read is + // dropped (fail closed). Every other code is left to the summary + // middleware, which strips it for every non-system reader. + if (ACTIVITY_SUMMARY_MESSAGE_KEY in metadata) { + const stored = metadata[ACTIVITY_SUMMARY_MESSAGE_KEY]; + const code = readActivitySummaryMessage(stored); + if (isRecord(stored) && stored.key === 'fieldChanges' && code?.key !== 'fieldChanges') { + delete metadata[ACTIVITY_SUMMARY_MESSAGE_KEY]; + changed = true; + } else if (code?.key === 'fieldChanges') { + const kept: ActivitySummaryFieldChange[] = []; + for (const change of code.changes) { + if (!servedSet.has(change.field)) continue; + if (referenceTitles && !(await referenceTitles(object, [change.field]))) continue; + kept.push(change); + } + if (kept.length === 0) { + delete metadata[ACTIVITY_SUMMARY_MESSAGE_KEY]; + changed = true; + } else { + narrowedChanges = { ...code, changes: kept }; + if (kept.length !== code.changes.length) { + metadata[ACTIVITY_SUMMARY_MESSAGE_KEY] = narrowedChanges; + changed = true; + } + } + } + } if (kindSources !== null && !(await servedWhole(kindSources))) { delete metadata[ACTIVITY_KIND_KEY]; changed = true; @@ -756,11 +809,40 @@ export async function redactActivityRows( const sources = provenance[col]; const served = (await servedWhole(sources)) && (!referenceTitles || sources === 'unknown' || (await referenceTitles(object, sources))); - if (!served) delete row[col]; + if (served) continue; + // [#36290] A field-change summary is not dropped whole when some of its + // changes are this reader's: it is re-composed from the narrowed code, + // so the reader reads the lines of the fields they may read. The text is + // composed from the served changes alone; the summary middleware then + // re-composes it in the reader's language from the same code. + if (col === 'summary' && narrowedChanges) { + row.summary = composeActivitySummary(narrowedChanges, authoredLabelsLocale(getObjectDef)) ?? ''; + continue; + } + delete row[col]; } } } +/** + * [#36290] The locale a narrowed field-change summary is composed in on this + * seam: no bundle (every key misses), so each field is named by its authored + * label, else its machine key, and each value by the text the writer stored. + */ +function authoredLabelsLocale(getObjectDef?: (object: string) => unknown): ActivitySummaryLocale { + return { + translate: () => undefined, + locale: undefined, + getObjectDef: (object) => { + try { + return getObjectDef?.(object) ?? null; + } catch { + return null; + } + }, + }; +} + /** * The text columns' provenance lives in `metadata`, and the parent in * `object_name`; a projection that names a value-bearing column without them @@ -816,7 +898,9 @@ export function installActivityFieldRedaction( servedFor, logger, ); - await redactActivityRows(list, security, ctx.context, logger, servedFor, restrictedFor, referenceTitles); + await redactActivityRows(list, security, ctx.context, logger, servedFor, restrictedFor, referenceTitles, (object) => + typeof engine.getSchema === 'function' ? engine.getSchema(object) : undefined, + ); } catch (err) { // A redaction failure must never fall open into a leak. logger.warn( diff --git a/packages/plugins/plugin-audit/src/activity-lookup-name-field-label-34055.test.ts b/packages/plugins/plugin-audit/src/activity-lookup-name-field-label-34055.test.ts index f4034d11003..ce7c4f7aaae 100644 --- a/packages/plugins/plugin-audit/src/activity-lookup-name-field-label-34055.test.ts +++ b/packages/plugins/plugin-audit/src/activity-lookup-name-field-label-34055.test.ts @@ -88,7 +88,8 @@ const member = { fields: { id: f('id', 'text', { primaryKey: true }), person: f('person', 'lookup', { reference: 'sys_user' }), - rate: f('rate', 'number'), + // [#36290] Values off: the update row is named by the record label, the text these pins read. + rate: f('rate', 'number', { fieldHistory: false }), }, }; diff --git a/packages/plugins/plugin-audit/src/activity-summary-message.ts b/packages/plugins/plugin-audit/src/activity-summary-message.ts index 18770b7a4fb..650bab5ec85 100644 --- a/packages/plugins/plugin-audit/src/activity-summary-message.ts +++ b/packages/plugins/plugin-audit/src/activity-summary-message.ts @@ -347,6 +347,12 @@ function parseMetadata(raw: unknown): Record | null { * `metadata`: its parameters are parent field values (the record label, a * changed value), and the field redaction judges the text columns, not this * slot. A row whose `summary` the projection did not ask for is not given one. + * + * [#36290] One code is served: a field-change code (`fieldChanges`), which the + * field redaction has already narrowed change by change for this reader + * (`activity-field-redaction.ts`), so the record page can draw one line per + * changed field. This middleware is registered OUTSIDE the redaction for that + * reason: it composes from the narrowed code, never from the stored one. */ export function localizeActivityRow( row: Record, @@ -366,12 +372,17 @@ export function localizeActivityRow( } } } - if (stripCode) { + if (stripCode && !isFieldChangeCode(metadata[ACTIVITY_SUMMARY_MESSAGE_KEY])) { delete metadata[ACTIVITY_SUMMARY_MESSAGE_KEY]; row.metadata = isRecord(row.metadata) ? metadata : JSON.stringify(metadata); } } +/** [#36290] A code this version reads as a field-change summary — the one code served to a reader. */ +function isFieldChangeCode(value: unknown): boolean { + return readActivitySummaryMessage(value)?.key === 'fieldChanges'; +} + /** The engine slice the summary middleware registers on. */ export interface ActivitySummaryEngine { registerMiddleware?( @@ -383,10 +394,12 @@ export interface ActivitySummaryEngine { /** * Install the `sys_activity` summary middleware. `getI18n` is resolved on every - * read: the i18n service may register after this plugin. Register it AFTER the - * field redaction (`installActivityFieldRedaction`), so it runs inside it: the - * summary is composed from the row as stored, and the redaction then judges - * the composed text by the same declared sources the stored one had. + * read: the i18n service may register after this plugin. Register it BEFORE the + * field redaction (`installActivityFieldRedaction`), so the redaction runs + * inside it [#36290]: the redaction judges the stored text by its declared + * sources and narrows the field-change code first, and this middleware then + * composes a kept summary in the reader's language from what the redaction + * left — a narrowed code composes only the changes this reader is served. */ export function installActivitySummaryLocale( engine: ActivitySummaryEngine, diff --git a/packages/plugins/plugin-audit/src/activity-summary-reader-locale.integration.test.ts b/packages/plugins/plugin-audit/src/activity-summary-reader-locale.integration.test.ts index 06d0710d2c8..19526be91f0 100644 --- a/packages/plugins/plugin-audit/src/activity-summary-reader-locale.integration.test.ts +++ b/packages/plugins/plugin-audit/src/activity-summary-reader-locale.integration.test.ts @@ -41,7 +41,8 @@ const contract = { { value: 'signed', label: 'Signed' }, ], }, - note: { name: 'note', label: 'Note', type: 'text' as const }, + // [#36290] label-only: these pins read the changed-fields line, not old → new + note: { name: 'note', label: 'Note', type: 'text' as const, fieldHistory: false }, }, }; diff --git a/packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts b/packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts index bab96ed469d..4b239388f46 100644 --- a/packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts +++ b/packages/plugins/plugin-audit/src/audit-lookup-summary.test.ts @@ -127,7 +127,8 @@ const bizDeal = { label: 'Owner', reference: 'sys_user', trackHistory: true, }), // An UNTRACKED reference: it must never cost a read, whatever it holds. - referrer_id: f('referrer_id', 'lookup', { label: 'Referrer', reference: 'crm_account' }), + // [#36290] Values off: the UNTRACKED reference field of the read-cost pins. + referrer_id: f('referrer_id', 'lookup', { label: 'Referrer', reference: 'crm_account', fieldHistory: false }), }, }; diff --git a/packages/plugins/plugin-audit/src/audit-milestone-summary.test.ts b/packages/plugins/plugin-audit/src/audit-milestone-summary.test.ts index 2f9d84b1338..ab720b8ecc9 100644 --- a/packages/plugins/plugin-audit/src/audit-milestone-summary.test.ts +++ b/packages/plugins/plugin-audit/src/audit-milestone-summary.test.ts @@ -147,8 +147,10 @@ const bizDeal = { region_id: f('region_id', 'lookup', { label: 'Region', reference: 'crm_region' }), parent_id: f('parent_id', 'master_detail', { label: 'Parent', reference: 'crm_account' }), vault_id: f('vault_id', 'lookup', { label: 'Vault', reference: 'crm_vault' }), + // [#36290] Values off, so a change of it alone reaches the generic branch. priority: f('priority', 'select', { label: 'Priority', + fieldHistory: false, options: [{ value: 'p1', label: 'Highest' }, { value: 'p2', label: 'Normal' }], }), }, diff --git a/packages/plugins/plugin-audit/src/audit-plugin.ts b/packages/plugins/plugin-audit/src/audit-plugin.ts index 6f043bfbbb0..42527cdbeef 100644 --- a/packages/plugins/plugin-audit/src/audit-plugin.ts +++ b/packages/plugins/plugin-audit/src/audit-plugin.ts @@ -840,14 +840,16 @@ export class AuditPlugin implements Plugin { return undefined; } }; - installActivityFieldRedaction(engine as any, getSecurity, ctx.logger); - ctx.logger.info('AuditPlugin: sys_activity field redaction installed'); // [#26167] …and each kept row's summary is composed in the READER's - // language from the code the writer stored beside it. Registered after - // the redaction, so it runs inside it: the redaction judges the - // composed text by the same declared sources as the stored one. + // language from the code the writer stored beside it. [#36290] + // Registered BEFORE the redaction, so the redaction runs inside it: the + // redaction judges the stored text by its declared sources and narrows + // the field-change code to this reader first, and the summary is then + // composed from what it kept. installActivitySummaryLocale(engine as any, getI18n); ctx.logger.info('AuditPlugin: sys_activity reader-language summaries installed'); + installActivityFieldRedaction(engine as any, getSecurity, ctx.logger); + ctx.logger.info('AuditPlugin: sys_activity field redaction installed'); // [#21155] The compliance ledger's before/after snapshots take the same // narrowing, through the same answer and the same resolver: a ledger // reader is not field-unrestricted by default. An auditor who must see diff --git a/packages/plugins/plugin-audit/src/audit-writers.test.ts b/packages/plugins/plugin-audit/src/audit-writers.test.ts index 6324b43fa48..481c40d6e9f 100644 --- a/packages/plugins/plugin-audit/src/audit-writers.test.ts +++ b/packages/plugins/plugin-audit/src/audit-writers.test.ts @@ -619,7 +619,8 @@ describe('audit writers — declarative trackHistory activity (ADR-0052 §5b)', crm_opportunity: { id: { type: 'text' }, name: { type: 'text', label: 'Name' }, - amount: { type: 'currency', label: 'Amount' }, + // [#36290] Values are on unless turned off: this one is turned off. + amount: { type: 'currency', label: 'Amount', fieldHistory: false }, stage: { type: 'select', label: 'Stage', @@ -662,11 +663,146 @@ describe('audit writers — declarative trackHistory activity (ADR-0052 §5b)', }); const activity = created.find((c) => c.object === 'sys_activity'); - // The label, never the value: `amount` is not `trackHistory`'d. + // The label, never the value: `amount` turns its values off (`fieldHistory: false`). expect(activity?.row.summary).toBe('Updated crm_opportunity "Acme Renewal": Amount'); }); }); +describe('[#36290] a changed field shows old → new unless the object or the field turns it off', () => { + const DEAL_FIELDS: Record = { + id: { type: 'text' }, + name: { type: 'text', label: 'Name' }, + amount: { type: 'currency', label: 'Amount' }, + note: { type: 'textarea', label: 'Note' }, + quiet: { type: 'text', label: 'Quiet', fieldHistory: false }, + // What the field designer wrote on every save while the key meant nothing. + designer_saved: { type: 'text', label: 'Designer Saved', trackHistory: false }, + api_token: { type: 'secret', label: 'API Token' }, + payload: { type: 'json', label: 'Payload' }, + payload_opted: { type: 'json', label: 'Payload Opted', trackHistory: true }, + payload_on: { type: 'json', label: 'Payload On', fieldHistory: true }, + insisted: { type: 'text', label: 'Insisted', fieldHistory: true }, + }; + const schemaWith = (summary: Record = { type: 'text' }) => ({ + sys_audit_log: SINGLE_TENANT.sys_audit_log, + sys_activity: { + ...Object.fromEntries(SINGLE_TENANT.sys_activity.map((f) => [f, { type: 'text' }])), + summary, + }, + deal: DEAL_FIELDS, + }); + + async function updateDeal( + previous: Record, + result: Record, + { objectDef = {}, summary }: { objectDef?: Record; summary?: Record } = {}, + ) { + const { engine, fire, created } = makeEngine(schemaWith(summary), { deal: { label: 'Deal', ...objectDef } }); + installAuditWriters(engine as any, 'test.audit'); + await fire('afterUpdate', { + object: 'deal', + input: { id: 'deal-1' }, + result: { id: 'deal-1', name: 'D-1', ...result }, + previous: { id: 'deal-1', name: 'D-1', ...previous }, + session: {}, + }); + const activity = created.find((c) => c.object === 'sys_activity'); + expect(activity).toBeDefined(); + return { summary: activity!.row.summary as string, metadata: JSON.parse(activity!.row.metadata) }; + } + + it('an object and a field that say nothing show the values', async () => { + const { summary, metadata } = await updateDeal({ amount: 100 }, { amount: 200 }); + expect(summary).toBe('Amount: 100 → 200'); + expect(metadata.summary_message).toEqual({ + key: 'fieldChanges', + object: 'deal', + changes: [{ field: 'amount', from: { text: '100' }, to: { text: '200' } }], + }); + }); + + it('an object that sets enable.fieldHistory: false names the field, never its values', async () => { + const { summary, metadata } = await updateDeal({ amount: 100 }, { amount: 200 }, { objectDef: { enable: { fieldHistory: false } } }); + expect(summary).toBe('Updated Deal "D-1": Amount'); + expect(metadata.summary_message.key).toBe('activityUpdatedFields'); + }); + + it('enable.trackHistory: false alone no longer turns the values off', async () => { + // A parsed body writes it on every object with an `enable` block. + const { summary } = await updateDeal({ amount: 100 }, { amount: 200 }, { objectDef: { enable: { trackHistory: false } } }); + expect(summary).toBe('Amount: 100 → 200'); + }); + + it('a field that sets trackHistory: false still shows its values: that false is not an off switch', async () => { + const { summary } = await updateDeal({ designer_saved: 'd-before' }, { designer_saved: 'd-after' }); + expect(summary).toBe('Designer Saved: d-before → d-after'); + }); + + it('enable.fieldHistory: false wins over a field that sets fieldHistory: true', async () => { + const { summary } = await updateDeal({ insisted: 'i1' }, { insisted: 'i2' }, { objectDef: { enable: { fieldHistory: false } } }); + expect(summary).toBe('Updated Deal "D-1": Insisted'); + }); + + it('a field that sets fieldHistory: false is named by label only, beside a field that shows its values', async () => { + const quietOnly = await updateDeal({ quiet: 'q-before' }, { quiet: 'q-after' }); + expect(quietOnly.summary).toBe('Updated Deal "D-1": Quiet'); + expect(quietOnly.summary).not.toContain('q-after'); + const mixed = await updateDeal({ quiet: 'q-before', amount: 1 }, { quiet: 'q-after', amount: 2 }); + expect(mixed.summary).toBe('Amount: 1 → 2'); + expect(JSON.stringify(mixed.metadata.summary_message)).not.toContain('q-after'); + }); + + it('a credential field is named by label only, never by its mask', async () => { + const { summary, metadata } = await updateDeal({ api_token: 'tok-before' }, { api_token: 'tok-after' }); + expect(summary).toBe('Updated Deal "D-1": API Token'); + expect(JSON.stringify(metadata.summary_message)).not.toContain('•'); + expect(JSON.stringify({ summary, metadata })).not.toContain('tok-after'); + }); + + it('a structured-JSON field shows values only when it opts in with trackHistory: true or fieldHistory: true', async () => { + const plain = await updateDeal({ payload: { a: 1 } }, { payload: { a: 2 } }); + expect(plain.summary).toBe('Updated Deal "D-1": Payload'); + const opted = await updateDeal({ payload_opted: 'p1' }, { payload_opted: 'p2' }); + expect(opted.summary).toBe('Payload Opted: p1 → p2'); + const on = await updateDeal({ payload_on: 'p1' }, { payload_on: 'p2' }); + expect(on.summary).toBe('Payload On: p1 → p2'); + }); + + it('a long value still fits a bounded summary column, and the code keeps a bounded copy of each side', async () => { + const before = 'b'.repeat(3000); + const after = 'a'.repeat(3000); + const { summary, metadata } = await updateDeal({ note: before }, { note: after }, { summary: { type: 'text', maxLength: 500 } }); + expect(summary.length).toBeLessThanOrEqual(500); + expect(summary.startsWith('Note: ')).toBe(true); + const [change] = metadata.summary_message.changes; + expect(change.field).toBe('note'); + expect(change.to.text.length).toBe(1000); + expect(change.to.text.endsWith('…')).toBe(true); + }); + + it('many changes fit a bounded summary column by leaving trailing changes out of the stored sentence only', async () => { + const fields = Object.fromEntries(Array.from({ length: 30 }, (_, i) => [`f${i}`, { type: 'text', label: `Field ${i}` }])); + const { engine, fire, created } = makeEngine( + { ...schemaWith({ type: 'text', maxLength: 500 }), many: { id: { type: 'text' }, name: { type: 'text' }, ...fields } }, + { many: { label: 'Many' } }, + ); + installAuditWriters(engine as any, 'test.audit'); + const prev = Object.fromEntries(Object.keys(fields).map((k) => [k, `old-value-of-${k}`])); + const next = Object.fromEntries(Object.keys(fields).map((k) => [k, `new-value-of-${k}`])); + await fire('afterUpdate', { + object: 'many', + input: { id: 'm-1' }, + result: { id: 'm-1', name: 'M', ...next }, + previous: { id: 'm-1', name: 'M', ...prev }, + session: {}, + }); + const row = created.find((c) => c.object === 'sys_activity')!.row; + expect(row.summary.length).toBeLessThanOrEqual(500); + expect(row.summary.endsWith('; …')).toBe(true); + expect(JSON.parse(row.metadata).summary_message.changes).toHaveLength(30); + }); +}); + describe('audit writers — the generic update summary names the changed fields (#25787)', () => { // A campaign whose roll-up counters a hook bumps once per enrolled member — // plain number fields, none `trackHistory`'d (the measured HotCRM shape). @@ -693,7 +829,8 @@ describe('audit writers — the generic update summary names the changed fields previous: Record, result: Record, ) { - const { engine, fire, created } = makeEngine(schema, { campaign: { label: 'Campaign' } }); + // [#36290] Values off for the object: this describe pins the label-only branch. + const { engine, fire, created } = makeEngine(schema, { campaign: { label: 'Campaign', enable: { fieldHistory: false } } }); installAuditWriters(engine as any, 'test.audit'); await fire('afterUpdate', { object: 'campaign', @@ -1306,7 +1443,10 @@ describe('audit writers — localized activity summaries (framework#3039)', () = result[`f${i}`] = 1; } const i18n = makeI18n(); - const { engine, fire, created } = setup('zh-CN', i18n, {}, { ...SINGLE_TENANT, person_qualification: fields }); + // [#36290] Values off for the object, so the named-field list is what is written. + const { engine, fire, created } = setup( + 'zh-CN', i18n, { person_qualification: { enable: { fieldHistory: false } } }, { ...SINGLE_TENANT, person_qualification: fields }, + ); await fire('afterUpdate', { ...insertCtx(), previous, result }); const [activity] = activityRows(created); expect(activity.summary).toBe('Updated person_qualification "OC-00001": F1, F2, F3, F4, F5, and 2 more'); diff --git a/packages/plugins/plugin-audit/src/audit-writers.ts b/packages/plugins/plugin-audit/src/audit-writers.ts index 9a2d9c0a192..9248a983363 100644 --- a/packages/plugins/plugin-audit/src/audit-writers.ts +++ b/packages/plugins/plugin-audit/src/audit-writers.ts @@ -987,12 +987,13 @@ function planTrackedLookupReads( fields: Record | undefined | null, oldVals: Record | null, newVals: Record | null, + showsValues: ChangeValuesShown, ): Map> { const byObject = new Map>(); if (!fields || !newVals) return byObject; for (const key of Object.keys(newVals)) { const field = fields[key]; - if (!field || field.trackHistory !== true) continue; + if (!field || !showsValues(key, field)) continue; if (typeof field.type !== 'string' || !REFERENCE_FIELD_TYPES.has(field.type)) continue; const reference = referenceTargetForSummary(field); if (!reference) continue; @@ -1029,8 +1030,10 @@ function planLabelLookupRead( } /** - * ADR-0052 §5b — declarative activity. For fields declared `trackHistory: true`, - * render the diff the writer already captured as a human-readable timeline + * ADR-0052 §5b — declarative activity. For every changed field whose values + * are shown ({@link changeValuesShownFor}: on unless the object or the field + * turns them off, #36290), render the diff the writer already captured as a + * human-readable timeline * summary ("Stage: Proposal → Closed Won"; multiple changes joined by "; "), * using the field label, select option labels and referenced record titles. * Returns null when no tracked field changed, so the caller falls back to the @@ -1071,24 +1074,126 @@ function renderTrackedChangeSummary( oldVals: Record | null, newVals: Record | null, locale: ActivitySummaryLocale, + showsValues: ChangeValuesShown, lookupTitles?: Map>, + maxLength?: number, ): { text: string; fields: string[]; message: ActivitySummaryMessage } | null { if (!fields || !newVals) return null; const changes: ActivitySummaryFieldChange[] = []; for (const key of Object.keys(newVals)) { const field = fields[key]; - if (!field || field.trackHistory !== true) continue; + if (!field || !showsValues(key, field)) continue; const reference = referenceTargetForSummary(field); const titlesFor = reference ? lookupTitles?.get(reference) : undefined; changes.push({ field: key, - from: summaryValueOf(field, oldVals ? oldVals[key] : undefined, titlesFor), - to: summaryValueOf(field, newVals[key], titlesFor), + from: boundedChangeValue(summaryValueOf(field, oldVals ? oldVals[key] : undefined, titlesFor), MAX_CHANGE_VALUE_TEXT), + to: boundedChangeValue(summaryValueOf(field, newVals[key], titlesFor), MAX_CHANGE_VALUE_TEXT), }); } if (changes.length === 0) return null; const message: ActivitySummaryMessage = { key: 'fieldChanges', object: objectName, changes }; - return { text: composeStoredSummary(message, locale), fields: changes.map((c) => c.field), message }; + return { text: fitStoredChangeSummary(message, locale, maxLength), fields: changes.map((c) => c.field), message }; +} + +/** + * [#36290] Whether a changed field's old → new VALUES are rendered: the + * predicate {@link changeValuesShownFor} builds for one object. + */ +type ChangeValuesShown = (key: string, field: any) => boolean; + +/** + * [#36290] The field types whose value has no one-line text — media, embedded + * structured values, vectors, a signature. Their change is named by label + * only, unless the field itself turns them on (`fieldHistory: true`, or the + * `trackHistory: true` opt-in it always was). + */ +const NO_LINE_VALUE_TYPES: ReadonlySet = new Set([ + 'image', 'file', 'avatar', 'video', 'audio', 'signature', + 'composite', 'repeater', 'record', 'location', 'address', 'code', 'json', 'vector', +]); + +/** + * [#36290, ruling 7076513167] ADR-0052 §5b.1 with its default reversed: a + * changed field's old → new values render on the record's activity stream + * unless the object turns it off (`enable.fieldHistory: false`) or the field + * does (its own `fieldHistory: false`). An absent flag is on. Neither + * `trackHistory` turns values off: the object's keeps its own meaning (the + * ledger view and the `history` verb) and a parsed body materializes it as + * `false` on every object with an `enable` block; the field's `false` was + * written by the field designer on every save while it meant nothing, so a + * stored one cannot be told from a choice and reads like an absent key. A + * field's `trackHistory: true` still forces a no-line type on. Two classes + * never render values, whatever the flags say: + * + * - a credential field (`collectMaskedReadFields`): both sides are the same + * mask, so the change is named by label only, never `•••• → ••••`; + * - a type in {@link NO_LINE_VALUE_TYPES}, unless the field declares + * `fieldHistory: true` or `trackHistory: true` itself. + * + * Who may READ the values is not decided here: the row is redacted per reader, + * field by field (`activity-field-redaction.ts`). + */ +function changeValuesShownFor(objectDef: any): ChangeValuesShown { + if (objectDef?.enable?.fieldHistory === false) return () => false; + const credentials = new Set(collectMaskedReadFields(objectDef)); + return (key, field) => { + if (!field || field.fieldHistory === false || credentials.has(key)) return false; + if (field.fieldHistory === true || field.trackHistory === true) return true; + return !(typeof field.type === 'string' && NO_LINE_VALUE_TYPES.has(field.type)); + }; +} + +/** + * [#36290] The longest text one side of a field change keeps in the stored + * code. The code is what a reader's record page draws each change from, so a + * long text keeps enough to read; bounded so one edit of a long text field + * cannot grow the row without limit. + */ +const MAX_CHANGE_VALUE_TEXT = 1000; + +/** + * [#36290] How long one side of a change may be inside the STORED one-line + * summary when the full sentence does not fit `sys_activity.summary`'s + * `maxLength`. + */ +const FITTED_CHANGE_VALUE_TEXT = 60; + +/** `value` with its text cut to `max` characters (an ellipsis marks the cut). */ +function boundedChangeValue(value: ActivitySummaryValue, max: number): ActivitySummaryValue { + if (value.text.length <= max) return value; + return { ...value, text: `${value.text.slice(0, Math.max(0, max - 1))}…` }; +} + +/** + * [#36290] The stored sentence for a field-change code, fitted to + * `sys_activity.summary`'s `maxLength` (the SQL driver sizes the column + * `varchar(n)` from it, so an over-long text fails the whole activity insert). + * With values on by default one save can change many fields, or one long + * text, so the tracked branch is fitted as the changed-fields branch is: first + * each side is cut to {@link FITTED_CHANGE_VALUE_TEXT} characters, then + * trailing changes are left out, then the sentence itself is cut. The code + * keeps every change, so a reader's language re-composes the whole of it. + */ +function fitStoredChangeSummary( + message: Extract, + locale: ActivitySummaryLocale, + maxLength: number | undefined, +): string { + const full = composeStoredSummary(message, locale); + if (maxLength === undefined || full.length <= maxLength) return full; + const cut = message.changes.map((c) => ({ + field: c.field, + from: boundedChangeValue(c.from, FITTED_CHANGE_VALUE_TEXT), + to: boundedChangeValue(c.to, FITTED_CHANGE_VALUE_TEXT), + })); + for (let shown = cut.length; shown >= 1; shown -= 1) { + const text = composeStoredSummary({ ...message, changes: cut.slice(0, shown) }, locale); + const tail = shown < cut.length ? '; …' : ''; + if (text.length + tail.length <= maxLength) return `${text}${tail}`; + } + const one = composeStoredSummary({ ...message, changes: cut.slice(0, 1) }, locale); + return `${one.slice(0, Math.max(0, maxLength - 1))}…`; } /** @@ -1103,8 +1208,9 @@ const MAX_NAMED_CHANGED_FIELDS = 5; * changed: before this, the row said only `Updated "