Repository navigation
Commit 3684d18
feat(spec): ActionSchema.preflight, a declared same-origin read shown in the param dialog before submit (#31859)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbFVf7GDTdiXTXLqC5MVJbvu)_
Fixes #31840
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #31860
## 维护者速读
- 改了什么:动作(action)新增可选键 `preflight`:参数对话框提交前先发一个同源
GET,把答复显示在参数上方,并可把答复里的值填进指定参数(只读、照原样提交)。同源规则从页面元素的接口读取里搬到一个共享模块,两边共用一套。
- 为什么改:云端安装/升级要在确认前先给用户看「这次会改什么」,并把确认令牌带进提交;现在动作没有任何声明方式。本 PR 只做 spec
一半,控制台在 #31808 里读它。
- 风险与回滚:纯新增,旧元数据解析结果不变;页面元素读取的接受集、提示文字与 JSON Schema 逐字节不变(差分 2208 个输入 0
差异)。回滚即 revert 本 PR。新键在活性账本里是 planned,控制台未读之前作者写了也看不到效果。
- 先看:`packages/spec/src/ui/action.zod.ts`(`preflight` 键与
`refusePreflightContradictions`
七类拒收)、`packages/spec/src/ui/same-origin-api-read.ts`(共享规则)、`packages/spec/src/ui/page.zod.ts`(只改为引用共享模块)。
- 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run
src/ui/action-preflight.test.ts
src/ui/page-element-api-data-source.test.ts`,预期全绿。
- 需要你做的:无,席位落地。
## What changes
- **`ActionSchema.preflight`** (`packages/spec/src/ui/action.zod.ts`):
`{ read: { url, method? }, path?, fields?, seed? }`, the shape the card
body declares. `fields` is built from the same row as
`resultDialog.fields` (`actionAnswerFieldRow` plus one shared format set
`ACTION_ANSWER_FIELD_FORMATS`), so the two cannot drift;
`resultDialog`'s JSON Schema and parse are unchanged (measured below).
- **Refused at parse, each at its own issue path:**
1. `read.url` not a same-origin API path (scheme, `//`, backslash, space
or control, relative), the class named; projects as `pattern`. A URL
opening with a hole gets its own sentence.
2. `read.method` other than `GET`.
3. A credential key (`headers`, `auth`, `authorization`, `token`,
`credentials`, `apiKey`), `body`, `params`, `title` or any unknown key,
with guidance.
4. A hole outside `${param.NAME}` / `${ctx.recordId}` /
`${ctx.record.FIELD}` (`${result.*}` named), an unterminated hole, or a
`${param.NAME}` naming no declared param.
5. `preflight` on an action with no non-empty `params`.
6. A `seed.param` naming no declared param, a param seeded twice, a
seeded param that declares `defaultValue` / `defaultFromRow` /
`carryOver`, a seeded param a hole reads.
7. `preflight` beside `execution: 'aggregate'` (the seat's ruling in the
Claim).
- **One shared same-origin module**
(`packages/spec/src/ui/same-origin-api-read.ts`, import-free,
package-internal): the URL regex, the class-naming refusal (subject
passed in), the response-path regex and the no-credentials text.
`page.zod.ts` imports it; the page element's accept set, messages and
published `pattern` are byte-identical.
- **Liveness:** `preflight` is `planned` in
`packages/spec/liveness/action.json`, consumer #31808, with its children
drilled (`check:liveness` requires it).
- **Form:** an `omit` row in `metadata-form-zod-reconciliation.test.ts`
on the `pressed` planned precedent; `action.form.ts` unchanged.
- **Docs:** a `preflight` section in
`content/docs/protocol/objectui/actions.mdx`, marked planned.
- **Regenerated:** `content/docs/references/**` (3),
`authorable-surface/ui.json`, `liveness/state-counts/action.md`,
`docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md`.
- **Changesets:** `minor` on `@objectstack/spec`; `patch` on
`@object-ui/core` for the one inventory line.
- **ui inventory:** `'preflight'` in `SPEC_ACTION_KEYS`
(`ui/packages/core/src/actions/actionKeys.ts`); `ActionDef`, the runner
and the console are untouched.
## Tests
Head `5e02b708c` (branch merged with `origin/main` `31ae944b4`; no
`packages/spec` change came in, so the spec build and readings below
stand).
- `packages/spec/src/ui/action-preflight.test.ts` (new, 57 cases): the
cloud-shaped example parses and is kept as written; the closed hole set
and a `field`-named param are admitted; refusals 1 to 7, each asserted
on code + issue path and on the slot or class the message names; the
published `pattern`; an inline action does not pick the key.
- `packages/spec/src/ui/page-element-api-data-source.test.ts` (one new
top-level `describe`): the page element's five class messages, the
`path` and `method` refusals and the credential guidance, whole, as they
read before the move, and the published `pattern` source.
- `packages/spec/src/system/metadata-form-zod-reconciliation.test.ts`:
the `omit` row for `action.preflight`.
- `ui/packages/core/src/actions/actionKeys.ts`: `'preflight'` in
`SPEC_ACTION_KEYS` (Claim amend 2), so the inventory pin stays green.
<details><summary>Readings</summary>
- `pnpm --filter @objectstack/spec exec vitest run --project local
--maxWorkers=2` (under the verify lock): Test Files 828 passed (828),
Tests 26192 passed, 1 todo. VERDICT command-exit 0.
- `pnpm --filter @objectstack/spec exec vitest run
src/ui/action-preflight.test.ts
src/ui/page-element-api-data-source.test.ts`: 2 files, 123 tests passed.
- spec `repo` project, the 13 files naming liveness, action, page or
form: 13 passed, 308 tests.
- Consumer `@objectstack/lint`: `vitest run`, Test Files 197 passed,
Tests 8365 passed.
- Consumer `@object-ui/core`: `vitest run packages/core/src/actions/`
from `ui/`, Test Files 55 passed, Tests 755 passed. Before the inventory
line: `actionKeys.pin.test.ts` failed with `missing: ['preflight']` (1
failed / 18 passed).
- **Page element byte-identity, differential** (scratch, not committed):
`page.zod.ts` at `cc16008a` copied beside the new one,
`ElementApiDataSourceSchema.safeParse` compared on 2208 inputs (23 URLs
including non-strings, 8 read shapes, 4 paths, 3 top-level extras): **0
differences**; `z.toJSONSchema` equal.
- **`resultDialog` unchanged, differential**: `ActionSchema` at
`cc16008a` vs now, input JSON Schema: `resultDialog` equal, the only
added property is `preflight`, no other property changed; a
`resultDialog` fixture with an alias and a bad format parses to the same
result.
- **Ablation** (`node scripts/ablation-replace.mjs`, the anchor
`.superRefine(refusePreflightContradictions)` 1 to 0):
`action-preflight.test.ts` 18 failed / 39 passed; restored to the HEAD
blob `c028a358ec5a`.
</details>
## Acceptance notes
- **PM premise measured, partly disproven:** the runner's hole parser
(`substituteScopeTokens`,
`ui/packages/core/src/actions/ActionRunner.ts`) is module-private in
`@object-ui/core`, and `@objectstack/spec` has no workspace
dependencies, so the spec cannot import it. The spec declares the closed
set itself, spelled to the runner's `${SCOPE.PATH}` token (`PATH`
`[\w.]+`), in `preflightHoleParam`. No second spec-side parser existed
before (searched `packages/spec/src` for a hole regex: none).
- **New exports: none.** The shared module is not re-exported from the
`ui` barrel and the preflight schema is inline in `ActionSchema`, so
`check:api-surface` does not move. The console half re-judges stored
metadata with `ActionSchema`, not with the regex.
- `fields[].path` keeps `resultDialog.fields`' unconstrained `path`
string (the row is reused as is); `preflight.path` and `seed[].path` use
the dotted response-path regex.
## Verification
<details><summary>Derived gates (dispatch-gates --commands, 112
families)</summary>
- 111 run, exit 0. `check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT
MET), left to CI (`dispatch-gates --ran`: 112 derived, 111 run, 1
NOT-MEASURED, 0 UNRUN).
- `check:doc-formula-expressions`, `check:doc-security-posture` and
`check:skill-examples` first answered exit 3 (unbuilt
`@objectstack/formula` / `lint` / `client-react`); after `turbo run
build --filter=@objectstack/lint --filter=@objectstack/client-react` (43
tasks) all three exit 0.
- `pnpm --filter @objectstack/spec check:generated`: all 14 generated
artefacts up to date, after `gen:docs`, `gen:strictness-ledger` and
`gen:liveness-counts`; `check:api-surface` green with no regeneration
(no new export).
- `check:liveness` required drilling `preflight`'s children (all
`planned`) rather than a baseline row.
</details>
Deviations from the Claim's first surface, both ruled by the seat:
`docs/audits/2026-07-unknown-key-strictness-ledger.counts/ui.md` (pure
`gen:strictness-ledger` regeneration, amend 1) and
`ui/packages/core/src/actions/actionKeys.ts` with its `patch` changeset
`.changeset/31840-action-keys-preflight.md` on the precedent of the
`pressed` spec PR (amend 2).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jRzeonr7DwHQMQLRRu)_
<!-- signed: domain:spec#2 · zhuangjianguo ·
session_01QsR2jUe9c6YdtNkrzUnMUd -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ef4af73 commit 3684d18
19 files changed
Lines changed: 1015 additions & 117 deletions
File tree
- .changeset
- content/docs
- protocol/objectui
- references
- data
- kernel
- ui
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- metadata-protocol/src
- spec
- authorable-surface
- liveness
- state-counts
- scripts
- src
- system
- ui
- ui/packages/core/src/actions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| |||
562 | 563 | | |
563 | 564 | | |
564 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
565 | 599 | | |
566 | 600 | | |
567 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
507 | 508 | | |
508 | 509 | | |
509 | 510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
170 | 180 | | |
171 | 181 | | |
172 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| |||
265 | 270 | | |
266 | 271 | | |
267 | 272 | | |
268 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
269 | 276 | | |
270 | 277 | | |
271 | | - | |
| 278 | + | |
272 | 279 | | |
273 | 280 | | |
274 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
0 commit comments