@open-mercato/core 0.6.5-develop.4639.1.0416d895fa → 0.6.5-develop.4656.1.5b0d4fd8a6

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/AGENTS.md CHANGED
@@ -518,6 +518,7 @@ MikroORM's identity-map and subscriber infrastructure can silently discard pendi
518
518
  - Enable `{ transaction: true }` when atomicity matters (all-or-nothing semantics).
519
519
  - Keep `emitCrudSideEffects` / `emitCrudUndoSideEffects` calls **OUTSIDE** `withAtomicFlush`
520
520
  — side effects should only fire after the DB changes are committed.
521
+ - Cache invalidation follows the same rule as side effects: invalidate **after** the DB write commits, never inside the `withAtomicFlush` block. For the opt-in always-consistent read-projection tail (`OM_CACHE_SAFETY_ALWAYS_CONSISTENT`, default OFF) see `.ai/specs/2026-06-05-cache-safety-always-consistent.md`.
521
522
  - This applies to **both** `execute` methods (update commands) and `undo` handlers.
522
523
 
523
524
  ### Commit-boundary guarantee (defense in depth)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/core",
3
- "version": "0.6.5-develop.4639.1.0416d895fa",
3
+ "version": "0.6.5-develop.4656.1.5b0d4fd8a6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -245,16 +245,16 @@
245
245
  "zod": "^4.4.3"
246
246
  },
247
247
  "peerDependencies": {
248
- "@open-mercato/ai-assistant": "0.6.5-develop.4639.1.0416d895fa",
249
- "@open-mercato/shared": "0.6.5-develop.4639.1.0416d895fa",
250
- "@open-mercato/ui": "0.6.5-develop.4639.1.0416d895fa",
248
+ "@open-mercato/ai-assistant": "0.6.5-develop.4656.1.5b0d4fd8a6",
249
+ "@open-mercato/shared": "0.6.5-develop.4656.1.5b0d4fd8a6",
250
+ "@open-mercato/ui": "0.6.5-develop.4656.1.5b0d4fd8a6",
251
251
  "react": "^19.0.0",
252
252
  "react-dom": "^19.0.0"
253
253
  },
254
254
  "devDependencies": {
255
- "@open-mercato/ai-assistant": "0.6.5-develop.4639.1.0416d895fa",
256
- "@open-mercato/shared": "0.6.5-develop.4639.1.0416d895fa",
257
- "@open-mercato/ui": "0.6.5-develop.4639.1.0416d895fa",
255
+ "@open-mercato/ai-assistant": "0.6.5-develop.4656.1.5b0d4fd8a6",
256
+ "@open-mercato/shared": "0.6.5-develop.4656.1.5b0d4fd8a6",
257
+ "@open-mercato/ui": "0.6.5-develop.4656.1.5b0d4fd8a6",
258
258
  "@testing-library/dom": "^10.4.1",
259
259
  "@testing-library/jest-dom": "^6.9.1",
260
260
  "@testing-library/react": "^16.3.1",
@@ -88,6 +88,11 @@ Commands (`commands/people.ts`) demonstrate:
88
88
  4. Side effects with `emitCrudSideEffects` and `emitCrudUndoSideEffects`
89
89
  5. Include `indexer: { entityType, cacheAliases }` in both directions
90
90
 
91
+ ## Transaction Safety
92
+
93
+ - Multi-phase scalar + relation mutations (e.g. update commands that also sync tags) use `withAtomicFlush(em, phases, { transaction: true })` from `@open-mercato/shared/lib/commands/flush` — never interleave `em.find`/`em.findOne` between a scalar mutation and `em.flush()`.
94
+ - Side effects (`emitCrudSideEffects`) and cache invalidation fire **after** commit, outside the `withAtomicFlush` block. See `packages/core/AGENTS.md` → "Entity Update Safety — `withAtomicFlush`" and `.ai/specs/2026-06-05-cache-safety-always-consistent.md`.
95
+
91
96
  ## Custom Field Integration
92
97
 
93
98
  Use `collectCustomFieldValues()` from `@open-mercato/ui/backend/utils/customFieldValues`:
@@ -135,4 +135,4 @@ await withAtomicFlush(em, [
135
135
  await emitCrudSideEffects({ ... })
136
136
  ```
137
137
 
138
- Never run `em.find`/`em.findOne` between scalar mutations and `em.flush()` without `withAtomicFlush` — changes will be silently lost.
138
+ Never run `em.find`/`em.findOne` between scalar mutations and `em.flush()` without `withAtomicFlush` — changes will be silently lost. Cache invalidation must also stay outside `withAtomicFlush` and fire after commit, so the opt-in `OM_CACHE_SAFETY_ALWAYS_CONSISTENT` mode (default OFF) never serves stale or partially-committed reads.