Skip to content

Commit d958c99

Browse files
committed
fix(cli): read the objectql slot through its IObjectQLEngine contract, not any (#5081)
The ADR-0120 D5e advisory's `SchemaStack.allObjects()` erased its service-lookup result to `any`, which `no-restricted-syntax` rejects (#4168/#4176/#4251): the lookup already returns the slot's contract, and the annotation switched that checking off while looking identical to code that has it. The `objectql` slot HAS a contract — `IObjectQLEngine`, whose `registry.getAllObjects()` is exactly what this reads — so this takes the prescription's first branch (pass the contract type) rather than the UNCONTRACTED_SLOTS registration. Concretely it buys what the rule is for: a rename of `registry` or `getAllObjects` now breaks this at compile time instead of silently returning zero objects and turning the advisory mute. `allObjects()` returns `unknown[]` accordingly; its only consumer, `collectGlobalUniques`, already accepts `unknown`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
1 parent 0a3a4ed commit d958c99

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎packages/cli/src/utils/schema-migrate.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import chalk from 'chalk';
1616
import type { ManagedDriftEntry, DriftCategory, PendingSchemaWork } from '@objectstack/driver-sql';
1717
import { isInPlaceSchemaWork } from '@objectstack/driver-sql';
18+
import type { IObjectQLEngine } from '@objectstack/spec/contracts';
1819
import { describeDriverConnection } from './connection-display.js';
1920

2021
export type { PendingSchemaWork };
@@ -51,7 +52,7 @@ export interface SchemaStack {
5152
* this project's `objectstack.config.ts`. Read by the ADR-0120 D5e
5253
* unique-scope advisory; best-effort (`[]` when no ObjectQL service composed).
5354
*/
54-
allObjects: () => any[];
55+
allObjects: () => unknown[];
5556
/**
5657
* Perform the deferred sync — call only once the operator has confirmed the
5758
* plan. Returns the work it actually ran (`[]` when nothing was deferred).
@@ -223,9 +224,14 @@ export async function bootSchemaStack(
223224
* marketplace packages is a strict subset. Best-effort — a stack with no
224225
* ObjectQL service reports none, and the advisory then simply says nothing.
225226
*/
226-
allObjects: (): any[] => {
227+
allObjects: (): unknown[] => {
227228
try {
228-
const ql: any = (kernel as any).getService?.('objectql');
229+
// The `objectql` slot's contract is `IObjectQLEngine` (#4251) — read it
230+
// through that rather than erasing the lookup to `any`, so a rename of
231+
// `registry` / `getAllObjects` breaks this at compile time instead of
232+
// silently reporting zero objects and turning the D5e advisory mute.
233+
const getService = (kernel as { getService?: (name: string) => unknown })?.getService;
234+
const ql = getService?.call(kernel, 'objectql') as IObjectQLEngine | undefined;
229235
return ql?.registry?.getAllObjects?.() ?? [];
230236
} catch {
231237
return [];

0 commit comments

Comments
 (0)