Skip to content

Commit a3d52c3

Browse files
committed
test(security): hold the new boot double to the engine-double contracts
The `find` double added for the #18535 anchor pins refuses a WHERE combinator it does not implement instead of comparing it as a field name, applies the caller's bound by presence after the filter, and its grown seam counts are ratcheted into the engine-double ledger. Claude-Session: https://claude.ai/code/session_01Gqi43smmqjJ5sUrhfoPeKu Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3cd53b1 commit a3d52c3

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎packages/plugins/plugin-security/src/security-plugin.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4298,9 +4298,23 @@ describe('audience-anchor bindings read the stack\'s declared capabilities (#185
42984298
registerMiddleware: () => {},
42994299
find: async (object: string, opts?: any) => {
43004300
const where = opts?.where ?? {};
4301-
return (tables[object] ?? []).filter((r: any) =>
4302-
Object.entries(where).every(([k, v]) => r[k] === v),
4301+
const matched = (tables[object] ?? []).filter((r: any) =>
4302+
// The matcher REFUSES what it does not implement rather than
4303+
// answering as if it had: a `$or` key compared as a field name
4304+
// matches no row and reports that as "no rows"
4305+
// (`check:where-matcher` — refusal is the conforming cheap answer for
4306+
// a double that only ever sees scalar equality).
4307+
Object.entries(where).every(([k, v]) => {
4308+
if (k.startsWith('$')) {
4309+
throw new Error(`test double: unsupported WHERE combinator '${k}' — implement it or narrow the fixture`);
4310+
}
4311+
return r[k] === v;
4312+
}),
43034313
);
4314+
// The caller's bound, applied BY PRESENCE and after the filter — the
4315+
// plugin reads `limit: 5` here to tell an organization-less row from
4316+
// this organization's own (`check:objectql-double-limit`).
4317+
return typeof opts?.limit === 'number' ? matched.slice(0, opts.limit) : matched;
43044318
},
43054319
findOne: async (object: string, query?: EngineFindOneQueryInput) => {
43064320
assertEngineFindOnePredicate(object, query);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,12 +2999,12 @@
29992999
{
30003000
"file": "packages/plugins/plugin-security/src/security-plugin.test.ts",
30013001
"verb": "findOne",
3002-
"pinned": 5
3002+
"pinned": 6
30033003
},
30043004
{
30053005
"file": "packages/plugins/plugin-security/src/security-plugin.test.ts",
30063006
"verb": "update",
3007-
"pinned": 1
3007+
"pinned": 2
30083008
},
30093009
{
30103010
"file": "packages/plugins/plugin-security/src/seed-write-refusal.test.ts",

0 commit comments

Comments
 (0)