From d2848f113ca0db7897f92b32c447daf79770ac48 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:05:32 +0000 Subject: [PATCH 1/5] test(objectql): pin the authored-action resync's artifact-shipped judgement per holder on a booted kernel Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cyWLSMyXZGc6dwhCAu --- .../src/plugin-authored-actions.test.ts | 149 +++++++++++++++++- 1 file changed, 148 insertions(+), 1 deletion(-) diff --git a/packages/objectql/src/plugin-authored-actions.test.ts b/packages/objectql/src/plugin-authored-actions.test.ts index a3e14017423..50e7220bcc5 100644 --- a/packages/objectql/src/plugin-authored-actions.test.ts +++ b/packages/objectql/src/plugin-authored-actions.test.ts @@ -15,7 +15,8 @@ * @objectstack/runtime tests. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { ObjectKernel } from '@objectstack/core'; import { ObjectQLPlugin } from './plugin.js'; import { ObjectQL } from './engine.js'; import { isServedOverrideRowOf } from '@objectstack/metadata-protocol'; @@ -513,3 +514,149 @@ describe('[#30065] a declared .custom action override rebinds the body, and rest await expect(ql.executeAction(OBJ, ACT, {})).rejects.toThrow(/not found/); }); }); + +/** + * [#32990] On a booted kernel, the resync judges "artifact-shipped" against + * each code package's own action of the name, by the object it owns, not by + * the first package found under the bare name. + * + * The composition: package A ships a script action `approve` on its object, + * package B ships one of the same name on its own, and the environment + * authors its own script action `approve` on an object neither binds. The + * route serves the environment's declaration there (#32751), and its + * dispatch names no package, so it runs the handler the resync binds for + * that object. The bare-name filter found A's (or B's) artifact and skipped + * the row, so nothing ran there. Each holder binds its own handler now; a row + * on an object a package's action owns stays that holder's customization + * (ADR-0150 D4), whose handler stays the one that runs. + * + * Real: `ObjectKernel`, `ObjectQLPlugin` (its `kernel:ready` resync reads the + * stored rows), `ObjectQL` and its `SchemaRegistry`, the manifest service. + * Doubled: the driver (one row map per object) and what the runtime's + * AppPlugin does at start: the default action runner, and each package's + * handler bound under `app:PACKAGE`. + */ +describe('[#32990] the resync judges artifact-shipped by each holder\'s owner key, on a booted kernel', () => { + const A = 'com.acme.alpha'; + const B = 'com.acme.beta'; + const PAIR_OF_B = `${B}.custom`; + const ON_A = 'alpha_account'; + const ON_B = 'beta_contact'; + const ON_ENV = 'env_lead'; + + const script = (label: string, objectName?: string, extra: AnyRecord = {}) => ({ + name: 'approve', label, type: 'script', + ...(objectName !== undefined ? { objectName } : {}), + body: { language: 'js', source: `return '${label}';` }, + ...extra, + }); + const packageOf = (id: string, objectName: string, actionObject: string | undefined = objectName) => { + const ns = id.split('.').pop()!; + return { + id, name: ns, namespace: ns, version: '1.0.0', type: 'app', + objects: [{ name: objectName, label: objectName, fields: { name: { name: 'name', label: 'Name', type: 'text' } } }], + actions: [script(ns, actionObject)], + }; + }; + const storedRow = (id: string, body: AnyRecord, packageId: string | null = null) => ({ + id, type: 'action', name: body.name, state: 'active', package_id: packageId, metadata: JSON.stringify(body), + }); + + function rowStoreDriver(rows: AnyRecord[]) { + const matches = (row: AnyRecord, where: AnyRecord | undefined): boolean => + Object.entries(where ?? {}).every(([k, v]) => { + if (k.startsWith('$')) throw new Error(`row store driver: combinator ${k} is not implemented`); + if (v !== null && typeof v === 'object') throw new Error(`row store driver: operator on ${k} is not implemented`); + return row[k] === v; + }); + return { + name: 'row-store', version: '0.0.0', supports: {}, + async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async syncSchema() {}, + async find(object: string, ast: AnyRecord) { + return object === 'sys_metadata' ? rows.filter((r) => matches(r, ast?.where)).map((r) => ({ ...r })) : []; + }, + async findOne(object: string, ast: AnyRecord) { + return object === 'sys_metadata' ? rows.find((r) => matches(r, ast?.where)) ?? null : null; + }, + async count(object: string, ast: AnyRecord) { + return object === 'sys_metadata' ? rows.filter((r) => matches(r, ast?.where)).length : 0; + }, + async create() { throw new Error('row store driver: no writes'); }, + async update() { throw new Error('row store driver: no writes'); }, + async delete() { throw new Error('row store driver: no writes'); }, + }; + } + + const kernels: ObjectKernel[] = []; + afterEach(async () => { + while (kernels.length) { + const k = kernels.pop()!; + if (k.getState() === 'running') await k.shutdown(); + } + }); + + /** Boot with `packages` registered in that order during the cold boot and `rows` stored; the `kernel:ready` resync binds. */ + async function boot(packages: AnyRecord[], rows: AnyRecord[]): Promise { + const kernel = new ObjectKernel({ logger: { level: 'silent' }, gracefulShutdown: false }); + kernels.push(kernel); + await kernel.use({ + name: 'test.row-store', type: 'driver', version: '1.0.0', + init: async (ctx: AnyRecord) => { ctx.registerService('driver.row-store', rowStoreDriver(rows)); }, + } as never); + await kernel.use(new ObjectQLPlugin()); + await kernel.use({ + name: 'test.app-plugin', version: '1.0.0', + dependencies: ['com.objectstack.engine.objectql'], + init: async () => {}, + start: async (ctx: AnyRecord) => { + const ql = ctx.getService('objectql') as ObjectQL; + ql.registry.logLevel = 'silent'; + ql.setDefaultActionRunner((action: AnyRecord) => (action?.body ? async () => `ran ${action.label}` : undefined)); + const manifest = ctx.getService('manifest') as { register(m: unknown): Promise | void }; + for (const p of packages) { + await manifest.register(structuredClone(p)); + for (const a of p.actions) ql.registerAction(a.objectName ?? 'global', a.name, async () => `ran ${a.label}`, `app:${p.id}`); + } + }, + } as never); + await kernel.bootstrap(); + return kernel.getService('objectql'); + } + + const ORDERS = [['A then B', [packageOf(A, ON_A), packageOf(B, ON_B)]], ['B then A', [packageOf(B, ON_B), packageOf(A, ON_A)]]] as const; + const run = (ql: ObjectQL, object: string) => ql.executeAction(object, 'approve', {}).then((r) => r, (e: Error) => e.message); + + it('two holders and the environment\'s own action on an object neither binds: each runs its own body, in either registration order', async () => { + for (const [order, packages] of ORDERS) { + const ql = await boot([...packages], [storedRow('env-approve', script('env', ON_ENV))]); + expect(await run(ql, ON_ENV), order).toBe('ran env'); + expect(await run(ql, ON_A), order).toBe('ran alpha'); + expect(await run(ql, ON_B), order).toBe('ran beta'); + expect(await ql.executeAction(ON_A, 'approve', {}, { packageId: A }), order).toBe('ran alpha'); + expect(await ql.executeAction(ON_B, 'approve', {}, { packageId: B }), order).toBe('ran beta'); + } + }); + + it('CONTROL — a package-less row on an object a holder\'s action owns is that holder\'s customization: the holder\'s body keeps running, in either registration order', async () => { + for (const [order, packages] of ORDERS) { + const ql = await boot([...packages], [storedRow('env-on-b', script('env', ON_B))]); + expect(await run(ql, ON_B), order).toBe('ran beta'); + expect(await run(ql, ON_A), order).toBe('ran alpha'); + } + }); + + it('CONTROL — an object-less action a package ships owns every object: a row on another object binds nothing', async () => { + const ql = await boot([packageOf(A, ON_A, undefined)], [storedRow('env-approve', script('env', ON_ENV))]); + expect(await run(ql, ON_ENV)).toBe(`Action 'approve' on object '${ON_ENV}' not found`); + expect(await run(ql, 'global')).toBe('ran alpha'); + }); + + it('the declared override of the holder registered SECOND binds over that holder\'s handler, in either registration order', async () => { + const override = storedRow('pair-approve', script('override', ON_B, { overrides: { package: B, basedOn: '1.0.0' } }), PAIR_OF_B); + for (const [order, packages] of ORDERS) { + const ql = await boot([...packages], [override]); + expect(await run(ql, ON_B), order).toBe('ran override'); + expect(await run(ql, ON_A), order).toBe('ran alpha'); + } + }); +}); From 3731daec2b765094c17262687fecd5101f8ab1c0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:10:47 +0000 Subject: [PATCH 2/5] fix(objectql): judge an authored action artifact-shipped by each holder's owner key, not by bare name Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cyWLSMyXZGc6dwhCAu --- .../objectql/src/action-handler-coordinate.ts | 6 +- .../src/plugin-authored-actions.test.ts | 21 +++++-- packages/objectql/src/plugin.ts | 61 +++++++++++++++---- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/packages/objectql/src/action-handler-coordinate.ts b/packages/objectql/src/action-handler-coordinate.ts index 93a0cf951d9..2449a83502d 100644 --- a/packages/objectql/src/action-handler-coordinate.ts +++ b/packages/objectql/src/action-handler-coordinate.ts @@ -39,9 +39,9 @@ const AUTHORED_ACTION_OWNER = 'metadata-service'; * * - `app:` (the runtime's `bindAppArtifactHandlers`) → that package; * - `metadata-service` → {@link ENVIRONMENT_ACTION_COORDINATE}: an - * environment-authored action (the resync binds no row a code package - * ships, `isArtifactShippedAction`, except a declared override, which is - * bound at its base's coordinate instead); + * environment-authored action (the resync binds no row on an object a code + * package's action of its name owns, `isArtifactShippedAction`, except a + * declared override, which is bound at its base's coordinate instead); * - none or `''` → {@link HOST_ACTION_COORDINATE}: host code; * - any other owner (a plugin's id) → itself, as the one-holder rule names it * ({@link handlerOwnerPackageId}). diff --git a/packages/objectql/src/plugin-authored-actions.test.ts b/packages/objectql/src/plugin-authored-actions.test.ts index 50e7220bcc5..14650459b9d 100644 --- a/packages/objectql/src/plugin-authored-actions.test.ts +++ b/packages/objectql/src/plugin-authored-actions.test.ts @@ -550,12 +550,12 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke body: { language: 'js', source: `return '${label}';` }, ...extra, }); - const packageOf = (id: string, objectName: string, actionObject: string | undefined = objectName) => { + const packageOf = (id: string, objectName: string, opts: { objectLess?: true } = {}) => { const ns = id.split('.').pop()!; return { id, name: ns, namespace: ns, version: '1.0.0', type: 'app', objects: [{ name: objectName, label: objectName, fields: { name: { name: 'name', label: 'Name', type: 'text' } } }], - actions: [script(ns, actionObject)], + actions: [script(ns, opts.objectLess ? undefined : objectName)], }; }; const storedRow = (id: string, body: AnyRecord, packageId: string | null = null) => ({ @@ -596,7 +596,7 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke }); /** Boot with `packages` registered in that order during the cold boot and `rows` stored; the `kernel:ready` resync binds. */ - async function boot(packages: AnyRecord[], rows: AnyRecord[]): Promise { + async function boot(packages: AnyRecord[], rows: AnyRecord[], disabled: string[] = []): Promise { const kernel = new ObjectKernel({ logger: { level: 'silent' }, gracefulShutdown: false }); kernels.push(kernel); await kernel.use({ @@ -617,6 +617,7 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke await manifest.register(structuredClone(p)); for (const a of p.actions) ql.registerAction(a.objectName ?? 'global', a.name, async () => `ran ${a.label}`, `app:${p.id}`); } + for (const id of disabled) ql.registry.disablePackage(id); }, } as never); await kernel.bootstrap(); @@ -637,6 +638,18 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke } }); + it('one holder and the environment\'s own action on another object: the environment\'s body runs there, the holder\'s on its own', async () => { + const ql = await boot([packageOf(A, ON_A)], [storedRow('env-approve', script('env', ON_ENV))]); + expect(await run(ql, ON_ENV)).toBe('ran env'); + expect(await run(ql, ON_A)).toBe('ran alpha'); + }); + + it('CONTROL — a DISABLED holder registered after another still owns its object: the environment\'s row there binds nothing', async () => { + const D = 'com.acme.delta'; + const ql = await boot([packageOf(A, ON_A), packageOf(D, ON_ENV)], [storedRow('env-approve', script('env', ON_ENV))], [D]); + expect(await run(ql, ON_ENV)).toBe('ran delta'); + }); + it('CONTROL — a package-less row on an object a holder\'s action owns is that holder\'s customization: the holder\'s body keeps running, in either registration order', async () => { for (const [order, packages] of ORDERS) { const ql = await boot([...packages], [storedRow('env-on-b', script('env', ON_B))]); @@ -646,7 +659,7 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke }); it('CONTROL — an object-less action a package ships owns every object: a row on another object binds nothing', async () => { - const ql = await boot([packageOf(A, ON_A, undefined)], [storedRow('env-approve', script('env', ON_ENV))]); + const ql = await boot([packageOf(A, ON_A, { objectLess: true })], [storedRow('env-approve', script('env', ON_ENV))]); expect(await run(ql, ON_ENV)).toBe(`Action 'approve' on object '${ON_ENV}' not found`); expect(await run(ql, 'global')).toBe('ran alpha'); }); diff --git a/packages/objectql/src/plugin.ts b/packages/objectql/src/plugin.ts index 8b76ea5bbfd..039d47fac22 100644 --- a/packages/objectql/src/plugin.ts +++ b/packages/objectql/src/plugin.ts @@ -52,6 +52,7 @@ import { GLOBAL_ACTION_OBJECT_KEY, runActionGovernanceInventory, standaloneActionOwnerKey, + standaloneActionOwnsRoute, } from './action-governance.js'; // [ADR-0126 §8] The packaged-action activation ledger's durable store. The // engine holds the projection; this plugin is what attaches the store and @@ -3974,21 +3975,32 @@ export class ObjectQLPlugin implements Plugin { } /** - * True when an action of this name is shipped by an installed CODE - * package — either as a standalone `action` artifact, or embedded in a - * packaged object's `actions[]` array (the common `defineStack` shape). - * Those handlers are registered by AppPlugin under `app:` with its - * own runner, and `engine.registerAction` REPLACES by `:` - * key — so re-registering here would clobber the packaged handler with a - * metadata copy. Artifact-wins, same rule as {@link isArtifactShippedHook}. + * True when a CODE package ships this action at its owner key — either as + * a standalone `action` artifact that owns the action's object, or embedded + * in a packaged object's `actions[]` array (the common `defineStack` + * shape). Those handlers are registered by AppPlugin under `app:` + * with its own runner, and an authored row there is that holder's + * customization (ADR-0150 D4), so binding its copy would run it in place + * of the packaged handler. Artifact-wins, same rule as + * {@link isArtifactShippedHook}. + * + * [#32990] Judged against every holder's artifact of the name + * ({@link artifactActionsNamed}), each by the object it owns + * ({@link standaloneActionOwnsRoute}: an object-less artifact owns every + * object), never by the bare name alone. Two packages may hold one action + * name on different objects (ADR-0150 D4 keys the action by + * `(package, objectName, name)`), and the environment's own action on an + * object none of them binds is its own item, whose declaration the route + * serves (#32751): the bare-name test found a holder's artifact and left + * it with no handler. */ private isArtifactShippedAction(action: any): boolean { const name = action?.name; if (typeof name !== 'string' || name.length === 0) return false; const registry: any = this.ql?.registry; if (!registry || typeof registry.getArtifactItem !== 'function') return false; - if (registry.getArtifactItem('action', name) !== undefined) return true; const objectKey = standaloneActionOwnerKey(action); + if (this.artifactActionsNamed(name).some((artifact) => standaloneActionOwnsRoute(artifact, objectKey))) return true; if (objectKey !== GLOBAL_ACTION_OBJECT_KEY) { const artifactObject: any = registry.getArtifactItem('object', objectKey); if (Array.isArray(artifactObject?.actions) @@ -3999,6 +4011,30 @@ export class ObjectQLPlugin implements Plugin { return false; } + /** + * [#32990] Every code package's artifact of action `name`: the registry's + * first match by bare name (`getArtifactItem`, what one holder always + * answered), and each holder's own (`packageScopedHoldersOf`, disabled + * packages included: a reversible disable never moves a binding), read + * prefer-local. Deduplicated; a holder whose own read answers another + * package's artifact adds nothing that is not a genuine artifact. + */ + private artifactActionsNamed(name: string): any[] { + const registry: any = this.ql?.registry; + if (!registry || typeof registry.getArtifactItem !== 'function') return []; + const found = new Set(); + const first = registry.getArtifactItem('action', name); + if (first !== undefined && first !== null) found.add(first); + const holders: string[] = typeof registry.packageScopedHoldersOf === 'function' + ? registry.packageScopedHoldersOf('action', name, null, { includeDisabledPackages: true }) + : []; + for (const packageId of holders) { + const own = registry.getArtifactItem('action', name, packageId); + if (own !== undefined && own !== null) found.add(own); + } + return [...found]; + } + /** * Read the ACTIVE runtime-authored action definitions from `sys_metadata`. * @@ -4120,13 +4156,16 @@ export class ObjectQLPlugin implements Plugin { const registry: any = this.ql?.registry; if (!registry || typeof registry.getArtifactItem !== 'function') return false; const installed = installedManifestsOf(registry); - const artifact: any = registry.getArtifactItem('action', action.name); - if (artifact === undefined || artifact === null) { + // [#32990] The artifact at the row's own object, among every holder's: + // the first match by bare name may be another holder's, on another object. + const artifacts = this.artifactActionsNamed(action.name); + if (artifacts.length === 0) { return isServedOverrideRowOf(row as any, action?.overrides?.package, installed); } + const objectKey = standaloneActionOwnerKey(action); + const artifact: any = artifacts.find((a) => standaloneActionOwnerKey(a) === objectKey); const base = artifact?._packageId; if (typeof base !== 'string' || base === '') return false; - if (standaloneActionOwnerKey(artifact) !== standaloneActionOwnerKey(action)) return false; return isServedOverrideRowOf(row as any, base, installed); } From ab806df240348e20541288f4a5b4d803d7304563 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:13:17 +0000 Subject: [PATCH 3/5] chore(changeset): objectql patch for the per-holder artifact-shipped judgement Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cyWLSMyXZGc6dwhCAu --- .changeset/32990-authored-action-owner-key.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .changeset/32990-authored-action-owner-key.md diff --git a/.changeset/32990-authored-action-owner-key.md b/.changeset/32990-authored-action-owner-key.md new file mode 100644 index 00000000000..5e5bd36e7cc --- /dev/null +++ b/.changeset/32990-authored-action-owner-key.md @@ -0,0 +1,14 @@ +--- +'@objectstack/objectql': patch +--- + +fix(objectql): the authored-action resync judges "artifact-shipped" by each holder's owner key, so an environment script action on an object no package's action of that name owns gets its handler (#32990) + +Clause-②: yes (widening) +Metadata-protocol: none + +On a booted host, `ObjectQLPlugin` binds runtime-authored script actions through the engine's default action runner, and skips a row a code package ships, since that package's handler is bound by the app plugin. The skip asked the registry for an artifact of the bare NAME. When a package shipped an action of that name on any object, an environment-authored script action of the same name on a different object got no handler: its route served the declaration, and the dispatch answered `Action 'NAME' on object 'OBJECT' not found`. + +The skip now reads every code package's artifact of the name (disabled packages included) and judges each by the object it owns: a row is artifact-shipped only when one of them owns the row's object, an object-less artifact owning every object. A declared `.custom` override is matched to the artifact on its own object, not to the first package found by name. + +FROM: an environment script action `approve` on `lead` beside a package's `approve` on `account` (one or two such packages) had no handler, and its dispatch answered not found. TO: its own body runs. Unchanged: a row on an object a package's action owns (that holder's customization) binds nothing and the holder's handler runs; an object-less package action keeps every other object's row unbound; a disabled holder still owns its object. A declared override of the second-registered of two holders now binds over that holder's handler, where it was missed before. From 63a002e9be2a1fe7c7c7851a5d7d789e783882bf Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:30:12 +0000 Subject: [PATCH 4/5] fix(objectql): a declared action override's base is the package it names among holders at its owner key Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cyWLSMyXZGc6dwhCAu --- .../src/plugin-authored-actions.test.ts | 10 +++++++ packages/objectql/src/plugin.ts | 27 ++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/objectql/src/plugin-authored-actions.test.ts b/packages/objectql/src/plugin-authored-actions.test.ts index 14650459b9d..41f5d7592f9 100644 --- a/packages/objectql/src/plugin-authored-actions.test.ts +++ b/packages/objectql/src/plugin-authored-actions.test.ts @@ -672,4 +672,14 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke expect(await run(ql, ON_A), order).toBe('ran alpha'); } }); + + it('[review S1] two holders both shipping an object-less action: the declared override of B binds over B\'s handler, in either registration order', async () => { + const override = storedRow('pair-approve', script('override', undefined, { overrides: { package: B, basedOn: '1.0.0' } }), PAIR_OF_B); + const objectLess = [packageOf(A, ON_A, { objectLess: true }), packageOf(B, ON_B, { objectLess: true })]; + for (const [order, packages] of [['A then B', objectLess], ['B then A', [...objectLess].reverse()]] as const) { + const ql = await boot([...packages], [override]); + expect(await ql.executeAction('global', 'approve', {}, { packageId: B }), order).toBe('ran override'); + expect(await ql.executeAction('global', 'approve', {}, { packageId: A }), order).toBe('ran alpha'); + } + }); }); diff --git a/packages/objectql/src/plugin.ts b/packages/objectql/src/plugin.ts index 039d47fac22..d5973e882ed 100644 --- a/packages/objectql/src/plugin.ts +++ b/packages/objectql/src/plugin.ts @@ -4089,7 +4089,7 @@ export class ObjectQLPlugin implements Plugin { const data = parseRow(row, 'action'); if (data && typeof data.name === 'string') { actions.push(data); - if (this.isDeclaredArtifactActionOverride(row, data)) this.declaredActionOverrides.add(data); + if (this.isDeclaredArtifactActionOverride(row, data, ctx)) this.declaredActionOverrides.add(data); } } @@ -4133,6 +4133,9 @@ export class ObjectQLPlugin implements Plugin { */ private readonly declaredActionOverrides = new WeakSet(); + /** [#32990 review S1] Once-per-process dedupe for the ambiguous-override-base warning, keyed `OBJECT:NAME`. */ + private readonly overrideBaseAmbiguityWarned = new Set(); + /** * [#30065, ADR-0146 D9 `action`] Whether a stored `action` row is the * declared override of the action a code package ships under its name, on @@ -4152,7 +4155,7 @@ export class ObjectQLPlugin implements Plugin { * a row of another base's pair that ships the same key is replaced by the * real base's handler when it arrives, as the reads decline it. */ - private isDeclaredArtifactActionOverride(row: unknown, action: any): boolean { + private isDeclaredArtifactActionOverride(row: unknown, action: any, ctx?: PluginContext): boolean { const registry: any = this.ql?.registry; if (!registry || typeof registry.getArtifactItem !== 'function') return false; const installed = installedManifestsOf(registry); @@ -4162,8 +4165,26 @@ export class ObjectQLPlugin implements Plugin { if (artifacts.length === 0) { return isServedOverrideRowOf(row as any, action?.overrides?.package, installed); } + // [#32990 review S1] Several holders may ship the name at one owner key + // (two object-less actions both own `global`): the base is the one the row + // declares; with several and none declared, no base is picked (an + // ambiguity is reported, never guessed). const objectKey = standaloneActionOwnerKey(action); - const artifact: any = artifacts.find((a) => standaloneActionOwnerKey(a) === objectKey); + const atKey = artifacts.filter((a) => standaloneActionOwnerKey(a) === objectKey); + const declared = action?.overrides?.package; + const named = atKey.filter((a) => a?._packageId === declared); + const artifact: any = named.length === 1 ? named[0] : atKey.length === 1 ? atKey[0] : undefined; + if (artifact === undefined && atKey.length > 1) { + const key = `${objectKey}:${String(action.name)}`; + if (!this.overrideBaseAmbiguityWarned.has(key)) { + this.overrideBaseAmbiguityWarned.add(key); + ctx?.logger.warn( + `[ObjectQLPlugin] stored action '${String(action.name)}' on '${objectKey}' is bound as no override: ` + + `${atKey.length} packages ship it there (${atKey.map((a) => `'${String(a?._packageId)}'`).join(', ')}) and the row ` + + 'declares none of them in overrides.package. Fix: name the base package in the row\'s overrides.package.', + ); + } + } const base = artifact?._packageId; if (typeof base !== 'string' || base === '') return false; return isServedOverrideRowOf(row as any, base, installed); From efef4782e2d3383e25e732b74136739929681d0e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:16:59 +0000 Subject: [PATCH 5/5] test(objectql): the booted-kernel row-store double holds the caller's find bound Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cyWLSMyXZGc6dwhCAu --- packages/objectql/src/plugin-authored-actions.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/objectql/src/plugin-authored-actions.test.ts b/packages/objectql/src/plugin-authored-actions.test.ts index 41f5d7592f9..112e7d32eb1 100644 --- a/packages/objectql/src/plugin-authored-actions.test.ts +++ b/packages/objectql/src/plugin-authored-actions.test.ts @@ -573,7 +573,10 @@ describe('[#32990] the resync judges artifact-shipped by each holder\'s owner ke name: 'row-store', version: '0.0.0', supports: {}, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async syncSchema() {}, async find(object: string, ast: AnyRecord) { - return object === 'sys_metadata' ? rows.filter((r) => matches(r, ast?.where)).map((r) => ({ ...r })) : []; + if (object !== 'sys_metadata') return []; + const hits = rows.filter((r) => matches(r, ast?.where)); + const page = typeof ast?.limit === 'number' ? hits.slice(0, ast.limit) : hits; + return page.map((r) => ({ ...r })); }, async findOne(object: string, ast: AnyRecord) { return object === 'sys_metadata' ? rows.find((r) => matches(r, ast?.where)) ?? null : null;