Skip to content

Commit e74ec56

Browse files
fix(rest,runtime,metadata-protocol)!: /published, REST /state, _drafts and the event-door absence body answer a disabled package's item as the by-name read does (#24247)
Part of #24210 (the second half: it closes `/published` on both transports, REST `/meta/object/NAME/state/FIELD`, `GET /meta/_drafts` on both transports, and the event and diff doors' absence body). Non-object `?layers=true` and `/layers` stay on the card for after #23050 slice 13b lands (they sit in G4, which is in flight), so #24210 remains open. Clause-②: no (narrowing) (owes one `CONTRACT_REVIEW_TIER` review before the queue) Implements triage 6239967422 (absence for a non-object type; `OBJECT_PACKAGE_DISABLED` for an object; no new or generalised code) and the seat's ruling 6241893667 (Q1 A door side, Q2, item 6) under claim 6243792589, dispatched by the `domain:engine` seat 1 (`session_01JtSQQ3EWsbNPzyYMug1tXy`), plus the first half's ACCEPT 6243458372 open question A (the event and diff doors' absence is byte-identical with the plain read). ## What changed Since PR #24223 the by-name read answers a disabled package's non-object item as absent, as the list omits it. Four more doors still read past that answer. Each now asks the same disabled-owner question and takes the exit a missing name takes. 1. **`GET /meta/_drafts`, both transports: the producer.** `listDrafts` (`packages/metadata-protocol/src/protocol.ts`) omits every draft whose row `packageId` names a disabled package, by the shared predicate `isItemOfDisabledPackage` (`package` never hidden). Neither door is edited. The package batch doors (`publish-drafts`, `discard-drafts`, the batch closure) read the repository's own `listDrafts`, not this method, so a disabled package's drafts still publish and discard (pinned as a resolution reader). 2. **REST G6, `/history`, `/audit`, `/diff`: the absence body.** `eventDoorRefusal` (the class member) and the `/diff` branch catch `fetchCurrentMetaDocument`'s withheld-item throw and answer it through `sendMetaItemAbsent`, recognised by `thrownAnswerIsBareNotFound`, the same predicate the plain read's catch asks. The answer is now the plain read's nested body, `{"error":{"code":"RESOURCE_NOT_FOUND","message":"Metadata item not found or access denied."}}`, instead of the flat `{"error":"…","code":"RESOURCE_NOT_FOUND"}`. `fetchCurrentMetaDocument` is not edited. A deleted item keeps its answer. 3. **REST G7, `GET /meta/object/:name/state/:field`.** Before reading the schema, the door asks the engine registry's `isObjectPackageDisabled(name)`. For such an object it reads the protocol's by-name read, whose `404 OBJECT_PACKAGE_DISABLED` the door's own catch renders, byte for byte what `GET /meta/object/:name` answers. The schema is never read for that name. This is the dispatcher twin's `disabledObjectAnswer` shape. It closes the interim transport split the first half named. 4. **REST G8, `GET /meta/:type/:name/published`, every type but `object` and `package`.** Before either exit (the stored published row, or the code/package snapshot), the door reads the plain read's kept protection envelope `packageId` and asks the engine registry's `isPackageDisabled`. A disabled owner takes the missing name's exits: no overlay, no snapshot, `404 NOT_FOUND`. The registry is reached through `wiredEngineOrLoud`, so a failed engine is a loud `503`, and a host with no engine withholds nothing. Objects keep the layered read's own refusal. 5. **Dispatcher `/published` twin** (`packages/runtime/src/domains/meta.ts`): the same question through `deps.getObjectQL` and `isServiceItemOfDisabledPackage`. A disabled owner answers the missing name's `404 RESOURCE_NOT_FOUND` "Not found". A throw of that plain read is the item read's answer (`errorFromThrown(e, 404)`). The producer `getMetaItemLayered` is not touched (ruling Q1 A: it keeps serving its resolution reader, the security catalog echo). There is no new public method, spec key, error code or enforcement change. ## Mechanism hypotheses (measured before any edit) - **H1, `/published`'s owner: half falsified.** On a live `pnpm dev:crm --fresh`, the layered envelope of a runtime-saved item carries **no** `packageId`, and its `effective` carries no `_packageId`. The stored row's `package_id` is grafted only by the plain read (`readMetaItem`). So the owner comes from the plain read's kept envelope `packageId` (the field the first half's echo fix reads, and the one the protocol's predicate asks of the resolved item), asked of the registry's `isPackageDisabled`. A REST door has no registry predicate of its own, so G8 reads the `objectQLProvider` slot (see Acceptance notes). - **H2, `_drafts`: holds.** `repo.listDrafts` rows carry `packageId`. The protocol method has exactly two callers, the two `_drafts` doors. The three batch doors call the repository directly. So the producer filters, and neither door is edited. - **H3, REST `/state`: holds.** The G7 handler reads `ql.registry.getObject` directly. The dispatcher's `disabledObjectAnswer` shape ports as-is, and no schema is read for the name. - **H4, the absence body: holds.** `sendMetaItemAbsent` is reachable from `eventDoorRefusal` and the `/diff` branch. The deleted item keeps its answer on all three doors (pinned and measured). ## Doors, measured over HTTP **REST:** `pnpm dev:crm -- --fresh` on a real socket. Before is `origin/main` `2bcd406a2` (full build); after is `d78cc5fd` (the fix commit; later commits change only tests, changesets and a ledger). **Dispatcher:** the real store (`SqliteWasmDriver`) and the real protocol (`ObjectQLPlugin`) under `createHonoApp`, driven through its fetch handler (scratch harness, not committed). Writable package `app.probe-24210b` holds dashboard `probe_dash` (saved twice), page `probe_page`, app `probe_app` (saved twice), object `probe_gadget` and a draft `probe_draft_dash`. Control package `app.control-24210b` holds the same shapes. `probe_gone` was saved and deleted. | Request, package disabled | REST before | REST after | Dispatcher before | Dispatcher after | |---|---|---|---|---| | `/meta/dashboard/probe_dash/history`, `/audit`, `/diff`; `/meta/app/probe_app/history`, `/diff` | 404 `RESOURCE_NOT_FOUND`, flat body | **404, the plain read's nested body** | not a dispatcher route | n/a | | `/meta/dashboard/probe_gone/history`, `/diff` (deleted) | 200 events; 200 empty diff | unchanged | n/a | n/a | | `/meta/dashboard/probe_dash/published`, `/meta/page/probe_page/published`, `/meta/app/probe_app/published` | 200, served | **404 `NOT_FOUND`**, = missing name | 200, served | **404 `RESOURCE_NOT_FOUND`**, = missing name | | `/meta/object/probe_gadget/published` | 404 `OBJECT_PACKAGE_DISABLED` | unchanged | (closed by PR #24223) | unchanged | | `/meta/object/probe_gadget/state/status?from=open` | 200, served | **404 `OBJECT_PACKAGE_DISABLED`**, = `GET /meta/object/probe_gadget` | (closed by PR #24223) | unchanged | | `GET /meta/_drafts` | lists `probe_draft_dash` | **omits it**; `ctrl_draft_dash` listed | lists it | **omits it**; control listed | | `GET /meta/_drafts?packageId=app.probe-24210b` | lists it | **`{"drafts":[]}`** | lists it | **`{"drafts":[]}`** | | control: `ctrl_dash` `/history`, `/diff`, `/published`; `ctrl_page/published`; `ctrl_gadget/state/status` | 200 | 200 | 200 | 200 | Byte equality on REST, compared over status, headers (minus date, request id, timing) and body: the disabled `probe_dash` by-name read, its `/history`, `/audit` and `/diff`, and `probe_app`'s `/history` and `/diff` all equal `GET /meta/dashboard/no_such_dash_x`. The three disabled `/published` reads equal `GET /meta/dashboard/no_such_dash_x/published`. On the dispatcher, both disabled `/published` reads answer `{"success":false,"error":{"code":"RESOURCE_NOT_FOUND","message":"Not found","httpStatus":404}}`, the missing name's bytes. Enabled readings after equal enabled readings before on both transports, after normalising timestamps, hashes and actor ids. Re-enabling restores every row on both transports. ## Callers of `GET /meta/_drafts` (objectui at the pinned `.objectui-sha` `5e15928b`, read-only clone) | Call site | Reads | After, for a disabled package | |---|---|---| | `PackagesPage.tsx` package sheet (`_drafts?packageId=`) | counts pending drafts and shows the Publish / Discard section | the section is hidden while the package is disabled. The `publish-drafts` / `discard-drafts` doors themselves still act on those drafts; re-enable and the section returns | | `usePendingDrafts`, `HomePage`, `DraftChangesPanel`, `usePublishAllDrafts` | the pending-changes list | the disabled package's drafts are not listed. The by-name draft read already answered them `404 NO_DRAFT` (first half) | | `ObjectHooksPanel`, `PackageOwdOverviewPanel`, `StudioDesignSurface` (`listDrafts({ packageId, type })`) | draft-only objects and hooks of one package | none for a disabled package, as its list read already omits its objects | No caller must tell "disabled" from "missing". ## Pins - `packages/objectql/src/package-disable-enforcement.test.ts`, the #7557 table: two API-reader rows (`listDrafts()`, `listDrafts({ packageId })`, which must stop), one resolution-reader row (the repository's `listDrafts`, which the batch doors read and must keep serving), and the control (the healthy package's two drafts still listed). The re-enable case walks the same rows. - `packages/rest/src/meta-disabled-package-doors.test.ts` (new), on the real protocol and a real `SchemaRegistry`: `/published` on both exits served, then equal to the missing name (status and body), then served again after re-enable, with a control package and `getPublished` never asked for a withheld item; `/state` served, then refused `404 OBJECT_PACKAGE_DISABLED` byte-equal to `GET /meta/object/:name`, `getObject` never asked the name, a control and a missing name, then served again; the slot outage case (a rejecting provider answers `503 SERVICE_UNAVAILABLE`, an absent one serves). - `packages/rest/src/meta-alternate-door-read-gates.test.ts`: the withheld gated dashboard and app now assert the event and diff doors' body is the plain read's own, byte for byte, and the deleted-item case asserts its `/diff` body is unchanged. - `packages/runtime/src/domains/meta-disabled-package-doors.test.ts`: the dispatcher `/published` of a non-object item on both exits (served, then byte-equal to the missing name with neither store asked, then served again), and a control. - `packages/rest/src/objectql-slot-consumer-census.test.ts`: the census counts the fourth consumer, `/published`, which passes its decidable test through `wiredEngineOrLoud`, and §3 cites its outage pin. - Pin sweep: `git grep` of the absence sentence, `_drafts` / `listDrafts`, `/published`, `disablePackage` / `isPackageDisabled` across every test. No other pin asserts the old answers. The suites of every touched package plus `http-conformance` were run (below). ## Verification **Rework (merge-queue removal, `CI_FAILURE`), head `ff82c7a1bf`:** merged `origin/main` `cbfa5e4335` as `07b1e218a5` (a merge commit). #23050 slice 13b (`646303eae`) had dropped `thrownAnswerIsBareNotFound` from `rest-server.ts`'s imports, and the event and diff doors here read it (TS2304 at `rest-server.ts` 3646 and 6419). It is re-imported from `./error-response.js`, the only source edit, reproduced red without it. At `ff82c7a1bf`: full `pnpm build` 76/76 and `@objectstack/rest` build exit 0; `rest`, `runtime` and `metadata-protocol` typecheck exit 0; suites `rest` 295 / 6034, `runtime` 413 / 6413, `metadata-protocol` 244 / 20641, the #7557 pin 15/15; `dispatch-gates` 78 derived, 78 run, all exit 0, `--ran` 0 NOT-MEASURED, 0 UNRUN. The readings below are the previous head's. Head `98dd4f8141`, after merging `origin/main` (`7715d049e`, a merge commit; no rebase, no force-push) with a full `pnpm build` (76/76). - **Suites** (at `0268f810`; the one later commit changes only the new REST test's `find` double and the engine-double ledger, and its file was re-run at `98dd4f8141`, 3/3): `@objectstack/rest` 295 files, 6032 passed (326 skipped); `@objectstack/runtime` 412 / 6313 (19 skipped); `@objectstack/objectql` 437 / 8244; `@objectstack/metadata-protocol` 244 files (3 skipped) / 20641; `@objectstack/http-conformance` 14 / 150. - **Typecheck scripts**, each package's own `typecheck` (`tsc --noEmit`, plus `check:test-typecheck` where the script carries it), each exit 0 at `98dd4f8141`: `metadata-protocol`, `objectql`, `runtime`, `rest`. - **Gates:** `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (no paths) derived 78 commands at `98dd4f8141`, all exit 0 (unshallowed clone). `--ran` says: "78 derived, 78 run, 0 NOT-MEASURED, 0 UNRUN". At the previous head two families went red on the new test's double, `check:engine-double-contract` (an unrecorded pinned double) and `check:objectql-double-limit` (a limit-blind `find`). Both are fixed in `98dd4f8141`. - **Ablations**, one per changed behaviour, each through `scripts/ablation-replace.mjs` with the restore proven `blob == HEAD`: - (a) `listDrafts`' predicate replaced by an always-true marker. `metadata-protocol` was rebuilt, and `ablation-dist-preflight` found the marker in `dist/`. The two `_drafts` API rows and the control went red (2 failed / 13 passed). After the restore and rebuild, `--absent` gave a dist reading of PASS (its tree reading exited 3 only on the untracked scratch harness, since removed), and the run was 15/15. - (b) `eventDoorRefusal`'s fork disabled: only the withheld-item case went red (1 / 427). (c) The `/diff` fork disabled: the same case only (1 / 427). - (d) REST `/state`'s disabled check: only the `/state` case (1 / 2). (e) REST `/published`'s withheld verdict: only the `/published` case (1 / 2). - (f) The dispatcher `/published` check: only its case (1 / 9). - (g) REST `/published` reading the slot with a swallowing `.catch`: only the outage case (1 / 3). ## Acceptance notes - **File surface.** REST edits sit in G6 (the `/history`, `/audit` and `/diff` handlers' calls), G7, G8 and the class member `eventDoorRefusal`. Nothing in G4, G5 or the class head. `meta-collection-routes.ts` is not edited, and neither is the dispatcher's `_drafts` (the producer carries it). - **Outside the claim's list:** `scripts/engine-double-contract.pinned.json` gains three rows for the new test file's pinned double. That is `check:engine-double-contract`'s own prescription (`--write`) for new pinned coverage, a mechanical ledger entry with no source change. - **A fourth `objectQLProvider` consumer.** G8 reads the engine registry, which no REST `/meta` door read before. It goes through `wiredEngineOrLoud`, and the census pin is updated to count it. - **Dispatcher transport** was measured through `createHonoApp`'s fetch handler (`app.request`), the `packages/qa/http-conformance` shape, not over a socket. The scratch harness sat untracked under `packages/qa/http-conformance` and was removed before the gates ran. - **Ungated types' event and diff doors** (`page`, `flow`, `report`, …) still serve a disabled package's item's events and diff. No per-caller gate exists there to bypass, as the first half's record (③.7) named. This half does not change them. --- _Generated by [Claude Code](https://claude.ai/code/session_01Y9zBTp9ePwgEEJXeqyLG4N)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 21b945c commit e74ec56

12 files changed

Lines changed: 530 additions & 22 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/metadata-protocol': minor
3+
---
4+
5+
fix(metadata-protocol)!: `listDrafts` omits a disabled package's drafts, as the list read omits its items
6+
7+
Clause-②: no (narrowing)
8+
9+
<!-- adr-0087: not-required (no-migration-prescription) the narrowing is the served set of the pending-drafts list for drafts whose owning package is disabled: no stored metadata changes shape, no spec key, export or error code is added or removed, and nothing must be rewritten; re-enabling the package restores the list -->
10+
11+
**BREAKING** (a served-set narrowing), shipped as `minor` under the launch-window convention for breaking changes.
12+
13+
`GET /meta/_drafts` (both transports) listed a disabled package's pending drafts, while the by-name draft read answers them `404 NO_DRAFT` and the list read omits the package's items.
14+
15+
- **Omitted now:** every draft whose `packageId` names a disabled package, with or without `?packageId=`. The predicate is the one the list and by-name reads ask. Drafts of the `package` type are never hidden.
16+
- **Unchanged:** the package batch doors (`POST /packages/:id/publish-drafts`, `/discard-drafts`) still publish and discard a disabled package's drafts; they read the store directly. Other packages' drafts are listed as before.
17+
18+
What changes for you: re-enable the package to see its pending drafts in the list again.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/rest': minor
3+
---
4+
5+
fix(rest)!: `/published` and `/meta/object/:name/state/:field` answer a disabled package's item as the by-name read does, and the event and diff doors' absence is the plain read's body
6+
7+
Clause-②: no (narrowing)
8+
9+
<!-- adr-0087: not-required (no-migration-prescription) the narrowing is the served set of two runtime read doors for an item whose owning package is disabled, plus the body of a 404 that already carried this status and code: no stored metadata changes shape, no spec key, export or error code is added or removed, and nothing must be rewritten; re-enabling the package restores the reads -->
10+
11+
**BREAKING** (a served-set narrowing), shipped as `minor` under the launch-window convention for breaking changes.
12+
13+
- **`GET /meta/:type/:name/published`, every type but `object` and `package`:** a disabled package's item is answered as a name with nothing behind it (`404 NOT_FOUND`, byte for byte), on both exits: the stored published row and the code/package snapshot. The owner is the one the by-name read's protection envelope names (`packageId`). Objects already answered `404 OBJECT_PACKAGE_DISABLED` here.
14+
- **`GET /meta/object/:name/state/:field`:** a disabled package's object is refused `404 OBJECT_PACKAGE_DISABLED`, what `GET /meta/object/:name` answers, as the runtime dispatcher's twin already does. The schema is not read.
15+
- **`/history`, `/audit` and `/diff`:** the `404 RESOURCE_NOT_FOUND` a disabled package's gated item gets is now the plain read's nested body, `{ "error": { "code": "RESOURCE_NOT_FOUND", "message": "Metadata item not found or access denied." } }`, instead of the flat `{ "error": "…", "code": "RESOURCE_NOT_FOUND" }`. Status and code are unchanged; read `body.error.code`.
16+
- **Unchanged:** items of enabled packages, a deleted item, and a name with nothing behind it.
17+
18+
What changes for you: re-enable the package to read its items' published versions and its objects' state machines again.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/runtime': minor
3+
---
4+
5+
fix(runtime)!: the dispatcher's `/meta/:type/:name/published` answers a disabled package's non-object item as a missing name
6+
7+
Clause-②: no (narrowing)
8+
9+
<!-- adr-0087: not-required (no-migration-prescription) the narrowing is the served set of one runtime read door for an item whose owning package is disabled: no stored metadata changes shape, no spec key, export or error code is added or removed, and nothing must be rewritten; re-enabling the package restores the read -->
10+
11+
**BREAKING** (a served-set narrowing), shipped as `minor` under the launch-window convention for breaking changes.
12+
13+
- **Absent now, `404 RESOURCE_NOT_FOUND` "Not found", byte for byte the missing name's answer:** `GET /meta/:type/:name/published` for an item of every type but `object` and `package` whose owning package is disabled, on the stored published row and the code/package snapshot alike. The owner is the one the by-name read's protection envelope names (`packageId`), as `RestServer`'s `/published` asks it. Objects already answered `404 OBJECT_PACKAGE_DISABLED` here.
14+
- **Unchanged:** items of enabled packages, and a name with nothing behind it.
15+
16+
What changes for you: re-enable the package to read its items' published versions again.

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25531,6 +25531,14 @@ export class ObjectStackProtocolImplementation implements
2553125531
* promote and discard by, with the canonical member spelled out, as the
2553225532
* by-name doors' `member` selector takes it back
2553325533
* ({@link bundleMemberDiscriminator}); absent for a type with no members.
25534+
*
25535+
* [#7557, #24210] A disabled package's drafts are omitted, as the list
25536+
* read omits its items and the by-name draft read answers them `404
25537+
* NO_DRAFT`: each row's `packageId`, asked of the same predicate ({@link
25538+
* isItemOfDisabledPackage}); `package` is never hidden. This method serves
25539+
* the `_drafts` doors only. The package batch doors (publish, discard, the
25540+
* batch closure) read the repository's `listDrafts` directly, so a
25541+
* disabled package's drafts still publish and discard.
2553425542
*/
2553525543
async listDrafts(request?: {
2553625544
packageId?: string;
@@ -25558,8 +25566,10 @@ export class ObjectStackProtocolImplementation implements
2555825566
// [#23073] The declared header (`ListDraftsResponseSchema`), with the
2555925567
// row's stored member on every draft of a bundled type: absent there
2556025568
// means the canonical member, which is spelled out here.
25569+
const served = drafts.filter((draft) => draft.type === 'package'
25570+
|| !isItemOfDisabledPackage(this.engine?.registry, { _packageId: draft.packageId }));
2556125571
return {
25562-
drafts: drafts.map(({ member: stored, ...header }) => {
25572+
drafts: served.map(({ member: stored, ...header }) => {
2556325573
const member = bundleMemberDiscriminator(header.type, stored);
2556425574
return member === undefined ? header : { ...header, member };
2556525575
}),

‎packages/objectql/src/package-disable-enforcement.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,29 @@ const READERS: Array<{
396396
servesByName(() => protocol.getMetaItem({ type, name: shippedName(type, PKG) }), (r) => r?.item),
397397
},
398398
]),
399+
{
400+
reader: 'listDrafts() — GET /meta/_drafts',
401+
enforces: true,
402+
why: '[#24210] the pending-changes list omits a disabled package\'s drafts, as its by-name draft read answers NO_DRAFT',
403+
serves: async ({ protocol }) =>
404+
((await protocol.listDrafts())?.drafts ?? []).some((d: any) => d?.packageId === PKG),
405+
},
406+
{
407+
reader: 'listDrafts({ packageId }) — GET /meta/_drafts?packageId=',
408+
enforces: true,
409+
why: '[#24210] naming the package does not bring its drafts back',
410+
serves: async ({ protocol }) =>
411+
((await protocol.listDrafts({ packageId: PKG }))?.drafts ?? []).length > 0,
412+
},
413+
{
414+
reader: 'the repository\'s listDrafts — the package batch doors (publish-drafts, discard-drafts)',
415+
enforces: false,
416+
why: '[#24210] a disabled package\'s drafts still publish and discard: those doors define their batch here',
417+
serves: async ({ protocol }) => {
418+
await (protocol as any).ensureOverlayIndex();
419+
return ((await (protocol as any).getOverlayRepo().listDrafts({ packageId: PKG })) ?? []).length > 0;
420+
},
421+
},
399422
{
400423
reader: 'assertObjectRegistered — the data plane (findData / getData funnel here)',
401424
enforces: true,
@@ -587,6 +610,11 @@ describe('#7557 (A) — a disabled package stops serving, on every API reader at
587610
expect(served).toEqual(allTrue(served));
588611
const app: any = await h.protocol.getMetaItem({ type: 'app', name: 'healthy_app' });
589612
expect(app?.item?._packageId).toBe(OTHER_PKG);
613+
// [#24210] …and its pending drafts are still listed, both of them.
614+
const drafts = (await h.protocol.listDrafts()).drafts;
615+
expect(drafts.filter((d) => d.packageId === OTHER_PKG).map((d) => `${d.type}/${d.name}`).sort())
616+
.toEqual(['app/healthy_app', 'object/healthy_widget']);
617+
expect(drafts.filter((d) => d.packageId === PKG)).toEqual([]);
590618
});
591619

592620
it('[#24210] the protection envelope stays: the write doors\' verdict on the address is not the item', async () => {

‎packages/rest/src/meta-alternate-door-read-gates.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,8 @@ describe('[#20156] edges', () => {
10161016
const history = await drive(rest, '/history', 'doc', 'crm_admin_runbook');
10171017

10181018
expect(envelope(diff)).toEqual({ status: 404, code: 'RESOURCE_NOT_FOUND' });
1019+
// [#24210] Unchanged by the withheld-item answer: already the plain read's nested body.
1020+
expect(diff.body).toEqual({ error: { code: 'RESOURCE_NOT_FOUND', message: 'Metadata item not found or access denied.' } });
10191021
expect(text(diff)).not.toContain(DOC_SECRET);
10201022
expect(history.statusCode).toBe(200);
10211023
expect(Array.isArray(history.body?.events)).toBe(true);
@@ -1040,9 +1042,18 @@ describe('[#20156] edges', () => {
10401042
protocol.historyMetaItem.mockClear();
10411043
protocol.auditMetaItem.mockClear();
10421044
protocol.diffMetaItem.mockClear();
1045+
// [#24210] The plain read's own answer for this withheld item, the
1046+
// missing name's nested body (`sendMetaItemAbsent`), is the one
1047+
// these doors give, byte for byte: not the flat `{ error, code }`.
1048+
const plain = await drive(rest, '', type, name);
1049+
expect({ status: plain.statusCode, body: plain.body }).toEqual({
1050+
status: 404,
1051+
body: { error: { code: 'RESOURCE_NOT_FOUND', message: 'Metadata item not found or access denied.' } },
1052+
});
10431053
for (const suffix of ['/history', '/audit', '/diff']) {
10441054
const res = await drive(rest, suffix, type, name);
10451055
expect(envelope(res), `${type} ${suffix} withheld`).toEqual({ status: 404, code: 'RESOURCE_NOT_FOUND' });
1056+
expect(text(res), `${type} ${suffix} withheld body`).toBe(text(plain));
10461057
expect(text(res), `${type} ${suffix}`).not.toContain('w_open_matters');
10471058
expect(text(res), `${type} ${suffix}`).not.toContain('nav_payroll_runs');
10481059
}

0 commit comments

Comments
 (0)