Repository navigation
Commit d9fabb2
fix(metadata-protocol): the publish probes skip a missing widget dataset, not check the read's envelope (#34669)
Fixes #34560
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:发布后的运行时探针在读取仪表盘组件引用的数据集时,若数据集不存在,现在按「图问题」跳过,不再把读取结果的外层信封当成数据集去检查。
- 为什么改:按名称读取元数据时,条目不存在会返回一个 item
为空的外层信封,而不是空值;读取函数把信封本身当成了数据集,导致该组件被计入「已检查」,还会报出一条假的「组件查询失败」(已实测复现)。
- 风险与回滚:极低。只改一行读取逻辑:信封里没有 item 就返回空;存在的数据集读取方式不变。回滚即还原该行。
-
先看:`packages/metadata-protocol/src/build-probes.ts`(`publishedItemReader`
的返回行);`packages/metadata-protocol/src/build-probes-dataset-holders.test.ts`(新增的
`[#34560]` 用例组)。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/build-probes-dataset-holders.test.ts`,预期 13 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
`publishedItemReader` (the item read the ADR-0038 L3 publish probes use,
over the protocol facade at `protocol-history-and-publish.ts`) returned
`wrapper?.item ?? wrapper`. The real by-name read `getMetaItem` answers
an item nothing holds with its envelope (`{ type, name, item: undefined,
lock, editable, … }`), never a throw and never `undefined`, so the
reader handed the envelope to the widget plane as the dataset body. A
widget naming a missing dataset was then counted in `checked.widgets`,
and its query ran over the envelope, which reports a false
`widget_query_failed`.
The reader now returns the envelope's `item` alone (`envelope?.item`). A
dataset that exists is read exactly as before; a missing one reads as no
body, so the widget takes the dangling-dataset path again (an L1 graph
finding, not probed, not counted).
Why the fallback existed: it was born with the probes (`106ce3d1dc`,
ADR-0038 L3) as a defensive spread for a protocol that might answer a
bare body. No producer ever did: `getMetaItem` answered an envelope then
and answers one now. Every double that feeds `publishedItemReader` was
checked, and none returns a bare body:
- `build-probes-dataset-holders.test.ts` (the `#31700` protocol double):
answers `{ item }`, `undefined`, or throws
`PackageScopedNameRefusedError`;
- `packages/rest/src/analytics-routes.test.ts` and
`packages/runtime/src/domains/meta-qualified-item-read.test.ts`: drive
the real `ObjectStackProtocolImplementation`, on datasets that exist or
that are refused.
`packages/metadata-protocol/src/build-probes-dataset-holders.test.ts`
gains a top-level `[#34560]` describe that drives
`ObjectStackProtocolImplementation` itself (its real `getMetaItem` and
`resolveCallerPackageAddress`) over a registry double that reads
`dataset` by package, as `SchemaRegistry` does. So the envelope under
test is the one the read builds, not a hand-copied one. It covers both
reader arms, from the publishing package (the publish path) and by name:
- the real read answers `missing_ds` with an envelope whose `item` is
undefined, and the reader returns `undefined` for it;
- the widget plane: `checked.widgets` is 1 (only the existing dataset),
no issue codes, and only `own_ds` is queried;
- CONTROL: an existing dataset is handed over as its body (no `item`
key).
`scripts/engine-double-contract.pinned.json` gains one row: the new
engine double's `findOne` is pinned through
`assertEngineFindOnePredicate`, and `check:engine-double-contract` asks
the ledger to record it (`--write`: 1 row added, 0 lost).
## Tests
Premise, measured on the unmodified `build-probes.ts` (`origin/main`
`082f9c2945`) with the new pin: 4 of the new cases fail, with the real
envelope and the false finding in the output.
<details><summary>Premise reading on origin/main source</summary>
```text
× read from package com.qa.app: the real read answers a missing dataset with its envelope, and the reader hands the probes no body
× read from package com.qa.app: the widget takes the L1 skip path: not counted, not queried, no widget_query_failed
× read by name: the real read answers a missing dataset with its envelope, and the reader hands the probes no body
× read by name: the widget takes the L1 skip path: not counted, not queried, no widget_query_failed
AssertionError: expected { type: 'dataset', …(7) } to be undefined
+ Received:
{ "deletable": true, "editable": true, "item": undefined, "lock": "none",
"name": "missing_ds", "resettable": false, "type": "dataset", "version": null }
AssertionError: expected { checked: 2, …(2) } to deeply equal { checked: 1, codes: [], …(1) }
- "checked": 1,
- "codes": [],
+ "checked": 2,
+ "codes": [ "widget_query_failed" ],
"queried": [
+ "missing_ds",
"own_ds",
Tests 4 failed | 9 passed (13)
```
</details>
<details><summary>After the fix</summary>
```text
src/build-probes-dataset-holders.test.ts Tests 13 passed (13)
pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2
Test Files 348 passed | 9 skipped (357)
Tests 23052 passed | 45 skipped (23097)
os-verify-lock: VERDICT command-exit 0
pnpm --filter @objectstack/metadata-protocol typecheck (tsc --noEmit; --listFiles includes the test file)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation: restore the fallback, the pin goes red;
restore, the blob equals HEAD</summary>
`node scripts/ablation-replace.mjs` on `build-probes.ts`, anchor `return
envelope?.item;` replaced with `return envelope?.item ?? envelope ??
undefined;` (the pre-fix fallback). The test imports `./build-probes.js`
by relative specifier, so it reads `src/`, not `dist/`.
```text
ablation-replace: anchor x1 -> x0
ablation-replace: replace " return envelope?.item ?? envelope ?? undefined;" x0 -> x1
ablation-replace: ok mutation landed: anchor 1 -> 0, blob feb1269 -> de11d1693def
Tests 4 failed | 9 passed (13) (the same four cases as the premise reading)
ablation-replace: ok restored: blob == HEAD (feb1269) and `git diff HEAD` is empty
```
</details>
## Acceptance notes
- The analytics double in the pin refuses a body that binds no object.
That is how the false `widget_query_failed` shows up in the test.
Whatever the real analytics service does with an envelope, the reader
fix keeps the envelope from reaching it.
- The registry double declares `dataset` read by package
(`readsByPackage`), as `SchemaRegistry` does. With
`NO_PACKAGE_SCOPED_READS` alone, the real read refuses the bare
`dataset` read as unjudgeable (ADR-0150 D2/D3) before it reaches the
envelope.
## Verification
Every reading below was taken at head `aaafe49eff` (the branch with
`origin/main` merged in; `main` had moved `meta-compile-cache.ts` /
`meta-overlay-cache.ts` in this package, which `getMetaItem` reads
through, so the package suite was run again after the merge).
- `pnpm --filter @objectstack/metadata-protocol exec vitest run
--maxWorkers=2` then `pnpm --filter @objectstack/metadata-protocol
typecheck`: Test Files 348 passed | 9 skipped (357), Tests 23056 passed
| 45 skipped (23101); `VERDICT command-exit 0`.
- Derived gate families (`node scripts/pm/dispatch-gates.mjs
--commands`, derived at `aaafe49eff`): 73 run, each exit code captured
before any pipe; `--ran` reconciliation: `Run reconciliation — 73
derived, 73 run, 0 NOT-MEASURED, 0 UNRUN.` The dist-reading families
(`check:dual-build-cjs-loads`, `check:lean-entry-closure`,
`check:dts-closure`, `check:published-files`) ran after a full `turbo
run build --filter=!@objectstack/docs` (`VERDICT command-exit 0`) and a
rebuild of this package after the merge.
- Not run locally, declared to CI: `test:repo`, and the importers'
suites in `@objectstack/rest` and `@objectstack/runtime` (the reader's
exported type is unchanged; its answer changes only for an item nothing
holds, which neither suite reads). Dogfood: n/a (no `!` in the title,
`Clause-②: no`).
<details><summary>Gate record (command :: exit code)</summary>
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:agent-test-spelling :: exit 0
pnpm check:bash32-floor :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:entry-guard :: exit 0
pnpm check:error-code-casing :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:object-def-param-keys :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:parse-guard :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:pnpm-filter-targets :: exit 0
pnpm check:pnpm-flag-spellings :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:scripts-symbol-anchors :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPJxG4vBVaLCBWLcWJ)_
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmPJxG4vBVaLCBWLcWJ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0004e8d commit d9fabb2
4 files changed
Lines changed: 137 additions & 2 deletions
File tree
- .changeset
- packages/metadata-protocol/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
282 | 286 | | |
283 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
| |||
0 commit comments