Skip to content

Commit cce969c

Browse files
committed
test(plugin-security): the explain-fault stack's engine door runs the stored-row seam
The merged-in explain-dependency-fault stack is walled, so the Layer 0 tenant wall installs the stored-row seam on its by-id update. Its terminal now runs it on the prior row merged with the payload, as the engine does, through the producer's dispatch predicate. Claude-Session: https://claude.ai/code/session_01Evb5jFDZGKQE9KG4jbMfMF Co-authored-by: Claude <noreply@anthropic.com>
1 parent fe15792 commit cce969c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎packages/plugins/plugin-security/src/explain-dependency-fault.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// controls pin that a dependency that ANSWERS — including one that answers
2828
// "no restriction" — is reported exactly as before.
2929
import { describe, it, expect, vi } from 'vitest';
30-
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
30+
import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
3131
import { SharingService, buildSharingMiddleware } from '@objectstack/plugin-sharing';
3232
import { PermissionSetSchema } from '@objectstack/spec/security';
3333
import type { PermissionSet } from '@objectstack/spec/security';
@@ -244,6 +244,19 @@ async function makeStack(
244244
// A write stops at the engine's door: reaching it is the admission
245245
// under test, and no write verb is exercised on this double.
246246
if (operation === 'read') rows = await engine.find(OBJECT, { where: opCtx.ast.where });
247+
// [#20013] …except the one step the engine takes at that door
248+
// before its statement: it runs the installed stored-row seam
249+
// (`postHookWriteImageCheck`) on the row it writes, the prior row
250+
// merged with the payload. The Layer 0 tenant wall installs that
251+
// seam on every walled update (this stack is walled), and a door
252+
// that skipped it would be refused fail-closed after `next()`.
253+
const seam = opCtx.postHookWriteImageCheck;
254+
if (operation === 'update' && seam) {
255+
const dispatch = assertEngineUpdateDispatch(opCtx.data, opCtx.options);
256+
const prior = dispatch.kind === 'by-id' ? await engine.find(OBJECT, { where: { id: dispatch.id } }) : [];
257+
seam.honoured = true;
258+
await seam.evaluate(prior.map((r: Record<string, unknown>) => ({ ...r, ...opCtx.data })));
259+
}
247260
});
248261
});
249262
} catch (error) {

0 commit comments

Comments
 (0)