@lenne.tech/nest-server 12.1.1 → 12.3.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.
Files changed (317) hide show
  1. package/.claude/rules/architecture.md +1 -0
  2. package/.claude/rules/better-auth.md +31 -4
  3. package/.claude/rules/configurable-features.md +8 -6
  4. package/.claude/rules/package-management.md +29 -2
  5. package/.claude/rules/persistence.md +27 -1
  6. package/.claude/rules/testing.md +80 -15
  7. package/.claude/rules/versioning.md +13 -2
  8. package/CLAUDE.md +7 -1
  9. package/FRAMEWORK-API.md +20 -4
  10. package/README.md +20 -2
  11. package/dist/config.env.js +2 -2
  12. package/dist/config.env.js.map +1 -1
  13. package/dist/core/common/helpers/graphql-ws-connection.helper.d.ts +4 -0
  14. package/dist/core/common/helpers/graphql-ws-connection.helper.js +17 -3
  15. package/dist/core/common/helpers/graphql-ws-connection.helper.js.map +1 -1
  16. package/dist/core/common/interfaces/server-options.interface.d.ts +49 -0
  17. package/dist/core/common/interfaces/service-options.interface.d.ts +3 -0
  18. package/dist/core/common/persistence/core-persistence.module.js +12 -2
  19. package/dist/core/common/persistence/core-persistence.module.js.map +1 -1
  20. package/dist/core/common/persistence/data-source.runtime.js +4 -2
  21. package/dist/core/common/persistence/data-source.runtime.js.map +1 -1
  22. package/dist/core/common/persistence/data-store.interface.d.ts +24 -9
  23. package/dist/core/common/persistence/id-format.d.ts +2 -0
  24. package/dist/core/common/persistence/id-format.js +14 -0
  25. package/dist/core/common/persistence/id-format.js.map +1 -1
  26. package/dist/core/common/persistence/model-descriptor.interface.d.ts +6 -0
  27. package/dist/core/common/persistence/model-metadata.registry.d.ts +2 -1
  28. package/dist/core/common/persistence/model-metadata.registry.js +20 -2
  29. package/dist/core/common/persistence/model-metadata.registry.js.map +1 -1
  30. package/dist/core/common/persistence/mongo/sync-schema.plugin.d.ts +18 -0
  31. package/dist/core/common/persistence/mongo/sync-schema.plugin.js +368 -0
  32. package/dist/core/common/persistence/mongo/sync-schema.plugin.js.map +1 -0
  33. package/dist/core/common/persistence/mongoose-data-store.d.ts +19 -9
  34. package/dist/core/common/persistence/mongoose-data-store.js +107 -31
  35. package/dist/core/common/persistence/mongoose-data-store.js.map +1 -1
  36. package/dist/core/common/persistence/persisted-model.decorator.d.ts +3 -0
  37. package/dist/core/common/persistence/persisted-model.decorator.js +9 -0
  38. package/dist/core/common/persistence/persisted-model.decorator.js.map +1 -1
  39. package/dist/core/common/persistence/policies/sync.policy.d.ts +17 -0
  40. package/dist/core/common/persistence/policies/sync.policy.js +77 -0
  41. package/dist/core/common/persistence/policies/sync.policy.js.map +1 -0
  42. package/dist/core/common/persistence/sql/mysql/mysql-data-store.d.ts +12 -8
  43. package/dist/core/common/persistence/sql/mysql/mysql-data-store.js +82 -29
  44. package/dist/core/common/persistence/sql/mysql/mysql-data-store.js.map +1 -1
  45. package/dist/core/common/persistence/sql/mysql/mysql-schema.compiler.d.ts +10 -0
  46. package/dist/core/common/persistence/sql/mysql/mysql-schema.compiler.js +61 -4
  47. package/dist/core/common/persistence/sql/mysql/mysql-schema.compiler.js.map +1 -1
  48. package/dist/core/common/persistence/sql/mysql/mysql-schema.migrator.js +101 -4
  49. package/dist/core/common/persistence/sql/mysql/mysql-schema.migrator.js.map +1 -1
  50. package/dist/core/common/persistence/sql/postgres/postgres-schema.compiler.d.ts +10 -0
  51. package/dist/core/common/persistence/sql/postgres/postgres-schema.compiler.js +41 -2
  52. package/dist/core/common/persistence/sql/postgres/postgres-schema.compiler.js.map +1 -1
  53. package/dist/core/common/persistence/sql/postgres/postgres-schema.migrator.js +98 -10
  54. package/dist/core/common/persistence/sql/postgres/postgres-schema.migrator.js.map +1 -1
  55. package/dist/core/common/persistence/sql/sql-data-store.d.ts +38 -14
  56. package/dist/core/common/persistence/sql/sql-data-store.js +212 -38
  57. package/dist/core/common/persistence/sql/sql-data-store.js.map +1 -1
  58. package/dist/core/common/persistence/sql/sql-errors.d.ts +2 -1
  59. package/dist/core/common/persistence/sql/sql-errors.js +3 -1
  60. package/dist/core/common/persistence/sql/sql-errors.js.map +1 -1
  61. package/dist/core/common/persistence/sync-access.registry.d.ts +17 -0
  62. package/dist/core/common/persistence/sync-access.registry.js +8 -0
  63. package/dist/core/common/persistence/sync-access.registry.js.map +1 -0
  64. package/dist/core/common/persistence/sync-model.d.ts +29 -0
  65. package/dist/core/common/persistence/sync-model.js +138 -0
  66. package/dist/core/common/persistence/sync-model.js.map +1 -0
  67. package/dist/core/common/services/crud.service.d.ts +13 -1
  68. package/dist/core/common/services/crud.service.js +174 -16
  69. package/dist/core/common/services/crud.service.js.map +1 -1
  70. package/dist/core/modules/ai/core-ai-mcp.controller.d.ts +3 -0
  71. package/dist/core/modules/ai/core-ai-mcp.controller.js +29 -0
  72. package/dist/core/modules/ai/core-ai-mcp.controller.js.map +1 -1
  73. package/dist/core/modules/ai/core-ai.constants.d.ts +2 -0
  74. package/dist/core/modules/ai/core-ai.constants.js +2 -0
  75. package/dist/core/modules/ai/core-ai.constants.js.map +1 -1
  76. package/dist/core/modules/ai/core-ai.controller.d.ts +6 -0
  77. package/dist/core/modules/ai/core-ai.controller.js +31 -1
  78. package/dist/core/modules/ai/core-ai.controller.js.map +1 -1
  79. package/dist/core/modules/ai/core-ai.module.d.ts +2 -0
  80. package/dist/core/modules/ai/core-ai.module.js +8 -1
  81. package/dist/core/modules/ai/core-ai.module.js.map +1 -1
  82. package/dist/core/modules/ai/core-ai.resolver.d.ts +6 -0
  83. package/dist/core/modules/ai/core-ai.resolver.js +32 -0
  84. package/dist/core/modules/ai/core-ai.resolver.js.map +1 -1
  85. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.d.ts +65 -1
  86. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.js +6 -3
  87. package/dist/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.js.map +1 -1
  88. package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js +48 -1
  89. package/dist/core/modules/ai/helpers/ai-mcp-oauth.helper.js.map +1 -1
  90. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.d.ts +9 -0
  91. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.js +54 -0
  92. package/dist/core/modules/ai/helpers/ai-tool-authorization.helper.js.map +1 -0
  93. package/dist/core/modules/ai/index.d.ts +7 -0
  94. package/dist/core/modules/ai/index.js +6 -0
  95. package/dist/core/modules/ai/index.js.map +1 -1
  96. package/dist/core/modules/ai/inputs/core-ai-settings.input.d.ts +3 -0
  97. package/dist/core/modules/ai/inputs/core-ai-settings.input.js +31 -0
  98. package/dist/core/modules/ai/inputs/core-ai-settings.input.js.map +1 -0
  99. package/dist/core/modules/ai/interfaces/ai-tool.interface.d.ts +2 -0
  100. package/dist/core/modules/ai/models/core-ai-settings.model.d.ts +4 -0
  101. package/dist/core/modules/ai/models/core-ai-settings.model.js +30 -0
  102. package/dist/core/modules/ai/models/core-ai-settings.model.js.map +1 -0
  103. package/dist/core/modules/ai/models/core-ai-user-setting.model.d.ts +8 -0
  104. package/dist/core/modules/ai/models/core-ai-user-setting.model.js +45 -0
  105. package/dist/core/modules/ai/models/core-ai-user-setting.model.js.map +1 -0
  106. package/dist/core/modules/ai/services/core-ai-conversation.service.d.ts +4 -1
  107. package/dist/core/modules/ai/services/core-ai-conversation.service.js +16 -4
  108. package/dist/core/modules/ai/services/core-ai-conversation.service.js.map +1 -1
  109. package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js +6 -6
  110. package/dist/core/modules/ai/services/core-ai-mcp-oauth.service.js.map +1 -1
  111. package/dist/core/modules/ai/services/core-ai-mcp.service.d.ts +27 -2
  112. package/dist/core/modules/ai/services/core-ai-mcp.service.js +118 -11
  113. package/dist/core/modules/ai/services/core-ai-mcp.service.js.map +1 -1
  114. package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js +9 -6
  115. package/dist/core/modules/ai/services/core-ai-prompt-builder.service.js.map +1 -1
  116. package/dist/core/modules/ai/services/core-ai-user-setting.service.d.ts +17 -0
  117. package/dist/core/modules/ai/services/core-ai-user-setting.service.js +72 -0
  118. package/dist/core/modules/ai/services/core-ai-user-setting.service.js.map +1 -0
  119. package/dist/core/modules/ai/services/core-ai.service.d.ts +8 -3
  120. package/dist/core/modules/ai/services/core-ai.service.js +68 -29
  121. package/dist/core/modules/ai/services/core-ai.service.js.map +1 -1
  122. package/dist/core/modules/better-auth/better-auth.config.js +3 -1
  123. package/dist/core/modules/better-auth/better-auth.config.js.map +1 -1
  124. package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js +2 -2
  125. package/dist/core/modules/better-auth/core-better-auth-email-verification.service.js.map +1 -1
  126. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.d.ts +8 -0
  127. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.js +64 -0
  128. package/dist/core/modules/better-auth/core-better-auth-path-guard.middleware.js.map +1 -0
  129. package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js +2 -1
  130. package/dist/core/modules/better-auth/core-better-auth-rate-limit.middleware.js.map +1 -1
  131. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.d.ts +1 -1
  132. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js +5 -3
  133. package/dist/core/modules/better-auth/core-better-auth-rate-limiter.service.js.map +1 -1
  134. package/dist/core/modules/better-auth/core-better-auth.module.js +2 -0
  135. package/dist/core/modules/better-auth/core-better-auth.module.js.map +1 -1
  136. package/dist/core/modules/better-auth/index.d.ts +1 -0
  137. package/dist/core/modules/better-auth/index.js +1 -0
  138. package/dist/core/modules/better-auth/index.js.map +1 -1
  139. package/dist/core/modules/error-code/error-codes.d.ts +72 -0
  140. package/dist/core/modules/error-code/error-codes.js +64 -0
  141. package/dist/core/modules/error-code/error-codes.js.map +1 -1
  142. package/dist/core/modules/migrate/sql-migration.helper.d.ts +15 -1
  143. package/dist/core/modules/migrate/sql-migration.helper.js +90 -5
  144. package/dist/core/modules/migrate/sql-migration.helper.js.map +1 -1
  145. package/dist/core/modules/sync/core-sync-base.controller.d.ts +7 -0
  146. package/dist/core/modules/sync/core-sync-base.controller.js +44 -0
  147. package/dist/core/modules/sync/core-sync-base.controller.js.map +1 -0
  148. package/dist/core/modules/sync/core-sync-cursor.d.ts +19 -0
  149. package/dist/core/modules/sync/core-sync-cursor.js +77 -0
  150. package/dist/core/modules/sync/core-sync-cursor.js.map +1 -0
  151. package/dist/core/modules/sync/core-sync-hints.controller.d.ts +4 -0
  152. package/dist/core/modules/sync/core-sync-hints.controller.js +55 -0
  153. package/dist/core/modules/sync/core-sync-hints.controller.js.map +1 -0
  154. package/dist/core/modules/sync/core-sync-hints.service.d.ts +28 -0
  155. package/dist/core/modules/sync/core-sync-hints.service.js +155 -0
  156. package/dist/core/modules/sync/core-sync-hints.service.js.map +1 -0
  157. package/dist/core/modules/sync/core-sync-infrastructure.models.d.ts +2 -0
  158. package/dist/core/modules/sync/core-sync-infrastructure.models.js +17 -0
  159. package/dist/core/modules/sync/core-sync-infrastructure.models.js.map +1 -0
  160. package/dist/core/modules/sync/core-sync-mutation.store.d.ts +43 -0
  161. package/dist/core/modules/sync/core-sync-mutation.store.js +88 -0
  162. package/dist/core/modules/sync/core-sync-mutation.store.js.map +1 -0
  163. package/dist/core/modules/sync/core-sync-state.store.d.ts +18 -0
  164. package/dist/core/modules/sync/core-sync-state.store.js +64 -0
  165. package/dist/core/modules/sync/core-sync-state.store.js.map +1 -0
  166. package/dist/core/modules/sync/core-sync.constants.d.ts +28 -0
  167. package/dist/core/modules/sync/core-sync.constants.js +23 -0
  168. package/dist/core/modules/sync/core-sync.constants.js.map +1 -0
  169. package/dist/core/modules/sync/core-sync.controller.d.ts +8 -0
  170. package/dist/core/modules/sync/core-sync.controller.js +79 -0
  171. package/dist/core/modules/sync/core-sync.controller.js.map +1 -0
  172. package/dist/core/modules/sync/core-sync.decorators.d.ts +12 -0
  173. package/dist/core/modules/sync/core-sync.decorators.js +28 -0
  174. package/dist/core/modules/sync/core-sync.decorators.js.map +1 -0
  175. package/dist/core/modules/sync/core-sync.module.d.ts +16 -0
  176. package/dist/core/modules/sync/core-sync.module.js +50 -0
  177. package/dist/core/modules/sync/core-sync.module.js.map +1 -0
  178. package/dist/core/modules/sync/core-sync.resolver.d.ts +9 -0
  179. package/dist/core/modules/sync/core-sync.resolver.js +46 -0
  180. package/dist/core/modules/sync/core-sync.resolver.js.map +1 -0
  181. package/dist/core/modules/sync/core-sync.service.d.ts +143 -0
  182. package/dist/core/modules/sync/core-sync.service.js +1237 -0
  183. package/dist/core/modules/sync/core-sync.service.js.map +1 -0
  184. package/dist/core/modules/sync/interfaces/core-sync.interfaces.d.ts +56 -0
  185. package/dist/core/modules/sync/interfaces/core-sync.interfaces.js +2 -0
  186. package/dist/core/modules/sync/interfaces/core-sync.interfaces.js.map +1 -0
  187. package/dist/core/modules/sync/models/core-sync-hint.model.d.ts +4 -0
  188. package/dist/core/modules/sync/models/core-sync-hint.model.js +30 -0
  189. package/dist/core/modules/sync/models/core-sync-hint.model.js.map +1 -0
  190. package/dist/core/modules/tenant/core-tenant.guard.js +14 -0
  191. package/dist/core/modules/tenant/core-tenant.guard.js.map +1 -1
  192. package/dist/core/modules/tenant/core-tenant.service.d.ts +21 -1
  193. package/dist/core/modules/tenant/core-tenant.service.js +153 -1
  194. package/dist/core/modules/tenant/core-tenant.service.js.map +1 -1
  195. package/dist/core.module.js +14 -0
  196. package/dist/core.module.js.map +1 -1
  197. package/dist/index.d.ts +16 -0
  198. package/dist/index.js +16 -0
  199. package/dist/index.js.map +1 -1
  200. package/dist/server/modules/error-code/error-codes.d.ts +8 -0
  201. package/dist/server/modules/sync-note/inputs/sync-note-create.input.d.ts +4 -0
  202. package/dist/server/modules/sync-note/inputs/sync-note-create.input.js +27 -0
  203. package/dist/server/modules/sync-note/inputs/sync-note-create.input.js.map +1 -0
  204. package/dist/server/modules/sync-note/inputs/sync-note.input.d.ts +6 -0
  205. package/dist/server/modules/sync-note/inputs/sync-note.input.js +37 -0
  206. package/dist/server/modules/sync-note/inputs/sync-note.input.js.map +1 -0
  207. package/dist/server/modules/sync-note/sync-note.model.d.ts +10 -0
  208. package/dist/server/modules/sync-note/sync-note.model.js +73 -0
  209. package/dist/server/modules/sync-note/sync-note.model.js.map +1 -0
  210. package/dist/server/modules/sync-note/sync-note.module.d.ts +2 -0
  211. package/dist/server/modules/sync-note/sync-note.module.js +21 -0
  212. package/dist/server/modules/sync-note/sync-note.module.js.map +1 -0
  213. package/dist/server/modules/sync-note/sync-note.service.d.ts +10 -0
  214. package/dist/server/modules/sync-note/sync-note.service.js +35 -0
  215. package/dist/server/modules/sync-note/sync-note.service.js.map +1 -0
  216. package/dist/test/test.helper.d.ts +1 -0
  217. package/dist/test/test.helper.js +9 -2
  218. package/dist/test/test.helper.js.map +1 -1
  219. package/docs/REQUEST-LIFECYCLE.md +4 -2
  220. package/docs/error-codes.md +14 -0
  221. package/docs/offline-sync-protocol.md +111 -68
  222. package/docs/security-overrides.md +14 -0
  223. package/migration-guides/12.0.x-to-12.1.x.md +0 -1
  224. package/migration-guides/12.1.x-to-12.2.x.md +154 -0
  225. package/migration-guides/12.2.x-to-12.3.x.md +440 -0
  226. package/package.json +23 -21
  227. package/src/config.env.ts +6 -2
  228. package/src/core/common/helpers/graphql-ws-connection.helper.ts +32 -4
  229. package/src/core/common/interfaces/server-options.interface.ts +229 -8
  230. package/src/core/common/interfaces/service-options.interface.ts +15 -0
  231. package/src/core/common/persistence/core-persistence.module.ts +21 -2
  232. package/src/core/common/persistence/data-source.runtime.ts +5 -2
  233. package/src/core/common/persistence/data-store.interface.ts +65 -12
  234. package/src/core/common/persistence/id-format.ts +26 -0
  235. package/src/core/common/persistence/model-descriptor.interface.ts +12 -0
  236. package/src/core/common/persistence/model-metadata.registry.ts +31 -2
  237. package/src/core/common/persistence/mongo/sync-schema.plugin.ts +508 -0
  238. package/src/core/common/persistence/mongoose-data-store.ts +171 -35
  239. package/src/core/common/persistence/persisted-model.decorator.ts +26 -0
  240. package/src/core/common/persistence/policies/sync.policy.ts +121 -0
  241. package/src/core/common/persistence/sql/mysql/mysql-data-store.ts +108 -30
  242. package/src/core/common/persistence/sql/mysql/mysql-schema.compiler.ts +107 -4
  243. package/src/core/common/persistence/sql/mysql/mysql-schema.migrator.ts +129 -3
  244. package/src/core/common/persistence/sql/postgres/postgres-schema.compiler.ts +74 -2
  245. package/src/core/common/persistence/sql/postgres/postgres-schema.migrator.ts +139 -7
  246. package/src/core/common/persistence/sql/sql-data-store.ts +325 -44
  247. package/src/core/common/persistence/sql/sql-errors.ts +5 -1
  248. package/src/core/common/persistence/sync-access.registry.ts +50 -0
  249. package/src/core/common/persistence/sync-model.ts +270 -0
  250. package/src/core/common/services/crud.service.ts +257 -19
  251. package/src/core/modules/ai/INTEGRATION-CHECKLIST.md +36 -15
  252. package/src/core/modules/ai/README.md +163 -25
  253. package/src/core/modules/ai/core-ai-mcp.controller.ts +48 -1
  254. package/src/core/modules/ai/core-ai.constants.ts +6 -0
  255. package/src/core/modules/ai/core-ai.controller.ts +36 -1
  256. package/src/core/modules/ai/core-ai.module.ts +12 -0
  257. package/src/core/modules/ai/core-ai.resolver.ts +36 -0
  258. package/src/core/modules/ai/helpers/ai-mcp-oauth-consent.helper.ts +35 -4
  259. package/src/core/modules/ai/helpers/ai-mcp-oauth.helper.ts +68 -1
  260. package/src/core/modules/ai/helpers/ai-tool-authorization.helper.ts +99 -0
  261. package/src/core/modules/ai/index.ts +18 -0
  262. package/src/core/modules/ai/inputs/core-ai-settings.input.ts +24 -0
  263. package/src/core/modules/ai/interfaces/ai-hook.interface.ts +1 -1
  264. package/src/core/modules/ai/interfaces/ai-tool.interface.ts +38 -26
  265. package/src/core/modules/ai/models/core-ai-mode.model.ts +1 -1
  266. package/src/core/modules/ai/models/core-ai-settings.model.ts +23 -0
  267. package/src/core/modules/ai/models/core-ai-tool-policy.model.ts +1 -1
  268. package/src/core/modules/ai/models/core-ai-user-setting.model.ts +46 -0
  269. package/src/core/modules/ai/services/core-ai-conversation.service.ts +31 -6
  270. package/src/core/modules/ai/services/core-ai-mcp-oauth.service.ts +12 -9
  271. package/src/core/modules/ai/services/core-ai-mcp.service.ts +206 -13
  272. package/src/core/modules/ai/services/core-ai-prompt-builder.service.ts +13 -6
  273. package/src/core/modules/ai/services/core-ai-user-setting.service.ts +85 -0
  274. package/src/core/modules/ai/services/core-ai.service.ts +134 -35
  275. package/src/core/modules/api-token/README.md +4 -2
  276. package/src/core/modules/better-auth/CUSTOMIZATION.md +1 -1
  277. package/src/core/modules/better-auth/INTEGRATION-CHECKLIST.md +7 -0
  278. package/src/core/modules/better-auth/README.md +32 -1
  279. package/src/core/modules/better-auth/better-auth.config.ts +12 -1
  280. package/src/core/modules/better-auth/core-better-auth-email-verification.service.ts +5 -2
  281. package/src/core/modules/better-auth/core-better-auth-path-guard.middleware.ts +85 -0
  282. package/src/core/modules/better-auth/core-better-auth-rate-limit.middleware.ts +5 -2
  283. package/src/core/modules/better-auth/core-better-auth-rate-limiter.service.ts +14 -7
  284. package/src/core/modules/better-auth/core-better-auth.module.ts +12 -2
  285. package/src/core/modules/better-auth/index.ts +1 -0
  286. package/src/core/modules/error-code/error-codes.ts +77 -0
  287. package/src/core/modules/migrate/sql-migration.helper.ts +141 -7
  288. package/src/core/modules/sync/INTEGRATION-CHECKLIST.md +95 -0
  289. package/src/core/modules/sync/README.md +198 -0
  290. package/src/core/modules/sync/SECURITY.md +65 -0
  291. package/src/core/modules/sync/core-sync-base.controller.ts +43 -0
  292. package/src/core/modules/sync/core-sync-cursor.ts +117 -0
  293. package/src/core/modules/sync/core-sync-hints.controller.ts +52 -0
  294. package/src/core/modules/sync/core-sync-hints.service.ts +178 -0
  295. package/src/core/modules/sync/core-sync-infrastructure.models.ts +40 -0
  296. package/src/core/modules/sync/core-sync-mutation.store.ts +146 -0
  297. package/src/core/modules/sync/core-sync-state.store.ts +89 -0
  298. package/src/core/modules/sync/core-sync.constants.ts +51 -0
  299. package/src/core/modules/sync/core-sync.controller.ts +68 -0
  300. package/src/core/modules/sync/core-sync.decorators.ts +84 -0
  301. package/src/core/modules/sync/core-sync.module.ts +75 -0
  302. package/src/core/modules/sync/core-sync.resolver.ts +35 -0
  303. package/src/core/modules/sync/core-sync.service.ts +1773 -0
  304. package/src/core/modules/sync/interfaces/core-sync.interfaces.ts +85 -0
  305. package/src/core/modules/sync/models/core-sync-hint.model.ts +18 -0
  306. package/src/core/modules/tenant/INTEGRATION-CHECKLIST.md +12 -1
  307. package/src/core/modules/tenant/README.md +49 -3
  308. package/src/core/modules/tenant/core-tenant.guard.ts +26 -2
  309. package/src/core/modules/tenant/core-tenant.service.ts +287 -2
  310. package/src/core.module.ts +25 -0
  311. package/src/index.ts +21 -0
  312. package/src/server/modules/sync-note/inputs/sync-note-create.input.ts +14 -0
  313. package/src/server/modules/sync-note/inputs/sync-note.input.ts +23 -0
  314. package/src/server/modules/sync-note/sync-note.model.ts +77 -0
  315. package/src/server/modules/sync-note/sync-note.module.ts +16 -0
  316. package/src/server/modules/sync-note/sync-note.service.ts +25 -0
  317. package/src/test/test.helper.ts +17 -3
@@ -4,6 +4,7 @@ import supertest from 'supertest';
4
4
  import * as util from 'util';
5
5
  import ws from 'ws';
6
6
  import { getStringIds } from '../core/common/helpers/db.helper.js';
7
+ import { ConfigService } from '../core/common/services/config.service.js';
7
8
  import { resolveBetterAuthSessionCookieName } from '../core/modules/better-auth/better-auth-cookie-prefix.helper.js';
8
9
  import { isObjectIdLike } from '../core/common/helpers/id.helper.js';
9
10
  export var TestGraphQLType;
@@ -234,8 +235,11 @@ export class TestHelper {
234
235
  },
235
236
  }, base);
236
237
  expect(init.message?.error).toBeUndefined();
237
- expect(init.sessionId).toBeTruthy();
238
- const sessionId = init.sessionId;
238
+ const stateless = options.stateless ?? ConfigService.get('ai.mcp')?.stateless === true;
239
+ if (!stateless) {
240
+ expect(init.sessionId).toBeTruthy();
241
+ }
242
+ const sessionId = stateless ? '' : (init.sessionId ?? '');
239
243
  await this.mcp({ method: 'notifications/initialized' }, { ...base, sessionId });
240
244
  let nextId = 2;
241
245
  const request = async (method, params, requestOptions = {}) => {
@@ -250,6 +254,9 @@ export class TestHelper {
250
254
  return { ...result, json: TestHelper.parseJsonOrUndefined(result.content?.[0]?.text) };
251
255
  },
252
256
  close: async () => {
257
+ if (!sessionId) {
258
+ return;
259
+ }
253
260
  await this.rest(path, {
254
261
  cookies: base.cookies,
255
262
  headers: { ...base.headers, 'mcp-session-id': sessionId },
@@ -1 +1 @@
1
- {"version":3,"file":"test.helper.js","sourceRoot":"","sources":["../../src/test/test.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,kCAAkC,EAAE,MAAM,iEAAiE,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAKrE,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,kCAAe,CAAA;IACf,gDAA6B,CAAA;AAC/B,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AA6UD,MAAM,OAAO,UAAU;IAErB,GAAG,CAAmB;IAItB,eAAe,CAAS;IAKxB,YAAY,GAAQ,EAAE,eAAwB;QAC5C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IASD,QAAQ,CAAC,GAAW,EAAE,cAA6C;QACjE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,SA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,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACvD,CAAC;IAKD,MAAM,CAAC,oBAAoB,CAAC,IAAwB;QAClD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAMD,QAAQ,CAAC,KAAK;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF"}
@@ -64,6 +64,7 @@ Modern OAuth-compatible authentication with plugin architecture:
64
64
  | **Social Login** | OAuth providers: Google, GitHub, Apple, Discord, etc. (plugin) |
65
65
  | **Email Verification** | Configurable email verification flow |
66
66
  | **Sign-Up Validation** | Custom validation hooks for registration |
67
+ | **Path Guard** | `CoreBetterAuthPathGuardMiddleware`, the first middleware under the Better-Auth base path (always registered): a path with a `.` / `..` segment (also `%2e`-encoded), a backslash, an encoded `/` / `\` or a `#` is refused with 400 (`#LTNS_0305`) before the rate limiter, the controller routes or the forwarding read it. Every check there reads the path as sent while Better-Auth routes the resolved one, so without the guard `/iam/callback/../sign-in/email` was skipped by the limiter as a callback and ran as a sign-in (12.3.0) |
67
68
  | **Rate Limiting** | Per-endpoint rate limits (`betterAuth.rateLimit`, configurable). Counters live behind a `RateLimitStore`: `RedisRateLimitStore` when `redis` is configured, so `max` is enforced **exactly across replicas** instead of `max × replicas`; otherwise the process-local `InMemoryRateLimitStore` as before. `check()` / `reset()` / `clear()` are **async** since 11.33.0. On a Redis outage it degrades to the in-memory counter and logs once per transition — never a 500, never "allowed". Counters are keyed on `request.ip`, which Express derives from `X-Forwarded-For` only as far as `trust proxy` allows — set `trustProxy` (§ServerOptions) behind a reverse proxy or every client resolves to the proxy and shares ONE bucket; unset with a limiter enabled logs a boot warning |
68
69
  | **Cross-Subdomain Cookies** | Automatic cookie domain configuration |
69
70
  | **Organization / Multi-Tenant** | Teams and organization management (plugin) |
@@ -131,6 +132,7 @@ JWT-based authentication for existing projects:
131
132
  | **Bulk Operations** | Batch create/update/delete |
132
133
  | **Force Mode** | `force: true` bypasses all security checks |
133
134
  | **Raw Mode** | `raw: true` skips prepareInput/prepareOutput |
135
+ | **Synchronized models** | `@PersistedModel({ sync })` (offline sync, 12.x): the store writes `version`, `deletedAt` and the change position on every write path (on MongoDB through `mongo/sync-schema.plugin.ts`, applied to these schemas only); `CrudService.delete()` and every port delete leave a tombstone, reads leave tombstones out unless `includeTombstones`, and `ServiceOptions.expectedVersion` makes `update()` / `delete()` one conditional statement (409 `VersionConflictError` on another version). Unique indexes apply to live records only. With the `sync` configuration (12.2.0) the sync module serves `GET/POST /sync/{model}` for models whose CrudService carries `@SyncService()`: `@Roles(S_USER)` on the route, the model's `sync.roles` passed as `serviceOptions.roles` on every CrudService call, every pulled record through `securityCheck()`, a header-less request scoped to the caller's memberships, the 410 resync body written by the controller itself (`src/core/modules/sync/README.md`). Change hints (`GET /sync/hints`, SSE, and the GraphQL subscription `syncHint`) carry `{ model, at }` only, sent from the CrudService's create / update / delete of such a model and delivered to a subscriber only with the model's pull roles and access to the tenant of the change; the SSE stream registers with the WebSocket re-check registry and ends on every invalidation or re-check, so the client reconnects with its current rights. An hourly purge removes tombstones past `sync.retention.tombstonesDays` after moving the retention horizon past them. What a client must delete on logout is in the module's `SECURITY.md`. See `.claude/rules/persistence.md` → "Synchronized models" |
134
136
 
135
137
  ### Models & Inputs
136
138
 
@@ -180,8 +182,8 @@ JWT-based authentication for existing projects:
180
182
  | **AI Module** | Prompt orchestrator (auto + plan mode), DB-backed LLM connections, tool registry |
181
183
  | **REST Endpoints** | `POST /ai/prompt`, `POST /ai/stream` (SSE); `GET/POST/PUT/DELETE /ai/connections*`, `/ai/connections/available`, `/ai/connections/select`, `/ai/connections/preferences*`, `/ai/conversations*`, `/ai/interactions*`, `/ai/budget-limits*`, `GET /ai/usage` |
182
184
  | **GraphQL Endpoints** | `aiPrompt`, `aiAvailableConnections`, `aiSetUserConnection`, connection/preference/conversation/interaction/budget queries + mutations, `aiUsage` |
183
- | **MCP Server** | Streamable HTTP at `POST/GET/DELETE /ai/mcp` (Bearer auth); a user the controller resolves itself (the OAuth access token, which only this controller accepts, after the guards ran without a user) gets `req.user` and the tenant the header names from an active membership only, through `CoreTenantGuard.resolveMembershipContext()` (11.43.3); with `ai.mcp.oauth` an OAuth 2.1 router (`/.well-known/*`, `/authorize`, `/token`, `/register`) that `CoreAiMcpOAuthInitializer` mounts during `app.init()` — an Express router behind the Nest middleware and routes, ahead of Nest's not-found handler, so guards and interceptors do not run for it; `/authorize` answers with a built-in consent page (the Better-Auth session from the middleware is the user; Allow is a CSRF-bound POST) |
184
- | **Permission Model** | `S_USER` for prompt/conversations/available/usage; `ADMIN` for connections/preferences/interactions/budgets; encrypted API keys never leave the server (`securityCheck` + `secretFields`) |
185
+ | **MCP Server** | Streamable HTTP at `POST/GET/DELETE /ai/mcp` (Bearer auth; with `ai.mcp.stateless` (12.3.0+) a server and transport per POST, no session, GET / DELETE 405, so any replica answers; `tools/call` runs the admin's tool policies, `authorize()` and the elicitation confirmation (12.3.0+) — refused for tools needing confirmation in stateless mode); a user the controller resolves itself (the OAuth access token, which only this controller accepts, after the guards ran without a user) gets `req.user` and the tenant the header names from an active membership only, through `CoreTenantGuard.resolveMembershipContext()` (11.43.3); with `ai.mcp.oauth` an OAuth 2.1 router (`/.well-known/*`, `/authorize`, `/token`, `/register`) that `CoreAiMcpOAuthInitializer` mounts during `app.init()` — an Express router behind the Nest middleware and routes, ahead of Nest's not-found handler, so guards and interceptors do not run for it; `/authorize` answers with a built-in consent page (the Better-Auth session from the middleware is the user; Allow is a CSRF-bound POST) |
186
+ | **Permission Model** | `S_USER` for prompt/conversations/available/usage; `ADMIN` for connections/preferences/interactions/budgets; encrypted API keys never leave the server (`securityCheck` + `secretFields`); a prompt continues only the caller's own conversation — a foreign or unknown `conversationId` counts as none, admins included (`CoreAiService.scopeConversation()`, 12.3.0) |
185
187
 
186
188
  ### Email & Templates
187
189
 
@@ -346,6 +346,20 @@ All error codes follow the format: `#PREFIX_XXXX: Description`
346
346
  - DE: Die gesendeten Daten sind zu groß und wurden nicht verarbeitet.
347
347
  - EN: The submitted data is too large and was not processed.
348
348
 
349
+ ### LTNS_0305: invalidRequestPath
350
+
351
+ **Message:** Invalid request path
352
+
353
+ **Description:** Answered with HTTP 400 when a request under the Better-Auth base path (`/iam` by default) carries a path segment `.` or `..` (also percent-encoded as `%2e`), a backslash, an encoded `/` or `\` (`%2f`, `%5c`), or a `#`. No route there uses such a path, and the checks in front of Better-Auth would read it as a different route than Better-Auth itself.
354
+
355
+ **Solution:** Send the path in its canonical form. Browsers and HTTP clients do that on their own; the error points at a client that builds paths by hand or sends them unnormalized on purpose.
356
+
357
+ **Parameters:** none
358
+
359
+ **Translations:**
360
+ - DE: Der Anfragepfad ist ungültig.
361
+ - EN: The request path is invalid.
362
+
349
363
  ---
350
364
 
351
365
  ## Resource Errors (LTNS_0400-LTNS_0499)
@@ -1,9 +1,12 @@
1
1
  # Offline sync protocol
2
2
 
3
- > **Status: specification, not implemented yet.** Phase 1 of the offline-sync epic (DEV-3819, this phase DEV-3898).
4
- > Nothing described here exists in the package before the sync module ships (phase 4). The implementation plan, the
5
- > port extensions and the reasoning live in the framework repository under `.claude/plans/offline-sync/PLAN.md`.
6
- > Points the cursor prototype (phase 2) still decides are marked **OPEN** and listed in §15, next to the owner's decisions.
3
+ > **Status: implemented** by the sync module (`src/core/modules/sync/`, 12.2.0): pull, push, conflicts, client ids and
4
+ > resync (DEV-3901), hints (§9) and the tombstone purge (DEV-3902), proven end to end by a PWA and a Node test client
5
+ > and by two server instances with skewed clocks (DEV-3903). Specified in
6
+ > phase 1 of the offline-sync epic (DEV-3819, DEV-3898), the open points decided by the cursor prototype of phase 2
7
+ > (DEV-3899). The implementation plan, the port extensions, the reasoning and the measurements live in the epic's
8
+ > design plan, which the team keeps outside this public repository; references to §15 below point into its list of
9
+ > decisions.
7
10
 
8
11
  Clients read and write while disconnected and reconcile with the server when they are back: they pull what changed
9
12
  since their cursor, push what they changed locally, and receive tombstones for deletions. The protocol is HTTP with
@@ -37,58 +40,69 @@ supports (MongoDB, PostgreSQL with any engine, MySQL / MariaDB) with the same ob
37
40
  | `version` | An integer the server increments on every change of the record, starting at 1. Never set by a client. |
38
41
  | `updatedAt` | The server's time of the last change. Informational; ordering never relies on it. |
39
42
  | `deletedAt` | `null` for a live record, the deletion time for a tombstone. |
40
- | Tombstone | What remains of a deleted record: `id`, `version`, `deletedAt`, `updatedAt`, on a tenant-scoped model `tenantId`, and the user-id fields the model declares as its scope (e.g. `ownerId`). No content field. |
43
+ | Tombstone | What remains of a deleted record: `id`, `version`, `deletedAt`, `updatedAt`, on a tenant-scoped model `tenantId`, and the user-id fields the model declares as its scope (e.g. `ownerId`). The server also keeps its audit fields (`createdAt`, `createdBy`, `updatedBy` — who deleted it); a pull sends none of them. No content field. |
41
44
  | Cursor | Opaque string the server returns with every pull page; the client sends it back to continue. |
42
45
  | Retention horizon | How long tombstones are kept. A cursor older than the horizon cannot be continued (§8). |
43
46
  | Mutation id | A unique id the client gives every pushed change, so a repeated push is recognised (§6.5). |
44
47
 
45
48
  ## 3. Identifiers
46
49
 
47
- **Clients create the ids of records they create offline.** Two formats are accepted for sync models:
50
+ **Clients create the ids of records they create offline**, in the one format the model declares:
48
51
 
49
- | Format | Shape | Generated by |
50
- |---|---|---|
51
- | ObjectId-hex | 24 lowercase hex characters (`^[0-9a-f]{24}$`) | the server's own format; any ObjectId generator |
52
- | uuidv7 | 36 characters, `xxxxxxxx-xxxx-7xxx-[89ab]xxx-xxxxxxxxxxxx`, lowercase | `crypto.randomUUID()` is v4 — use a uuidv7 generator |
53
-
54
- * The server validates the format of every id it receives and refuses anything else (`INVALID_ID`, §7). It never
55
- rewrites a client id.
56
- * Records the server creates itself (a create through the normal API) keep the server's format, ObjectId-hex. Server
57
- ids are predictable from an observed one, so a client could occupy the next ones; on a sync model the server
52
+ | Format | Shape | Used by | Generated by |
53
+ |---|---|---|---|
54
+ | ObjectId-hex | 24 lowercase hex characters (`^[0-9a-f]{24}$`) | every model unless declared otherwise — existing models and projects change nothing | the client, as in MongoDB's own model where the driver creates the id — but with a random tail: 4 timestamp bytes plus 8 bytes from a secure random source, fresh for every id (see below); not a driver's default `new ObjectId()` |
55
+ | uuidv7 | 36 characters, `xxxxxxxx-xxxx-7xxx-[89ab]xxx-xxxxxxxxxxxx`, lowercase | a model declared with it — a choice for **new** models only | a uuidv7 generator (`crypto.randomUUID()` is v4) |
56
+
57
+ * **One format per model, never mixed** in a collection or table (decided 2026-10-29). An existing model does not
58
+ switch: that would mix both formats in its data.
59
+ * The server validates every id it receives against the model's format and refuses anything else (`INVALID_ID`, §7).
60
+ It never rewrites a client id.
61
+ * Records the server creates itself (a create through the normal API) get the model's format. Server-generated
62
+ ObjectIds are predictable from an observed one, so a client could occupy the next ones; on a sync model the server
58
63
  therefore generates a fresh id and retries when its own id is taken, and a normal create never fails on that.
59
- * Ids of models that are not syncable keep today's rule: ObjectId-hex only. Declaring a model syncable widens the
60
- accepted formats for that model alone.
61
- * **Prefer uuidv7.** It carries 74 random bits, so ids of other clients cannot be guessed. An ObjectId carries a
62
- timestamp, a per-process value and a counter; ids generated close to a known one are predictable.
64
+ * Ids of models that are not syncable keep today's rule: ObjectId-hex only.
65
+ * **A client's next ids must not be predictable.** A uuidv7 carries 74 random bits by construction. A driver's default
66
+ ObjectId does not: its per-process value and counter make every next id of a client predictable from one it has
67
+ created, so a member of the same tenant who sees one could create those ids first, and the client's own create
68
+ would then meet a record that is not its own. That is why a client fills the 8 bytes after an ObjectId's timestamp
69
+ from a secure random source (`crypto.getRandomValues`) for every id — still a valid ObjectId, as unguessable as a
70
+ uuidv7. The server cannot tell how an id was generated, so this rule is the client's. Beyond it, every access is
71
+ checked against the caller's rights, an id taken by a record the caller may not see answers `ID_UNAVAILABLE`, and
72
+ the push rate limit bounds probing. ObjectId stays the default; uuidv7 is a model's choice for new models.
63
73
  * Records created offline may reference each other by these ids before any of them reached the server. Push them in
64
74
  dependency order (§6.3) or accept that a reference may point to a record the server has not received yet — the server
65
75
  checks a reference against the caller's rights only where the model declares that check.
66
76
 
67
- How each database stores both formats: the id column is already a string column wide enough for both on PostgreSQL
77
+ How each database stores the formats: the id column is already a string column wide enough for both on PostgreSQL
68
78
  (`text`) and MySQL / MariaDB (`varchar(255)`). On MongoDB an ObjectId-hex id is stored as an ObjectId and a uuidv7 id
69
- as a string `_id`; the format alone decides the representation, so every lookup by id is deterministic. References to
70
- a sync model use the same mapping. **OPEN (phase 2):** Mongoose casting, populate and sort on a collection holding both
71
- representations are verified by the prototype before phase 3 builds on them.
79
+ as a BSON UUID (binary subtype 4, MongoDB's recommended UUID representation); the core keeps ids as strings, the store
80
+ converts at its boundary. References to a model use that model's representation. Because a collection holds one
81
+ format, casting, populate and sort never meet two representations side by side.
72
82
 
73
- **A create whose id is already taken** by a record or tombstone the caller may see is answered `conflict` with that record as the
74
- caller may see it (§6.5) — without comparing the stored values with `data`: an answer that depended on the comparison
83
+ **A create whose id is already taken** by a record or tombstone the caller may see — inside their tenant scope, with the
84
+ model's pull roles, not hidden by `securityCheck` — is answered `conflict` with that record as the caller may see it (§6.5) — without comparing the stored values with `data`: an answer that depended on the comparison
75
85
  would let the caller test guesses for fields hidden from them. Taken by a record or tombstone the caller may **not**
76
86
  see, the item is refused with `ID_UNAVAILABLE` — the same answer,
77
87
  same timing, for every reason an id cannot be used; it carries no tenant, owner, content or deletion state. That an id
78
88
  is occupied stays observable — decided (O2, §15): ids stay unique across tenants, the push rate limit bounds probing,
79
- and a uuidv7 id of someone else cannot be guessed in the first place.
89
+ and an id generated as above (uuidv7, or ObjectId-hex with its random tail) cannot be guessed in the first place.
80
90
 
81
91
  ## 4. Requests and authentication
82
92
 
83
93
  * **Base path** `/sync` (configurable). Model names in paths are the names the project registered for sync.
94
+ * **Tenant:** with `X-Tenant-Id` a request covers that one tenant (and requires an active membership in it); without the
95
+ header it spans every tenant the caller is an active member of.
84
96
  * **Authentication:** a Better-Auth session cookie or a bearer token (JWT or session token), exactly as for every other
85
97
  route. API tokens are refused on sync routes unless the project releases a sync scope for them.
86
98
  * **Writes with cookie authentication** follow the rules of every writing endpoint — the session cookie is
87
99
  `SameSite=lax`, credentialed CORS is answered for the trusted origins (for any origin under `cors.allowAll`, a
88
100
  development setting) — and push additionally requires
89
- `Content-Type: application/json` (which forces a CORS preflight) and refuses a request whose `Origin` is not a
90
- trusted origin or whose `Sec-Fetch-Site` is `cross-site`. A bearer-authenticated request carries no ambient
91
- credential and is not subject to these checks.
101
+ `Content-Type: application/json` (which forces a CORS preflight; required of every push, `400` otherwise) and,
102
+ while the server uses cookies, refuses a request whose `Origin` is not a trusted origin or whose `Sec-Fetch-Site` is
103
+ `cross-site` (`403`). The trusted origins are those credentialed CORS answers plus the app's and the API's own. A
104
+ client without fetch metadata (a native app, a server) sends neither header and is not affected; a browser app
105
+ using a bearer token runs on a trusted origin anyway, or CORS would refuse it first.
92
106
  * **Session expired while offline:** push answers `401` for the whole request before it looks at any item. Nothing is
93
107
  applied and nothing is discarded; after signing in again the client sends the same items with the same mutation ids
94
108
  and gets no duplicates (§6.5).
@@ -114,7 +128,7 @@ GET /sync/{model}?cursor={cursor}&limit={n}
114
128
  ```json
115
129
  {
116
130
  "items": [
117
- { "id": "0190f8a2-…", "version": 3, "updatedAt": "2026-11-02T09:14:03.120Z", "deletedAt": null, "data": { "title": "…" } },
131
+ { "id": "6720c0…", "version": 3, "updatedAt": "2026-11-02T09:14:03.120Z", "deletedAt": null, "data": { "title": "…" } },
118
132
  { "id": "6720c1…", "version": 5, "updatedAt": "2026-11-02T09:15:44.002Z", "deletedAt": "2026-11-02T09:15:44.002Z" }
119
133
  ],
120
134
  "cursor": "c3luYzpub3RlOjE…",
@@ -131,8 +145,10 @@ GET /sync/{model}?cursor={cursor}&limit={n}
131
145
  cursor continues with page n+1. Apply a page's items and store its cursor in one local transaction.
132
146
  * **Ordering and duplicates.** Pages are ordered by the server's change order, not by `updatedAt`. A record may appear
133
147
  more than once across pages (it changed again while the client was paging) — keep the item with the higher
134
- `version`. **OPEN (phase 2):** whether the chosen cursor also delivers an unchanged record twice (an overlap window
135
- does, a change sequence does not); clients must tolerate it either way by comparing `version`.
148
+ `version`. Depending on the database the server runs on, a pull also repeats **unchanged** records (decided in
149
+ phase 2, P2-2): on MongoDB a run re-reads what changed within a window W before its cursor (on a replica set the
150
+ server's transaction lifetime — 60 s by default — plus 30 s, on a standalone 30 s; decided in DEV-3901), on SQL
151
+ databases it never does. Clients compare `version` and need not know which.
136
152
  * Without a cursor the client receives every record and every unexpired tombstone it may see, then continues with the
137
153
  last cursor like any delta. A client whose local storage was cleared (Safari removes the storage of a site not
138
154
  installed after seven days without interaction) simply starts without a cursor.
@@ -142,8 +158,9 @@ GET /sync/{model}?cursor={cursor}&limit={n}
142
158
  * Every change committed before the pull started and visible to the caller is delivered in some page of the run that
143
159
  starts at the given cursor — regardless of how many server instances wrote it, whether their clocks differ, whether
144
160
  two changes carry the same timestamp, or whether a transaction committed after a younger one was already pulled.
145
- **OPEN (phase 2):** the mechanism (P §3.4: a server-assigned change sequence with a commit horizon, or an
146
- overlap window with `version` comparison) is chosen by the prototype on every target database.
161
+ The mechanism (decided in phase 2, P §3.4, measured on every target database): on SQL databases a change sequence
162
+ the server assigns in commit order, on MongoDB the server's clock with a window that a commit cannot outlast. The
163
+ cursor is opaque either way; a client never reads or compares it.
147
164
  * No record and no tombstone of another tenant, and no record the caller's rights or `securityCheck` hide.
148
165
 
149
166
  ## 6. Push
@@ -160,7 +177,7 @@ Content-Type: application/json
160
177
  ### 6.2 Item
161
178
 
162
179
  ```json
163
- { "mutationId": "0190f8b3-…", "op": "upsert", "id": "0190f8a2-…", "baseVersion": 2, "data": { "title": "…" } }
180
+ { "mutationId": "0190f8b3-…", "op": "upsert", "id": "6720c0…", "baseVersion": 2, "data": { "title": "…" } }
164
181
  { "mutationId": "0190f8b4-…", "op": "delete", "id": "6720c1…", "baseVersion": 5 }
165
182
  ```
166
183
 
@@ -169,7 +186,7 @@ Content-Type: application/json
169
186
  | `mutationId` | Unique per change, generated by the client (uuidv7). The same change sent again carries the same `mutationId`. |
170
187
  | `op` | `upsert` (create or update) or `delete` (creates a tombstone; a hard delete is not reachable through sync). |
171
188
  | `id` | The record's id (§3). |
172
- | `baseVersion` | The `version` the client's change is based on. Absent **only** on the item that creates the record. Every later item carries the version the item before it produces — a create gives 1, each applied change adds 1 (§6.3) — so a record created and changed twice offline is pushed as the create, then `baseVersion: 1`, then `baseVersion: 2`. A client may instead fold all unsent changes of one record into a single item. |
189
+ | `baseVersion` | The `version` the client's change is based on. Absent **only** on the item that creates the record. Every later item carries the version the item before it produces — a create gives 1, each applied change adds 1 (§6.3) — so a record created and changed twice offline is pushed as the create, then `baseVersion: 1`, then `baseVersion: 2`. Such a chain may travel in one request: when an item of it is not stored, the server holds the rest back (§6.3). A client may instead fold all unsent changes of one record into a single item. |
173
190
  | `data` | The fields to set, validated against the model's input type like any create/update. Absent for `delete`. |
174
191
  | `fields` | Optional, for `merge`: the field names the client changed. Without it, every key in `data` counts as changed. |
175
192
 
@@ -178,12 +195,19 @@ Content-Type: application/json
178
195
  * Items are processed **in the order sent**, each in its own atomic step. A batch is not a transaction: on a database
179
196
  without transactions (MongoDB standalone) it could not be one, so it is not one anywhere.
180
197
  * An item referencing a record created earlier in the same batch sees that record.
198
+ * Once an item of a record is **not stored** (`conflict`, `rejected`, `not_found`, `retry`), the later items of that
199
+ record in the same batch are held back: never applied, answered `retry` behind a `retry` (send them again together),
200
+ otherwise `conflict` with the server's record (`not_found` when the caller may not see one). Each of them builds on the
201
+ version the item before it produces (§6.2); applied on its own, its `baseVersion` could match another writer's version
202
+ and the change would land on data the client never saw. Items of other records are unaffected. The server holds
203
+ back **within one request only**; across requests the client keeps the order (§11).
181
204
  * `upsert` without `baseVersion` on an id that does not exist creates the record with `version: 1`.
182
205
  * `upsert` with `baseVersion` is an **atomic conditional change**: it applies only when the stored version still equals
183
206
  `baseVersion` (`WHERE id = … AND version = …` or the MongoDB equivalent; never read-then-write), and it increments
184
207
  `version`.
185
- * `delete` with a matching `baseVersion` turns the record into a tombstone through the normal update pipeline (rights,
186
- `securityCheck`, audit apply). Deleting a tombstone again is answered `applied`.
208
+ * `delete` with a matching `baseVersion` turns the record into a tombstone through the normal delete pipeline (the
209
+ model's delete rights, `securityCheck`, audit apply). Deleting a tombstone again is answered `applied`. A delete through
210
+ any other route of the server leaves a tombstone too, so clients learn of it the same way.
187
211
  * An `upsert` on a tombstone is a conflict, never a silent resurrection.
188
212
 
189
213
  ### 6.4 Conflicts
@@ -219,9 +243,9 @@ A conflict is a `baseVersion` that no longer matches. What happens is the model'
219
243
  ```json
220
244
  {
221
245
  "results": [
222
- { "mutationId": "0190f8b3-…", "id": "0190f8a2-…", "status": "applied", "version": 3 },
246
+ { "mutationId": "0190f8b3-…", "id": "6720c0…", "status": "applied", "version": 3 },
223
247
  { "mutationId": "0190f8b4-…", "id": "6720c1…", "status": "conflict", "version": 7, "record": { … } },
224
- { "mutationId": "0190f8b5-…", "id": "0190f8a9-…", "status": "rejected", "code": "VALIDATION_FAILED", "details": [ … ] }
248
+ { "mutationId": "0190f8b5-…", "id": "6720c9…", "status": "rejected", "code": "VALIDATION_FAILED", "details": [ … ] }
225
249
  ]
226
250
  }
227
251
  ```
@@ -233,15 +257,15 @@ A conflict is a `baseVersion` that no longer matches. What happens is the model'
233
257
  | `applied` | The change is stored (also for a recognised repeat). `version` is the new version. | Store `version`; mark the change sent. |
234
258
  | `merged` | Stored after a field merge; `record` is the result. | Replace the local record. |
235
259
  | `conflict` | Not stored; `record` is the server's current record (a tombstone when it was deleted). | Resolve, then push again with `baseVersion` = `record.version`, or drop the change. |
236
- | `rejected` | Not stored, for the reason in `code`. Retrying the same change will not help. | Show or log; drop or correct the change. |
237
- | `not_found` | An update or delete for a record that does not exist **or that the caller may not see** — the same answer for both. | Drop the local record. |
238
- | `retry` | Not stored for a transient reason (a lock timeout, a store outage, the same `mutationId` still in progress). | Send the same item again later. |
260
+ | `rejected` | Not stored, for the reason in `code`. Retrying the same change will not help. | Show or log; drop or correct the change — and the record's later changes, which built on it. |
261
+ | `not_found` | An update or delete for a record that does not exist **or that the caller may not see** — the same answer for both. | Drop the local record and its queued changes. |
262
+ | `retry` | Not stored for a transient reason (a lock timeout, a store outage, the same `mutationId` still in progress). | Send the same item again later, the record's later changes with it — never before it. |
239
263
 
240
264
  | `code` (with `rejected`) | Meaning |
241
265
  |---|---|
242
266
  | `VALIDATION_FAILED` | `data` failed input validation; `details` lists the fields. |
243
267
  | `FORBIDDEN` | The caller may not change this record or these fields. |
244
- | `INVALID_ID` | The id has neither accepted format. |
268
+ | `INVALID_ID` | The id does not match the model's id format (§3). |
245
269
  | `ID_UNAVAILABLE` | The id cannot be used (§3); no further detail by design. |
246
270
  | `CUSTOM_REFUSED` | The `custom` conflict hook refused the change. |
247
271
 
@@ -257,7 +281,7 @@ When the server cannot continue a cursor consistently, pull answers:
257
281
  | `reason` | Cause |
258
282
  |---|---|
259
283
  | `horizon` | The cursor is older than the tombstone retention horizon; deletions in between may be gone. |
260
- | `access` | The caller's access changed since the cursor was issued: a tenant membership removed, a role changed, a record moved to another tenant or visibility scope. |
284
+ | `access` | The caller's access changed since the cursor was issued while the caller may still pull the model: a tenant membership removed (on a pull without `X-Tenant-Id`), a role changed, a record moved to another tenant or visibility scope. Once the caller may not pull the model at all, the pull answers `403` instead (§10). |
261
285
  | `invalid` | The cursor is malformed, was issued for another model or user, or for an incompatible sync configuration. |
262
286
 
263
287
  **Client procedure:** keep the unsent local changes, delete every local record of that model, pull without a cursor
@@ -272,13 +296,18 @@ start, on the `online` event and on focus. The server never assumes a client syn
272
296
  Sync API exists only in Chromium).
273
297
 
274
298
  * **SSE** for every web client: `GET /sync/hints?models=note,task` with `Accept: text/event-stream`, authenticated like
275
- any request. Events: `event: change` with `data: {"model":"note","at":"2026-11-02T09:15:44.002Z"}`; a comment line
276
- every 25 seconds keeps proxies from closing the stream.
299
+ any request (`models` optional: all models without it; a name that is not offered never matches). Events:
300
+ `event: change` with `data: {"model":"note","at":"2026-11-02T09:15:44.002Z"}`; a comment line every 25 seconds keeps
301
+ proxies from closing the stream, and `retry: 3000` tells the EventSource how soon to reconnect. A signed-in caller
302
+ always gets the stream (`200`); models the caller may not pull simply never send a hint, so the stream reveals
303
+ nothing about which models exist. `404` when the server switched the SSE channel off.
277
304
  * **GraphQL subscription** for clients that use GraphQL: `subscription { syncHint(models: ["note"]) { model at } }`.
278
305
  * A hint carries the model name and a time — no record, no id, no tenant. It is sent only to subscribers who hold the
279
306
  model's pull roles and may read the changed tenant's records of that model; bursts are collapsed (default 250 ms).
280
307
  * Both channels are long-lived, so the server checks them again during their lifetime like its GraphQL WebSockets: a
281
- channel whose user lost access, signed out or changed roles is closed; the client reconnects and is checked anew.
308
+ channel whose user lost access, signed out or changed roles is closed; the client reconnects and is checked anew. An
309
+ SSE stream also ends before its first hint after the re-check interval (30 s by default) and is reconnected — a hint
310
+ is never delivered on rights older than that.
282
311
  * On reconnect a client pulls once, because hints sent while it was disconnected are not replayed.
283
312
 
284
313
  ## 10. HTTP errors
@@ -287,40 +316,51 @@ Sync API exists only in Chromium).
287
316
  |---|---|
288
317
  | `400` | Malformed body or query, unknown `op`, more than `maxPushItems` items. |
289
318
  | `401` | Not authenticated or session expired. Nothing was applied. |
290
- | `403` | Authenticated, but without the model's pull roles (pull, hints); a cookie-authenticated push failing the origin rules. A push item lacking the operation's roles is `rejected` / `FORBIDDEN` (§7). |
319
+ | `403` | On a pull: the caller may not pull the model (pull roles withdrawn), or `X-Tenant-Id` names a tenant they left or that was deactivated — access loss like `410 access`: delete that model's (and tenant's) local records and cursor; the unsent changes cannot be pushed under this account (§11). On a push: a cookie-authenticated push failing the origin rules. A push item lacking the operation's roles is `rejected` / `FORBIDDEN` (§7). |
291
320
  | `404` | The model is not registered for sync. |
292
321
  | `410` | Resync required (§8). |
293
322
  | `413` | The body exceeds the server's limit. |
294
323
  | `429` | Rate limit; `Retry-After` says when to try again. |
295
324
  | `503` | A store needed for the request is unavailable; retry later. |
296
325
 
297
- Error bodies use the framework's error-code format (`#LTNS_…` codes, registered when the module ships).
326
+ Error bodies use the framework's error-code format, sync codes in `#LTNS_0700`–`#LTNS_0799` (`SYNC_RESYNC_REQUIRED`,
327
+ `SYNC_MODEL_NOT_FOUND`, `SYNC_INVALID_REQUEST`, `SYNC_ORIGIN_REFUSED`, `SYNC_STORE_UNAVAILABLE`; 429 is
328
+ `RATE_LIMIT_EXCEEDED`). The `410` body is always the one §8 shows, whatever exception filter the project registered.
298
329
 
299
330
  ## 11. Client duties
300
331
 
301
332
  * Sync at start, on `online`, on focus, and after a hint; back off exponentially on `429`, `503` and network errors.
302
- * Generate ids (uuidv7 recommended) and mutation ids locally; persist unsent changes with their mutation ids until a
333
+ * Generate ids in the model's format with the random part §3 requires, and mutation ids, locally; persist unsent changes with their mutation ids until a
303
334
  terminal status (`applied`, `merged`, `conflict`, `rejected`, `not_found`) arrives.
304
335
  * Give every queued change of one record the `baseVersion` the change before it produces (§6.2), or fold them into one
305
- item; push them in that order.
336
+ item; push them in that order. Send a later change only in the same request as the change before it, or after that
337
+ one came back `applied` or `merged`: the server holds a chain back within one request only (§6.3), and a later
338
+ change sent on its own could match another writer's version.
306
339
  * Store each pulled page and its cursor atomically; compare `version` before overwriting a local record.
307
- * **On logout delete every local record and the cursors.** The device holds personal data outside the server; the
308
- integration guide of the sync module lists what to delete.
340
+ * **On logout delete every local record, the cursors and the unsent changes**, and do the same before another user's
341
+ first pull. The device holds personal data outside the server; the sync module's `SECURITY.md` lists what to delete
342
+ and how to keep the credential out of reach.
343
+ * **On `410 access` and on `403` to a pull, delete the local records of that model** (and tenant) and the cursor — the
344
+ caller lost access, and the device must not keep what the server would no longer send (§8, §10, the module's
345
+ `SECURITY.md`).
309
346
  * Treat a cleared storage as a fresh start (no cursor).
310
347
 
311
348
  ## 12. What the server guarantees
312
349
 
313
350
  * Pull and push run through the same `@Restricted`, `securityCheck`, tenant and output pipeline as every other
314
351
  request, with the operation roles the model declares for sync (§1); hints reach only callers with the pull roles.
315
- * A pull never delivers a record or tombstone of another tenant; a push never changes one and never reveals that one
316
- exists (`not_found` / `ID_UNAVAILABLE`, §3, §7).
352
+ * A pull never delivers a record or tombstone of another tenant; a push never changes one. An update or delete of it
353
+ answers `not_found` like an unused id, a create on its id `ID_UNAVAILABLE` — the same answer for every reason, with
354
+ nothing about the record; that an id is taken stays observable by design (§3, decided O2, §15).
317
355
  * Tombstones carry no content field. On a model whose records only certain users may see, the tombstone keeps the
318
356
  user-id fields the model declares as its scope (e.g. `ownerId`, decided O1, §15), so it reaches exactly the users who
319
357
  could see the record — never the rest of the tenant.
320
358
  * Hard deletes are not reachable through sync.
321
359
  * Changes are never lost by the cursor (§5.3) and never duplicated by retries (§6.5).
322
- * Idempotency records, rate-limit counters and the retention horizon live in infrastructure stores with an explicit
323
- expiry condition, never in a TTL index; expired tombstones are removed by a cron job under the `LockStore` lease.
360
+ * Idempotency records and rate-limit counters live in infrastructure stores with an explicit expiry condition that
361
+ every reader checks itself — a TTL index (MongoDB) or the expiry sweep (SQL) only removes what has expired. The
362
+ retention horizon never expires. Tombstones older than `sync.retention.tombstonesDays` (90 days) are removed every
363
+ hour under a lease, after the horizon moved past them.
324
364
 
325
365
  ## 13. Compatibility
326
366
 
@@ -329,7 +369,7 @@ project stays as it is.
329
369
 
330
370
  ## 14. Requirement trace
331
371
 
332
- Every requirement of DEV-3819 and where this document meets it (P = `.claude/plans/offline-sync/PLAN.md`).
372
+ Every requirement of DEV-3819 and where this document meets it (P = the offline-sync design plan).
333
373
 
334
374
  | Requirement (DEV-3819) | Where |
335
375
  |---|---|
@@ -353,13 +393,16 @@ Every requirement of DEV-3819 and where this document meets it (P = `.claude/pla
353
393
  | Unique indexes do not fail on tombstones (partial; MySQL via generated column) | P §3.3 (E3), P §3.6 |
354
394
  | Cursor without loss across instances, clocks, equal timestamps, late commits; prototype decides | §5.3, P §3.4, P phase 2 |
355
395
  | Push item-atomic; batch transaction only with `capabilities.transactions`, not the default | §6.3 |
356
- | Hints via `capabilities.changeFeed` where present, else emitted by the CrudService via in-process / Redis pub/sub | §9, P §3.9 |
396
+ | Hints emitted by the store after every successful write, via in-process / Redis pub/sub; no change feed (P2-5, §15) | §9, P §3.9 |
357
397
  | Idempotency keys, rate-limit counters, retention horizon in infrastructure stores with explicit expiry; cron sweep under `LockStore` | §12, P §3.7 |
358
398
  | Every pull/push through the full pipeline; no `pullLean` | §1, §12 |
359
- | Tombstones carry `tenantId` and only `id`, `version`, `deletedAt`, `updatedAt` | §2, §12; plus declared user-id scope fields, decided O1 (§15) |
399
+ | Tombstones carry `tenantId` and only `id`, `version`, `deletedAt`, `updatedAt` | §2, §12; plus declared user-id scope fields, decided O1 (§15); the server keeps the audit fields too (DEV-3900), a pull sends none |
360
400
  | Hard delete not reachable through sync | §6.2, §12 |
361
- | Access loss → client deletes local copies; at least a forced full resync | §8 |
362
- | Integration doc says what a client deletes on logout | §11 (detailed in the module's checklist, phase 6) |
401
+ | Access loss → client deletes local copies; at least a forced full resync | §8 (`410 access`), §10 / §11 (`403` on a pull) |
402
+ | Integration doc says what a client deletes on logout | §11, the module's `SECURITY.md` and its checklist |
403
+ | Acceptance: the same contract suite green on MongoDB standalone and replica set, PostgreSQL × three engines (and MySQL, MariaDB) | `tests/sync-contract.e2e-spec.ts` (framework repository) |
404
+ | Acceptance: no lost change with parallel writers on two instances with skewed clocks | `tests/sync-clock-skew.e2e-spec.ts` |
405
+ | Acceptance: PWA test client in a browser, and a client without one, pass the same scenarios | `tests/sync-pwa-client.e2e-spec.ts`, `tests/sync-node-client.e2e-spec.ts` |
363
406
  | Without sync configuration nothing changes | §1, §13 |
364
407
  | Decisions 2026-10-29: both id formats, full resync on access loss, SSE + GraphQL, test clients, prototype decides the cursor | §3, §8, §9, P §11 |
365
408
 
@@ -367,10 +410,10 @@ Every requirement of DEV-3819 and where this document meets it (P = `.claude/pla
367
410
 
368
411
  | # | Question | Decided by | Notes |
369
412
  |---|---|---|---|
370
- | P2-1 | Cursor mechanism: change sequence with a commit horizon, or overlap window with `version` comparison | phase 2 prototype on MongoDB standalone and replica set, PostgreSQL × TypeORM / Kysely / Drizzle, MySQL, MariaDB | P §3.4 lists the candidates and what is measured |
371
- | P2-2 | Whether a page may repeat an unchanged record | phase 2, follows from P2-1 | Clients compare `version` either way (§5.2) |
372
- | P2-3 | MongoDB collections holding ObjectId and string `_id` side by side: casting, populate, sort, references | phase 2 | §3 |
373
- | P2-4 | Partial unique index on MongoDB with `{ deletedAt: { $type: 'null' } }`, on MySQL / MariaDB through virtual live-key columns (both refuse a plain partial unique index) | phase 2 contract case | P §3.6 |
374
- | P2-5 | Whether `capabilities.changeFeed` (change streams on a replica set, `LISTEN/NOTIFY` on PostgreSQL) is worth it for hints, measured against CrudService-emitted events | phase 2 | §9 |
413
+ | P2-1 | Cursor mechanism: change sequence with a commit horizon, or overlap window with `version` comparison | **decided 2026-10-31 (DEV-3899, measured on all seven targets):** SQL — a commit-ordered sequence, the counter taken last (no horizon needed); MongoDB — the server clock with a window W derived from the transaction lifetime | P §3.4, P §5 |
414
+ | P2-2 | Whether a page may repeat an unchanged record | **decided 2026-10-31 (DEV-3899):** on MongoDB yes, within W before the cursor; on SQL no | Clients compare `version` either way (§5.2) |
415
+ | P2-3 | MongoDB collections holding ObjectId and string `_id` side by side: casting, populate, sort, references | **dropped 2026-10-29 (owner, DEV-3899):** one id format per model, never mixed — the question cannot arise | §3 |
416
+ | P2-4 | Partial unique index on MongoDB with `{ deletedAt: { $type: 'null' } }`, on MySQL / MariaDB through virtual live-key columns (both refuse a plain partial unique index) | **decided 2026-10-31 (DEV-3899, measured):** MongoDB filters live records with `{ deletedAt: null }` (accepted on 5.0, 7.0, 8.2, covers a missing field, used by the matching query); PostgreSQL keeps `NULLS NOT DISTINCT` with `WHERE deleted_at IS NULL`; MySQL / MariaDB use the virtual live-key column. Every target refuses a second live value and a second live `NULL` and lets tombstones repeat a value | P §3.6, P §5 |
417
+ | P2-5 | Whether `capabilities.changeFeed` (change streams on a replica set, `LISTEN/NOTIFY` on PostgreSQL) is worth it for hints, measured against CrudService-emitted events | **decided 2026-10-31 (DEV-3899):** no. A feed would add hints only for writes that bypass the store. Those reach a client with its next pull at the earliest (on SQL the sequence trigger numbers them too, on MongoDB they carry no cursor field and are not pulled at all — sync models are written through the store), and hints are optional by design. The store path is needed on MySQL, MariaDB and standalone MongoDB regardless. One source, the store's write events | §9, P §3.9 |
375
418
  | O1 | Tombstones on per-user-visibility models | **decided 2026-10-29 (owner):** a tombstone keeps the user-id fields the model declares as its scope (`syncScope`, e.g. `ownerId`) — only user ids, never content | §2, §12; otherwise a tombstone either reaches the whole tenant (ids and deletion times of other users' records) or nobody (a deletion never reaches the owner's other devices) |
376
419
  | O2 | Id collision with a record the caller may not see | **decided 2026-10-29 (owner):** the uniform `ID_UNAVAILABLE` stays, ids stay unique across tenants | §3; ids unique per tenant would change every lookup, reference and route by id in the framework |