Skip to content

Commit d49ec41

Browse files
committed
test(service-settings): hold the caller's bound in the fixture driver's find
`check:objectql-double-limit` graded the new fixture driver twice: first limit-blind, then touching rows outside the bound because the copy ran before the slice. The bound is now applied after the filter, by presence, and before any row-touching stage; `count` no longer derives a population size from a page. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARYe3yQTQCUFm5qPYNgKaJ
1 parent c6540cd commit d49ec41

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

packages/services/service-settings/src/settings-admission-tenancy-posture.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ function makeMemoryDriver() {
211211
async connect() {}, async disconnect() {}, async checkHealth() { return true; },
212212
async execute() { return null; },
213213
async find(object: string, ast: any) {
214-
return [...rowsOf(object).values()].filter((r) => matches(r, ast?.where)).map(copy);
214+
const rows = [...rowsOf(object).values()].filter((r) => matches(r, ast?.where));
215+
// The caller's bound, applied AFTER the filter and held BY PRESENCE, and
216+
// BEFORE the copy — a limit-blind double answers more rows than the
217+
// caller asked for, and one that touches rows outside the bound reads
218+
// work the engine it stands in for would never have done.
219+
const page = typeof ast?.limit === 'number' ? rows.slice(0, ast.limit) : rows;
220+
return page.map(copy);
215221
},
216222
async findOne(object: string, ast: any) {
217223
for (const r of rowsOf(object).values()) if (matches(r, ast?.where)) return copy(r);
@@ -237,7 +243,10 @@ function makeMemoryDriver() {
237243
return id && rowsOf(object).has(id) ? this.update(object, id, data) : this.create(object, data);
238244
},
239245
async delete(object: string, id: string) { return rowsOf(object).delete(id); },
240-
async count(object: string, ast: any) { return (await this.find(object, ast)).length; },
246+
// ⛔ Not `find().length`: a bound is a page size, never a population size.
247+
async count(object: string, ast: any) {
248+
return [...rowsOf(object).values()].filter((r) => matches(r, ast?.where)).length;
249+
},
241250
async bulkCreate(object: string, rows: Record<string, unknown>[]) {
242251
return Promise.all(rows.map((r) => this.create(object, r)));
243252
},

0 commit comments

Comments
 (0)