Repository navigation
Commit 1f1cd21
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
211 | 228 | | |
212 | 229 | | |
213 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1703 | 1703 | | |
1704 | 1704 | | |
1705 | 1705 | | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1706 | 1717 | | |
1707 | 1718 | | |
1708 | 1719 | | |
| |||
1741 | 1752 | | |
1742 | 1753 | | |
1743 | 1754 | | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1748 | 1762 | | |
1749 | 1763 | | |
1750 | 1764 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
103 | 163 | | |
104 | 164 | | |
105 | 165 | | |
| |||
1316 | 1376 | | |
1317 | 1377 | | |
1318 | 1378 | | |
1319 | | - | |
| 1379 | + | |
1320 | 1380 | | |
1321 | 1381 | | |
1322 | 1382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
195 | 213 | | |
196 | 214 | | |
197 | 215 | | |
| |||
209 | 227 | | |
210 | 228 | | |
211 | 229 | | |
212 | | - | |
213 | | - | |
| 230 | + | |
| 231 | + | |
214 | 232 | | |
215 | 233 | | |
216 | 234 | | |
| |||
1959 | 1977 | | |
1960 | 1978 | | |
1961 | 1979 | | |
1962 | | - | |
1963 | | - | |
1964 | | - | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
1965 | 1983 | | |
1966 | 1984 | | |
1967 | 1985 | | |
| |||
4699 | 4717 | | |
4700 | 4718 | | |
4701 | 4719 | | |
4702 | | - | |
4703 | | - | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
4704 | 4723 | | |
4705 | 4724 | | |
4706 | 4725 | | |
| |||
0 commit comments