|
27 | 27 | // controls pin that a dependency that ANSWERS — including one that answers |
28 | 28 | // "no restriction" — is reported exactly as before. |
29 | 29 | import { describe, it, expect, vi } from 'vitest'; |
30 | | -import { assertEngineFindOnePredicate } from '@objectstack/metadata-core'; |
| 30 | +import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/metadata-core'; |
31 | 31 | import { SharingService, buildSharingMiddleware } from '@objectstack/plugin-sharing'; |
32 | 32 | import { PermissionSetSchema } from '@objectstack/spec/security'; |
33 | 33 | import type { PermissionSet } from '@objectstack/spec/security'; |
@@ -244,6 +244,19 @@ async function makeStack( |
244 | 244 | // A write stops at the engine's door: reaching it is the admission |
245 | 245 | // under test, and no write verb is exercised on this double. |
246 | 246 | 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 | + } |
247 | 260 | }); |
248 | 261 | }); |
249 | 262 | } catch (error) { |
|
0 commit comments