Repository navigation
fix(metadata-protocol,cli,cloud-connection)!: refuse an object extension that re-declares an owner's field beyond its display properties (ADR-0146 D10) - #30712
Conversation
…t re-declares an owner field beyond its display properties ADR-0146 D10: a base field changes only within the display-property whitelist. An objectExtensions[].fields entry naming a field the extended object's owner declares replaces that field whole in the registry fold, so it is now refused at the object_extension save/publish/restore doors, at os validate (owner in the same artifact) and at the marketplace install door when it changes anything outside BASE_FIELD_DISPLAY_WHITELIST. One judge, judgeRedeclaredOwnerFields; the prescription names fieldPatches and the whitelist. The registry warning stays. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx4CnMVtuDswCA9p2c
…efusal at each door; add its changeset The object_extension save and publish doors (real store and registry), os validate on an assembled artifact, and the install-local door each refuse a type change of an owner field with VALIDATION_ERROR and admit a display-only re-declaration. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx4CnMVtuDswCA9p2c
…declares Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx4CnMVtuDswCA9p2c
📓 Docs Drift CheckThis PR changes 3 package(s): 37 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 45 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 29087b212d64a1c407b916fdd174e0d59f50a9be && git checkout 29087b212d64a1c407b916fdd174e0d59f50a9be
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin badf24dffc27773f566987e810e36896bbd34c2b 435f30c7f5e18059de44fb0d3579aed79aff88f5 && git checkout -B drift-repro badf24dffc27773f566987e810e36896bbd34c2b && git merge --no-ff 435f30c7f5e18059de44fb0d3579aed79aff88f5
node scripts/docs-audit/affected-docs.mjs --json badf24dffc27773f566987e810e36896bbd34c2b
|
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW Contract-review-claim: session_016WV4cytLmJxfAmgPVjUbbW · head 674555f · 2026-11-05T23:03Z |
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Should-fix (non-blocking, none is a FAIL):
Implemented-by: VERDICT: PASS |
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW 席位核对 · ACCEPT · 2026-11-05T23:34Z · #30610Head-sha: 435f30c
|
Requested by Elon · project thread
Fixes #30610
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: no move —
skills/**andcontent/docs/**already teachfieldPatchesas the way to change a base field's display, and no page teaches taking an owner field over throughfields; the prescription ships in the refusal text.ADR-0087 disposition (in the changeset):
not-required (no-migration-prescription)— a refused shape with no mechanical rewrite (which keys of a re-declared field were meant as display and which as a takeover is a judgement about the field), and no first-party artifact writes the shape (measured below). A stored row that already re-declares an owner field keeps registering with the registry's warning and is judged when next saved or published.维护者速读
objectExtensions[].fields里重新声明属主对象已有的字段(例如把amount的类型从数字改成文本、去掉必填、改成只读)时,现在在三道门被拒:元数据保存/发布/恢复(400VALIDATION_ERROR)、os validate(退出码 1)、市场安装(422VALIDATION_ERROR)。提示语点名fieldPatches和可改的展示属性白名单。fields里写同名字段会整体替换属主字段,过去只有注册表打一条警告,任何门都不拦。packages/metadata-protocol/src/protocol-extension-redeclared-owner-field.ts(判定本身,redeclaredFieldChanges的比较规则是风险点),packages/metadata-protocol/src/protocol-object-extension-item.ts第 7 步,packages/cloud-connection/src/marketplace-install-local-plugin.ts的 2e'。pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol-extension-redeclared-owner-field.test.ts,预期 12 个用例全绿(类型变更被拒、只改标签放行)。What changes
ADR-0146 D10, second rule: "Everything else on a base field — type,
required,unique,reference,defaultValue, formulas,optionsmembership — is refused on the extension with a prescription naming the whitelist." AnobjectExtensions[].fieldskey naming a field the extended object's owner declares replaces that field whole inmergeObjectDefinitions({ ...base.fields, ...extension.fields }), and before this PR no door refused it; onlyreportRedeclaredFieldswarned.One judge —
packages/metadata-protocol/src/protocol-extension-redeclared-owner-field.ts, beside the__cjudge (judgeExtensionFieldSuffix):judgeRedeclaredOwnerFields({ packageId, objectExtensions, ownerOf, at })returns every entry that re-declares an owner field and changes something outsideBASE_FIELD_DISPLAY_WHITELIST(read from@objectstack/spec/data, never re-spelled), located, withchanged(the keys, sorted) and the sentence.redeclaredFieldChanges(extensionField, ownerField): both bodies are read throughFieldSchemafirst (a default the parse stamps on one side is no change), then compared key by key, skipping the whitelisted keys,nameand the ADR-0010_envelope.optionsis compared as membership keyed by storedvalue, each option without its whitelistedlabel, so a relabel or reorder is no change.redeclaredOwnerFieldRefusalError(VALIDATION_ERROR/ 400 withissues[], the__cjudge's envelope) andredeclaredOwnerFieldInstallMessage(the install door's sentence).Three doors call it:
objectExtensionItemRefusalstep 7 (protocol-object-extension-item.ts), which the save (draft and live), the per-item and package publish, and the restore doors already ask. The owner is the registry'sgetObjectOwner(target)— its own declaration, never the resolved object, which already carries this package's earlier extension.os validate—packages/cli/src/utils/extension-redeclared-owner-fields.tswalks the artifact (eachpackages[]entry under its id, or the stack undermanifest.id); step 3a-v-bis ofvalidate.tsexits 1 with the rows onerrors(code: VALIDATION_ERROR). An owner outside the artifact is judged at install.POST /api/v1/marketplace/install-localstep 2e', on the managed and the.custompair branches, beside the field-patch target check:422 VALIDATION_ERROR, every refusal indetails.refusals, before any write. The owner is a package this artifact delivers, or the installed owner (getObjectOwner).reportRedeclaredFields(packages/objectql/src/registry.ts) is unchanged and stays a warning.Measurement (the card's step 1)
At
origin/mainf4d568ba:judgeExtensionFieldSuffixjudges only the suffix; the field-patch target check judgesfieldPatcheskeys; the registry warns.examples/app-showcase/src/data/extensions/account.extension.ts(the only extension underexamples/**) addsloyalty_tier,linkedin_url,csat_score, none of whichshowcase_accountdeclares, and extends its own package's object.packages/plugins/plugin-auth/src/manifest.tsextendssys_sso_providerwithoidc_client_secret, whichpackages/platform-objects/src/identity/sys-sso-provider.object.tsdoes not declare. HotCRM (objectstack-ai/hotcrm6961ab1): noobjectExtensionsanywhere.Tests
All at head
435f30c7.packages/metadata-protocol/src/protocol-extension-redeclared-owner-field.test.ts, 12 cases: refused on atypechange, a droppedrequired,readonly+defaultValue, an added option value, the array spelling located by index; admitted on a display-only re-declaration (labels, help text, option labels, reordered options), a parse-stamped default (required: falseagainst an owner that omits it), an added field, the package's own object, an unknown owner, the_envelope; the save doors' envelopeVALIDATION_ERROR/ 400 with every entry inissues.describeinpackages/runtime/src/domains/meta-object-extension-item.test.ts(the real-store rig: better-sqlite3 behindObjectQL, the real protocol and registry), with a writable module package that depends on the base: atypechange is refused at the save door (VALIDATION_ERROR/ 400 atfields.name, no row, no extender); a draft stored before the rule is refused at publish and stays a draft; a display-only re-declaration saves and publishes.os validate—packages/cli/test/validate-extension-redeclared-owner-field.test.ts(integration tier, spawns the CLI): an assembled artifact whose second package re-declares the first'samountastextexits 1 withpackages[1].manifest.objectExtensions[0].fields.amount,code: VALIDATION_ERROR,changed: ['type']; a label-only re-declaration validates clean.describeinpackages/cloud-connection/src/marketplace-install-local-field-patch-targets.test.ts(the 2e harness, a realSchemaRegistry): a type change of the installed owner's field is refused422 VALIDATION_ERRORwith the refusal indetails.refusalsand nothing registered, synced or written; an added option value on an owner the same artifact delivers is refused atpackages[1]…; a display-only re-declaration installs.validate-build-gate-parity.test.ts: the new gate is classified inVALIDATE_ONLY_GATES.Ablation (one-time, not kept)
Committed first, then
node scripts/ablation-replace.mjsonprotocol-extension-redeclared-owner-field.ts: anchorif (changed.length === 0) continue;(x1) replaced byif (changed.length >= 0) continue;(the judge refuses nothing);pnpm --filter @objectstack/metadata-protocol build;ablation-dist-preflight.mjssaw the marker indist/.os validate: 1 failed / 1 passed (the refusal)Restored from
HEAD(blobe7ae83e11485equals the HEAD blob,git diff HEADempty), rebuilt,ablation-dist-preflight.mjs --absentpassed over 24 built files; the runtime, install andos validatefiles green again.Acceptance notes
os builddoes not run the check yet (VALIDATE_ONLY_GATESrow invalidate-build-gate-parity.test.ts), the same build-side gap the field-patch target check carries; the install door refuses what the build emits.os validatejudges only an owner declared by another package of the same artifact. A single-package module stack that extends an installed base is judged at install.owner_id) is judged there and not atos validate..custompair, an unsuffixedfieldskey is refused first by the__cjudge, whose prescription already namesfieldPatches.Verification
Affected packages (head 435f30c)
pnpm --filter @objectstack/metadata-protocol test: Test Files 318 passed, 4 skipped; Tests 22466 passed, 26 skipped — exit 0pnpm --filter @objectstack/cloud-connection test: Test Files 70 passed; Tests 893 passed — exit 0pnpm --filter @objectstack/cli exec vitest run --project unit: Test Files 389 passed; Tests 5431 passed — exit 0pnpm --filter @objectstack/cli exec vitest run --project integration test/validate-extension-redeclared-owner-field.test.ts: 2 passed — exit 0 (the rest of the integration layer is declared to CI)pnpm --filter @objectstack/runtime exec vitest run src/domains/meta-object-extension-item.test.ts: 22 passed — exit 0Derived gates + lint (head 435f30c)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 64 families. All 64 ran with exit 0;--ranreconciliation: "64 derived famil(ies) accounted for — 64 run, 0 NOT-MEASURED".check-plugin-teardown-shape --self-test,check:dual-build-cjs-loadsandcheck:i18n-coverageexited 3 (prerequisites). Re-run after fetching the pinned commit and a whole-treeturbo run build(exit 0): all three exit 0.check:registry-log-declared,check:rest-log-spy-declared,check:route-envelope) were re-run on the restored tree: exit 0.node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD: exit 0.pnpm lint: exit 0.Dogfood battery (the `(narrowing)` arm)
Head
435f30c7, after the whole-tree build, under the lock:pnpm --filter @objectstack/dogfood test—VERDICT command-exit 0, Test Files 421 passed, 3 skipped (424); Tests 3513 passed, 36 skipped (3549); no failures.origin/mainmoved 10 commits since the branch point (f4d568ba); none touches a file this PR changes, andgit merge-treemerges clean.Generated by Claude Code