Skip to content

Commit 743308b

Browse files
fix(lint, runtime)!: an action body that cannot compile in its (input, ctx) wrapper is refused at validate, build and publish, and at run time answers naming itself (#34980)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufziunkXbDT7wUWqfmWz Fixes #34884 Clause-②: no (narrowing) — an L2 action body (`type: 'script'`, `body.language: 'js'`) that does not compile as the body of `(async (input, ctx) => { … })` passed `os validate`, `os build`, `os lint`, `os verify` and the runtime publish door; it is now refused there as `action-body-does-not-compile` at `error` (on the publish door for `action` writes and for `object` writes carrying inline `actions[]`). One arm advises instead of refusing: a regular-expression literal the host engine refuses is a `warning`. Such a body never ran: every run failed with a SyntaxError before its first statement. `@objectstack/lint` also gains exports (`validateActionBodyCompiles`, `hostCompileFailure`, `ACTION_BODY_DOES_NOT_COMPILE`, `ACTION_BODY_PARAMETERS`, `actionBodyFunctionExpression` and two finding types on `.`, `actionBodyFunctionExpression` on `./runtime`). Metadata-protocol: narrowed Skills-docs: follow-up owed — skills/objectstack-data/references/data-hooks.md (it teaches the action wrap `(async (input, ctx) => { … })` without saying a body must not declare `input` / `ctx` again); follow-up #34988 (blocked on #34504, which holds that file); this PR teaches it in `content/docs/ui/actions.mdx` and `content/docs/automation/hook-bodies.mdx`. ## 维护者速读 - 改了什么:脚本动作的 `body.source` 如果在运行时的包装 `(async (input, ctx) => { … })` 里编译不过(最常见是 `const input = ctx.input || {}` 重复声明参数),现在 `os validate` / `os build` / `os lint` / 发布保存(动作写入和对象写入)都会报错拒绝,点名动作、编译错误和行号;运行时若仍遇到这种动作,REST `/actions` 与 MCP `run_action` 回答 `500 INTERNAL_ERROR`,消息点名动作和编译错误,不再是光秃秃的 "Internal server error"。 - 为什么改:这种动作以前四道门全过,部署后每次运行都失败,调用方(尤其 AI)只看到不透明的 500,只好绕开去直接写数据,把状态弄错。 - 风险与回滚:新拒绝的只有本来就永远跑不起来的动作体;检查用宿主 JS 引擎(Node 的 V8)编译、不执行,与运行时 QuickJS 唯一实测分歧在正则字面量,那一支只给警告不拒绝。四个示例应用实测 0 处命中,全量 dogfood 绿。回滚即 revert。 - 先看:`packages/lint/src/validate-action-body-compiles.ts`(编译方式与正则分支);`packages/runtime/src/sandbox/quickjs-runner.ts`(`actionBodyCompileFailure` 与包装改用共享函数);`packages/lint/src/authoring-rules.ts`(注册:门禁级、发布门 `action` + `object`)。;`packages/spec/src/migrations/entries/semantic/18.action-body-does-not-compile-refused.ts`(ADR-0087 语义迁移条目,升级指南与 `os migrate meta` 读它)。 - 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run src/validate-action-body-compiles.test.ts`,预期 14 条全过,其中含卡里那句原样的动作体被拒。 - 需要你做的:无,席位落地(收窄需一次契约级审查,由席位安排)。 ## What changes - **Author time (`@objectstack/lint`)** — new gating rule `action-body-does-not-compile` (`validate-action-body-compiles.ts`). It compiles each L2 action body inside `actionBodyFunctionExpression(source)`, the wrapper the runtime builds, from the same function, with the host engine, as a script, never running it (`node:vm` `Script`; the `Function` constructor where `node:vm` is absent; no verdict where the host refuses to compile at all). The finding names the action, the compiler's sentence and the line of `body.source`; a redeclared wrapper parameter gets a hint naming it. Registered in `authoring-rules.ts` as `gating` on all three commands and on the runtime publish door for `action` and `object` writes; `os explain action-body-does-not-compile` added; barrel exports added. The object door's roster pin in `runtime-gate.object-writes.test.ts` names the join. - **The shared wrapper** — `packages/lint/src/action-body-wrapper.ts` holds the one spelling, `(async (input, ctx) => { SOURCE })`. `quickjs-runner.ts` now builds its action wrapper from it through `@objectstack/lint/runtime` (the runtime already depends on that entry); the wrapper text is byte-identical to before. - **Run time (`@objectstack/runtime`)** — when evaluating an action's wrapper fails with a `SyntaxError` (a compile failure: an async body cannot throw synchronously, so anything the body itself throws crosses `__error` instead), the runner throws a `SandboxError` with `status: 500`, no code, the operator line `action 'NAME' does not compile: SyntaxError: …` and the caller sentence `Action 'NAME' cannot run: its body does not compile (SyntaxError: …). The action's author must fix its body.source and publish it again.` The doors answer the status's own `INTERNAL_ERROR` and relay that sentence. A crash while running (a `TypeError`, a `SyntaxError` thrown by `JSON.parse`) keeps the sanitised 500. Hook and job bodies are unchanged. - **Protocol (`@objectstack/spec`)** — the ADR-0087 semantic entry `packages/spec/src/migrations/entries/semantic/18.action-body-does-not-compile-refused.ts` (`action-body-does-not-compile-refused`: surface, replacement, reason, acceptance criteria) registers the narrowing for the upgrade guide and `os migrate meta`; the generated registry picks it up, no other spec file changes. The changeset declares `Metadata-protocol: narrowed`, carries `adr-0087: registered action-body-does-not-compile-refused`, and grades `@objectstack/lint` and `@objectstack/spec` `minor`, `@objectstack/runtime` `patch`. - **Docs** — `content/docs/automation/hook-bodies.mdx` and `content/docs/ui/actions.mdx` teach the rule; `content/docs/api/error-catalog.mdx` gains the Action Errors row; the author-time rule count the CLI prints goes 70 to 71 in the four transcript pages. `content/docs/deployment/validating-metadata.mdx` gains the rule's row in the four-doors table (`✓ ✓ ✓ ✓ᵃᶜᵒ`: the three commands, and the publish door for `action` and `object` writes). ## Tests - `packages/lint/src/validate-action-body-compiles.test.ts` (14): the card's body byte for byte refused (`error`, path, `'input'`, line 1, parameter hint); the same source compiling in the parse check's own wrapper (why no check saw it); `let ctx` on line 3; an unparseable body; `new.target`; four bodies that compile (`var input`, reading `input`, …) admitted; the regex arm at `warning`; a body that closes the wrapper early compiles and never executes; both registration sites, merged action once, non-script and non-js skipped; `validate` / `build` / `lint` each refuse; the `action` and `object` publish doors refuse and admit; an unrelated write is not charged with a stored bad body. - `packages/runtime/src/sandbox/sandboxed-action-crash-is-a-fault.test.ts`, new top-level describe (3): the real runner on the card's body (message, `status: 500`, no code, sentence); the real `/actions` door answers `500 INTERNAL_ERROR` with the sentence, not `Internal server error`; control: a runtime `SyntaxError` stays a sanitised crash. - `packages/core/src/utils/import-runner-sandbox-fault-row.test.ts` (round 2): the census that renders every `SandboxError` construction in `quickjs-runner.ts` gains crash samples for the new site's two interpolations, `actionName` and `compilerError`; the census is not loosened, and the new site becomes one more §2 case (the door withholds a sandbox fault's text, the import row reads the door's sentence). Red before on `bc80b37795` (`quickjs-runner.ts:2407 (relayed): no sample for the interpolation actionName`, 1 failed, 44 passed), green after (46 passed). <details><summary>Live measurement before and after (scratch app, CLI built from this tree)</summary> Before (origin/main fff0ad0), action body `const input = ctx.input || {}; return 1;`: - `os validate` exit 0, `os build` exit 0, `os verify` exit 0 ("verify passed — no runtime failures"). - REST `POST /api/v1/actions/OBJ/ACTION/ID`: `500 {"code":"INTERNAL_ERROR","message":"Internal server error"}`. - MCP `run_action`: `{"error":{"code":"INTERNAL_ERROR","message":"Internal server error","status":500}}`. - `PUT /api/v1/meta/action/NAME` with that body: `200` saved active. - Server log: `ERROR [BodyRunner] sandboxed action threw … action 'rpc_decide' threw: SyntaxError: invalid redefinition of parameter name`, then `sandboxed body crashed: …`. - First door that could see the error and did not: `os validate` (every author-time door shares the registry). After (this branch, the pre-fix artifact booted with `-a` to stand for a body deployed before the rule): - `os validate` / `os build` / `os verify` exit 1, `action-body-does-not-compile` at `actions[0].body.source` ("SyntaxError: Identifier 'input' has already been declared, line 1"). - REST and MCP: `500 INTERNAL_ERROR`, message `Action 'rpc_decide' cannot run: its body does not compile (SyntaxError: invalid redefinition of parameter name). The action's author must fix its body.source and publish it again.` - `PUT /api/v1/meta/action/NAME`: `422 INVALID_METADATA` with the rule's issue; a body using `const params = ctx.input || {}` saves `200`. - Server log: `action 'rpc_decide' does not compile: SyntaxError: invalid redefinition of parameter name`. - Control action `return { ok: true }`: `200` both times. </details> <details><summary>Engine probe (36 bodies, Node 22 V8 vs the runtime's QuickJS)</summary> Agreed on every redeclaration, grammar error, strict-mode error, `super` and `new.target` (with the wrapper compiled as a script). Disagreed once: `/(?<a>x)|(?<a>y)/` (duplicate named groups) is refused by Node 22's V8 and accepted by QuickJS, hence the regex `warning` arm. </details> <details><summary>Ablations (each restored to blob == HEAD, `git diff HEAD` empty)</summary> - `validate-action-body-compiles.ts`: `if (!failure) continue;` → `if (!failure || site) continue;` via `scripts/ablation-replace.mjs` (anchor 1 → 0, blob 9e2fd44 → 1f242fac955b): 9 of 14 red; restored 9e2fd44. - `quickjs-runner.ts`: the compile-failure branch disabled (`&& !err`, anchor 1 → 0, blob 571aa67 → a06de24caa83): the 2 compile-failure pins red, the control and the 3 earlier cases green; restored 571aa67. - Both test files import the code under test from `src/` (relative), so no dist rebuild sits between the mutation and the run. </details> ## Acceptance notes - **Metadata-protocol: narrowed** (seat ruling 21:04Z on the round-1 question, option B; claim amendment on #34884): the semantic entry above, in the precedent's shape (`.changeset/34378-lookup-filter-record-path-multi-valued.md`, `.changeset/33435-injected-column-null-guard-at-build.md`): BREAKING scope, FROM → TO, Fix, measured first-party exposure (zero). - **The object publish door runs the rule too** (`runtimeTypes: ['action', 'object']`, kept by the seat's ruling): an object write carries inline `actions[]`, the second place a body is published, so an object write cannot republish a refused body inline. The publish gate charges a write with every non-compiling inline body the written object carries, changed or not (only another entry's findings cancel), so an object publish is refused while it still carries such a body, a body stored before this rule included; a write of another object is not charged with it (pinned). This is the surface the semantic entry declares. The registration comment in `authoring-rules.ts` still says "only the bodies it adds"; that sentence is left for a later touch of the file (seat contract review 6964237524, N1). - Hook and job bodies (`(async (ctx) => { … })`) are not judged and their run-time answer is unchanged (seat ruling: they stay out of this PR; follow-up #34987). - No user-text catalog (`*.user-text.ts`) is authored for the new rule: the publish door renders its `message`. - Text conflict with open PR #34791 on the four rule-count transcript lines (both bump 70 to 71); whichever lands second re-bumps. No overlap with #34719's lines (`overlap-check`: merges cleanly). ## Verification Head `15faf1da07` (round 2: `origin/main` merged twice, the spec entry, the changeset rewrite, the docs row, the core census samples). Local readings (CI runs the full farm): <details><summary>Round 2 — spec, core census, docs</summary> - `pnpm --filter @objectstack/spec gen:migration-registry` then `vitest run src/migrations`: 5 files, 198 passed (the generated registry carries `action-body-does-not-compile-refused` once). - `pnpm --filter @objectstack/spec run check:generated` exit 0 (14 generated artifacts up to date); `check:adr-0087-registration --base origin/main` exit 0 (`registered action-body-does-not-compile-refused (new here)`); `check:changeset-no-major` exit 0; `check:issue-citations` exit 0. - `pnpm --filter @objectstack/core exec vitest run --project repo src/utils/import-runner-sandbox-fault-row.test.ts`: before the samples (on `bc80b37795`) VERDICT command-exit 1, 1 failed / 44 passed, the census naming `quickjs-runner.ts:2407 (relayed): no sample for the interpolation actionName`; after, VERDICT command-exit 0, 46 passed. `pnpm --filter @objectstack/core run test:repo`: 8 files, 106 passed. The other tests that read `quickjs-runner.ts` from disk or pin its arms: `packages/rest` `error-response-sandbox-arm-message`, `rest-sandbox-declared-status`, `rest-hook-script-fault-envelope` (3 files, 120 passed); `packages/core` `import-runner-sandbox-refusal-row` (23 passed). - `check:doc-authoring`, `check:docs-transcript-drift` (4 transcript values), `check:doc-anchors` exit 0 after the `validating-metadata.mdx` row. </details> <details><summary>Round 1 — package tests and typecheck (at `f34867b93d`; round 2 changed no lint or runtime source)</summary> - `pnpm --filter @objectstack/lint typecheck` exit 0; `pnpm --filter @objectstack/lint exec vitest run`: 218 files, 9200 tests, 2 red in `runtime-gate.object-writes.test.ts` (the object roster pins), fixed in this PR; re-run of that file and the new file: 69 passed. - `pnpm --filter @objectstack/runtime typecheck` exit 0; `vitest run src/sandbox`: 47 files, 497 passed; the edited pin file: 6 passed. - `packages/metadata-protocol` runtime-authoring-gate files: 13 files, 320 passed. - Ablations as listed under Tests (round 2 adds a registry entry, a changeset, a docs row and test samples: no tested behaviour changed, so no new ablation). </details> <details><summary>Dogfood battery (owed by the narrowing arm) — on the final head</summary> At `15faf1da07`: packages and examples built under the lock (exit 0), `pnpm --filter @objectstack/dogfood test`: VERDICT command-exit 0, Test Files 479 passed | 3 skipped (482), Tests 4072 passed | 68 skipped (4140). (Also green at `bc80b37795` with the same counts.) </details> <details><summary>Derived gates (`dispatch-gates --commands` at the final head, 118 commands)</summary> All 118 exit 0 at `15faf1da07`, after the full build, including `check:type-check-debt` (0 ledger entries above their measurement), `check:dts-closure`, `check:dual-build-cjs-loads`, `check:test-source-alias`, the spec projections (`check:spec-changes`, `check:upgrade-guide`, `check:api-surface`, `check:authorable-surface`) and `check:kernel-hook-pairs`. `dispatch-gates --ran` with each exit code recorded: 118 derived, 118 run, 0 NOT-MEASURED, 0 UNRUN (a derived zero). `overlap-check`: `origin/main` merges cleanly; text conflict with #34791 only, on the rule-count transcript lines and the `validating-metadata.mdx` table (left for whichever lands second). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufziunkXbDT7wUWqfmWz --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 367e324 commit 743308b

20 files changed

Lines changed: 605 additions & 6 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/lint': minor
3+
'@objectstack/spec': minor
4+
'@objectstack/runtime': patch
5+
---
6+
7+
fix(lint, runtime)!: an action body that cannot compile in its `(async (input, ctx) => { … })` wrapper is refused at validate, build and publish, and at run time answers naming the action and the compile error
8+
9+
Clause-②: no (narrowing) — an L2 action body (`type: 'script'`, `body.language: 'js'`) that does not compile as the body of `(async (input, ctx) => { … })` passed `os validate`, `os build`, `os lint`, `os verify` and the runtime publish door (`action` and `object` writes); it is now refused there as `action-body-does-not-compile` at `error`, except a regular-expression literal the host engine refuses, which is a `warning`. Such a body never ran: every run failed with a SyntaxError before its first statement. `@objectstack/lint` also gains the exports `validateActionBodyCompiles`, `hostCompileFailure`, `ACTION_BODY_DOES_NOT_COMPILE`, `ACTION_BODY_PARAMETERS`, `actionBodyFunctionExpression` and two finding types on `.`, and `actionBodyFunctionExpression` on `./runtime`.
10+
Metadata-protocol: narrowed
11+
Skills-docs: follow-up owed — `skills/objectstack-data/references/data-hooks.md` teaches the action wrap `(async (input, ctx) => { … })` without saying a body must not declare `input` / `ctx` again; this change teaches it in `content/docs/ui/actions.mdx` and `content/docs/automation/hook-bodies.mdx`.
12+
13+
<!-- adr-0087: registered action-body-does-not-compile-refused -->
14+
15+
**BREAKING** only for an action body that never ran. The runtime compiles an L2 action's `body.source` as the statements of `(async (input, ctx) => { SOURCE })`, so a body that declares a wrapper parameter again (`const input = ctx.input || {}`, `let ctx = …`), or fails to compile there for any other reason, raises a SyntaxError before its first statement. Every authoring door accepted it: the parse check (`action-body-source-unparseable`) reads the source inside a different wrapper, and a parser reports no redeclaration. It deployed clean, and then every run of the action answered `500 INTERNAL_ERROR "Internal server error"` on the `/actions` door and MCP `run_action`. `action-body-does-not-compile` now refuses it at `os validate`, `os build`, `os lint` and the runtime publish door (`422 INVALID_METADATA`), naming the action, the compile error and its line of `body.source`. The publish door runs the rule on `object` writes too, so an object write cannot republish a refused body inline in `actions[]`. Hook and job bodies (`(async (ctx) => { … })`) are not judged. Measured first-party exposure: zero — `os validate` over the example apps reports no finding, and no skill or docs sample carries an action body that redeclares `input` or `ctx`.
16+
17+
**FROM → TO.** FROM `body: { language: 'js', source: 'const input = ctx.input || {}; return input.amount;' }` (accepted at every door, failing every run) TO `source: 'const params = ctx.input || {}; return params.amount;'` (or `return input.amount;`).
18+
19+
**Fix:** read the params as `input` (they are also `ctx.input`), or give the local another name (`const params = ctx.input || {}`); `var input = …` compiles. Fix any other compile error the finding names at the line it names. The semantic entry `action-body-does-not-compile-refused` carries the same notice into the upgrade guide and `os migrate meta`. `os explain action-body-does-not-compile` says what the rule judges and where the host's engine and the runtime's QuickJS differ.
20+
21+
The rule compiles the body inside the expression the runtime builds, from the same function (`actionBodyFunctionExpression`, which the QuickJS runner now builds its wrapper from, byte for byte as before), with the host's JavaScript engine and without running it.
22+
23+
At run time, an action whose body still does not compile (one deployed before this release, or syntax the host engine accepts and QuickJS does not) answers `500 INTERNAL_ERROR` on the `/actions` door and MCP `run_action` with the sentence `Action 'NAME' cannot run: its body does not compile (SyntaxError: …). The action's author must fix its body.source and publish it again.`, where it answered `500 INTERNAL_ERROR "Internal server error"`. The server log line reads `action 'NAME' does not compile: SyntaxError: …`. A body that crashes while running (a `TypeError`, a `SyntaxError` thrown by `JSON.parse`) still answers the sanitised `500`.

‎content/docs/api/error-catalog.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ value directly (single wrap).
709709
| Type has no server dispatch (`url`/`modal`/`form`/`api`), or a param-contract violation | **400** | `{ success: false, error: { message, code } }` |
710710
| Data engine or automation service unavailable | **503** | `{ success: false, error: { message, code } }` |
711711
| Handler **crashed** (`TypeError`, driver error, sandbox timeout) | **500** | `{ success: false, error: { message, code } }` |
712+
| Sandboxed body **does not compile** in its `(async (input, ctx) => { … })` wrapper | **500** | `{ success: false, error: { message, code: 'INTERNAL_ERROR' } }` — `message` names the action and the compile error |
712713

713714
A rejection and a crash are told apart by the thrown error: a plain
714715
`throw new Error(msg)`, a sandboxed body's deliberate throw, or a

‎content/docs/automation/hook-bodies.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Static validation around a hook is asymmetric, and it is worth knowing exactly w
227227
- **Checked — write side, literal-only.** Since [#4271](https://github.com/objectstack-ai/objectstack/issues/4271), `body.source` is **parsed** (never executed, never type-checked) and the field names it writes are resolved against the target object's declarations, which include every field an `objectExtensions` entry of the same artifact adds to it. An unknown field raises `hook-body-write-unknown-field` — a **warning** carrying a did-you-mean suggestion, which never blocks a build. Action bodies get the same check on their `ctx.api` writes (`action-body-write-unknown-field`). Both run under `os validate`, `os lint` and `os compile`. The *existence* question is advisory like this because the answer can depend on a package the build cannot see; the separate *writability* question — [writing a `readonly` field through `ctx.api`](#writing-a-readonly-field) — **does** gate, because both halves of that judgement are declared in the stack being checked.
228228
- **Checked — writes to a system column the object has no storage for.** Since [#8663](https://github.com/objectstack-ai/objectstack/issues/8663), a write to an injected system column is no longer exempted on the strength of its NAME alone. The registry injects `owner_id` / `organization_id` / the audit family onto an ADR-0015 [`external` object](/docs/data-modeling/external-datasources) exactly as onto a local one, but the remote database owns that schema and no column exists behind them. Writing one raises `hook-body-write-unprovisioned-anchor` (or `action-body-write-unprovisioned-anchor` / `flow-node-write-unprovisioned-anchor` on the other two surfaces) — a **warning** on all three, including the flow-node rule that otherwise gates, because the claim is about a remote schema the build cannot see. A column you **declare** yourself is untouched: on a federated object a declared `owner_id` maps a remote column you vouch for. Why it matters more than an ordinary typo: an undeclared name is refused upstream by the engine's own write-path validator (`INVALID_FIELD`), whereas the injected anchor is in the registered schema and passes it — so it is the one payload key that reaches the remote database raw, where a SQL remote aborts the **whole statement** with an untyped `no such column` and takes the correctly named fields of the same payload with it.
229229
- **Checked — writes that reach nothing at all.** Since [#4345](https://github.com/objectstack-ai/objectstack/issues/4345), an action body assigning to `ctx.record` raises `action-record-write-discarded`, also a warning. This one is **not** a field-resolution question: an action's `ctx.record` is a snapshot the runtime never writes back, so the assignment is discarded whether or not the field is declared — see [Signature conventions](#signature-conventions) below.
230+
- **Checked — an action body compiles in its wrapper.** An action body runs as the body of `(async (input, ctx) => { … })`, so `input` and `ctx` are parameters the body shares a scope with. A body that does not compile there — `const input = ctx.input || {}` redeclares a parameter, a syntax error — raises `action-body-does-not-compile`, an **error** under `os validate`, `os build`, `os lint` and the runtime publish door (`action` and `object` writes), naming the action and the compile error. Read the params as `input`, or name the local differently (`const params = ctx.input || {}`); `var input = …` compiles. The check compiles the body inside the same expression the runtime builds, without running it, with the host's JavaScript engine; a regular-expression literal that engine refuses is a warning, because its dialect measurably differs from the runtime's QuickJS. An action whose body still fails to compile at run time answers `500 INTERNAL_ERROR` with a sentence naming the action and the compile error, never a bare `Internal server error`.
230231

231232
Four literal write shapes are recognized, and only these:
232233

‎content/docs/deployment/cli.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ os compile --json # JSON output for CI pipelines
887887
→ Normalizing stack definition...
888888
→ Lowering inline handlers...
889889
→ Validating protocol compliance...
890-
→ Running author-time rules (70)...
890+
→ Running author-time rules (71)...
891891
→ Checking that every required capability has a provider installable in this edition...
892892
→ Collecting package docs (ADR-0046)... 0 collected
893893
→ Writing artifact...

‎content/docs/deployment/validating-metadata.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ orthogonal to both, and no cell here can carry it; it is written out in
519519
| Print page blocks — a page that declares `print` holds only printable component types (`print-page-block-unprintable`, #22158) | ✓ | ✓ | ✓ | ✓ᵖ |
520520
| Page variable declarations — each name once and never blank, a `defaultValue` of its declared type, a `source` naming a component the page holds (#28663, #28725) | ✓ | ✓ | ✓ | ✓ᵖ |
521521
| JSX / React page source parses (ADR-0080/0081) | ✓ | ✓ | ✓ | — |
522+
| Script action bodies compile in the runtime's wrapper — an L2 action's `body.source` that does not compile as the body of `(async (input, ctx) => { … })`, most often `const input = …` redeclaring a parameter; an object write runs it over its inline `actions[]`, so an object write cannot republish a refused body (`action-body-does-not-compile`, #34884) | ✓ | ✓ | ✓ | ✓ᵃᶜᵒ |
522523
| Approval-node approvers (ADR-0090 D3) | ✓ | ✓ | ✓ | ✓ᶠ |
523524
| Security posture (ADR-0090 — e.g. every custom object declares `sharingModel`) | ✓ | ✓ | ✓ | ✓ˢᵖᵉᵇᵒ |
524525
| Security vocabulary freeze (ADR-0090 D3 — the reserved word, replaced by `permission_set` / `position` / `business_unit`) | ✓ | ✓ | ✓ | ✓ᵒᵖᵉᵇᵖᵒᵃᵒˣ |
@@ -865,7 +866,7 @@ A clean run walks the registry and reports timing:
865866
Config: /path/to/support-desk/objectstack.config.ts
866867
Load time: 21ms
867868
→ Validating against ObjectStack Protocol...
868-
→ Running author-time rules (70)...
869+
→ Running author-time rules (71)...
869870
→ Checking that every required capability has a provider installable in this edition...
870871
→ Checking package docs (ADR-0046)...
871872

‎content/docs/getting-started/build-with-claude-code.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ visible: 'status != "resolved"'
311311
◆ Validate
312312
────────────────────────────────────────
313313
→ Validating against ObjectStack Protocol...
314-
→ Running author-time rules (70)...
314+
→ Running author-time rules (71)...
315315
316316
✗ Author-time rules failed (1 issue)
317317
• stack · action 'resolve_ticket' visible: bare reference `status` — a

‎content/docs/ui/actions.mdx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export default defineStack({
7272

7373
Self-contained logic ships inside the metadata and runs in the server sandbox
7474
— signature `(input, ctx)`, with `ctx.api.object(name)` for data access, a
75-
5-second default timeout, and declared `capabilities`:
75+
5-second default timeout, and declared `capabilities`. `input` and `ctx` are the
76+
wrapper's parameters, so a body must not declare them again: `const input = …`
77+
does not compile, and `os validate` / `os build` / the publish door refuse it
78+
(`action-body-does-not-compile`):
7679

7780
```typescript
7881
export const MarkDoneAction = defineAction({

‎content/docs/ui/react-pages.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ objectstack validate
404404
────────────────────────────────────────
405405
→ Loading configuration...
406406
→ Validating against ObjectStack Protocol...
407-
→ Running author-time rules (70)...
407+
→ Running author-time rules (71)...
408408
→ Checking that every required capability has a provider installable in this edition...
409409
→ Checking package docs (ADR-0046)...
410410

‎packages/core/src/utils/import-runner-sandbox-fault-row.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ const CRASH_SAMPLES: Readonly<Record<string, string>> = {
122122
...SAMPLES,
123123
'formatErr(err)': 'TypeError: boom',
124124
errStr: 'TypeError: boom',
125+
// An action body that does not compile in its wrapper: the action's name and
126+
// the compiler's sentence (`actionBodyCompileFailure`).
127+
actionName: 'mz_lock_decide',
128+
compilerError: 'SyntaxError: invalid redefinition of parameter name',
125129
};
126130

127131
/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The one spelling of the wrapper an L2 action body runs in.
5+
*
6+
* The runtime does not run an action's `body.source` as a script of its own: it
7+
* pastes the source into the body of an async arrow and calls that arrow with
8+
* the action's params and its context
9+
* (`packages/runtime/src/sandbox/quickjs-runner.ts`). So the source's
10+
* statements share a scope with two bindings the author never wrote, and a
11+
* source that is valid on its own can fail to compile there: declaring `input`
12+
* or `ctx` again with `const` / `let` / `class` is a redeclaration of a
13+
* parameter, a SyntaxError raised before any statement runs.
14+
*
15+
* The runtime builds its wrapper from {@link actionBodyFunctionExpression}, and
16+
* the author-time rule (`validate-action-body-compiles.ts`) compiles the source
17+
* inside that same expression, so the check and the run cannot disagree about
18+
* the wrapper. ⛔ Never spell the wrapper a second time anywhere: a copy is a
19+
* second shape the next edit can move one side of.
20+
*
21+
* Hook and job bodies run in a different wrapper, `(async (ctx) => { … })`, and
22+
* are not described here.
23+
*
24+
* No imports: the runtime reaches this module through `@objectstack/lint/runtime`.
25+
*/
26+
27+
/** The parameters an action body's wrapper binds, in call order: the params bag, then the context. */
28+
export const ACTION_BODY_PARAMETERS = ['input', 'ctx'] as const;
29+
30+
/**
31+
* The function expression an action body runs as: `(async (input, ctx) => { SOURCE })`.
32+
*
33+
* The source is placed after the opening brace on the expression's FIRST line,
34+
* so line N of the source is line N of the expression; a compile error's line
35+
* number therefore reads directly as a line of `body.source`.
36+
*/
37+
export function actionBodyFunctionExpression(source: string): string {
38+
return `(async (${ACTION_BODY_PARAMETERS.join(', ')}) => { ${source} })`;
39+
}

0 commit comments

Comments
 (0)