Skip to content

Commit 2c86a22

Browse files
committed
fix(metadata-protocol): pin the tripwire fixture's delete/update to the shared dispatch predicate (#7823)
check:engine-double-contract flagged makeSentinelEngine()'s delete()/update() as unpinned engine doubles — exactly the toolchain trap AGENTS.md names. Route both through assertEngineDeleteDispatch/assertEngineUpdateDispatch from @objectstack/metadata-core, the same pattern protocol.batch-verb-driver-text.test.ts already uses. No behavioural change to the tripwire itself. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RDTnVvsgA6cUZ4xFVtPZRy
1 parent 9c1ca6d commit 2c86a22

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/metadata-protocol/src/protocol.write-response-internal-fields.tripwire.test.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
// enumeration is shown to pick it up, and the scan is shown to catch its leak.
4646

4747
import { describe, it, expect } from 'vitest';
48+
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
4849
import { ObjectStackProtocolImplementation } from './protocol.js';
4950
import {
5051
collectInternalWriteResponseFields,
@@ -93,10 +94,18 @@ function makeSentinelEngine() {
9394
: writtenRow(data?.id ?? `new-${nextId++}`, data),
9495
insertMany: async (_object: string, rows: any[]) =>
9596
rows.map((r: any) => ({ ok: true, record: writtenRow(r?.id ?? `new-${nextId++}`, r) })),
96-
update: async (_object: string, data: any, options?: any) =>
97-
writtenRow(options?.where?.id ?? data?.id ?? 'row-1', data),
97+
update: async (_object: string, data: any, options?: any) => {
98+
// [#5480] The producer's own update-verb dispatch contract, so this fake
99+
// cannot accept a call `ObjectQL.update` refuses (check:engine-double-contract).
100+
assertEngineUpdateDispatch(data, options);
101+
return writtenRow(options?.where?.id ?? data?.id ?? 'row-1', data);
102+
},
98103
// Contract per #4435: `false` is the positive not-found value.
99-
delete: async (_object: string, _options?: any) => ({ deleted: 1 }),
104+
delete: async (_object: string, options?: any) => {
105+
// [#4550] Likewise for delete.
106+
assertEngineDeleteDispatch(options);
107+
return { deleted: 1 };
108+
},
100109
findOne: async (_object: string, options?: any) => storedRow(options?.where?.id ?? 'row-1'),
101110
find: async (_object: string, _options?: any) => [storedRow('row-1')],
102111
count: async () => 1,

0 commit comments

Comments
 (0)