Skip to content

Commit d2a8d4f

Browse files
committed
test(mcp): pin the matrix fixture's engine double to the dispatch predicates
`check:engine-double-contract` reads the new fixture as an engine double and requires its scanned write verbs to route through the producer-side predicates. The matrix reads and creates and never calls update / delete / findOne, but a double looser than the real engine is what the ratchet exists to keep out, so all three are pinned rather than left open. The RETAINED ledger is regenerated with `--write`: three rows added, none lost — new pinned coverage, not a weakened baseline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D47qPfEWVPmhguWgBZCi5N
1 parent e73a121 commit d2a8d4f

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

packages/mcp/src/stdio-tenancy-posture-api-key-matrix.test.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ import {
5454
AUTHZ_STORE_UNAVAILABLE_STATUS,
5555
} from '@objectstack/core';
5656
import type { ExecutionContext } from '@objectstack/spec/kernel';
57+
// The producer-side dispatch predicates every engine double in this repo is
58+
// pinned to (`check:engine-double-contract`). The three verbs below are not
59+
// exercised by this matrix — it reads and creates — but a double looser than
60+
// the real engine is exactly what the ratchet exists to keep out of the tree.
61+
import {
62+
assertEngineDeleteDispatch,
63+
assertEngineUpdateDispatch,
64+
assertEngineFindOnePredicate,
65+
type EngineFindOneQueryInput,
66+
} from '@objectstack/metadata-core';
5767
import { MCPServerPlugin } from './plugin.js';
5868
import { MCPServerRuntime } from './mcp-server-runtime.js';
5969
import type { McpDataBridge } from './mcp-http-tools.js';
@@ -111,9 +121,9 @@ function matchesWhere(row: Record<string, unknown>, where: unknown): boolean {
111121
interface Engine {
112122
find: (object: string, query?: unknown, opts?: unknown) => Promise<unknown>;
113123
insert: (object: string, data: unknown, opts?: unknown) => Promise<unknown>;
114-
update: (object: string, data: unknown, opts?: unknown) => Promise<unknown>;
115-
delete: (object: string, opts?: unknown) => Promise<unknown>;
116-
findOne: (object: string, query?: unknown, opts?: unknown) => Promise<unknown>;
124+
update: (object: string, data: any, opts?: any) => Promise<unknown>;
125+
delete: (object: string, opts?: any) => Promise<unknown>;
126+
findOne: (object: string, query?: EngineFindOneQueryInput) => Promise<unknown>;
117127
count: () => Promise<number>;
118128
}
119129

@@ -196,9 +206,15 @@ function makeFixture(): Fixture {
196206
rows.push(row);
197207
return { ...row };
198208
},
199-
async update() { throw new Error('fixture: update not exercised'); },
200-
async delete() { throw new Error('fixture: delete not exercised'); },
201-
async findOne() { return null; },
209+
async update(_object, data, opts) {
210+
assertEngineUpdateDispatch(data, opts);
211+
throw new Error('fixture: update not exercised by this matrix');
212+
},
213+
async delete(_object, opts) {
214+
assertEngineDeleteDispatch(opts);
215+
throw new Error('fixture: delete not exercised by this matrix');
216+
},
217+
async findOne(object, query) { assertEngineFindOnePredicate(object, query); return null; },
202218
async count() { return 0; },
203219
};
204220

scripts/engine-double-contract.pinned.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@
9191
"verb": "findOne",
9292
"pinned": 1
9393
},
94+
{
95+
"file": "packages/mcp/src/stdio-tenancy-posture-api-key-matrix.test.ts",
96+
"verb": "delete",
97+
"pinned": 1
98+
},
99+
{
100+
"file": "packages/mcp/src/stdio-tenancy-posture-api-key-matrix.test.ts",
101+
"verb": "findOne",
102+
"pinned": 1
103+
},
104+
{
105+
"file": "packages/mcp/src/stdio-tenancy-posture-api-key-matrix.test.ts",
106+
"verb": "update",
107+
"pinned": 1
108+
},
94109
{
95110
"file": "packages/metadata-protocol/src/migrations/recorded-by-sentinel.test.ts",
96111
"verb": "delete",

0 commit comments

Comments
 (0)