Repository navigation
fix(runtime,cli,lint,spec)!: a sandboxed body's ctx.api.object(X).updateById(id, patch) writes the row - #38643
Conversation
…d(id, patch) writes the row The QuickJS runner installs updateById behind api.write, refusing an id that is not a non-empty string or non-zero number at the crossing. The build infers api.write for it and lint's sandbox write list names it. Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
…yId leaf Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 195 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 64be7840f7f3988095a3be235ceba6ee06d27463 && git checkout 64be7840f7f3988095a3be235ceba6ee06d27463
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f5da514b07bcbb402e3b17790465615ca726b3b3 0dad68c61b62b6261639e96f918e6f24f89871f6 && git checkout -B drift-repro f5da514b07bcbb402e3b17790465615ca726b3b3 && git merge --no-ff 0dad68c61b62b6261639e96f918e6f24f89871f6
node scripts/docs-audit/affected-docs.mjs --json f5da514b07bcbb402e3b17790465615ca726b3b3
|
|
repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B Final green head · 2026-11-29T19:27Z · zone o3-B · |
…ssignment object is refused at save; the write-leaf lists name updateById The changeset declares the narrowing: an action body calling updateById without api.write, and an elevated body writing an identity-assignment object through it, are refused at save and in os validate. Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
…nd cli stay patch Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
…ong the judged write calls The save-time refusal it registers now judges updateById too, so its surface and reason list the call beside insert, update, delete, updateMany, deleteMany and upsert. The upgrade guide is a projection of this entry and is generated, not committed. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B
… the build infers api.write from updateById is inferred since this change; updateMany and deleteMany were inferred already and the row omitted them. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B
|
repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B Final green head · 2026-11-29T22:24Z · zone o3-B · |
|
repo:objectstack#3 · os-steve · session_01ADHkmQm8PTU4AkVU5kdwEv 席位核对REWORK @ Must-fix 1. The BREAKING section's second row states the old behaviour wrongly.
Read at head (these stand, and the delta review will not reopen them):
For the L2 at CONTRACT_REVIEW_TIER (the seat routes it): entry 18 is a v18 semantic entry, and claim amendment 2 (7262440822) edits its |
…teById threw TypeError too The sandbox did not install updateById, so that body never reached the run-time security middleware. The BREAKING table and the sentence after it now say so. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B
…tity-assignment save refusal Through v18 a sandboxed body had no updateById leaf and the call threw TypeError, so the v18 entry rightly does not name it; it is restored byte-identical to main. The new v19 entry records that a save now refuses an elevated body writing sys_user_position, sys_user_permission_set, sys_invitation or sys_member through updateById. The changeset registers it beside the publish-refuses entry that covers the api.write half. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B
|
repo:objectstack#3 · os-steve · session_01ADHkmQm8PTU4AkVU5kdwEv 席位核对ACCEPT @ The delta is three files. I read each sentence by sentence:
Everything else stands as read at 60c75f9 in 7263826297. |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract-review-handoff: repo:objectstack#1 — CONTRACT_REVIEW_TIER unavailable (project rule: the maintainer bars the ceiling tier in this seat, 「契约复审交 review 席位,不用 fable」; no l2-review or review seat is seated, mailbox list read 2026-11-29T23:26Z) · head 4c186ea Faces: narrowing ( |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract-review-claim: session_01ADHkmSAjFEZHRpRq3WCj6z · head 4c186ea · 2026-11-30T00:10Z The seat takes the tier itself from here (the maintainer, 2026-11-30 「你现在有fable」); the earlier handoff to repo:objectstack#1 is withdrawn on its mailbox #38524. |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract reviewServed-tier: Inputs read: card #38630 (body and all 12 comments), PR #38643 (body, 16-file list, all 6 comments), the net diff ① Derived judgments
② Semver levelClause-②: no (narrowing) — matches the diff. ③ Boundary flags
④ Design judgment
S1 (should-fix) — N1 (nit) — N2 (nit) — the id guard throws synchronously at the call site, like the capability denial, so a body that writes Implemented-by: VERDICT: PASS |
…nly-rule sandbox list name updateById Comment and string text only: hook.zod.ts's contract block over the elevated identity-assignment refusal, and the installed-leaf list in validate-readonly-hook-writes.ts's comment and its create() exclusion reason, now include updateById. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B
|
repo:objectstack#3 · os-steve · session_01ADHkmQm8PTU4AkVU5kdwEv 席位核对ACCEPT @
|
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract-review-claim: session_01ADHkmSAjFEZHRpRq3WCj6z · head 0dad68c · 2026-11-30T00:52Z |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Contract reviewServed-tier: Delta round over Prior findings:
① Derived judgments
② Semver levelClause-②: no (narrowing) — unchanged, and still matches the diff. The PR body still carries ③ Boundary flags
④ Design judgment
A sweep at the new head for a sandbox write-leaf list that names No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z 维护者速读
Seat opinion: land as is. The narrowing refuses only bodies that never ran (they threw 席位核对ACCEPT at head
ACCEPT → PR #38643 comment 7265266081 · Contract review → comment 7265670341 |
…ng declares (objectstack-ai#38648) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JeHmqv6CKCkW8ewrPBLekk)_ Fixes objectstack-ai#38623 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在 Studio、元数据接口或 AI 助手里保存或发布一条翻译时,如果它指向一个已经不存在的对象、字段、校验规则、里程碑或权限集,保存结果里会多出一条提示;以前保存显示一切正常,什么都不说。 - 属于“错误的元数据要被明确指出”这项构建能力:本地校验早就会报这类问题,线上保存却静默通过,这次替在 Studio 和 AI 助手里写翻译的作者补上这个缺口。 - 出错的最坏情况是对一条其实有效的翻译多报一条提示,保存本身照常成功、不会被拒;应用的导航菜单和应用名这类翻译这次仍不检查,可以直接撤回这次改动。 - 无。 ## What changes A `translation` item saved (active) or published over the metadata API now runs `validateTranslationReferences` at the runtime publish gate. An orphan key comes back as a `translation-target-unknown` **advisory** on the save and publish answer (`advisories`, severity `warning`). Before this, no rule ran on a `translation` write (`runtimeAuthoringRulesFor('translation')` was `[]`): the item was accepted as valid while `os validate` refused the same key. **Never a refusal.** Every finding on a translation write is a `warning`, so it lands in `advisories` and never in the 422 `errors`. A published item that names a key an upgrade removed still loads and saves. `os validate` keeps reporting the same key at `error`. **Families the door judges** (the ones the per-write snapshot carries, `RuntimeStackContext`: objects, permissions, books, datasets): - `objects.NAME`, only when the gate did not narrow `objects` to the write's package closure. The i18n layer is process-wide, so a translation may legitimately name an object outside its package's closure. - `objects.NAME.fields.FIELD`, and the field's `options` keys, only for a field that declares options inline. A picklist-bound field's served options are not in the snapshot. - `objects.NAME._validations.RULE` - `objects.NAME._milestones.FIELD.VALUE` - `permissions.NAME` **Not judged at the door:** apps and their navigation (platform-contributed nav items included), `_views`, `_sections`, `_tabs`, `_relatedLists`, `_actions`, `globalActions`, `dashboards`, `forms`, `pages`, `picklists`, `positions`, `reports`, `mappings`, `books` (the implicit per-package book is named by a package id the snapshot never sees), `flows`, `hooks`. Each resolves into a collection no per-write snapshot carries, so the door never guesses a key there unknown; `os validate` still judges all of them. Judging apps and navigation at the door would mean carrying served apps in the snapshot. That is a separate decision and not this card. The changes: - `authoring-rules.ts`: the `validateReferenceIntegrity` entry's `runtimeTypes` gains `translation`, so a translation write dispatches the suite. - `reference-integrity-suite.ts`: the `validateTranslationReferences` member gains `runtimeTypes: ['flow', 'translation']` and still hands its run context straight through. - `validate-translation-references.ts`: the rule reads `runtimeWriteType === 'translation'` off that context as its save-door reading. That is the signal the suite's other members already read for `wholeCollection`. In that reading the rule treats the entry as one item (keyed by its own `locale`), reduces the item to the judged families, and maps every finding to `warning`. - `runtime-gate.ts`: `TYPE_TO_STACK_KEY` gains `translation: 'translations'`. No context row is added, and no metadata-protocol source changes. - `scripts/engine-double-contract.pinned.json`: the three engine doubles the new protocol pin uses (`delete`, `findOne`, `update`) are recorded, written by `check-engine-double-contract --write`. - `content/docs/deployment/validating-metadata.mdx`: the "Reference integrity" row's runtime-publish cell gains `translation` (`✓ᶠᵛᵒᵈᵗʳᵖᵃᶜᵗ`), and its text says what a translation write runs. The superscript legend gains `✓ᵗ` `translation`, and the longest-first note now covers it. Nothing else on the page changes. The CLI reading is byte-identical: without `runtimeWriteType` the rule takes its old path, the whole rule at its own severities. **Control pins moved** (each held `translation` as the ungated control; it now crosses, so the control moves to a type that stays ungated; `tool`'s own control is untouched): - `packages/lint/src/authoring-rule-wiring.test.ts` ("a type nobody gated returns nothing"): `translation` → `doc` - `packages/lint/src/runtime-gate.test.ts` ("runs nothing for a metadata type no rule gates"): `translation` → `doc` - `packages/lint/src/runtime-gate.test.ts` ("returns null for an unmapped type"): `translation` → `doc` - `packages/lint/src/runtime-gate.inert-type-writes.test.ts` ("crossing these five widened no OTHER type s roster"): `translation` → `capability` - `packages/lint/src/runtime-gate.datasource-writes.test.ts` ("the types still awaiting their own readings are untouched"): `translation` → `capability`, and the comment says `translation` crossed on its own reading The seat's reading (7260663888 on objectstack-ai#38623) takes this card as the `translation` reading that the ADR-0049 group B line defers the wiring to. **Read these first** (ranked by risk): 1. `packages/lint/src/validate-translation-references.ts`: `doorJudgedSubset` and the `localeEntries` / `atSaveDoor` lines in `validateTranslationReferences`. This hunk decides what the door may judge; a family added here without its collection in the snapshot is a false advisory on every save. 2. `packages/lint/src/reference-integrity-suite.ts`: the member's `runtimeTypes`. 3. `packages/lint/src/authoring-rules.ts`: the entry's `runtimeTypes`. **Two-minute verification:** `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/runtime-gate.translation-writes-38623.test.ts` shows 9 passing. The removed field key, the orphan object, rule and milestone, and the orphan permission set come back in `advisories` with `errors` empty. Live keys and the unjudged families come back with neither. ## Tests New files, named for this card: - `packages/lint/src/runtime-gate.translation-writes-38623.test.ts`, through the gate's own entry (`runRuntimeAuthoringRules`): - the dispatch: suite on `translation`, exactly the translation member - a removed field → advisory, `errors` `[]` - an orphan object, validation rule and milestone → advisories - an orphan permission set → advisory - live keys → none - apps, navigation, global actions, positions, views and sections → not judged - a picklist-bound field's option keys → not judged - under a package closure, an object outside it is not judged while its sibling's removed field still is - the CLI reading is unchanged (a bundle, at `error`) - `packages/metadata-protocol/src/protocol.translation-target-door-38623.test.ts`, through the real `saveMetaItem` / `publishMetaItem` write path over a stub engine: - an active save naming a removed field → `success`, the advisory, and the row landed - a draft save says nothing (D1), and its publish answers with the advisory - a permission-set orphan → advisory - live keys → none - an already-published orphan neither blocks nor rides on an unrelated translation write <details><summary>Test runs: the new files at 8775b06; the whole-package readings at 66c22be (before the main merge, which brought no lint or metadata-protocol file)</summary> - At head 8775b06, under the verify lock, after a fresh build of the `@objectstack/metadata-protocol...` closure: `protocol.translation-target-door-38623.test.ts` Tests 5 passed (5), `runtime-gate.translation-writes-38623.test.ts` Tests 9 passed (9), `VERDICT command-exit 0`. The later docs commit changes no code. - `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2` (whole package): Test Files 247 passed (247), Tests 9977 passed (9977) - `pnpm --filter @objectstack/lint typecheck`: exit 0 (`tsc --noEmit` and `check:test-typecheck` OK) - `pnpm --filter @objectstack/metadata-protocol typecheck`: exit 0 - `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.translation-target-door-38623.test.ts`: Tests 5 passed (5) - The 29 metadata-protocol test files that mention `translation`: Test Files 29 passed (29), Tests 862 passed (862) </details> <details><summary>Ablation: the entry widening reverted</summary> `'translation'` removed from the entry's `runtimeTypes` through `scripts/ablation-replace.mjs`: - The anchor hit once and the mutation landed (blob 663f139 → 3068dd8e9df2). - lint was rebuilt, and `ablation-dist-preflight.mjs @objectstack/lint '"page", "action", "translation"]' --absent` confirmed the marker absent from all 20 built files. It had been present in the pristine `dist/runtime.js` and `dist/index.js`. Results on the mutant: - lint file: 5 failed / 4 passed. The dispatch case, the removed field, the orphan object, rule and milestone, the permission set and the closure case went quiet. Live keys stayed clean, and so did the unjudged-families, picklist and CLI cases. - protocol file: 4 failed / 1 passed. The active save, the draft publish and the permission set went quiet. The live-key save stayed clean. The already-published-orphan case also fails, because its first save asserts the advisory as a precondition. Restored: blob == HEAD (663f139) and `git diff HEAD` empty. lint was rebuilt, and the protocol file then read 5 passed (5). </details> ## Acceptance notes - **False positives, measured on `examples/app-showcase`'s real `ShowcaseTranslationBundle`** (en + zh-CN; context = the showcase's objects, permissions, books and datasets): - whole-stack `validateTranslationReferences`: 0 findings - the rule unrestricted on the door's snapshot: 85 phantom `translation-target-unknown`. By family: `_views` 28, `_sections` 19, positions 10, flows 10, dashboards 6, `_tabs` 4, reports 4, `globalActions` 2, apps 1, mappings 1. That is why the door judges only the families listed above. - this PR, through `runRuntimeAuthoringRules({ type: 'translation' })` per locale: errors 0, advisories 0 - the lit control on the same context (a removed `showcase_project` field) comes back as one `warning` advisory - A draft save is still never gated (objectstack-ai#4463 D1). The advisory appears on an active save and on publishing a draft, not on the draft save itself. - Found while measuring, not changed here: `os validate` refuses a bundle key under the platform `studio` app at the app level, whatever the navigation id (`translations[0]["zh-CN"].apps.studio`, "which this stack neither defines nor contributes into"), even for a live id such as `nav_api_console`. The lint's apps rung has no platform-app ladder; the objects rung has `isPlatformProvidedObjectName`. Reported to the seat with the CLI reproduction. ## Verification <details><summary>Local gates, derived with dispatch-gates --commands</summary> At head 9b075e6. Gates were derived with `node scripts/pm/dispatch-gates.mjs --commands` (105 families) and each exit code was captured before any pipe. The `--ran` reconciliation reads: 105 derived, 103 run, 2 NOT MEASURED (derived from a recorded exit 3), 0 unrun. - 68 code families were read at the code head: 266bea7, then 8775b06 for the ledger. The docs commit 9b075e6 changes only the page. - 37 families the docs path adds, all at 9b075e6: exit 0. They include `check-adr-links` with its self-test (the local half of Check Documentation Links; lychee runs only in CI, and the edit adds no link), `check:doc-anchors`, `check:doc-frontmatter`, `check:docs-redirects`, `check:docs-single-h1`, `check:docs-spec-enumerations`, `check:docs-audit-scope` and `@objectstack/spec` `check:docs`. - `@objectstack/spec` `check:skill-examples` first exited 3 (PREREQUISITE NOT MET: client SDK not built). After building `@objectstack/client-react...` and `@objectstack/client...` under the lock, it exits 0: "352 prose examples type-check across 3 surface(s)". - `pnpm check:engine-double-contract`: exit 1 before the ledger commit, exit 0 after it at 8775b06. - `pnpm check:objectql-double-limit`: exit 0 ("none new"). - `node scripts/check-nul-bytes.mjs`: exit 0. - `node scripts/pm/overlap-check.mjs --branch=HEAD` at 9b075e6: `VERDICT clean exit 0`. The branch merges cleanly with origin/main and with objectstack-ai#38643, objectstack-ai#38642, objectstack-ai#38594, objectstack-ai#38550 and objectstack-ai#38497. - NOT MEASURED: - `node scripts/check-plugin-teardown-shape.mjs --self-test`: exit 3 (shallow checkout). - `pnpm check:dual-build-cjs-loads`: exit 3 (needs a full `pnpm build`). - `pnpm check:dts-closure`: exit 1. The self-test passed. The scan's red came from a local build that skipped declaration output in an earlier worktree. `@objectstack/lint` and `@objectstack/metadata-protocol` were not among the packages it named. CI's fresh build gives the real reading. The families CI runs (the repo-wide lint, `test:repo`, Check Documentation Links' lychee step, the artifact roster) are read from this PR's check-runs. They were not re-run here. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…it was not granted (objectstack-ai#38650) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JeHmqv6CKCkW8ewrPBLekk)_ Refs objectstack-ai#37815 (items a, b) Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: follow-up objectstack-ai#38655 ## 维护者速读 - 用户能看到什么变化:应用作者保存或校验一个脚本动作或自己写的钩子脚本时,如果代码调用了沙箱需要授权的功能(写数据、事务、日志、发邮件、写活动记录等)却没有声明对应权限,现在会在保存和本地校验时直接被拒并说明要加哪个权限;以前能保存,但每次运行都报错。 - 为什么做:属于脚本动作与钩子的权限检查跟进工作,把只覆盖动作写数据的检查扩展到钩子和沙箱的全部授权项。 - 出错会怎样:误判会让一个本来能运行的动作或钩子保存不了;用函数写、由构建转换出来的钩子和动作这次不做新增检查;已存的元数据不受影响,可以直接撤回;现有示例应用实测无一被拒。 - 要你做什么:无。 ## What changes The QuickJS sandbox gates seven tokens, and before this PR lint judged one of them on one kind of body (`ctx.api` writes on action bodies, `action-body-write-capability-undeclared`). A hook body, and an action body calling any other gate, saved and published clean and then threw `403 INSUFFICIENT_PRIVILEGES` at every call. - **Runner census (measured first, read-only).** Every capability gate in `packages/runtime/src/sandbox/quickjs-runner.ts` at `0ba5e06ae7`: `api.read` on the `READ` leaves `find` / `findOne` / `count` / `aggregate` (`installApiMethod`, line 755) and on `ctx.title(FIELD)` with an argument (line 1035, hook bodies only: the action face builds no `ctx.title`); `api.write` on the `WRITE` leaves (line 756); `api.transaction` on `ctx.api.transaction` (`installTxLeaf`, line 783); `log` on `ctx.log.debug|info|warn|error` (line 881); `crypto.uuid` on `ctx.crypto.randomUUID` (line 907); `email.send` on `ctx.email.send` and `activity.append` on `ctx.activity.append` (`installDoor`, lines 941 to 994). That set is exactly `HookBodyCapability` in the spec. The rule judges exactly that set, as `SANDBOX_CAPABILITY_GATES`. - **Arm (a), authored hook bodies.** `validateActionBodyCapabilities` now walks `stack.hooks` too, with the same reading (blanked source; the member itself, a local bound once to it, or a handle bound once to `.object(…)`). New id `hook-body-capability-undeclared`, one finding per body and token, at `hooks[i].body.capabilities`. A hook body is never granted `email.send` (the hook's parse refuses the grant), so its `ctx.email.send` call is refused with the remedy that works: remove the call and send the mail from an action, a job or a flow. **Scope (route C): authored hook bodies only.** A hook body that `os build` / `os verify` lowered from an inline `handler` is not judged (`isLoweredHandlerBody`): under the CLI exactly when `ctx.loweredHookRefs` holds the hook's string `handler`, and at a door that hands no lowered refs (the runtime publish doors) whenever a string `handler` sits beside the body, the shape a build artifact carries. Its grant is the build's inference, and the extractor does not yet infer `api.transaction` or a read through a bound handle, so a finding there would name a grant the handler author cannot write. objectstack-ai#38653 carries the lowered-handler reading and both extractor gaps. The registry entry keeps its name and gains `hook` in `runtimeTypes` (the `validateHookAndJobBodyCompiles` precedent: one entry, ids per kind), and now receives `ctx`. - **Arm (b), the other tokens, authored action bodies.** On action bodies, every gate other than the writes is judged under the new id `action-body-capability-undeclared`. A missing `api.write` keeps its own id and its exact words, so nothing that matches on it today changes. **Scope (contract review M1, claim amendment 3): authored action bodies only, past the writes.** An action body that `os build` / `os verify` lowered from an inline `target` function is judged for `api.write` only, as before (`isLoweredTargetBody`). Measured before the edit: the CLI hands no lowered-action ref set (`LoweringResult` carries `loweredHookRefs` only), and `lowerActionCallable` leaves a string `target` (the registered ref) beside the minted body. So on every door, the CLI included, a body is read as lowered when a string `target` sits beside it. No `packages/cli` edit was needed. A JS body runs only on a `script` action, where `target` is kept for legacy `functions` references alone; an authored body beside a string `target` is therefore not judged for the other tokens either, a missed finding, never a false one. In `examples/app-showcase`, none of the 296 JS-body actions (318 actions in all) carries a string `target`. objectstack-ai#38653 carries the lowered reading. - **Pin.** The new test file reads the runner's source: the token set from `caps.has('…')`, the `installApiMethod` tokens and the `installDoor` calls must equal the census; the `caps.has(NAME)` calls with a variable must be exactly the two known ones, so a third parametrised gate turns it red; the `READ` list, the log levels and the door triples are pinned; and the census token set must equal `HookBodyCapability.options`. - **L1-a's nit from objectstack-ai#38628.** The `action-body-write-unknown-field` explanation now lists the installed field-carrying leaves: `insert`, `update({ id, … })`, `updateById(id, { … })`, `upsert`, `updateMany`. `updateById` landed with objectstack-ai#38643, which this branch merged from `main`; the census and the gate table read the runner's `WRITE` list and needed no edit. - `os explain` entries for both new ids, and two rows in `content/docs/deployment/validating-metadata.mdx`. - **Upgrade guide and barrel.** `packages/lint/src/index.ts` exports both new id constants. A new upgrade-guide entry, `packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts`, follows the `hook-job-body-does-not-compile-refused` precedent and says the hook arm covers authored bodies only; the changeset marker is `registered` with that id, and the changeset carries an `@objectstack/spec` patch line. The `os build` extractor (`packages/cli`) is unchanged: byte-identical to `main`. The rule file's header names `hook` as the third runtime door (review N2), and the upgrade-guide entry's `acceptanceCriteria` names the inline path `objects[N].actions[M].body.capabilities` (N2). S1 (`updateById` in the `action-body-write-unknown-field` leaf list) was met at `a60a6de915`. This touches a contract face: the lint rule family's accept set at the save door and in `os validate` (a narrowing). ## Tests - New file `packages/lint/src/validate-action-body-capabilities.hook-and-tokens-37815.test.ts`: per arm a refused case, a granted control that passes, and an ungated call that stays quiet; the hook case through the save door (`runRuntimeAuthoringRules` on `type: 'hook'`) and through `runAuthoringRules` for `validate` / `build` / `lint`; the hook `email.send` remedy; `ctx.title(FIELD)` against `ctx.title()`; a shape table for `bodyGatedCalls`; the runner pin. - M1 pins, both sides, on one source (a write inside `ctx.api.transaction`, granted `api.write` only, as the extractor infers): the authored action body is refused; the same body beside a string `target` is not judged, through `validateActionBodyCapabilities`, through `runAuthoringRules` for `validate` / `build` / `lint` at the top level and inline on an object, and at the `action` and `object` doors (each with an authored positive control); a lowered body without `api.write` is still refused under the write id. - Route C pins, both sides, on one source (a read through a bound handle): the authored body is refused; the same body lowered from a handler is not judged, through `validateActionBodyCapabilities`, through `runAuthoringRules` for `validate` / `build` / `lint` with `loweredHookRefs`, and at the save door with a string `handler` beside the body; a string `handler` the build did not lower leaves the authored body judged. - One ablation per behaviour with `scripts/ablation-replace.mjs`, each restored to a clean tree. <details><summary>Readings at 4c07e0d, 29d3b0f, a60a6de and c3319db</summary> - At 29d3b0f: `pnpm --filter @objectstack/lint typecheck && pnpm --filter @objectstack/lint test`: typecheck clean, `check:test-typecheck` OK; Test Files 248 passed, Tests 10035 passed. The new test file: 46 passed. Ablation of the M1 exemption (`if (lowered) continue;` deleted): Tests 3 failed / 43 passed, exactly the three lowered-target pins; restored, blob equal to HEAD. `check-adr-0087-registration --base origin/main`, `check-changeset-no-major`, `check:spec-changes`, `check:upgrade-guide` and `check-nul-bytes` exit 0; overlap-check clean. - Full dogfood battery on 29d3b0f (`pnpm --filter @objectstack/dogfood test` under the lock, after building the dogfood closure): Test Files 495 passed / 3 skipped (498), Tests 4187 passed / 68 skipped (4255), VERDICT command-exit 0. The head after it, 4c07e0d, changes only one sentence of the upgrade-guide entry's guidance text. - At 4c07e0d, after a cli build: `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/migrate-meta-engine-guidance.test.ts test/explain-rule-id.test.ts test/verify-delete-behaviors.test.ts`: Test Files 3 passed, Tests 20 passed. The entry's printed guidance names no tracker, so the Test Core (2/12) red at 29d3b0f is fixed. `check-adr-0087-registration`, `check-changeset-no-major`, `check:spec-changes`, `check:upgrade-guide`, `check:generated` and `check-nul-bytes` exit 0; overlap-check clean. - At a60a6de (after merging `main` with objectstack-ai#38643): `pnpm --filter @objectstack/lint typecheck && pnpm --filter @objectstack/lint test`: typecheck clean, `check:test-typecheck` OK; Test Files 248 passed, Tests 10031 passed. The new test file, census pin included: 42 passed. `check-adr-0087-registration --base origin/main` exit 0; `check-changeset-no-major` exit 0. - At c3319db: lint suite Test Files 248 passed, Tests 10019 passed. - `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/verify-delete-behaviors.test.ts test/published-subpath-hook-body.pin.test.ts test/explain-rule-id.test.ts test/extract-hook-body.test.ts test/lint-hook-rules-reach-handler-hooks.test.ts` (after a cli build): Test Files 5 passed, Tests 109 passed. - Ablation of the narrowing (the `isLoweredHandlerBody` early return deleted): Tests 2 failed / 40 passed, exactly the two not-judged pins; restored, blob equal to HEAD. - Round 1 ablations: the hook walk removed, 8 failed / 31 passed; the `api.transaction` gate entry removed, 8 failed / 31 passed; both restored. - After the build: `check-adr-0087-registration` exit 0 (1 migration entry added); `check:spec-changes` exit 0; `check:upgrade-guide` exit 0; `check:generated` all 14 artifacts current; `check-nul-bytes` OK. The upgrade guide was regenerated with `gen:upgrade-guide` only. - `node scripts/pm/dispatch-gates.mjs --commands`: 118 families derived; 116 exit 0, 2 NOT MEASURED (exit 3, PREREQUISITE NOT MET: `check:skill-examples`, `check:dual-build-cjs-loads`); `--ran` reconciliation: 118 accounted for. CI on c3319db: 72 check-runs, 62 success and 10 skipped, among them `Lint & Repo Gates`, `Test Core`, `Check Changeset` and `Dogfood Regression Gate` green. - Full dogfood battery on c3319db (`pnpm --filter @objectstack/dogfood test` under the lock, after building the dogfood closure): Test Files 495 passed / 3 skipped (498), Tests 4187 passed / 68 skipped (4255), VERDICT command-exit 0. - First-party measurement of example apps before any edit: 0 findings. A sweep of 50 handlers under `packages/*/test/**` and `examples/**` found one body refused under the lowered-handler reading (`packages/cli/test/verify-delete-behaviors.test.ts`); under route C it is not judged, and that test is green. </details> ## Acceptance notes - Scope, route C (claim amendment 2): the hook arm judges authored hook bodies only. Lowered handlers, and the two extractor gaps under them (no `api.transaction` inference; no `api.read` inference through a bound handle, `?.` before the leaf or an argument holding parentheses), are carried by objectstack-ai#38653, a widening that follows this PR. The published `@objectstack/cli/hook-body` type and its pin are untouched, so this PR keeps its one Clause-② arm. - At the runtime publish doors a hook carrying both a string `handler` and a body is read as a build artifact and not judged. A hand-written hook with both keys is therefore not judged either: a missed finding, never a false one. - An action carrying both a string `target` and a JS body is read as lowered on every door, the CLI included, and judged for `api.write` only. That covers an author who wrote a body beside a `target` function, too: `lowerActionCallable` keeps that authored body and still turns the `target` into a string ref. A missed finding, never a false one. objectstack-ai#38653 carries the lowered reading for both arms. - Not changed, per the review: N1 (`ctx.title(undefined)` / `ctx.title(null)` read as the related-record form) and N3 (job bodies are not judged). ## Verification Read first: `packages/lint/src/validate-action-body-capabilities.ts` (`SANDBOX_CAPABILITY_GATES`, `bodyGatedCalls`, the hook walk), then `isLoweredTargetBody` and the action loop's `lowered` skip, then the new test file's runner-pin block, its M1 pins and its route C pins, then the `authoring-rules.ts` entry (`runtimeTypes` gains `hook`, `run` receives `ctx`). Two-minute check: `pnpm --filter @objectstack/lint exec vitest run src/validate-action-body-capabilities.hook-and-tokens-37815.test.ts` shows 46 passed. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B)_ <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B --> --------- Co-authored-by: Claude <noreply@anthropic.com>
… whose documentBy is not a single-valued parent link (objectstack-ai#38662) <!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Xj6YfMRKw8XnmTA1ohBr6K)_ Fixes objectstack-ai#38537 Clause-②: no Metadata-protocol: none **Lands after objectstack-ai#38594** (merged 2026-11-30T01:10Z; main merged into this branch at `d1e1ba3f03`). Both PRs are seat 2's. The overlap is two files (`packages/lint/src/index.ts`, `packages/lint/src/rule-explanations.ts`), in hunks far apart; `overlap-check` reads both clean against each other and main. ## 维护者速读 - 用户能看到什么变化:知识源的“文档单位”(`documentBy`)如果填的不是指向父记录的单值查找字段,`os validate` / `os build` / `os lint` 和发布时都会报错并说明怎么改。之前只有在 Studio / 元数据 API 保存时才会拒绝。 - 为什么做:随包发布或代码注册的知识源不经过保存这道门,填错了没人拦,检索按父记录聚合会悄悄失效。这是 objectstack-ai#38537 的第二个也是最后一个 PR。 - 出错会怎样:只影响声明了 `documentBy` 的知识源;规则误判会让正确的知识源发布失败,删掉 `documentBy` 即可绕开。 - 要你做什么:无。 ## What changes - **New rule** `knowledge-source-document-by-not-parent-link` (`error`) in `validate-knowledge-source.ts`. It refuses a `source.documentBy` that `metadataFields` lists and that is not a single-valued parent link of the indexed object. The checks run in the save door's order: declared by the object, neither credential-class nor `internal`, a `lookup` / `master_detail` type, a target `referenceTargetOf` can read, and not `multiple: true`. Each reason gets its own message, worded like the save door's `documentUnitRefusalText`, naming the field and the fix. Path: `knowledgeSources[i].source.documentBy`. - **Where it runs.** The rule rides the existing `validateKnowledgeSource` registry entry, so it reaches `os validate` / `build` / `lint` and the runtime publish gate (`knowledge_source` writes) with no new wiring. This is what judges a source a package ships or code registers; until now only the metadata API's save door did (objectstack-ai#38564). - **Not judged twice.** A `documentBy` that `metadataFields` does not list is left to the parse, which already names that fix. A member the object does not have is reported once, as `knowledge-source-field-unknown`. An object with no readable field map is not judged. - **Published and explained.** The rule id is re-exported from the root barrel (`index.ts`, one line in the knowledge block). `rule-explanations.ts` gets its `os explain` entry and table row beside the five sibling rules. - **Census pin** (`packages/core/src/security/second-object-read-exposure.pin.test.ts`): the new `referenceTargetOf` import makes `validate-knowledge-source.ts` a caller of the reference-target arbiter, so it is classified `not-a-served-read` beside the other lint callers. It only asks whether a target is declared, and reads and serves nothing of the target. Admitted by the seat for this fix after CI's Test Core (8/12) flagged the unclassified caller. Locally: 1 failed / 3 passed before the entry, 4/4 after. - **Changeset** `patch` for `@objectstack/lint`. ## Route chosen for the parent-link rule (objectstack-ai#38564's PR 2 question) objectstack-ai#38564 left PR 2 two ways to reach `parentLinkRule` / `documentUnitOf` (`service-knowledge`'s `knowledge-search-scope.ts`). The seat accepted a third: - **A: lint imports `@objectstack/service-knowledge`.** Not taken. `@objectstack/lint`'s package description says it "Depends on @objectstack/spec; never on a runtime", and service-knowledge is a runtime service. It would also need a new line on service-knowledge's `exports` surface. - **B: move the rule to "a package lint already reads, for example `@objectstack/core`".** Not taken. Lint does not depend on `@objectstack/core`; its workspace dependencies are `formula`, `metadata-core`, `sdui-parser` and `spec`. Moving it to `spec` would put runtime-shaped logic into the protocol package and widen this PR well past its card. - **C (taken): compose the verdict in lint from the spec predicates `parentLinkRule` itself asks.** Withheld = `isMaskedOnReadFieldType(type, managedBy)` or `internal === true`. That is the reading this file already takes for `knowledge-source-field-never-indexed`, and the one `collectCredentialWriteResponseFields` / `collectInternalWriteResponseFields` compute in core. Target = `referenceTargetOf` (`@objectstack/spec/data`). The type pair `lookup` / `master_detail` is spelled locally, as eight other lint rule files already spell it. Cost: the four-part rule now lives in two places. No test pins their agreement, because no package that depends on both can import `documentUnitOf` without one more barrel line in service-knowledge. The module header names the save door's function so a change to one points at the other. ## Why ADR-0161 K4: "a packaged item meets the gates that need no principal in `os validate` and at publish". `documentBy` is such a gate: it reads only the object definition. objectstack-ai#38564 left it judged at save only, and its body says "PR 2's `os validate` rule covers packaged sources." ## Clause-② and Metadata-protocol, measured from the diff `Clause-②: no` / `Metadata-protocol: none`, a judgement call stated here for review. The rule refuses values of `source.documentBy`, a key objectstack-ai#38564 added in this same prerelease line. Its changeset `.changeset/38537-knowledge-document-by.md` is still pending (not moved to `.changeset/pre/`), so no published version carries the key and nothing an author could write against a release is refused. The metadata API's save door already refuses the same values. Read against `main` instead, a packaged source with a non-parent-link `documentBy` passed `os validate` before this PR and fails it after. If review prefers that reading, the lines become `Clause-②: no (narrowing)` / `Metadata-protocol: narrowed` (level `minor` and an ADR-0087 disposition). ## Verification ### Acceptance (the card's `os validate` half) | Card line | Test (`validate-knowledge-source.document-by.test.ts`) | |:--|:--| | Refuse a text field, a `user` field, an `internal` lookup and a `multiple` lookup, each naming the fix | "refuses a text field / a user field / an internal lookup / a multiple lookup as the document unit, naming the field and the fix" | | (the save door's other reasons) | "… a credential-class field", "… a lookup with no readable target", "… a system column the platform adds" | | Positive controls | "CONTROL: a lookup and a master_detail to the parent are admitted", "CONTROL: a source without documentBy is judged as before" | | Same verdict at publish | "refuses the publish with the words os validate prints", "CONTROL: a single-valued parent link publishes with nothing to report" | | Published id + `os explain` | "the root barrel re-exports it", "os explain answers it" | ### Ablation (`scripts/ablation-replace.mjs`, each mutation verified on disk, each restore verified blob == HEAD `d9f63681062f` with an empty `git diff HEAD`) <details><summary>Call site disabled (<code>const refusal = documentUnitRefusal(…)</code> → <code>undefined</code>): 9 red</summary> `validate-knowledge-source.document-by.test.ts`: 9 failed / 8 passed. All seven refusal tests, "a fields array is read like a field map", and "refuses the publish with the words os validate prints". The controls stay green. </details> <details><summary><code>multiple</code> arm deleted: 1 red</summary> 1 failed / 16 passed: "refuses a multiple lookup as the document unit…". </details> <details><summary><code>internal</code> half of the withheld arm removed: 1 red</summary> 1 failed / 16 passed: "refuses an internal lookup as the document unit…". (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.) </details> ### Package suite and typecheck - `pnpm --filter @objectstack/lint test`: Test Files 248 passed (248), Tests 9989 passed / 5 skipped. Exit 0. - `pnpm --filter @objectstack/lint typecheck` (tsc + test layer): exit 0. - `eslint` on the four changed source files: exit 0. - `overlap-check`: VERDICT clean exit 0. origin/main merges cleanly, and so do the 7 open PRs sharing a file (objectstack-ai#38651, objectstack-ai#38650, objectstack-ai#38643, objectstack-ai#38605, objectstack-ai#38594, objectstack-ai#38550, objectstack-ai#38497). ### Derived gate families (`dispatch-gates.mjs --commands`, 70) - First pass, captured per the tool's idiom: `--ran` reports "70 derived famil(ies) accounted for — 66 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)". All 66 that ran exited 0, including `check-changeset-no-major --base origin/main`, `check-adr-0087-registration --base origin/main`, `check:doc-authoring`, `check:issue-citations` and `check:cross-package-test-inputs`. - The four exit-3 families each had a prerequisite missing. Three were re-run after fixing it, each exit 0: `check-plugin-teardown-shape --self-test` (needed `git fetch --unshallow`), `check:docs-transcript-drift` (needed the built lint) and `check:lean-entry-closure` (needed the built objectql). These re-runs were by hand, outside the `--ran` record. - `check:dual-build-cjs-loads` was not measured locally: it reads every package's `dist/`, which needs a full build. CI's `Build Core` job runs it on this PR. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (spec untouched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (eslint on the changed files). - [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: n/a. - [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 (the 维护者速读 block is the maintainer's Chinese brief). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. ## Read first 1. `packages/lint/src/validate-knowledge-source.ts`: `documentUnitRefusal` and the call site after `judgeMembers('metadataFields')`. 2. `packages/services/service-knowledge/src/knowledge-search-scope.ts`: `parentLinkRule` / `documentUnitOf`, the save door's rule this one restates. **Two-minute check:** `pnpm --filter @objectstack/lint exec vitest run src/validate-knowledge-source.document-by.test.ts`. Expect 17 passed. Dogfood: n/a (no `!` in the title, no `(narrowing)` arm). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD <!-- signed: repo:objectstack#2 · os-warren · session_01JQwxbWsSJprjGydwaCH1gD --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Fixes #38630
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #38655
维护者速读
What changes
ctx.api.object(X)now installsupdateByIdamong itsWRITEleaves (installCtx), behind the sameapi.writecapability gate. It forwards by name to the host's scoped repository, as every leaf does; no per-method argument mapping was needed.updateById's id argument is judged at the crossing, before the host is called (ID_ARGUMENT_INDEX,refuseNonScalarIdArgument). Anything but a non-empty string or a non-zero number is refused asVALIDATION_ERROR/ 400 with a sentence naming the call, the shape it was given, and the bulk form (update(data, { where, multi: true })).0and''are refused becauseHookObjectApi.updateByIdalready declares them a refusal (they identify no row).objectstack build'sapi.writeinference namesupdateById(theapi.writeregex andOBJECT_WRITE_LEAVES), so a lowered handler whose only write isupdateByIdis granted the call. The word boundary matters:update\bdoes not match insideupdateById.SANDBOX_API_WRITE_METHODSgainsupdateById; its existing pin to the runner'sWRITElist holds with both sides moved.action-body-write-capability-undeclaredtherefore finds an ungrantedupdateByIdcall.BODY_WRITE_METHODSinpackages/spec/src/identity/identity-assignment-body-writes.ts, the list that names itself the runner'sapi.writeset, gainsupdateById. SoHookSchemaandActionSchemarefuse an elevated body (arunAs: 'system'hook, ascriptaction) that writessys_user_position,sys_user_permission_set,sys_invitationorsys_memberthroughupdateById, as they refuse the other write calls. Before this change the call threwTypeError: not a functionin the sandbox; now that it is installed, the run-time refusal (plugin-security's data middleware) refuses the write as well.!,Clause-②: no (narrowing),Metadata-protocol: narrowed). At save and inos validate: an action body callingupdateByIdwithoutapi.writeis refused asaction-body-write-capability-undeclared(FROM saved and threw at every run → TO declareapi.write), and the elevated identity-assignment write above is refused atbody.source. Neither body ever worked. ADR-0087:registered— the new v19 entryhook-action-body-system-identity-assignment-update-by-id-refusedfor the identity-assignment door, beside the existingpublish-refuses-seeds-and-actions-that-save-and-do-not-workthat covers the ungrantedapi.writewrite.updateByIdis not one: theos explain action-body-write-capability-undeclaredparagraph (rule-explanations.ts, it said "the sixctx.apiwrite leaves") and the build's.create()refusal (extract-hook-body.ts). Both now listupdateById; "six" is dropped.validate-hook-body-writes.ts(API_WRITE_METHODSnote),validate-action-body-writes.ts(two comments that said a body has noupdateById; the hint itself is unchanged) andauthoring-rules.ts, and the two docs lists (content/docs/automation/hook-bodies.mdx, the.create()paragraph;content/docs/deployment/validating-metadata.mdx, the rule's row).content/docs/automation/hook-bodies.mdx, theapi.writerow of the Capability inference table now readsinsert / update / updateById / updateMany / upsert / delete / deleteMany / patch / remove / create, the alternationextract-hook-body.tsmatches.updateByIdis new here.updateManyanddeleteManywere already inferred, and the row had omitted them before this PR; they are fixed in the same row.packages/spec/src/migrations/entries/semantic/19.hook-action-body-system-identity-assignment-update-by-id-refused.tsrecords that a save now refuses an elevated body (arunAs: 'system'hook or ascriptaction) that writessys_user_position,sys_user_permission_set,sys_invitationorsys_memberthroughupdateById, a call that threwTypeError: not a functionbefore this release. The v18 entryhook-action-body-system-identity-assignment-write-refusedis unchanged: in v18updateByIdwas never refused, it threw. The protocol upgrade guide is projected from the registries bygen:upgrade-guideinto the gitignoredcontent/docs/protocol-upgrade/; nothing generated is committed.rule-explanations.ts~1365 / ~1376 / ~1838 andvalidate-hook-body-writes.ts~246 / ~256 nameupdateByIdas a write channel; with the leaf installed each is true, so none is edited. Thehook-bodies.mdxsnippet is now true, and theaction-record-write-discardedhint (update({ id: ctx.recordId, … })) stays.Measured before the change, and what the host does with a non-scalar id
Probe on real
ObjectQL+ better-sqlite3SqlDriver+QuickJSScriptRunner, atorigin/mainf3028c5 (throwaway file, not committed):The host repository called in-process (
ScopedContext.object('ubi_deal').updateById(id, …)), two rows seeded: every non-scalar or falsy id was refused by the engine and no row moved. The messages are about filters oroptions.multi, and several carry no code:{ $ne: null },{ $in: [id] },null,'',0,NaN,trueError: Update requires an ID or options.multi=true(no code){}INVALID_FILTER/ 400 (empty object atwhere.id)[id]INVALID_FILTER/ 400 (array comparand atwhere.id)undefinedINVALID_FILTER/ 400 (undefined comparand atwhere.id)So no shape reaches a wider write than one row today; the guard turns each into one coded refusal before the engine is called. After the change, same probe:
updateByIdwritesA=won, anullid answersVALIDATION_ERROR/ 400 withctx.api.object('ubi_deal').updateById(id, data) needs the id of one record (a non-empty string or a non-zero number) and was given null, so nothing was written.Tests
packages/runtime/src/sandbox/body-update-by-id.integration.test.ts(new, real runner): an action body and a hook body callingupdateById(id, patch)write that row and only that row (before/after reads of both rows); a control onupdate({ id, … })on both faces; theapi.writegate (INSUFFICIENT_PRIVILEGES/ 403, nothing written); one case per refused id shape (operator object, array,null,undefined,'',0), each assertingcode+status, noupdatereaching the engine (an engine middleware counts them) and no row moved; and a hook body that catches the coded refusal.packages/cli/test/extract-hook-body.test.ts:updateByIdalone infers exactly['api.write'], directly and on a bound handle; the.create()refusal's leaf list.packages/spec/src/identity/identity-assignment-body-writes.test.ts:updateByIdjoins the per-method battery (every quote form, all four objects); arunAs: 'system'hook and a script action writingsys_user_positionthroughupdateByIdare refused atbody.sourcewith their sentence; CONTROL: the same call oncrm_accountparses on both faces.packages/lint/src/validate-action-body-capabilities.test.ts: an ungrantedupdateByIdis refused and named; granted, it passes. The runner-list pin is unchanged and green with both lists moved.Readings
Test Files 1 passed (1),Tests 11 passed (11).scripts/ablation-replace.mjs, anchor x1 → x0, blob b52e071075c9 → a62699b7b677):Tests 10 failed | 1 passed (11), the one green being theupdate({ id })control; restored, blob == HEAD,git diff HEADempty.Tests 7 failed | 4 passed (11), the seven guard cases red (expected undefined to be 'VALIDATION_ERROR',expected 'INVALID_FILTER' to be 'VALIDATION_ERROR'), the write pins, control and gate green; restored,git diff HEADempty.@objectstack/clitest/extract-hook-body.test.ts:Tests 67 passed (67).@objectstack/lintwhole suite:Test Files 246 passed (246),Tests 9960 passed (9960).pnpm --filter @objectstack/runtime --filter @objectstack/cli --filter @objectstack/lint typecheck: VERDICT command-exit 0.@objectstack/specwhole suite at f7b947f:Test Files 1007 passed (1007),Tests 30504 passed | 1 todo (30505).updateByIdremoved from the spec'sBODY_WRITE_METHODS(blob 408d74efe3cc → b126506e753a):Tests 6 failed | 25 passed (31)inidentity-assignment-body-writes.test.ts, the four per-object method batteries and the twoupdateByIdrefusals red, thecrm_accountcontrol green; restored, blob == HEAD,git diff HEADempty.@objectstack/lintwhole suite at f7b947f:Test Files 246 passed (246),Tests 9960 passed (9960).check-adr-0087-registration --base origin/mainexits 0 (registered hook-action-body-system-identity-assignment-update-by-id-refused, publish-refuses-seeds-and-actions-that-save-and-do-not-work;1 migration entry added, each at or above PROTOCOL_MAJOR 19);check:spec-changesandcheck:upgrade-guidegenerate in memory (protocol 19.0.0);gen:upgrade-guidewrites the docs pages and19.mdcarries the entry;check:generatedafter a spec build:All 14 generated artifacts are up to date; the spec migrations, registry and upgrade-guide tests:Test Files 8 passed (8),Tests 246 passed (246); clitest/migrate-meta-engine-guidance.test.ts:Tests 3 passed (3);check-changeset-no-major --eventwith this PR's body: exit 0;overlap-check --branch=HEAD: VERDICT clean.@objectstack/specpnpm test(local project) at 8e38653:Test Files 913 passed (913),Tests 28896 passed | 1 todo (28897); the upgrade-guide span and docs tests with the migrations tests:Test Files 7 passed (7),Tests 239 passed (239).dispatch-gates --ranat 8e38653: 124 derived, 124 run, 0 UNRUN; every family exit 0 once the cli and formula closures were built.dispatch-gates --commandsderives forcontent/docs/automation/hook-bodies.mdxall exit 0, among themcheck:doc-anchors(1179 fragment links resolve),check:docs-spec-enumerations,check:doc-security-postureandcheck:doc-formula-expressions;overlap-check --branch=HEAD: VERDICT clean.TypeError: not a functionbefore this change.pnpm --filter @objectstack/dogfood test, no shard, at f7b947f): VERDICT command-exit 0,Test Files 495 passed | 3 skipped (498),Tests 4187 passed | 68 skipped (4255).dispatch-gates --ran: 121 derived, 121 run, 0 UNRUN. Four exited 3 for a prerequisite, not a finding:check-plugin-teardown-shape --self-test(shallow clone),check:skill-examples(client-react dist not built),check:dual-build-cjs-loads;check:type-check-debtre-run under the lock afterwards:OK — 0 ledger entr(ies) re-measured … none above its recorded number. CI'sType Check · debt ledgeris green.Acceptance notes
updateById: none, so nothing in this repository is newly refused.Verification
Read first, by risk:
packages/runtime/src/sandbox/quickjs-runner.ts:refuseNonScalarIdArgumentand its call at the top ofinstallApiMethod's leaf.packages/runtime/src/sandbox/body-update-by-id.integration.test.ts: the refused-shape table.packages/cli/src/utils/extract-hook-body.ts: theapi.writealternation.Two-minute check:
pnpm --filter @objectstack/runtime exec vitest run --project local src/sandbox/body-update-by-id.integration.test.tsprintsTests 11 passed (11).For the save-time narrowing:
pnpm --filter @objectstack/spec exec vitest run src/identity/identity-assignment-body-writes.test.tsprintsTests 31 passed (31).Generated by Claude Code