Repository navigation
feat(rest): Change Owner endpoint, single and bulk, gated by the object switch - #36154
Conversation
…ct switch (#35402) Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi Co-authored-by: Claude <noreply@anthropic.com>
… 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
📓 Docs Drift CheckThis PR changes 5 package(s): 59 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 16 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 189 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
… 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
… main Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5pJZvcko4CsCLefrvi Final head: 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 ( Since the report on #35402 (06b053c):
Ready for L1. Generated by Claude Code |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): REWORK, two items at head 席位核对Shape and gates.
What reads right.
R1 (should-fix, or name a follow-up #N in the body). The notification is English-only.
Either carry R2 (must fix: a refusal without its code). N1 (nit, non-blocking). The dogfood notify case is titled "gets one inbox notification naming the record", but it asserts Next.
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv Contract reviewServed-tier: ① Derived judgments
② Declarations
③ Findings
④ Accepted deviations
Implemented-by: 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
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5pJZvcko4CsCLefrvi New final head: 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 ( Since the previous final head (
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 |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5nbzs5iP1HcMCFhZo5 L1 verdict (L1-a): ACCEPT at head 席位核对R1 is closed (the notice in the new owner's language).
Both keys ship in every locale of R2 is closed. The dogfood queue refusal pins N1 is closed. The notify case now pins:
Contract F1 (
Contract F2.
The rest.
Next. The contract delta and landing are the seat's. |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv Contract reviewServed-tier: ① Derived judgments
② Declarations
③ Findings
④ Accepted deviations
Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv 席位核对Landing · 2026-11-21T20:47Z · head
|
Requested by Leehom · project thread
Fixes #35402
Clause-②: yes (widening): new error code
CHANGE_OWNER_DISABLED(403); new routesPOST /api/v1/data/:object/:id/change-ownerandPOST /api/v1/data/:object/change-owner; new client methodsdata.changeOwneranddata.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-ownerwith{ 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-ownerwith{ 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 andnotified. Every row that did not move is listed; none is skipped or sampled.Order of checks, per request:
update: the same gates every/datawrite passes.userActions.transferis off (explicitly, or by thecontrolled_by_parentdefault), is refused as a whole with403 CHANGE_OWNER_DISABLED, whoever asks, amodifyAllRecordsholder included, before any read or write.assertAssignableUser). The check follows the write path's rule for a user reference (objectql: a plainlookupwrite accepts a target the writer cannot read — the reference check probes it elevated, and onlymaster_detailasks 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 thequeuecolumn.owner_id: edit on the record plusallowTransferormodifyAllRecords, and the ADR-0142 queue admissions. Without the grant the answer is the data door's own403 PERMISSION_DENIEDand 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
transferoperation reports, so a pre-check would only restate it.notify: truesends the new owner one notification under the newrecord.owner_changedtopic, naming the record (or the count, for a bulk move). Its title rideskeyedText(messages.recordOwnerChangedTitle/messages.recordsOwnerChangedTitle, the object's label itself keyed asobjects.<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;notifiedreports what happened.A plain
owner_idupdate 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, andassertAssignableUser(extracted from the assigned-work hand-over; it now reads the target through the caller's own read first, as above).@objectstack/rest: thechange-owner-routes.tsregistrar, its two route-ledger rows (data-actionsfamily, 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.changeOwneranddata.changeOwnerMany.@objectstack/spec:CHANGE_OWNER_DISABLEDin the error-code ledger, under@objectstack/corebecause core stamps it (the provenance gate requires the stamping package's key). TheuserActions.transferliveness row is nowlive. 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_changedin the platform topic list, and the notice's two title entries in every shipped locale of itsmessagesbundle (theenentries are core's own English, so they cannot drift).content/docs/api/data-api.mdxdocuments both routes, their bodies, the 500 cap, the per-row report andCHANGE_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_parentdefault,ownership: 'org', asys_*object, amanagedByobject) 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 noqueuecolumn 400;PERMISSION_DENIEDandRECORD_NOT_FOUNDpassthrough; 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 theprivateshowcase_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_idupdate stays governed byallowTransferalone, so import mappings and hooks are unaffected. An author who wants a hard block declaresowner_idreadonly."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_idhas 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:
modifyAllRecords403 CHANGE_OWNER_DISABLED, single and bulk, owner unchangedshowcase_invoice_line)403 PERMISSION_DENIED, owner unchanged; in bulk, the row's failure code200with a per-row report. Dogfood:updated: 2, failed: 1, the other member's note listed asRECORD_NOT_FOUND. Core and rest: one moves, aPERMISSION_DENIEDrow and aRECORD_NOT_FOUNDrow listed200,owner_id: null, queue: note_triage; refused403 PERMISSION_DENIEDwithout the grantsys_notificationevent for this record, delivered to the new owner's inbox alone; title keyedMeasured, not assumed: on the showcase, after alice (holding the transfer grant) hands her private note to bob:
created_bystays alice;owner_idis bob.GET200,PATCH200.GET404,PATCH404. TheprivateOWD gives her no row access once she is not the owner, and being the creator, which theowner_only_writesfloor 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 aPATCH).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), thenpackages/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.tsafter a dogfood closure build. Expect 6 of 6 passing.Local runs
On 06b053c:
vitest run(full): Test Files 164 passed, Tests 3810 passed.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.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-loadsandcheck:i18n(whole-repo build); left to CI.Review round 1 (L1 7068420281, contract 7068497336), on the commits after a8787f4:
src/security75 files, 1455 tests passed; the target-read pins fail with the caller read removed (ablation: 3 failed) and pass with it.user-work-routes,change-owner-routes, hook-sentence ledger: 730 passed.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-spellingexit 0.Generated by Claude Code
https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi