Repository navigation
Commit 3cbf1f2
feat(lint)!: refuse an object that shows two visible fields under one label (#33639)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XU2xTyPNgEy5xtAJUJL1GdG)_
Fixes #33545
Part of #33506
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — the authoring half (an AI builder reusing `owner_id`
rather than adding a second owner field) is the skills lane's on the
parent card; `os explain field-label-duplicate` carries the rule's full
text, and four CLI transcripts in `content/docs` move their author-time
rule count from 67 to 68 (claim amendment 6887617666).
Severity ruling: error at the author door, installed apps unaffected at
load (claim 6887573651, Ruling-ref 「开放 p3卡认领」). Measured: no boot or
registration path runs the author-time rules, so no fork.
## 维护者速读
- **改了什么**:`@objectstack/lint` 新增一条门禁规则
`field-label-duplicate`:同一对象上两个及以上可见字段(含平台注入的
`owner_id`、创建/修改时间与人)在作者写的标签或任一语言下显示为同一个标签,就报错。`os build` / `os
validate` / `os lint` 和元数据发布门(对象写入)都执行它。示例应用里三处中文标签撞了 `owner_id`
的「负责人」,已改名(showcase 的任务「处理人」、团队「组长」,todo 的任务「处理人」),并登记了 ADR-0087 迁移条目。
- **为什么改**:staging 上 AI 搭的工单对象有 `owner_id`(中文「负责人」)和新加的
`assignee`(也叫「负责人」),表格出两列「负责人」、看板卡片显示两次,用户分不清改的是哪个。构建时就拦下,比上线后再发现好。
-
**风险与回滚**:今天能构建的元数据如果有同名可见字段会构建失败(这是有意的收紧);已安装的应用启动不受影响。发布门上,已存储对象若带同名字段,再次保存该对象会被拒直到改名;保存别的对象不受影响。回滚即
revert。
-
**先看**:`packages/lint/src/lint-duplicate-field-labels.ts`(比较哪些字段、哪些语言),`packages/lint/src/authoring-rules.ts`(新登记项,门禁
+ 对象发布门),`examples/app-showcase/src/system/translations/index.ts`(示例改名)。
- **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run
--maxWorkers=2 src/lint-duplicate-field-labels.test.ts`,预期 9
个用例全绿;其中第一个就是 staging 的 `owner_id` + `assignee`「负责人」。
- **需要你做的**:无,席位落地。
## What changes
- **`packages/lint/src/lint-duplicate-field-labels.ts`** (new):
`lintDuplicateFieldLabels(stack)`, rule id `FIELD_LABEL_DUPLICATE` =
`field-label-duplicate`, `error`. Per object it compares the fields the
object SERVES: its own fields with every `objectExtensions` field of the
stack folded in (`objectsAsServed`, tied fields left out, as
`lintAutonumberFormats` does), plus the columns the registry injects on
it (`injectedColumnDefsFor`, the spec tables `applySystemFields`
spreads; an authored field of the same name replaces the injected one).
`hidden: true` fields are skipped; the injected `organization_id`,
`owning_business_unit_id` and `queue` are hidden by their own
definitions, so `owner_id` and the four audit columns are compared.
Labels are compared trimmed, once as authored and once per locale,
through the spec's own read-exit translator `translateObject` (no second
copy of its ladder). Locales: every locale a `translations` bundle of
the stack carries plus `BUILTIN_SYSTEM_FIELD_LABEL_LOCALES` (`en`,
`zh-CN`, `ja-JP`, `es-ES`), the locales a `/meta` read translates the
injected columns into with no bundle at all. That second set is what
catches the #33506 case: the author's `assignee` keeps 负责人 while
`owner_id` is served 负责人 to a `zh-CN` reader. One finding per group of
fields sharing a label; it names every field, the label, the locale(s)
when only some clash, and the injected column(s) involved; the hint says
rename, `hidden: true`, or drop the duplicate and use the platform
column.
- **`packages/lint/src/authoring-rules.ts`**: one entry, `tier:
'gating'`, `input: 'parsed'`, all three commands, `surfaces:
CLI_AND_RUNTIME`, `runtimeTypes: ['object']` (the `lintSummaryRollups`
shape). **`index.ts`**: barrel export of the function, the id constant
and the finding type.
- **`packages/lint/src/rule-explanations.ts`**: `os explain
field-label-duplicate` entry (additive, appended after the last entry
and at the end of the table; in-flight PR #33517 also edits this file).
- **User text:** none. The family's `*.user-text.ts` catalogs hold
sentences for door ADVISORIES only
(`lint-autonumber-formats.user-text.ts`: "The two errors … refuse the
write and have no sentence here"); this rule is an error.
- **Tests:** `lint-duplicate-field-labels.test.ts` (new, 9 cases: the
#33506 pair red, hidden duplicate clean, distinct labels clean,
`ownership: 'none'` clean, a clash only one translated locale creates
naming that locale, an authored clash named once with no locale, an
authored `owner_id` with its own label replacing the injected one, the
registry entry on all three commands, and the explanation naming exactly
the built-in locales); `runtime-gate.object-writes.test.ts` (the door
roster and `rulesRun` pins gain the entry; a new describe: the write
that adds the clash is refused with a name-keyed path, the hidden and
relabelled controls publish, a sibling write is not charged with a
stored object's clash, and a re-save of the clashing object is judged on
its body).
- **Shipped metadata the narrowing bit, relabelled (zh-CN bundle
only):** `example-showcase` `showcase_task.assignee` 负责人 → 处理人 and
`showcase_team.lead` 负责人 → 组长 (plus the `p_assignee` action-param label
and its comment, which said it matches `showcase_task.assignee`);
`example-todo` `todo_task.owner` 负责人 → 处理人 (and the
`todo_tasks_by_owner` report label/description that names the same
field). Each of the three was served 负责人 beside `owner_id` to a `zh-CN`
reader.
- **ADR-0087:**
`packages/spec/src/migrations/entries/semantic/18.object-field-label-duplicate-refused.ts`
(a structured TODO: which field keeps the label is the author's choice,
so no D2 conversion); the changeset carries `registered
object-field-label-duplicate-refused`.
- **Fixtures the door now refuses, relabelled (claim amendment
6887847864, no assertion changed):** two metadata-protocol test files,
both about other rules at the publish door.
`protocol.runtime-authoring-gate.test.ts`: four fixture objects declare
`owner: { type: 'text', label: 'Owner' }`, which the door now reads as
one label with the injected `owner_id` ("Owner"); relabelled `'Owner
Name'` (lines 413, 703, 714, 791).
`protocol.unknown-picklist-binding-refusal.test.ts`: the `object()`
helper gives every bound select field the label `'Tier'`, so a fixture
binding `t` and `tier` showed two "Tier" columns; the label is now ``
`Tier (${field})` `` (line 187). Neither test is about labels or
`owner_id`; 266 of 266 metadata-protocol tests green after the relabel.
No other fixture in the swept suites or the dogfood battery was refused.
- **Docs:** the four CLI transcripts' `Running author-time rules (67)` →
`(68)` (claim amendment 6887617666).
- **`.changeset/33545-duplicate-field-labels.md`**: `@objectstack/lint`
and `@objectstack/spec` `minor` (`narrowed`), BREAKING banner with FROM
→ TO lines and fixes.
### Where the rule runs, measured
- `os build` / `os validate` / `os lint` and `os verify`'s author-time
step: the registry (`authoringRulesFor`). Scaffold validation runs it
too (`scaffold-validate.ts`).
- The publish door: `saveMetaItem` with `state: 'active'` and the
draft→active promotion, through `judgeRuntimeAuthoringRules` /
`runtimeAuthoringRulesFor('object')`. Studio, REST `/meta` and MCP/AI
authors reach it there. The door snapshot carries no `translations`, so
at the door the authored labels and the built-in system-field labels are
compared (which is the staging case).
- Boot / registration: nothing on that path runs `AUTHORING_RULES` (`git
grep` over every non-test consumer: the CLI commands, scaffold validate,
`os verify`, the metadata-protocol save/publish gate;
`metadata-diagnostics.ts` imports two named lint functions only, not the
registry). So an installed app keeps loading — no fork.
- "The AI builder's integrity check" (card item 1): not in this
repository (no such check under `packages/`; the builder is in cloud).
What this repo offers it is the publish door above, which every
MCP/REST/Studio object write passes; nothing was done in cloud.
## Tests
- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/lint-duplicate-field-labels.test.ts
src/runtime-gate.object-writes.test.ts`: 53 passed.
- **Ablation 1** (rule returns nothing: `if (!isRec(stack)) return
findings;` → always return, via `scripts/ablation-replace.mjs`): 6 red,
among them the #33506 `owner_id` + `assignee` case, the one-locale
clash, the authored clash, the registry entry and both door cases;
restored, blob equals HEAD, `git diff HEAD` empty.
- **Ablation 2** (hidden fields compared: `if (def.hidden === true)
continue;` neutralised): 2 red, the hidden control in the rule test and
the hidden/relabelled publish control at the door; restored the same
way.
- Consumer suites on this branch, each exit 0: rest 8393, runtime 10781,
objectql 13028, service-automation 3916, service-datasource 1317,
plugin-security 6679, client 812, mcp 1174, cloud-connection 1209,
verify 437, example-showcase 545, example-todo 249, example-crm 51, cli
unit tier 5966, metadata-protocol 266, plugin-approvals rule-runner
tests 24, spec migrations 198.
## Acceptance notes
- **Sweep.** Every example and every first-party app under
`packages/apps` built through the real CLI (`os build`): only
`example-showcase` and `example-todo` were refused, the three fields
relabelled above; all 11 build clean now. HotCRM (5 packages, 23
objects, 5 bundles): 0 findings, with a positive control (a duplicate of
each object's first visible label) firing on 23 of 23 objects, so the
probe reached every object.
- **A re-save of a stored object that carries the clash is refused** at
the publish door until it is fixed, as for every gating rule there (the
door's differential removes the written item's stored self, so its own
clash is new to the judgment). A write of any other object is never
charged with it. The door test pins both.
- **Out of scope, reported:** run over the platform's own objects with
their generated translation bundles (98 objects, 111 bundles), the rule
finds three clashes no author door judges, because these objects are not
built through `os build` and the door snapshot carries no translations:
`sys_import_job` `created_at`/`created_count` "Создано" (ru),
`sys_oauth_resource` `id`/`identifier` "المعرّف" (ar), `sys_user`
`accountable_user_id`/`manager_id` "Responsable" (fr). Each is a
reader-facing duplicate column in that locale. Left untouched here
(translation pipeline output outside the card); named as a follow-up in
the report.
- **Where the door compares locales:** the authored labels and the
built-in `en`/`zh-CN`/`ja-JP`/`es-ES` system-field labels, which is the
staging case; a clash only a stored translation bundle creates is caught
by `os build`/`os validate`/`os lint`, not at the object write.
## Verification
- Gate list from `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at 274a4bd: 116 commands, every one run,
every one exit 0. Three first exited 3 (prerequisite not met, not a
finding) and were rerun after the dependency builds:
`check-plugin-teardown-shape.mjs --self-test` (pinned commit fetched),
`spec check:skill-examples` (client builds),
`check:dual-build-cjs-loads` (dist builds). Log:
`/mnt/project-files/pm-orders/spec/33545-gates-ran.txt`.
- Typecheck: `@objectstack/lint` (including its test typecheck),
`@objectstack/metadata-protocol`, `@objectstack/spec` (`tsc --noEmit`),
`example-showcase`, `example-todo`: exit 0.
- Dogfood battery on 274a4bd (`pnpm --filter @objectstack/dogfood test`
under the verify lock, after building `@objectstack/dogfood^...`):
command exit 0, 467 files passed and 3 skipped, 3950 tests passed and 42
skipped. No fixture was refused.
- Not measured here: the CI-only rows `dispatch-gates` names as having
no local invocation (Build Core, the Dogfood Regression Gate's
merge-queue run, the type-check lanes over CI's whole-workspace
filters).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5mdmzDcF58D1JdRH4y
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mdmzDcF58D1JdRH4y)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent de5eb08 commit 3cbf1f2
16 files changed
Lines changed: 525 additions & 15 deletions
File tree
- .changeset
- content/docs
- deployment
- getting-started
- ui
- examples
- app-showcase/src/system/translations
- app-todo/src/translations
- packages
- lint/src
- metadata-protocol/src
- spec/src/migrations/entries/semantic
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | | - | |
| 883 | + | |
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
846 | 846 | | |
847 | 847 | | |
848 | 848 | | |
849 | | - | |
| 849 | + | |
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
471 | 474 | | |
472 | 475 | | |
473 | 476 | | |
| |||
859 | 862 | | |
860 | 863 | | |
861 | 864 | | |
862 | | - | |
| 865 | + | |
863 | 866 | | |
864 | 867 | | |
865 | 868 | | |
| |||
1002 | 1005 | | |
1003 | 1006 | | |
1004 | 1007 | | |
1005 | | - | |
| 1008 | + | |
1006 | 1009 | | |
1007 | 1010 | | |
1008 | 1011 | | |
| |||
1013 | 1016 | | |
1014 | 1017 | | |
1015 | 1018 | | |
1016 | | - | |
| 1019 | + | |
1017 | 1020 | | |
1018 | 1021 | | |
1019 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
107 | | - | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
2345 | 2346 | | |
2346 | 2347 | | |
2347 | 2348 | | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
2348 | 2378 | | |
2349 | 2379 | | |
2350 | 2380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1185 | 1185 | | |
1186 | 1186 | | |
1187 | 1187 | | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1188 | 1191 | | |
1189 | 1192 | | |
1190 | 1193 | | |
| |||
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments