Skip to content

Commit e460193

Browse files
committed
test(metadata-protocol): hold the caller's limit in the fanout find double; ledger the new pinned engine doubles
check:objectql-double-limit named the new find double limit-blind — the bound now applies after the filter, by presence. The engine-double ledger learned the fanout file's pinned delete/findOne/update doubles via the gate's own --write. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5WBDtaUnoz5XuJ6jk8pQ5
1 parent 44a2e59 commit e460193

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,17 @@ function makeReplica(store: ReturnType<typeof makeSharedStore>) {
138138
if (table !== 'sys_metadata') return null;
139139
return findRow(opts.where)?.row ?? null;
140140
},
141-
async find(table: string, opts?: { where?: Record<string, unknown> }) {
141+
async find(table: string, opts?: { where?: Record<string, unknown>; limit?: number }) {
142+
// Hold the caller's bound AFTER the filter, by PRESENCE — the
143+
// objectql-double-limit contract: a bound the double ignores makes
144+
// a pagination bug invisible to every test built on it.
145+
const bound = <T>(all: T[]): T[] =>
146+
typeof opts?.limit === 'number' ? all.slice(0, opts.limit) : all;
142147
if (table === 'sys_metadata_history') {
143-
return historyRows.filter((h) => matchesHistory(h, opts?.where ?? {}));
148+
return bound(historyRows.filter((h) => matchesHistory(h, opts?.where ?? {})));
144149
}
145150
if (table !== 'sys_metadata') return [];
146-
return Array.from(rows.values()).filter((r) => matchesWhere(r, opts?.where ?? {}));
151+
return bound(Array.from(rows.values()).filter((r) => matchesWhere(r, opts?.where ?? {})));
147152
},
148153
async insert(table: string, data: Record<string, unknown>) {
149154
if (table === 'sys_metadata_audit') return { id: 'audit_skip' };

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@
351351
"verb": "update",
352352
"pinned": 1
353353
},
354+
{
355+
"file": "packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts",
356+
"verb": "delete",
357+
"pinned": 1
358+
},
359+
{
360+
"file": "packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts",
361+
"verb": "findOne",
362+
"pinned": 1
363+
},
364+
{
365+
"file": "packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts",
366+
"verb": "update",
367+
"pinned": 1
368+
},
354369
{
355370
"file": "packages/metadata-protocol/src/protocol.code-only-types.test.ts",
356371
"verb": "delete",

0 commit comments

Comments
 (0)