Skip to content

Commit 083ab1b

Browse files
committed
test(mcp): the stdio pin's store is an in-memory SQLite SqlDriver, not the frozen memory driver
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
1 parent 8ab53b5 commit 083ab1b

4 files changed

Lines changed: 30 additions & 25 deletions

File tree

‎packages/mcp/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"zod": "^4.6.6"
4040
},
4141
"devDependencies": {
42-
"@objectstack/driver-memory": "workspace:*",
42+
"@objectstack/driver-sql": "workspace:*",
4343
"@objectstack/metadata-protocol": "workspace:*",
4444
"@objectstack/objectql": "workspace:*",
4545
"@objectstack/service-analytics": "workspace:*",

‎packages/mcp/src/mcp-record-context-tools.test.ts‎

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type { IDataEngine, IMetadataService } from '@objectstack/spec/contracts'
3030
import { createRecordContextTools } from '@objectstack/service-record-context';
3131
import { ObjectQL } from '@objectstack/objectql/core';
3232
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
33-
import { InMemoryDriver } from '@objectstack/driver-memory';
33+
import { SqlDriver } from '@objectstack/driver-sql';
3434
import { SysMetadataObject } from '@objectstack/metadata-core';
3535
import { MCPServerRuntime } from './mcp-server-runtime.js';
3636
import type { McpDataBridge } from './mcp-http-tools.js';
@@ -306,7 +306,9 @@ describe('[ADR-0160 D4] get_record_context — the gates the record tools put be
306306
describe('[ADR-0160 D4] get_record_context — a package pack the real protocol serves', () => {
307307
it('the served listing carries the read decoration, and both doors answer through the pack', async () => {
308308
const engineOfRecord = new ObjectQL();
309-
engineOfRecord.registerDriver(new InMemoryDriver() as never, true);
309+
const store = new SqlDriver({ client: 'better-sqlite3', connection: { filename: ':memory:' }, useNullAsDefault: true } as never);
310+
await store.initObjects([SysMetadataObject] as never);
311+
engineOfRecord.registerDriver(store as never, true);
310312
await engineOfRecord.init();
311313
engineOfRecord.registry.registerObject(SysMetadataObject as never, '@objectstack/platform-objects');
312314
engineOfRecord.registerApp({
@@ -319,24 +321,27 @@ describe('[ADR-0160 D4] get_record_context — a package pack the real protocol
319321
aiContexts: [PACK],
320322
} as never);
321323
const protocol = new ObjectStackProtocolImplementation(engineOfRecord as never);
324+
try {
325+
// Precondition: the protocol serves the pack decorated, as `/meta/ai_context` does.
326+
// Were it served bare, this case could not tell a door that strips from one that does not.
327+
const listed = (await protocol.getMetaItems({ type: 'ai_context' })) as { items: Array<Record<string, unknown>> };
328+
const served = listed.items.find((p) => p.name === PACK.name);
329+
expect(served?._packageId).toBe('com.objectstack.qa.record-context-stdio');
330+
expect(served).toHaveProperty('_diagnostics');
322331

323-
// Precondition: the protocol serves the pack decorated, as `/meta/ai_context` does.
324-
// Were it served bare, this case could not tell a door that strips from one that does not.
325-
const listed = (await protocol.getMetaItems({ type: 'ai_context' })) as { items: Array<Record<string, unknown>> };
326-
const served = listed.items.find((p) => p.name === PACK.name);
327-
expect(served?._packageId).toBe('com.objectstack.qa.record-context-stdio');
328-
expect(served).toHaveProperty('_diagnostics');
329-
330-
// No pack on the metadata service: the only listing is the protocol's.
331-
const bridge = stdioBridge([], true, protocol as unknown as Record<string, unknown>);
332-
const { http, stdio } = await callBoth(bridge, GET_RECORD_CONTEXT_TOOL_NAME, {
333-
objectName: 'policy',
334-
recordId: 'p1',
335-
context: PACK.name,
336-
});
337-
expect(http.isError, JSON.stringify(http.payload)).toBe(false);
338-
expect(stdio).toEqual(http);
339-
expect(http.payload.data.pack.name).toBe(PACK.name);
340-
expect(http.payload.data.related[0].rows.map((r: { id: string }) => r.id)).toEqual(['r1', 'r2']);
332+
// No pack on the metadata service: the only listing is the protocol's.
333+
const bridge = stdioBridge([], true, protocol as unknown as Record<string, unknown>);
334+
const { http, stdio } = await callBoth(bridge, GET_RECORD_CONTEXT_TOOL_NAME, {
335+
objectName: 'policy',
336+
recordId: 'p1',
337+
context: PACK.name,
338+
});
339+
expect(http.isError, JSON.stringify(http.payload)).toBe(false);
340+
expect(stdio).toEqual(http);
341+
expect(http.payload.data.pack.name).toBe(PACK.name);
342+
expect(http.payload.data.related[0].rows.map((r: { id: string }) => r.id)).toEqual(['r1', 'r2']);
343+
} finally {
344+
await engineOfRecord.destroy();
345+
}
341346
});
342347
});

‎packages/mcp/vitest.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export default defineConfig({
8383
// listing is read off the real `ObjectStackProtocolImplementation` in the
8484
// checkout, decorations included, never a build of it.
8585
{ find: /^@objectstack\/metadata-protocol$/, replacement: path.resolve(__dirname, '../metadata-protocol/src/index.ts') },
86-
// …over a real store: the in-memory driver backs the `sys_metadata` read the protocol's listing makes.
87-
{ find: /^@objectstack\/driver-memory$/, replacement: path.resolve(__dirname, '../drivers/driver-memory/src/index.ts') },
86+
// …over a real store: an in-memory SQLite `SqlDriver` backs the `sys_metadata` read the protocol's listing makes.
87+
{ find: /^@objectstack\/driver-sql$/, replacement: path.resolve(__dirname, '../drivers/driver-sql/src/index.ts') },
8888
// [ADR-0160] The record-context executor, so `get_record_context`'s transport parity runs the real one.
8989
{ find: /^@objectstack\/service-record-context$/, replacement: path.resolve(__dirname, '../services/service-record-context/src/index.ts') },
9090
],

‎pnpm-lock.yaml‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)