Skip to content

Commit 7c9b22b

Browse files
fix(core)!: Change Owner refuses an object of a disabled package with 404 OBJECT_PACKAGE_DISABLED (#36674)
Fixes #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 #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('[#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('[#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: #36683 in 499e92e and #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 `[#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>
1 parent 6902acb commit 7c9b22b

10 files changed

Lines changed: 224 additions & 27 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/core': patch
3+
'@objectstack/metadata-protocol': patch
4+
'@objectstack/spec': patch
5+
'@objectstack/rest': patch
6+
---
7+
8+
fix(core)!: Change Owner refuses an object of a disabled package with the data door's `404 OBJECT_PACKAGE_DISABLED`
9+
10+
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
11+
Metadata-protocol: none
12+
Skills-docs: none — no page under `skills/` teaches Change Owner; the refusal carries the data door's own sentence, which names the fix
13+
14+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no stored row, registry key or authored value changes. What moves is the answer the three Change Owner doors give for an object whose owning package is disabled, an answer that returns to what it was the moment the package is re-enabled; there is nothing for a migration to rewrite and no tombstone. -->
15+
16+
**BREAKING** for a caller that changes owners on a disabled package's object.
17+
18+
- 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 (and, when a cascade was named, its child rows), and when asked the notification was sent; `GET /api/v1/data/:object/change-owner/cascades` answered `200` with the object's cascade candidates.
19+
- TO: all three doors answer `404 OBJECT_PACKAGE_DISABLED`, naming the object, in the data door's words; nothing is read, written or sent. The fix for a caller: re-enable the package.
20+
21+
`POST /api/v1/data/:object/:id/change-owner` and `POST /api/v1/data/:object/change-owner` changed owners (and cascaded child rows), and sent owner-change notifications, on records of an object whose owning package was disabled, although every `/data` write refuses such an object. `changeRecordOwner` and `changeRecordsOwner` now ask the engine registry's `isObjectPackageDisabled` before the object's Change Owner switch is read, and refuse the whole call with the data door's own envelope (`code: 'OBJECT_PACKAGE_DISABLED'`, `status: 404`, the object name on `object`) before any user lookup, write or notification. Re-enabling the package restores the action; nothing is cached. `GET /api/v1/data/:object/change-owner/cascades` asks the same predicate in the same order (after the object resolves, before the switch), so the dialog lists nothing for such an object.
22+
23+
The refusal's constructor, `objectPackageDisabledError`, now lives in `@objectstack/core` and is exported from it; `@objectstack/metadata-protocol` re-exports the same function under the same name, so its importers are unchanged and the code, status and sentence stay one. The error-code ledger (`@objectstack/spec`) records `OBJECT_PACKAGE_DISABLED` under `@objectstack/core` as a provenance row; the code itself, its status and its wire shape are unchanged.

‎content/docs/api/data-api.mdx‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ Offered only on an object the platform gives a reassignable owner and whose
475475
included. The switch gates this action only: a plain `owner_id` update (an
476476
import, a hook, a `PATCH`) still needs the transfer grant and nothing else.
477477

478+
An object whose owning package is disabled is refused first, before its switch
479+
is read, with the data door's own `404 OBJECT_PACKAGE_DISABLED`: nothing is
480+
written and nobody is notified. Re-enable the package to change owners again.
481+
478482
**Body**: exactly one target, and an optional notification.
479483

480484
```json
@@ -509,8 +513,10 @@ A queue move answers `"ownerId": null, "queue": "support_triage"`.
509513
The same for a list of records: one by-id update per record, each under the
510514
same rules as the single route. Takes up to **500** ids; an empty list, a list
511515
over 500 and a list naming an id twice are refused `400` before anything is
512-
written. An object that does not offer Change Owner is refused as a whole,
513-
`403 CHANGE_OWNER_DISABLED`, before any record is read.
516+
written. An object of a disabled package is refused as a whole,
517+
`404 OBJECT_PACKAGE_DISABLED`, and an object that does not offer Change Owner
518+
`403 CHANGE_OWNER_DISABLED`, both before any record is read, written or
519+
notified.
514520

515521
**Body**: `{ "ids": ["lead_1", "lead_2"], "ownerId": "usr_123", "notify": true }`
516522
(or `queue` in place of `ownerId`).
@@ -591,9 +597,10 @@ that offers Change Owner itself. Two more filters apply: a child whose declared
591597
API exposure does not serve `update` is left out, and so is a child that belongs
592598
to a disabled package. Whether the caller may transfer on each child
593599
is the explain engine's `transfer` operation (`POST /security/explain`), which
594-
the Console's dialog asks before it offers a tick. Takes no query parameter;
595-
an object that does not offer Change Owner is refused `403
596-
CHANGE_OWNER_DISABLED`.
600+
the Console's dialog asks before it offers a tick. Takes no query parameter.
601+
An object of a disabled package is refused `404 OBJECT_PACKAGE_DISABLED`, as by
602+
the two write doors above, and an object that does not offer Change Owner is
603+
refused `403 CHANGE_OWNER_DISABLED`.
597604

598605
```json
599606
{ "success": true, "data": { "object": "account", "cascades": [

‎packages/core/src/index.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ export * from './utils/operation-user-message.js';
237237
// resolve with it (one name space for both doors).
238238
export * from './utils/object-not-found.js';
239239

240+
// The one `OBJECT_PACKAGE_DISABLED` envelope: the data door, the by-name
241+
// `/meta` reads and the Change Owner doors refuse an object of a disabled
242+
// package with it. `@objectstack/metadata-protocol` re-exports it.
243+
export * from './utils/object-package-disabled.js';
244+
240245
// [#22777] The one walk that finds a filter's nested-relation conditions and
241246
// their target objects: the data door (`@objectstack/metadata-protocol`) and
242247
// the MCP stdio data bridge (`@objectstack/mcp`) ask each target its exposure

‎packages/core/src/security/change-record-owner.test.ts‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const CALLER = { userId: 'u_manager', tenantId: 'org_1' };
5050
* without, answering the stored row; refused before any write, as
5151
* `ERR_READONLY_FIELD_REJECTED`, under `strictReadonlyWrites`.
5252
*/
53-
function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: string[]; locked?: (row: Row) => string[] } = {}) {
53+
function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: string[]; locked?: (row: Row) => string[]; disabledPackageObjects?: string[] } = {}) {
5454
/** Per update call, in order: whether it passed `strictReadonlyWrites: true`. */
5555
const strictWrites: boolean[] = [];
5656
const tables: Record<string, Row[]> = {
@@ -79,6 +79,8 @@ function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: stri
7979
calls,
8080
strictWrites,
8181
getSchema: (name) => SCHEMAS[name],
82+
// The engine registry's package predicate: a disabled package's object stays registered (getSchema resolves it).
83+
registry: { isObjectPackageDisabled: (name: string) => (opts.disabledPackageObjects ?? []).includes(name) },
8284
getConfigs: () => SCHEMAS,
8385
async count(object, q) {
8486
calls.push({ op: 'count', object, where: q?.where, context: q?.context });
@@ -421,6 +423,57 @@ describe('[#35402] notify', () => {
421423
});
422424
});
423425

426+
describe('[#36261] an object of a disabled package', () => {
427+
const DISABLED = { code: 'OBJECT_PACKAGE_DISABLED', status: 404 };
428+
429+
it('single: refused 404 OBJECT_PACKAGE_DISABLED, nothing read, written or sent', async () => {
430+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
431+
const messaging = { emit: vi.fn(async () => SENT) };
432+
const err = await refusalOf(changeRecordOwner(engine, 'lead', 'l1', { ownerId: 'u_next' }, CALLER, { notify: true, messaging }));
433+
expect({ code: err.code, status: err.status, object: err.object }).toEqual({ ...DISABLED, object: 'lead' });
434+
expect(engine.calls).toEqual([]);
435+
expect(messaging.emit).not.toHaveBeenCalled();
436+
expect(engine.tables.lead[0]!.owner_id).toBe('u_a');
437+
});
438+
439+
it('bulk: refused as a whole, 404 OBJECT_PACKAGE_DISABLED, nothing read, written or sent', async () => {
440+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
441+
const messaging = { emit: vi.fn(async () => SENT) };
442+
const err = await refusalOf(changeRecordsOwner(engine, 'lead', ['l1', 'l2'], { ownerId: 'u_next' }, CALLER, { notify: true, messaging }));
443+
expect({ code: err.code, status: err.status, object: err.object }).toEqual({ ...DISABLED, object: 'lead' });
444+
expect(engine.calls).toEqual([]);
445+
expect(messaging.emit).not.toHaveBeenCalled();
446+
});
447+
448+
it('is asked before the object\'s switch: a switched-off object of a disabled package answers the package refusal', async () => {
449+
const engine = fakeEngine({ disabledPackageObjects: ['pinned_lead'] });
450+
const err = await refusalOf(changeRecordOwner(engine, 'pinned_lead', 'x1', { ownerId: 'u_next' }, CALLER));
451+
expect({ code: err.code, status: err.status }).toEqual(DISABLED);
452+
});
453+
454+
it('a request naming a cascade is refused the same way, before any parent or child read or write', async () => {
455+
const rel = { object: 'lead_task', field: 'lead' };
456+
for (const run of [
457+
(e: ReturnType<typeof fakeEngine>) => changeRecordOwner(e, 'lead', 'l1', { ownerId: 'u_next' }, CALLER, { cascade: [rel] }),
458+
(e: ReturnType<typeof fakeEngine>) => changeRecordsOwner(e, 'lead', ['l1', 'l2'], { ownerId: 'u_next' }, CALLER, { cascade: [rel] }),
459+
]) {
460+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
461+
const err = await refusalOf(run(engine));
462+
expect({ code: err.code, status: err.status }).toEqual(DISABLED);
463+
expect(engine.calls).toEqual([]);
464+
expect(engine.tables.lead_task!.map((r) => r.owner_id)).toEqual(['u_a', 'u_b', 'u_a', 'u_b']);
465+
}
466+
});
467+
468+
it('control: the same object with its package enabled takes the change', async () => {
469+
const engine = fakeEngine({ disabledPackageObjects: ['memo'] });
470+
const result = await changeRecordOwner(engine, 'lead', 'l1', { ownerId: 'u_next' }, CALLER);
471+
expect(result).toEqual({ object: 'lead', id: 'l1', ownerId: 'u_next', notified: false });
472+
const report = await changeRecordsOwner(engine, 'lead', ['l2'], { ownerId: 'u_next' }, CALLER);
473+
expect({ updated: report.updated, failed: report.failed }).toEqual({ updated: 1, failed: 0 });
474+
});
475+
});
476+
424477
describe('[#35315 phase 2] the Change Owner cascade', () => {
425478
const ownersOf = (engine: ReturnType<typeof fakeEngine>, object: string) =>
426479
Object.fromEntries(engine.tables[object]!.map((r) => [r.id, r.owner_id]));

‎packages/core/src/security/change-record-owner.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import {
9999
} from '@objectstack/spec/data';
100100
import { SystemFieldName } from '@objectstack/spec/system';
101101
import { objectNotFoundError } from '../utils/object-not-found.js';
102+
import { objectPackageDisabledError } from '../utils/object-package-disabled.js';
102103
import { recordNotFoundError } from '../utils/record-not-found.js';
103104
import {
104105
assertAssignableUser,
@@ -203,7 +204,7 @@ export type ChangeOwnerTarget = { ownerId: string; queue?: undefined } | { queue
203204
* The slice of the data engine this module reads and writes through — the
204205
* engine's own public methods, so every write takes the ordinary path.
205206
*/
206-
export interface ChangeOwnerEngine extends Pick<UserWorkEngine, 'find' | 'update'> {
207+
export interface ChangeOwnerEngine extends Pick<UserWorkEngine, 'find' | 'update' | 'registry'> {
207208
/** The registered object definition, `undefined` when no object has the name. */
208209
getSchema(object: string): unknown;
209210
/** Every registered object definition — read to find the cascades declared to an object. */
@@ -332,12 +333,22 @@ export function changeOwnerOffRefusal(object: string, reason: string): Error {
332333
/**
333334
* The object's definition, when it offers Change Owner and can take the
334335
* target; throws otherwise, before anything is read or written: `404
335-
* OBJECT_NOT_FOUND`, `403 CHANGE_OWNER_DISABLED`, or `400 VALIDATION_ERROR`
336-
* for a queue target on an object with no queue column.
336+
* OBJECT_NOT_FOUND`, `404 OBJECT_PACKAGE_DISABLED`, `403
337+
* CHANGE_OWNER_DISABLED`, or `400 VALIDATION_ERROR` for a queue target on an
338+
* object with no queue column.
339+
*
340+
* [#36261] A disabled package's object serves no data door — every `/data`
341+
* write answers it `404 OBJECT_PACKAGE_DISABLED` — so neither does this one:
342+
* refused with that door's own envelope, asked of the registry predicate the
343+
* data plane asks (`isObjectPackageDisabled`), before the object's switch is
344+
* read and before any write or notification. `getSchema` still resolves such
345+
* an object (disable is reversible and keeps it registered), so the switch
346+
* alone would let it through.
337347
*/
338348
function offeredDefinition(engine: ChangeOwnerEngine, object: string, target: ChangeOwnerTarget): AnyRec {
339349
const def = asRecord(engine.getSchema(object));
340350
if (!def) throw objectNotFoundError(object);
351+
if (engine.registry?.isObjectPackageDisabled?.(object) === true) throw objectPackageDisabledError(object);
341352
const reason = changeOwnerOffReason(object, def);
342353
if (reason) throw changeOwnerOffRefusal(object, reason);
343354
if (target.queue !== undefined) {
@@ -699,9 +710,9 @@ export async function changeRecordOwner(
699710
* the caller, one by-id update each, and report every row that did not move.
700711
*
701712
* Refuses the whole call before any write: an empty list, a list longer than
702-
* the cap, a repeated id (`400 VALIDATION_ERROR`), an object that does not
703-
* offer the action (`403 CHANGE_OWNER_DISABLED`), and a target the single form
704-
* refuses.
713+
* the cap, a repeated id (`400 VALIDATION_ERROR`), an object of a disabled
714+
* package (`404 OBJECT_PACKAGE_DISABLED`), an object that does not offer the
715+
* action (`403 CHANGE_OWNER_DISABLED`), and a target the single form refuses.
705716
*/
706717
export async function changeRecordsOwner(
707718
engine: ChangeOwnerEngine,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [#7557, #24097] The ONE refusal for an object whose owning package is
5+
* disabled, raised by every API reader of that object: the data plane
6+
* (`ObjectStackProtocolImplementation.assertObjectRegistered`), the by-name
7+
* `/meta` reads (`getMetaItem`, `getMetaItemLayered`), and the Change Owner
8+
* doors (`security/change-record-owner.ts`). One constructor, so the answers
9+
* cannot drift apart in code, status or text.
10+
*
11+
* Why it lives in `@objectstack/core`: the Change Owner rules live here, and
12+
* ADR-0076 D2's boundary keeps this package from importing
13+
* `@objectstack/metadata-protocol`, where the refusal was first written. It
14+
* moved down for the reason `objectNotFoundError` and `recordNotFoundError`
15+
* did; `@objectstack/metadata-protocol` re-exports it from its original home.
16+
*/
17+
export function objectPackageDisabledError(object: string): Error {
18+
const disabled: any = new Error(
19+
`Object '${object}' belongs to a disabled package and is not being served. `
20+
+ 'Re-enable the package to restore access.',
21+
);
22+
disabled.code = 'OBJECT_PACKAGE_DISABLED';
23+
disabled.status = 404;
24+
disabled.object = object;
25+
return disabled;
26+
}

‎packages/metadata-protocol/src/protocol-authoring-refusals.ts‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,14 @@ import type { MetadataIssueEntry } from './protocol-metadata-issues.js';
1313

1414
/**
1515
* [#7557, #24097] The ONE refusal for an object whose owning package is
16-
* disabled, raised by every API reader of that object: the data plane
17-
* ({@link ObjectStackProtocolImplementation.assertObjectRegistered}) and the
18-
* by-name `/meta` reads (`getMetaItem`, `getMetaItemLayered`). One constructor,
19-
* so the two halves of the answer cannot drift apart in code, status or text.
16+
* disabled, raised by the data plane
17+
* ({@link ObjectStackProtocolImplementation.assertObjectRegistered}), the
18+
* by-name `/meta` reads (`getMetaItem`, `getMetaItemLayered`) and the Change
19+
* Owner doors. It lives in `@objectstack/core` (`utils/object-package-disabled.ts`,
20+
* moved down so core's Change Owner rules raise the same constructor); this
21+
* module re-exports it under its original name.
2022
*/
21-
export function objectPackageDisabledError(object: string): Error {
22-
const disabled: any = new Error(
23-
`Object '${object}' belongs to a disabled package and is not being served. `
24-
+ 'Re-enable the package to restore access.',
25-
);
26-
disabled.code = 'OBJECT_PACKAGE_DISABLED';
27-
disabled.status = 404;
28-
disabled.object = object;
29-
return disabled;
30-
}
23+
export { objectPackageDisabledError } from '@objectstack/core';
3124

3225
/**
3326
* [#7557, #24097] Whether `registry` says `name` is an object of a disabled

0 commit comments

Comments
 (0)