Repository navigation
fix(core)!: change owner answers what was saved when the owner or queue is locked, and notified reads the emit answer - #36683
Conversation
…e emit answer Each owner write passes strictReadonlyWrites, so a readonlyWhen lock that holds for the row refuses it (ERR_READONLY_FIELD_REJECTED) instead of committing without owner_id / queue and answering moved. notified is true only when the emit reports a delivered or an enqueued row. Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
…hunks Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
…ed over a real engine The engine's strict refusal reached the /data classification as a bare error and was answered 404 OBJECT_NOT_FOUND by its message heuristic; the owner write now answers it as the row's own refusal, as the record-file door does. Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
…ange-owner-readonly-when
…de branch's hunks Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
…tamping it as a constant Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 41 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 f75beabaa9c0347f419a04b72d48a7f43708cecb && git checkout f75beabaa9c0347f419a04b72d48a7f43708cecb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e343ab7c209c858ee5a7a1fa117baacf96a77229 c32cb7bd84657541b7abbbf52f9efc45f2ac819d && git checkout -B drift-repro e343ab7c209c858ee5a7a1fa117baacf96a77229 && git merge --no-ff c32cb7bd84657541b7abbbf52f9efc45f2ac819d
node scripts/docs-audit/affected-docs.mjs --json e343ab7c209c858ee5a7a1fa117baacf96a77229
|
|
repo:objectstack#7 · os-alice · session_011y7As6FyXmJyGyHNKXUkV7 Known red, blocked on a decision · 2026-11-23T11:32Z · head
|
…line (#36259) The change-owner door now pins FIELD_NOT_ACCESSIBLE at 403, so the census row shrinks by one. Run with --update on the maintainer's go-ahead (decision card in the seat thread, 2026-11-23T14:14Z: allow the seat to run --update). Claude-Session: https://claude.ai/code/session_011y7As5bdhV5T4N9vpjmZzH Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV Contract-review-claim: session_011y7As6YDLR8TJVDpdXzJyV · head 00ca61b · 2026-11-23T14:21Z L1-a review thread runs the narrowing-face contract review at CONTRACT_REVIEW_TIER on this head, in parallel with its L1. |
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV 维护者速读
席位核对Verdict: REWORK · head Reviewed against GitHub at this head (diff, card body and rulings, Checklist
REWORK items
Serial notes
|
…banner Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe narrowing makes the spec's own refusal real; it takes no declared capability away. A Attempts to break it, and what they found:
No must-fix, no should-fix. Nits, each left as an accepted deviation or a follow-up; none is fixed on this head outside the prose faces:
Implemented-by: VERDICT: PASS |
…what notified means The changeset names both halves of the narrowing and the caller's fix. Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV Contract-review-claim: session_011y7As6YDLR8TJVDpdXzJyV · head c32cb7b · 2026-11-23T20:00Z |
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNothing on the review surface moved, so the judgment of the earlier record stands unchanged: the narrowing makes the spec's own refusal real and takes no declared capability away. The declaration gap named in ② of the earlier record: closed. N6: closed (both pages now state the refusal and what No must-fix, no should-fix. Nits, unchanged or new, none fixed outside the prose faces:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV 维护者速读
席位核对 — ACCEPT · head c32cb7b · card #36259L2 record at this head: comment 7112452212 (PASS, REWORK items
Checklist
Accepted deviation
Out of scope, disposition
|
|
repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH Review request — declared narrowing (
|
#36683 landed first (writeOwner, strictReadonlyWrites, lockedOwnerRefusal, emit-answer notified); the single-record line keeps this branch's previousOwners read above main's writeOwner call. Claude-Session: https://claude.ai/code/session_01ADHkmRY38EZf38Yy3zthbY Co-authored-by: Claude <noreply@anthropic.com>
…d in the dialog (objectstack-ai#36525) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JpRoUZGqtwqMU5k7b4C58D)_ Fixes objectstack-ai#35315 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up objectstack-ai#36713 ## 维护者速读 - 用户能看到什么变化:在「更改负责人」对话框里,给某条记录换负责人时,可以勾选「同时转移相关记录」,把挂在它下面、原来归原负责人的相关记录一起转给新负责人。 - 为什么做:这是「负责人变更与离职交接」里你裁定的第二阶段(级联转移),按关系在子对象的引用字段上声明,对话框里勾选。 - 出错会怎样:只影响勾选了级联的更改负责人请求;每条相关记录都按操作人自己的转移权限逐条判断,转不动的逐条列出,不会悄悄跳过;不勾选时行为与现在完全一样,可以直接撤回。 - 要你做什么:无。 ## What changes Phase 2 of the ruled Change Owner direction: ruling 7000907189 point 4 (the maintainer: 「都同意」), as the claim (comment 7081809395) scoped it. **The declaration (spec).** `transferBehavior: 'none' | 'cascade'` on a field, beside `deleteBehavior`, default `none` (not materialized at parse). `'cascade'` on a child's reference field to a parent opts that relationship into the Change Owner cascade. Refused at parse where it could never act (ADR-0049): - `FieldSchema`: the key on any type but `lookup` / `master_detail` (`'none'` included, the `mailAssociation` precedent), `'cascade'` on a reference to a `sys_*` object, and `'cascade'` on a multi-value relationship (`multiple: true`), located at `transferBehavior`, the `lookupAutofill` precedent. A multi-value lookup stores its targets as one JSON array, which `driver-sql` refuses to compare by equality, so the cascade's child read could never find a row there; `'none'` stays accepted on it. - `ObjectSchema` (`refuseIneligibleTransferCascades`): `'cascade'` on a field of an object that does not offer Change Owner itself, per the new `transferCascadeIneligibilityReason` in `user-action-transfer.ts`: structurally ineligible, a `controlled_by_parent` detail (whatever its switch says: ruling point 4, its access already follows its master), or `userActions.transfer` off. The seat named the first two; the third is the same door, since a child whose switch is off is refused by the endpoint and the cascade could never run. Door choice: parse, not lint, following objectstack-ai#35401's precedent for `userActions.transfer` (the object-level facts are local to the declaring object, so parse sees everything it needs). The parent side (whether the referenced object offers Change Owner) is cross-object and is not judged at parse; the server simply never offers a cascade from an object that does not offer the action (`403 CHANGE_OWNER_DISABLED` first). **The server (core + rest).** The cascade is an optional leg of the two objectstack-ai#35402 requests, not a new write route: `cascade: [{ object, field }]` on `POST /data/:object/:id/change-owner` and `POST /data/:object/change-owner`. Reused: `UserWorkTransferOutcome` (each outcome extends it with `remaining` and `readFailure?`), `failureOf`, `USER_WORK_TRANSFER_ROW_CAP`. - Judged before any write: every named relationship must be in `transferCascadeRelations(engine, object)` (declared `cascade`, a single-value `lookup` / `master_detail` to `object`, child passing `transferCascadeIneligibilityReason`, child's package not disabled, child's declared API exposure serving `update`), named once, and only with a person target. A `multiple: true` reference is skipped there too, for a definition that reached the registry without the parse. Otherwise `400 VALIDATION_ERROR`, nothing written. So a relationship that is not declared is never cascaded. - Semantics: the ruled default, the only one. The parent's owner is read as the caller just before the move; for each parent that moved, the child rows that point at it and carry its previous owner go to the new owner, one by-id `update` each under the caller's context. The probe is grouped by previous owner: one `find` per (previous owner, relationship) with `{ field: { $in: parentIds }, owner_id: previousOwner }` (bare equality for one parent), so a bulk move of N records owned by K people reads K times per relationship, not N. Grouping changes no row's verdict: the reference is single-valued, so each child row points at one parent and falls in one group, whose key is exactly the owner the row must carry. So each row passes the caller's own transfer verdict on the child object (the owner guard in plugin-security), and a refused row is listed with its id, code and the `/data` door's sentence. A parent whose previous owner was nobody (a queue) or already the new owner cascades nothing. - Cap: one call cascades at most 500 child rows in total. Each relationship's outcome lists every row the caller's write refused (id, code, sentence); rows past the cap are not listed but counted in `remaining`; a relationship whose rows could not be read carries `readFailure` and none of its rows moved. - One read, `GET /data/:object/change-owner/cascades` (`data.changeOwnerCascades`), lists the candidates. It is a new route because the Console has no full object list on the record page (`RecordDetailView` deliberately does not load the registry), and only the server knows which children point at an object. It declares its closed query set (none), passes the same gates as the writes, and is in `rest-route-ledger.ts`. **The console.** `ChangeOwnerDialog`, for a person target, shows one tick per candidate on which the explain engine's object-level `transfer` operation is a definite allow (`useChangeOwnerCascadeCandidates`, reusing the list's `askObjectTransfer` cache). It computes no verdict itself. Ticks go into the request; each relationship's outcome is drawn, every refused row with the server's sentence. A single record whose cascade left anything behind keeps the dialog open on the report instead of toasting it away. Seven i18n keys in every locale. **Also.** `transferBehavior` classified in the FLS key table (`metadata-core`, `keep`) and the DDL key table (`driver-sql`, `presentation`), both with a `patch` changeset entry; `content/docs/api/data-api.mdx` documents the leg and the read: the refused rows, the capped count, `readFailure`, the two candidate filters (child API exposure without `update`, a disabled package) and the multi-value refusal. `transferCascadeIneligibilityReason` reads `sharingModel` only where `ObjectSchema` declares it, as `derivedTransferDefault` does. ## Tests <details><summary>Readings (filled at the final head)</summary> **Round 3, head `8eed0dffa8`** (`3fd28f0926` merge of `origin/main` over objectstack-ai#36683 at `ec545def5d`; `9394e8f46f` the cascade child write through `writeOwner`; `8eed0dffa8` changeset and API doc). Conflict: one, the single-record line in `change-record-owner.ts`, resolved to this branch's `previousOwners` read followed by main's `writeOwner` call; the test files and `data-api.mdx` merged without conflict. - `pnpm --filter @objectstack/core exec vitest run src/security/change-record-owner.test.ts`: `Tests 45 passed (45)`. New: a locked child (single and bulk) is listed under the relationship's `failures` as `FIELD_NOT_ACCESSIBLE`, keeps its owner, siblings move, every child write carries `strictReadonlyWrites: true`, the notice names the parent only. Whole core suite: `Tests 3735 passed`. - `pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-routes.test.ts`: `Tests 22 passed (22)`, among them a real ObjectQL + SQLite case with `owner_id.readonlyWhen` on the child: `200`, cascade `{ updated: 2, failed: 1 }`, the closed child refused `FIELD_NOT_ACCESSIBLE` and still on its old owner, one notice naming the parent. Whole rest suite: `Tests 8804 passed, 351 skipped`. - Ablation: the child write reverted to a bare `engine.update` through `scripts/ablation-replace.mjs`: core red 2 of 45, rest red 1 of 22 (the three new pins); restored with `blob == HEAD`, `git diff HEAD` empty, both green. - Typecheck `@objectstack/core`, `@objectstack/rest`: exit 0. `dispatch-gates.mjs`: 128 derived, 125 run exit 0, 3 NOT MEASURED locally (`check:skill-examples`, `check:dual-build-cjs-loads`, `check:i18n`), all three green in CI's `Lint & Repo Gates`. - The PR's check-runs at `8eed0dffa8`: 70, all completed, 61 success, 9 skipped (opt-in or conditional), none failed. Round 2 readings follow, at its own head. Head of the tested tree: `b17d3b639` (this round: `ff4a69996` code and pins, `b17d3b639` changeset, API doc and liveness note only; the source and test files are byte-identical between the two). Every run below went through `os-verify-lock.sh`, each `VERDICT command-exit 0`, unless marked. - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/data/field-transfer-behavior.test.ts src/data/user-action-transfer.test.ts src/data/field.test.ts src/data/object.test.ts`: exit 0, `Test Files 4 passed (4)`, `Tests 580 passed (580)` (one new case: `'cascade'` with `multiple: true` refused at `transferBehavior`, `'none'` accepted there, the single-value control accepted). - `pnpm --filter @objectstack/core exec vitest run --maxWorkers=2 src/security/change-record-owner.test.ts`: exit 0, `Tests 36 passed (36)`. New: the multi-value skip (not offered, a request naming it `400 VALIDATION_ERROR` before any write, single-value control offered), `readFailure` (child read throws, `readFailure.code` set, no child write, parent move stands), a queued parent with a null-owner child (untouched, `updated: 0`, no child read), the grouped probe (two `find` calls for three parents owned by two people, `{ lead: { $in: ['l1', 'l3'] }, owner_id: 'u_a' }` and `{ lead: 'l2', owner_id: 'u_b' }`), and the cap across a grouped read (`remaining` counts the row left, the refused row not twice). Whole core suite: `Test Files 164 passed (164)`, `Tests 3829 passed (3829)`. - `pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-routes.test.ts`: exit 0, `Tests 17 passed (17)`. - Typecheck `@objectstack/spec`, `@objectstack/core`, `@objectstack/rest`, `@objectstack/client`: each `Done`, exit 0. - Ablations, each one line through `scripts/ablation-replace.mjs` (anchor hit 1 to 0, blob moved), suite red, then restored with `blob == HEAD` and `git diff HEAD` empty: - delete `outcome.readFailure = { code, message };`: core red 1 of 36, the `readFailure` case; - `if (!previousOwner || previousOwner === newOwner)` to `if (previousOwner === newOwner)`: core red 1 of 36, the queued-parent case; - drop `&& f.multiple !== true` in `transferCascadeRelations`: core red 1 of 36, the multi-value case; - the `FieldSchema` multi-value branch to `else if (false)`: spec `field-transfer-behavior.test.ts` red 1 of 21. - `pnpm --filter @objectstack/spec check:generated --fix`: nothing stale (14 of 14 up to date, `check:liveness` among them). `check:liveness` alone: exit 0, the row's evidence anchors resolve. - `dispatch-gates.mjs` (stderr: tree `objectstack-ai/objectstack` at `b17d3b639`, 58 paths against merge base `c1e6cf75a`): 128 derived, `--ran` reconciles 128 of 128. 124 exit 0 on the first pass. Two refused for build state and exit 0 after building `@objectstack/client` and `@objectstack/client-react`: `check:skill-examples` (exit 3 then 0) and `pnpm --dir ui exec vitest run scripts/` (one file could not resolve the unbuilt client; that file re-run `Tests 15 passed (15)`, the other 171 files passed on the first pass). NOT MEASURED locally, exit 3 `PREREQUISITE NOT MET` (need the CLI and plugin closure, or a full build): `check:i18n`, `check:dual-build-cjs-loads`. CI ran both in `Lint & Repo Gates`: `success` at `b17d3b639`. - The PR's check-runs at `b17d3b639`: 70, all completed, none failed (`Lint & Repo Gates`, `TypeScript Type Check`, `Test Core`, `Build Core`, `Governed Surface Queue Guard`, `Lint UI`, `Type Check UI`, `Test UI`, `Build & E2E UI`, `Live E2E UI`, `Dogfood Regression Gate`, `Spec property liveness`, `Check Changeset`: `success`). - UI suites not re-run in this round: nothing under `ui/` changed since `a39661e4a`, where `changeOwner-35403.test.tsx` and the two census pins read `Tests 44 passed (44)`. </details> ## Acceptance notes - Phase 1 re-measured on main by reading the code at `dda5e74fd`: the record header's `sys_change_owner` entry (`RecordDetailView.tsx`), the form's read-only owner line (`FormOwnerLine` in `ModalForm.tsx` / `ObjectForm.tsx`), the list's bulk entry (`useListChangeOwnerOffered` in `ObjectView.tsx`). Not driven in a browser in this run. - The Studio field form and the object form's field rows offer `transferBehavior`, translated in all 11 metadata-form packs. - The liveness ledger row for `field.transferBehavior` is in `packages/spec/liveness/field.json` (status `live`, `verifiedAt` 2026-11-23, `evidenceScope` in-repo; evidence `change-record-owner.ts#transferCascadeRelations`, `field.zod.ts#transferBehavior`, `object.zod.ts#refuseIneligibleTransferCascades`; the two pinning test files are named in the row's `note`, the `renamedFrom` row's shape), and the liveness counts are regenerated. The maintainer authorised the row in the project chat at 2026-11-23T11:57Z: 「35315 同意」 (recorded on the card, comment 7100319120). `check:liveness` and `check:generated` are green; the known red is gone. - Seat 7's PR objectstack-ai#36683 landed first (`ec545def5d`), as the maintainer ruled. This branch merged over it in round 3, and the cascade's child write goes through the same `writeOwner`: a child whose `owner_id` is locked is listed under `failures` as `FIELD_NOT_ACCESSIBLE`, keeps its owner, and the parent's move stands. The narrowing of the Change Owner doors for a locked parent is objectstack-ai#36683's and is declared in its changeset. - A failed `count` after the cap is spent still reads as `remaining: 0` (the optional L1 nit). Marking it unknown changes the outcome's shape in core, rest and client, so it is left out of this round. - A `controlled_by_parent` detail is never a cascade child, whatever its own switch says: the seat accepted this strict reading of ruling point 4 as a deviation, recorded on objectstack-ai#35315. - Children's rows the caller cannot read are outside the cascade, as they are outside the caller's own list (the hand-over's rule); the dialog does not count them. ## Verification Read first, by risk: 1. `packages/core/src/security/change-record-owner.ts`: `cascadeRelationsOf` (the declared-only guard), `transferCascadeRelations` (the multi-value skip), `runCascade` (the grouped probe, cap, the child write through `writeOwner`, per-row failures, `remaining`, `readFailure`). 2. `packages/spec/src/data/object.zod.ts`: `refuseIneligibleTransferCascades`, and `transferCascadeIneligibilityReason` in `user-action-transfer.ts`. 3. `ui/packages/app-shell/src/views/changeOwner.ts`: `useChangeOwnerCascadeCandidates`. Two-minute check: `pnpm --filter @objectstack/core exec vitest run --maxWorkers=2 src/security/change-record-owner.test.ts`, expect `Tests 45 passed (45)`, the cascade cases among them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRY38EZf38Yy3zthbY <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRY38EZf38Yy3zthbY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
… 404 OBJECT_PACKAGE_DISABLED (objectstack-ai#36674) Fixes objectstack-ai#36261 Clause-②: yes (narrowing) — `@objectstack/core` gains the root export `objectPackageDisabledError`, and all three Change Owner doors newly answer `404 OBJECT_PACKAGE_DISABLED` for an object of a disabled package, which they answered `200` before Metadata-protocol: none Skills-docs: none — no page under `skills/` teaches Change Owner; the refusal carries the data door's own sentence, which names the fix ## 维护者速读 - 管理员停用某个软件包后,用户再也不能通过“更改负责人”去改这个包里对象的记录负责人,也不会再收到相关通知;之前可以改,改完还会发通知。 - 属于“停用软件包”这一组问题的收口:停用的包本应停止服务它的全部记录,数据接口早已拒绝,更改负责人这道门之前漏了。 - 有转移权限的用户在停用包的对象上点更改负责人,会收到“包已停用”的提示,记录及其关联子记录都不变,可选的关联列表也不再列出;重新启用包即恢复,可直接撤回本改动。 - 无 ## BREAKING For a caller that changes owners on a disabled package's object: - FROM: `POST /api/v1/data/:object/:id/change-owner` and `POST /api/v1/data/:object/change-owner` answered `200` for an object of a disabled package. The owner changed, a named cascade moved its child rows, and the notification was sent. `GET /api/v1/data/:object/change-owner/cascades` answered `200` with the object's cascade candidates. - TO: all three doors answer `404 OBJECT_PACKAGE_DISABLED`, and nothing is read, written or sent. To fix it, re-enable the package. ADR-0087 disposition (stated in full in the changeset's marker): not-required (no-migration-prescription). No schema key, stored row, registry key or authored value changes. The answer returns to what it was the moment the package is re-enabled. ## What changes - `packages/core/src/security/change-record-owner.ts`: `offeredDefinition` (shared by `changeRecordOwner` and `changeRecordsOwner`) now asks the engine registry's `isObjectPackageDisabled` right after the object resolves and BEFORE the Change Owner switch is read. An object of a disabled package is refused with the data door's own envelope: `code: 'OBJECT_PACKAGE_DISABLED'`, `status: 404`, `object`. Nothing is looked up, written or emitted. `ChangeOwnerEngine` picks `registry` from `UserWorkEngine`, the in-package precedent (`user-assigned-work.ts` `servedObjects`). - `packages/core/src/utils/object-package-disabled.ts` (new): the ONE constructor `objectPackageDisabledError`, moved down verbatim from `@objectstack/metadata-protocol` (`protocol-authoring-refusals.ts`) because core cannot import metadata-protocol (ADR-0076 D2 boundary). It follows the `objectNotFoundError` / `recordNotFoundError` precedent. `@objectstack/core` exports it, and metadata-protocol re-exports the same function under the same name, so its importers are unchanged. **Producer note:** this file and the metadata-protocol re-export sit outside the claimed surface (`packages/core/src/security/**`, `change-owner-routes.ts`). The only other option was a second copy of the refusal, which the constructor's own docblock forbids. - `packages/spec/src/api/error-code-ledger.zod.ts`: one provenance row, `OBJECT_PACKAGE_DISABLED` under `@objectstack/core`, beside `CHANGE_OWNER_DISABLED`. `check:error-code-provenance` requires it because the stamp site moved into core. No code is minted, and the union, status and wire shape are unchanged. - `content/docs/api/data-api.mdx`: both Change Owner sections, single and bulk, now document the `404 OBJECT_PACKAGE_DISABLED` refusal beside `403 CHANGE_OWNER_DISABLED`. - `.changeset/36261-change-owner-disabled-package.md`: declares the narrowing (the `(narrowing)` arm, `!` headline, BREAKING FROM/TO, `adr-0087` marker), following the same-class siblings 35195, 35427, 35525 and 35526. - REST, the two write doors: the thrown refusal reaches them through their existing `sendRefusal` → `handleRouteError` classification, which answers `404` with nested `error.code: OBJECT_PACKAGE_DISABLED`. - REST, the third door `GET …/change-owner/cascades` (added on main by objectstack-ai#36525): it reads `getSchema` and `changeOwnerOffReason` directly, so the core check did not reach it. `change-owner-routes.ts` now asks the same registry predicate in the same order (after the object resolves, before the switch) and throws the same `objectPackageDisabledError`. A request naming a cascade on the write doors is refused by core's `offeredDefinition` before `cascadeRelationsOf`, any previous-owner read, and any parent or child write. ## Tests - `packages/core/src/security/change-record-owner.test.ts`, new top-level `describe('[objectstack-ai#36261] an object of a disabled package')`: - single → 404 `OBJECT_PACKAGE_DISABLED`; `engine.calls` is empty (no find, no update), `messaging.emit` was not called, and the row is unchanged; - bulk → the same; - a switched-off object (`pinned_lead`) of a disabled package answers the package refusal, not `CHANGE_OWNER_DISABLED`. This shows the check runs before the switch; - control: the same object with its package enabled moves, single and bulk. - `packages/rest/src/change-owner-routes.test.ts`, new top-level `describe('[objectstack-ai#36261] …')`: - the single and bulk doors answer `404` with `error.code === 'OBJECT_PACKAGE_DISABLED'`, `engine.update` is not called and `emit` is not called; - control: package enabled → 200 for both, and the predicate was asked. ## Acceptance notes - Ablation (core pin, subject resolved from `src` by relative import, no dist leg needed): `node scripts/ablation-replace.mjs --delete` on the check line. The anchor went 1 → 0 and the blob 3797018 → 9993c0ad4202. Three pins went red (single, bulk, before-the-switch; `Tests 3 failed | 23 passed (26)`). The file was restored with blob == HEAD and an empty `git diff HEAD`. - Read-only observations, not filed: - `packages/services/service-analytics/src/api-exposure-door.ts:202` carries its own copy of `objectPackageDisabledError`. It could now import core's, but that is outside this card. - The card's note that `recycle-bin-routes.ts` reaches the engine without a package check was not verified here. It is the same family as the disabled-packages topic. ## Verification <details><summary>Targeted pins, ablation, package suites, typecheck</summary> Rework round 3, head `de5633e6`. `origin/main` was merged twice: objectstack-ai#36683 in 499e92e and objectstack-ai#36525 in d371d69. Conflicts were test-double and describe hunks only, with both sides kept (named in the merge commits). New pins: - core: a request naming a cascade, single and bulk, is refused 404 with no call at all; - rest: the cascades read answers 404 when the package is disabled and lists the candidates when it is enabled; a single POST naming a cascade answers 404 with no parent or child write. Ablations at this head: - core check: 4 red (single, bulk, before-switch, cascade), restored to the HEAD blob; - cascades-read check in `change-owner-routes.ts`: 1 red (the cascades read pin), restored to the HEAD blob. Pins: core `Tests 50 passed (50)`, rest `Tests 27 passed (27)`. Typecheck core and rest exit 0. The dogfood battery and gate readings for this head are in the round-3 os-dev-report comment on the card. Rework round 1, head `1741fd74`: the changeset and docs changed, no code. Dogfood battery and delta gates: see the os-dev-report comment on the card for this round. Readings on head `ab42e688`. The package suites ran at `74da4908` (code + pins). The later commits touch only `packages/spec` and the changeset, which were re-measured below. - Build closure: `pnpm --filter '@objectstack/rest^...' --filter @objectstack/rest build` returned `VERDICT command-exit 0`. - Targeted pins: core `change-record-owner.test.ts` `Tests 26 passed (26)`; rest `change-owner-routes.test.ts` `Tests 17 passed (17)`. - Ablation: described above (3 red, then restored to the HEAD blob). - `pnpm --filter @objectstack/core test`: `Test Files 156 passed (156)`, `Tests 3711 passed (3711)`, exit 0. - `pnpm --filter @objectstack/metadata-protocol test`: `Test Files 365 passed | 9 skipped (374)`, `Tests 23352 passed | 45 skipped`, exit 0. - `pnpm --filter @objectstack/rest test`: `Test Files 427 passed (427)`, `Tests 8791 passed | 351 skipped`, exit 0. - `typecheck` for core, metadata-protocol and rest: `VERDICT command-exit 0`. - spec ledger tests (`error-code-ledger`, `api-error-code-type`, `retired-error-codes`, `check-error-code-provenance`): `Tests 59 passed (59)`. - `check:error-code-provenance`: `OK — every registered-code stamp site is listed under its own owner key …` (583 listed, 24 waived). - `pnpm --filter @objectstack/spec check:generated`: exit 0. - Derived gate families: 96 derived and 96 run (`dispatch-gates --ran`). Every family exited 0 except two that were NOT MEASURED: - `check-plugin-teardown-shape --self-test` exited 3: shallow clone, and its positive-control commit is unreachable. This is checker-health only. - `check:dual-build-cjs-loads` exited 3: `PREREQUISITE NOT MET`, because ~48 packages have no `dist/` without a full build. CI runs it. </details> Two-minute check: `pnpm --filter @objectstack/core exec vitest run --maxWorkers=2 src/security/change-record-owner.test.ts`. Expect `Tests 26 passed (26)`, including the four `[objectstack-ai#36261]` cases. Read first, by risk: 1. `packages/core/src/security/change-record-owner.ts`, the `offeredDefinition` hunk (the order of the check against the switch). 2. `packages/metadata-protocol/src/protocol-authoring-refusals.ts`, the constructor replaced by a re-export (identity of the data door's refusal). 3. `packages/spec/src/api/error-code-ledger.zod.ts`, the new core provenance row. --- _Generated by [Claude Code](https://claude.ai/code/session_011y7As5bdhV5T4N9vpjmZzH)_ <!-- signed: repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #36259
Clause-②: no (narrowing: the single Change Owner door answers
403 FIELD_NOT_ACCESSIBLEwhere it answered200, and the bulk door lists underfailuresa record it reported moved, when the record'sowner_idorqueueis locked;notifiedisfalsewhere no delivery or outbox row was taken; a customChangeOwnerMessaging.emitmust now return{ delivered, enqueued })Metadata-protocol: none
Skills-docs: updated here —
content/docs/api/data-api.mdx(the locked-owner refusal on both Change Owner routes, and whatnotifiedmeans) and theFIELD_NOT_ACCESSIBLEentry incontent/docs/api/error-catalog.mdx; no page underskills/teaches Change Owner's answers维护者速读
BREAKING
In two halves.
owner_idorqueueis locked (read-only, or under areadonlyWhencondition that holds for the record; a staticreadonlyqueue is refused too). FROM:POST /api/v1/data/:object/:id/change-owneranswered200, andPOST /api/v1/data/:object/change-ownercounted the record underupdated, while the stored owner did not change;notifiedwastruewhenever the messaging service'semitreturned. TO: nothing is written for that record; the single door answers403 FIELD_NOT_ACCESSIBLEnaming the locked column, the bulk door lists it underfailureswithFIELD_NOT_ACCESSIBLE, and no notification is sent for it;notifiedisfalsewherever no delivery or outbox row was taken (a muted topic, an unavailable channel).ChangeOwnerMessagingfrom@objectstack/core's security entry. FROM:emitcould resolve any value. TO: a customemitmust return{ delivered, enqueued }, the counts the messaging service'sEmitResultalready carries.403 FIELD_NOT_ACCESSIBLEanswer and thefailuresrow (change the record so the lock no longer holds, or remove the lock from the field, then change the owner again); (b) return the two counts{ delivered, enqueued }from a customemit.not-required (no-migration-prescription); nothing stored or authorable moves.What changes
packages/core/src/security/change-record-owner.ts: every owner write (single and bulk) now goes throughwriteOwner, a by-id update under the caller's context withstrictReadonlyWrites: true. A lock onowner_idorqueuefor the row (read-only, or areadonlyWhencondition that holds) makes the engine refuse the write before anything is written;writeOwneranswers that refusal as the row's own:403 FIELD_NOT_ACCESSIBLE, naming the locked column(s) (the record-file door answers the same engine refusal the same way). The single form throws it; the bulk form lists the row underfailureswith that code and keeps moving the others; no notification names a row that did not move. A queue target writes both keys, so a lock on either leaves both unchanged.notifiedis read off the messaging service's answer:trueonly when the emit reportsdelivered > 0orenqueued > 0.ChangeOwnerMessaging.emitnow declares the slice ofEmitResultit reads (ChangeOwnerEmitResult).content/docs/api/data-api.mdx(both Change Owner routes: the locked-owner refusal, and whatnotifiedmeans) and theFIELD_NOT_ACCESSIBLEentry ofcontent/docs/api/error-catalog.mdx.scripts/error-status-unpinned-baseline.json: theFIELD_NOT_ACCESSIBLErow removed (see Acceptance notes 1).change-owner-routes.tsanswers the refusal through its existing classification, because the refusal now declares its status.Why the mapping lives in core and not the route: the engine's bare
ERR_READONLY_FIELD_REJECTEDcarries no status, and the shared/dataclassification answered it404 OBJECT_NOT_FOUND(its message names the object in quotes and contains "not", which the unknown-object message heuristic matches). Measured on this branch at c3a6553, before the mapping existed.Tests
packages/core/src/security/change-record-owner.test.ts(fake engine that strips a locked key, or refuses understrictReadonlyWritesas the engine does): single refusal, bulk failure row, all-locked bulk sends no notice, queue target with a locked owner (single and bulk), an unlocked control;notifiedfalse on zero delivered and zero enqueued (single and bulk), true on either count; every owner write asserted to pass the flag.packages/rest/src/change-owner-routes.test.ts, new top-level describe over a REALObjectQL+ SQLite:memory:withowner_id.readonlyWhen: "record.status == 'closed'": single answers403 FIELD_NOT_ACCESSIBLE(not 200), stored owner unchanged, no emit; bulk lists the closed row underfailures, moves the open rows, one notice naming only them; queue target refused with owner and queue both unchanged in the stored row; an emit answering zero of both givesnotified: falsewhile the move stands. Existing route pins updated for the new option and a real emit answer.Acceptance notes
scripts/error-status-unpinned-baseline.json: theFIELD_NOT_ACCESSIBLErow is removed (shrink only), because this PR's producer now pins its documented 403. Done by the seat with the gate's maintainer-only--updateunder the maintainer's option A (ruling comment 7103795578 on change owner: answers 'moved' and notifies the new owner when a readonlyWhen lock kept owner_id unchanged; notified is true whenever emit returns #36259), commit 00ca61b.packages/types/src/data-error-classification.ts,looksLikeUnknownObject) answers any bareERR_READONLY_FIELD_REJECTEDas404 OBJECT_NOT_FOUND. No REST door passesstrictReadonlyWritesafter this PR, so no public door reaches it; noted, not filed.content/docs/api/data-api.mdx; feat: Change Owner cascade, transferBehavior on a relationship, ticked in the dialog #36525 conflicts on the single-record update line inchange-record-owner.ts). The feat: Change Owner cascade, transferBehavior on a relationship, ticked in the dialog #36525 cascade child update is a second owner write that will need the sameOWNER_WRITE_OPTIONSonce both land; whoever lands second carries that.Verification
Two-minute check:
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-routes.test.tsafter building@objectstack/core(the rest suite reads core'sdist/); expect 18/18, including the four real-engine pins.Read first (by risk):
writeOwner/lockedOwnerRefusalinchange-record-owner.ts;emitReachedSomeone; the real-engine describe inchange-owner-routes.test.ts.Readings (code at ed59773; the later commits 00ca61b, 4cd6965 and c32cb7b change only the baseline row, the changeset and two docs pages)
pnpm --filter @objectstack/core test: Test Files 156 passed (156), Tests 3714 passed (3714).pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-routes.test.ts: Test Files 1 passed (1), Tests 18 passed (18).pnpm --filter @objectstack/core typecheck,pnpm --filter @objectstack/rest typecheck: exit 0.Dogfood battery (head c32cb7b)
pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build(lock VERDICT command-exit 0), thenpnpm --filter @objectstack/dogfood testunder the lock, no shard, no path: VERDICT command-exit 0 · Test Files 487 passed, 3 skipped (490) · Tests 4121 passed, 68 skipped (4189) · no failure.Changeset and docs gates (head c32cb7b)
pnpm check:adr-0087-registration: exit 0,[BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription).pnpm check:error-status-conformance,pnpm check:doc-authoring,pnpm --filter @objectstack/spec run check:docs, the docs-audit and docs families the two pages derive: exit 0.pnpm --filter @objectstack/spec run check:skill-examples: exit 3, not measured locally (the client SDK packages are not built in this tree); CI carries it.Ablation (drop strictReadonlyWrites from the owner writes)
Taken at 36b626d; the later commits move the real-engine describe within its file and read the engine code inline, and leave the ablated line unchanged.
Mutation through
scripts/ablation-replace.mjs: anchorconst OWNER_WRITE_OPTIONS = { strictReadonlyWrites: true } as const;x1 to x0, replacement x0 to x1, blob 3078e5bd8d6f to 7ea0d78d9da5; core rebuilt;ablation-dist-preflight.mjs @objectstack/core 'strictReadonlyWrites: true' --absent: marker absent from all 20 built files.Restore: blob after restore == HEAD (3078e5bd8d6f),
git diff HEADempty; core rebuilt; preflight without--absent: marker present in 2 built files; both suites green again (above).Generated by Claude Code