Skip to content

Commit fa487d2

Browse files
committed
fix(spec): name the default-off field types and answer trackChanges/feedTracked with fieldHistory
The shared enable.trash / versioning prescription said field history needs no key; a media or structured-JSON field shows values only with fieldHistory: true, so the sentence now says so and the cross-check pins the opt-in. The trackChanges and feedTracked field spellings renamed onto trackHistory, whose false turns nothing off; they now take the tracked answer (both stay refused). Claude-Session: https://claude.ai/code/session_01L9qibybKQ9ZAg8zN9fVBEN Co-authored-by: Claude <noreply@anthropic.com>
1 parent 396a54f commit fa487d2

6 files changed

Lines changed: 60 additions & 13 deletions

File tree

‎.changeset/36776-retired-key-field-history-prescription.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Metadata-protocol: none
99

1010
Four retired-key refusals 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.
1111

12-
The `enable.trash` and `versioning` refusals now say that field history needs no key: a changed field's old → new values show on the record activity timeline by default, `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).
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).
1313

1414
Wording only: every key that was refused is still refused, and nothing is newly refused. Nothing to migrate.

‎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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ describe('ObjectCapabilities', () => {
104104
// `enable.trash` and `versioning` both promised history, so both refusals
105105
// say where field history lives now. It is the model `resolveFieldHistory`
106106
// enforces (values on by default, `enable.fieldHistory: false` for the
107-
// object, a field's own `fieldHistory: false`), never `trackHistory`: on a
107+
// object, a field's own `fieldHistory: false`, a media or structured-JSON
108+
// field opting in with `fieldHistory: true`), never `trackHistory`: on a
108109
// field that only opts a media or JSON type in and `false` turns nothing off.
109110
describe('retired history-promising keys prescribe the field-history model that runs', () => {
110111
const trashMessage = (): string => {
@@ -129,7 +130,10 @@ describe('ObjectCapabilities', () => {
129130
it(`${key}: values show by default, and the two off switches are named`, () => {
130131
const message = read();
131132
expect(message).toContain(
132-
'Field history needs no key: a changed field\'s old → new values show on the record activity timeline by default.',
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`.',
133137
);
134138
expect(message).toContain('`enable.fieldHistory: false` turns them off for the object');
135139
expect(message).toContain('a field opts out with its own `fieldHistory: false`');
@@ -147,6 +151,12 @@ describe('ObjectCapabilities', () => {
147151
expect(resolveFieldHistory(text, { enable: { fieldHistory: false } }), 'object off switch').toBe(false);
148152
expect(resolveFieldHistory({ ...text, fieldHistory: false }, {}), 'field off switch').toBe(false);
149153
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);
150160
});
151161
});
152162

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,18 @@ export function stripLegacyApiMethods(
197197
* history — the `enable.trash` and `versioning` tombstones share it, so the
198198
* two prescriptions cannot drift apart. It states the model
199199
* `resolveFieldHistory` (`field-history-default.ts`) enforces: values show by
200-
* default, the object's off switch is `enable.fieldHistory: false`, a field's
201-
* is its own `fieldHistory: false`. ⛔ Never `trackHistory` here: on a field it
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
202204
* only opts a media or structured-JSON type in, and `false` is not an off
203205
* switch; on the object it opens the history ledger, not the values.
204206
*/
205207
const FIELD_HISTORY_PRESCRIPTION =
206-
'Field history needs no key: a changed field\'s old → new values show on the record ' +
207-
'activity timeline by default. `enable.fieldHistory: false` turns them off for the ' +
208-
'object, and a field opts out with its own `fieldHistory: false`.';
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`.';
209212

210213
/**
211214
* Tombstones for RETIRED capability flags — same doctrine as the tenancy

0 commit comments

Comments
 (0)