Skip to content

fix(core)!: change owner answers what was saved when the owner or queue is locked, and notified reads the emit answer - #36683

Merged
os-zhuang merged 10 commits into
mainfrom
claude/issue-36259-change-owner-readonly-when
Nov 23, 2026
Merged

os-zhuang merged 10 commits into
mainfrom
claude/issue-36259-change-owner-readonly-when

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #36259

Clause-②: no (narrowing: the single Change Owner door answers 403 FIELD_NOT_ACCESSIBLE where it answered 200, and the bulk door lists under failures a record it reported moved, when the record's owner_id or queue is locked; notified is false where no delivery or outbox row was taken; a custom ChangeOwnerMessaging.emit must 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 what notified means) and the FIELD_NOT_ACCESSIBLE entry in content/docs/api/error-catalog.mdx; no page under skills/ teaches Change Owner's answers

维护者速读

  • 用户在“更改负责人”时,若对象在某条件下锁定了负责人字段(例如工单关闭后负责人只读),以前会提示“已转移”并通知新负责人,现在单条操作直接拒绝并说明哪一列被锁定,批量操作把这一条列入失败清单,也不再发出通知;通知是否送达也改为按消息服务的真实回执判断。
  • 属于“记录负责人转移”这条能力,替管理员和业务用户解决“系统说转了其实没转、同事收到不属于自己的记录通知”的问题。
  • 出错时最坏情况是本该能转移的记录被拒绝转移(用户会看到明确的拒绝提示,不会静默丢失);改动只在服务端,撤回即恢复旧行为。
  • 无。

BREAKING

In two halves.

  • (a) Both Change Owner doors, for a record whose owner_id or queue is locked (read-only, or under a readonlyWhen condition that holds for the record; a static readonly queue is refused too). FROM: POST /api/v1/data/:object/:id/change-owner answered 200, and POST /api/v1/data/:object/change-owner counted the record under updated, while the stored owner did not change; notified was true whenever the messaging service's emit returned. TO: nothing is written for that record; the single door answers 403 FIELD_NOT_ACCESSIBLE naming the locked column, the bulk door lists it under failures with FIELD_NOT_ACCESSIBLE, and no notification is sent for it; notified is false wherever no delivery or outbox row was taken (a muted topic, an unavailable channel).
  • (b) Code that implements ChangeOwnerMessaging from @objectstack/core's security entry. FROM: emit could resolve any value. TO: a custom emit must return { delivered, enqueued }, the counts the messaging service's EmitResult already carries.
  • The fix for a caller: (a) handle the 403 FIELD_NOT_ACCESSIBLE answer and the failures row (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 custom emit.
  • ADR-0087 disposition (in the changeset): 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 through writeOwner, a by-id update under the caller's context with strictReadonlyWrites: true. A lock on owner_id or queue for the row (read-only, or a readonlyWhen condition that holds) makes the engine refuse the write before anything is written; writeOwner answers 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 under failures with 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.
  • notified is read off the messaging service's answer: true only when the emit reports delivered > 0 or enqueued > 0. ChangeOwnerMessaging.emit now declares the slice of EmitResult it reads (ChangeOwnerEmitResult).
  • Docs: content/docs/api/data-api.mdx (both Change Owner routes: the locked-owner refusal, and what notified means) and the FIELD_NOT_ACCESSIBLE entry of content/docs/api/error-catalog.mdx.
  • scripts/error-status-unpinned-baseline.json: the FIELD_NOT_ACCESSIBLE row removed (see Acceptance notes 1).
  • The console: the default record form never renders owner_id, and the console has no Change Owner action, so an object without an authored form cannot be reassigned #35315 rulings stand: per-row by-id updates under the caller's context, every failure reported with its row id in the existing report shape, the row cap unchanged. No route code changed: change-owner-routes.ts answers 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_REJECTED carries no status, and the shared /data classification answered it 404 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 under strictReadonlyWrites as 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; notified false 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 REAL ObjectQL + SQLite :memory: with owner_id.readonlyWhen: "record.status == 'closed'": single answers 403 FIELD_NOT_ACCESSIBLE (not 200), stored owner unchanged, no emit; bulk lists the closed row under failures, 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 gives notified: false while the move stands. Existing route pins updated for the new option and a real emit answer.

Acceptance notes

  1. scripts/error-status-unpinned-baseline.json: the FIELD_NOT_ACCESSIBLE row is removed (shrink only), because this PR's producer now pins its documented 403. Done by the seat with the gate's maintainer-only --update under 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.
  2. The shared classifier (packages/types/src/data-error-classification.ts, looksLikeUnknownObject) answers any bare ERR_READONLY_FIELD_REJECTED as 404 OBJECT_NOT_FOUND. No REST door passes strictReadonlyWrites after this PR, so no public door reaches it; noted, not filed.
  3. Open drafts feat: Change Owner cascade, transferBehavior on a relationship, ticked in the dialog #36525 (cascade) and fix(core)!: Change Owner refuses an object of a disabled package with 404 OBJECT_PACKAGE_DISABLED #36674 edit the same files: overlap-check at c32cb7b reports a textual conflict with each (both also share 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 in change-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 same OWNER_WRITE_OPTIONS once both land; whoever lands second carries that.
  4. The refusal sentence is English, like every other refusal in this module.

Verification

Two-minute check: pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-routes.test.ts after building @objectstack/core (the rest suite reads core's dist/); expect 18/18, including the four real-engine pins.

Read first (by risk): writeOwner / lockedOwnerRefusal in change-record-owner.ts; emitReachedSomeone; the real-engine describe in change-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), then pnpm --filter @objectstack/dogfood test under 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: anchor const 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.

  • core suite: Tests 6 failed / 23 passed (the four readonlyWhen pins and the two flag assertions red; the notified pins stay green, as they test the emit answer).
  • rest suite: Tests 6 failed / 12 passed (the three real-engine readonlyWhen pins and three option assertions red).

Restore: blob after restore == HEAD (3078e5bd8d6f), git diff HEAD empty; core rebuilt; preflight without --absent: marker present in 2 built files; both suites green again (above).


Generated by Claude Code

…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>
…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>
…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>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/core, touching 17 documentable anchor(s).

6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/connect-mcp.mdx (via FIELD_NOT_ACCESSIBLE (literal, a string literal in lockedOwnerRefusal))
  • content/docs/api/data-api.mdx (via FIELD_NOT_ACCESSIBLE (literal, a string literal in lockedOwnerRefusal), /:object/:id/change-owner (route, bridged from symbol changeRecordOwner — its route source's handler names it), /:object/change-owner (route, bridged from symbol changeRecordsOwner — its route source's handler names it))
  • content/docs/api/error-catalog.mdx (via FIELD_NOT_ACCESSIBLE (literal, a string literal in lockedOwnerRefusal))
  • content/docs/data-modeling/field-types.mdx (via ERR_READONLY_FIELD_REJECTED (literal, a string literal in lockedOwnerRefusal))
  • content/docs/data-modeling/validation-rules.mdx (via ERR_READONLY_FIELD_REJECTED (literal, a string literal in lockedOwnerRefusal))
  • content/docs/kernel/contracts/data-engine.mdx (via ERR_READONLY_FIELD_REJECTED (literal, a string literal in lockedOwnerRefusal))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-6.mdx (via ERR_READONLY_FIELD_REJECTED (literal, a string literal in lockedOwnerRefusal))
  • content/docs/releases/v18/18-5.mdx (via FIELD_NOT_ACCESSIBLE (literal, a string literal in lockedOwnerRefusal))
  • content/docs/releases/v18/18-6.mdx (via ERR_READONLY_FIELD_REJECTED (literal, a string literal in lockedOwnerRefusal))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 68 of 251 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 41 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json e343ab7c209c858ee5a7a1fa117baacf96a77229 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from f75beabaa9c0347f419a04b72d48a7f43708cecb — the merge of head c32cb7bd84657541b7abbbf52f9efc45f2ac819d into base e343ab7c209c858ee5a7a1fa117baacf96a77229, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs e343ab7c209c858ee5a7a1fa117baacf96a77229 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6FyXmJyGyHNKXUkV7

Known red, blocked on a decision · 2026-11-23T11:32Z · head ed59773d32

  • Failing: Lint · docs & code guards, step "Documented HTTP status matches the status the runtime emits" (check:error-status-conformance), and Lint & Repo Gates, the lane verdict that rolls it up. Cause: this PR now pins FIELD_NOT_ACCESSIBLE at 403 while scripts/error-status-unpinned-baseline.json still lists it as unpinned. The red comes from this PR. It is not a flake.
  • Blocker: the baseline's --update is maintainer-only. Which way to go (shrink the row, answer PERMISSION_DENIED, or declare a status for ERR_READONLY_FIELD_REJECTED) is with the maintainer through seat 7, from the os-dev-report 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 (7099512890). Nothing is pushed until it is answered, and the PR stays draft.

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV

维护者速读

  • 结论:退回修改(REWORK),只需改文字面,代码不动。修复本身对:负责人字段被条件锁住时,“更改负责人”不再谎报成功、不再误发通知;“已通知”只在真的送达时为真。
  • 问题与 fix(core)!: Change Owner refuses an object of a disabled package with 404 OBJECT_PACKAGE_DISABLED #36674 相同:单条接口从 200 变 403、批量里该行从成功变失败,属于收窄,PR 和 changeset 仍写 Clause-②: no。
  • 为了不耽误优先落地,契约审核已在当前 head 并行跑;改动若只动 changeset 和 PR 正文,该审核记录可沿用。无需你做任何事。

席位核对

Verdict: REWORK · head 00ca61b93468c4d2a5c77e0330489e82171a3b33 · card #36259 · L2: owed on the narrowing face, claimed and running on this head (claim 7103871433)

Reviewed against GitHub at this head (diff, card body and rulings, pr-state.mjs), not against the report.

Checklist

  • Shape: open, draft, base main, first line Fixes #36259. Fixes is right: every Done-when line is delivered (strictReadonlyWrites on both owner writes, notified read off delivered/enqueued, real ObjectQL + SQLite pins for single, bulk, queue target and a zero-delivery emit, ablation).
  • Scope: 5 files; the scripts/error-status-unpinned-baseline.json shrink (FIELD_NOT_ACCESSIBLE leaves the unpinned baseline because the new pins assert it) carries 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.
  • Changeset sentences read against the diff: both door answers, the bulk failures row with FIELD_NOT_ACCESSIBLE, no notification for an unmoved record, queue target writing both keys under one lock, notified from delivered/enqueued. All hold in change-record-owner.ts.
  • Gates at this head: 9 success, 0 failed, 16 pending when read; the floor and the full set are re-read before the seat lands.

REWORK items

  1. The narrowing is undeclared. On this head POST /api/v1/data/:object/:id/change-owner answers 403 FIELD_NOT_ACCESSIBLE where it answered 200, and the bulk door lists under failures a row it reported moved; ChangeOwnerMessaging (exported from @objectstack/core's security entry) now requires emit to resolve a { delivered, enqueued } answer where it took any value. The same class on main declares it (.changeset/35195-…, 35427-…, 35525-…, 35526-…, and the L2 record on fix(core)!: Change Owner refuses an object of a disabled package with 404 OBJECT_PACKAGE_DISABLED #36674). Fix in the changeset body and PR body/title: the Clause-②: line with the (narrowing) arm, ! in the title and changeset headline, a BREAKING banner (FROM: a locked owner or queue answered 200 / counted as moved, and notified: true whenever the emit returned; TO: 403 FIELD_NOT_ACCESSIBLE / a failures row, nothing written or sent, and notified true only on a delivered or enqueued notice; the fix for a caller: unlock the field's condition or change owner where it holds), and the adr-0087 marker (the siblings use not-required (no-migration-prescription)). Run check-adr-0087-registration --base origin/main after the edit. No code change is asked.
  2. Owed once the arm is declared: the dogfood battery in full at the new head (dogfood_battery in the report). The contract review is already running at this head; if the fix moves only the changeset and the PR body, its record carries over with a Regen-provenance: line, so the delta is fast.

Serial notes

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 00ca61b93468c4d2a5c77e0330489e82171a3b33
Local-runs: none
Scope: packages/core/src/security/change-record-owner.ts, packages/core/src/security/change-record-owner.test.ts, packages/rest/src/change-owner-routes.test.ts, scripts/error-status-unpinned-baseline.json + none in the diff; read, not reviewed, in the cited code: packages/objectql/src/engine-update.ts, packages/objectql/src/readonly-strict-errors.ts, packages/objectql/src/validation/rule-validator.ts, packages/services/service-storage/src/record-file-access.ts, packages/services/service-messaging/src/messaging-service.ts, packages/rest/src/change-owner-routes.ts, packages/core/src/security/index.ts, packages/spec/src/data/user-action-transfer.ts, packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, scripts/check-error-status-conformance.mjs, content/docs/api/data-api.mdx, content/docs/api/error-catalog.mdx

① Derived judgments

  • Accept-set, single door (POST /api/v1/data/:object/:id/change-owner): NARROWED, and right. A record whose owner_id or queue the engine would strip from the owner write now answers 403 FIELD_NOT_ACCESSIBLE where it answered 200 with a receipt copied from the request. writeOwner passes strictReadonlyWrites: true on the one by-id update; the engine collects every strip of a caller-supplied key and throws once, before any driver call (engine-update.ts, assertNoStrictDrops, after both strip passes), so nothing is half-written.
  • Accept-set, bulk door (POST /api/v1/data/:object/change-owner): NARROWED, and right. The same row is counted under failed and listed under failures with FIELD_NOT_ACCESSIBLE where it was counted under updated; the loop is unchanged, so the other rows move and the row cap and per-row reporting of the console: the default record form never renders owner_id, and the console has no Change Owner action, so an object without an authored form cannot be reassigned #35315 rulings stand.
  • The refused set is wider than the prose says, and that is still right: strict refuses EVERY strip of the two caller keys, so a statically readonly queue column (not an eligibility bar; transferIneligibilityReason reads owner_id alone) is refused too, where it used to drop the queue, empty the owner and answer a queue receipt. The declaration should say "locked", not only "readonlyWhen".
  • Queue target: right. The change-set carries owner_id: null and queue in one update, so a lock on either refuses the row whole; main's half-move (queue lands, owner stays, receipt says ownerId: null) is gone.
  • Notification suppression: right. notifyNewOwner runs after the write and only over moved (bulk) or after a non-throwing single write; a refused row reaches neither, and an all-refused bulk call sends nothing (ids.length === 0).
  • Envelope: right. 403 FIELD_NOT_ACCESSIBLE is the pairing the platform already answers for this same engine refusal (record-file-access.ts, readonlyRefusalOf, Upload links: a link is issued for a record the user cannot change, and the upload page then says "Done. The file was attached" when nothing was attached (readonlyWhen), or "Upload failed" with no reason (approval lock, 500) #32734), and error-catalog.mdx publishes 403 for the code. No existence oracle is opened: the authz middleware (ownership gate, step 3.5) wraps the engine body and refuses before the strip is judged, and the by-id not-found gate precedes it as well.
  • ERR_READONLY_FIELD_REJECTED reading: right. It is the code ReadonlyFieldRejectedError carries (READONLY_FIELD_REJECTED_CODE), documented as caught by code, never instanceof, with fields the union of dropped keys; the mapper reads both and stamps neither (the inline literal keeps check:error-code-provenance out of core). The caller-supplied snapshot is taken before the middleware chain, so strict judges only owner_id and queue, never a server stamp.
  • notified: right. MessagingService.emit answers EmitResult with numeric delivered and enqueued on every return path; the outbox path reports delivered: 0 with enqueued counting accepted rows, and the zero-recipient, no-channel, muted and unreachable paths answer zero of both. The emit carries no dedupKey, so the deduped zero cannot occur here. notified is now false on those paths and on a messaging object whose emit answers nothing readable.
  • Public type surface: NARROWED. ChangeOwnerMessaging.emit (exported from the @objectstack/core security entry) returns a Promise of ChangeOwnerEmitResult where it returned a Promise of unknown. An embedder passing its own messaging whose emit resolves to nothing no longer type-checks, and at runtime now reads notified: false. In-repo consumers: one, packages/rest/src/change-owner-routes.ts, which casts the resolved service; nothing in the repo breaks.
  • Baseline: right. Removing FIELD_NOT_ACCESSIBLE from scripts/error-status-unpinned-baseline.json is the shrink the gate demands once a readable producer declares 403; the documented status and the producer agree. Maintainer ruling 7103795578 (option A) authorised the --update.
  • Check-runs on this head when read: Lint · docs & code guards (the job carrying check:error-status-conformance), Lint · ESLint, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Lint · scoped · query-options erasure, Type Check · source gates, Type Check · debt ledger, Check Changeset, Check PR Size, PR-body guards, Governed Surface Queue Guard, Dogfood Regression Gate, Flag docs affected by code changes: success. Still in progress, so NOT cited as green: Test Core 1 to 10, Test UI 1 to 16, Build Core, Type Check · workspace, Type Check · consumer gates, Type Check UI, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · scoped · slot lookup & corpus, Build & E2E UI, Live E2E UI. The new pins and the type change are answered by those pending runs, not by this record.

② Semver level

  • Level: patch on @objectstack/core is right. Metadata-protocol: none is right: nothing a metadata author can write changes, and a non-protocol breaking change ships patch.
  • Clause-②: no as written on this head (PR body and changeset) is WRONG against the diff. The diff refuses requests two shipped doors answered with success, and narrows an exported type. Owed before landing, on the prose faces only:
    • Clause-②: no (narrowing) in the PR body and in the changeset body, both.
    • The BREAKING banner in the changeset body, naming both halves: (a) the two Change Owner doors refuse a record whose owner_id or queue is locked (403 FIELD_NOT_ACCESSIBLE single, a failures row bulk) where they answered success, and notified is false where no delivery or outbox row was taken; (b) ChangeOwnerMessaging.emit must answer { delivered, enqueued }. With the fix a caller applies: handle the 403 and the failure row; return the two counts from a custom emit.
    • Exactly one ADR-0087 disposition marker in the changeset body. Nothing an author wrote needs rewriting and the kind is none, so the category that reads true is not-required (no-migration-prescription) with its reason; pnpm check:adr-0087-registration on the corrected head is the verdict on the category, not this record.
    • The PR body gains the Skills-docs: line a (narrowing) arm owes.
    • The arm also makes the full dogfood battery owed once on the final head (the dev report reads n/a only because no arm was declared); its reading belongs on the card before landing.
  • The PR body is also stale against the head: it still says the baseline is untouched and the gate red, and its readings name head ed59773d32. The one commit since then touches the baseline file alone.
  • This PASS is of the narrowing. It does not stand in for the declaration: a head that lands with Clause-②: no unarmed ships an undeclared break.

③ Boundary flags

④ Design judgment

The narrowing makes the spec's own refusal real; it takes no declared capability away. A readonlyWhen that holds declares the field unwritable for an API-boundary caller, and the engine has always declined that write. What main delivered on top was a false receipt and a false notification, which no spec line declares. Change Owner is the one door whose answer asserts a move, so strict is the right reading there, and the plain PATCH keeps its observable strip.

Attempts to break it, and what they found:

  • Refusal before permission, leaking a hidden record's state: no. The authz middleware wraps the engine body.
  • Strict refusing server stamps on every call under a real security stack: no. The supplied-keys snapshot precedes the middleware chain.
  • A deduped or void emit answer read as delivered: no. No dedupKey; the reader is null-safe and number-typed.
  • A locked row still notified in bulk: no. The notice is built from moved.

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:

  • N1 (nit): the engine strips a same-value write of a locked key, so a queue move of a record that is already ownerless, on an object locking only owner_id, is refused although the saved row would equal the request. It follows the card's Done-when and the changeset's "a lock on either leaves both unchanged"; follow-up only if a user reports it.
  • N2 (nit): lockedOwnerRefusal always says "read-only on this record in its current state". For a statically readonly queue the refusal is right and the sentence is not; the record-file door branches its sentence on drops.
  • N3 (nit): the mapper does not check the refusal's object. A strict refusal thrown by a nested write inside a hook on another object would be reworded as this object's lock.
  • N4 (nit): ChangeOwnerEmitResult is exported from the module and not from packages/core/src/security/index.ts, so the type the exported interface now returns cannot be named from the entry. Structural typing covers implementers.
  • N5 (nit): no pin locks queue itself; every lock in both suites is on owner_id. The path is the same engine refusal.
  • N6 (nit, prose): content/docs/api/data-api.mdx states neither the new refusal nor what notified now means, and the FIELD_NOT_ACCESSIBLE entry in error-catalog.mdx speaks only of field-level access. This is what the Skills-docs: line in ② should point at.

Implemented-by: claude/issue-36259-change-owner-readonly-when
Reviewed-by: session_011y7As6YDLR8TJVDpdXzJyV

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>
@objectstack-fleet objectstack-fleet Bot changed the title fix(core): change owner answers what was saved when a readonlyWhen lock holds the owner, and notified reads the emit answer fix(core)!: change owner answers what was saved when the owner or queue is locked, and notified reads the emit answer Nov 23, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV

Contract-review-claim: session_011y7As6YDLR8TJVDpdXzJyV · head c32cb7b · 2026-11-23T20:00Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: c32cb7bd84657541b7abbbf52f9efc45f2ac819d
Local-runs: none
Scope: packages/core/src/security/change-record-owner.ts, packages/core/src/security/change-record-owner.test.ts, packages/rest/src/change-owner-routes.test.ts, scripts/error-status-unpinned-baseline.json + none in the diff; delta read against the record on head 00ca61b93468c4d2a5c77e0330489e82171a3b33 (comment 7104020664): .changeset/36259-change-owner-answers-what-was-saved.md, content/docs/api/data-api.mdx, content/docs/api/error-catalog.mdx, the PR body and title, and the check-runs on this head

① Derived judgments

  • Delta record. It extends the record on 00ca61b93468c4d2a5c77e0330489e82171a3b33 to this head and re-judges nothing that did not move.
  • The review surface did not move. git diff 00ca61b934 c32cb7bd84 is two commits (4cd69659, c32cb7bd) over three files, all prose faces: the changeset, content/docs/api/data-api.mdx, content/docs/api/error-catalog.mdx. The four floor paths are byte-identical to the reviewed head, so every ① judgment of the earlier record stands as written: the refusal on both doors, the queue target, the notification suppression, the 403 FIELD_NOT_ACCESSIBLE envelope, the ERR_READONLY_FIELD_REJECTED reading, notified, the exported type, the baseline row.
  • Check-runs on this head, all read as completed: every run that is not skipped concludes success. That includes the runs the earlier record could only name as pending: Test Core 1 to 10 and its roll-up, Test UI 1 to 16 and its roll-up, Build Core, Type Check · workspace, Type Check · consumer gates, Type Check UI, TypeScript Type Check, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · scoped · slot lookup & corpus, Lint & Repo Gates, Build & E2E UI, Live E2E UI; and the prose gates of this delta: Check Changeset, Lint · docs & code guards, Build Docs, Check Documentation Links, PR-body guards, Governed Surface Queue Guard. The new pins and the type change are now answered green by CI, not by this record.

② Semver level

  • The declaration now matches the narrowing reviewed. Clause-②: no (narrowing: ...) stands on the PR body and the changeset body, both, with the same sentence; Metadata-protocol: none on both.
  • Arm: (narrowing) is right. The two doors refuse what they answered with success, and an exported type accepts fewer implementations. no is right: nothing is added to any accept-set.
  • Level: patch on @objectstack/core is right. The kind is none, and a non-protocol breaking change ships patch with its banner and disposition.
  • Banner: right, and in the two halves owed. (a) names both doors, the 403 FIELD_NOT_ACCESSIBLE and the failures row, that nothing is written, and that notified is false where no delivery or outbox row was taken. (b) names ChangeOwnerMessaging from the security entry and states that a custom emit must resolve { delivered, enqueued }. That is exactly the tree: emit returns a Promise of ChangeOwnerEmitResult, whose two members are the numeric counts MessagingService.emit answers on every path. The caller-side fix is stated for each half.
  • The wording now says "locked (read-only, or under a readonlyWhen condition that holds)", which covers the static-readonly queue case the earlier record asked to be named.
  • ADR-0087: exactly one marker, not-required (no-migration-prescription), with a reason that reads true: no key, accepted value or metadata type moves and nothing stored is rewritten. The body carries FROM and TO bullets describing door answers, not an authorable rewrite; whether that counts as a prescription is the gate's question, and the jobs carrying the changeset gates conclude success on this head. The dev's local reading of check:adr-0087-registration (exit 0, the narrowing arm recognised) is the dev's, cited as such.
  • Title carries the breaking mark (fix(core)!:), in the PR and in the changeset summary. The Skills-docs: line is present and true (updated here, the two pages in this delta). The dogfood battery the arm makes owed is reported on this head in the PR body (487 files passed, 3 skipped; no failure): the dev's reading, with Dogfood Regression Gate success in CI.
  • The PR body is no longer stale: it names the baseline edit, its ruling, and which commits changed what.

③ Boundary flags

④ Design judgment

Nothing 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 notified means; the catalog entry covers a locked field).

No must-fix, no should-fix.

Nits, unchanged or new, none fixed outside the prose faces:

  • N1 to N5 of the earlier record: open as accepted deviations or follow-ups; they are code or test observations and this delta rightly did not touch them.
  • N7 (nit, prose): the changeset and data-api.mdx say a "read-only" owner_id is refused FIELD_NOT_ACCESSIBLE. A statically readonly owner_id never reaches that answer: the object is ineligible and the whole call is refused 403 CHANGE_OWNER_DISABLED, as the next paragraph of the page says. Only queue can be statically read-only here. The sentence is loose, not wrong about any answer a caller can receive for a lock that holds.

Implemented-by: claude/issue-36259-change-owner-readonly-when
Reviewed-by: session_011y7As6YDLR8TJVDpdXzJyV

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6YDLR8TJVDpdXzJyV

维护者速读

  • 结论:通过(ACCEPT)。上一轮退回的原因只是没写收窄声明,这次补齐了:标题带 !,changeset 有两段 BREAKING 说明,文档也同步改了。代码与上一轮相同。
  • 契约审核在当前 head 通过(7112452212)。无需你做任何事。

席位核对 — ACCEPT · head c32cb7b · card #36259

L2 record at this head: comment 7112452212 (PASS, CONTRACT_REVIEW_TIER, delta of 7104020664; no must-fix, no should-fix) · 2026-11-23T20:02Z. This replaces the REWORK 7103895155 at 00ca61b934. I read it against GitHub (git diff 00ca61b934..c32cb7bd84, l1-face.mjs --pr 36683, pr-state.mjs), not against the report.

REWORK items

  • Item 1 closed. The title is fix(core)!: …, and so is the changeset headline. Clause-②: no (narrowing: …) appears in the PR body and the changeset. The BREAKING banner comes in two halves, each with FROM, TO and the fix for a caller: (a) the Change Owner doors on a locked owner_id / queue; (b) a custom ChangeOwnerMessaging.emit resolving { delivered, enqueued }. There is one adr-0087: not-required (no-migration-prescription) marker. no is the right answer to the widening question: nothing is added to a published surface, and the emit return shape is a tightened requirement, which is the narrowing. Level patch under Metadata-protocol: none is right.
  • Item 2 closed. The dogfood battery is in full at this head (report 7112363773): c32cb7bd84 · VERDICT command-exit 0 · 487 files passed, 3 skipped · 4121 tests passed, 68 skipped · no failure.

Checklist

  • Since 00ca61b934 the move is two commits over three prose files only (the changeset, content/docs/api/data-api.mdx, content/docs/api/error-catalog.mdx). The code checklist of 7103895155 stands.
  • Prose read sentence by sentence against the code checked on 7103895155. In data-api.mdx, the single door refuses a locked owner or queue with 403 FIELD_NOT_ACCESSIBLE naming the column, nothing is written, a queue move writes both columns, the bulk report lists the row as FIELD_NOT_ACCESSIBLE, and notified is true only on a delivered or outbox-taken notice. The error-catalog.mdx FIELD_NOT_ACCESSIBLE cause and fix are updated. All hold.
  • Skills-docs: line present and true: no page under skills/ teaches Change Owner's answers, and the API docs are updated here.
  • l1-face flags @objectstack/rest as having no changeset entry. Its only touched file is src/change-owner-routes.test.ts, and files[] ships dist, README.md and CHANGELOG.md, so nothing published moves and no entry is owed.
  • Gates at this head: 62 success, 12 expected skip, 0 failed, 0 pending. Lint & Repo Gates and TypeScript Type Check are success, and mergeable_state is clean.

Accepted deviation

  • L2 N7 (prose): "read-only" owner_id in the banner and in data-api.mdx. A statically readonly owner makes the object ineligible (403 CHANGE_OWNER_DISABLED), so only queue can be statically read-only here. No caller gets a wrong answer from the sentence. Accepted as is, as the area asked.

Out of scope, disposition

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

Review request — declared narrowing (Clause-②: no (narrowing), fix(core)!:), which the queue guard's narrowed leg lands by an authorized approval. The maintainer asked for this PR to land before #36525.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 23, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 23, 2026 21:10
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit ec545de Nov 23, 2026
80 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-36259-change-owner-readonly-when branch November 23, 2026 21:48
os-steve pushed a commit that referenced this pull request Nov 24, 2026
#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>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…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>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

change owner: answers 'moved' and notifies the new owner when a readonlyWhen lock kept owner_id unchanged; notified is true whenever emit returns

3 participants