Skip to content

Commit 1f1cd21

Browse files
fix(spec): retired-key refusals prescribe the field-history model, not trackHistory (#38064)
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoBECS1rg6UkLcjHuoNw27Ci)_ Fixes #36776 repo:objectstack#3 · os-tesla · session_01L9qibybKQ9ZAg8zN9fVBEN Clause-②: no Metadata-protocol: none ## 维护者速读 - 搭建者写了已退役的回收站、版本化、字段审计或「追踪变更」类配置时,报错现在说对了字段历史怎么用:默认就显示,媒体和结构化数据字段要单独打开,要关在对象或字段上关;以前的报错让人去开一个并不管这件事的开关。 - 属于「错误的元数据在作者门口被拒,并给出正确处方」这条线,替照着报错改配置的搭建者和 AI 解决被指错路的问题。 - 只改报错文字,哪些配置被拒完全不变;若新说法有误,最多是提示不准,可以直接撤回。 - 无 ## What changes - `packages/spec/src/data/object.zod.ts`: - New `FIELD_HISTORY_PRESCRIPTION` constant, shared by the `enable.trash` tombstone (`CAPABILITIES_RETIRED_KEY_GUIDANCE.trash`) and the top-level `versioning` tombstone, so the two cannot drift: "Field history is on by default: a changed field's old → new values show on the record activity timeline, except a media or structured-JSON field, which opts in with `fieldHistory: true`. `enable.fieldHistory: false` turns them off for the object, and a field opts out with its own `fieldHistory: false`." Each tombstone keeps its retention half (`lifecycle`). The constant's docblock names `resolveFieldHistory` and `FIELD_HISTORY_DEFAULT_OFF_TYPES` as the model it states and says why it never names `trackHistory`. - The `activityMilestones` TSDoc no longer calls `trackHistory` "field-level"; it names the field-change rows and their two off switches. - `packages/spec/src/data/authoring-key-lint.ts`: `FIELD_KEY_GUIDANCE.audit` and `.auditTrail` now say to delete the key, that a changed field's values already show by default, and that `fieldHistory: false` is the field's off switch (`fieldHistory: true` opts a media or structured-JSON field in). They no longer send the author to `trackHistory`. - `packages/spec/src/data/field-key-aliases.ts` and `packages/spec/src/data/field.zod.ts`: the `trackChanges` and `feedTracked` field spellings no longer rename onto `trackHistory` (whose `false` turns nothing off). The two alias rows are gone, and both keys take the same prose answer as the existing `tracked` row, now built by one `fieldHistorySpellingAnswer(key)` helper (`tracked`'s text is unchanged). All three keys stay refused. - No key is newly refused or newly accepted; no export, schema shape or `.describe()` changes. - `patch` changeset for `@objectstack/spec`. ## Tests - `packages/spec/src/data/object.test.ts`, new `describe` "retired history-promising keys prescribe the field-history model that runs": - for `enable.trash` and for `versioning`: the message carries the default sentence, the default-off exception with its `fieldHistory: true` opt-in, both off switches and the retention half; and it does not contain `trackHistory`; - a cross-check that `resolveFieldHistory` agrees with the sentence: a text field on by default, `enable.fieldHistory: false` off, a field's `fieldHistory: false` off, `trackHistory: false` not an off switch, and a `json` and an `image` field off by default and on with `fieldHistory: true`. - The 16.0 tombstone table's `versioning` needle moves from `'trackHistory'` to `'fieldHistory'`. - `packages/spec/src/data/authoring-key-lint.test.ts`, new `describe` for `audit` / `auditTrail` through `FieldSchema.safeParse`: the refusal carries the three sentences and no `trackHistory`. - `packages/spec/src/data/field.test.ts`, in the existing `tracked` describe: `trackChanges` and `feedTracked` are refused with the `fieldHistory` answer and no `trackHistory`, and `fieldSchemaAliases()` has no row for either. <details><summary>Readings at fa487d2 (base origin/main 27ee984); head 9978932 changes only the changeset prose</summary> - Premise, before the fix, at 27ee984 through source: `ObjectCapabilities.safeParse({ trash: false })` said "For history use per-field `trackHistory` (audit trail)…"; `ObjectSchema.create({ versioning })` said "Use per-field `Field.trackHistory` for field-level history…"; `FIELD_KEY_GUIDANCE.audit` / `.auditTrail` said "Use `trackHistory` for the activity timeline."; `fieldSchemaAliases()` renamed `trackChanges` / `feedTracked` onto `trackHistory`. - Ablation through `scripts/ablation-replace.mjs` on the committed fix, each restore `blob == HEAD` and `git diff HEAD` empty: - first head 396a54f, `vitest run src/data/object.test.ts src/data/authoring-key-lint.test.ts`: `enable.trash` old text `2 failed`; `versioning` old text `3 failed` (its two pins and the 16.0 table needle); `audit` old text `2 failed`; `auditTrail` old text `2 failed`. - fa487d2, `vitest run src/data/object.test.ts src/data/field.test.ts`: the default-off exception removed from `FIELD_HISTORY_PRESCRIPTION` `2 failed` (trash and versioning); the `trackChanges` guidance row deleted `1 failed`; the `feedTracked` row deleted `1 failed`; the two alias rows restored `2 failed` (`vitest run src/data/field.test.ts`). - At fa487d2: `pnpm --filter @objectstack/spec build` exit 0; `check:generated` exit 0 ("All 14 generated artifacts are up to date"); `typecheck` exit 0; `test`: `Test Files 909 passed (909)`, `Tests 28811 passed | 1 todo (28812)`; `eslint` on the six changed `.ts` exit 0. </details> ## Acceptance notes - Derived local gate set at fa487d2: `dispatch-gates --ran` reconciles 93 derived, 92 run, 1 NOT MEASURED, 0 unrun. Two run families exited 1 in the sweep, `check:dts-closure` and `check:dual-build-cjs-loads`, because an earlier `OS_SKIP_DTS=1` build in this worktree had left `.d.ts`-less dists; after `turbo run build --force` of the `@objectstack/formula`, `@objectstack/lint` and `@objectstack/objectql` closures both exit 0, as do `check:doc-formula-expressions` and `check:lean-entry-closure`. Left to CI: `check-plugin-teardown-shape.mjs --self-test` (its fixture commit is out of this shallow clone's reach). - Scope beyond the card's two sentences, as the claim and its correction set it: the `audit` / `auditTrail` field-key refusals and the `trackChanges` / `feedTracked` rename rows (done-when 2), and the `activityMilestones` TSDoc in the same file. - Not stated by the new sentences (contract review N1, accepted): `enable.activities: false` writes no activity row at all, a credential field never shows values, and computed types are never diffed. - Out of scope, for the seat to file: `skills/objectstack-project/evals/project-process.json:145`; the docs pages `content/docs/data-modeling/field-types.mdx:1063`, `objects.mdx:81,94`, `schema-design.mdx:68`, `content/docs/protocol/objectql/schema.mdx:239`, `index.mdx:89`, `content/docs/concepts/metadata-driven.mdx:487`; and the comments in `packages/spec/src/system/index.ts:45` and `security-context.zod.ts:17`. ## Verification Read first (by risk): 1. `packages/spec/src/data/object.zod.ts`: `FIELD_HISTORY_PRESCRIPTION` and its two uses (the `trash` and `versioning` tombstones). 2. `packages/spec/src/data/field.zod.ts` and `field-key-aliases.ts`: `fieldHistorySpellingAnswer` and the two alias rows it replaces. 3. `packages/spec/src/data/object.test.ts`: the new describe and the `resolveFieldHistory` cross-check. Two-minute check: `pnpm --filter @objectstack/spec exec vitest run src/data/object.test.ts src/data/authoring-key-lint.test.ts src/data/field.test.ts` shows every test passing; put "Use per-field `Field.trackHistory` for field-level history" back into the `versioning` tombstone and the same command shows 3 failing. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibybKQ9ZAg8zN9fVBEN)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 94fdf16 commit 1f1cd21

8 files changed

Lines changed: 173 additions & 15 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
fix(spec): the `enable.trash`, `versioning`, `audit`, `auditTrail`, `trackChanges` and `feedTracked` refusals point at the field-history model that runs, not at `trackHistory`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Four retired-key refusals and two field-key renames told an author to use per-field `trackHistory` for field history. On a field, `trackHistory` only opts a media or structured-JSON type into old → new values, and `false` turns nothing off; on the object, `enable.trackHistory` opens the history ledger, not the values. So an author following the refusal set a flag that did not do what it said.
11+
12+
The `enable.trash` and `versioning` refusals now say that field history is on by default: a changed field's old → new values show on the record activity timeline, except a media or structured-JSON field, which opts in with `fieldHistory: true`; `enable.fieldHistory: false` turns them off for the object, and a field opts out with its own `fieldHistory: false`. A `lifecycle` policy stays the answer for retention. The field-key refusals for `audit` and `auditTrail` say to delete the key, because values already show by default, and name `fieldHistory: false` as the field's off switch (`fieldHistory: true` opts a media or structured-JSON field in).
13+
14+
The field spellings `trackChanges` and `feedTracked`, which were refused with a rename to `trackHistory`, now get the same answer as `tracked`: values show by default, `fieldHistory: false` turns them off for the field (`true` opts a media or structured-JSON field in), and `enable.fieldHistory: false` turns them off for every field on the object.
15+
16+
Wording only: every key that was refused is still refused, and nothing is newly refused. Nothing to migrate.

‎packages/spec/src/data/authoring-key-lint.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,32 @@ describe('lintAuthoredRecordKeys — an unknown key gets the shared rename rule'
245245
expect(runComparator({ dfltValue: 'x' }, declared)[0]?.suggestion).toBe('defaultValue');
246246
});
247247
});
248+
249+
describe('the retired `audit` / `auditTrail` field keys prescribe the field-history model that runs', () => {
250+
// A field's change values show by default and its off switch is its own
251+
// `fieldHistory: false` (`resolveFieldHistory`). `trackHistory` on a field
252+
// only opts a media or JSON type in, so the refusal never names it.
253+
for (const key of ['audit', 'auditTrail'] as const) {
254+
const message = (): string => {
255+
const r = FieldSchema.safeParse({ name: 'amount', type: 'number', [key]: true });
256+
expect(r.success, `\`${key}\` was not refused`).toBe(false);
257+
if (r.success) throw new Error('unreachable');
258+
const issue = r.error.issues.find((i) => i.code === 'unrecognized_keys');
259+
expect(issue, `\`${key}\` was not refused as an unknown key`).toBeTruthy();
260+
return issue!.message;
261+
};
262+
263+
it(`\`${key}\`: values already show by default, and the field's off switch is named`, () => {
264+
const m = message();
265+
expect(m).toContain(
266+
'Delete the key: a changed field\'s old → new values already show on the record activity timeline by default',
267+
);
268+
expect(m).toContain('`fieldHistory: false` is this field\'s off switch');
269+
expect(m).toContain('`fieldHistory: true` opts a media or structured-JSON field in');
270+
});
271+
272+
it(`\`${key}\`: never sends the author to \`trackHistory\``, () => {
273+
expect(message()).not.toContain('trackHistory');
274+
});
275+
}
276+
});

‎packages/spec/src/data/authoring-key-lint.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ export const FIELD_KEY_GUIDANCE: Readonly<
127127
startingNumber: { why: 'never a FieldSchema key. An autonumber counter resets per rendered prefix, which `autonumberFormat` itself determines.' },
128128
validation: { why: 'field-level predicates are not a FieldSchema key — author a `validation` metadata item on the object, which carries its own message.' },
129129
errorMessage: { why: 'pairs with the `validation` key that never existed; a `validation` metadata item carries its own message.' },
130-
audit: { why: 'the `auditTrail` family was pruned in 2026-06 as dead in both layers. Use `trackHistory` for the activity timeline.' },
131-
auditTrail: { why: 'pruned in 2026-06 as dead in both layers. Use `trackHistory` for the activity timeline.' },
130+
audit: { why: 'the `auditTrail` family was pruned in 2026-06 as dead in both layers. Delete the key: a changed field\'s old → new values already show on the record activity timeline by default, and `fieldHistory: false` is this field\'s off switch (`fieldHistory: true` opts a media or structured-JSON field in).' },
131+
auditTrail: { why: 'pruned in 2026-06 as dead in both layers. Delete the key: a changed field\'s old → new values already show on the record activity timeline by default, and `fieldHistory: false` is this field\'s off switch (`fieldHistory: true` opts a media or structured-JSON field in).' },
132132
pii: { why: 'the `dataQuality` governance family was pruned in 2026-06 as dead in both layers — it enforced nothing.' },
133133
dataQuality: { why: 'pruned in 2026-06 as dead in both layers, and its leftover `DataQualityRules` schema was deleted from the public API too — it enforced nothing.' },
134134
encrypted: { why: 'the `encryptionConfig` family was pruned in 2026-06: it implied at-rest protection that never happened. The real channel is `type: \'secret\'`.' },

‎packages/spec/src/data/field-key-aliases.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ const FIELD_ALIAS_ROWS: Readonly<Record<string, string>> = {
9292
component: 'widget', renderer: 'widget', control: 'widget',
9393
mimeTypes: 'accept', allowedTypes: 'accept', fileTypes: 'accept',
9494
maxFileSize: 'maxSize', maxBytes: 'maxSize',
95-
trackChanges: 'trackHistory', feedTracked: 'trackHistory',
95+
// NOTE: no `trackChanges` / `feedTracked` rows. They renamed onto
96+
// `trackHistory`, whose `false` turns nothing off and whose `true` matters
97+
// only for a media or structured-JSON type; both keys are answered in prose
98+
// with the `fieldHistory` model beside `tracked` in `field.zod.ts`.
9699
permissions: 'requiredPermissions', requiredCapabilities: 'requiredPermissions',
97100
};
98101

‎packages/spec/src/data/field.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ObjectSchema } from './object.zod';
1818
import { FormSelectOptionSchema } from '../ui/view.zod';
1919
import { SnakeCaseIdentifierSchema, SystemIdentifierSchema } from '../shared/identifiers.zod';
2020
import { MULTI_CAPABLE_TYPES, MULTI_OPTION_TYPES, isMultiValueField } from './field-value.zod';
21+
import { fieldSchemaAliases } from './field-key-aliases';
2122

2223
describe('FieldType', () => {
2324
it('should accept valid field types', () => {
@@ -208,6 +209,22 @@ describe('FieldSchema — field-level `tracked` key guidance, naming `fieldHisto
208209
const m = unrecognizedKeyMessage({ ...FIELD, totallyBogusKey: true });
209210
expect(m).not.toContain('fieldHistory');
210211
});
212+
213+
// `trackChanges` / `feedTracked` used to rename onto `trackHistory`, whose
214+
// `false` turns nothing off; they now take `tracked`'s answer.
215+
for (const key of ['trackChanges', 'feedTracked'] as const) {
216+
it(`\`${key}\` stays rejected with the \`fieldHistory\` answer, not a rename to \`trackHistory\``, () => {
217+
const m = unrecognizedKeyMessage({ ...FIELD, [key]: false });
218+
expect(m).toContain(`\`${key}\` is not a field key`);
219+
expect(m).toContain('Write `fieldHistory: false` to turn them off for this field');
220+
expect(m).toContain('`enable.fieldHistory: false` on the object');
221+
expect(m).not.toContain('trackHistory');
222+
});
223+
224+
it(`\`${key}\` is no longer a rename row onto \`trackHistory\``, () => {
225+
expect(fieldSchemaAliases()).not.toHaveProperty(key);
226+
});
227+
}
211228
});
212229

213230
describe('FieldSchema', () => {

‎packages/spec/src/data/field.zod.ts‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,17 @@ const INLINE_EDIT_BOOLEAN_RETIRED =
17031703
+ 'name it in a field group of the parent (`fieldGroups[].relatedList`). '
17041704
+ 'Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand.';
17051705

1706+
/**
1707+
* The prose answer for a field-level spelling of "track this field's
1708+
* history" that is not a field key: it names the `fieldHistory` model
1709+
* (`resolveFieldHistory`), never `trackHistory`.
1710+
*/
1711+
function fieldHistorySpellingAnswer(key: string): string {
1712+
return `\`${key}\` is not a field key — a field's old → new values show on the record activity timeline `
1713+
+ 'by default. Write `fieldHistory: false` to turn them off for this field (`true` opts a media or '
1714+
+ 'structured-JSON field in), or `enable.fieldHistory: false` on the object to turn them off for every field.';
1715+
}
1716+
17061717
export const FieldSchema = lazySchema(() => {
17071718
const base = strictObject({
17081719
surface: 'this field',
@@ -1741,10 +1752,13 @@ export const FieldSchema = lazySchema(() => {
17411752
// CASE-SENSITIVELY on the authored spelling, so a row per spelling is the
17421753
// only way this channel can cover a family, and `not_null` was the spelling
17431754
// it would have missed.
1744-
tracked:
1745-
'`tracked` is not a field key — a field\'s old → new values show on the record activity timeline '
1746-
+ 'by default. Write `fieldHistory: false` to turn them off for this field (`true` opts a media or '
1747-
+ 'structured-JSON field in), or `enable.fieldHistory: false` on the object to turn them off for every field.',
1755+
// `trackChanges` / `feedTracked` (the Salesforce "Track Field History" /
1756+
// "Feed Tracking" spellings) used to RENAME onto `trackHistory`, whose
1757+
// `false` turns nothing off; they take `tracked`'s answer instead, so both
1758+
// stay refused and the author is sent to the switch that works.
1759+
tracked: fieldHistorySpellingAnswer('tracked'),
1760+
trackChanges: fieldHistorySpellingAnswer('trackChanges'),
1761+
feedTracked: fieldHistorySpellingAnswer('feedTracked'),
17481762
// [ADR-0158 L3] The natural spellings of a quantity's unit on the field
17491763
// itself, answered in prose because the targets are NESTED keys of
17501764
// `unitConfig` — the form the `currency` answer above takes. None of them

‎packages/spec/src/data/object.test.ts‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { collectDroppedRefinements } from '../../scripts/lib/dropped-refinements
1414
import { Field } from './field.zod';
1515
import { defineStack } from '../stack.zod';
1616
import { isMaskedOnReadFieldType } from './masked-field-types';
17+
import { resolveFieldHistory } from './field-history-default';
1718
import { CONTROLLED_BY_PARENT_MASTER_INVALID, type ControlledByParentMasterShape } from './controlled-by-parent-master';
1819
import type { StateMachineValidation } from './validation.zod';
1920

@@ -100,6 +101,65 @@ describe('ObjectCapabilities', () => {
100101
.not.toMatch(/#\d{3,5}/);
101102
});
102103

104+
// `enable.trash` and `versioning` both promised history, so both refusals
105+
// say where field history lives now. It is the model `resolveFieldHistory`
106+
// enforces (values on by default, `enable.fieldHistory: false` for the
107+
// object, a field's own `fieldHistory: false`, a media or structured-JSON
108+
// field opting in with `fieldHistory: true`), never `trackHistory`: on a
109+
// field that only opts a media or JSON type in and `false` turns nothing off.
110+
describe('retired history-promising keys prescribe the field-history model that runs', () => {
111+
const trashMessage = (): string => {
112+
const r = ObjectCapabilities.safeParse({ trash: false });
113+
expect(r.success).toBe(false);
114+
return r.success ? '' : r.error.issues.map((i) => i.message).join('\n');
115+
};
116+
const versioningMessage = (): string => {
117+
try {
118+
ObjectSchema.create({
119+
name: 'demo',
120+
fields: { status: { type: 'text' } },
121+
versioning: { enabled: true },
122+
} as Record<string, unknown> as Parameters<typeof ObjectSchema.create>[0]);
123+
} catch (e) {
124+
return (e as Error).message;
125+
}
126+
throw new Error('`versioning` was not refused');
127+
};
128+
129+
for (const [key, read] of [['enable.trash', trashMessage], ['versioning', versioningMessage]] as const) {
130+
it(`${key}: values show by default, and the two off switches are named`, () => {
131+
const message = read();
132+
expect(message).toContain(
133+
'Field history is on by default: a changed field\'s old → new values show on the record activity timeline',
134+
);
135+
expect(message, 'the default-off types are named with their opt-in').toContain(
136+
'except a media or structured-JSON field, which opts in with `fieldHistory: true`.',
137+
);
138+
expect(message).toContain('`enable.fieldHistory: false` turns them off for the object');
139+
expect(message).toContain('a field opts out with its own `fieldHistory: false`');
140+
expect(message).toMatch(/For retention, (use )?a (data lifecycle policy \(`lifecycle`\)|`lifecycle` policy)/);
141+
});
142+
143+
it(`${key}: never sends the author to \`trackHistory\``, () => {
144+
expect(read()).not.toContain('trackHistory');
145+
});
146+
}
147+
148+
it('the prescription agrees with resolveFieldHistory', () => {
149+
const text = { type: 'text' } as const;
150+
expect(resolveFieldHistory(text, {}), 'values show by default').toBe(true);
151+
expect(resolveFieldHistory(text, { enable: { fieldHistory: false } }), 'object off switch').toBe(false);
152+
expect(resolveFieldHistory({ ...text, fieldHistory: false }, {}), 'field off switch').toBe(false);
153+
expect(resolveFieldHistory({ ...text, trackHistory: false }, {}), 'trackHistory: false is no off switch').toBe(true);
154+
const json = { type: 'json' } as const;
155+
expect(resolveFieldHistory(json, {}), 'a structured-JSON field is off by default').toBe(false);
156+
expect(resolveFieldHistory({ ...json, fieldHistory: true }, {}), 'fieldHistory: true opts it in').toBe(true);
157+
const image = { type: 'image' } as const;
158+
expect(resolveFieldHistory(image, {}), 'a media field is off by default').toBe(false);
159+
expect(resolveFieldHistory({ ...image, fieldHistory: true }, {}), 'fieldHistory: true opts it in').toBe(true);
160+
});
161+
});
162+
103163
it('rejects unknown capability keys instead of stripping them', () => {
104164
const result = ObjectCapabilities.safeParse({ feedEnabled: true });
105165
expect(result.success).toBe(false);
@@ -1316,7 +1376,7 @@ describe('ObjectSchema.create()', () => {
13161376

13171377
it('tombstone: dead metadata keys removed in 16.0 carry upgrade guidance', () => {
13181378
const cases: Array<[string, unknown, string]> = [
1319-
['versioning', { enabled: true }, 'trackHistory'],
1379+
['versioning', { enabled: true }, 'fieldHistory'],
13201380
['softDelete', { enabled: true }, 'the recycle bin that shipped later (ADR-0148)'],
13211381
['search', { fields: ['name'] }, 'searchableFields'],
13221382
['recordName', { type: 'autonumber' }, 'autonumber'],

‎packages/spec/src/data/object.zod.ts‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ export function stripLegacyApiMethods(
192192
return kept;
193193
}
194194

195+
/**
196+
* Where a retired key that promised history sends the author for FIELD
197+
* history — the `enable.trash` and `versioning` tombstones share it, so the
198+
* two prescriptions cannot drift apart. It states the model
199+
* `resolveFieldHistory` (`field-history-default.ts`) enforces: values show by
200+
* default except for the `FIELD_HISTORY_DEFAULT_OFF_TYPES` (media and
201+
* structured JSON), which opt in with `fieldHistory: true`; the object's off
202+
* switch is `enable.fieldHistory: false`, a field's is its own
203+
* `fieldHistory: false`. ⛔ Never `trackHistory` here: on a field it
204+
* only opts a media or structured-JSON type in, and `false` is not an off
205+
* switch; on the object it opens the history ledger, not the values.
206+
*/
207+
const FIELD_HISTORY_PRESCRIPTION =
208+
'Field history is on by default: a changed field\'s old → new values show on the record ' +
209+
'activity timeline, except a media or structured-JSON field, which opts in with ' +
210+
'`fieldHistory: true`. `enable.fieldHistory: false` turns them off for the object, and a ' +
211+
'field opts out with its own `fieldHistory: false`.';
212+
195213
/**
196214
* Tombstones for RETIRED capability flags — same doctrine as the tenancy
197215
* block and the top-level `UNKNOWN_KEY_GUIDANCE` map below: a retired
@@ -209,8 +227,8 @@ const CAPABILITIES_RETIRED_KEY_GUIDANCE: Record<string, string> = {
209227
'soft-delete that never ran). Delete the key. The recycle bin that shipped ' +
210228
'later (ADR-0148) has no flag: it takes every by-id delete of a business ' +
211229
'object, and none of a platform object (`sys_`, `cloud_`, `ai_`), whose ' +
212-
'deletes stay permanent. For history use per-field `trackHistory` (audit ' +
213-
'trail), and for retention a `lifecycle` policy. ' +
230+
'deletes stay permanent. ' + FIELD_HISTORY_PRESCRIPTION + ' For retention, ' +
231+
'a `lifecycle` policy. ' +
214232
'This edit left `os migrate meta` with the protocol-16.x conversions: apply it by hand, or run the tool on a release that still carries the conversion — https://objectstack.ai/docs/protocol-upgrade.',
215233
mru:
216234
'`enable.mru` was removed from @objectstack/spec in the 16.x line (' +
@@ -1959,9 +1977,9 @@ const UNKNOWN_KEY_GUIDANCE: Record<string, string> = {
19591977
'deletes are permanent.',
19601978
versioning:
19611979
'`versioning` was removed from the spec in 16.0 (ADR-0049) — no ' +
1962-
'record-versioning engine ever read it (it snapshotted no history). Use ' +
1963-
'per-field `Field.trackHistory` for field-level history, or a data ' +
1964-
'lifecycle policy (`lifecycle`) for retention.',
1980+
'record-versioning engine ever read it (it snapshotted no history). ' +
1981+
FIELD_HISTORY_PRESCRIPTION + ' For retention, use a data lifecycle ' +
1982+
'policy (`lifecycle`).',
19651983
search:
19661984
'`search` (the SearchConfig block) was removed from the spec in 16.0 ' +
19671985
'(ADR-0049) — no search-engine config was consumed. Declare the ' +
@@ -4699,8 +4717,9 @@ const ObjectSchemaBase = strictObject(
46994717
/**
47004718
* Declarative semantic activity milestones (ADR-0052 §5b.2). When a watched
47014719
* field transitions INTO `value`, the platform emits a templated activity-row
4702-
* on the record timeline — no `*.hook.ts` / `*.flow.ts`. Complements field-level
4703-
* `trackHistory` (which renders raw "Field: old → new"): use milestones for
4720+
* on the record timeline — no `*.hook.ts` / `*.flow.ts`. Complements the
4721+
* field-change rows (raw "Field: old → new", shown by default; off with
4722+
* `enable.fieldHistory: false` or a field's `fieldHistory: false`): use milestones for
47044723
* business-meaningful events ("Deal won", "Task completed"). `summary` supports
47054724
* `{field}` tokens interpolated from the record; the milestone summary takes
47064725
* precedence over the field-change summary for the same update. Consumed by

0 commit comments

Comments
 (0)