Skip to content

Commit 9678d34

Browse files
os-try2026claude
andcommitted
test(metadata-protocol): the harness find double honours the caller's limit
check:objectql-double-limit refuses a NEW limit-blind double ('the baseline never grows'): the copied harness answered more rows than the real engine would, so every assertion downstream of it measured a shape production never produces. Applies the bound after the filter, by presence. Records the new file's engine doubles in the pinned ledger, as check:engine-double-contract prescribes for new pinned coverage. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
1 parent d55e071 commit 9678d34

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

packages/metadata-protocol/src/protocol-publish-drafts-object-field-refs.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ function makeStubEngine() {
130130
}
131131
return findRow(opts.where)?.row ?? null;
132132
},
133-
async find(table: string, opts: { where: Record<string, unknown> }) {
134-
if (table === 'sys_metadata_history') {
135-
return historyRows.filter((h) => matchesHistory(h, opts.where));
136-
}
137-
return Array.from(rows.values()).filter((r) => matchesMetadataWhere(r, opts.where));
133+
async find(table: string, opts: { where: Record<string, unknown>; limit?: number }) {
134+
const matched = table === 'sys_metadata_history'
135+
? historyRows.filter((h) => matchesHistory(h, opts.where))
136+
: Array.from(rows.values()).filter((r) => matchesMetadataWhere(r, opts.where));
137+
// The caller's bound, applied AFTER the filter and by PRESENCE — a
138+
// double that silently ignores `limit` answers more rows than the
139+
// real engine would, and every assertion downstream of it is then
140+
// measuring a shape production never produces.
141+
return typeof opts?.limit === 'number' ? matched.slice(0, opts.limit) : matched;
138142
},
139143
async insert(table: string, data: Record<string, unknown>) {
140144
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
@@ -161,6 +161,21 @@
161161
"verb": "update",
162162
"pinned": 1
163163
},
164+
{
165+
"file": "packages/metadata-protocol/src/protocol-publish-drafts-object-field-refs.test.ts",
166+
"verb": "delete",
167+
"pinned": 1
168+
},
169+
{
170+
"file": "packages/metadata-protocol/src/protocol-publish-drafts-object-field-refs.test.ts",
171+
"verb": "findOne",
172+
"pinned": 1
173+
},
174+
{
175+
"file": "packages/metadata-protocol/src/protocol-publish-drafts-object-field-refs.test.ts",
176+
"verb": "update",
177+
"pinned": 1
178+
},
164179
{
165180
"file": "packages/metadata-protocol/src/protocol-publish-drafts-org-scope.test.ts",
166181
"verb": "delete",

0 commit comments

Comments
 (0)