@shirudo/ddd-kit 1.3.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/{aggregate-BGdgvqKh.d.ts → aggregate-DFi6HlEh.d.ts} +143 -88
- package/dist/http.d.ts +36 -13
- package/dist/http.js +15 -7
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +916 -182
- package/dist/index.js +2017 -376
- package/dist/index.js.map +1 -1
- package/dist/presentation.d.ts +54 -0
- package/dist/presentation.js +45 -0
- package/dist/presentation.js.map +1 -0
- package/dist/testing.d.ts +124 -2
- package/dist/testing.js +535 -116
- package/dist/testing.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +160 -18
- package/dist/utils.js.map +1 -1
- package/package.json +20 -13
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/array/is-built-in.ts","../src/utils/array/deep-equal.ts","../src/testing/repository-contract.ts"],"names":["tagA","tagB","len"],"mappings":";;;;AAcA,IAAM,aAAA,uBAAyC,GAAA,CAAI;AAAA,EAClD,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,sBAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACD,CAAC,CAAA;AAMD,SAAS,eAAA,CACR,OACA,IAAA,EAC6B;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,wBAAA,CAAyB,KAAA,EAAO,IAAI,CAAA,EAAG,GAAA;AAG1D,EAAA,IAAI,CAAC,GAAA,EAAK,MAAM,IAAI,KAAA,CAAM,CAAA,6BAAA,EAAgC,IAAI,CAAA,CAAE,CAAA;AAChE,EAAA,OAA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Q;AAAA,EAER;AAIA,EAAA,IAAI;AACH,IAAA,IAAI,KAAA,GAAuB,MAAA,CAAO,cAAA,CAAe,SAAS,CAAA;AAC1D,IAAA,KAAA,IAAS,QAAQ,CAAA,EAAG,KAAA,KAAU,IAAA,IAAQ,KAAA,GAAQ,IAAI,KAAA,EAAA,EAAS;AAC1D,MAAA,IACE,KAAA,CAAM,WAAA,EAAgD,IAAA,KAAS,IAAA,EAC/D;AACD,QAAA,OAAO,IAAA;AAAA,MACR;AACA,MAAA,KAAA,GAAQ,MAAA,CAAO,eAAe,KAAK,CAAA;AAAA,IACpC;AAAA,EACD,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,KAAA;AACR;AAzBS,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AA2BT,SAAS,cAAc,KAAA,EAAwB;AAC9C,EAAA,IAAI,iBAAiB,KAAA,EAAO;AAC3B,IAAA,OAAO,CAAA,EAAG,KAAA,CAAM,IAAI,CAAA,EAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AAAA,EACvC;AACA,EAAA,OAAO,OAAO,KAAK,CAAA;AACpB;AALS,MAAA,CAAA,aAAA,EAAA,eAAA,CAAA","file":"testing.js","sourcesContent":["/**\n * Set of `Object.prototype.toString.call(x)` tags that the library treats\n * as built-in atomic types. Members of this set are compared/cloned by\n * reference (or with type-specific logic) rather than walked structurally.\n *\n * Detection is tag-based, since `Object.prototype.toString` gives the same\n * answer across realms (an iframe's `Date` has the same tag as the main\n * window's `Date`), and then brand-verified via internal-slot probes,\n * because `Symbol.toStringTag` lets any plain object claim a built-in tag.\n * The previous strategy also checked `globalThis[name] === constructor`\n * and a `proto !== Object.prototype` heuristic; both broke for cross-realm\n * objects and the latter additionally misclassified ordinary user classes\n * as built-ins.\n */\nconst BUILT_IN_TAGS: ReadonlySet<string> = new Set([\n\t\"[object Date]\",\n\t\"[object RegExp]\",\n\t\"[object Map]\",\n\t\"[object Set]\",\n\t\"[object WeakMap]\",\n\t\"[object WeakSet]\",\n\t\"[object Promise]\",\n\t\"[object Error]\",\n\t\"[object Boolean]\",\n\t\"[object Number]\",\n\t\"[object String]\",\n\t\"[object ArrayBuffer]\",\n\t\"[object SharedArrayBuffer]\",\n\t\"[object DataView]\",\n]);\n\n// Intrinsic probes for brand verification. Each one reads an internal slot\n// and throws a TypeError when `this` is not a genuine instance, the only\n// check a plain object cannot spoof via `Symbol.toStringTag`. Captured once\n// so a tampered prototype cannot redirect the probe later.\nfunction intrinsicGetter(\n\tproto: object,\n\tprop: string,\n): (this: unknown) => unknown {\n\tconst get = Object.getOwnPropertyDescriptor(proto, prop)?.get;\n\t// Spec-guaranteed accessors on intrinsic prototypes: unreachable\n\t// unless the environment itself is broken.\n\tif (!get) throw new Error(`missing intrinsic getter for ${prop}`);\n\treturn get;\n}\n\nconst dateGetTime = Date.prototype.getTime;\nconst mapSizeGet = intrinsicGetter(Map.prototype, \"size\");\nconst setSizeGet = intrinsicGetter(Set.prototype, \"size\");\nconst weakMapHas = WeakMap.prototype.has;\nconst weakSetHas = WeakSet.prototype.has;\nconst dataViewByteLengthGet = intrinsicGetter(DataView.prototype, \"byteLength\");\nconst arrayBufferByteLengthGet = intrinsicGetter(\n\tArrayBuffer.prototype,\n\t\"byteLength\",\n);\nconst regExpSourceGet = intrinsicGetter(RegExp.prototype, \"source\");\nconst booleanValueOf = Boolean.prototype.valueOf;\nconst numberValueOf = Number.prototype.valueOf;\nconst stringValueOf = String.prototype.valueOf;\nconst PROBE_KEY = {};\n\n/**\n * Tags that `deepEqual` compares BY REFERENCE (its unhandled-built-in\n * fallback) and that `deepOmit` must therefore ALIAS rather than clone:\n * a clone would break `deepEqualExcept(x, x)` reflexivity. Single source\n * of truth so the two modules cannot drift: if `deepEqual` ever learns a\n * by-value comparison for one of these, remove it here and add a clone\n * case in `deepOmit`'s `cloneBuiltIn` in the same change.\n */\nexport const REFERENCE_COMPARED_TAGS: ReadonlySet<string> = new Set([\n\t\"[object Error]\",\n\t\"[object ArrayBuffer]\",\n\t\"[object SharedArrayBuffer]\",\n\t\"[object Promise]\",\n\t\"[object WeakMap]\",\n\t\"[object WeakSet]\",\n]);\n\n/**\n * Verifies that `obj` genuinely is the type its tag claims, via an\n * internal-slot probe. Tags without a cheap probe (Promise, Error,\n * SharedArrayBuffer) are trusted: their downstream handling is\n * reference-based and cannot crash on a spoofed object.\n */\nfunction hasBrand(obj: object, tag: string): boolean {\n\ttry {\n\t\tswitch (tag) {\n\t\t\tcase \"[object Date]\":\n\t\t\t\tdateGetTime.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object RegExp]\":\n\t\t\t\tregExpSourceGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Map]\":\n\t\t\t\tmapSizeGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Set]\":\n\t\t\t\tsetSizeGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object WeakMap]\":\n\t\t\t\tweakMapHas.call(obj, PROBE_KEY);\n\t\t\t\treturn true;\n\t\t\tcase \"[object WeakSet]\":\n\t\t\t\tweakSetHas.call(obj, PROBE_KEY);\n\t\t\t\treturn true;\n\t\t\tcase \"[object DataView]\":\n\t\t\t\tdataViewByteLengthGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object ArrayBuffer]\":\n\t\t\t\tarrayBufferByteLengthGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Boolean]\":\n\t\t\t\tbooleanValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Number]\":\n\t\t\t\tnumberValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object String]\":\n\t\t\t\tstringValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn true;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Returns `true` when `obj` is a built-in JavaScript type that should be\n * treated atomically (compared/cloned as a unit, not walked structurally).\n * Cross-realm safe, and brand-verified: a plain object spoofing a built-in\n * tag via `Symbol.toStringTag` returns `false` and is walked structurally\n * like any other plain object instead of crashing type-specific code.\n *\n * @param obj - The object to classify\n * @param tag - The result of `Object.prototype.toString.call(obj)`, passed\n * in so callers that already computed it don't pay twice\n */\nexport function isBuiltInObject(obj: object, tag: string): boolean {\n\t// ArrayBuffer views (DataView + all TypedArrays, present and future)\n\t// carry an unforgeable internal slot, the strongest brand check.\n\tif (ArrayBuffer.isView(obj)) return true;\n\t// A built-in-looking TypedArray tag WITHOUT the view brand is spoofed.\n\tif (tag.endsWith(\"Array]\")) return false;\n\treturn BUILT_IN_TAGS.has(tag) && hasBrand(obj, tag);\n}\n","import { isBuiltInObject } from \"./is-built-in\";\n\nconst objProto = Object.prototype;\nconst objToString = objProto.toString;\nconst objHasOwn = objProto.hasOwnProperty;\n\n/**\n * SameValueZero: `===` plus NaN-equals-NaN (and `+0 === -0`, unlike\n * `Object.is`). The numeric semantics `deepEqual` documents for primitives,\n * applied consistently inside TypedArrays, Dates and Number wrappers.\n */\nfunction sameValueZero(a: unknown, b: unknown): boolean {\n\treturn (\n\t\ta === b || (Number.isNaN(a as number) && Number.isNaN(b as number))\n\t);\n}\n\n/**\n * Performs a deep equality check between two values.\n *\n * This function compares values recursively, handling:\n * - Primitives (with special handling for NaN)\n * - Arrays (nested arrays supported)\n * - Objects (plain objects and class instances)\n * - TypedArrays (Uint8Array, Int32Array, etc.)\n * - DataView\n * - Maps and Sets\n * - Dates and RegExp\n * - Wrapper objects (Boolean, Number, String)\n * - Circular references (detected and handled)\n *\n * @param a - The first value to compare\n * @param b - The second value to compare\n * @returns `true` if the values are deeply equal, `false` otherwise\n *\n * @example\n * ```ts\n * deepEqual([1, 2, 3], [1, 2, 3]); // true\n * deepEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }); // true\n * deepEqual(NaN, NaN); // true\n * deepEqual([1, 2], [1, 2, 3]); // false\n * ```\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n\treturn deepEqualInner(a, b, new WeakMap<object, WeakSet<object>>());\n}\n\n/**\n * Visited pair tracker for cycle detection. The cache is a pair-set:\n * for every left-hand object we keep the set of right-hand objects we\n * have already paired it with. Encountering an already-known pair returns\n * the cycle hypothesis (assume equal); a new (a, b') pair with b' ≠ any\n * previously cached b for that a is walked normally. The previous shape\n * (`WeakMap<object, object>`) could only remember one B per A, which\n * could short-circuit unrelated comparisons that happened to revisit the\n * same A with a different B.\n */\ntype VisitedPairs = WeakMap<object, WeakSet<object>>;\n\n/**\n * Internal recursive function for deep equality comparison.\n *\n * @internal\n */\nfunction deepEqualInner(\n\ta: unknown,\n\tb: unknown,\n\tvisited: VisitedPairs,\n): boolean {\n\t// 1. Fast path: reference equality\n\tif (a === b) return true;\n\n\tconst typeA = typeof a;\n\tconst typeB = typeof b;\n\n\t// 2. If one is not an object → primitive / function\n\tif (typeA !== \"object\" || a === null || typeB !== \"object\" || b === null) {\n\t\t// Special case: NaN should be equal\n\t\tif (typeA === \"number\" && typeB === \"number\") {\n\t\t\treturn Number.isNaN(a as number) && Number.isNaN(b as number);\n\t\t}\n\t\t// Everything else is directly unequal with !== (including functions)\n\t\treturn false;\n\t}\n\n\t// From here on: both are non-null objects\n\n\tconst objA = a as object;\n\tconst objB = b as object;\n\n\t// 3. Cycles: already seen this exact (a, b) pair?\n\tlet cachedBs = visited.get(objA);\n\tif (cachedBs?.has(objB)) {\n\t\t// Cycle hypothesis: pretend equal so the walk can terminate. If the\n\t\t// structure is actually unequal elsewhere, a different recursive\n\t\t// branch will surface the mismatch.\n\t\treturn true;\n\t}\n\tif (!cachedBs) {\n\t\tcachedBs = new WeakSet();\n\t\tvisited.set(objA, cachedBs);\n\t}\n\tcachedBs.add(objB);\n\n\t// 4. Handle Typed Arrays / DataView first\n\tif (ArrayBuffer.isView(objA) || ArrayBuffer.isView(objB)) {\n\t\tif (!ArrayBuffer.isView(objA) || !ArrayBuffer.isView(objB)) return false;\n\n\t\tconst tagA = objToString.call(objA);\n\t\tconst tagB = objToString.call(objB);\n\t\tif (tagA !== tagB) return false;\n\n\t\t// DataView: compare byte by byte\n\t\tif (tagA === \"[object DataView]\") {\n\t\t\tconst viewA = objA as DataView;\n\t\t\tconst viewB = objB as DataView;\n\t\t\tif (viewA.byteLength !== viewB.byteLength) return false;\n\n\t\t\tconst len = viewA.byteLength;\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tif (viewA.getUint8(i) !== viewB.getUint8(i)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\t// Typed Arrays: element by element (length + numeric index access are\n\t\t// part of the TypedArray contract; the indexed read is sound).\n\t\tconst arrA = objA as unknown as Record<number, unknown> & { length: number };\n\t\tconst arrB = objB as unknown as Record<number, unknown> & { length: number };\n\n\t\tconst len = arrA.length;\n\t\tif (len !== arrB.length) return false;\n\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tif (!sameValueZero(arrA[i], arrB[i])) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// 5. Arrays: `Array.isArray` is brand-based and immune to\n\t// `Symbol.toStringTag` spoofing (a spoofed tag would otherwise route a\n\t// real array away from element comparison, or a plain object into it).\n\tif (Array.isArray(objA) || Array.isArray(objB)) {\n\t\tif (!Array.isArray(objA) || !Array.isArray(objB)) return false;\n\t\tconst arrA = objA as unknown[];\n\t\tconst arrB = objB as unknown[];\n\t\tconst len = arrA.length;\n\t\tif (len !== arrB.length) return false;\n\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tif (!deepEqualInner(arrA[i], arrB[i], visited)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// 6. Tag-based type detection (robust across realms), brand-verified:\n\t// a plain object spoofing a built-in tag is compared as a plain object\n\t// instead of crashing type-specific code below.\n\tconst tagA = objToString.call(objA);\n\tconst tagB = objToString.call(objB);\n\tif (tagA !== tagB) return false;\n\n\tconst builtInA = isBuiltInObject(objA, tagA);\n\tconst builtInB = isBuiltInObject(objB, tagB);\n\t// A genuine built-in never equals a spoofed lookalike.\n\tif (builtInA !== builtInB) return false;\n\n\tif (!builtInA) {\n\t\treturn comparePlainObjects(objA, objB, visited);\n\t}\n\n\tswitch (tagA) {\n\t\tcase \"[object Map]\": {\n\t\t\tconst mapA = objA as Map<unknown, unknown>;\n\t\t\tconst mapB = objB as Map<unknown, unknown>;\n\n\t\t\tif (mapA.size !== mapB.size) return false;\n\n\t\t\tfor (const [key, valA] of mapA) {\n\t\t\t\t// Map keys according to JS semantics: reference / SameValueZero\n\t\t\t\tif (!mapB.has(key)) return false;\n\t\t\t\tconst valB = mapB.get(key);\n\t\t\t\tif (!deepEqualInner(valA, valB, visited)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tcase \"[object Set]\": {\n\t\t\tconst setA = objA as Set<unknown>;\n\t\t\tconst setB = objB as Set<unknown>;\n\n\t\t\tif (setA.size !== setB.size) return false;\n\n\t\t\t// Set elements: same reference (JS semantics)\n\t\t\tfor (const value of setA) {\n\t\t\t\tif (!setB.has(value)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tcase \"[object Date]\": {\n\t\t\t// SameValueZero so two invalid Dates (getTime() === NaN) compare\n\t\t\t// equal, matching the primitive NaN semantics.\n\t\t\treturn sameValueZero((objA as Date).getTime(), (objB as Date).getTime());\n\t\t}\n\n\t\tcase \"[object RegExp]\": {\n\t\t\tconst regA = objA as RegExp;\n\t\t\tconst regB = objB as RegExp;\n\t\t\treturn regA.source === regB.source && regA.flags === regB.flags;\n\t\t}\n\n\t\tcase \"[object Boolean]\":\n\t\tcase \"[object Number]\":\n\t\tcase \"[object String]\": {\n\t\t\t// Wrapper objects (new Boolean/Number/String); SameValueZero so\n\t\t\t// two NaN Number wrappers compare equal.\n\t\t\treturn sameValueZero(\n\t\t\t\t(objA as { valueOf(): unknown }).valueOf(),\n\t\t\t\t(objB as { valueOf(): unknown }).valueOf(),\n\t\t\t);\n\t\t}\n\n\t\tdefault: {\n\t\t\t// Unhandled but brand-trusted built-ins: compared by reference.\n\t\t\t// Their internal structure is unknown, and this keeps new\n\t\t\t// built-ins from falling through to plain-object comparison.\n\t\t\t// This branch IS the REFERENCE_COMPARED_TAGS contract exported\n\t\t\t// from is-built-in.ts (and consumed by deepOmit's cloneBuiltIn):\n\t\t\t// adding a by-value case above means removing the tag there.\n\t\t\treturn objA === objB;\n\t\t}\n\t}\n}\n\n/**\n * Plain / custom objects: compare own enumerable string keys + own symbol\n * keys and their values. Used both as the final fallback and for objects\n * whose built-in-looking tag failed brand verification.\n */\nfunction comparePlainObjects(\n\tobjA: object,\n\tobjB: object,\n\tvisited: VisitedPairs,\n): boolean {\n\tconst recA = objA as Record<string | symbol, unknown>;\n\tconst recB = objB as Record<string | symbol, unknown>;\n\n\tconst stringKeysA = Object.keys(objA);\n\tconst stringKeysB = Object.keys(objB);\n\tif (stringKeysA.length !== stringKeysB.length) return false;\n\n\tconst symbolKeysA = Object.getOwnPropertySymbols(objA);\n\tconst symbolKeysB = Object.getOwnPropertySymbols(objB);\n\tif (symbolKeysA.length !== symbolKeysB.length) return false;\n\n\t// Build the B-side symbol set once; the previous impl rebuilt the\n\t// array and ran .includes per key, which was quadratic.\n\tconst symbolKeysBSet = new Set<symbol>(symbolKeysB);\n\n\tfor (const key of stringKeysA) {\n\t\tif (!objHasOwn.call(objB, key)) return false;\n\t}\n\tfor (const key of symbolKeysA) {\n\t\tif (!symbolKeysBSet.has(key)) return false;\n\t}\n\n\tfor (const key of stringKeysA) {\n\t\tif (!deepEqualInner(recA[key], recB[key], visited)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const key of symbolKeysA) {\n\t\tif (!deepEqualInner(recA[key], recB[key], visited)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","import type { IAggregateRoot } from \"../aggregate/aggregate\";\nimport type { AnyDomainEvent } from \"../aggregate/domain-event\";\nimport type { Id } from \"../core/id\";\nimport { deepEqual } from \"../utils/array/deep-equal\";\n\n/**\n * The repository surface the contract suite exercises: the minimal\n * structural subset of the canonical `IUnitOfWorkRepository` (exported\n * from the main entry) that the tests need. `getById` is typed over\n * the aggregate's own branded id (`TAgg[\"id\"]`), so concrete adapters,\n * including arrow-function-property style repositories, which are\n * checked contravariantly, match without casts.\n */\nexport interface ContractRepository<\n\tTAgg extends IAggregateRoot<Id<string>, AnyDomainEvent>,\n> {\n\tgetById(id: TAgg[\"id\"]): Promise<TAgg | null>;\n\tsave(aggregate: TAgg): Promise<void>;\n\tdelete(aggregate: TAgg): Promise<void>;\n}\n\n/**\n * One isolated test environment: fresh storage, fresh outbox. The\n * suite creates one per test via {@link RepositoryContractHarness} and\n * tears it down afterwards (a teardown failure never masks an\n * in-flight contract violation).\n */\nexport interface RepositoryContractEnvironment<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\t/**\n\t * Execute one unit of work against the adapter under test: open the\n\t * transaction, hand the suite a tx-bound repository, commit on\n\t * resolve, roll back on throw, and run the post-commit lifecycle\n\t * (event harvest into the outbox, `markPersisted`). Wire this\n\t * through your real `UnitOfWork` / `withCommit` setup: the commit\n\t * boundary IS part of what the suite proves.\n\t */\n\trun<R>(\n\t\twork: (ctx: { repository: ContractRepository<TAgg> }) => Promise<R>,\n\t): Promise<R>;\n\n\t/**\n\t * All events currently persisted in the outbox (committed writes\n\t * only; a rolled-back transaction's events must not appear here).\n\t */\n\tcommittedOutboxEvents(): Promise<ReadonlyArray<Evt>>;\n\n\t/** Release connections, drop schemas, etc. Called in a finally. */\n\tteardown?(): Promise<void>;\n}\n\n/**\n * What an adapter supplies to run the contract suite.\n *\n * The harness MUST provide isolation per environment (fresh\n * tables/keyspace or a truncate); tests assume they see only their\n * own writes. **For SQL/ORM adapters this must run against a real\n * database** (testcontainers or equivalent), not an in-memory fake:\n * the mandatory two-writer test proves YOUR `WHERE version = ?`\n * predicate, and an in-memory stand-in proves only itself.\n *\n * Optional capabilities widen the suite: tests for an absent\n * capability come back **marked `skipped`** with a `run()` that\n * rejects loudly: bind them with `it.skip` so the gap stays visible\n * in every report (see {@link RepositoryContractTest}); a naive\n * binding fails instead of green-no-op'ing. Capabilities are captured\n * once at suite creation. Provide every capability your adapter can\n * support; each one closes a real OCC hole.\n */\nexport interface RepositoryContractHarness<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\tcreateEnvironment(): Promise<RepositoryContractEnvironment<TAgg, Evt>>;\n\n\t/**\n\t * A brand-new aggregate (never persisted, unique id,\n\t * `persistedVersion === undefined`).\n\t */\n\tcreateAggregate(): TAgg;\n\n\t/**\n\t * Apply exactly ONE version-bumping domain mutation that records at\n\t * least one domain event (a `commit()`-style state change). The\n\t * suite relies on the +1-per-call arithmetic and on the event for\n\t * its outbox assertions.\n\t */\n\tmutate(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: a version-bumping mutation whose state is deep-equal to\n\t * the previous state (`setState({...state}, true)`). Enables the\n\t * version-only-change-still-persists test: the skip-save/OCC-desync\n\t * trap.\n\t */\n\tmutateVersionOnly?(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: a mutation that changes ONLY a child collection (a\n\t * non-root-row `changedKeys` entry). Enables the\n\t * child-change-bumps-root-version test for partial-write\n\t * repositories.\n\t */\n\tmutateChildCollection?(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: construct a NEW (never-persisted) aggregate instance\n\t * carrying a SPECIFIC id. Enables TWO tests: deletion-is-final-\n\t * across-instances (resurrection via a factory after delete) and\n\t * the duplicate-insert test (see\n\t * {@link insertsAreDuplicateChecked} to opt out of the latter\n\t * independently).\n\t */\n\tcreateAggregateWithId?(id: TAgg[\"id\"]): TAgg;\n\n\t/**\n\t * Semantic opt-OUT (default `true`): whether `save()`'s INSERT path\n\t * rejects an existing id with `DuplicateAggregateError` (mapping the\n\t * driver's unique-violation: Postgres `23505`, MySQL `1062`, SQLite\n\t * `SQLITE_CONSTRAINT_UNIQUE`). This is the near-mandatory contract:\n\t * `save()` is insert-or-update, never upsert. Create-idempotency\n\t * belongs in the USE CASE (load, then decide), not in the save path.\n\t * Set `false` ONLY for a deliberately upserting adapter\n\t * (idempotent-create design); the duplicate-insert test is then\n\t * reported as skipped under this capability name, without costing\n\t * the deletion-finality coverage that `createAggregateWithId` also\n\t * gates.\n\t */\n\tinsertsAreDuplicateChecked?: boolean;\n\n\t/**\n\t * Optional: a plain-data projection of the aggregate's persisted\n\t * state, compared with deep equality. Enables the mandatory test's\n\t * state assertion (without it, only the version and the outbox are\n\t * compared, and an adapter whose predicate guards the version write\n\t * but not the state write would slip through).\n\t *\n\t * **The projection must be roundtrip-stable**: it compares a\n\t * DB-reloaded aggregate against an in-memory one, so normalize\n\t * anything your store changes in transit: dates to ISO strings at\n\t * your store's precision (MySQL DATETIME truncates millis), no\n\t * `undefined`-valued keys (JSON columns drop them), decimals/bigints\n\t * to one consistent representation. A mismatch here fails the\n\t * mandatory test; the message names the projection as a suspect.\n\t */\n\tsnapshotState?(aggregate: TAgg): unknown;\n\n\t/**\n\t * Optional flag: declare it when your `delete(aggregate)` runs an\n\t * OCC predicate (`DELETE … WHERE id = ? AND version = ?`). Enables\n\t * the stale-delete conflict test. Unpredicated deletes are\n\t * last-write-wins by construction: acceptable for GC-style\n\t * cleanup, rarely for user-initiated deletion of contended\n\t * aggregates (see the repository guide).\n\t */\n\tdeletesAreVersionChecked?: boolean;\n}\n\n/**\n * One named contract test; `run` rejects with a descriptive Error on\n * violation. When the harness lacks the capability a test needs, the\n * entry is still returned with {@link skipped} set and a `run` that\n * REJECTS with an explanatory error: bind it with your runner's skip\n * (`(test.skipped ? it.skip : it)(test.name, test.run)`) so the gap is\n * visible in every test report: a missing capability must never look\n * like green coverage, and a naive binding that ignores `skipped`\n * fails loud instead of passing silently.\n */\nexport interface RepositoryContractTest {\n\tname: string;\n\trun: () => Promise<void>;\n\t/** Present when the harness lacks the capability this test needs. */\n\tskipped?: { capability: string };\n}\n\n/**\n * The repository contract test suite: the proof that an adapter\n * actually delivers the guarantees the kit's Unit of Work documents.\n *\n * The kit is ORM-agnostic: the OCC version predicate lives in YOUR\n * repository's SQL. That makes optimistic concurrency a **repository\n * contract, not a kit guarantee**: the kit ships the boundary, the\n * `persistedVersion` baseline, `ConcurrencyConflictError`, and this\n * suite; your adapter must pass it. An adapter that has not passed the\n * suite (against a real database, for SQL adapters) has not\n * demonstrated OCC.\n *\n * Framework-agnostic: assertions throw plain `Error`s, so the suite\n * binds to vitest, jest, or `node:test` the same way:\n *\n * ```ts\n * import { describe, it } from \"vitest\";\n * import { createRepositoryContractTests } from \"@shirudo/ddd-kit/testing\";\n *\n * const harness: RepositoryContractHarness<Order, OrderEvent> = {\n * createEnvironment: async () => {\n * const schema = await provisionTestSchema(); // testcontainers etc.\n * const uowDeps = {\n * scope: schema.scope,\n * outbox: schema.outbox,\n * repositories: {\n * orders: (tx, session) => new DrizzleOrderRepository(tx, session),\n * },\n * };\n * return {\n * run: (work) =>\n * new UnitOfWork(uowDeps).run(({ repositories }) =>\n * work({ repository: repositories.orders })),\n * committedOutboxEvents: () => schema.readOutboxEvents(),\n * teardown: () => schema.drop(),\n * };\n * },\n * createAggregate: () => Order.draft(orderIds.next()),\n * mutate: (order) => order.changeNote(`note-${counter++}`), // ONE bump + event\n * // provide every optional capability your adapter supports:\n * createAggregateWithId: (id) => Order.draft(id),\n * snapshotState: (order) => normalizeForRoundtrip(order.state),\n * deletesAreVersionChecked: true,\n * };\n *\n * describe(\"DrizzleOrderRepository: repository contract\", () => {\n * for (const test of createRepositoryContractTests(harness)) {\n * (test.skipped ? it.skip : it)(test.name, test.run);\n * }\n * });\n * ```\n *\n * **`env.run` must provide unit-of-work semantics.** Three core tests\n * (identity-map sameness, getById-null-after-delete, deletion\n * finality) exercise the session machinery: `session.identityMap`,\n * the `isDeleted` probe, the deleted-gate. Wiring `run` through the\n * kit's `UnitOfWork` gives you all of it; a hand-rolled `withCommit`\n * wiring must provide equivalents or those tests will fail. A\n * `withCommit`-only setup that deliberately makes no identity-map /\n * deletion-finality claims is outside this suite's scope; the suite\n * is the compliance bar for unit-of-work repositories.\n *\n * **Error matching is by NAME along the `cause` chain, not by\n * `instanceof`.** The suite ships in its own bundle entry; comparing\n * class identity would spuriously fail whenever the adapter's errors\n * come from a different copy of the kit (the main entry's bundle, or a\n * second installed version). `error.name === \"ConcurrencyConflictError\"`\n * anywhere in the chain is the contract.\n *\n * **What each test proves.** The OCC, routing, rollback, and outbox\n * tests prove YOUR adapter's SQL and transaction wiring. The\n * identity-map, deletion-finality, and event-lifecycle tests prove\n * your READ-PATH and unit-of-work WIRING (they exercise kit-provided\n * machinery, namely `session.identityMap`, the deleted-gate, and\n * `withCommit`'s harvest, and fail when your repository bypasses or\n * mis-wires it).\n * A deletion-finality failure usually means a missing\n * `identityMap.isDeleted` check or an `enrollSaved` placed after the\n * row write, not a broken DELETE statement.\n *\n * **Known limitation: no truly concurrent runs.** The mandatory\n * two-writer test is deliberately sequential-deterministic: writer B\n * loads, writer A loads/mutates/commits, then B commits its stale\n * instance. The stale `persistedVersion` baseline travels with B's\n * instance, so the version predicate is exercised exactly as in a true\n * race, without depending on lock timing, pool sizes, or\n * engine-specific blocking. The flip side: lock interaction is NOT\n * covered. A `SELECT … FOR UPDATE`-style repository that blocks\n * instead of conflicting, or a SERIALIZABLE engine surfacing raw\n * serialization failures (Postgres 40001) your adapter must map to\n * `ConcurrencyConflictError`, needs adapter-specific tests on top of\n * this suite.\n */\nexport function createRepositoryContractTests<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n>(harness: RepositoryContractHarness<TAgg, Evt>): RepositoryContractTest[] {\n\ttype Env = RepositoryContractEnvironment<TAgg, Evt>;\n\n\tasync function withEnvironment(\n\t\tbody: (env: Env) => Promise<void>,\n\t): Promise<void> {\n\t\tconst env = await harness.createEnvironment();\n\t\tlet bodyFailed = false;\n\t\tlet bodyError: unknown;\n\t\ttry {\n\t\t\tawait body(env);\n\t\t} catch (error) {\n\t\t\tbodyFailed = true;\n\t\t\tbodyError = error;\n\t\t}\n\t\ttry {\n\t\t\tawait env.teardown?.();\n\t\t} catch (teardownError) {\n\t\t\t// A teardown failure (dropping a schema on an aborted pool)\n\t\t\t// must never REPLACE the contract-violation diagnostic that is\n\t\t\t// the suite's entire value. Only surface it when the body\n\t\t\t// itself succeeded.\n\t\t\tif (!bodyFailed) {\n\t\t\t\tthrow teardownError;\n\t\t\t}\n\t\t}\n\t\tif (bodyFailed) {\n\t\t\tthrow bodyError;\n\t\t}\n\t}\n\n\t/** Load with a contract diagnostic instead of a bare TypeError downstream. */\n\tasync function loadOrFail(\n\t\trepository: ContractRepository<TAgg>,\n\t\tid: TAgg[\"id\"],\n\t): Promise<TAgg> {\n\t\tconst loaded = await repository.getById(id);\n\t\tassert(\n\t\t\tloaded !== null,\n\t\t\t`getById(${String(id)}) returned null for an aggregate that must exist - broken hydration or a write that did not commit`,\n\t\t);\n\t\treturn loaded;\n\t}\n\n\t/** Seed one aggregate with a single committed mutation; returns it persisted. */\n\tasync function seed(env: Env): Promise<TAgg> {\n\t\tconst aggregate = harness.createAggregate();\n\t\tharness.mutate(aggregate);\n\t\tawait env.run(async ({ repository }) => {\n\t\t\tawait repository.save(aggregate);\n\t\t});\n\t\treturn aggregate;\n\t}\n\n\tasync function reload(env: Env, id: TAgg[\"id\"]): Promise<TAgg> {\n\t\treturn env.run(({ repository }) => loadOrFail(repository, id));\n\t}\n\n\tfunction captureRejection(promise: Promise<unknown>): Promise<unknown> {\n\t\treturn promise.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t);\n\t}\n\n\t// Sorted: eventIds are unique, so this is a multiset comparison. The\n\t// environment contract guarantees WHICH events are persisted, not the\n\t// order a `SELECT` without `ORDER BY` happens to return them in.\n\tconst eventIds = (events: ReadonlyArray<Evt>): string[] =>\n\t\tevents.map((event) => event.eventId).sort();\n\n\t// Capabilities are captured ONCE at suite creation: a harness mutated\n\t// between createRepositoryContractTests() and the run must not flip a\n\t// test's behavior mid-flight.\n\tconst snapshotState = harness.snapshotState;\n\tconst mutateVersionOnly = harness.mutateVersionOnly;\n\tconst mutateChildCollection = harness.mutateChildCollection;\n\tconst createAggregateWithId = harness.createAggregateWithId;\n\tconst deletesAreVersionChecked = harness.deletesAreVersionChecked === true;\n\t// Semantic opt-OUT, default true (the contract is near-mandatory).\n\tconst insertsAreDuplicateChecked =\n\t\tharness.insertsAreDuplicateChecked !== false;\n\n\tfunction skippedTest(name: string, capability: string): RepositoryContractTest {\n\t\treturn {\n\t\t\tname,\n\t\t\tskipped: { capability },\n\t\t\trun: async () => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Repository contract test skipped: harness capability '${capability}' is not provided. ` +\n\t\t\t\t\t\t`Bind skipped tests with it.skip ((test.skipped ? it.skip : it)(test.name, test.run)) ` +\n\t\t\t\t\t\t`or provide the capability - each one closes a real OCC hole.`,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\tconst tests: RepositoryContractTest[] = [\n\t\t{\n\t\t\tname: \"MANDATORY two-writer conflict: the stale writer throws ConcurrencyConflictError and persists nothing\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst seedEvents = await env.committedOutboxEvents();\n\t\t\t\t\tconst seedEventIds = new Set(seedEvents.map((e) => e.eventId));\n\n\t\t\t\t\t// Writer B loads first - its persistedVersion baseline is\n\t\t\t\t\t// now fixed at the pre-conflict version.\n\t\t\t\t\tconst staleB = await reload(env, seeded.id);\n\n\t\t\t\t\t// Writer A loads the same version, mutates, commits.\n\t\t\t\t\tconst committedA = await env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst a = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tharness.mutate(a);\n\t\t\t\t\t\tawait repository.save(a);\n\t\t\t\t\t\treturn a;\n\t\t\t\t\t});\n\t\t\t\t\tconst outboxAfterA = await env.committedOutboxEvents();\n\t\t\t\t\tassert(\n\t\t\t\t\t\toutboxAfterA.length > seedEvents.length,\n\t\t\t\t\t\t\"writer A's events must reach the outbox on commit\",\n\t\t\t\t\t);\n\t\t\t\t\t// Writer A's NEW events must carry A's ACTUAL committed\n\t\t\t\t\t// version - not merely some number. A wrong value here\n\t\t\t\t\t// (hardcoded, schema version, persistedVersion) would\n\t\t\t\t\t// poison every consumer's ordering/idempotency watermark.\n\t\t\t\t\tconst newSinceSeed = outboxAfterA.filter(\n\t\t\t\t\t\t(event) => !seedEventIds.has(event.eventId),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tnewSinceSeed.length > 0 &&\n\t\t\t\t\t\t\tnewSinceSeed.every(\n\t\t\t\t\t\t\t\t(event) => event.aggregateVersion === committedA.version,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t`writer A's committed outbox events must carry aggregateVersion === ${committedA.version} (A's commit version). ` +\n\t\t\t\t\t\t\t`Suspect #1: your outbox read-back (committedOutboxEvents) reconstructs events from an explicit column list ` +\n\t\t\t\t\t\t\t`and drops or string-types the aggregateVersion field. Suspect #2: a hand-rolled orchestration that does not ` +\n\t\t\t\t\t\t\t`stamp aggregateVersion = aggregate.version at harvest (withCommit does this automatically).`,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Writer B mutates its stale instance and tries to commit.\n\t\t\t\t\tharness.mutate(staleB);\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(staleB);\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\trejection !== undefined,\n\t\t\t\t\t\t\"the second writer's commit must reject - it committed on a stale version instead (OCC predicate missing?)\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"ConcurrencyConflictError\"),\n\t\t\t\t\t\t`the second writer's rejection must be (or wrap, via the cause chain) ConcurrencyConflictError; got: ${describeError(rejection)}`,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Final persisted state equals writer A's.\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tcommittedA.version,\n\t\t\t\t\t\t\"the persisted version must equal writer A's committed version\",\n\t\t\t\t\t);\n\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, final),\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, committedA),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"the persisted STATE must equal writer A's. Two suspects: \" +\n\t\t\t\t\t\t\t\t\"(a) a predicate that guards only the version write lets the stale writer's state survive; \" +\n\t\t\t\t\t\t\t\t\"(b) your snapshotState projection is not roundtrip-stable (date precision, undefined-valued keys, decimal representation) - see its JSDoc\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Outbox contains exactly the events it contained after A's\n\t\t\t\t\t// commit - same records, not merely the same count.\n\t\t\t\t\tconst outboxFinal = await env.committedOutboxEvents();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(eventIds(outboxFinal), eventIds(outboxAfterA)),\n\t\t\t\t\t\t\"the outbox must contain exactly the winning writer's events (compared by eventId) - nothing from the stale writer, nothing replaced\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"insert routing: a never-persisted aggregate INSERTs even after pre-save mutations\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tassert(\n\t\t\t\t\t\taggregate.persistedVersion === undefined,\n\t\t\t\t\t\t\"harness contract: createAggregate() must return a never-persisted aggregate (persistedVersion === undefined)\",\n\t\t\t\t\t);\n\t\t\t\t\t// Mutate BEFORE the first save: version moves past zero in\n\t\t\t\t\t// memory while no row exists. Routing on version === 0\n\t\t\t\t\t// would attempt an UPDATE that affects zero rows.\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tharness.mutate(aggregate);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst loaded = await reload(env, aggregate.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tloaded.version,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"the INSERT must persist the in-memory version (route on persistedVersion === undefined, not version === 0)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"update writes the in-memory version and predicates on persistedVersion\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tbaseline + 2,\n\t\t\t\t\t\t\"two mutations must persist as baseline + 2 (version is a mutation sequence)\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.persistedVersion,\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\"a reloaded aggregate's persistedVersion must equal its version\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"rollback persists nothing: state, version, and outbox untouched\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst versionBefore = seeded.version;\n\t\t\t\t\tconst outboxBefore = (await env.committedOutboxEvents()).length;\n\t\t\t\t\tconst probe = new Error(\"contract rollback probe\");\n\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\tthrow probe;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\trejection !== undefined,\n\t\t\t\t\t\t\"a throwing unit of work must reject\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tversionBefore,\n\t\t\t\t\t\t\"a rolled-back write must not change the persisted version\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t(await env.committedOutboxEvents()).length,\n\t\t\t\t\t\toutboxBefore,\n\t\t\t\t\t\t\"a rolled-back transaction must not leave events in the outbox\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"identity map: two getById calls in one unit of work return the same instance\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst first = await repository.getById(seeded.id);\n\t\t\t\t\t\tconst second = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tfirst !== null && first === second,\n\t\t\t\t\t\t\t\"repeated loads within one unit of work must return the SAME instance (identity map) - distinct instances double-harvest events\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"delete: getById returns null in the same unit of work and after the commit\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\tconst probe = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tprobe === null,\n\t\t\t\t\t\t\t\"after delete, getById in the SAME unit of work must return null (isDeleted check), even if the physical delete is deferred\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst probe = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tprobe === null,\n\t\t\t\t\t\t\t\"after the deleting unit of work committed, the aggregate must be gone\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"deletion is final: saving the deleted aggregate in the same unit of work throws AggregateDeletedError\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"AggregateDeletedError\"),\n\t\t\t\t\t\t`save-after-delete must reject with (or wrap) AggregateDeletedError; got: ${describeError(rejection)}. ` +\n\t\t\t\t\t\t\t`If you see ConcurrencyConflictError here instead, your save() probably enrolls AFTER the row write - enroll first.`,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"events are cleared after a committed unit of work and kept after a rollback\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst committed = harness.createAggregate();\n\t\t\t\t\tharness.mutate(committed);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommitted.pendingEvents.length > 0,\n\t\t\t\t\t\t\"harness contract: mutate() must record at least one domain event\",\n\t\t\t\t\t);\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(committed);\n\t\t\t\t\t});\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tcommitted.pendingEvents.length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"pending events must be cleared after a successful commit\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst rolledBack = harness.createAggregate();\n\t\t\t\t\tharness.mutate(rolledBack);\n\t\t\t\t\tconst pendingBefore = rolledBack.pendingEvents.length;\n\t\t\t\t\tawait captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(rolledBack);\n\t\t\t\t\t\t\tthrow new Error(\"contract rollback probe\");\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\trolledBack.pendingEvents.length,\n\t\t\t\t\t\tpendingBefore,\n\t\t\t\t\t\t\"pending events must survive a rollback (so a fresh load + retry can re-emit them)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"persistedVersion syncs only after a successful commit\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t// Re-saving the SAME instance after the rollback is the\n\t\t\t\t\t// documented carve-out from \"don't reuse aggregates after a\n\t\t\t\t\t// rollback\": a NEVER-persisted aggregate has no row and its\n\t\t\t\t\t// baseline is still undefined, so there is nothing to\n\t\t\t\t\t// reload - retrying its first save is the only path.\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tharness.mutate(aggregate);\n\n\t\t\t\t\tawait captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t\t\tthrow new Error(\"contract rollback probe\");\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\taggregate.persistedVersion === undefined,\n\t\t\t\t\t\t\"a rolled-back first save must leave persistedVersion undefined (the aggregate is still unpersisted)\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.persistedVersion,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"after a successful commit, persistedVersion must equal version (markPersisted ran)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t];\n\n\t// Capability-gated tests: when the harness lacks the capability, the\n\t// entry is returned WITH `skipped` set and a loudly-rejecting run() -\n\t// the gap stays visible in every test report (it.skip) and a naive\n\t// binding fails instead of green-no-op'ing.\n\ttests.push(\n\t\tmutateVersionOnly\n\t\t\t? {\n\t\t\t\t\tname: \"version-only change still persists (skip-save must not desync the OCC baseline)\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\tmutateVersionOnly.call(harness, loaded);\n\t\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tbaseline + 1,\n\t\t\t\t\t\t\t\t\"a version-only change (empty changedKeys, bumped version) must still be persisted - skipping it desyncs persistedVersion and produces false ConcurrencyConflictErrors later\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"version-only change still persists (skip-save must not desync the OCC baseline)\",\n\t\t\t\t\t\"mutateVersionOnly\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tmutateChildCollection\n\t\t\t? {\n\t\t\t\t\tname: \"a child-collection-only change bumps the persisted root version\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\tmutateChildCollection.call(harness, loaded);\n\t\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfinal.version > baseline,\n\t\t\t\t\t\t\t\t\"a child-collection-only change must advance the persisted ROOT version - otherwise concurrent writers interleave with collection writes undetected\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"a child-collection-only change bumps the persisted root version\",\n\t\t\t\t\t\"mutateChildCollection\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tcreateAggregateWithId\n\t\t\t? {\n\t\t\t\t\tname: \"deletion is final across instances: a re-created aggregate with the same id cannot be saved\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\t\t\t\tconst resurrected = createAggregateWithId.call(\n\t\t\t\t\t\t\t\t\t\tharness,\n\t\t\t\t\t\t\t\t\t\tseeded.id,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tharness.mutate(resurrected);\n\t\t\t\t\t\t\t\t\tawait repository.save(resurrected);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"AggregateDeletedError\"),\n\t\t\t\t\t\t\t\t`saving a re-created instance of a deleted aggregate must reject with (or wrap) AggregateDeletedError; got: ${describeError(rejection)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"deletion is final across instances: a re-created aggregate with the same id cannot be saved\",\n\t\t\t\t\t\"createAggregateWithId\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tcreateAggregateWithId && insertsAreDuplicateChecked\n\t\t\t? {\n\t\t\t\t\tname: \"duplicate insert: a second never-persisted aggregate with an existing id throws DuplicateAggregateError\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\t// A second NEVER-persisted instance with the same id:\n\t\t\t\t\t\t\t// two concurrent creators racing on a business-derived\n\t\t\t\t\t\t\t// id, or an id-generator collision. The INSERT must\n\t\t\t\t\t\t\t// surface as the kit's error class, not a raw driver\n\t\t\t\t\t\t\t// error. Mutated TWICE so its version differs from the\n\t\t\t\t\t\t\t// seeded row's - a clobbering insert is then visible\n\t\t\t\t\t\t\t// in the version check below even without a state\n\t\t\t\t\t\t\t// snapshot.\n\t\t\t\t\t\t\tconst duplicate = createAggregateWithId.call(\n\t\t\t\t\t\t\t\tharness,\n\t\t\t\t\t\t\t\tseeded.id,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tharness.mutate(duplicate);\n\t\t\t\t\t\t\tharness.mutate(duplicate);\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tawait repository.save(duplicate);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"DuplicateAggregateError\"),\n\t\t\t\t\t\t\t\t`inserting a second aggregate with an existing id must reject with (or wrap) DuplicateAggregateError - ` +\n\t\t\t\t\t\t\t\t\t`map your driver's unique-violation signal (Postgres 23505, MySQL 1062, SQLite SQLITE_CONSTRAINT_UNIQUE) ` +\n\t\t\t\t\t\t\t\t\t`instead of letting the raw driver error escape; got: ${describeError(rejection)}`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// The existing row is untouched by the rejected insert:\n\t\t\t\t\t\t\t// version AND (capability permitting) state.\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tseeded.version,\n\t\t\t\t\t\t\t\t\"the existing row must be untouched by the rejected duplicate insert - a duplicate check that fires AFTER the write (or outside the transaction) clobbers the existing row\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\t\t\tsnapshotState.call(harness, final),\n\t\t\t\t\t\t\t\t\t\tsnapshotState.call(harness, seeded),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\"the existing row's STATE must be untouched by the rejected duplicate insert\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"duplicate insert: a second never-persisted aggregate with an existing id throws DuplicateAggregateError\",\n\t\t\t\t\t// Name the capability that is actually missing: the\n\t\t\t\t\t// mechanical one (cannot build the duplicate) or the\n\t\t\t\t\t// semantic opt-out (deliberately upserting adapter).\n\t\t\t\t\tcreateAggregateWithId\n\t\t\t\t\t\t? \"insertsAreDuplicateChecked\"\n\t\t\t\t\t\t: \"createAggregateWithId\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tdeletesAreVersionChecked\n\t\t\t? {\n\t\t\t\t\tname: \"stale delete conflicts: deleting from a stale instance throws ConcurrencyConflictError\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\t// Writer B loads, writer A commits an update, B deletes\n\t\t\t\t\t\t\t// from its stale baseline - the predicated DELETE must\n\t\t\t\t\t\t\t// affect zero rows and conflict, not destroy A's write.\n\t\t\t\t\t\t\tconst staleB = await reload(env, seeded.id);\n\t\t\t\t\t\t\tconst versionAfterA = await env.run(\n\t\t\t\t\t\t\t\tasync ({ repository }) => {\n\t\t\t\t\t\t\t\t\tconst a = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\t\tharness.mutate(a);\n\t\t\t\t\t\t\t\t\tawait repository.save(a);\n\t\t\t\t\t\t\t\t\treturn a.version;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tawait repository.delete(staleB);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"ConcurrencyConflictError\"),\n\t\t\t\t\t\t\t\t`a stale delete must reject with (or wrap) ConcurrencyConflictError; got: ${describeError(rejection)} - an unpredicated DELETE silently destroys the concurrent writer's update`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// A's write survived - load nullable on purpose: the\n\t\t\t\t\t\t\t// rejected delete must not have destroyed the row.\n\t\t\t\t\t\t\tconst final = await env.run(({ repository }) =>\n\t\t\t\t\t\t\t\trepository.getById(seeded.id),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfinal !== null,\n\t\t\t\t\t\t\t\t\"the row must still exist after the stale delete was rejected - the predicate must PREVENT the destructive delete, not merely report it\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tversionAfterA,\n\t\t\t\t\t\t\t\t\"the surviving row must carry writer A's version\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"stale delete conflicts: deleting from a stale instance throws ConcurrencyConflictError\",\n\t\t\t\t\t\"deletesAreVersionChecked\",\n\t\t\t\t),\n\t);\n\n\treturn tests;\n}\n\nfunction assert(condition: boolean, message: string): asserts condition {\n\tif (!condition) {\n\t\tthrow new Error(`Repository contract violated: ${message}`);\n\t}\n}\n\nfunction assertEqual(\n\tactual: unknown,\n\texpected: unknown,\n\tmessage: string,\n): void {\n\tif (actual !== expected) {\n\t\tthrow new Error(\n\t\t\t`Repository contract violated: ${message} (expected ${String(expected)}, got ${String(actual)})`,\n\t\t);\n\t}\n}\n\n/**\n * Walks the standard `cause` chain (cycle-safe, hostile-getter-safe)\n * looking for an Error that matches the given name. Matching is\n * deliberately by NAME, not `instanceof`: the suite ships in its own\n * bundle entry, and the adapter's errors come from the main entry's\n * copy of the kit (or even a second installed kit version) -\n * cross-copy `instanceof` is always false, name identity is the stable\n * contract. The kit's error classes pin their runtime `name` via\n * BaseError's `options.name`, so the match survives consumer-side\n * minification AND subclassing (a `PgConflictError extends\n * ConcurrencyConflictError` inherits the pinned name). For errors from\n * OLDER kit versions (no pinned name), the prototype chain's\n * constructor names are checked as a fallback, so subclasses still\n * match.\n */\nfunction chainContainsErrorNamed(error: unknown, name: string): boolean {\n\tconst seen = new Set<unknown>();\n\tlet current: unknown = error;\n\twhile (current !== null && current !== undefined && !seen.has(current)) {\n\t\tif (typeof current !== \"object\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (errorMatchesName(current, name)) {\n\t\t\treturn true;\n\t\t}\n\t\tseen.add(current);\n\t\ttry {\n\t\t\tcurrent = (current as { cause?: unknown }).cause;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction errorMatchesName(candidate: object, name: string): boolean {\n\ttry {\n\t\tif ((candidate as { name?: unknown }).name === name) {\n\t\t\treturn true;\n\t\t}\n\t} catch {\n\t\t// Hostile `name` getter: treat as non-matching, keep walking.\n\t}\n\t// Fallback for errors from kit versions without a pinned runtime\n\t// name: a subclass instance's own `name` is the subclass name, but\n\t// its prototype chain still carries the base class's constructor.\n\ttry {\n\t\tlet proto: object | null = Object.getPrototypeOf(candidate);\n\t\tfor (let depth = 0; proto !== null && depth < 20; depth++) {\n\t\t\tif (\n\t\t\t\t(proto.constructor as { name?: unknown } | undefined)?.name === name\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tproto = Object.getPrototypeOf(proto);\n\t\t}\n\t} catch {\n\t\t// Hostile `constructor` getter on a prototype: non-matching.\n\t}\n\treturn false;\n}\n\nfunction describeError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn `${error.name}: ${error.message}`;\n\t}\n\treturn String(error);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/array/is-built-in.ts","../src/utils/array/deep-equal.ts","../src/testing/contract-assertions.ts","../src/testing/es-repository-contract.ts","../src/testing/repository-contract.ts"],"names":["tagA","tagB","len"],"mappings":";;;;AAcA,IAAM,aAAA,uBAAyC,GAAA,CAAI;AAAA,EAClD,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,sBAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACD,CAAC,CAAA;AAMD,SAAS,eAAA,CACR,OACA,IAAA,EAC6B;AAC7B,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,wBAAA,CAAyB,KAAA,EAAO,IAAI,CAAA,EAAG,GAAA;AAG1D,EAAA,IAAI,CAAC,GAAA,EAAK,MAAM,IAAI,KAAA,CAAM,CAAA,6BAAA,EAAgC,IAAI,CAAA,CAAE,CAAA;AAChE,EAAA,OAAO,GAAA;AACR;AATS,MAAA,CAAA,eAAA,EAAA,iBAAA,CAAA;AAWT,IAAM,WAAA,GAAc,KAAK,SAAA,CAAU,OAAA;AACnC,IAAM,UAAA,GAAa,eAAA,CAAgB,GAAA,CAAI,SAAA,EAAW,MAAM,CAAA;AACxD,IAAM,UAAA,GAAa,eAAA,CAAgB,GAAA,CAAI,SAAA,EAAW,MAAM,CAAA;AACxD,IAAM,UAAA,GAAa,QAAQ,SAAA,CAAU,GAAA;AACrC,IAAM,UAAA,GAAa,QAAQ,SAAA,CAAU,GAAA;AACrC,IAAM,qBAAA,GAAwB,eAAA,CAAgB,QAAA,CAAS,SAAA,EAAW,YAAY,CAAA;AAC9E,IAAM,wBAAA,GAA2B,eAAA;AAAA,EAChC,WAAA,CAAY,SAAA;AAAA,EACZ;AACD,CAAA;AAC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,MAAM,UAAA,CAAW,KAAK,CAAC,CAAA;AACvB,YAAA,OAAO,CAAA,CAAE,OAAA;AAAA,UACV;AAAA,SACD;AAEA,QAAA,MAAM,YAAY,MAAM,gBAAA;AAAA,UACvB,GAAA,CAAI,GAAA,CAAI,OAAO,EAAE,YAAW,KAAM;AACjC,YAAA,MAAM,UAAA,CAAW,OAAO,MAAM,CAAA;AAAA,UAC/B,CAAC;AAAA,SACF;AACA,QAAA,MAAA;AAAA,UACC,uBAAA,CAAwB,WAAW,0BAA0B,CAAA;AAAA,UAC7D,CAAA,yEAAA,EAA4E,aAAA,CAAc,SAAS,CAAC,CAAA,0EAAA;AAAA,SACrG;AAIA,QAAA,MAAM,KAAA,GAAQ,MAAM,GAAA,CAAI,GAAA;AAAA,UAAI,CAAC,EAAE,UAAA,OAC9B,UAAA,CAAW,OAAA,CAAQ,OAAO,EAAE;AAAA,SAC7B;AACA,QAAA,MAAA;AAAA,UACC,KAAA,KAAU,IAAA;AAAA,UACV;AAAA,SACD;AACA,QAAA,WAAA;AAAA,UACC,KAAA,CAAM,OAAA;AAAA,UACN,aAAA;AAAA,UACA;AAAA,SACD;AAAA,MACD,CAAC,CAAA,EAzCG,KAAA;AAAA,KA0CN,GACC,WAAA;AAAA,MACA,wFAAA;AAAA,MACA;AAAA;AACD,GACH;AAEA,EAAA,OAAO,KAAA;AACR;AA7jBgB,MAAA,CAAA,6BAAA,EAAA,+BAAA,CAAA","file":"testing.js","sourcesContent":["/**\n * Set of `Object.prototype.toString.call(x)` tags that the library treats\n * as built-in atomic types. Members of this set are compared/cloned by\n * reference (or with type-specific logic) rather than walked structurally.\n *\n * Detection is tag-based, since `Object.prototype.toString` gives the same\n * answer across realms (an iframe's `Date` has the same tag as the main\n * window's `Date`), and then brand-verified via internal-slot probes,\n * because `Symbol.toStringTag` lets any plain object claim a built-in tag.\n * The previous strategy also checked `globalThis[name] === constructor`\n * and a `proto !== Object.prototype` heuristic; both broke for cross-realm\n * objects and the latter additionally misclassified ordinary user classes\n * as built-ins.\n */\nconst BUILT_IN_TAGS: ReadonlySet<string> = new Set([\n\t\"[object Date]\",\n\t\"[object RegExp]\",\n\t\"[object Map]\",\n\t\"[object Set]\",\n\t\"[object WeakMap]\",\n\t\"[object WeakSet]\",\n\t\"[object Promise]\",\n\t\"[object Error]\",\n\t\"[object Boolean]\",\n\t\"[object Number]\",\n\t\"[object String]\",\n\t\"[object BigInt]\",\n\t\"[object ArrayBuffer]\",\n\t\"[object SharedArrayBuffer]\",\n\t\"[object DataView]\",\n]);\n\n// Intrinsic probes for brand verification. Each one reads an internal slot\n// and throws a TypeError when `this` is not a genuine instance, the only\n// check a plain object cannot spoof via `Symbol.toStringTag`. Captured once\n// so a tampered prototype cannot redirect the probe later.\nfunction intrinsicGetter(\n\tproto: object,\n\tprop: string,\n): (this: unknown) => unknown {\n\tconst get = Object.getOwnPropertyDescriptor(proto, prop)?.get;\n\t// Spec-guaranteed accessors on intrinsic prototypes: unreachable\n\t// unless the environment itself is broken.\n\tif (!get) throw new Error(`missing intrinsic getter for ${prop}`);\n\treturn get;\n}\n\nconst dateGetTime = Date.prototype.getTime;\nconst mapSizeGet = intrinsicGetter(Map.prototype, \"size\");\nconst setSizeGet = intrinsicGetter(Set.prototype, \"size\");\nconst weakMapHas = WeakMap.prototype.has;\nconst weakSetHas = WeakSet.prototype.has;\nconst dataViewByteLengthGet = intrinsicGetter(DataView.prototype, \"byteLength\");\nconst arrayBufferByteLengthGet = intrinsicGetter(\n\tArrayBuffer.prototype,\n\t\"byteLength\",\n);\nconst sharedArrayBufferByteLengthGet =\n\ttypeof SharedArrayBuffer === \"undefined\"\n\t\t? undefined\n\t\t: intrinsicGetter(SharedArrayBuffer.prototype, \"byteLength\");\nconst regExpSourceGet = intrinsicGetter(RegExp.prototype, \"source\");\nconst booleanValueOf = Boolean.prototype.valueOf;\nconst numberValueOf = Number.prototype.valueOf;\nconst stringValueOf = String.prototype.valueOf;\nconst bigIntValueOf = BigInt.prototype.valueOf;\nconst functionToString = Function.prototype.toString;\nconst PROBE_KEY = {};\n\nconst INTRINSIC_CONSTRUCTOR_NAMES = [\n\t\"Object\",\n\t\"Array\",\n\t\"Date\",\n\t\"RegExp\",\n\t\"Map\",\n\t\"Set\",\n\t\"WeakMap\",\n\t\"WeakSet\",\n\t\"Promise\",\n\t\"Error\",\n\t\"EvalError\",\n\t\"RangeError\",\n\t\"ReferenceError\",\n\t\"SyntaxError\",\n\t\"TypeError\",\n\t\"URIError\",\n\t\"AggregateError\",\n\t\"Boolean\",\n\t\"Number\",\n\t\"String\",\n\t\"BigInt\",\n\t\"ArrayBuffer\",\n\t\"SharedArrayBuffer\",\n\t\"DataView\",\n\t\"Int8Array\",\n\t\"Uint8Array\",\n\t\"Uint8ClampedArray\",\n\t\"Int16Array\",\n\t\"Uint16Array\",\n\t\"Int32Array\",\n\t\"Uint32Array\",\n\t\"Float32Array\",\n\t\"Float64Array\",\n\t\"BigInt64Array\",\n\t\"BigUint64Array\",\n] as const;\n\nconst intrinsicConstructorSources: ReadonlyMap<string, string> = new Map(\n\tINTRINSIC_CONSTRUCTOR_NAMES.flatMap((name) => {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(globalThis, name);\n\t\tconst intrinsic = descriptor?.value;\n\t\treturn typeof intrinsic === \"function\"\n\t\t\t? [[name, functionToString.call(intrinsic)] as const]\n\t\t\t: [];\n\t}),\n);\nconst intrinsicConstructorSourceSet: ReadonlySet<string> = new Set(\n\tintrinsicConstructorSources.values(),\n);\nconst ERROR_INTRINSIC_NAMES = [\n\t\"Error\",\n\t\"EvalError\",\n\t\"RangeError\",\n\t\"ReferenceError\",\n\t\"SyntaxError\",\n\t\"TypeError\",\n\t\"URIError\",\n\t\"AggregateError\",\n] as const;\n\nexport function isIntrinsicConstructorPrototype(\n\tprototype: object,\n\texpectedName?: string,\n): boolean {\n\tconst constructorDescriptor = Object.getOwnPropertyDescriptor(\n\t\tprototype,\n\t\t\"constructor\",\n\t);\n\tconst candidateConstructor = constructorDescriptor?.value;\n\tif (\n\t\tconstructorDescriptor === undefined ||\n\t\t!(\"value\" in constructorDescriptor) ||\n\t\ttypeof candidateConstructor !== \"function\"\n\t) {\n\t\treturn false;\n\t}\n\n\tlet candidateSource: string;\n\ttry {\n\t\tcandidateSource = functionToString.call(candidateConstructor);\n\t} catch {\n\t\treturn false;\n\t}\n\tconst expectedSource =\n\t\texpectedName === undefined\n\t\t\t? undefined\n\t\t\t: intrinsicConstructorSources.get(expectedName);\n\tif (\n\t\t(expectedSource !== undefined && candidateSource !== expectedSource) ||\n\t\t(expectedSource === undefined &&\n\t\t\t!intrinsicConstructorSourceSet.has(candidateSource))\n\t) {\n\t\treturn false;\n\t}\n\n\tconst nameDescriptor = Object.getOwnPropertyDescriptor(\n\t\tcandidateConstructor,\n\t\t\"name\",\n\t);\n\tconst candidateName =\n\t\tnameDescriptor !== undefined &&\n\t\t\"value\" in nameDescriptor &&\n\t\ttypeof nameDescriptor.value === \"string\"\n\t\t\t? nameDescriptor.value\n\t\t\t: undefined;\n\tconst intrinsicName = expectedName ?? candidateName;\n\tconst intrinsicSource =\n\t\tintrinsicName === undefined\n\t\t\t? undefined\n\t\t\t: intrinsicConstructorSources.get(intrinsicName);\n\treturn (\n\t\tcandidateName === intrinsicName &&\n\t\tintrinsicSource !== undefined &&\n\t\tcandidateSource === intrinsicSource &&\n\t\tObject.getOwnPropertyDescriptor(candidateConstructor, \"prototype\")\n\t\t\t?.value === prototype\n\t);\n}\n\n/**\n * Accepts an intrinsic prototype, optionally behind transparent\n * `Symbol.toStringTag` override layers. A user-defined subclass has its own\n * non-native constructor and is therefore rejected before reaching the\n * intrinsic prototype.\n */\nexport function hasIntrinsicPrototypeChain(\n\tvalue: object,\n\texpectedName?: string,\n): boolean {\n\tconst visited = new WeakSet<object>();\n\tlet prototype = Object.getPrototypeOf(value);\n\n\twhile (prototype !== null && !visited.has(prototype)) {\n\t\tvisited.add(prototype);\n\t\tif (Object.hasOwn(prototype, \"constructor\")) {\n\t\t\treturn isIntrinsicConstructorPrototype(prototype, expectedName);\n\t\t}\n\t\tconst ownKeys = Reflect.ownKeys(prototype);\n\t\tif (ownKeys.length !== 1 || ownKeys[0] !== Symbol.toStringTag) {\n\t\t\treturn false;\n\t\t}\n\t\tprototype = Object.getPrototypeOf(prototype);\n\t}\n\n\treturn false;\n}\n\n/**\n * Tags that `deepEqual` compares BY REFERENCE (its unhandled-built-in\n * fallback) and that `deepOmit` must therefore ALIAS rather than clone:\n * a clone would break `deepEqualExcept(x, x)` reflexivity. Single source\n * of truth so the two modules cannot drift: if `deepEqual` ever learns a\n * by-value comparison for one of these, remove it here and add a clone\n * case in `deepOmit`'s `cloneBuiltIn` in the same change.\n */\nexport const REFERENCE_COMPARED_TAGS: ReadonlySet<string> = new Set([\n\t\"[object Error]\",\n\t\"[object ArrayBuffer]\",\n\t\"[object SharedArrayBuffer]\",\n\t\"[object Promise]\",\n\t\"[object WeakMap]\",\n\t\"[object WeakSet]\",\n]);\n\nexport function findPropertyDescriptor(\n\tvalue: object,\n\tkey: PropertyKey,\n): PropertyDescriptor | undefined {\n\tconst visited = new WeakSet<object>();\n\tlet current: object | null = value;\n\n\twhile (current !== null && !visited.has(current)) {\n\t\tvisited.add(current);\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(current, key);\n\t\tif (descriptor !== undefined) return descriptor;\n\t\tcurrent = Object.getPrototypeOf(current);\n\t}\n\n\treturn undefined;\n}\n\nexport function objectTagWithoutInvokingAccessors(value: object): string {\n\tconst descriptor = findPropertyDescriptor(value, Symbol.toStringTag);\n\treturn descriptor !== undefined && !(\"value\" in descriptor)\n\t\t? \"[object Object]\"\n\t\t: Object.prototype.toString.call(value);\n}\n\nexport type MutableBuiltInTag =\n\t| \"[object Date]\"\n\t| \"[object Map]\"\n\t| \"[object Set]\";\n\nexport function builtInTagWithoutInvokingAccessors(\n\tvalue: object,\n): string | undefined {\n\tif (ArrayBuffer.isView(value)) {\n\t\treturn hasBrand(value, \"[object DataView]\")\n\t\t\t? \"[object DataView]\"\n\t\t\t: \"[object TypedArray]\";\n\t}\n\n\tconst descriptor = findPropertyDescriptor(value, Symbol.toStringTag);\n\tif (descriptor !== undefined && !(\"value\" in descriptor)) {\n\t\treturn builtInTagFromBrand(value);\n\t}\n\n\tconst tag = Object.prototype.toString.call(value);\n\tif (BUILT_IN_TAGS.has(tag) && hasBrand(value, tag)) {\n\t\treturn tag;\n\t}\n\treturn descriptor === undefined ? undefined : builtInTagFromBrand(value);\n}\n\nexport function mutableBuiltInTagWithoutInvokingAccessors(\n\tvalue: object,\n): MutableBuiltInTag | undefined {\n\tconst tag = builtInTagWithoutInvokingAccessors(value);\n\treturn tag === \"[object Date]\" ||\n\t\ttag === \"[object Map]\" ||\n\t\ttag === \"[object Set]\"\n\t\t? tag\n\t\t: undefined;\n}\n\nfunction builtInTagFromBrand(value: object): string | undefined {\n\tif (hasBrand(value, \"[object Date]\")) return \"[object Date]\";\n\tif (hasBrand(value, \"[object RegExp]\")) return \"[object RegExp]\";\n\tif (hasBrand(value, \"[object Map]\")) return \"[object Map]\";\n\tif (hasBrand(value, \"[object Set]\")) return \"[object Set]\";\n\tif (hasBrand(value, \"[object WeakMap]\")) return \"[object WeakMap]\";\n\tif (hasBrand(value, \"[object WeakSet]\")) return \"[object WeakSet]\";\n\tif (hasBrand(value, \"[object DataView]\")) return \"[object DataView]\";\n\tif (hasBrand(value, \"[object ArrayBuffer]\")) return \"[object ArrayBuffer]\";\n\tif (hasBrand(value, \"[object SharedArrayBuffer]\")) {\n\t\treturn \"[object SharedArrayBuffer]\";\n\t}\n\tif (hasBrand(value, \"[object Boolean]\")) return \"[object Boolean]\";\n\tif (hasBrand(value, \"[object Number]\")) return \"[object Number]\";\n\tif (hasBrand(value, \"[object String]\")) return \"[object String]\";\n\tif (hasBrand(value, \"[object BigInt]\")) return \"[object BigInt]\";\n\tif (hasNativePrototype(value, \"Promise\")) return \"[object Promise]\";\n\tif (hasNativePrototype(value, \"Error\")) return \"[object Error]\";\n\treturn undefined;\n}\n\nfunction hasNativePrototype(value: object, expectedName: string): boolean {\n\tconst visited = new WeakSet<object>();\n\tlet prototype = Object.getPrototypeOf(value);\n\n\twhile (prototype !== null && !visited.has(prototype)) {\n\t\tvisited.add(prototype);\n\t\tif (isIntrinsicConstructorPrototype(prototype, expectedName)) {\n\t\t\treturn true;\n\t\t}\n\t\tprototype = Object.getPrototypeOf(prototype);\n\t}\n\treturn false;\n}\n\n/**\n * Verifies that `obj` genuinely is the type its tag claims, via an\n * internal-slot probe. Promise and Error have no side-effect-free standard\n * probe, so their visible tags remain conservative; masked instances are\n * identified separately through their native prototype chain.\n */\nfunction hasBrand(obj: object, tag: string): boolean {\n\ttry {\n\t\tswitch (tag) {\n\t\t\tcase \"[object Date]\":\n\t\t\t\tdateGetTime.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object RegExp]\":\n\t\t\t\tregExpSourceGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Map]\":\n\t\t\t\tmapSizeGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Set]\":\n\t\t\t\tsetSizeGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object WeakMap]\":\n\t\t\t\tweakMapHas.call(obj, PROBE_KEY);\n\t\t\t\treturn true;\n\t\t\tcase \"[object WeakSet]\":\n\t\t\t\tweakSetHas.call(obj, PROBE_KEY);\n\t\t\t\treturn true;\n\t\t\tcase \"[object DataView]\":\n\t\t\t\tdataViewByteLengthGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object ArrayBuffer]\":\n\t\t\t\tarrayBufferByteLengthGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object SharedArrayBuffer]\":\n\t\t\t\tif (!sharedArrayBufferByteLengthGet) return false;\n\t\t\t\tsharedArrayBufferByteLengthGet.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Boolean]\":\n\t\t\t\tbooleanValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Number]\":\n\t\t\t\tnumberValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object String]\":\n\t\t\t\tstringValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object BigInt]\":\n\t\t\t\tbigIntValueOf.call(obj);\n\t\t\t\treturn true;\n\t\t\tcase \"[object Promise]\":\n\t\t\t\treturn hasNativePrototype(obj, \"Promise\");\n\t\t\tcase \"[object Error]\":\n\t\t\t\treturn ERROR_INTRINSIC_NAMES.some((name) =>\n\t\t\t\t\thasNativePrototype(obj, name),\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Returns `true` when `obj` is a built-in JavaScript type that should be\n * treated atomically (compared/cloned as a unit, not walked structurally).\n * Cross-realm safe, and brand-verified: a plain object spoofing a built-in\n * tag via `Symbol.toStringTag` returns `false` and is walked structurally\n * like any other plain object instead of crashing type-specific code.\n *\n * @param obj - The object to classify\n * @param tag - The result of `Object.prototype.toString.call(obj)`, passed\n * in so callers that already computed it don't pay twice\n */\nexport function isBuiltInObject(obj: object, tag: string): boolean {\n\t// ArrayBuffer views (DataView + all TypedArrays, present and future)\n\t// carry an unforgeable internal slot, the strongest brand check.\n\tif (ArrayBuffer.isView(obj)) return true;\n\t// A built-in-looking TypedArray tag WITHOUT the view brand is spoofed.\n\tif (tag.endsWith(\"Array]\")) return false;\n\treturn BUILT_IN_TAGS.has(tag) && hasBrand(obj, tag);\n}\n","import { isBuiltInObject } from \"./is-built-in\";\n\nconst objProto = Object.prototype;\nconst objToString = objProto.toString;\nconst objHasOwn = objProto.hasOwnProperty;\n\n/**\n * SameValueZero: `===` plus NaN-equals-NaN (and `+0 === -0`, unlike\n * `Object.is`). The numeric semantics `deepEqual` documents for primitives,\n * applied consistently inside TypedArrays, Dates and Number wrappers.\n */\nfunction sameValueZero(a: unknown, b: unknown): boolean {\n\treturn (\n\t\ta === b || (Number.isNaN(a as number) && Number.isNaN(b as number))\n\t);\n}\n\n/**\n * Performs a deep equality check between two values.\n *\n * This function compares values recursively, handling:\n * - Primitives (with special handling for NaN)\n * - Arrays (nested arrays supported)\n * - Objects (plain objects and class instances)\n * - TypedArrays (Uint8Array, Int32Array, etc.)\n * - DataView\n * - Maps and Sets\n * - Dates and RegExp\n * - Wrapper objects (Boolean, Number, String)\n * - Circular references (detected and handled)\n *\n * @param a - The first value to compare\n * @param b - The second value to compare\n * @returns `true` if the values are deeply equal, `false` otherwise\n *\n * @example\n * ```ts\n * deepEqual([1, 2, 3], [1, 2, 3]); // true\n * deepEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }); // true\n * deepEqual(NaN, NaN); // true\n * deepEqual([1, 2], [1, 2, 3]); // false\n * ```\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n\treturn deepEqualInner(a, b, new WeakMap<object, WeakSet<object>>());\n}\n\n/**\n * Visited pair tracker for cycle detection. The cache is a pair-set:\n * for every left-hand object we keep the set of right-hand objects we\n * have already paired it with. Encountering an already-known pair returns\n * the cycle hypothesis (assume equal); a new (a, b') pair with b' ≠ any\n * previously cached b for that a is walked normally. The previous shape\n * (`WeakMap<object, object>`) could only remember one B per A, which\n * could short-circuit unrelated comparisons that happened to revisit the\n * same A with a different B.\n */\ntype VisitedPairs = WeakMap<object, WeakSet<object>>;\n\n/**\n * Internal recursive function for deep equality comparison.\n *\n * @internal\n */\nfunction deepEqualInner(\n\ta: unknown,\n\tb: unknown,\n\tvisited: VisitedPairs,\n): boolean {\n\t// 1. Fast path: reference equality\n\tif (a === b) return true;\n\n\tconst typeA = typeof a;\n\tconst typeB = typeof b;\n\n\t// 2. If one is not an object → primitive / function\n\tif (typeA !== \"object\" || a === null || typeB !== \"object\" || b === null) {\n\t\t// Special case: NaN should be equal\n\t\tif (typeA === \"number\" && typeB === \"number\") {\n\t\t\treturn Number.isNaN(a as number) && Number.isNaN(b as number);\n\t\t}\n\t\t// Everything else is directly unequal with !== (including functions)\n\t\treturn false;\n\t}\n\n\t// From here on: both are non-null objects\n\n\tconst objA = a as object;\n\tconst objB = b as object;\n\n\t// 3. Cycles: already seen this exact (a, b) pair?\n\tlet cachedBs = visited.get(objA);\n\tif (cachedBs?.has(objB)) {\n\t\t// Cycle hypothesis: pretend equal so the walk can terminate. If the\n\t\t// structure is actually unequal elsewhere, a different recursive\n\t\t// branch will surface the mismatch.\n\t\treturn true;\n\t}\n\tif (!cachedBs) {\n\t\tcachedBs = new WeakSet();\n\t\tvisited.set(objA, cachedBs);\n\t}\n\tcachedBs.add(objB);\n\n\t// 4. Handle Typed Arrays / DataView first\n\tif (ArrayBuffer.isView(objA) || ArrayBuffer.isView(objB)) {\n\t\tif (!ArrayBuffer.isView(objA) || !ArrayBuffer.isView(objB)) return false;\n\n\t\tconst tagA = objToString.call(objA);\n\t\tconst tagB = objToString.call(objB);\n\t\tif (tagA !== tagB) return false;\n\n\t\t// DataView: compare byte by byte\n\t\tif (tagA === \"[object DataView]\") {\n\t\t\tconst viewA = objA as DataView;\n\t\t\tconst viewB = objB as DataView;\n\t\t\tif (viewA.byteLength !== viewB.byteLength) return false;\n\n\t\t\tconst len = viewA.byteLength;\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tif (viewA.getUint8(i) !== viewB.getUint8(i)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\t// Typed Arrays: element by element (length + numeric index access are\n\t\t// part of the TypedArray contract; the indexed read is sound).\n\t\tconst arrA = objA as unknown as Record<number, unknown> & { length: number };\n\t\tconst arrB = objB as unknown as Record<number, unknown> & { length: number };\n\n\t\tconst len = arrA.length;\n\t\tif (len !== arrB.length) return false;\n\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tif (!sameValueZero(arrA[i], arrB[i])) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// 5. Arrays: `Array.isArray` is brand-based and immune to\n\t// `Symbol.toStringTag` spoofing (a spoofed tag would otherwise route a\n\t// real array away from element comparison, or a plain object into it).\n\tif (Array.isArray(objA) || Array.isArray(objB)) {\n\t\tif (!Array.isArray(objA) || !Array.isArray(objB)) return false;\n\t\tif (objA.length !== objB.length) return false;\n\n\t\tconst keysA = Reflect.ownKeys(objA).filter((key) => key !== \"length\");\n\t\tconst keysB = Reflect.ownKeys(objB).filter((key) => key !== \"length\");\n\t\tif (keysA.length !== keysB.length) return false;\n\n\t\tconst arrA = objA as unknown as Record<PropertyKey, unknown>;\n\t\tconst arrB = objB as unknown as Record<PropertyKey, unknown>;\n\t\tfor (const key of keysA) {\n\t\t\tif (!objHasOwn.call(objB, key)) return false;\n\t\t\t// Read the element by access (invoking any getter) rather than\n\t\t\t// comparing accessor descriptors by function identity, so an array\n\t\t\t// index defined as a getter is compared by the value it yields,\n\t\t\t// matching how comparePlainObjects treats accessor properties.\n\t\t\t// Sparse holes stay observable through the key-set comparison above:\n\t\t\t// a hole leaves no own key, so two arrays that differ by a hole vs\n\t\t\t// an explicit undefined have different key sets.\n\t\t\tif (!deepEqualInner(arrA[key], arrB[key], visited)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// 6. Tag-based type detection (robust across realms), brand-verified:\n\t// a plain object spoofing a built-in tag is compared as a plain object\n\t// instead of crashing type-specific code below.\n\tconst tagA = objToString.call(objA);\n\tconst tagB = objToString.call(objB);\n\tif (tagA !== tagB) return false;\n\n\tconst builtInA = isBuiltInObject(objA, tagA);\n\tconst builtInB = isBuiltInObject(objB, tagB);\n\t// A genuine built-in never equals a spoofed lookalike.\n\tif (builtInA !== builtInB) return false;\n\n\tif (!builtInA) {\n\t\treturn comparePlainObjects(objA, objB, visited);\n\t}\n\n\tswitch (tagA) {\n\t\tcase \"[object Map]\": {\n\t\t\tconst mapA = objA as Map<unknown, unknown>;\n\t\t\tconst mapB = objB as Map<unknown, unknown>;\n\n\t\t\tif (mapA.size !== mapB.size) return false;\n\n\t\t\tfor (const [key, valA] of mapA) {\n\t\t\t\t// Map keys according to JS semantics: reference / SameValueZero\n\t\t\t\tif (!mapB.has(key)) return false;\n\t\t\t\tconst valB = mapB.get(key);\n\t\t\t\tif (!deepEqualInner(valA, valB, visited)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tcase \"[object Set]\": {\n\t\t\tconst setA = objA as Set<unknown>;\n\t\t\tconst setB = objB as Set<unknown>;\n\n\t\t\tif (setA.size !== setB.size) return false;\n\n\t\t\t// Set elements: same reference (JS semantics)\n\t\t\tfor (const value of setA) {\n\t\t\t\tif (!setB.has(value)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tcase \"[object Date]\": {\n\t\t\t// SameValueZero so two invalid Dates (getTime() === NaN) compare\n\t\t\t// equal, matching the primitive NaN semantics.\n\t\t\treturn sameValueZero((objA as Date).getTime(), (objB as Date).getTime());\n\t\t}\n\n\t\tcase \"[object RegExp]\": {\n\t\t\tconst regA = objA as RegExp;\n\t\t\tconst regB = objB as RegExp;\n\t\t\treturn regA.source === regB.source && regA.flags === regB.flags;\n\t\t}\n\n\t\tcase \"[object Boolean]\":\n\t\tcase \"[object Number]\":\n\t\tcase \"[object String]\":\n\t\tcase \"[object BigInt]\": {\n\t\t\t// Wrapper objects (Boolean/Number/String/BigInt); SameValueZero so\n\t\t\t// two NaN Number wrappers compare equal.\n\t\t\treturn sameValueZero(\n\t\t\t\t(objA as { valueOf(): unknown }).valueOf(),\n\t\t\t\t(objB as { valueOf(): unknown }).valueOf(),\n\t\t\t);\n\t\t}\n\n\t\tdefault: {\n\t\t\t// Unhandled but brand-trusted built-ins: compared by reference.\n\t\t\t// Their internal structure is unknown, and this keeps new\n\t\t\t// built-ins from falling through to plain-object comparison.\n\t\t\t// This branch IS the REFERENCE_COMPARED_TAGS contract exported\n\t\t\t// from is-built-in.ts (and consumed by deepOmit's cloneBuiltIn):\n\t\t\t// adding a by-value case above means removing the tag there.\n\t\t\treturn objA === objB;\n\t\t}\n\t}\n}\n\n/**\n * Plain / custom objects: compare own enumerable string keys + own symbol\n * keys and their values. Used both as the final fallback and for objects\n * whose built-in-looking tag failed brand verification.\n */\nfunction comparePlainObjects(\n\tobjA: object,\n\tobjB: object,\n\tvisited: VisitedPairs,\n): boolean {\n\tconst recA = objA as Record<string | symbol, unknown>;\n\tconst recB = objB as Record<string | symbol, unknown>;\n\n\t// Own string keys including non-enumerable ones: symbols are already\n\t// counted through Object.getOwnPropertySymbols (which ignores\n\t// enumerability), so using Object.keys here would let two objects that\n\t// differ only by a non-enumerable string property compare equal.\n\tconst stringKeysA = Object.getOwnPropertyNames(objA);\n\tconst stringKeysB = Object.getOwnPropertyNames(objB);\n\tif (stringKeysA.length !== stringKeysB.length) return false;\n\n\tconst symbolKeysA = Object.getOwnPropertySymbols(objA);\n\tconst symbolKeysB = Object.getOwnPropertySymbols(objB);\n\tif (symbolKeysA.length !== symbolKeysB.length) return false;\n\n\t// Build the B-side symbol set once; the previous impl rebuilt the\n\t// array and ran .includes per key, which was quadratic.\n\tconst symbolKeysBSet = new Set<symbol>(symbolKeysB);\n\n\tfor (const key of stringKeysA) {\n\t\tif (!objHasOwn.call(objB, key)) return false;\n\t}\n\tfor (const key of symbolKeysA) {\n\t\tif (!symbolKeysBSet.has(key)) return false;\n\t}\n\n\tfor (const key of stringKeysA) {\n\t\tif (!deepEqualInner(recA[key], recB[key], visited)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const key of symbolKeysA) {\n\t\tif (!deepEqualInner(recA[key], recB[key], visited)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","/**\n * Assertion, error-matching, and suite-runner helpers shared by the\n * repository contract suites (state-stored and event-sourced). Internal\n * to the testing entry: not re-exported from `@shirudo/ddd-kit/testing`.\n */\n\n/**\n * Runs one contract-test body against a fresh environment and tears it\n * down in a finally-like discipline with one subtle, load-bearing rule:\n * a teardown failure (dropping a schema on an aborted pool) must never\n * REPLACE the contract-violation diagnostic that is the suite's entire\n * value. It only surfaces when the body itself succeeded.\n */\nexport async function runInContractEnvironment<\n\tEnv extends { teardown?(): Promise<void> },\n>(\n\tcreateEnvironment: () => Promise<Env>,\n\tbody: (env: Env) => Promise<void>,\n): Promise<void> {\n\tconst env = await createEnvironment();\n\tlet bodyFailed = false;\n\tlet bodyError: unknown;\n\ttry {\n\t\tawait body(env);\n\t} catch (error) {\n\t\tbodyFailed = true;\n\t\tbodyError = error;\n\t}\n\ttry {\n\t\tawait env.teardown?.();\n\t} catch (teardownError) {\n\t\tif (!bodyFailed) {\n\t\t\tthrow teardownError;\n\t\t}\n\t}\n\tif (bodyFailed) {\n\t\tthrow bodyError;\n\t}\n}\n\n/** Resolves to the rejection reason, or `undefined` when the promise resolved. */\nexport function captureRejection(promise: Promise<unknown>): Promise<unknown> {\n\treturn promise.then(\n\t\t() => undefined,\n\t\t(error: unknown) => error,\n\t);\n}\n\n/**\n * Load with a contract diagnostic instead of a bare TypeError downstream.\n * `suspectHint` names the suite-specific likely cause (broken hydration\n * vs broken replay read).\n */\nexport async function loadAggregateOrFail<TAgg, TId>(\n\trepository: { getById(id: TId): Promise<TAgg | null> },\n\tid: TId,\n\tsuspectHint: string,\n): Promise<TAgg> {\n\tconst loaded = await repository.getById(id);\n\tassert(\n\t\tloaded !== null,\n\t\t`getById(${String(id)}) returned null for an aggregate that must exist: ${suspectHint}`,\n\t);\n\treturn loaded;\n}\n\n/**\n * A capability-gated test entry whose `run()` rejects loudly, so a naive\n * binding that ignores `skipped` fails instead of green-no-op'ing.\n * Structurally assignable to both suites' test-entry types.\n */\nexport function skippedContractTest(\n\tname: string,\n\tcapability: string,\n): {\n\tname: string;\n\trun: () => Promise<void>;\n\tskipped: { capability: string };\n} {\n\treturn {\n\t\tname,\n\t\tskipped: { capability },\n\t\trun: async () => {\n\t\t\tthrow new Error(\n\t\t\t\t`Repository contract test skipped: harness capability '${capability}' is not provided. ` +\n\t\t\t\t\t`Bind skipped tests with it.skip ((test.skipped ? it.skip : it)(test.name, test.run)) ` +\n\t\t\t\t\t`or provide the capability; each one closes a real OCC hole.`,\n\t\t\t);\n\t\t},\n\t};\n}\n\nexport function assert(condition: boolean, message: string): asserts condition {\n\tif (!condition) {\n\t\tthrow new Error(`Repository contract violated: ${message}`);\n\t}\n}\n\nexport function assertEqual(\n\tactual: unknown,\n\texpected: unknown,\n\tmessage: string,\n): void {\n\tif (actual !== expected) {\n\t\tthrow new Error(\n\t\t\t`Repository contract violated: ${message} (expected ${String(expected)}, got ${String(actual)})`,\n\t\t);\n\t}\n}\n\n/**\n * Walks the standard `cause` chain (cycle-safe, hostile-getter-safe)\n * looking for an Error that matches the given name. Matching is\n * deliberately by NAME, not `instanceof`: the suite ships in its own\n * bundle entry, and the adapter's errors come from the main entry's\n * copy of the kit (or even a second installed kit version) -\n * cross-copy `instanceof` is always false, name identity is the stable\n * contract. The kit's error classes pin their runtime `name` via\n * BaseError's `options.name`, so the match survives consumer-side\n * minification AND subclassing (a `PgConflictError extends\n * ConcurrencyConflictError` inherits the pinned name). For errors from\n * OLDER kit versions (no pinned name), the prototype chain's\n * constructor names are checked as a fallback, so subclasses still\n * match.\n */\nexport function chainContainsErrorNamed(error: unknown, name: string): boolean {\n\tconst seen = new Set<unknown>();\n\tlet current: unknown = error;\n\twhile (current !== null && current !== undefined && !seen.has(current)) {\n\t\tif (typeof current !== \"object\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (errorMatchesName(current, name)) {\n\t\t\treturn true;\n\t\t}\n\t\tseen.add(current);\n\t\ttry {\n\t\t\tcurrent = (current as { cause?: unknown }).cause;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** Like {@link chainContainsErrorNamed}, but accepts any of several names. */\nexport function chainContainsErrorNamedAnyOf(\n\terror: unknown,\n\tnames: readonly string[],\n): boolean {\n\treturn names.some((name) => chainContainsErrorNamed(error, name));\n}\n\nfunction errorMatchesName(candidate: object, name: string): boolean {\n\ttry {\n\t\tif ((candidate as { name?: unknown }).name === name) {\n\t\t\treturn true;\n\t\t}\n\t} catch {\n\t\t// Hostile `name` getter: treat as non-matching, keep walking.\n\t}\n\t// Fallback for errors from kit versions without a pinned runtime\n\t// name: a subclass instance's own `name` is the subclass name, but\n\t// its prototype chain still carries the base class's constructor.\n\ttry {\n\t\tlet proto: object | null = Object.getPrototypeOf(candidate);\n\t\tfor (let depth = 0; proto !== null && depth < 20; depth++) {\n\t\t\tif (\n\t\t\t\t(proto.constructor as { name?: unknown } | undefined)?.name === name\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tproto = Object.getPrototypeOf(proto);\n\t\t}\n\t} catch {\n\t\t// Hostile `constructor` getter on a prototype: non-matching.\n\t}\n\treturn false;\n}\n\nexport function describeError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn `${error.name}: ${error.message}`;\n\t}\n\treturn String(error);\n}\n","import type { IAggregateRoot } from \"../aggregate/aggregate\";\nimport type { AnyDomainEvent } from \"../aggregate/domain-event\";\nimport type { Id } from \"../core/id\";\nimport { deepEqual } from \"../utils/array/deep-equal\";\nimport {\n\tassert,\n\tassertEqual,\n\tcaptureRejection,\n\tchainContainsErrorNamed,\n\tchainContainsErrorNamedAnyOf,\n\tdescribeError,\n\tloadAggregateOrFail,\n\trunInContractEnvironment,\n\tskippedContractTest,\n} from \"./contract-assertions\";\n\n/**\n * The repository surface the event-sourced contract suite exercises.\n * Deliberately smaller than the state-stored `ContractRepository`: pure\n * event-sourced aggregates rarely have a meaningful `delete` (the\n * lifecycle ends with a `Closed` / `Terminated` event in the stream),\n * so the suite does not require one.\n */\nexport interface EsContractRepository<\n\tTAgg extends IAggregateRoot<Id<string>, AnyDomainEvent>,\n> {\n\tgetById(id: TAgg[\"id\"]): Promise<TAgg | null>;\n\tsave(aggregate: TAgg): Promise<void>;\n}\n\n/**\n * One isolated test environment: fresh event store, fresh outbox. The\n * suite creates one per test and tears it down afterwards.\n */\nexport interface EsRepositoryContractEnvironment<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\t/**\n\t * Execute one unit of work against the adapter under test. Wire this\n\t * through your real `UnitOfWork` / `withCommit` setup: the commit\n\t * boundary IS part of what the suite proves (outbox harvest,\n\t * `markPersisted`, rollback purity).\n\t */\n\trun<R>(\n\t\twork: (ctx: { repository: EsContractRepository<TAgg> }) => Promise<R>,\n\t): Promise<R>;\n\n\t/**\n\t * All events currently persisted in the outbox (committed writes\n\t * only; a rolled-back transaction's events must not appear here).\n\t */\n\tcommittedOutboxEvents(): Promise<ReadonlyArray<Evt>>;\n\n\t/**\n\t * The COMMITTED stream for the given aggregate id, in stream order,\n\t * optionally only the events after `fromVersion` (the snapshot\n\t * catch-up read). Implement this through your adapter's\n\t * `EventStore.readStream` so the suite's ordering and slicing\n\t * assertions exercise your real read path. A rolled-back\n\t * transaction's events must not appear here.\n\t */\n\tcommittedStreamEvents(\n\t\tid: TAgg[\"id\"],\n\t\tfromVersion?: number,\n\t): Promise<ReadonlyArray<Evt>>;\n\n\t/** Release connections, drop schemas, etc. Called in a finally. */\n\tteardown?(): Promise<void>;\n}\n\n/**\n * What an adapter supplies to run the event-sourced contract suite.\n *\n * The harness MUST provide isolation per environment. **For SQL-backed\n * event stores this must run against a real database** (testcontainers\n * or equivalent): the mandatory two-writer test proves YOUR\n * expectedVersion guard, and an in-memory stand-in proves only itself.\n *\n * Aggregate arithmetic the suite relies on:\n * - `createAggregate()` returns a fresh aggregate with exactly ONE\n * applied creation event (version 1, `persistedVersion === undefined`).\n * - `mutate()` applies exactly ONE event (+1 version).\n */\nexport interface EsRepositoryContractHarness<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\tcreateEnvironment(): Promise<EsRepositoryContractEnvironment<TAgg, Evt>>;\n\n\t/**\n\t * A brand-new aggregate: exactly one applied creation event, unique\n\t * id, version 1, `persistedVersion === undefined`.\n\t */\n\tcreateAggregate(): TAgg;\n\n\t/** Apply exactly ONE domain event via `apply()` (+1 version). */\n\tmutate(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: construct a NEW (never-persisted) aggregate carrying a\n\t * SPECIFIC id, with its creation event applied. Enables the\n\t * duplicate-create conflict test (two creators racing on one stream).\n\t */\n\tcreateAggregateWithId?(id: TAgg[\"id\"]): TAgg;\n\n\t/**\n\t * Optional: a plain-data projection of the aggregate's state,\n\t * compared with deep equality. Enables the state assertions in the\n\t * mandatory and replay-equality tests. Must be roundtrip-stable\n\t * across your store (see the state-stored harness JSDoc for the\n\t * normalization checklist).\n\t */\n\tsnapshotState?(aggregate: TAgg): unknown;\n}\n\n/** One named contract test; see the state-stored suite for the binding pattern. */\nexport interface EsRepositoryContractTest {\n\tname: string;\n\trun: () => Promise<void>;\n\t/** Present when the harness lacks the capability this test needs. */\n\tskipped?: { capability: string };\n}\n\n/**\n * The event-sourced repository contract test suite: the proof that an\n * adapter delivers what the kit's `EventStore` port and Unit of Work\n * document. The kit is store-agnostic: the expectedVersion guard lives\n * in YOUR adapter's append. That makes stream OCC a **repository\n * contract, not a kit guarantee**; an adapter that has not passed this\n * suite (against a real store, for SQL-backed adapters) has not\n * demonstrated it.\n *\n * What each test proves:\n * - The MANDATORY two-writer test proves your append's expectedVersion\n * guard and its atomicity.\n * - The replay/lifecycle tests prove your read path (fold order,\n * identity map wiring) and the commit lifecycle (outbox harvest,\n * `markPersisted`, rollback purity).\n * - The duplicate-create and fromVersion tests prove the create race\n * and the snapshot catch-up read.\n *\n * Error matching is by NAME along the `cause` chain, not `instanceof`\n * (same rationale as the state-stored suite). Binding:\n *\n * ```ts\n * for (const test of createEsRepositoryContractTests(harness)) {\n * (test.skipped ? it.skip : it)(test.name, test.run);\n * }\n * ```\n *\n * **Known limitation:** like the state-stored suite, the two-writer\n * test is sequential-deterministic; lock interaction and raw\n * serialization failures (Postgres 40001) need adapter-specific tests\n * on top.\n */\nexport function createEsRepositoryContractTests<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n>(\n\tharness: EsRepositoryContractHarness<TAgg, Evt>,\n): EsRepositoryContractTest[] {\n\ttype Env = EsRepositoryContractEnvironment<TAgg, Evt>;\n\n\t// Runner plumbing shared with the state-stored suite; see\n\t// ./contract-assertions for the teardown-never-masks rule.\n\tconst withEnvironment = (body: (env: Env) => Promise<void>): Promise<void> =>\n\t\trunInContractEnvironment(() => harness.createEnvironment(), body);\n\n\tconst loadOrFail = (\n\t\trepository: EsContractRepository<TAgg>,\n\t\tid: TAgg[\"id\"],\n\t): Promise<TAgg> =>\n\t\tloadAggregateOrFail(\n\t\t\trepository,\n\t\t\tid,\n\t\t\t\"broken replay read or a write that did not commit\",\n\t\t);\n\n\t/** Seed one aggregate (creation event only, committed). */\n\tasync function seed(env: Env): Promise<TAgg> {\n\t\tconst aggregate = harness.createAggregate();\n\t\tawait env.run(async ({ repository }) => {\n\t\t\tawait repository.save(aggregate);\n\t\t});\n\t\treturn aggregate;\n\t}\n\n\tasync function reload(env: Env, id: TAgg[\"id\"]): Promise<TAgg> {\n\t\treturn env.run(({ repository }) => loadOrFail(repository, id));\n\t}\n\n\t// Ordered ids: streams are ordered, so stream assertions compare the\n\t// exact sequence (unlike the outbox, whose read-back order is not\n\t// part of the environment contract).\n\tconst orderedIds = (events: ReadonlyArray<Evt>): string[] =>\n\t\tevents.map((event) => event.eventId);\n\tconst sortedIds = (events: ReadonlyArray<Evt>): string[] =>\n\t\torderedIds(events).sort();\n\n\t// Capabilities are captured ONCE at suite creation.\n\tconst snapshotState = harness.snapshotState;\n\tconst createAggregateWithId = harness.createAggregateWithId;\n\n\tconst skippedTest = (\n\t\tname: string,\n\t\tcapability: string,\n\t): EsRepositoryContractTest => skippedContractTest(name, capability);\n\n\tconst tests: EsRepositoryContractTest[] = [\n\t\t{\n\t\t\tname: \"MANDATORY two-writer conflict: the stale writer's append throws ConcurrencyConflictError and the stream is untouched\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst seedStream = await env.committedStreamEvents(seeded.id);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tseedStream.length > 0,\n\t\t\t\t\t\t\"seeding must have appended the creation event to the stream\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// Writer B loads first: its persistedVersion baseline is\n\t\t\t\t\t// now fixed at the pre-conflict stream version.\n\t\t\t\t\tconst staleB = await reload(env, seeded.id);\n\n\t\t\t\t\t// Writer A loads the same version, mutates, commits.\n\t\t\t\t\tconst committedA = await env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst a = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tharness.mutate(a);\n\t\t\t\t\t\tawait repository.save(a);\n\t\t\t\t\t\treturn a;\n\t\t\t\t\t});\n\t\t\t\t\tconst streamAfterA = await env.committedStreamEvents(seeded.id);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tstreamAfterA.length === seedStream.length + 1,\n\t\t\t\t\t\t\"writer A's event must reach the stream on commit\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// Writer B appends a TWO-event batch from its stale baseline:\n\t\t\t\t\t// the exact-ids assertion below then also proves the rejected\n\t\t\t\t\t// append was atomic (no prefix of the batch landed), port\n\t\t\t\t\t// contract point 2.\n\t\t\t\t\tharness.mutate(staleB);\n\t\t\t\t\tharness.mutate(staleB);\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(staleB);\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\trejection !== undefined,\n\t\t\t\t\t\t\"the second writer's commit must reject; it appended on a stale expectedVersion instead (append guard missing?)\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"ConcurrencyConflictError\"),\n\t\t\t\t\t\t`the second writer's rejection must be (or wrap, via the cause chain) ConcurrencyConflictError; got: ${describeError(rejection)}`,\n\t\t\t\t\t);\n\n\t\t\t\t\t// The stream contains exactly writer A's history, in order:\n\t\t\t\t\t// nothing from the stale writer, nothing reordered.\n\t\t\t\t\tconst finalStream = await env.committedStreamEvents(seeded.id);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(orderedIds(finalStream), orderedIds(streamAfterA)),\n\t\t\t\t\t\t\"the stream must contain exactly the winning writer's events in order: a rejected append must leave the stream untouched\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// The reloaded fold equals writer A's aggregate.\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tcommittedA.version,\n\t\t\t\t\t\t\"the reloaded version must equal writer A's committed version (version IS the event count)\",\n\t\t\t\t\t);\n\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, final),\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, committedA),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"the reloaded state must fold to writer A's state. Suspects: a partial append survived the rejection, or your snapshotState projection is not roundtrip-stable\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// The outbox carries the same committed events (as stamped\n\t\t\t\t\t// copies with identical eventIds); nothing from B.\n\t\t\t\t\tconst outbox = await env.committedOutboxEvents();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(sortedIds(outbox), sortedIds(streamAfterA)),\n\t\t\t\t\t\t\"the outbox must contain exactly the committed events (compared by eventId); nothing from the stale writer\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"replay equality: a reloaded aggregate folds the committed stream in emission order\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tconst emittedIds = orderedIds(aggregate.pendingEvents);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\temittedIds.length,\n\t\t\t\t\t\t3,\n\t\t\t\t\t\t\"harness contract: createAggregate applies ONE creation event and mutate applies ONE event each\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\n\t\t\t\t\t// The stream holds the UNSTAMPED originals in emission order.\n\t\t\t\t\tconst stream = await env.committedStreamEvents(aggregate.id);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(orderedIds(stream), emittedIds),\n\t\t\t\t\t\t\"the committed stream must contain exactly the emitted events in emission order; reordering breaks every consumer's fold\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// Post-commit lifecycle on the saved instance.\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.pendingEvents.length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"pending events must be cleared after a successful commit (markPersisted ran)\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.persistedVersion,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"after a successful commit, persistedVersion must equal version\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// The reload folds to the same aggregate.\n\t\t\t\t\tconst reloaded = await reload(env, aggregate.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\treloaded.version,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"the reloaded version must equal the event count\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\treloaded.persistedVersion,\n\t\t\t\t\t\treloaded.version,\n\t\t\t\t\t\t\"a reloaded aggregate's persistedVersion must equal its version\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\treloaded.pendingEvents.length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"a reloaded aggregate must not carry pending events (replay is not re-recording)\",\n\t\t\t\t\t);\n\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, reloaded),\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, aggregate),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"the reloaded aggregate must fold to the same state as the in-memory instance. Suspects: fold order (readStream must return emission order), or a snapshotState projection that is not roundtrip-stable\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"getById returns null for a stream that does not exist\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst never = harness.createAggregate();\n\t\t\t\t\tconst probe = await env.run(({ repository }) =>\n\t\t\t\t\t\trepository.getById(never.id),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tprobe === null,\n\t\t\t\t\t\t\"getById of a never-persisted id must return null (empty stream = no aggregate)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"identity map: two getById calls in one unit of work return the same instance\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst first = await repository.getById(seeded.id);\n\t\t\t\t\t\tconst second = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tfirst !== null && first === second,\n\t\t\t\t\t\t\t\"repeated loads within one unit of work must return the SAME instance (identity map); distinct instances double-harvest events\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"rollback persists nothing: stream and outbox untouched, pending events survive, first save can be retried\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tconst pendingBefore = aggregate.pendingEvents.length;\n\n\t\t\t\t\tawait captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t\t\tthrow new Error(\"contract rollback probe\");\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t(await env.committedStreamEvents(aggregate.id)).length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"a rolled-back transaction must not leave events in the stream\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t(await env.committedOutboxEvents()).length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"a rolled-back transaction must not leave events in the outbox\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.pendingEvents.length,\n\t\t\t\t\t\tpendingBefore,\n\t\t\t\t\t\t\"pending events must survive a rollback (so the first save can be retried)\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\taggregate.persistedVersion === undefined,\n\t\t\t\t\t\t\"a rolled-back first save must leave persistedVersion undefined (the stream does not exist)\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// Retrying the SAME never-persisted instance is the\n\t\t\t\t\t// documented carve-out: there is no row/stream to reload.\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t(await env.committedStreamEvents(aggregate.id)).length,\n\t\t\t\t\t\tpendingBefore,\n\t\t\t\t\t\t\"the retried first save must append the full pending history\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.persistedVersion,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"after the successful retry, persistedVersion must equal version\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"readStream honors fromVersion: the snapshot catch-up read returns exactly the events after the position\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst full = await env.committedStreamEvents(aggregate.id);\n\t\t\t\t\tassertEqual(full.length, 3, \"seeding must have committed 3 events\");\n\n\t\t\t\t\tconst afterOne = await env.committedStreamEvents(aggregate.id, 1);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(orderedIds(afterOne), orderedIds(full.slice(1))),\n\t\t\t\t\t\t\"fromVersion=1 must return exactly the events after stream position 1, in order; restoreFromSnapshotWithEvents replays exactly this window\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst afterAll = await env.committedStreamEvents(\n\t\t\t\t\t\taggregate.id,\n\t\t\t\t\t\tfull.length,\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tafterAll.length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"fromVersion at the stream head must return no events\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t];\n\n\ttests.push(\n\t\tcreateAggregateWithId\n\t\t\t? {\n\t\t\t\t\tname: \"duplicate create: two creators racing on one stream; the second append conflicts and the stream is untouched\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\t\t\tconst seedStream = await env.committedStreamEvents(seeded.id);\n\n\t\t\t\t\t\t\tconst duplicate = createAggregateWithId.call(\n\t\t\t\t\t\t\t\tharness,\n\t\t\t\t\t\t\t\tseeded.id,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tawait repository.save(duplicate);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamedAnyOf(rejection, [\n\t\t\t\t\t\t\t\t\t\"ConcurrencyConflictError\",\n\t\t\t\t\t\t\t\t\t\"DuplicateAggregateError\",\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t`the duplicate creator's append (expectedVersion 0 on an existing stream) must reject with (or wrap) ConcurrencyConflictError or DuplicateAggregateError; got: ${describeError(rejection)}`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst finalStream = await env.committedStreamEvents(seeded.id);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tdeepEqual(orderedIds(finalStream), orderedIds(seedStream)),\n\t\t\t\t\t\t\t\t\"the existing stream must be untouched by the rejected duplicate create\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"duplicate create: two creators racing on one stream; the second append conflicts and the stream is untouched\",\n\t\t\t\t\t\"createAggregateWithId\",\n\t\t\t\t),\n\t);\n\n\treturn tests;\n}\n","import type { IAggregateRoot } from \"../aggregate/aggregate\";\nimport type { AnyDomainEvent } from \"../aggregate/domain-event\";\nimport type { Id } from \"../core/id\";\nimport { deepEqual } from \"../utils/array/deep-equal\";\nimport {\n\tassert,\n\tassertEqual,\n\tcaptureRejection,\n\tchainContainsErrorNamed,\n\tdescribeError,\n\tloadAggregateOrFail,\n\trunInContractEnvironment,\n\tskippedContractTest,\n} from \"./contract-assertions\";\n\n/**\n * The repository surface the contract suite exercises: the minimal\n * structural subset of the canonical `IUnitOfWorkRepository` (exported\n * from the main entry) that the tests need. `getById` is typed over\n * the aggregate's own branded id (`TAgg[\"id\"]`), so concrete adapters,\n * including arrow-function-property style repositories, which are\n * checked contravariantly, match without casts.\n */\nexport interface ContractRepository<\n\tTAgg extends IAggregateRoot<Id<string>, AnyDomainEvent>,\n> {\n\tgetById(id: TAgg[\"id\"]): Promise<TAgg | null>;\n\tsave(aggregate: TAgg): Promise<void>;\n\tdelete(aggregate: TAgg): Promise<void>;\n}\n\n/**\n * One isolated test environment: fresh storage, fresh outbox. The\n * suite creates one per test via {@link RepositoryContractHarness} and\n * tears it down afterwards (a teardown failure never masks an\n * in-flight contract violation).\n */\nexport interface RepositoryContractEnvironment<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\t/**\n\t * Execute one unit of work against the adapter under test: open the\n\t * transaction, hand the suite a tx-bound repository, commit on\n\t * resolve, roll back on throw, and run the post-commit lifecycle\n\t * (event harvest into the outbox, `markPersisted`). Wire this\n\t * through your real `UnitOfWork` / `withCommit` setup: the commit\n\t * boundary IS part of what the suite proves.\n\t */\n\trun<R>(\n\t\twork: (ctx: { repository: ContractRepository<TAgg> }) => Promise<R>,\n\t): Promise<R>;\n\n\t/**\n\t * All events currently persisted in the outbox (committed writes\n\t * only; a rolled-back transaction's events must not appear here).\n\t */\n\tcommittedOutboxEvents(): Promise<ReadonlyArray<Evt>>;\n\n\t/** Release connections, drop schemas, etc. Called in a finally. */\n\tteardown?(): Promise<void>;\n}\n\n/**\n * What an adapter supplies to run the contract suite.\n *\n * The harness MUST provide isolation per environment (fresh\n * tables/keyspace or a truncate); tests assume they see only their\n * own writes. **For SQL/ORM adapters this must run against a real\n * database** (testcontainers or equivalent), not an in-memory fake:\n * the mandatory two-writer test proves YOUR `WHERE version = ?`\n * predicate, and an in-memory stand-in proves only itself.\n *\n * Optional capabilities widen the suite: tests for an absent\n * capability come back **marked `skipped`** with a `run()` that\n * rejects loudly: bind them with `it.skip` so the gap stays visible\n * in every report (see {@link RepositoryContractTest}); a naive\n * binding fails instead of green-no-op'ing. Capabilities are captured\n * once at suite creation. Provide every capability your adapter can\n * support; each one closes a real OCC hole.\n */\nexport interface RepositoryContractHarness<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n> {\n\tcreateEnvironment(): Promise<RepositoryContractEnvironment<TAgg, Evt>>;\n\n\t/**\n\t * A brand-new aggregate (never persisted, unique id,\n\t * `persistedVersion === undefined`).\n\t */\n\tcreateAggregate(): TAgg;\n\n\t/**\n\t * Apply exactly ONE version-bumping domain mutation that records at\n\t * least one domain event (a `commit()`-style state change). The\n\t * suite relies on the +1-per-call arithmetic and on the event for\n\t * its outbox assertions.\n\t */\n\tmutate(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: a version-bumping mutation whose state is deep-equal to\n\t * the previous state (`setState({...state}, true)`). Enables the\n\t * version-only-change-still-persists test: the skip-save/OCC-desync\n\t * trap.\n\t */\n\tmutateVersionOnly?(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: a mutation that changes ONLY a child collection (a\n\t * non-root-row `changedKeys` entry). Enables the\n\t * child-change-bumps-root-version test for partial-write\n\t * repositories.\n\t */\n\tmutateChildCollection?(aggregate: TAgg): void;\n\n\t/**\n\t * Optional: construct a NEW (never-persisted) aggregate instance\n\t * carrying a SPECIFIC id. Enables TWO tests: deletion-is-final-\n\t * across-instances (resurrection via a factory after delete) and\n\t * the duplicate-insert test (see\n\t * {@link insertsAreDuplicateChecked} to opt out of the latter\n\t * independently).\n\t */\n\tcreateAggregateWithId?(id: TAgg[\"id\"]): TAgg;\n\n\t/**\n\t * Semantic opt-OUT (default `true`): whether `save()`'s INSERT path\n\t * rejects an existing id with `DuplicateAggregateError` (mapping the\n\t * driver's unique-violation: Postgres `23505`, MySQL `1062`, SQLite\n\t * `SQLITE_CONSTRAINT_UNIQUE`). This is the near-mandatory contract:\n\t * `save()` is insert-or-update, never upsert. Create-idempotency\n\t * belongs in the USE CASE (load, then decide), not in the save path.\n\t * Set `false` ONLY for a deliberately upserting adapter\n\t * (idempotent-create design); the duplicate-insert test is then\n\t * reported as skipped under this capability name, without costing\n\t * the deletion-finality coverage that `createAggregateWithId` also\n\t * gates.\n\t */\n\tinsertsAreDuplicateChecked?: boolean;\n\n\t/**\n\t * Optional: a plain-data projection of the aggregate's persisted\n\t * state, compared with deep equality. Enables the mandatory test's\n\t * state assertion (without it, only the version and the outbox are\n\t * compared, and an adapter whose predicate guards the version write\n\t * but not the state write would slip through).\n\t *\n\t * **The projection must be roundtrip-stable**: it compares a\n\t * DB-reloaded aggregate against an in-memory one, so normalize\n\t * anything your store changes in transit: dates to ISO strings at\n\t * your store's precision (MySQL DATETIME truncates millis), no\n\t * `undefined`-valued keys (JSON columns drop them), decimals/bigints\n\t * to one consistent representation. A mismatch here fails the\n\t * mandatory test; the message names the projection as a suspect.\n\t */\n\tsnapshotState?(aggregate: TAgg): unknown;\n\n\t/**\n\t * Optional flag: declare it when your `delete(aggregate)` runs an\n\t * OCC predicate (`DELETE … WHERE id = ? AND version = ?`). Enables\n\t * the stale-delete conflict test. Unpredicated deletes are\n\t * last-write-wins by construction: acceptable for GC-style\n\t * cleanup, rarely for user-initiated deletion of contended\n\t * aggregates (see the repository guide).\n\t */\n\tdeletesAreVersionChecked?: boolean;\n}\n\n/**\n * One named contract test; `run` rejects with a descriptive Error on\n * violation. When the harness lacks the capability a test needs, the\n * entry is still returned with {@link skipped} set and a `run` that\n * REJECTS with an explanatory error: bind it with your runner's skip\n * (`(test.skipped ? it.skip : it)(test.name, test.run)`) so the gap is\n * visible in every test report: a missing capability must never look\n * like green coverage, and a naive binding that ignores `skipped`\n * fails loud instead of passing silently.\n */\nexport interface RepositoryContractTest {\n\tname: string;\n\trun: () => Promise<void>;\n\t/** Present when the harness lacks the capability this test needs. */\n\tskipped?: { capability: string };\n}\n\n/**\n * The repository contract test suite: the proof that an adapter\n * actually delivers the guarantees the kit's Unit of Work documents.\n *\n * The kit is ORM-agnostic: the OCC version predicate lives in YOUR\n * repository's SQL. That makes optimistic concurrency a **repository\n * contract, not a kit guarantee**: the kit ships the boundary, the\n * `persistedVersion` baseline, `ConcurrencyConflictError`, and this\n * suite; your adapter must pass it. An adapter that has not passed the\n * suite (against a real database, for SQL adapters) has not\n * demonstrated OCC.\n *\n * Framework-agnostic: assertions throw plain `Error`s, so the suite\n * binds to vitest, jest, or `node:test` the same way:\n *\n * ```ts\n * import { describe, it } from \"vitest\";\n * import { createRepositoryContractTests } from \"@shirudo/ddd-kit/testing\";\n *\n * const harness: RepositoryContractHarness<Order, OrderEvent> = {\n * createEnvironment: async () => {\n * const schema = await provisionTestSchema(); // testcontainers etc.\n * const uowDeps = {\n * scope: schema.scope,\n * outbox: schema.outbox,\n * repositories: {\n * orders: (tx, session) => new DrizzleOrderRepository(tx, session),\n * },\n * };\n * return {\n * run: (work) =>\n * new UnitOfWork(uowDeps).run(({ repositories }) =>\n * work({ repository: repositories.orders })),\n * committedOutboxEvents: () => schema.readOutboxEvents(),\n * teardown: () => schema.drop(),\n * };\n * },\n * createAggregate: () => Order.draft(orderIds.next()),\n * mutate: (order) => order.changeNote(`note-${counter++}`), // ONE bump + event\n * // provide every optional capability your adapter supports:\n * createAggregateWithId: (id) => Order.draft(id),\n * snapshotState: (order) => normalizeForRoundtrip(order.state),\n * deletesAreVersionChecked: true,\n * };\n *\n * describe(\"DrizzleOrderRepository: repository contract\", () => {\n * for (const test of createRepositoryContractTests(harness)) {\n * (test.skipped ? it.skip : it)(test.name, test.run);\n * }\n * });\n * ```\n *\n * **`env.run` must provide unit-of-work semantics.** Three core tests\n * (identity-map sameness, getById-null-after-delete, deletion\n * finality) exercise the session machinery: `session.identityMap`,\n * the `isDeleted` probe, the deleted-gate. Wiring `run` through the\n * kit's `UnitOfWork` gives you all of it; a hand-rolled `withCommit`\n * wiring must provide equivalents or those tests will fail. A\n * `withCommit`-only setup that deliberately makes no identity-map /\n * deletion-finality claims is outside this suite's scope; the suite\n * is the compliance bar for unit-of-work repositories.\n *\n * **Error matching is by NAME along the `cause` chain, not by\n * `instanceof`.** The suite ships in its own bundle entry; comparing\n * class identity would spuriously fail whenever the adapter's errors\n * come from a different copy of the kit (the main entry's bundle, or a\n * second installed version). `error.name === \"ConcurrencyConflictError\"`\n * anywhere in the chain is the contract.\n *\n * **What each test proves.** The OCC, routing, rollback, and outbox\n * tests prove YOUR adapter's SQL and transaction wiring. The\n * identity-map, deletion-finality, and event-lifecycle tests prove\n * your READ-PATH and unit-of-work WIRING (they exercise kit-provided\n * machinery, namely `session.identityMap`, the deleted-gate, and\n * `withCommit`'s harvest, and fail when your repository bypasses or\n * mis-wires it).\n * A deletion-finality failure usually means a missing\n * `identityMap.isDeleted` check or an `enrollSaved` placed after the\n * row write, not a broken DELETE statement.\n *\n * **Known limitation: no truly concurrent runs.** The mandatory\n * two-writer test is deliberately sequential-deterministic: writer B\n * loads, writer A loads/mutates/commits, then B commits its stale\n * instance. The stale `persistedVersion` baseline travels with B's\n * instance, so the version predicate is exercised exactly as in a true\n * race, without depending on lock timing, pool sizes, or\n * engine-specific blocking. The flip side: lock interaction is NOT\n * covered. A `SELECT … FOR UPDATE`-style repository that blocks\n * instead of conflicting, or a SERIALIZABLE engine surfacing raw\n * serialization failures (Postgres 40001) your adapter must map to\n * `ConcurrencyConflictError`, needs adapter-specific tests on top of\n * this suite.\n */\nexport function createRepositoryContractTests<\n\tTAgg extends IAggregateRoot<Id<string>, Evt>,\n\tEvt extends AnyDomainEvent = AnyDomainEvent,\n>(harness: RepositoryContractHarness<TAgg, Evt>): RepositoryContractTest[] {\n\ttype Env = RepositoryContractEnvironment<TAgg, Evt>;\n\n\t// Runner plumbing shared with the event-sourced suite; see\n\t// ./contract-assertions for the teardown-never-masks rule.\n\tconst withEnvironment = (body: (env: Env) => Promise<void>): Promise<void> =>\n\t\trunInContractEnvironment(() => harness.createEnvironment(), body);\n\n\tconst loadOrFail = (\n\t\trepository: ContractRepository<TAgg>,\n\t\tid: TAgg[\"id\"],\n\t): Promise<TAgg> =>\n\t\tloadAggregateOrFail(\n\t\t\trepository,\n\t\t\tid,\n\t\t\t\"broken hydration or a write that did not commit\",\n\t\t);\n\n\t/** Seed one aggregate with a single committed mutation; returns it persisted. */\n\tasync function seed(env: Env): Promise<TAgg> {\n\t\tconst aggregate = harness.createAggregate();\n\t\tharness.mutate(aggregate);\n\t\tawait env.run(async ({ repository }) => {\n\t\t\tawait repository.save(aggregate);\n\t\t});\n\t\treturn aggregate;\n\t}\n\n\tasync function reload(env: Env, id: TAgg[\"id\"]): Promise<TAgg> {\n\t\treturn env.run(({ repository }) => loadOrFail(repository, id));\n\t}\n\n\t// Sorted: eventIds are unique, so this is a multiset comparison. The\n\t// environment contract guarantees WHICH events are persisted, not the\n\t// order a `SELECT` without `ORDER BY` happens to return them in.\n\tconst eventIds = (events: ReadonlyArray<Evt>): string[] =>\n\t\tevents.map((event) => event.eventId).sort();\n\n\t// Capabilities are captured ONCE at suite creation: a harness mutated\n\t// between createRepositoryContractTests() and the run must not flip a\n\t// test's behavior mid-flight.\n\tconst snapshotState = harness.snapshotState;\n\tconst mutateVersionOnly = harness.mutateVersionOnly;\n\tconst mutateChildCollection = harness.mutateChildCollection;\n\tconst createAggregateWithId = harness.createAggregateWithId;\n\tconst deletesAreVersionChecked = harness.deletesAreVersionChecked === true;\n\t// Semantic opt-OUT, default true (the contract is near-mandatory).\n\tconst insertsAreDuplicateChecked =\n\t\tharness.insertsAreDuplicateChecked !== false;\n\n\tconst skippedTest = (\n\t\tname: string,\n\t\tcapability: string,\n\t): RepositoryContractTest => skippedContractTest(name, capability);\n\n\tconst tests: RepositoryContractTest[] = [\n\t\t{\n\t\t\tname: \"MANDATORY two-writer conflict: the stale writer throws ConcurrencyConflictError and persists nothing\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst seedEvents = await env.committedOutboxEvents();\n\t\t\t\t\tconst seedEventIds = new Set(seedEvents.map((e) => e.eventId));\n\n\t\t\t\t\t// Writer B loads first - its persistedVersion baseline is\n\t\t\t\t\t// now fixed at the pre-conflict version.\n\t\t\t\t\tconst staleB = await reload(env, seeded.id);\n\n\t\t\t\t\t// Writer A loads the same version, mutates, commits.\n\t\t\t\t\tconst committedA = await env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst a = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tharness.mutate(a);\n\t\t\t\t\t\tawait repository.save(a);\n\t\t\t\t\t\treturn a;\n\t\t\t\t\t});\n\t\t\t\t\tconst outboxAfterA = await env.committedOutboxEvents();\n\t\t\t\t\tassert(\n\t\t\t\t\t\toutboxAfterA.length > seedEvents.length,\n\t\t\t\t\t\t\"writer A's events must reach the outbox on commit\",\n\t\t\t\t\t);\n\t\t\t\t\t// Writer A's NEW events must carry A's ACTUAL committed\n\t\t\t\t\t// version - not merely some number. A wrong value here\n\t\t\t\t\t// (hardcoded, schema version, persistedVersion) would\n\t\t\t\t\t// poison every consumer's ordering/idempotency watermark.\n\t\t\t\t\tconst newSinceSeed = outboxAfterA.filter(\n\t\t\t\t\t\t(event) => !seedEventIds.has(event.eventId),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tnewSinceSeed.length > 0 &&\n\t\t\t\t\t\t\tnewSinceSeed.every(\n\t\t\t\t\t\t\t\t(event) => event.aggregateVersion === committedA.version,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t`writer A's committed outbox events must carry aggregateVersion === ${committedA.version} (A's commit version). ` +\n\t\t\t\t\t\t\t`Suspect #1: your outbox read-back (committedOutboxEvents) reconstructs events from an explicit column list ` +\n\t\t\t\t\t\t\t`and drops or string-types the aggregateVersion field. Suspect #2: a hand-rolled orchestration that does not ` +\n\t\t\t\t\t\t\t`stamp aggregateVersion = aggregate.version at harvest (withCommit does this automatically).`,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Writer B mutates its stale instance and tries to commit.\n\t\t\t\t\tharness.mutate(staleB);\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(staleB);\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\trejection !== undefined,\n\t\t\t\t\t\t\"the second writer's commit must reject - it committed on a stale version instead (OCC predicate missing?)\",\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"ConcurrencyConflictError\"),\n\t\t\t\t\t\t`the second writer's rejection must be (or wrap, via the cause chain) ConcurrencyConflictError; got: ${describeError(rejection)}`,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Final persisted state equals writer A's.\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tcommittedA.version,\n\t\t\t\t\t\t\"the persisted version must equal writer A's committed version\",\n\t\t\t\t\t);\n\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, final),\n\t\t\t\t\t\t\t\tsnapshotState.call(harness, committedA),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"the persisted STATE must equal writer A's. Two suspects: \" +\n\t\t\t\t\t\t\t\t\"(a) a predicate that guards only the version write lets the stale writer's state survive; \" +\n\t\t\t\t\t\t\t\t\"(b) your snapshotState projection is not roundtrip-stable (date precision, undefined-valued keys, decimal representation) - see its JSDoc\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Outbox contains exactly the events it contained after A's\n\t\t\t\t\t// commit - same records, not merely the same count.\n\t\t\t\t\tconst outboxFinal = await env.committedOutboxEvents();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdeepEqual(eventIds(outboxFinal), eventIds(outboxAfterA)),\n\t\t\t\t\t\t\"the outbox must contain exactly the winning writer's events (compared by eventId) - nothing from the stale writer, nothing replaced\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"insert routing: a never-persisted aggregate INSERTs even after pre-save mutations\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tassert(\n\t\t\t\t\t\taggregate.persistedVersion === undefined,\n\t\t\t\t\t\t\"harness contract: createAggregate() must return a never-persisted aggregate (persistedVersion === undefined)\",\n\t\t\t\t\t);\n\t\t\t\t\t// Mutate BEFORE the first save: version moves past zero in\n\t\t\t\t\t// memory while no row exists. Routing on version === 0\n\t\t\t\t\t// would attempt an UPDATE that affects zero rows.\n\t\t\t\t\tharness.mutate(aggregate);\n\t\t\t\t\tharness.mutate(aggregate);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst loaded = await reload(env, aggregate.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tloaded.version,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"the INSERT must persist the in-memory version (route on persistedVersion === undefined, not version === 0)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"update writes the in-memory version and predicates on persistedVersion\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tbaseline + 2,\n\t\t\t\t\t\t\"two mutations must persist as baseline + 2 (version is a mutation sequence)\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.persistedVersion,\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\"a reloaded aggregate's persistedVersion must equal its version\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"rollback persists nothing: state, version, and outbox untouched\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\tconst versionBefore = seeded.version;\n\t\t\t\t\tconst outboxBefore = (await env.committedOutboxEvents()).length;\n\t\t\t\t\tconst probe = new Error(\"contract rollback probe\");\n\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\tthrow probe;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\trejection !== undefined,\n\t\t\t\t\t\t\"a throwing unit of work must reject\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\tversionBefore,\n\t\t\t\t\t\t\"a rolled-back write must not change the persisted version\",\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t(await env.committedOutboxEvents()).length,\n\t\t\t\t\t\toutboxBefore,\n\t\t\t\t\t\t\"a rolled-back transaction must not leave events in the outbox\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"identity map: two getById calls in one unit of work return the same instance\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst first = await repository.getById(seeded.id);\n\t\t\t\t\t\tconst second = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tfirst !== null && first === second,\n\t\t\t\t\t\t\t\"repeated loads within one unit of work must return the SAME instance (identity map) - distinct instances double-harvest events\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"delete: getById returns null in the same unit of work and after the commit\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\tconst probe = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tprobe === null,\n\t\t\t\t\t\t\t\"after delete, getById in the SAME unit of work must return null (isDeleted check), even if the physical delete is deferred\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tconst probe = await repository.getById(seeded.id);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tprobe === null,\n\t\t\t\t\t\t\t\"after the deleting unit of work committed, the aggregate must be gone\",\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"deletion is final: saving the deleted aggregate in the same unit of work throws AggregateDeletedError\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\tharness.mutate(loaded);\n\t\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"AggregateDeletedError\"),\n\t\t\t\t\t\t`save-after-delete must reject with (or wrap) AggregateDeletedError; got: ${describeError(rejection)}. ` +\n\t\t\t\t\t\t\t`If you see ConcurrencyConflictError here instead, your save() probably enrolls AFTER the row write - enroll first.`,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"events are cleared after a committed unit of work and kept after a rollback\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\tconst committed = harness.createAggregate();\n\t\t\t\t\tharness.mutate(committed);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommitted.pendingEvents.length > 0,\n\t\t\t\t\t\t\"harness contract: mutate() must record at least one domain event\",\n\t\t\t\t\t);\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(committed);\n\t\t\t\t\t});\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\tcommitted.pendingEvents.length,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t\"pending events must be cleared after a successful commit\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst rolledBack = harness.createAggregate();\n\t\t\t\t\tharness.mutate(rolledBack);\n\t\t\t\t\tconst pendingBefore = rolledBack.pendingEvents.length;\n\t\t\t\t\tawait captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(rolledBack);\n\t\t\t\t\t\t\tthrow new Error(\"contract rollback probe\");\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\trolledBack.pendingEvents.length,\n\t\t\t\t\t\tpendingBefore,\n\t\t\t\t\t\t\"pending events must survive a rollback (so a fresh load + retry can re-emit them)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: \"persistedVersion syncs only after a successful commit\",\n\t\t\trun: () =>\n\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t// Re-saving the SAME instance after the rollback is the\n\t\t\t\t\t// documented carve-out from \"don't reuse aggregates after a\n\t\t\t\t\t// rollback\": a NEVER-persisted aggregate has no row and its\n\t\t\t\t\t// baseline is still undefined, so there is nothing to\n\t\t\t\t\t// reload - retrying its first save is the only path.\n\t\t\t\t\tconst aggregate = harness.createAggregate();\n\t\t\t\t\tharness.mutate(aggregate);\n\n\t\t\t\t\tawait captureRejection(\n\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t\t\tthrow new Error(\"contract rollback probe\");\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\taggregate.persistedVersion === undefined,\n\t\t\t\t\t\t\"a rolled-back first save must leave persistedVersion undefined (the aggregate is still unpersisted)\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\tawait repository.save(aggregate);\n\t\t\t\t\t});\n\t\t\t\t\tassertEqual(\n\t\t\t\t\t\taggregate.persistedVersion,\n\t\t\t\t\t\taggregate.version,\n\t\t\t\t\t\t\"after a successful commit, persistedVersion must equal version (markPersisted ran)\",\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t},\n\t];\n\n\t// Capability-gated tests: when the harness lacks the capability, the\n\t// entry is returned WITH `skipped` set and a loudly-rejecting run() -\n\t// the gap stays visible in every test report (it.skip) and a naive\n\t// binding fails instead of green-no-op'ing.\n\ttests.push(\n\t\tmutateVersionOnly\n\t\t\t? {\n\t\t\t\t\tname: \"version-only change still persists (skip-save must not desync the OCC baseline)\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\tmutateVersionOnly.call(harness, loaded);\n\t\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tbaseline + 1,\n\t\t\t\t\t\t\t\t\"a version-only change (empty changedKeys, bumped version) must still be persisted - skipping it desyncs persistedVersion and produces false ConcurrencyConflictErrors later\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"version-only change still persists (skip-save must not desync the OCC baseline)\",\n\t\t\t\t\t\"mutateVersionOnly\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tmutateChildCollection\n\t\t\t? {\n\t\t\t\t\tname: \"a child-collection-only change bumps the persisted root version\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\t\t\t\t\t\t\tconst baseline = seeded.version;\n\n\t\t\t\t\t\t\tawait env.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\tmutateChildCollection.call(harness, loaded);\n\t\t\t\t\t\t\t\tawait repository.save(loaded);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfinal.version > baseline,\n\t\t\t\t\t\t\t\t\"a child-collection-only change must advance the persisted ROOT version - otherwise concurrent writers interleave with collection writes undetected\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"a child-collection-only change bumps the persisted root version\",\n\t\t\t\t\t\"mutateChildCollection\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tcreateAggregateWithId\n\t\t\t? {\n\t\t\t\t\tname: \"deletion is final across instances: a re-created aggregate with the same id cannot be saved\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tconst loaded = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\t\tawait repository.delete(loaded);\n\t\t\t\t\t\t\t\t\tconst resurrected = createAggregateWithId.call(\n\t\t\t\t\t\t\t\t\t\tharness,\n\t\t\t\t\t\t\t\t\t\tseeded.id,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tharness.mutate(resurrected);\n\t\t\t\t\t\t\t\t\tawait repository.save(resurrected);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"AggregateDeletedError\"),\n\t\t\t\t\t\t\t\t`saving a re-created instance of a deleted aggregate must reject with (or wrap) AggregateDeletedError; got: ${describeError(rejection)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"deletion is final across instances: a re-created aggregate with the same id cannot be saved\",\n\t\t\t\t\t\"createAggregateWithId\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tcreateAggregateWithId && insertsAreDuplicateChecked\n\t\t\t? {\n\t\t\t\t\tname: \"duplicate insert: a second never-persisted aggregate with an existing id throws DuplicateAggregateError\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\t// A second NEVER-persisted instance with the same id:\n\t\t\t\t\t\t\t// two concurrent creators racing on a business-derived\n\t\t\t\t\t\t\t// id, or an id-generator collision. The INSERT must\n\t\t\t\t\t\t\t// surface as the kit's error class, not a raw driver\n\t\t\t\t\t\t\t// error. Mutated TWICE so its version differs from the\n\t\t\t\t\t\t\t// seeded row's - a clobbering insert is then visible\n\t\t\t\t\t\t\t// in the version check below even without a state\n\t\t\t\t\t\t\t// snapshot.\n\t\t\t\t\t\t\tconst duplicate = createAggregateWithId.call(\n\t\t\t\t\t\t\t\tharness,\n\t\t\t\t\t\t\t\tseeded.id,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tharness.mutate(duplicate);\n\t\t\t\t\t\t\tharness.mutate(duplicate);\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tawait repository.save(duplicate);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"DuplicateAggregateError\"),\n\t\t\t\t\t\t\t\t`inserting a second aggregate with an existing id must reject with (or wrap) DuplicateAggregateError - ` +\n\t\t\t\t\t\t\t\t\t`map your driver's unique-violation signal (Postgres 23505, MySQL 1062, SQLite SQLITE_CONSTRAINT_UNIQUE) ` +\n\t\t\t\t\t\t\t\t\t`instead of letting the raw driver error escape; got: ${describeError(rejection)}`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// The existing row is untouched by the rejected insert:\n\t\t\t\t\t\t\t// version AND (capability permitting) state.\n\t\t\t\t\t\t\tconst final = await reload(env, seeded.id);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tseeded.version,\n\t\t\t\t\t\t\t\t\"the existing row must be untouched by the rejected duplicate insert - a duplicate check that fires AFTER the write (or outside the transaction) clobbers the existing row\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (snapshotState) {\n\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\tdeepEqual(\n\t\t\t\t\t\t\t\t\t\tsnapshotState.call(harness, final),\n\t\t\t\t\t\t\t\t\t\tsnapshotState.call(harness, seeded),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\"the existing row's STATE must be untouched by the rejected duplicate insert\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"duplicate insert: a second never-persisted aggregate with an existing id throws DuplicateAggregateError\",\n\t\t\t\t\t// Name the capability that is actually missing: the\n\t\t\t\t\t// mechanical one (cannot build the duplicate) or the\n\t\t\t\t\t// semantic opt-out (deliberately upserting adapter).\n\t\t\t\t\tcreateAggregateWithId\n\t\t\t\t\t\t? \"insertsAreDuplicateChecked\"\n\t\t\t\t\t\t: \"createAggregateWithId\",\n\t\t\t\t),\n\t);\n\ttests.push(\n\t\tdeletesAreVersionChecked\n\t\t\t? {\n\t\t\t\t\tname: \"stale delete conflicts: deleting from a stale instance throws ConcurrencyConflictError\",\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\twithEnvironment(async (env) => {\n\t\t\t\t\t\t\tconst seeded = await seed(env);\n\n\t\t\t\t\t\t\t// Writer B loads, writer A commits an update, B deletes\n\t\t\t\t\t\t\t// from its stale baseline - the predicated DELETE must\n\t\t\t\t\t\t\t// affect zero rows and conflict, not destroy A's write.\n\t\t\t\t\t\t\tconst staleB = await reload(env, seeded.id);\n\t\t\t\t\t\t\tconst versionAfterA = await env.run(\n\t\t\t\t\t\t\t\tasync ({ repository }) => {\n\t\t\t\t\t\t\t\t\tconst a = await loadOrFail(repository, seeded.id);\n\t\t\t\t\t\t\t\t\tharness.mutate(a);\n\t\t\t\t\t\t\t\t\tawait repository.save(a);\n\t\t\t\t\t\t\t\t\treturn a.version;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst rejection = await captureRejection(\n\t\t\t\t\t\t\t\tenv.run(async ({ repository }) => {\n\t\t\t\t\t\t\t\t\tawait repository.delete(staleB);\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tchainContainsErrorNamed(rejection, \"ConcurrencyConflictError\"),\n\t\t\t\t\t\t\t\t`a stale delete must reject with (or wrap) ConcurrencyConflictError; got: ${describeError(rejection)} - an unpredicated DELETE silently destroys the concurrent writer's update`,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// A's write survived - load nullable on purpose: the\n\t\t\t\t\t\t\t// rejected delete must not have destroyed the row.\n\t\t\t\t\t\t\tconst final = await env.run(({ repository }) =>\n\t\t\t\t\t\t\t\trepository.getById(seeded.id),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfinal !== null,\n\t\t\t\t\t\t\t\t\"the row must still exist after the stale delete was rejected - the predicate must PREVENT the destructive delete, not merely report it\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tassertEqual(\n\t\t\t\t\t\t\t\tfinal.version,\n\t\t\t\t\t\t\t\tversionAfterA,\n\t\t\t\t\t\t\t\t\"the surviving row must carry writer A's version\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: skippedTest(\n\t\t\t\t\t\"stale delete conflicts: deleting from a stale instance throws ConcurrencyConflictError\",\n\t\t\t\t\t\"deletesAreVersionChecked\",\n\t\t\t\t),\n\t);\n\n\treturn tests;\n}\n\n// assert / assertEqual / chainContainsErrorNamed / describeError live in\n// ./contract-assertions, shared with the event-sourced contract suite.\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -51,7 +51,8 @@ interface DeepOmitOptions {
|
|
|
51
51
|
* apply. Types that `deepEqual` compares by reference (Error, ArrayBuffer,
|
|
52
52
|
* SharedArrayBuffer, Promise, WeakMap, WeakSet) are passed through by
|
|
53
53
|
* reference, so `deepEqualExcept(x, x)` stays reflexive. Cycles are
|
|
54
|
-
* preserved: a cycle `a → a` clones to `a' → a'`.
|
|
54
|
+
* preserved: a cycle `a → a` clones to `a' → a'`. Arrays retain sparse
|
|
55
|
+
* holes and all non-ignored own properties, including symbol keys.
|
|
55
56
|
*
|
|
56
57
|
* **Shared references.** Without `ignoreKeyPredicate`, an object reached
|
|
57
58
|
* via several paths dedupes to a single clone. With a predicate, each
|