From 274303005de89c5261a2025e0b780d3529ac778e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:35:30 +0000 Subject: [PATCH 1/5] fix(metadata-protocol): judgesPackageLessRows returns a plain boolean, and the boot load joins the hydration-state pins judgesPackageLessRows was declared as the type predicate `type is PackageScopedType`, but its false answer depends on the registry (readsByPackage), not on the type alone: a caller holding a package-scoped type saw its false branch narrowed to never. It now returns boolean; a tsc-checked pin keeps `hook` typed in that branch. A stored package-less action row of a shipped name, read at a holder's exact address, answers the holder's own item before and after the boot load (loadMetaFromDb), as it already does around the read-side hydrator and with a bare-slot copy. The boot load is added to those hydration-state pins (action, queue, tool; one holder and two). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 --- .../src/protocol-exact-qualifier.test.ts | 14 +++++++++++++- .../src/protocol-exact-qualifier.ts | 8 ++++++-- .../src/package-scoped-exact-qualifier.test.ts | 12 ++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-exact-qualifier.test.ts b/packages/metadata-protocol/src/protocol-exact-qualifier.test.ts index 1ca612a7b4c..2eefd0cbc55 100644 --- a/packages/metadata-protocol/src/protocol-exact-qualifier.test.ts +++ b/packages/metadata-protocol/src/protocol-exact-qualifier.test.ts @@ -9,7 +9,8 @@ * by the admitted holder's. */ -import { describe, it, expect } from 'vitest'; +import { describe, it, expect, expectTypeOf } from 'vitest'; +import type { PackageScopedType } from '@objectstack/core'; import { exactQualifierItem, judgesPackageLessRows, packageLessRowOwners, pairRowOnAddress } from './protocol-exact-qualifier.js'; const BASE = 'com.acme.alpha'; @@ -86,6 +87,17 @@ describe('[#31699] packageLessRowOwners', () => { expect(packageLessRowOwners({ packageScopedHoldersOf: () => ['a.x', 'b.y'] }, 'action', 'approve')).toEqual(['a.x', 'b.y']); expect(judgesPackageLessRows({ readsByPackage: () => false }, 'function')).toBe(false); }); + + // [#32716 N1] Checked by `tsc` (the package's `typecheck` compiles this + // file): under the type predicate `type is PackageScopedType`, the `false` + // branch below narrowed `type` to `never`, though a package-scoped type the + // registry does not read by package (`hook`) lands there. + it('[#32716 N1] judgesPackageLessRows is a plain boolean: a package-scoped type it does not judge keeps its type in the false branch (BASE: never)', () => { + const type = 'hook' as PackageScopedType; + if (judgesPackageLessRows({ readsByPackage: () => false }, type)) throw new Error('hook is not judged here'); + expectTypeOf(type).toEqualTypeOf(); + expect(type).toBe('hook'); + }); }); /** diff --git a/packages/metadata-protocol/src/protocol-exact-qualifier.ts b/packages/metadata-protocol/src/protocol-exact-qualifier.ts index 8f14e88f213..bde0cc79979 100644 --- a/packages/metadata-protocol/src/protocol-exact-qualifier.ts +++ b/packages/metadata-protocol/src/protocol-exact-qualifier.ts @@ -54,7 +54,6 @@ import { type PackageScopedHolder, type PackageScopedRefusalReason, type PackageScopedResolvableType, - type PackageScopedType, } from '@objectstack/core'; import { ENVIRONMENT_ADDRESS_SEGMENT, readNamespacePositionSegment } from '@objectstack/spec/kernel'; import { installedManifestsOfEngine } from './installed-manifests.js'; @@ -612,8 +611,13 @@ export function resolveCallerPackageAddress( * narrowed type lets two namespaces hold one name whether or not its readers * are wired, so the refusal is in place from the change that narrows it * (`action` since #31697, read through `getItem`), never one reader card later. + * + * A plain `boolean`, never the type predicate `type is PackageScopedType`: + * the `false` answer depends on the registry (`readsByPackage`), not on the + * type alone, so a predicate would narrow a package-scoped type to `never` in + * a caller's `false` branch (#32716 N1). */ -export function judgesPackageLessRows(registry: { readsByPackage?(type: string): boolean }, type: string): type is PackageScopedType { +export function judgesPackageLessRows(registry: { readsByPackage?(type: string): boolean }, type: string): boolean { if (!isPackageScopedType(type)) return false; return registry.readsByPackage?.(type) === true || isNamespaceScopedBareNameType(type); } diff --git a/packages/objectql/src/package-scoped-exact-qualifier.test.ts b/packages/objectql/src/package-scoped-exact-qualifier.test.ts index ab20fad70ed..4b5baca8d9e 100644 --- a/packages/objectql/src/package-scoped-exact-qualifier.test.ts +++ b/packages/objectql/src/package-scoped-exact-qualifier.test.ts @@ -2226,10 +2226,13 @@ describe('[#32568] a package-less row at a holder\'s exact address: declined for }); describe('location 4: one answer in every hydration state (both registration orders)', () => { - const STATES = ['stored, not hydrated', 'after the read-side hydrator', "bare-slot copy stamped ''", "bare-slot copy stamped 'sys_metadata'"] as const; + // [#32716 N3] The boot load (`loadMetaFromDb`) is the other hydration the + // card names beside the list read: the same answers before and after it. + const STATES = ['stored, not hydrated', 'after the read-side hydrator', 'after the boot load', "bare-slot copy stamped ''", "bare-slot copy stamped 'sys_metadata'"] as const; const enter = async (type: string, state: (typeof STATES)[number]) => { storeRow(type, 'active', 'stored'); if (state === 'after the read-side hydrator') await protocol.getMetaItems({ type } as never); + if (state === 'after the boot load') expect(await protocol.loadMetaFromDb(), 'the boot load read the row').toMatchObject({ errors: 0, invalid: 0 }); if (state.startsWith('bare-slot')) { registry.registerItem(type, { ...sealedBody(type, 'stored'), _provenance: 'org', _packageId: state.endsWith("''") ? '' : 'sys_metadata' }, 'name' as never); } @@ -2258,11 +2261,12 @@ describe('[#32568] a package-less row at a holder\'s exact address: declined for } } - it(`${type}, one holder: the stored row is declined before and after the read-side hydrator, on the exact and the bare read (BASE: after it, both served the row)`, async () => { + it(`${type}, one holder: the stored row is declined before and after the boot load and the read-side hydrator, on the exact and the bare read (BASE: after the hydrator, both served the row)`, async () => { shipSealed(type, A); storeRow(type, 'active', 'stored'); - for (const when of ['before', 'after']) { - if (when === 'after') await protocol.getMetaItems({ type } as never); + for (const when of ['before', 'after the boot load', 'after the read-side hydrator']) { + if (when === 'after the boot load') await protocol.loadMetaFromDb(); + if (when === 'after the read-side hydrator') await protocol.getMetaItems({ type } as never); expect(labelOf(await read(type, 'approve', A)), `${when} exact`).toBe(`alpha ${type}`); expect(labelOf(await protocol.getMetaItem({ type, name: 'approve' } as never)), `${when} bare`).toBe(`alpha ${type}`); } From a8fe301280f10731f3b24f8f4cee856971b920b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:36:19 +0000 Subject: [PATCH 2/5] test(objectql): the boot-load pin asserts the load reached the row, not that a fixture is spec-valid Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 --- packages/objectql/src/package-scoped-exact-qualifier.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/objectql/src/package-scoped-exact-qualifier.test.ts b/packages/objectql/src/package-scoped-exact-qualifier.test.ts index 4b5baca8d9e..c3b86cab134 100644 --- a/packages/objectql/src/package-scoped-exact-qualifier.test.ts +++ b/packages/objectql/src/package-scoped-exact-qualifier.test.ts @@ -2232,7 +2232,7 @@ describe('[#32568] a package-less row at a holder\'s exact address: declined for const enter = async (type: string, state: (typeof STATES)[number]) => { storeRow(type, 'active', 'stored'); if (state === 'after the read-side hydrator') await protocol.getMetaItems({ type } as never); - if (state === 'after the boot load') expect(await protocol.loadMetaFromDb(), 'the boot load read the row').toMatchObject({ errors: 0, invalid: 0 }); + if (state === 'after the boot load') expect(await protocol.loadMetaFromDb(), 'the boot load read the row').toMatchObject({ loaded: 1, errors: 0 }); if (state.startsWith('bare-slot')) { registry.registerItem(type, { ...sealedBody(type, 'stored'), _provenance: 'org', _packageId: state.endsWith("''") ? '' : 'sys_metadata' }, 'name' as never); } From a382764b428559f64332e1db9779392f54cfe2ee Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:37:13 +0000 Subject: [PATCH 3/5] fix(metadata-protocol): packageLessRowOwners narrows the type through isPackageScopedType, not the registry-dependent judge Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 --- packages/metadata-protocol/src/protocol-exact-qualifier.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/metadata-protocol/src/protocol-exact-qualifier.ts b/packages/metadata-protocol/src/protocol-exact-qualifier.ts index bde0cc79979..197b862a41a 100644 --- a/packages/metadata-protocol/src/protocol-exact-qualifier.ts +++ b/packages/metadata-protocol/src/protocol-exact-qualifier.ts @@ -647,7 +647,9 @@ export function packageLessRowOwners( name: string, options?: { includeDisabledPackages?: boolean }, ): string[] { - if (!judgesPackageLessRows(registry, type)) return []; + // `isPackageScopedType` narrows `type` (its answer is the type's alone); + // `judgesPackageLessRows` is a plain boolean (its answer is the registry's too). + if (!isPackageScopedType(type) || !judgesPackageLessRows(registry, type)) return []; if (isPlatformRequestedBareName(type, name)) return []; // [#32183] The served holders: a read judges them, so a package-less row // of a name an enabled and a disabled package hold is the enabled one's. From e2cf2bd26217a3a61918f27928fbf3e57d7570c5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:44:52 +0000 Subject: [PATCH 4/5] chore(changeset): metadata-protocol patch for the judgesPackageLessRows signature Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 --- .changeset/32716-judges-package-less-rows-boolean.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/32716-judges-package-less-rows-boolean.md diff --git a/.changeset/32716-judges-package-less-rows-boolean.md b/.changeset/32716-judges-package-less-rows-boolean.md new file mode 100644 index 00000000000..e145cb4aa45 --- /dev/null +++ b/.changeset/32716-judges-package-less-rows-boolean.md @@ -0,0 +1,12 @@ +--- +'@objectstack/metadata-protocol': patch +--- + +fix(metadata-protocol): `judgesPackageLessRows` returns a plain `boolean`, not a type predicate + +Clause-②: no +Metadata-protocol: none + +`judgesPackageLessRows(registry, type)` was declared `type is PackageScopedType`. Its `false` answer depends on the registry (`readsByPackage`), not on the type alone, so TypeScript narrowed a package-scoped type to `never` in a caller's `false` branch, although a package-scoped type the registry does not read by package (`hook`, for one) lands there. It now returns `boolean`. Its runtime answer is unchanged. To narrow a `string` to `PackageScopedType`, call `isPackageScopedType` from `@objectstack/core`, whose answer depends on the type alone. + +No read moves. A stored package-less row of a sealed type (`action`, `queue`, `tool`) of a name a package ships, read at a holder's exact address (`?package=`), gets the holder's own item before and after the boot load (`loadMetaFromDb`), around the list read's hydrator, and with a copy in the registry's bare slot. This holds with one holder and with two. The boot load is now pinned beside the other hydration states. From 82cc3c1593afa70f3367cd72029bc7232c0fb199 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 22:26:24 +0000 Subject: [PATCH 5/5] =?UTF-8?q?docs(changeset):=20declare=20the=20judgesPa?= =?UTF-8?q?ckageLessRows=20return-type=20change=20as=20Clause-=E2=91=A1=20?= =?UTF-8?q?yes=20(narrowing)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The exported function's .d.ts return type moves from a type predicate to boolean, so a TypeScript caller narrowing through its true branch no longer compiles (review#3 contract record). Title gains `!`, a BREAKING paragraph names the remedy (isPackageScopedType first), and one ADR-0087 not-required marker. Level stays patch. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 --- .changeset/32716-judges-package-less-rows-boolean.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.changeset/32716-judges-package-less-rows-boolean.md b/.changeset/32716-judges-package-less-rows-boolean.md index e145cb4aa45..37f4e942346 100644 --- a/.changeset/32716-judges-package-less-rows-boolean.md +++ b/.changeset/32716-judges-package-less-rows-boolean.md @@ -2,11 +2,15 @@ '@objectstack/metadata-protocol': patch --- -fix(metadata-protocol): `judgesPackageLessRows` returns a plain `boolean`, not a type predicate +fix(metadata-protocol)!: `judgesPackageLessRows` returns a plain `boolean`, not a type predicate -Clause-②: no +Clause-②: yes (narrowing) — the exported `judgesPackageLessRows`'s return type moves from the predicate `type is PackageScopedType` to `boolean`, so a TypeScript caller that narrowed `type` through its `true` branch no longer compiles. Its runtime answer is unchanged. Metadata-protocol: none + + +**BREAKING** for a TypeScript caller that narrows `type` to `PackageScopedType` through `judgesPackageLessRows(registry, type)` (for example `if (judgesPackageLessRows(r, t)) useScoped(t)`): it no longer compiles. Call `isPackageScopedType(type)` from `@objectstack/core` first, as `packageLessRowOwners` now does. + `judgesPackageLessRows(registry, type)` was declared `type is PackageScopedType`. Its `false` answer depends on the registry (`readsByPackage`), not on the type alone, so TypeScript narrowed a package-scoped type to `never` in a caller's `false` branch, although a package-scoped type the registry does not read by package (`hook`, for one) lands there. It now returns `boolean`. Its runtime answer is unchanged. To narrow a `string` to `PackageScopedType`, call `isPackageScopedType` from `@objectstack/core`, whose answer depends on the type alone. No read moves. A stored package-less row of a sealed type (`action`, `queue`, `tool`) of a name a package ships, read at a holder's exact address (`?package=`), gets the holder's own item before and after the boot load (`loadMetaFromDb`), around the list read's hydrator, and with a copy in the registry's bare slot. This holds with one holder and with two. The boot load is now pinned beside the other hydration states.