Repository navigation
Commit 4bba8b8
fix(metadata-protocol)!: judgesPackageLessRows returns a plain boolean, and the boot load joins the hydration-state pins (objectstack-ai#33483)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDwkEEJd65kqFZGFjQnzBQt)_
Fixes objectstack-ai#32716
Clause-②: yes (narrowing)
Metadata-protocol: none
**BREAKING** for a TypeScript caller that narrows `type` to
`PackageScopedType` through the exported
`judgesPackageLessRows(registry, type)` (for example `if
(judgesPackageLessRows(r, t)) useScoped(t)`): its return type is now
`boolean`, so that call no longer compiles. Call
`isPackageScopedType(type)` from `@objectstack/core` first. The runtime
answer is unchanged; the level stays patch.
<!-- adr-0087: not-required (no-migration-prescription) no key of any
schema is added, removed, renamed or re-shaped and no stored row changes
shape: what moves is one exported function's TypeScript return type -->
## 维护者速读
- 改了什么:① `judgesPackageLessRows` 的返回类型由类型谓词改为普通
`boolean`,运行时答案不变;`packageLessRowOwners` 改用 `isPackageScopedType` 收窄类型。②
N3 实测:按包精确读一条包外 action
存储行,在载入前后(启动加载、列表读、裸槽副本)答案一致,都是持有者自己的条目,所以不改代码,只把「启动加载」补进现有的载入状态 pin。
- 为什么改:① 谓词会让调用方的 false 分支被收窄成 never,但 false 其实取决于注册表。② 卡片说的「载入前 200、载入后
409」在当前 main 上已不存在(objectstack-ai#32568 的裁决已经处理),这里实测确认并钉住启动加载这一路。
- 风险与回滚:仅类型签名与测试;无读答案变化。回滚 = revert 本 PR。
-
先看:`packages/metadata-protocol/src/protocol-exact-qualifier.ts`(`judgesPackageLessRows`
签名与 `packageLessRowOwners`
首行);`packages/objectql/src/package-scoped-exact-qualifier.test.ts` 的
location 4 `STATES`。
- 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run
src/package-scoped-exact-qualifier.test.ts -t "location 4"`,预期全部通过,含新增的
`after the boot load` 用例。
- 需要你做的:无,席位落地。
## What changes
1. **N1.** `judgesPackageLessRows(registry, type)` returned the type
predicate `type is PackageScopedType`. Its `false` depends on the
registry (`readsByPackage`), so the predicate narrowed a package-scoped
type to `never` in a caller's `false` branch. It now returns `boolean`.
One caller relied on the predicate: `packageLessRowOwners` passed the
narrowed `type` to `isPlatformRequestedBareName`. It now narrows through
`isPackageScopedType`, which depends on the type alone. The CLI caller
(`stored-package-references.ts`, a `filter`) typechecks unchanged. The
runtime answer is unchanged.
2. **N3, measured: the answers are the same, so no read moves.** A
stored package-less `action` row of a name a package ships was read at
the holder's exact address (`?package=`) and in the layered read. It was
read before and after each hydration path: the boot load
(`loadMetaFromDb`), the list read's hydrator (`getMetaItems`), and a
copy in the registry's bare slot stamped `''` or `sys_metadata`. Each
path was run with one holder and with two holders in both registration
orders. The answer was the holder's own item every time (200), and the
layered read reported no overlay. The card's 200-before / 409-after
premise came from before the epic ruling 6817768147 on objectstack-ai#32568. That
ruling's change makes the hydrator decline the row
(`hydrateOverlayIntoRegistry`) and makes the exact read replace a
bare-slot copy (`declinedCopyReplaced`). The list read and the bare-slot
copies were already pinned (location 4 of `[objectstack-ai#32568]`). The boot load was
not, so this PR adds it to those pins for `action`, `queue` and `tool`,
with one holder and two.
No ADR-0150 D4 ruling is needed for N3: nothing differs, so nothing is
implemented beyond the pins.
## Tests
- `packages/metadata-protocol/src/protocol-exact-qualifier.test.ts`: a
new case, `[objectstack-ai#32716 N1]`. It is checked by `tsc`, and the package's
`typecheck` compiles the file (`tsc --listFiles` lists it). In the
`false` branch, a `hook` typed `PackageScopedType` keeps that type.
- `packages/objectql/src/package-scoped-exact-qualifier.test.ts`,
location 4: a new state, `after the boot load`, in both registration
orders × `action`/`queue`/`tool` (6 new cases). The one-holder case now
walks before → after the boot load → after the read-side hydrator. The
boot-load leg asserts the load reached the row (`loaded: 1, errors: 0`),
so the pin cannot pass without a load.
All runs on head `4bb529d89` (the merge of `origin/main` 0c2aeb9 into
the branch), through `scripts/pm/os-verify-lock.sh`:
<details><summary>Unit and package runs</summary>
- `pnpm --filter @objectstack/metadata-protocol typecheck` → exit 0;
`pnpm --filter @objectstack/metadata-protocol test` → Test Files 340
passed, 9 skipped (349); Tests 22866 passed, 43 skipped. VERDICT
command-exit 0.
- `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2
src/package-scoped-exact-qualifier.test.ts` → Tests 294 passed (294).
Before the change the file held 288; the 6 new cases are the boot-load
state.
- `pnpm --filter @objectstack/cli typecheck` (after building its
dependency closure, which included the new `.d.ts`) → exit 0, and
`check:test-typecheck` OK. This is the one other caller of
`judgesPackageLessRows`.
- `objectql` is a tests-only touch here: its full suite and the
`integration` layers are left to CI (`Test Core`).
</details>
<details><summary>Ablations (one-shot; nothing left in the
tree)</summary>
- **N1.** Ran `scripts/ablation-replace.mjs` on
`protocol-exact-qualifier.ts`, replacing the anchor `type: string):
boolean {` with the predicate `type is
import('@objectstack/core').PackageScopedType`. The anchor went x1 to x0
and the blob changed. `typecheck` then went RED, with one error at the
new pin: `protocol-exact-qualifier.test.ts(98,42): error TS2344 ...
Actual: never`. The file was restored to blob == HEAD and `git diff
HEAD` came back empty.
- **N3 boot-load pin.** The hydrator's decline branch in
`protocol-registry-hydration.ts` (`if (scoped && canonicalType !==
'flow' && !options.packageId && host.declinesStoredRow(`) was put behind
an always-false guard. The rebuilt `dist/` was proven to carry the
marker (`ablation-dist-preflight`). Location 4 then went RED, 6 failed:
`after the boot load exact: expected 'stored' to be 'alpha action'`, the
same for `queue` and `tool`, plus the pre-existing disabled-holder
cases. After the restore, the rebuild was proven free of the marker
(`--absent`), and the file is back to 294 passed.
</details>
<details><summary>N3 measurement on main (ba35dfd with only the
type-only N1 edit on top; a throwaway describe, not committed)</summary>
The stored package-less `action` row is `approve`, and A and B are the
shipping packages. Below, "own" means the holder's own item, and
"layered own" means the layered read reported no overlay and its
effective item was the holder's own.
| holders | hydration | `?package=A` before / after | `?package=B`
before / after | layered before / after |
|---|---|---|---|---|
| A | boot load | 200 own / 200 own | 409 not held / 409 not held | own
/ own |
| A | list read | 200 own / 200 own | 409 / 409 | own / own |
| A | bare copy `''`, `sys_metadata` | 200 own / 200 own | 409 / 409 |
own / own |
| A+B, B+A | boot load | 200 own / 200 own | 200 own / 200 own | own /
own |
| A+B, B+A | list read | 200 own / 200 own | 200 own / 200 own | own /
own |
| A+B, B+A | bare copy `''`, `sys_metadata` | 200 own / 200 own | 200
own / 200 own | own / own |
The boot load reported `{loaded:1, errors:0}` and left the holder's slot
holding the holder's own item. A boot load run before the package
registers, and then the package, also gives 200 own at each holder's
exact address.
</details>
## Acceptance notes
- **Clause-② reading.** First declared `no`; review#3's contract record
(6885158237) ruled the exported return type public surface, so a caller
narrowing through the predicate's `true` branch stops compiling: `yes
(narrowing)`, `!` title, BREAKING paragraph, one ADR-0087 not-required
marker (same reading as review#1 on objectstack-ai#33121). Delta head 82cc3c1 changes
only the changeset and this body.
- **Not in scope, harness observation only, not filed.** In the same
harness, a bare read naming no package with a bare-slot copy in place
answers differently from the exact read. With one holder it serves the
copy; with two it is refused naming "3 holders". The exact read serves
the holder's own in both cases. The bare-slot copy is a hand-registered
state: the hydrator no longer produces it, and the heal walk is said to
remove a pre-install copy. This harness registers packages without that
walk, so no public door was measured. `reach:` none measured.
- E1's open PR objectstack-ai#33405 edits the same objectql test file at a different
hunk (after line 2529); this PR's hunk is at location 4 (lines
2228–2270).
## Verification
Derived gate families (`node scripts/pm/dispatch-gates.mjs --commands`,
from the tree at the merge head `4bb529d89`): 64 commands. Each was run,
and its exit code was captured before any pipe:
- **63 exit 0.** These include `check:changeset-no-major`,
`check:adr-0087-registration`, `check:empty-changeset`,
`check:closing-keyword-parity`, `check:nul-bytes`,
`check:test-source-alias`, `check:cross-package-test-inputs`,
`check:type-check-coverage`, `check:type-check-debt`,
`check:durability-log-level`, `check:engine-double-contract`,
`check:published-files`, `check:dts-closure`, `check:doc-authoring` and
`check:issue-citations`.
- **1 NOT MEASURED:** `pnpm check:dual-build-cjs-loads`, exit 3,
`PREREQUISITE NOT MET`. It reads every package's `dist/`, and this
worktree did not build the whole repo. CI carries it.
- **Reconciliation:** `dispatch-gates --ran` with the exit codes
recorded: 64 derived, 63 run, 1 NOT-MEASURED (derived from the recorded
exit 3), 0 UNRUN.
- **Lint:** `eslint --no-inline-config` on the three changed `.ts` files
gives exit 0. The repo-wide `pnpm lint` is CI's.
- No symbol was renamed or removed, so `check-platform-checklist
--changed-from` does not apply.
- The full farm, dogfood and the `integration` layers are CI's. The
title carries no `!` and there is no `(narrowing)` arm, so no dogfood
battery is owed.
Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: domain:server#5 · os-elon-musk ·
session_016WV4cz4f7zEQZ2C9GTG382 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5ea8ce5 commit 4bba8b8
4 files changed
Lines changed: 46 additions & 8 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- objectql/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
612 | 611 | | |
613 | 612 | | |
614 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
615 | 619 | | |
616 | | - | |
| 620 | + | |
617 | 621 | | |
618 | 622 | | |
619 | 623 | | |
| |||
643 | 647 | | |
644 | 648 | | |
645 | 649 | | |
646 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
647 | 653 | | |
648 | 654 | | |
649 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2226 | 2226 | | |
2227 | 2227 | | |
2228 | 2228 | | |
2229 | | - | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
2230 | 2232 | | |
2231 | 2233 | | |
2232 | 2234 | | |
| 2235 | + | |
2233 | 2236 | | |
2234 | 2237 | | |
2235 | 2238 | | |
| |||
2258 | 2261 | | |
2259 | 2262 | | |
2260 | 2263 | | |
2261 | | - | |
| 2264 | + | |
2262 | 2265 | | |
2263 | 2266 | | |
2264 | | - | |
2265 | | - | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
2266 | 2270 | | |
2267 | 2271 | | |
2268 | 2272 | | |
| |||
0 commit comments