Skip to content

feat(rest): Change Owner endpoint, single and bulk, gated by the object switch - #36154

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-l6qorl
Nov 21, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-l6qorl

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #35402

Clause-②: yes (widening): new error code CHANGE_OWNER_DISABLED (403); new routes POST /api/v1/data/:object/:id/change-owner and POST /api/v1/data/:object/change-owner; new client methods data.changeOwner and data.changeOwnerMany.
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:本卡用户无感;它提供改负责人的服务端操作(单条和批量),界面按钮由后续的界面卡接上。
  • 为什么做:改负责人三张卡的第二张,落实你定的「专门的改负责人操作,按对象开关开放」。
  • 出错会怎样:只影响新增的改负责人请求;普通编辑和导入改负责人的规则不变,可以直接撤回。
  • 要你做什么:无。

What changes

Two new doors under the data surface. Both run as the caller, and both read the object switch from #35401 first.

  • POST /api/v1/data/:object/:id/change-owner with { ownerId | queue, notify? } hands one record to a person, or moves it into an ownership queue (ADR-0142). It answers { object, id, ownerId, queue?, notified }.
  • POST /api/v1/data/:object/change-owner with { ids, ownerId | queue, notify? } does the same for up to 500 ids, one by-id update per row. It answers the Offboarding: banning a user says nothing about their open work, and there is no way to hand it over #30205 report shape (updated, failed, failures[] with each row's id, code and sentence) plus the target and notified. Every row that did not move is listed; none is skipped or sampled.

Order of checks, per request:

  1. The authenticated-caller floor, the closed query set (no parameters), and the object's API exposure for update: the same gates every /data write passes.
  2. The object switch. An object the platform gives no reassignable owner, or whose userActions.transfer is off (explicitly, or by the controlled_by_parent default), is refused as a whole with 403 CHANGE_OWNER_DISABLED, whoever asks, a modifyAllRecords holder included, before any read or write.
  3. The target. A person must be one the caller can read, and not banned (the hand-over's own check, now shared as assertAssignableUser). The check follows the write path's rule for a user reference (objectql: a plain lookup write accepts a target the writer cannot read — the reference check probes it elevated, and only master_detail asks the caller's read door #29029): a user the caller cannot read answers as one that does not exist (404, reference_not_found), on Change Owner and on the hand-over alike. A queue target needs the object to carry the queue column.
  4. Each record goes through the ordinary engine update under the caller's context. So the owner guard in the security plugin decides it as it decides a hand edit of owner_id: edit on the record plus allowTransfer or modifyAllRecords, and the ADR-0142 queue admissions. Without the grant the answer is the data door's own 403 PERMISSION_DENIED and the owner stays.

There is deliberately no second permission check in the endpoint. The write gate is the same verdict the explain engine's record-level transfer operation reports, so a pre-check would only restate it.

notify: true sends the new owner one notification under the new record.owner_changed topic, naming the record (or the count, for a bulk move). Its title rides keyedText (messages.recordOwnerChangedTitle / messages.recordsOwnerChangedTitle, the object's label itself keyed as objects.<object>.label), so it renders in the new owner's own language at delivery; the English sentence is the literal delivered when no entry renders. It is skipped for a queue target, when the caller is the new owner, when nothing moved, or when no messaging service is mounted. A failing send never fails the transfer; notified reports what happened.

A plain owner_id update is untouched: the switch gates this action only, so imports and hooks still need only the transfer grant (ruling 7000907189 point 2).

Package by package:

  • @objectstack/core: changeRecordOwner, changeRecordsOwner, changeOwnerOffReason, changeOwnerOffRefusal, CHANGE_OWNER_DISABLED, CHANGE_OWNER_NOTIFICATION_TOPIC, CHANGE_OWNER_NOTIFICATION_TEXT, and assertAssignableUser (extracted from the assigned-work hand-over; it now reads the target through the caller's own read first, as above).
  • @objectstack/rest: the change-owner-routes.ts registrar, its two route-ledger rows (data-actions family, sdk disposition), and its entries in the REST censuses (query slots, docblock floors, objectQL slot consumers, write-echo dispositions, hook-sentence rows, route envelope).
  • @objectstack/client: data.changeOwner and data.changeOwnerMany.
  • @objectstack/spec: CHANGE_OWNER_DISABLED in the error-code ledger, under @objectstack/core because core stamps it (the provenance gate requires the stamping package's key). The userActions.transfer liveness row is now live. Two docblocks (user-action-transfer.ts, object.zod.ts) now say the endpoint reads the switch instead of "nothing reads it yet": prose only.
  • @objectstack/service-messaging: record.owner_changed in the platform topic list, and the notice's two title entries in every shipped locale of its messages bundle (the en entries are core's own English, so they cannot drift).
  • Docs: content/docs/api/data-api.mdx documents both routes, their bodies, the 500 cap, the per-row report and CHANGE_OWNER_DISABLED.

The row cap is the existing USER_WORK_TRANSFER_ROW_CAP (500), as the seat asked; no new constant.

Tests

  • packages/core/src/security/change-record-owner.test.ts: off and ineligible objects (switched off, controlled_by_parent default, ownership: 'org', a sys_* object, a managedBy object) refused for single and bulk with no engine call; the opted-in detail; unknown object 404; person and queue writes; queue on an object with no queue column 400; PERMISSION_DENIED and RECORD_NOT_FOUND passthrough; banned and unknown targets; a target the caller cannot read, active or banned, answers as unknown and its ban is never read (single, bulk, and the hand-over); the mixed bulk report; empty, over-cap and duplicate ids refused before any write; notify cases.
  • packages/rest/src/change-owner-routes.test.ts: the HTTP faces, every refusal pinned by status and code in the nested envelope, and the closed body.
  • packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts: the real showcase, real security plugin, real sharing, on the private showcase_private_note.

Acceptance notes

The rulings, quoted from #35315.

7000556646: "Chosen: a dedicated Change Owner action, the Salesforce / Dynamics 365 shape. Not a plain editable owner field." … "Sharing. Sharing is recomputed on transfer. The previous owner's access follows the sharing rules, not the old ownership."

7000907189, point 2: "The switch gates the dedicated action, not the raw write. The Change Owner endpoint (single, bulk and cascade) refuses an object whose switch is off. A plain owner_id update stays governed by allowTransfer alone, so import mappings and hooks are unaffected. An author who wants a hard block declares owner_id readonly."

7000907189, Bulk: "The bulk form issues per-row by-id updates under the caller's context and reports per-row failures. A predicate update carrying owner_id has no pre-image and is refused by the owner guard (security-plugin-authz-middleware.ts ~1778–1783). Reuse the #30205 report shape and row cap (UserWorkTransferReport, USER_WORK_TRANSFER_ROW_CAP)."

Done-when, each pinned by code and status:

Done-when Answer Where
Ineligible or switched-off object, even for modifyAllRecords 403 CHANGE_OWNER_DISABLED, single and bulk, owner unchanged core unit, rest, dogfood (admin on showcase_invoice_line)
Edit without transfer 403 PERMISSION_DENIED, owner unchanged; in bulk, the row's failure code rest, dogfood
Mixed bulk batch 200 with a per-row report. Dogfood: updated: 2, failed: 1, the other member's note listed as RECORD_NOT_FOUND. Core and rest: one moves, a PERMISSION_DENIED row and a RECORD_NOT_FOUND row listed core unit, rest, dogfood
Queue target (ADR-0142) 200, owner_id: null, queue: note_triage; refused 403 PERMISSION_DENIED without the grant core unit, dogfood
Notify one sys_notification event for this record, delivered to the new owner's inbox alone; title keyed core unit, dogfood

Measured, not assumed: on the showcase, after alice (holding the transfer grant) hands her private note to bob:

  • created_by stays alice; owner_id is bob.
  • bob: GET 200, PATCH 200.
  • alice: GET 404, PATCH 404. The private OWD gives her no row access once she is not the owner, and being the creator, which the owner_only_writes floor keys on, does not give it back. Read from the code, not measured separately: the floor narrows writes on rows the caller can already reach and grants no access of its own.

Cascade (ruling point 4) is phase 2 and not here.

Known and left as they are: a Change Owner to the record's current owner is written like any other and counted as moved; the two route-ledger rows carry no responseSchema (the client's result types are written by hand, as for the hand-over); no pin yet for a grant holder who can read a record but not edit it (the owner guard decides it as for a PATCH).

Prior rulings read: change,owner,server,single,bulk,endpoint,gated,object,switch,per-row,report → 349 hits; ADR-0027 Decision §12, ADR-0081 Decision §3, ADR-0139 D4, ADR-0029 D3, ADR-0029 D9.5, ADR-0057 D9, ADR-0061 D2, ADR-0071 Decision §1, ADR-0093 D7; thread: none; repo: objectstack-ai/objectstack

Both counts: 349 ADR hits by keyword, 9 decisions surfaced, 0 bearing on this change (they match on words like "change", "object" and "switch"); the rulings this change follows are the two #35315 comments above.

Verification

Read first: packages/core/src/security/change-record-owner.ts (the order of checks and the change set), then packages/rest/src/change-owner-routes.ts (the refusal envelope), then the dogfood file's MEASURED case.

Two-minute check: pnpm --filter @objectstack/dogfood exec vitest run test/change-owner-endpoint.dogfood.test.ts after a dogfood closure build. Expect 6 of 6 passing.

Local runs

On 06b053c:

  • core vitest run (full): Test Files 164 passed, Tests 3810 passed.
  • rest vitest run (full): 8 census failures on the first run, each naming the new module; fixed and re-run: Test Files 7 passed, Tests 960 passed.
  • spec error-code ledger tests 36/36; rest ledger conformance 23/23; client URL and ledger coverage 12/12; service-messaging full 1060/1060.
  • typecheck: core, rest, client, service-messaging clean.
  • Derived local gates (dispatch-gates --commands, 127): failures found and fixed: check:docs, check:liveness, check:dispatcher-error-vocabulary, check:engine-double-contract; all exit 0 on re-run. Not measurable here: check-plugin-teardown-shape --self-test (shallow clone), check:dual-build-cjs-loads and check:i18n (whole-repo build); left to CI.

Review round 1 (L1 7068420281, contract 7068497336), on the commits after a8787f4:

  • core src/security 75 files, 1455 tests passed; the target-read pins fail with the caller read removed (ablation: 3 failed) and pass with it.
  • rest user-work-routes, change-owner-routes, hook-sentence ledger: 730 passed.
  • service-messaging translations + keyed notification text: 29 passed.
  • dogfood change-owner-endpoint.dogfood.test.ts: 6 of 6 (lock VERDICT command-exit 0).
  • check:where-matcher, check:test-source-alias, check:keyed-text-bounds, check:i18n-stale-fill, check:liveness, check:doc-authoring, check:doc-route-spelling exit 0.

Generated by Claude Code

https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi

… the doors in the REST censuses

The single and bulk doors answer a thrown refusal in the nested ADR-0112
envelope (the `/data` door's classification, re-dressed), the module's
declared shape. Each handler states the authenticated-caller floor itself.
The new registrar joins the query-slot, docblock, objectQL-slot, write-echo
and hook-sentence censuses; the hook-sentence double opens update() with the
engine's dispatch predicate. Regenerated the spec reference docs, the
liveness count shard and the engine-double ledger. The dogfood proof keeps
the showcase's own member set as the app default.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/client, @objectstack/core, @objectstack/rest, @objectstack/service-messaging, @objectstack/spec, touching 107 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/spec/liveness/object.json, packages/spec/liveness/state-counts/object.md, packages/spec/src/data/user-action-transfer.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

59 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 1705ec955c2097933a0a0776e9c00d270c26907b.

⛔ 16 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/spec/liveness/object.json, packages/spec/liveness/state-counts/object.md, packages/spec/src/data/user-action-transfer.ts) — pages documenting those are invisible to this run
  • 5 cross-cutting symbol(s) contributed no route anchor: enforceAuth (32 routes), resolveExecCtx (37 routes), routeManager (26 routes), enforceApiAccess (12 routes), resolveProtocol (29 routes)
  • 2 anchor(s) matched too much of the corpus to be a work list: PERMISSION_DENIED (literal, 56 pages), /data/:object/:id (route, 38 pages)
  • 7 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 67 of 249 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 189 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 1705ec955c2097933a0a0776e9c00d270c26907b → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7e50969e5f9c1727ddb0fcc9418c646f89050c18 — the merge of head 8ecad2fc6844118c2e6c5004b73b024f25f1855e into base 1705ec955c2097933a0a0776e9c00d270c26907b, 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 7e50969e5f9c1727ddb0fcc9418c646f89050c18 && git checkout 7e50969e5f9c1727ddb0fcc9418c646f89050c18
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1705ec955c2097933a0a0776e9c00d270c26907b 8ecad2fc6844118c2e6c5004b73b024f25f1855e && git checkout -B drift-repro 1705ec955c2097933a0a0776e9c00d270c26907b && git merge --no-ff 8ecad2fc6844118c2e6c5004b73b024f25f1855e

node scripts/docs-audit/affected-docs.mjs --json 1705ec955c2097933a0a0776e9c00d270c26907b

⚠️ 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 1705ec955c2097933a0a0776e9c00d270c26907b → pass the list as
args.docs, on the commit named under Which tree this was computed on.

… REST test pays the engine load at collection

The two find() doubles matched every key as a plain field, so a `$and` or
`$or` would read as a field name and match silently; they now refuse any
combinator they do not implement. The REST test imports the engine at module
top so its first load is not paid inside a test's clock.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5pJZvcko4CsCLefrvi

Final head: a8787f4282c173e3e35bfadb40e46557a562de64.

CI on this head is green: every check run completed success or skipped by its own condition (Lint & Repo Gates, Lint · CI, release & engine gates, Type Check · workspace, Test Core 1–10/10, Build Core, Spec property liveness, Check Changeset among them). GitHub reads the PR as mergeable (clean).

Since the report on #35402 (06b053c):

  • 0823c1f7: the two test doubles' find() now refuse a WHERE combinator they do not implement (where-matcher conformance), and the REST test imports the engine at module top (test-source alias gate). Both gates were red on 06b053c.
  • c9d03393: merged main (no rebase), no conflict.
  • a8787f42: regenerated the object liveness count shard after the merge.

Ready for L1.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5

L1 verdict (L1-a): REWORK, two items at head a8787f4282c173e3e35bfadb40e46557a562de64 (Fixes #35402, seat note 7065223271). Full read of origin/main...a8787f4282 (28 files, +1592/−43).

席位核对

Shape and gates.

  • l1-face --pr 36154 at a8787f4 is CLEAN (13 items):
    • First line Fixes #35402.
    • Clause-②: yes (widening): the new code, the two routes and the client methods are named in the body.
    • Floors are success.
    • Check-runs: 60 success, 10 expected skip, 0 failed, 0 pending.
  • One changeset covers all five touched published packages: core, rest, client, spec and service-messaging.
  • The body's local runs are on 06b053c2. The later commits are a doubles/test fix (0823c1f730), merges of main, and a liveness count-shard regeneration. CI at the head covers them.

What reads right.

  • Order of checks (change-record-owner.ts):
    1. Body and closed-set checks.
    2. Then the switch, via changeOwnerOffReason, which runs resolveUserActionTransfer and refuses 403 CHANGE_OWNER_DISABLED before any record read, whoever asks.
    3. Then the target, via assertAssignableUser. This is a byte-faithful extraction of the hand-over's own check.
    4. Then one by-id engine.update per row under the caller's context.
    • So the transfer verdict is the owner guard's, with no second permission check. That matches ruling 7000907189 point 2 and the card's "per-row by-id updates under the caller's context".
  • The change set. It is { owner_id }, or { owner_id: null, queue } for a queue target. A queue target on an object without a queue column is refused 400.
  • The bulk form.
  • Refusal envelope (change-owner-routes.ts). UserWorkTransferRefusal answers its status and code with details.fields. Everything else goes through handleRouteError into nestedRefusalEnvelope. The rest tests pin each refusal by status and code.
  • Done-when. Every row of the body's table has a pin:
    • off and ineligible objects, for single and bulk, with a modifyAllRecords holder in dogfood;
    • edit without transfer, 403 PERMISSION_DENIED;
    • the mixed bulk report;
    • the queue target;
    • notify.
  • The MEASURED case is real. On the showcase's private note, after alice hands it to bob:
    • created_by stays alice;
    • bob gets GET 200 and PATCH 200;
    • alice gets GET 404 and PATCH 404.
  • Spec.
    • The CHANGE_OWNER_DISABLED ledger row is filed under @objectstack/core, the stamping package, which is what the provenance gate requires. The seat note said @objectstack/rest, and the body explains why it differs.
    • The userActions.transfer liveness row goes from planned to live, with the authorWarn/authorHint dropped in the same edit, as its own note asked.
    • The two docblocks are prose only.
    • git grep finds no content/docs or skills/** page left saying "nothing reads it yet".

R1 (should-fix, or name a follow-up #N in the body). The notification is English-only. notifyNewOwner sends a literal payload.title ("A … record was assigned to you" / "N … records were assigned to you"), built from the object's untranslated label. Nothing lets it render in the new owner's language. The platform's own notices do:

Either carry keyedText (a messages.* key with { label, count } params in the message bundles) and widen ChangeOwnerMessaging.emit to pass it, or leave it out and file a follow-up card, naming it in the body. Which one is the seat's call. It changes no ruling.

R2 (must fix: a refusal without its code). change-owner-endpoint.dogfood.test.ts, in the queue case: carol's refused queue move asserts only status 403. Pin the code too (the data door's PERMISSION_DENIED, as the edit-without-transfer case does). Otherwise a refusal for any other reason passes this pin.

N1 (nit, non-blocking). The dogfood notify case is titled "gets one inbox notification naming the record", but it asserts sys_notification rows by topic >= 1. It does not check that the row is bob's, that it is one, or that it names the record. Narrowing the query to bob and source_id would make the title true.

Next.

  • R1, by a commit or a follow-up #N in the body.
  • R2, by a test commit.
  • I will read only that delta.
  • After ACCEPT, the contract record is the seat's.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a8787f4282c173e3e35bfadb40e46557a562de64
Local-runs: probe — ran the PR's own core and rest suites on the head to confirm the refusal pins hold against freshly built core and spec dists.
Scope: full diff of merge base 1f11c33d56..a8787f42 (28 files); read in full packages/core/src/security/change-record-owner.ts, packages/rest/src/change-owner-routes.ts, both unit suites, packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts, the user-assigned-work.ts, rest-server.ts, rest-route-ledger.ts, client, spec, liveness, changeset and messaging hunks; read for context packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts:1816-2140 (owner guard), packages/objectql/src/engine-referential-integrity.ts:176-345,376-392 (reference check), packages/metadata-core/src/engine-update-dispatch.ts:428-473, packages/rest/src/user-work-routes.ts, content/docs/api/data-api.mdx; card #35402 with all comments, order-35402.md, PR body, final-head declaration 7068380984, siblings #35403 and #35399.
Security-touching: yes

① Derived judgments

  • Object switch. offeredDefinition (change-record-owner.ts:178-191) runs first in both forms (:261, :306) and throws 403 CHANGE_OWNER_DISABLED from resolveUserActionTransfer before any read or write. It takes no caller input, so a modifyAllRecords holder is refused like anyone else. Holds.
  • Per-record permission. Each row is one engine.update(object, changeSet, { where: { id }, context }) under the caller's context (:263, :323). A pure-id where dispatches by-id (engine-update-dispatch.ts:438-473), so the row meets the edit pre-image gate and the owner guard at step 3.5 (security-plugin-authz-middleware.ts:2031-2137): transfer grant, or the ADR-0142 claim / release, else PERMISSION_DENIED. No second permission rule is written in the endpoint, and none is missing. Holds, single and bulk, every row.
  • Record existence. A row the caller cannot reach and a row that does not exist answer the same thing on each branch (the caller-context pre-image is null for both, :2043-2057; the update returns nothing for both, change-record-owner.ts:264-266). The door answers what PATCH /data/:object/:id answers. Holds.
  • Tenant wall. The target probe spreads the caller's context before isSystem (user-assigned-work.ts:303), so tenantId reaches the driver; the per-row write also runs the ordinary reference check on owner_id. No cross-organization write is admitted.
  • Target user. See F1: the target pre-check does not ask the caller's read door. No write is admitted by it (the per-row reference check still refuses), so this is a disclosure finding, not a write hole.
  • System callers. The HTTP door refuses an anonymous caller (change-owner-routes.ts:221,255) and passes the resolved caller context only. An in-process isSystem caller of the core functions still meets the switch and the target check; it bypasses the permission layer as any engine write does.
  • Bulk. Cap is USER_WORK_TRANSFER_ROW_CAP (500), refused not truncated (:291-298); empty and repeated ids refused before any write (:292-305); per-row failure with id, code and sentence (:329-332); partial success, not transactional, as declared; hooks, validation, sharing recompute and audit fire as on a hand edit because each row is an ordinary update.
  • Spec. object.zod.ts and user-action-transfer.ts hunks are docblock prose only; error-code-ledger.zod.ts:1194-1204 adds one member; liveness flips transfer from planned to live and drops the author warning. No published schema shape changes. Clause-②: yes (widening) is right: nothing narrows. Metadata-protocol: none is right. patch on all five packages follows the level rule for kind none.
  • Envelope and ledger. Both rows are in rest-route-ledger.ts:386-389 (data-actions, sdk); refusals go through sendError in the nested envelope (change-owner-routes.ts:196-208); route-envelope ratchet row at 0/0/0.
  • Pins. Removing the switch check fails core change-record-owner.test.ts:96, rest change-owner-routes.test.ts:107,229 and dogfood :94. The transfer check lives in plugin-security, not in this diff; removing it fails dogfood :85, :144-151, :160-163, which run the real SecurityPlugin. The admit path is dogfood :107-129.
  • Runs. core change-record-owner.test.ts 21/21. rest change-owner-routes.test.ts 14/14 after rebuilding the local core and spec dists from the head; before the rebuild the stale dists gave 10 then 2 failures (missing export, then the unregistered code normalised to PERMISSION_DENIED), which is this checkout's state, not the PR's. Dogfood not run here (needs the closure build); CI on the head is the authority for it.

② Declarations

  • Clause-②: yes (widening): confirmed. New code CHANGE_OWNER_DISABLED (403), the two routes, data.changeOwner / data.changeOwnerMany, and the new @objectstack/core exports.
  • Metadata-protocol: none: confirmed.
  • Ledger key: the seat note 7065223271 named @objectstack/rest; the PR registers the code under @objectstack/core because core stamps it and the provenance gate keys on the stamping package. Declared in the PR body; accepted.
  • Changeset levels: patch ×5, confirmed.

③ Findings

  • F1 · should-fix · SECURITY. The new-owner pre-check (packages/core/src/security/user-assigned-work.ts:297-316, called at change-record-owner.ts:201-203,262,307) does not follow the rule the write path's reference check follows for a user the caller cannot read (engine-referential-integrity.ts:322-327, objectql: a plain lookup write accepts a target the writer cannot read — the reference check probes it elevated, and only master_detail asks the caller's read door #29029). Details are with the seat, not on this record. Fix in the shared function so both of its doors follow the write path's rule, correct its docblock (:293-295), and pin it.
  • F2 · should-fix. content/docs/api/data-api.mdx lists every /data route, :id/clone and its CLONE_DISABLED included (:433-441), and has no entry for the two Change Owner routes, their bodies, the 500 cap, the per-row report or CHANGE_OWNER_DISABLED. A declared Clause-② surface lands undocumented on the page that enumerates that surface.
  • N1 · nit. A change to the record's current owner is admitted as an echo and counted in updated; with notify: true the current owner is told the record "was assigned" to them (change-record-owner.ts:327-338, :268-270).
  • N2 · nit. The two ledger rows carry no responseSchema (rest-route-ledger.ts:386-387), and the client's ChangeOwnerResult / ChangeOwnerReport are hand copies of core's types (packages/client/src/index.ts:299-321).
  • N3 · nit. No pin for a transfer-grant holder on a record it can read but not edit through this door; the gate is the middleware's and is pinned on the PATCH door.

④ Accepted deviations

  • None. F1 and F2 are open.

Implemented-by: claude/project-thread-l6qorl
Reviewed-by: contract-review subagent of session_01FEkQ5krBqrrgxCYgjXmfbv (claude-fable-5-2)

VERDICT: FAIL

…new owner's language; pin the queue refusal's code

The new-owner notification now rides `keyedText`: `messages.recordOwnerChangedTitle`
or `messages.recordsOwnerChangedTitle`, with the object's label itself keyed
(`objects.<object>.label`). The entries ship in service-messaging's bundle in
every locale; its `en` entries are core's own English literal, which stays the
text delivered when no entry renders. The dogfood queue case pins the refusal's
code, and the notify case pins one event for this record delivered to the new
owner's inbox alone.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
…ocument the Change Owner routes

The target check shared by the assigned-work hand-over and Change Owner now
reads the user the way the write path reads a user reference (#29029): through
the caller's own read first, so a user the caller cannot read answers as one
that does not exist. The data API page documents both Change Owner routes.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5pJZvcko4CsCLefrvi

New final head: 8ecad2fc6844118c2e6c5004b73b024f25f1855e.

CI on this head is green: every check run completed success or skipped by its own condition (Lint & Repo Gates, TypeScript Type Check, Test Core, Test UI, Build Core, Build Docs, Spec property liveness, Check Changeset among them). GitHub reads the PR as mergeable (clean).

Since the previous final head (a8787f42), answering review round 1 (L1 7068420281, contract 7068497336):

  • d7c81f2f (R1, R2, N1): the Change Owner notice's title rides keyedText (messages.recordOwnerChangedTitle / messages.recordsOwnerChangedTitle, the object label keyed as objects.<object>.label), so it renders in the new owner's language; the English sentence is the fallback. Both entries ship in every locale of the service-messaging messages bundle, the en entries spread from core's CHANGE_OWNER_NOTIFICATION_TEXT. The dogfood queue refusal now pins PERMISSION_DENIED, and the notify case pins one sys_notification for this record delivered to the new owner's inbox alone.
  • cea61249 (F1, F2): assertAssignableUser follows the write path's rule for a user reference (objectql: a plain lookup write accepts a target the writer cannot read — the reference check probes it elevated, and only master_detail asks the caller's read door #29029): a user the caller cannot read answers as unknown (404, reference_not_found), active or banned, on Change Owner and on the hand-over alike; only a readable target's ban state is then read. Pinned single, bulk and hand-over, with an ablation (3 pins fail with the caller read removed). content/docs/api/data-api.mdx documents both routes, their bodies, the 500 cap, the per-row report and CHANGE_OWNER_DISABLED.
  • b0e0f525: merged main (no rebase), no conflict.
  • 8ecad2fc: the core test double's WHERE matcher is a pure filter (where-matcher conformance).

The remaining contract nits are left as they are and listed in the PR body under "Known and left as they are".

Ready for the L1 and contract delta reads.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5

L1 verdict (L1-a): ACCEPT at head 8ecad2fc6844118c2e6c5004b73b024f25f1855e (Fixes #35402). This is a delta read of a8787f4282..8ecad2fc68 over the PR's paths, on top of my REWORK record 7068420281. The commits are d7c81f2f, cea61249, a merge of main, and 8ecad2fc.

席位核对

R1 is closed (the notice in the new owner's language). notifyNewOwner now sends keyedText:

  • titleKey: messages.recordOwnerChangedTitle, or messages.recordsOwnerChangedTitle for two or more records.
  • The object param is the { key: objects.<object>.label, fallback: label } form that service-messaging's notification-text.ts already reads.
  • count is passed for a bulk move.
  • The English literal stays as the fallback.

Both keys ship in every locale of service-messaging's messages bundle. The en entries are spread from core's CHANGE_OWNER_NOTIFICATION_TEXT, so the two cannot drift. service-messaging already depends on @objectstack/core, so this adds no new package edge.

R2 is closed. The dogfood queue refusal pins error.code === 'PERMISSION_DENIED' beside the 403.

N1 is closed. The notify case now pins:

  • exactly one sys_notification for this record (source_id, source_object);
  • its inbox rows equal [bobId];
  • the delivered English title.

Contract F1 (cea61249), read for L1. assertAssignableUser now reads the target through the caller's own read of sys_user first.

  • A user the caller cannot read, or a read refused outright, answers like an unknown one: 404 RESOURCE_NOT_FOUND / reference_not_found. The ban state is not read.
  • Only a user the caller can read has its ban read elevated.
  • This holds on Change Owner and on the assigned-work hand-over alike. The pins cover single, bulk and the hand-over, with an ablation in 7068966876.
  • Clause-② reading. On the hand-over, a write naming a user the caller cannot read was already refused row by row by the write path's reference check. objectql: a plain lookup write accepts a target the writer cannot read — the reference check probes it elevated, and only master_detail asks the caller's read door #29029: a lookup / user field may name only a row the caller's read door returns (engine-master-detail-related.ts). So no write that was accepted before is refused now. What changes is that such a call is refused once, 404, before any row, where it used to answer a report in which every row failed. The changeset says so. I read no new (narrowing) arm, and the declaration line stands as written.

Contract F2. content/docs/api/data-api.mdx documents both routes, and it matches the code:

  • the bodies, and exactly one target;
  • notify is not allowed with queue;
  • the 500 cap and the empty, over-cap and duplicate refusals;
  • the per-row report;
  • CHANGE_OWNER_DISABLED, whoever asks;
  • 404 for an unreadable or unknown user, and 400 for a banned one.

The rest.

  • 8ecad2fc is a test-double-only change.
  • The merge of main touches none of the PR's paths beyond the merge itself.
  • Per 7068966876, CI is green and mergeable_state is clean at this head.

Next. The contract delta and landing are the seat's.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8ecad2fc6844118c2e6c5004b73b024f25f1855e
Local-runs: probe — ran the two core suites on the head and one ablation of the new target check to confirm its pins bite.
Scope: delta read of the PR's own commits after a8787f42 (d7c81f2f, cea61249, 8ecad2fc; the merge of main b0e0f525 excluded): packages/core/src/security/user-assigned-work.ts, change-record-owner.ts, index.ts, both core suites, packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts, packages/services/service-messaging/src/translations/messages.ts, content/docs/api/data-api.mdx, the changeset; for context packages/services/service-messaging/src/notification-text.ts:105-166 and messaging-service.ts:1367; PR body, declaration 7068966876, commit messages. The round-1 record on a8787f42 stands for everything outside the delta.
Security-touching: yes

① Derived judgments

  • F1 closed, all three doors. assertAssignableUser (user-assigned-work.ts:316-336) now asks the caller's own read of sys_user first (callerReadsUser, :291-300) and answers the one 404 RESOURCE_NOT_FOUND / reference_not_found refusal, built once (:322-323), for a user that read does not return; the elevated ban read runs only after it. The single route, the bulk route and the hand-over all call this one function, so all three follow the write path's rule (engine-referential-integrity.ts:322-327).
  • No new signal. A user the caller cannot read and a user that does not exist take the same single caller-context query and the same refusal object, so code, status, sentence and query count are identical. A caller refused the read outright answers the same way (:296-297); any other fault propagates for every id alike. The 400 for a banned user is reachable only for a user the caller can read, as on the write path.
  • Hand-over behaviour. An active target the caller cannot read used to pass the pre-check and then fail every row at the write path's reference check; it is now refused once, up front. Nothing that succeeded before is refused now, so Clause-②: yes (widening) still holds; the changeset states the change.
  • F2 closed. content/docs/api/data-api.mdx:458-534 documents both routes, the bodies, the 500 cap, the whole-call refusals, the per-row report, CHANGE_OWNER_DISABLED and the target rule.
  • R1. The title rides keyedText with titleKey messages.recordOwnerChangedTitle / messages.recordsOwnerChangedTitle and params object ({ key: objects.<object>.label, fallback: label }) and, for two or more, count (change-record-owner.ts:256-277). The shape passes assertNotificationTextKeys (notification-text.ts:108-152); a key the service refuses throws inside the existing try, so the transfer stands and notified is false. The English literal stays in payload.title. All eleven locales carry both entries; en spreads core's constant, and @objectstack/core is already a dependency of the messaging service.
  • R2, N1 (notify). Dogfood pins PERMISSION_DENIED on the queue refusal (:162-164) and one event for the record delivered to the new owner's inbox alone (:182-196).
  • Wording check. The PR body, changeset, commit messages, test names and the docs page state the rule (a user the caller cannot read answers as unknown) and nothing else.
  • Runs. core change-record-owner.test.ts + user-assigned-work.test.ts 42/42 on the head. With the caller read removed from assertAssignableUser, 3 fail (the two [#29029] pins and the read-order pin); the edit was reverted and the tree is clean. Dogfood and rest not re-run here; CI on the head is the authority.

② Declarations

  • Clause-②: yes (widening): confirmed on the new head. One more export, CHANGE_OWNER_NOTIFICATION_TEXT, named in the changeset.
  • Metadata-protocol: none: confirmed.
  • Changeset levels: patch ×5, confirmed.

③ Findings

  • F1 (round 1, should-fix, SECURITY): closed by cea61249.
  • F2 (round 1, should-fix): closed by cea61249.
  • No new must-fix or should-fix in the delta.
  • N4 · nit. The new target rule is pinned on test doubles only; no dogfood case drives a sys_user row the caller cannot read through the real read door.

④ Accepted deviations

Implemented-by: claude/project-thread-l6qorl
Reviewed-by: contract-review subagent of session_01FEkQ5krBqrrgxCYgjXmfbv (claude-fable-5-2)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv

席位核对

Landing · 2026-11-21T20:47Z · head 8ecad2fc6844118c2e6c5004b73b024f25f1855e

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 protocol:data size/xl 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 (2/3 server): single and bulk Change Owner endpoint gated by the object switch, with per-row report

1 participant