Skip to content

Commit 51fced9

Browse files
committed
test(runtime): type the audit's service lookup with its contract, not any
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0112hMx9hjJ9BgB28X97DS68
1 parent 99ff95c commit 51fced9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/runtime/src/action-governance-scope-divergence.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { describe, it, expect } from 'vitest';
5050
import { ObjectKernel, ServiceLifecycle } from '@objectstack/core';
5151
import { MetadataManager, DatabaseLoader } from '@objectstack/metadata';
5252
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
53+
import type { IMetadataService } from '@objectstack/spec/contracts';
5354
import { NodeMetadataManager } from '@objectstack/metadata/node';
5455
import type { MetadataLoader } from '@objectstack/metadata';
5556
import { runActionGovernanceInventory, collectEngineActionDeclarations } from '@objectstack/objectql';
@@ -314,11 +315,14 @@ describe('#14423 (a) — can `loadMany` omit a name `load` serves?', () => {
314315
ServiceLifecycle.SCOPED,
315316
);
316317

317-
// The audit's lookup — `ctx.getService('metadata')` in plugin.ts, inside its try/catch.
318-
let auditMeta: any;
318+
// The audit's lookup — `ctx.getService('metadata')` in plugin.ts, inside its
319+
// try/catch. Typed with the slot's CONTRACT, not `any`: the audit reads
320+
// `meta.loadMany` off whatever this returns, and erasing the result is
321+
// exactly the shape `check:slot-lookup` refuses (#4251).
322+
let auditMeta: IMetadataService | undefined;
319323
let auditLookupError: string | undefined;
320-
try { auditMeta = kernel.getService('metadata'); }
321-
catch (e: any) { auditLookupError = e?.message ?? String(e); }
324+
try { auditMeta = kernel.getService<IMetadataService>('metadata'); }
325+
catch (e: unknown) { auditLookupError = e instanceof Error ? e.message : String(e); }
322326

323327
// The router's lookup — the dispatcher's scoped branch, with the request's envId.
324328
const routerMeta = await kernel.getServiceAsync<MetadataManager>('metadata', 'env_a');

0 commit comments

Comments
 (0)