Repository navigation
Commit 5c7e448
fix(lint): the object_extension publish door refuses an extension field under a label its target already shows, or another field of the same extension shows (field-label-duplicate) (#34132)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9X2XkBPz2k7zHhv5J4C6j7e)_
Fixes #33644
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none owed — this PR edits
`content/docs/deployment/validating-metadata.mdx` (the object extension
door paragraph names the rule); `os explain field-label-duplicate` names
the door; `skills/objectstack-data` teaches `defineObjectExtension({
extend, fields })` and reusing `owner_id` instead of a second owner
field without saying the runtime door is exempt, so the door now gives
the verdict the build already gives.
## 维护者速读
- 改了什么:运行时发布扩展对象(Studio 加字段、`/meta` 写入、MCP/AI
作者)时,也检查"同一对象出现两个同名标签的可见字段";扩展新加的字段若和目标对象已有字段(含平台的
`owner_id`)同名标签,或同一扩展里两个字段同名标签,发布被拒(422)。
- 为什么改:这条规则原来只拦 `object`
写入,扩展写入不拦,于是扩展可以在别人的对象上加出第二个"负责人"列,列表、卡片、表单里两列同名分不清。
-
风险与回滚:只收紧扩展发布门;只追究这次扩展新造成的冲突,目标对象原有冲突不算它的,扩展把原有冲突变小(拿走其中一个字段)也不算;一方示例(showcase、plugin-auth
各一条扩展)实测零命中。回滚 = revert 本 PR。
-
先看:`packages/lint/src/lint-duplicate-field-labels.ts`(`duplicateFieldLabelFindings`
的两项门输入);`packages/lint/src/authoring-rules.ts`(`lintDuplicateFieldLabels`
条目加
`object_extension`);`packages/lint/src/runtime-gate.object-writes.test.ts`(新
describe 的十一条用例)。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run
src/runtime-gate.object-writes.test.ts -t "object_extension door
refuses"`,预期 11 条全绿。
- 需要你做的:无,席位落地。
## What changes
- `lintDuplicateFieldLabels` (`field-label-duplicate`) joins the
`object_extension` publish door (`runtimeTypes: ['object',
'object_extension']`).
- On that door the rule judges the target as it will be served after the
write: the door already hands the target as served without the written
package's own stored extension; the rule folds the written entry among
the target's other packages' extensions by priority
(`ctx.storedObjectExtensions`, the build's fold, so a field two packages
tie on is left out as at the build), and reads the served objects back
to their authored shape (`stripInjectedSystemColumns`, keyed on
`ctx.runtimeWriteType === 'object_extension'`, the argument
`validateStackExpressions` gives for the same input), so `owner_id` is
named as the platform's column exactly as the build names it.
- The published signature of `lintDuplicateFieldLabels(stack)` is
unchanged; the door inputs go through the module-internal
`duplicateFieldLabelFindings(stack, options)`, which is not on any
package entry.
- The gate's existing differential charges the write only with a clash
its entry creates; no gate code changed (one comment in
`runtime-gate.ts`). On this door the rule also drops a candidate clash
whose fields are a subset of a clash the target already serves before
the write: an entry that takes a member out of a three-member clash
(relabel, hide, or a priority tie) changes the group's message, so the
fingerprint differential alone would charge it for what is left.
- An entry whose own two fields share a label is refused the same way,
whether or not the target shows that label (the build already refuses
it; the semantic entry, changeset and docs now name this arm).
- The door reads no translation bundle, so the refusal's remedy
(semantic entry `replacement`, changeset Migration line, docs) is to
give the field a label of its own or reuse the platform column, and on
this door the finding's hint drops the build's "(in the translation
bundle too …)" clause; `os build` / `os validate` judge a bundle that
translates the label apart.
- The before-write snapshot that the shrink rule reads is computed only
for the objects the written entry extends (verdicts unchanged).
- `os explain field-label-duplicate` and
`content/docs/deployment/validating-metadata.mdx` name the door.
- ADR-0087 semantic entry
`object-extension-door-field-label-duplicate-refused` (registered),
changeset `.changeset/33644-object-extension-door-label-duplicate.md`
(lint + spec minor).
Premise reading: the card's "the TARGET's next `object` save is refused
for a clash the extension created" holds at `os build` (the stack's
extensions fold onto a declared target), not at the publish door: an
`object` write judges the body it sends, which carries no extension
fields. The door pin below reads it.
## Tests
New top-level describe in `runtime-gate.object-writes.test.ts` (the
rule's door harness), each a real reading through
`runRuntimeAuthoringRules`:
1. ⭐ an extension field labelled 负责人 beside the injected `owner_id` is
REFUSED: `where` `object "xl_ticket"`, wire path
`objects.xl_ticket.fields`, message names both fields, the label and
locale zh-CN, and is byte-identical to the build's finding over the same
entry; an extension field labelled like a target field (`Subject`) is
refused in the authored pass.
2. unrelated extension writes (`Escalation Level`; `assignee` labelled
处理人; `assignee` labelled 负责人 with `hidden: true`) are not charged.
3. the target's own `object` save after a refused extension write is
clean (`lintDuplicateFieldLabels` ran, zero errors).
4. a target that already carries a clash (`phone`/`mobile` both `Phone`,
the build reports it) is not charged to an unrelated extension write; an
entry that joins the clash is charged (`'fax', 'mobile' and 'phone'`).
5. priority fold: a tie with another package's extension is left out at
the build and at the door (with `storedObjectExtensions`); without the
stated extensions the door would refuse it; a higher priority (210) is
refused.
6. the rule is on both doors.
7. an entry that shrinks a three-member clash the target already serves
(`phone`/`mobile`/`fax` all `Phone`; the entry relabels or hides `fax`
at priority 210, or ties it at 200) is not charged; a swap that takes
`fax` out and puts `headline` under `Phone` is charged.
8. a clashing extension already stored is folded onto the served target
by the host; the target's own `object` save then has zero errors, and
the build reports the clash on `object "xl_ticket"`.
9. ⭐ an entry whose own `a__c` and `b__c` are both labelled `Region`, on
a target that shows no `Region`, is refused; the message names both
fields and equals the build's; the same fields under labels of their own
publish.
10. the door's hint for a clash only zh-CN shows does not mention a
translation bundle; the build's hint over the same entry still does.
Forced test edits (each because the rule now runs on this door):
- `runtime-gate.object-formula-writes.test.ts` (2 exact roster pins) and
`validate-security-posture.runtime-surface.test.ts` (3 exact roster
pins): `lintDuplicateFieldLabels` inserted in registry order.
- `lint-duplicate-field-labels.test.ts`: the entry's `runtimeTypes` pin
reads `['object', 'object_extension']`.
- `runtime-gate.object-formula-cycle.test.ts` "the target's own stored
cycle…": the extension field took the helper's shared label `F`, joining
the target's `f_x`/`f_y` group (a clash this door now charges); it gets
its own label `E`, so the test still asserts zero errors and still means
what it meant.
- `packages/runtime/src/domains/meta-object-extension-item.test.ts`
([#33153] / [#33494] formula-door describes): the `formula()` helper
labelled every field `F`, so the CONTROL entry (`a__c`, `b__c`) served
two visible fields under one label and the door refused it (CI Test Core
3/8 on `c51fcc1d`). The helper takes a label; the fields that share an
entry or a target get their own (`A`, `B`, `S`). Assertions unchanged.
Restoring the old fixture reds the CONTROL case only (1 of 50).
## Acceptance notes
- HotCRM extensions: not measured (outside this session's repository
scope).
- The CLI judges an extension's clash only when the stack declares the
target; an app extending another package's object is judged at the door
only. Unchanged by this PR.
## Verification
All readings at head `4fa9c1cd` (branch point `f81e4b6c`).
<details><summary>Package tests</summary>
- `pnpm --filter @objectstack/lint test`: Test Files 212 passed (212),
Tests 9037 passed (9037). `pnpm --filter @objectstack/lint typecheck`:
exit 0.
- `pnpm --filter @objectstack/spec exec vitest run src/migrations`: Test
Files 5 passed, Tests 198 passed.
- Consumer `pnpm --filter @objectstack/metadata-protocol test` (the
door's host): Test Files 342 passed, 9 skipped (351); Tests 22926
passed, 45 skipped.
- Extension-door fixture sweep (every test file outside `packages/lint`
that publishes or folds an `objectExtensions` entry): runtime 6 files /
135 tests, rest 5 / 55, objectql 8 / 343, cloud-connection 1 / 5, cli
`package-export` 1 / 6, all passed. The dogfood files of that kind run
in the battery below.
- Consumer `pnpm --filter @objectstack/cli exec vitest run --project
unit` (at `315696ed`; round 2 touches no cli input): 421/423 files on
the first run; the two reds were `published-subpath-console.pin` and
`published-subpath-hook-body.pin` refusing an unbuilt
`packages/cli/dist` (prerequisite); after the build both pass (2 files,
29 tests). Integration layer declared to CI.
- Full dogfood battery (Clause-② carries the `(narrowing)` arm), `pnpm
--filter @objectstack/dogfood test` under the lock: VERDICT command-exit
0, Test Files 467 passed, 3 skipped (470); Tests 3962 passed, 42 skipped
(4004).
</details>
<details><summary>Ablations (one-off, through
scripts/ablation-replace.mjs, restored to the HEAD blob each
time)</summary>
- Rule's `runtimeTypes` back to `['object']`: all 7 round-1 cases of the
new describe red.
- The stored-extension fold (`objectsAsServed(stack, [])`): only the
priority-fold case reds.
- The served-object read-back (`servedObjects` branch disabled): only
the owner_id case reds (the finding stops naming `owner_id` as the
platform's column, so it no longer equals the build's message).
- The subset drop (`continue` removed): only the shrink case (7) reds.
- The door's hint clause (`authored || extensionWrite` back to
`authored`): only the hint case (10) reds, 1 of 55 in the file.
</details>
<details><summary>First-party exposure</summary>
- `examples/app-showcase` entry on `showcase_account` (three fields):
build over object + entry + the showcase translation bundle 0 findings;
door 0; a planted 负责人 `user` field on the same target is refused (1).
- `packages/plugins/plugin-auth` entry on `sys_sso_provider`
(`oidc_client_secret`): build 0, door 0; a planted field under the
target's `ID` label is refused (1).
- No other `objectExtensions` entry under `examples/**` or `packages/**`
(tooling and tests aside). HotCRM: not measured.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 114 commands. All 114 exit 0.
- `dispatch-gates --ran`: 114 derived, 114 run, 0 NOT-MEASURED, 0 UNRUN.
- `check-changeset-no-major --base origin/main --event` over this body:
exit 0 (level axis: `no (narrowing)` + `narrowed`, no package graded
patch).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (No formatter ran;
`eslint --no-inline-config` over the ten changed `.ts` files exits 0;
the repo-wide run is CI's.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (One migration entry; `check:spec-changes`,
`check:upgrade-guide` and the generated-artifact gates exit 0, nothing
to commit.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE
<!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 74e99c2 commit 5c7e448
13 files changed
Lines changed: 474 additions & 50 deletions
File tree
- .changeset
- content/docs/deployment
- packages
- lint/src
- runtime/src/domains
- 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | | - | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
633 | 637 | | |
634 | 638 | | |
635 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
359 | 367 | | |
360 | 368 | | |
361 | 369 | | |
362 | 370 | | |
363 | 371 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
368 | 379 | | |
369 | 380 | | |
370 | 381 | | |
| |||
2370 | 2381 | | |
2371 | 2382 | | |
2372 | 2383 | | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
2373 | 2401 | | |
2374 | 2402 | | |
2375 | 2403 | | |
2376 | 2404 | | |
2377 | 2405 | | |
2378 | 2406 | | |
2379 | 2407 | | |
2380 | | - | |
2381 | | - | |
2382 | | - | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
2383 | 2414 | | |
2384 | 2415 | | |
2385 | 2416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
0 commit comments