Skip to content

Commit d4b14a8

Browse files
fix(core): the outside-closure refusal names the move when the holder already depends on the reader (#32982)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuXoji6hhHpSoiEVSsF3VSYf)_ Part of #32929 ## 维护者速读 - 问题:HotCRM 的 app 包看板读自家 revenue 模块的数据集,18.4.0 候选版返回 409。拒绝语只说「声明对持有包的依赖」,可模块本来就依赖 app,反过来声明会成环,启动直接失败(实测 `Circular dependency detected`)。 - 改法:只改 `outside-closure` 拒绝语。保留原来的「声明依赖」,后面加一句:持有包已经依赖读取方时,把读取的条目搬到持有包,或把被读的条目搬到读取方。 - 裁定:#32929 选二(6840360115);18.4.0 底线是「文案修正 + HotCRM 自修」(6840525219)。作者期拒绝挪到 18.4.1,另立卡。 - 答案不变:各门的状态码、错误码、`details.candidates`、解析到哪一项,全都不变,只是句子变长。另外修正三个 changeset 里「第一方 0」的说法,点名 HotCRM。 - 风险与回滚:纯文案。回滚就是 revert 本 PR。 - 需要你做的:无,席位落地。 Clause-②: no Metadata-protocol: none ## FROM → TO | Door | FROM (main a7c9729) | TO | |---|---|---| | Every package-scoped by-name read refused `outside-closure` (dataset query doors single and batch, `/meta/:type/:name?callerPackage=`, the picklist, flow, function, webhook, permission-set readers) | `… held outside the declared dependency closure of package "P": package "Q". Declare a dependency on the package that holds it (ADR-0141).` | Same sentence, then: `If that package already depends on "P", the dependency would be a cycle: move what reads it into that package, or move the <type> into "P" (ADR-0150 D3).` | | Status, code, `details.candidates`, the resolved item | unchanged | unchanged | | `.changeset/32072-dataset-resolve-by-package.md` | "first-party count for each: 0" | read in this repository: 0, plus a correction naming HotCRM's CRM Overview tile | | `.changeset/32310-dataset-caller-package.md` | "Who moves. Nothing first-party sent the parameter" | same, plus a correction: once the console sends it, HotCRM's tile is refused | | `.changeset/32311-dataset-caller-package-ui.md` | "The fix for those: add the holder to P's `dependencies`, or ship the dataset in P." | same, plus the cycle case (move the reading item into the holder) and HotCRM named | | `.changeset/32077-dataset-query-package.md` | "No first-party package references a dataset across packages." | same, plus a correction naming HotCRM's CRM Overview tile | ## Measured (step 0 on #32929, main a6be0fe, build-shaped artifact boot) An app package `com.qa.sib.app` and a module `com.qa.sib.rev` that declares it, both in one namespace. The module holds the object and the dataset; the app's dashboard binds it. - `POST /api/v1/analytics/dataset/query?callerPackage=com.qa.sib.app` returns 409 `outside-closure`, and so does the batch entry. The query with no package returns 200 (2 rows). `?callerPackage=com.qa.sib.rev` returns 200. - The fix the old sentence names (the app declares the module) does not boot: `[Kernel] Circular dependency detected: com.qa.sib.rev`. - Ablation: with #32337's caller arm switched off, the query returns 200/200. With #32804's admission arm switched off, it still returns 409/409. ## Tests - `packages/core/src/package-scoped-resolution.test.ts`: two new cases under `[#32929]`, the whole sentence for a dataset and the type label for an email template. Ablation: putting back the old sentence turns both red (2 failed / 30 passed); restoring it turns them green again (32/32). - `pnpm --filter @objectstack/core test`: 3362 / 3362 passed, run on b71abe3. - No other test pins the whole sentence. Every other reader asserts `toContain` on its head (`git grep "held outside the declared dependency closure"` over `*.test.ts`). - Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`), run on b71abe3: `--ran` gives 65 derived, 65 run, 0 NOT-MEASURED. 64 exit 0. `check-plugin-teardown-shape --self-test` exited 3 until its pinned fixture was fetched (shallow clone), then 0. `check:dual-build-cjs-loads` exited 3 until a full `pnpm build` ran, then 0 (123 entries / 72 packages). `check-empty-changeset --base origin/main` exits 1: this is the deliberate correction declared below. ## DELIBERATE CORRECTION (`check-empty-changeset`) Four pending release notes are corrected in this PR. Each counted 0 first-party consumers, and HotCRM is one. Where a note says how HotCRM fixes it, it now reads: "HotCRM fixes it in its own release, by moving the dashboard into the module or the dataset into the app package; the HotCRM lane chooses (#32929)." (review S1; ruling 6840525219, "Not ruled here"). The corrected sentences: - `.changeset/32072-dataset-resolve-by-package.md`: "(first-party count for each, read in this repository: 0 — … ; **corrected by #32929:** one first-party app outside this repository moves with the reader's package — HotCRM's CRM Overview dashboard, in its app package `app.objectstack.hotcrm`, binds the dataset `product_metrics` that its module package `app.objectstack.hotcrm.revenue` holds; …)" - `.changeset/32310-dataset-caller-package.md`: "- **Who moves.** … **Corrected by #32929:** once the console sends it (`32311-dataset-caller-package-ui`), one first-party app is refused — HotCRM's CRM Overview dashboard …" - `.changeset/32311-dataset-caller-package-ui.md`: "**The fix for those:** … When the holder already depends on P (a module of the app that reads it), that dependency is a cycle: move the reading item into the holder instead. **First-party (corrected by #32929):** HotCRM's CRM Overview dashboard …" - `.changeset/32077-dataset-query-package.md`: "No first-party package references a dataset across packages (read in this repository; **corrected by #32929:** one first-party app outside this repository does — HotCRM's CRM Overview dashboard … so once the console sends the item's package the tile is refused where it drew on 18.3.0; … Other first-party apps outside this repository: not measured)." (review S2) The dispatching seat confirms these by its own record. ## Acceptance notes - **Out of scope, carried to a follow-up card under #32929 (18.4.1):** - Authoring refusal: `indexResolvableDatasets` (`packages/lint/src/validate-widget-bindings.ts`) still treats every body of the artifact as resolution context, so `os validate` / `os build` keep accepting the tile the runtime refuses. A work-in-progress commit is on `claude/project-thread-ldkwcp-pr2` (c0ccb67, not tested on that head). - The CLI picklist hint (`packages/cli/src/utils/picklist-references.ts` `refusedReferenceHint`) and the publish probe's `widget_not_probed` fix (`packages/metadata-protocol/src/build-probes.ts` `datasetNotProbed`) still name only the dependency. - Whether the three app actions in HotCRM that launch module flows are refused: not measured. - HotCRM's own fix (move the dashboard into the revenue module) is the hotcrm card that is `Blocked-by: #32929`; this PR does not touch it. - Wording only: no package's answer moves, so no first-party consumer count changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUxLM4ELbDe8g3b14b <!-- signed: domain:server#1 · os-sales · session_01L6bhgVaKJ9TPfXPRhdqx3e --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent e336a33 commit d4b14a8

7 files changed

Lines changed: 41 additions & 5 deletions

‎.changeset/32072-dataset-resolve-by-package.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The query door also accepts an optional `?package=PACKAGE_ID`, the same exact qu
1818

1919
A publish's build probes read a dashboard widget's dataset by name, so a name several packages hold has no dataset to probe: the widget now gets one warning-tier `widget_not_probed` issue naming every holder, where it was skipped without a word.
2020

21-
**BREAKING** for answers that served one package's dataset for an address that does not name it, and for the failure answers around them (first-party count for each: 0 — no first-party package ships a dataset name another package also ships, no first-party package reads a dataset by bare name with a package caller, and nothing first-party sends `?package=` to the query door or reads a dataset at a package that does not hold it):
21+
**BREAKING** for answers that served one package's dataset for an address that does not name it, and for the failure answers around them (first-party count for each, read in this repository: 0 — no first-party package ships a dataset name another package also ships, no first-party package reads a dataset by bare name with a package caller, and nothing first-party sends `?package=` to the query door or reads a dataset at a package that does not hold it; **corrected by #32929:** one first-party app outside this repository moves with the reader's package — HotCRM's CRM Overview dashboard, in its app package `app.objectstack.hotcrm`, binds the dataset `product_metrics` that its module package `app.objectstack.hotcrm.revenue` holds; the module depends on the app, not the app on the module, so once the console sends the reader's package the tile answers `409 RESOURCE_CONFLICT` (`outside-closure`) where it drew on 18.3.0, and declaring the module from the app would be a dependency cycle the kernel refuses at boot. HotCRM fixes it in its own release, by moving the dashboard into the module or the dataset into the app package; the HotCRM lane chooses (#32929). Other first-party apps outside this repository: not measured.):
2222

2323
1. A bare `datasetName` two packages hold, on the query door and on `query_dataset`, ran the first listed. It is now `409 RESOURCE_CONFLICT` naming both, and nothing runs. Phase 1's install door already refuses the second holder, so only a deployment that booted with the clash (and was warned at boot) holds one. Fix: `?package=ID` on the query door; on `query_dataset`, rename one of the two datasets, since the tool takes no package.
2424
2. A bare by-name read of a dataset two packages hold — `GET /meta/dataset/:name`, and the protocol's `getMetaItem({ type: 'dataset', name })` it answers from — served the first registered. It is now `409 RESOURCE_CONFLICT` naming both. Fix: `/meta/dataset/NAMESPACE/:name` or `?package=ID`.

‎.changeset/32077-dataset-query-package.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ Metadata-protocol: none
2121

2222
An item authored in the environment (no `_packageId`, or the package-less `sys_metadata` sentinel) sends no `?package=`, so its read stays caller-less exactly as before. An inline dataset (the dashboard filter bar's option query, the Studio dataset preview) names no saved item and sends none. A `409` is shown as the server's sentence, naming every candidate, and is never retried with the bare name.
2323

24-
**BREAKING** (the dataset query of a package item, interim under the epic's ruling A): `?package=` is the exact qualifier (ADR-0150 D5), not the dependency-closure read of D3. **FROM:** a dashboard, report or list-view chart in package P, whose dataset only a dependency of P holds, is served by the bare read. **TO:** it is refused `409 RESOURCE_CONFLICT` (`not-held-by-qualifier`), naming the holder, and the item's widget or block shows that sentence. **The interim fix:** ship the dataset in the item's own package. No first-party package references a dataset across packages. Follow-ups #32310 (a caller-package arm on the dataset query door, with closure semantics) and #32311 (the console switches to it) restore the dependency case.
24+
**BREAKING** (the dataset query of a package item, interim under the epic's ruling A): `?package=` is the exact qualifier (ADR-0150 D5), not the dependency-closure read of D3. **FROM:** a dashboard, report or list-view chart in package P, whose dataset only a dependency of P holds, is served by the bare read. **TO:** it is refused `409 RESOURCE_CONFLICT` (`not-held-by-qualifier`), naming the holder, and the item's widget or block shows that sentence. **The interim fix:** ship the dataset in the item's own package. No first-party package references a dataset across packages (read in this repository; **corrected by #32929:** one first-party app outside this repository does — HotCRM's CRM Overview dashboard, in its app package `app.objectstack.hotcrm`, binds the dataset `product_metrics` that its module package `app.objectstack.hotcrm.revenue` holds, so once the console sends the item's package the tile is refused where it drew on 18.3.0; the module depends on the app, so declaring the module from the app is a cycle the kernel refuses at boot. Other first-party apps outside this repository: not measured). Follow-ups #32310 (a caller-package arm on the dataset query door, with closure semantics) and #32311 (the console switches to it) restore the dependency case.

‎.changeset/32310-dataset-caller-package.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ On the batch door the arm is read once, from the batch URL, for every query: a m
2828
2. `?callerPackage=` beside `?package=`, blank, `all`, repeated, or not a string (`?callerPackage[x]=`) is `400 VALIDATION_ERROR`, and nothing runs (on the batch, the whole request).
2929
3. A package id that is not installed gets the `?package=` answer for that id: `409` naming the holders, `404` when nothing holds the name.
3030
4. A deployment whose composed metadata protocol has a by-name read (`getMetaItem`) but no caller resolution (`resolveCallerPackageAddress`), or whose engine registry lacks the package-scoped reads the exact qualifier judges with, answers a `datasetName` sent with the arm `503 SERVICE_UNAVAILABLE` (on the batch, that query's entry), and runs nothing, where it answered `200` with the bare read. `@objectstack/metadata-protocol`'s protocol on an ObjectQL engine has both.
31-
- **Who moves.** Nothing first-party sent the parameter to either door. A script that sent it and relied on the bare read gets the reader's resolution.
31+
- **Who moves.** Nothing first-party sent the parameter to either door. A script that sent it and relied on the bare read gets the reader's resolution. **Corrected by #32929:** once the console sends it (`32311-dataset-caller-package-ui`), one first-party app is refused — HotCRM's CRM Overview dashboard, in its app package `app.objectstack.hotcrm`, binds the dataset `product_metrics` that its module package `app.objectstack.hotcrm.revenue` holds; the module depends on the app, not the app on the module, so once the console sends the reader's package the tile answers `409 RESOURCE_CONFLICT` (`outside-closure`) where it drew on 18.3.0, and declaring the module from the app would be a dependency cycle the kernel refuses at boot. HotCRM fixes it in its own release, by moving the dashboard into the module or the dataset into the app package; the HotCRM lane chooses (#32929). Other first-party apps outside this repository: not measured.
3232

3333
**The remedy.** Drop `?callerPackage=` for the bare read, send `?package=HOLDER` to read one holder's dataset, or add the holder to the reading package's `dependencies`.

‎.changeset/32311-dataset-caller-package-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ A saved dataset is read for the package of the item that references it, sent as
1818

1919
The package stays part of each query's signature, so a cached answer never crosses packages. An item authored in the environment (no `_packageId`, or the `sys_metadata` and `__runtime__` sentinels) sends no package, and its read stays caller-less exactly as before. An inline dataset names no saved item and sends none. A `409` is shown as the server's sentence on the widget and the report block, and as its status (`HTTP 409`) on the date range; the option-colour read keeps the theme palette. None of them is retried with the bare name. The `packageId` option (`?package=`) stays on both adapter methods for a caller that means the holder.
2020

21-
**What this does to the BREAKING note of the `?package=` change** (`32077-dataset-query-package`, the interim this follows up). That note refuses a dashboard, report or list-view chart in package P whose dataset only a dependency of P holds, with `409 RESOURCE_CONFLICT` (`not-held-by-qualifier`). After this change such an item is served again: the dependency's dataset, resolved for P. Two cases stay refused, now as `outside-closure`: a dataset held only by a package P does not declare in its `dependencies` (transitively), and a dataset authored in the environment rather than in a package. **The fix for those:** add the holder to P's `dependencies`, or ship the dataset in P.
21+
**What this does to the BREAKING note of the `?package=` change** (`32077-dataset-query-package`, the interim this follows up). That note refuses a dashboard, report or list-view chart in package P whose dataset only a dependency of P holds, with `409 RESOURCE_CONFLICT` (`not-held-by-qualifier`). After this change such an item is served again: the dependency's dataset, resolved for P. Two cases stay refused, now as `outside-closure`: a dataset held only by a package P does not declare in its `dependencies` (transitively), and a dataset authored in the environment rather than in a package. **The fix for those:** add the holder to P's `dependencies`, or ship the dataset in P. When the holder already depends on P (a module of the app that reads it), that dependency is a cycle: move the reading item into the holder instead. **First-party (corrected by #32929):** HotCRM's CRM Overview dashboard, in its app package `app.objectstack.hotcrm`, binds the dataset `product_metrics` that its module package `app.objectstack.hotcrm.revenue` holds; the module depends on the app, not the app on the module, so once the console sends the reader's package the tile answers `409 RESOURCE_CONFLICT` (`outside-closure`) where it drew on 18.3.0, and declaring the module from the app would be a dependency cycle the kernel refuses at boot. HotCRM fixes it in its own release, by moving the dashboard into the module or the dataset into the app package; the HotCRM lane chooses (#32929). Other first-party apps outside this repository: not measured.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/core': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
fix(core): a by-name read refused as held outside the reader's declared dependency closure now names the fix that works when the holder already depends on the reader
9+
10+
The `outside-closure` refusal (ADR-0150 D3), answered `409 RESOURCE_CONFLICT` by every package-scoped by-name door, told the reader to declare a dependency on the package that holds the item. When that package already depends on the reader, as a module depends on the app package of its suite, the dependency is a cycle the kernel refuses at boot (`Circular dependency detected`), so the only fix it named could not be followed. The sentence now keeps that fix and adds the one that can: move what reads the item into the package that holds it, or move the item into the reading package. Which item a read answers, its status, code and `details.candidates` do not change; only the message's wording does.
11+
12+
Measured on HotCRM's shape (#32929): an app package's dashboard bound to a dataset its own module holds, `POST /api/v1/analytics/dataset/query?callerPackage=<app>`, before: `… Declare a dependency on the package that holds it (ADR-0141).`; after, the same sentence followed by `If that package already depends on "<app>", the dependency would be a cycle: move what reads it into that package, or move the dataset into "<app>" (ADR-0150 D3).`

‎packages/core/src/package-scoped-resolution.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ describe('ADR-0150 D3 over a supplied holder set — a caller that belongs to a
7676
});
7777
});
7878

79+
describe('[#32929] the outside-closure sentence names both fixes', () => {
80+
it('keeps the dependency fix and adds the move for a holder that already depends on the reader', () => {
81+
const answer = resolvePackageScopedHolders({ type: 'dataset', name: 'n', callerPackageId: P }, packageScopedHolderSource([[A, 'a']]), closure([]));
82+
expect(answer).toMatchObject({ status: 'refused', reason: 'outside-closure', candidates: [{ kind: 'package', packageId: A }] });
83+
expect((answer as { message: string }).message).toBe(
84+
`The dataset "n" is held outside the declared dependency closure of package "${P}": package "${A}". `
85+
+ 'Declare a dependency on the package that holds it (ADR-0141). '
86+
+ `If that package already depends on "${P}", the dependency would be a cycle: move what reads it into that package, `
87+
+ `or move the dataset into "${P}" (ADR-0150 D3).`,
88+
);
89+
});
90+
91+
it('names the type in its own words', () => {
92+
const answer = resolvePackageScopedHolders({ type: 'email_template', name: 'n', callerPackageId: P }, packageScopedHolderSource([[A, 'a']]), closure([]));
93+
expect((answer as { message: string }).message).toContain(`or move the email template into "${P}"`);
94+
});
95+
});
96+
7997
describe('ADR-0150 D3 over a supplied holder set — a caller with no package', () => {
8098
it("answers the environment's own item first, then the unique package holder", () => {
8199
expect(resolve([[A, 'a'], [null, 'env']], [])).toMatchObject({ status: 'resolved', item: 'env', via: 'environment', holder: { kind: 'environment' } });

‎packages/core/src/package-scoped-resolution.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,14 @@ export function packageScopedRefusalMessage(refusal: Omit<PackageScopedRefusal,
560560
return `${subject} is held by ${refusal.candidates.length} ${counted} in this environment and the caller names ` +
561561
`no package: ${named}. Nothing picks one of them: address it by its package.`;
562562
case 'outside-closure':
563+
// [#32929] Two fixes, because the first is not always open: when the
564+
// holder already depends on the caller (a module of the app that reads
565+
// it), declaring the holder back is a dependency cycle the kernel
566+
// refuses at boot. The sentence is static; the answer does not move.
563567
return `${subject} is held outside the declared dependency closure of package "${refusal.callerPackageId}": ` +
564-
`${named}. Declare a dependency on the package that holds it (ADR-0141).`;
568+
`${named}. Declare a dependency on the package that holds it (ADR-0141). If that package already depends on ` +
569+
`"${refusal.callerPackageId}", the dependency would be a cycle: move what reads it into that package, or move the ` +
570+
`${typeLabel(refusal.type)} into "${refusal.callerPackageId}" (ADR-0150 D3).`;
565571
case 'not-held-by-qualifier':
566572
return `${subject} is not held by ${refusal.callerPackageId === null ? 'the environment' : `package "${refusal.callerPackageId}"`}, ` +
567573
`which the address names exactly (ADR-0150 D5): it is held by ${named}. Address it by its holder.`;

0 commit comments

Comments
 (0)