Skip to content

Commit f7f9345

Browse files
docs(metadata-protocol): name the disabled-package predicate on the $expand and relation-target checks, and pin its order (#37893)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoLphuot5c2R2SFweEMeNTrP)_ Fixes #35528 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;只改了代码注释、部署手册里"数据面"一条说明,外加一条测试。 - 为什么做:停用模块的关联展开与关联条件修好后(上一轮合并的修复),注释和手册仍只讲"接口是否开放",没讲"所属模块已停用"这一条。 - 出错会怎样:说明写错只会误导读文档的人,不影响运行;这次改动可以直接撤回。 - 要你做什么:无。 ## What changes - **N1 docblocks** (`packages/metadata-protocol/src/protocol.ts`, `protocol-query-validation.ts`): `refuseUnservedRelationTarget`, `servedExpand` and `servesExpansionTarget` now name the disabled-package predicate (`isObjectPackageDisabled`) beside the exposure decision, and say the package refusal is asked first. No code change. - **`EXPANSION_TARGET_OPERATION`**: the card said its "alike on both doors" sentence no longer held for a disabled target. Re-measured on `origin/main` e69fa46: it holds again. The dataset door's label pass now withholds a disabled package's target too (`analytics-service.ts` ~1737, wired in `service-analytics/src/plugin.ts` ~1803). So the sentence stays, and one added sentence says the disabled case renders the stored id on both doors. - **N2 pin**: a top-level `describe` in the existing harness file `protocol.expand-disabled-package-35427.test.ts`, which holds the PR #35444 pins. It covers a target that is both package-disabled and unexposed, in two forms: `apiEnabled: false`, and an `apiMethods: ['get']` whitelist that serves `$expand` but not `list`. The relation condition answers `404 OBJECT_PACKAGE_DISABLED` (`code` + `status` + `object`), the engine is never called, and `$expand` withholds both entries. A re-enable control shows each target's own exposure answer: `OBJECT_API_DISABLED` 404, `OBJECT_API_METHOD_NOT_ALLOWED` 405, and the whitelist target expanded. The whitelist case discriminates in both directions. - **N3 handbook** (`content/docs/deployment/marketplace-handbook.mdx`, Data plane bullet): a lookup from an enabled object into a disabled module keeps the stored id under `$expand`, and a condition on the related object's fields is refused `404 OBJECT_PACKAGE_DISABLED`. - Changeset: `@objectstack/metadata-protocol` patch. ## Tests <details><summary>metadata-protocol pin files + typecheck at 224d707; full package suite at 13b9b1b (the later commit is docblock-only)</summary> ``` vitest run src/protocol.expand-disabled-package-35427.test.ts src/protocol.expand-target-exposure.test.ts Test Files 2 passed (2) Tests 30 passed (30) tsc --noEmit (package typecheck; --listFiles counts the pin file: 1) os-verify-lock: VERDICT command-exit 0 vitest run (whole @objectstack/metadata-protocol) Test Files 372 passed | 9 skipped (381) Tests 23579 passed | 45 skipped (23624) os-verify-lock: VERDICT command-exit 0 ``` </details> ## Acceptance notes - The pin went green on `main` as written, so this PR adds no fix. The behaviour already held. - **Deviation from the claim's file surface:** the claim named "one new pin test file". AGENTS.md binds a new pin for a component that already has a shared harness file to go into that file as a top-level `describe` (ruling record 6583487846). The PR #35444 harness (`SCHEMAS` + `makeProtocol`) is exactly what this pin needs, so the pin is in that file under a `[#35528]` describe and the harness is not copied. Two schema rows and two lookups were added to its `SCHEMAS`. ## Verification Read first: (1) the new `describe` at the end of `protocol.expand-disabled-package-35427.test.ts`, (2) the `refuseUnservedRelationTarget` docblock in `protocol.ts`, (3) the `EXPANSION_TARGET_OPERATION` docblock. Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.expand-disabled-package-35427.test.ts` should report 15 passed, 3 of them under `[#35528]`. <details><summary>Derived gate families, local run at head 224d707</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 104 families from the 5 changed paths. All 104 were run after the final commit. Each exit code was captured before any pipe, and the `--ran` reconciliation over that record says: `104 derived famil(ies) accounted for — 103 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)`. - 103 exited 0, including `pnpm check:facade-delegation-only`: `packages/metadata-protocol/src/protocol.ts: 11705 lines, ceiling 11705 (0 left)`. - NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs --self-test` exited 3. The reason is a shallow clone: it cannot read its positive-control commit `621a4876`, and this run did not deepen the shared clone. CI runs it. </details> Ceiling note: the first head (13b9b1b) grew `protocol.ts` by 11 lines, and the facade line ceiling (0 margin, ruling 6897467376) went red on that. The second commit rewrites the docblocks so they take exactly the lines they replace, net 0 in `protocol.ts`. The ceiling was not raised. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibyBJGiLjzCtE4F6HHB)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1e721fd commit f7f9345

5 files changed

Lines changed: 69 additions & 18 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
Docblocks of the `$expand` and nested-relation target checks now name the
9+
disabled-package predicate beside the exposure decision: a lookup from an
10+
enabled object into a disabled package's object keeps its stored id under
11+
`$expand`, and a condition on that object's fields is refused `404
12+
OBJECT_PACKAGE_DISABLED`, before (and instead of) the exposure refusal when the
13+
target is also unexposed. No behaviour change; a new pin holds the order.

‎content/docs/deployment/marketplace-handbook.mdx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ its data is kept.
322322

323323
- **Data plane.** `/api/v1/data/<object>` and the by-name metadata reads answer
324324
the module's objects `404 OBJECT_PACKAGE_DISABLED`. Records stay in the
325-
database and come back on enable.
325+
database and come back on enable. A lookup from an enabled object into the
326+
module serves nothing of it either: `$expand` keeps the stored id, and a
327+
condition on the related object's fields is refused `404
328+
OBJECT_PACKAGE_DISABLED`.
326329
- **Navigation.** The module's `navigationContributions` leave the app's menu.
327330
- **Flows.** Record-change flows on the module's objects do not run while it is
328331
disabled, whoever writes the record.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ const INTERNAL_FIELD_WALK_DEPTH = 8;
220220
* that serves exactly those records by id; it is not the read this is. The
221221
* dataset door's dimension-label pass asks the same operation of the same
222222
* target (`@objectstack/service-analytics`), so a lookup renders its name, or
223-
* its stored id, alike on both doors.
223+
* its stored id, alike on both doors. A target of a disabled package renders
224+
* its stored id on both too: each door also asks the registry's
225+
* `isObjectPackageDisabled` and withholds it ({@link servesExpansionTarget}).
224226
*/
225227
const EXPANSION_TARGET_OPERATION = 'get';
226228

‎packages/metadata-protocol/src/protocol.expand-disabled-package-35427.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,19 @@ const SCHEMAS: Record<string, unknown> = {
5353
beta: lookup('beta', 'dp_beta'),
5454
open: lookup('open', 'dp_open'),
5555
hidden: lookup('hidden', 'dp_hidden'),
56+
off: lookup('off', 'dp_off'),
57+
listed: lookup('listed', 'dp_listed'),
5658
}),
5759
// The object the disable takes offline.
5860
dp_beta: object('dp_beta', undefined, { secret_note: { name: 'secret_note', label: 'Note', type: 'text' } }),
5961
// Enabled and exposed, with a lookup into the disabled one a hop further on.
6062
dp_open: object('dp_open', undefined, { inner: lookup('inner', 'dp_beta') }),
6163
// CONTROL: switched off by its own exposure, not by a package disable.
6264
dp_hidden: object('dp_hidden', { apiEnabled: false }),
65+
// [#35528] Disabled AND unexposed: the off switch, and a whitelist that
66+
// serves `get` (so `$expand`) but not `list` (so a relation condition).
67+
dp_off: object('dp_off', { apiEnabled: false }),
68+
dp_listed: object('dp_listed', { apiMethods: ['get'] }),
6369
};
6470

6571
function makeProtocol(opts: { disabled: Set<string>; registryAnswers?: boolean }) {
@@ -161,3 +167,30 @@ describe('[#35427] a nested-relation condition on a disabled package\'s object i
161167
expect(find).toHaveBeenCalledTimes(1);
162168
});
163169
});
170+
171+
describe('[#35528] a target both package-disabled and unexposed answers the package refusal first', () => {
172+
const BOTH = new Set(['dp_off', 'dp_listed']);
173+
const conditionError = async (disabled: Set<string>, rel: string): Promise<any> => {
174+
const { p, find } = makeProtocol({ disabled });
175+
const err: any = await p.findData({ object: 'dp_source', query: { where: { [rel]: { name: 'x' } } }, context: SYSTEM } as any).catch((e) => e);
176+
expect(find).not.toHaveBeenCalled();
177+
return { code: err.code, status: err.status, object: err.object };
178+
};
179+
180+
it('THE PIN: the relation condition answers 404 OBJECT_PACKAGE_DISABLED, not the exposure refusal', async () => {
181+
expect(await conditionError(BOTH, 'off')).toEqual({ code: 'OBJECT_PACKAGE_DISABLED', status: 404, object: 'dp_off' });
182+
expect(await conditionError(BOTH, 'listed')).toEqual({ code: 'OBJECT_PACKAGE_DISABLED', status: 404, object: 'dp_listed' });
183+
});
184+
185+
it('THE PIN: $expand withholds both entries', async () => {
186+
expect(await expandHandedToFind(BOTH, { expand: { off: { object: 'off' }, listed: { object: 'listed' }, open: { object: 'open' } } }))
187+
.toEqual({ open: { object: 'open' } });
188+
});
189+
190+
it('CONTROL: re-enabled, each answers its own exposure (off 404 / whitelist 405, the whitelist expanded)', async () => {
191+
expect(await conditionError(ENABLED, 'off')).toEqual({ code: 'OBJECT_API_DISABLED', status: 404, object: 'dp_off' });
192+
expect(await conditionError(ENABLED, 'listed')).toEqual({ code: 'OBJECT_API_METHOD_NOT_ALLOWED', status: 405, object: 'dp_listed' });
193+
expect(await expandHandedToFind(ENABLED, { expand: { off: { object: 'off' }, listed: { object: 'listed' } } }))
194+
.toEqual({ listed: { object: 'listed' } });
195+
});
196+
});

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5108,16 +5108,16 @@ export class ObjectStackProtocolImplementation implements
51085108
/**
51095109
* [#22737] A NESTED-RELATION condition is evaluated on its TARGET object
51105110
* (`ObjectQL.lowerRelationConditions` reads it as the caller), so the
5111-
* target is asked the spec's one exposure decision for
5112-
* {@link RELATION_CONDITION_TARGET_OPERATION}. A target it does not serve
5113-
* is REFUSED in the data door's own exposure answer: `404
5114-
* OBJECT_API_DISABLED` for the off switch, `405
5115-
* OBJECT_API_METHOD_NOT_ALLOWED` with the effective operation set for a
5116-
* whitelist. Refused, not withheld as {@link servedExpand} withholds:
5117-
* dropping a condition would widen the result, and a related object the
5118-
* caller may not read already answers this position with a refusal. The
5119-
* decision takes no caller. The target is named, as the `internal: true`
5120-
* refusal at this hop names it: it is the lookup's declared target.
5111+
* target is asked FIRST [#35427] whether its package is disabled (the data
5112+
* route's predicate and order: `404 OBJECT_PACKAGE_DISABLED`, unexposed or
5113+
* not), then the spec's one exposure decision for
5114+
* {@link RELATION_CONDITION_TARGET_OPERATION}: `404 OBJECT_API_DISABLED` for
5115+
* the off switch, `405 OBJECT_API_METHOD_NOT_ALLOWED` with the effective
5116+
* operation set for a whitelist. Refused, not withheld as {@link servedExpand}
5117+
* withholds: dropping a condition would widen the result, and a related
5118+
* object the caller may not read already answers this position with a
5119+
* refusal. The decision takes no caller. The target is named, as the
5120+
* `internal: true` refusal at this hop names it: the lookup's declared target.
51215121
*/
51225122
private refuseUnservedRelationTarget(target: string, param: string): void {
51235123
// [#25467 cut 3] The body moved to `protocol-query-validation.ts` (see `QueryValidationHost`).
@@ -5137,11 +5137,11 @@ export class ObjectStackProtocolImplementation implements
51375137
* `enable` block (`apiEnabled: false` answers 404, an `apiMethods` whitelist
51385138
* that does not grant the verb answers 405); the expansion's target was
51395139
* never asked, so `GET /data/{source}?$expand={lookup}` served the row
5140-
* fields of an object `GET /data/{target}` refuses. Every level is asked the
5141-
* spec's one decision, `canServeApiOperation(enable, 'get')`
5142-
* ({@link EXPANSION_TARGET_OPERATION} says why `get`), against that level's
5143-
* own target, and the decision takes no caller, so an administrator and a
5144-
* member get the same tree.
5140+
* fields of an object `GET /data/{target}` refuses. Every level's own target
5141+
* is asked the spec's one decision, `canServeApiOperation(enable, 'get')`
5142+
* ({@link EXPANSION_TARGET_OPERATION} says why `get`), and [#35427] whether
5143+
* its package is disabled (its route's `404 OBJECT_PACKAGE_DISABLED`); both
5144+
* take no caller, so an administrator and a member get the same tree.
51455145
*
51465146
* Withheld, not refused, and that is the precedent measured on this door: a
51475147
* related record the caller may not READ is answered by the engine's
@@ -5172,7 +5172,7 @@ export class ObjectStackProtocolImplementation implements
51725172
return servedExpand.call(host, source, expand, depth);
51735173
}
51745174

5175-
/** [#22661] Does the target's declared exposure serve an expansion read of it? */
5175+
/** [#22661, #35427] Do the target's declared exposure and its package (not disabled) serve an expansion read of it? */
51765176
private servesExpansionTarget(target: string): boolean {
51775177
// [#25467 cut 3] The body moved to `protocol-query-validation.ts` (see `QueryValidationHost`).
51785178
const readEngine = () => this.engine;

0 commit comments

Comments
 (0)