Repository navigation
Commit f129848
fix(metadata-protocol): a form view's unknown field or group is answered on save and publish, and the group finding reaches the read (#29389)
domain:server#2 · os-steve · session_01ADHkmQxwoGb5fSnrFkpxmt
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9VuKSPKLCdyPe1HVgMCJrsr)_
Fixes #29309
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:表单视图写了对象上不存在的字段或字段分组时,直接保存(非草稿)和发布的应答现在在 `advisories` 里带上 lint
原文警告(`form-field-unknown` / `form-section-group-unknown`);读取的
`_diagnostics.warnings` 也补上了分组那一条。
- 为什么改:MCP / AI 作者只看保存与发布的应答,以前这两处一声不吭,只有之后再读一次才知道字段或整个分区被静默跳过。
- 风险与回滚:只加警告,不拒绝任何保存或发布,`valid` 不变;草稿保存照旧不跑规则。规则现在也读 Studio
存的表单项(`viewKind: 'form'`,分区在 `config` 下),所以 `os validate` / `os build` /
`os lint` 对这类表单也会多出同样的警告。回滚即还原本 PR,无数据迁移。
- 先看:`packages/lint/src/validate-form-layout.ts`(表单项 `config`
这一级的遍历),`packages/lint/src/authoring-rules.ts`(`validateFormLayout`
登记项改为 `runtimeTypes:
['view']`),`packages/metadata-protocol/src/metadata-diagnostics.ts`(读取放行两条规则),`packages/metadata-protocol/src/protocol.form-layout-diagnostics.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.form-layout-diagnostics.test.ts`,预期 10 个用例全绿;在 main 上新增的用例
4 个红(对照组绿)。
- 需要你做的:无,席位落地。
## What changes
- **Save and publish answers** (`packages/lint/src/authoring-rules.ts`):
the `validateFormLayout` registration moves from `CLI_ONLY` +
`RUNTIME_NEEDS_FULL_SNAPSHOT` to `CLI_AND_RUNTIME` + `runtimeTypes:
['view']`.
- **The form item rung** (`packages/lint/src/validate-form-layout.ts`,
the view walk only, per claim amendment 6579089637): the rule also walks
a `viewKind: 'form'` item's `config` sections, the shape Studio saves
(`{ name, object, viewKind: 'form', config }`), binding
`config.data.object` first and the item's `object` otherwise. Rule ids,
messages, hints and severity are unchanged. A list item's `config` is
not walked. The rung lives in this rule, not in the shared
`view-walk.ts`, so the other walkers' verdicts do not move. The CLI
commands see the same rung, so a stack carrying a form item is judged
there too. The rule is advisory, so an active save and a publish of a
view whose form names an unknown field or an undeclared field group land
as before and answer both findings in `advisories` (rule id, message,
hint, `severity: 'warning'`).
- **The read**
(`packages/metadata-protocol/src/metadata-diagnostics.ts`):
`withFormLayoutWarnings` lets `form-section-group-unknown` through
beside `form-field-unknown`, with the lint's own message (one spelling).
Its own `config` adapter (`formLayoutSubject`, from #29196) is retired:
the rule now reads the served item as it is, the same walk the gate
runs, and the read's paths (`config.sections.0.fields.1`) are unchanged.
### The measurement the card asked for (the snapshot at the real doors)
Read and then measured on a real showcase boot (`pnpm dev --fresh`, this
branch's build):
| door | runs the registry? | objects in the snapshot | result |
|---|---|---|---|
| `PUT /meta/view/X` (active save) | yes |
`registry.listItems('object')` = `getAllObjects` → `resolveObject`
(overlay + every extender folded, the shape `getObject` serves), plus
stored rows folded by `foldStoredCollection` | container form naming
`loyalty_tier` (a `showcase_account` extension field), `no_such_field`
and group `no_such_group`: two advisories, the extension field not
reported |
| `POST /meta/view/X/publish` | yes | same | `no_such_field` answered as
a warning, publish not refused |
| `PUT /meta/view/X?mode=draft` | no (#4463 D1: no rule gates a draft) |
none handed to any rule | no advisory, by contract; the draft read
carries the warnings (#29196) |
| runtime-authored object (stored row only) | yes | stored half | form
on it: its real fields known, `nope_field` reported |
| control | yes | same | form naming `name` + `loyalty_tier`: no
advisory |
| Studio form item, before the rung | yes | same | `PUT
/meta/view/showcase_account.probe_e` (`viewKind: 'form'`,
`no_such_field` under `config`): no advisory, the read warned. This is
what the rung closes; pinned below. |
So the objects are present, extensions and stored rows included, on both
doors that run rules. No door hands the rule a snapshot without them.
### No double report on the read
The read carries no runtime advisory: the draft read folds the publish
verdict's refusals only (`withPublishVerdict`), and these findings are
never refusals. Pinned: the active read after an active save carries
each finding once.
## Tests
`packages/metadata-protocol/src/protocol.form-layout-diagnostics.test.ts`
(the #29196 file and harness, no new engine double), four new cases:
1. a section naming an undeclared field group reads with the lint
warning, draft and active (half 2);
2. an active save naming an unknown field and an unknown group answers
both as warnings with the lint's rule/message/hint, and the active read
carries each once (half 1);
3. a draft save carries no advisory (D1), and its publish answers
`form-field-unknown` as a warning and is not refused (half 1);
4. control: real fields (an extension field among them) and a declared
group answer no advisory and read `{ valid: true }`;
5. a Studio form item naming an unknown field: an active save and a
publish answer it as a warning, and its read carries it once at
`config.sections.0.fields.1`;
6. control: a form item naming only real fields (an extension field
among them) answers no advisory.
`packages/lint/src/validate-form-layout.test.ts`, four new cases: a form
item's unknown field and undeclared group, found at `views[0].config…`
with `where` `· config`; the config's own `data.object` binding wins
over the item's `object`; control: real fields and a declared group are
clean; control: a list item's `config` is not walked.
Red first: cases 1-3 red on `origin/main` `57cde8cb` (control green);
after the round-1 fix, case 5 and the two lint finding cases red on
`9226d33b` (both controls green).
**Forced test edits**, named:
- `protocol.form-layout-diagnostics.test.ts`: the stub registry's
`listItems('object')` now lists the served (merged) object rather than
the authored one. Both real registry reads go through `resolveObject`;
the old stub answered a shape no registry answers and would have
invented a phantom on the extension field. The fixture object also
declares one `fieldGroups` entry.
- `runtime-gate.test.ts` (three lists), `authoring-rule-wiring.test.ts`
(one), `runtime-gate.page-visibility-predicate-writes.test.ts` (one):
the `view` write's rule list gains `validateFormLayout` after
`validateReferenceIntegrity`.
## Acceptance notes
- Advisory paths at the gate are stack-shaped
(`views[0].formViews.edit.sections[0].fields[2]`,
`views[0].config.sections[0].fields[1]`), as every runtime-gate advisory
is; the read's warnings stay item-relative.
- A `?mode=draft` save runs no registry rule (#4463 D1), so it answers
no form-layout advisory; its read and its publish do. Left as it is by
the seat.
- An object outside the write's package closure is not in the snapshot;
both checks skip an unknown object, so such a form is not judged rather
than misjudged.
- Cost: no new read. The rule walks the objects the gate already
gathers; the view read path loses an adapter and gains nothing.
## Verification
Head: `6266ec85` (merge of `origin/main` `7f277a86` into the rung commit
`eb7ddbb4`). All runs below on `6266ec85` unless marked.
- Round 1 red first on `origin/main` `57cde8cb`: `Tests 3 failed | 5
passed (8)` (cases 1-3; control green).
- Round 2 red first on `9226d33b` (new pins, rule unchanged):
`validate-form-layout.test.ts` `Tests 2 failed | 34 passed (36)`,
`protocol.form-layout-diagnostics.test.ts` `Tests 1 failed | 9 passed
(10)` (case 5; both controls green).
- Green on `eb7ddbb4`: `36 passed (36)`, `10 passed (10)`.
- Ablation 1 (registration back to `CLI_ONLY`, lint rebuilt, preflight
marker in 4 built files): cases 2 and 3 red; restored, preflight
`--absent` exit 0.
- Ablation 2 (read filter back to `form-field-unknown` only): cases 1
and 2 red; restored.
- Ablation 3 (the `config` rung removed, lint rebuilt, preflight marker
in 4 built files): lint `2 failed | 34 passed`; door `3 failed | 7
passed` (the #29196 read pin, case 1 and case 5: the read has no adapter
now, so it depends on the rung too); restored, `git diff HEAD` empty,
rebuilt, preflight `--absent` exit 0.
- Real showcase boot measurements: see the table above.
<details><summary>Package suites and typecheck (head 6266ec8, under the
verify lock)</summary>
- `turbo run build --filter='./packages/**'` exit 0; `pnpm --filter
@objectstack/spec check:generated` exit 0
- `pnpm --filter @objectstack/lint test` → exit 0, `Test Files 189
passed (189)`, `Tests 7834 passed (7834)`
- `pnpm --filter @objectstack/lint typecheck` → exit 0
- `pnpm --filter @objectstack/metadata-protocol test` → exit 0, `Test
Files 304 passed | 4 skipped (308)`, `Tests 22161 passed | 26 skipped
(22187)`
- `pnpm --filter @objectstack/metadata-protocol typecheck` → exit 0
</details>
<details><summary>Derived gates: 61 derived, 61 run, 0 NOT-MEASURED, 0
UNRUN (dispatch-gates --ran, head 6266ec8)</summary>
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:docs-transcript-drift :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-code-casing :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:pm-changeset-deadline-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
Package lint: root eslint `--no-inline-config` on `packages/lint` and
`packages/metadata-protocol` → exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQ25mz3PUm6CpePgB3)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4138ce8 commit f129848
9 files changed
Lines changed: 328 additions & 37 deletions
File tree
- .changeset
- packages
- lint/src
- metadata-protocol/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
514 | 516 | | |
515 | 517 | | |
516 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1606 | 1606 | | |
1607 | 1607 | | |
1608 | 1608 | | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1609 | 1623 | | |
1610 | 1624 | | |
1611 | 1625 | | |
1612 | 1626 | | |
1613 | 1627 | | |
1614 | 1628 | | |
1615 | | - | |
1616 | | - | |
| 1629 | + | |
| 1630 | + | |
1617 | 1631 | | |
1618 | 1632 | | |
1619 | 1633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
342 | 345 | | |
343 | 346 | | |
344 | 347 | | |
| |||
545 | 548 | | |
546 | 549 | | |
547 | 550 | | |
| 551 | + | |
548 | 552 | | |
549 | 553 | | |
550 | 554 | | |
| |||
642 | 646 | | |
643 | 647 | | |
644 | 648 | | |
| 649 | + | |
645 | 650 | | |
646 | 651 | | |
647 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
615 | 661 | | |
616 | 662 | | |
617 | 663 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
168 | 183 | | |
169 | 184 | | |
170 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
440 | 441 | | |
441 | 442 | | |
442 | 443 | | |
443 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
444 | 455 | | |
445 | 456 | | |
446 | 457 | | |
| |||
458 | 469 | | |
459 | 470 | | |
460 | 471 | | |
461 | | - | |
| 472 | + | |
462 | 473 | | |
463 | 474 | | |
464 | | - | |
| 475 | + | |
| 476 | + | |
465 | 477 | | |
466 | 478 | | |
467 | 479 | | |
468 | 480 | | |
469 | 481 | | |
470 | 482 | | |
471 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
472 | 487 | | |
473 | 488 | | |
474 | 489 | | |
| |||
480 | 495 | | |
481 | 496 | | |
482 | 497 | | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
| 513 | + | |
| 514 | + | |
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
528 | 530 | | |
529 | | - | |
| 531 | + | |
530 | 532 | | |
531 | 533 | | |
532 | 534 | | |
533 | 535 | | |
534 | 536 | | |
535 | | - | |
536 | | - | |
| 537 | + | |
| 538 | + | |
537 | 539 | | |
538 | | - | |
| 540 | + | |
539 | 541 | | |
540 | 542 | | |
541 | 543 | | |
| |||
0 commit comments