Skip to content

Commit a400e6e

Browse files
committed
test(runtime): honour the caller's limit in the seed-scope engine double and pin its seams
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D47qPfEWVPmhguWgBZCi5N
1 parent 3957abd commit a400e6e

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

packages/runtime/src/domains/packages-seed-apply-org-scope.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,14 @@ function makeEngine() {
164164
registerItem: () => undefined,
165165
registerObject: () => undefined,
166166
},
167-
async find(table: string, opts?: { where?: Record<string, unknown> }) {
167+
async find(table: string, opts?: { where?: Record<string, unknown>, limit?: number }) {
168168
if (table === 'sys_metadata') metaReads.push({ ...(opts?.where ?? {}) });
169-
return tableOf(table).filter((r) => matches(r, opts?.where));
169+
const rows = tableOf(table).filter((r) => matches(r, opts?.where));
170+
// The caller's bound, applied AFTER the filter and by PRESENCE
171+
// (`check:objectql-double-limit`): a double that silently ignores
172+
// `limit` answers more rows than the real engine would, and a pin
173+
// written against a paged read would pass on rows it never sees.
174+
return typeof opts?.limit === 'number' ? rows.slice(0, opts.limit) : rows;
170175
},
171176
async findOne(table: string, opts?: { where?: Record<string, unknown> }) {
172177
assertEngineFindOnePredicate(table, opts);

scripts/engine-double-contract.pinned.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,6 +3141,21 @@
31413141
"verb": "update",
31423142
"pinned": 1
31433143
},
3144+
{
3145+
"file": "packages/runtime/src/domains/packages-seed-apply-org-scope.test.ts",
3146+
"verb": "delete",
3147+
"pinned": 1
3148+
},
3149+
{
3150+
"file": "packages/runtime/src/domains/packages-seed-apply-org-scope.test.ts",
3151+
"verb": "findOne",
3152+
"pinned": 1
3153+
},
3154+
{
3155+
"file": "packages/runtime/src/domains/packages-seed-apply-org-scope.test.ts",
3156+
"verb": "update",
3157+
"pinned": 1
3158+
},
31443159
{
31453160
"file": "packages/runtime/src/domains/share-links-enforcement-context.test.ts",
31463161
"verb": "delete",

0 commit comments

Comments
 (0)