hikoutei 0.3.0 → 0.3.1

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 (368) hide show
  1. package/README.ja.md +13 -21
  2. package/README.ko.md +14 -22
  3. package/README.md +25 -29
  4. package/dist/adapter/persistence/contracts/sql.d.ts +16 -2
  5. package/dist/adapter/persistence/contracts/sql.d.ts.map +1 -1
  6. package/dist/adapter/persistence/contracts/sql.js +11 -1
  7. package/dist/adapter/persistence/contracts/sql.js.map +1 -1
  8. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.d.ts +1 -1
  9. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.d.ts.map +1 -1
  10. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.js +40 -14
  11. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.js.map +1 -1
  12. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.d.ts +2 -0
  13. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.d.ts.map +1 -1
  14. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.js +23 -8
  15. package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.js.map +1 -1
  16. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.d.ts +13 -4
  17. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.d.ts.map +1 -1
  18. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.js +12 -2
  19. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.js.map +1 -1
  20. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.d.ts +21 -0
  21. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.d.ts.map +1 -0
  22. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.js +59 -0
  23. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.js.map +1 -0
  24. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarRuntime.d.ts +14 -13
  25. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarRuntime.d.ts.map +1 -1
  26. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarRuntime.js +43 -64
  27. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmScalarRuntime.js.map +1 -1
  28. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.d.ts.map +1 -1
  29. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.js +4 -2
  30. package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.js.map +1 -1
  31. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.d.ts.map +1 -1
  32. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js +1 -2
  33. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js.map +1 -1
  34. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPolling.d.ts +61 -0
  35. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPolling.d.ts.map +1 -0
  36. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPolling.js +186 -0
  37. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPolling.js.map +1 -0
  38. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingInspection.d.ts +56 -0
  39. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingInspection.d.ts.map +1 -0
  40. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingInspection.js +275 -0
  41. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingInspection.js.map +1 -0
  42. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingPersistence.d.ts +11 -0
  43. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingPersistence.d.ts.map +1 -0
  44. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingPersistence.js +345 -0
  45. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingPersistence.js.map +1 -0
  46. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingSql.d.ts +65 -0
  47. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingSql.d.ts.map +1 -0
  48. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingSql.js +51 -0
  49. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingSql.js.map +1 -0
  50. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingState.d.ts +36 -0
  51. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingState.d.ts.map +1 -0
  52. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingState.js +126 -0
  53. package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmUserInputPollingState.js.map +1 -0
  54. package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.d.ts +11 -2
  55. package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.d.ts.map +1 -1
  56. package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.js +39 -0
  57. package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.js.map +1 -1
  58. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.d.ts.map +1 -1
  59. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.js +46 -35
  60. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.js.map +1 -1
  61. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.d.ts.map +1 -1
  62. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.js +22 -4
  63. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.js.map +1 -1
  64. package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.d.ts +2 -0
  65. package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.d.ts.map +1 -1
  66. package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.js +47 -54
  67. package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.js.map +1 -1
  68. package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.d.ts.map +1 -1
  69. package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.js +6 -30
  70. package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.js.map +1 -1
  71. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.d.ts +1 -0
  72. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.d.ts.map +1 -1
  73. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.js +79 -22
  74. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.js.map +1 -1
  75. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.d.ts +2 -1
  76. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.d.ts.map +1 -1
  77. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.js.map +1 -1
  78. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.d.ts +5 -0
  79. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.d.ts.map +1 -1
  80. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.js +19 -4
  81. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.js.map +1 -1
  82. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.js +5 -6
  83. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.js.map +1 -1
  84. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.d.ts +2 -1
  85. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.d.ts.map +1 -1
  86. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.js +2 -1
  87. package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.js.map +1 -1
  88. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.d.ts +2 -1
  89. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.d.ts.map +1 -1
  90. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.js +15 -19
  91. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.js.map +1 -1
  92. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.d.ts.map +1 -1
  93. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js +44 -30
  94. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js.map +1 -1
  95. package/dist/adapter/sheets/providers/apps-script-gateway/validation.d.ts +3 -0
  96. package/dist/adapter/sheets/providers/apps-script-gateway/validation.d.ts.map +1 -0
  97. package/dist/adapter/sheets/providers/apps-script-gateway/validation.js +10 -0
  98. package/dist/adapter/sheets/providers/apps-script-gateway/validation.js.map +1 -0
  99. package/dist/api/Hikoutei.d.ts +17 -50
  100. package/dist/api/Hikoutei.d.ts.map +1 -1
  101. package/dist/api/Hikoutei.js +46 -105
  102. package/dist/api/Hikoutei.js.map +1 -1
  103. package/dist/api/entity.d.ts +9 -10
  104. package/dist/api/entity.d.ts.map +1 -1
  105. package/dist/api/entity.js +20 -26
  106. package/dist/api/entity.js.map +1 -1
  107. package/dist/api/errors.d.ts +0 -6
  108. package/dist/api/errors.d.ts.map +1 -1
  109. package/dist/api/errors.js +0 -6
  110. package/dist/api/errors.js.map +1 -1
  111. package/dist/api/index.d.ts +4 -4
  112. package/dist/api/index.d.ts.map +1 -1
  113. package/dist/api/index.js +2 -2
  114. package/dist/api/index.js.map +1 -1
  115. package/dist/api/internalEntityManager.d.ts.map +1 -1
  116. package/dist/api/internalEntityManager.js +33 -19
  117. package/dist/api/internalEntityManager.js.map +1 -1
  118. package/dist/application/orm/mapping/contracts.d.ts +16 -6
  119. package/dist/application/orm/mapping/contracts.d.ts.map +1 -1
  120. package/dist/application/orm/mapping/definition.d.ts.map +1 -1
  121. package/dist/application/orm/mapping/definition.js +47 -8
  122. package/dist/application/orm/mapping/definition.js.map +1 -1
  123. package/dist/application/orm/mapping/identity.js +1 -1
  124. package/dist/application/orm/mapping/identity.js.map +1 -1
  125. package/dist/application/orm/mapping/projection.d.ts.map +1 -1
  126. package/dist/application/orm/mapping/projection.js +10 -2
  127. package/dist/application/orm/mapping/projection.js.map +1 -1
  128. package/dist/application/orm/mapping/values.d.ts.map +1 -1
  129. package/dist/application/orm/mapping/values.js +5 -35
  130. package/dist/application/orm/mapping/values.js.map +1 -1
  131. package/dist/application/orm/persistence/flush/flushCoordinator.d.ts +3 -1
  132. package/dist/application/orm/persistence/flush/flushCoordinator.d.ts.map +1 -1
  133. package/dist/application/orm/persistence/flush/flushCoordinator.js +4 -3
  134. package/dist/application/orm/persistence/flush/flushCoordinator.js.map +1 -1
  135. package/dist/application/orm/persistence/lifecycle/entityLifecycle.js +2 -1
  136. package/dist/application/orm/persistence/lifecycle/entityLifecycle.js.map +1 -1
  137. package/dist/application/orm/persistence/projection/projectionEffects.d.ts +3 -1
  138. package/dist/application/orm/persistence/projection/projectionEffects.d.ts.map +1 -1
  139. package/dist/application/orm/persistence/projection/projectionEffects.js +14 -16
  140. package/dist/application/orm/persistence/projection/projectionEffects.js.map +1 -1
  141. package/dist/application/orm/persistence/scalar/unitOfWork.d.ts +6 -6
  142. package/dist/application/orm/persistence/scalar/unitOfWork.d.ts.map +1 -1
  143. package/dist/application/orm/persistence/scalar/unitOfWork.js +28 -28
  144. package/dist/application/orm/persistence/scalar/unitOfWork.js.map +1 -1
  145. package/dist/application/orm/persistence/support/businessKeys.d.ts.map +1 -1
  146. package/dist/application/orm/persistence/support/businessKeys.js +6 -24
  147. package/dist/application/orm/persistence/support/businessKeys.js.map +1 -1
  148. package/dist/application/orm/persistence/support/canonicalState.d.ts.map +1 -1
  149. package/dist/application/orm/persistence/support/canonicalState.js +9 -25
  150. package/dist/application/orm/persistence/support/canonicalState.js.map +1 -1
  151. package/dist/application/orm/persistence/support/contracts.d.ts +0 -57
  152. package/dist/application/orm/persistence/support/contracts.d.ts.map +1 -1
  153. package/dist/application/orm/persistence/support/contracts.js +0 -68
  154. package/dist/application/orm/persistence/support/contracts.js.map +1 -1
  155. package/dist/application/orm/persistence/support/helpers.d.ts +1 -11
  156. package/dist/application/orm/persistence/support/helpers.d.ts.map +1 -1
  157. package/dist/application/orm/persistence/support/helpers.js +1 -21
  158. package/dist/application/orm/persistence/support/helpers.js.map +1 -1
  159. package/dist/application/sync/gateway/constants.d.ts +2 -1
  160. package/dist/application/sync/gateway/constants.d.ts.map +1 -1
  161. package/dist/application/sync/gateway/constants.js +4 -3
  162. package/dist/application/sync/gateway/constants.js.map +1 -1
  163. package/dist/application/sync/gateway/syncGateway.d.ts.map +1 -1
  164. package/dist/application/sync/gateway/syncGateway.js +9 -28
  165. package/dist/application/sync/gateway/syncGateway.js.map +1 -1
  166. package/dist/application/sync/gateway/validation.d.ts +5 -0
  167. package/dist/application/sync/gateway/validation.d.ts.map +1 -1
  168. package/dist/application/sync/gateway/validation.js +22 -3
  169. package/dist/application/sync/gateway/validation.js.map +1 -1
  170. package/dist/application/sync/inbound/polling/SimpleSheetPolling.d.ts.map +1 -1
  171. package/dist/application/sync/inbound/polling/SimpleSheetPolling.js +3 -23
  172. package/dist/application/sync/inbound/polling/SimpleSheetPolling.js.map +1 -1
  173. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts +2 -0
  174. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts.map +1 -1
  175. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js +24 -6
  176. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js.map +1 -1
  177. package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts.map +1 -1
  178. package/dist/application/sync/outbound/effects/SyncEffectWorker.js +35 -34
  179. package/dist/application/sync/outbound/effects/SyncEffectWorker.js.map +1 -1
  180. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts +0 -1
  181. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts.map +1 -1
  182. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js +8 -37
  183. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js.map +1 -1
  184. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts.map +1 -1
  185. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js +2 -2
  186. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js.map +1 -1
  187. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts +0 -5
  188. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts.map +1 -1
  189. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js +3 -10
  190. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js.map +1 -1
  191. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts.map +1 -1
  192. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js +13 -21
  193. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js.map +1 -1
  194. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts +1 -1
  195. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts.map +1 -1
  196. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js +15 -3
  197. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js.map +1 -1
  198. package/dist/application/sync/outbound/projection/ProjectionEffectFactory.d.ts.map +1 -1
  199. package/dist/application/sync/outbound/projection/ProjectionEffectFactory.js +1 -10
  200. package/dist/application/sync/outbound/projection/ProjectionEffectFactory.js.map +1 -1
  201. package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.d.ts.map +1 -1
  202. package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.js +5 -9
  203. package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.js.map +1 -1
  204. package/dist/application/sync/service/SyncPollingSupervisor.d.ts +45 -0
  205. package/dist/application/sync/service/SyncPollingSupervisor.d.ts.map +1 -0
  206. package/dist/application/sync/service/SyncPollingSupervisor.js +142 -0
  207. package/dist/application/sync/service/SyncPollingSupervisor.js.map +1 -0
  208. package/dist/application/sync/service/SyncServiceBootstrap.d.ts +63 -0
  209. package/dist/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -0
  210. package/dist/application/sync/service/SyncServiceBootstrap.js +223 -0
  211. package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -0
  212. package/dist/application/sync/service/contracts.d.ts +25 -0
  213. package/dist/application/sync/service/contracts.d.ts.map +1 -0
  214. package/dist/application/sync/service/contracts.js +3 -0
  215. package/dist/application/sync/service/contracts.js.map +1 -0
  216. package/dist/application/sync/service/errors.d.ts +15 -0
  217. package/dist/application/sync/service/errors.d.ts.map +1 -0
  218. package/dist/application/sync/service/errors.js +16 -0
  219. package/dist/application/sync/service/errors.js.map +1 -0
  220. package/dist/domain/errors/types.d.ts +1 -1
  221. package/dist/domain/errors/types.d.ts.map +1 -1
  222. package/dist/domain/errors/types.js +2 -2
  223. package/dist/domain/errors/types.js.map +1 -1
  224. package/dist/domain/evaluate/constants.d.ts +1 -1
  225. package/dist/domain/evaluate/constants.d.ts.map +1 -1
  226. package/dist/domain/evaluate/constants.js.map +1 -1
  227. package/dist/domain/evaluate/preconditions.d.ts.map +1 -1
  228. package/dist/domain/evaluate/preconditions.js +25 -32
  229. package/dist/domain/evaluate/preconditions.js.map +1 -1
  230. package/dist/domain/evaluate/quarantine.js +4 -1
  231. package/dist/domain/evaluate/quarantine.js.map +1 -1
  232. package/dist/domain/model/constants.d.ts +48 -0
  233. package/dist/domain/model/constants.d.ts.map +1 -1
  234. package/dist/domain/model/constants.js +38 -0
  235. package/dist/domain/model/constants.js.map +1 -1
  236. package/dist/domain/model/index.d.ts +2 -2
  237. package/dist/domain/model/index.d.ts.map +1 -1
  238. package/dist/domain/model/index.js +1 -1
  239. package/dist/domain/model/index.js.map +1 -1
  240. package/dist/domain/model/types.d.ts +13 -10
  241. package/dist/domain/model/types.d.ts.map +1 -1
  242. package/dist/infrastructure/storage/constants.d.ts +1 -1
  243. package/dist/infrastructure/storage/constants.d.ts.map +1 -1
  244. package/dist/infrastructure/storage/constants.js.map +1 -1
  245. package/dist/infrastructure/storage/errors.d.ts +2 -2
  246. package/dist/infrastructure/storage/errors.d.ts.map +1 -1
  247. package/dist/infrastructure/storage/errors.js +3 -5
  248. package/dist/infrastructure/storage/errors.js.map +1 -1
  249. package/dist/infrastructure/storage/index.d.ts +9 -5
  250. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  251. package/dist/infrastructure/storage/index.js +3 -1
  252. package/dist/infrastructure/storage/index.js.map +1 -1
  253. package/dist/infrastructure/storage/sqlite/migrateSchema.js +9 -4
  254. package/dist/infrastructure/storage/sqlite/migrateSchema.js.map +1 -1
  255. package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts +9 -0
  256. package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts.map +1 -1
  257. package/dist/infrastructure/storage/state/canonical/canonicalCommit.js +35 -36
  258. package/dist/infrastructure/storage/state/canonical/canonicalCommit.js.map +1 -1
  259. package/dist/infrastructure/storage/state/mapped/mappedPersistenceSql.d.ts +8 -1
  260. package/dist/infrastructure/storage/state/mapped/mappedPersistenceSql.d.ts.map +1 -1
  261. package/dist/infrastructure/storage/state/mapped/mappedPersistenceSql.js +14 -0
  262. package/dist/infrastructure/storage/state/mapped/mappedPersistenceSql.js.map +1 -1
  263. package/dist/infrastructure/storage/state/observation/observationAudit.d.ts.map +1 -1
  264. package/dist/infrastructure/storage/state/observation/observationAudit.js +4 -1
  265. package/dist/infrastructure/storage/state/observation/observationAudit.js.map +1 -1
  266. package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts +11 -1
  267. package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts.map +1 -1
  268. package/dist/infrastructure/storage/state/observation/observationCanonical.js +108 -0
  269. package/dist/infrastructure/storage/state/observation/observationCanonical.js.map +1 -1
  270. package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts +36 -1
  271. package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts.map +1 -1
  272. package/dist/infrastructure/storage/state/observation/observationQuarantine.js +55 -0
  273. package/dist/infrastructure/storage/state/observation/observationQuarantine.js.map +1 -1
  274. package/dist/infrastructure/storage/state/observation/observationTypes.d.ts +22 -0
  275. package/dist/infrastructure/storage/state/observation/observationTypes.d.ts.map +1 -1
  276. package/dist/infrastructure/storage/state/observation/observationTypes.js +5 -0
  277. package/dist/infrastructure/storage/state/observation/observationTypes.js.map +1 -1
  278. package/dist/infrastructure/storage/state/observation/observationValidation.d.ts +1 -1
  279. package/dist/infrastructure/storage/state/observation/observationValidation.d.ts.map +1 -1
  280. package/dist/infrastructure/storage/state/observation/observationValidation.js +26 -0
  281. package/dist/infrastructure/storage/state/observation/observationValidation.js.map +1 -1
  282. package/dist/infrastructure/storage/state/observation/observationWriter.d.ts +1 -1
  283. package/dist/infrastructure/storage/state/observation/observationWriter.d.ts.map +1 -1
  284. package/dist/infrastructure/storage/state/observation/observationWriter.js +5 -1
  285. package/dist/infrastructure/storage/state/observation/observationWriter.js.map +1 -1
  286. package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts.map +1 -1
  287. package/dist/infrastructure/storage/state/resolution/resolutionWriter.js +3 -2
  288. package/dist/infrastructure/storage/state/resolution/resolutionWriter.js.map +1 -1
  289. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts +1 -5
  290. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts.map +1 -1
  291. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js +3 -43
  292. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js.map +1 -1
  293. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts +1 -1
  294. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts.map +1 -1
  295. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js +2 -4
  296. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js.map +1 -1
  297. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts +2 -2
  298. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts.map +1 -1
  299. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js +20 -10
  300. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js.map +1 -1
  301. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts +33 -18
  302. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts.map +1 -1
  303. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js.map +1 -1
  304. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts +1 -1
  305. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts.map +1 -1
  306. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js +2 -4
  307. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js.map +1 -1
  308. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts +6 -2
  309. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts.map +1 -1
  310. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js +157 -14
  311. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js.map +1 -1
  312. package/dist/infrastructure/storage/sync/outbound/reconciliationSql.d.ts +1 -1
  313. package/dist/infrastructure/storage/sync/outbound/reconciliationSql.d.ts.map +1 -1
  314. package/dist/infrastructure/storage/sync/outbound/reconciliationSql.js +14 -1
  315. package/dist/infrastructure/storage/sync/outbound/reconciliationSql.js.map +1 -1
  316. package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts +2 -1
  317. package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts.map +1 -1
  318. package/dist/infrastructure/storage/sync/shared/syncRegistry.js +4 -1
  319. package/dist/infrastructure/storage/sync/shared/syncRegistry.js.map +1 -1
  320. package/dist/infrastructure/storage/sync/shared/writerLease.d.ts +4 -0
  321. package/dist/infrastructure/storage/sync/shared/writerLease.d.ts.map +1 -1
  322. package/dist/infrastructure/storage/sync/shared/writerLease.js +9 -0
  323. package/dist/infrastructure/storage/sync/shared/writerLease.js.map +1 -1
  324. package/dist/shared/constants.d.ts +4 -4
  325. package/dist/shared/constants.d.ts.map +1 -1
  326. package/dist/shared/constants.js.map +1 -1
  327. package/dist/shared/encoding/index.d.ts +1 -0
  328. package/dist/shared/encoding/index.d.ts.map +1 -1
  329. package/dist/shared/encoding/index.js +1 -0
  330. package/dist/shared/encoding/index.js.map +1 -1
  331. package/dist/shared/encoding/normalizedCell.d.ts +4 -0
  332. package/dist/shared/encoding/normalizedCell.d.ts.map +1 -0
  333. package/dist/shared/encoding/normalizedCell.js +29 -0
  334. package/dist/shared/encoding/normalizedCell.js.map +1 -0
  335. package/dist/shared/encoding/stableEncode.d.ts +2 -1
  336. package/dist/shared/encoding/stableEncode.d.ts.map +1 -1
  337. package/dist/shared/encoding/stableEncode.js +6 -12
  338. package/dist/shared/encoding/stableEncode.js.map +1 -1
  339. package/dist/shared/identity/index.d.ts +3 -0
  340. package/dist/shared/identity/index.d.ts.map +1 -0
  341. package/dist/shared/identity/index.js +2 -0
  342. package/dist/shared/identity/index.js.map +1 -0
  343. package/dist/shared/identity/types.d.ts +41 -0
  344. package/dist/shared/identity/types.d.ts.map +1 -0
  345. package/dist/shared/identity/types.js +34 -0
  346. package/dist/shared/identity/types.js.map +1 -0
  347. package/dist/shared/index.d.ts +1 -0
  348. package/dist/shared/index.d.ts.map +1 -1
  349. package/dist/shared/index.js +1 -0
  350. package/dist/shared/index.js.map +1 -1
  351. package/dist/shared/state/constructors.d.ts +10 -0
  352. package/dist/shared/state/constructors.d.ts.map +1 -0
  353. package/dist/shared/state/constructors.js +18 -0
  354. package/dist/shared/state/constructors.js.map +1 -0
  355. package/dist/shared/state/index.d.ts +1 -0
  356. package/dist/shared/state/index.d.ts.map +1 -1
  357. package/dist/shared/state/index.js +1 -0
  358. package/dist/shared/state/index.js.map +1 -1
  359. package/dist/shared/validation.d.ts +2 -0
  360. package/dist/shared/validation.d.ts.map +1 -1
  361. package/dist/shared/validation.js +9 -0
  362. package/dist/shared/validation.js.map +1 -1
  363. package/docs/architecture.md +108 -103
  364. package/docs/ci.md +184 -61
  365. package/docs/mikro-orm-adapter-spike.md +55 -214
  366. package/docs/quick-start.md +58 -96
  367. package/docs/write-and-synchronization-flow.md +70 -39
  368. package/package.json +1 -1
package/docs/ci.md CHANGED
@@ -1,18 +1,29 @@
1
1
  # CI scenarios
2
2
 
3
- Hikoutei's CI includes an **internal sync/gateway end-to-end scenario**. It is
4
- not a public API smoke test. The scenario drives the internal typed-sheets sync
5
- pipeline — projection registration, gateway provisioning, the bounded effect
6
- worker, polling, and the MikroORM-backed storage/CAS/hash machinery — and
7
- loads implementation modules directly from the packed `dist/` tree. The
3
+ Hikoutei's CI runs two installed-consumer scenarios against the packed
4
+ package. Each is built as an installed consumer: after `npm pack` it imports
5
+ from the packed tarball rather than from `src/**` or the source-only test
6
+ fake, and neither is allowed to import those.
7
+
8
+ 1. **Internal sync/gateway E2E** (`scripts/ci/run-api-scenario.mjs`) drives the
9
+ internal typed-sheets sync pipeline — projection registration, gateway
10
+ provisioning, the bounded effect worker, polling, and the MikroORM-backed
11
+ storage/CAS/hash machinery — and loads implementation modules directly from
12
+ the packed `dist/` tree.
13
+ 2. **Installed root API smoke** (`scripts/ci/run-root-api-scenario.mjs`)
14
+ imports ONLY the installed package root entrypoint `hikoutei` (no internal
15
+ package subpaths and no source imports) and exercises the public
16
+ entity-lifecycle contract an application is meant to use.
17
+
18
+ The public contract is the high-level `hikoutei` root API: a SQLite-backed
19
+ entity lifecycle. Sheet configuration, registration, and synchronization remain
20
+ internal service concerns. The
8
21
  `hikoutei/orm` and `hikoutei/mikro-orm` package subpaths are intentionally not
9
- published.
10
-
11
- The public contract is the high-level `hikoutei` root API: Sheet
12
- configuration/registration and a MikroORM-style entity lifecycle. Root API
13
- coverage lives in the unit/provider tests; this installed-consumer scenario
14
- intentionally remains focused on the internal sync/gateway pipeline and should
15
- not be read as public API CRUD coverage.
22
+ published; the root smoke performs those dynamic imports only as negative
23
+ boundary assertions (they must be rejected with `ERR_PACKAGE_PATH_NOT_EXPORTED`)
24
+ while the lifecycle itself imports only the root `hikoutei` entrypoint. This
25
+ guards the boundary directly in an installed consumer in addition to the
26
+ source-level tests.
16
27
 
17
28
  ## Internal sync/gateway E2E
18
29
 
@@ -29,13 +40,63 @@ the same lifecycle:
29
40
  5. edit a User_Input value and verify that polling reports the changed row;
30
41
  6. restore the value, delete the entity, and verify the final projection state.
31
42
 
43
+ ## Installed root API smoke
44
+
45
+ The root smoke imports only the installed `hikoutei` root entrypoint and drives
46
+ the stable public lifecycle end to end against an in-memory SQLite authority
47
+ (`dbName: ":memory:"`):
48
+
49
+ 1. define a scalar entity with `defineTypedSheetsEntity()`;
50
+ 2. open the runtime with `createTypedSheets()` and only `dbName` plus entity tokens;
51
+ 3. obtain a request-local manager with `em.fork()`;
52
+ 4. `create()` / `persist()` / `flush()` one entity and `findOne()`-verify it;
53
+ 5. mutate the loaded entity, `flush()`, and re-read it through a fresh fork to
54
+ confirm the mutation committed locally;
55
+ 6. `remove()` / `flush()` and verify the entity is gone through a fresh fork;
56
+ 7. close the runtime.
57
+
58
+ It uses assertions and writes a JSON report plus a clear pass summary. It never
59
+ contacts Google Sheets, never needs credentials, and never provisions remote
60
+ tabs, so it runs as a packed consumer only in the normal CI, develop, and stable
61
+ verify jobs and has no live counterpart. It is local-only — an in-memory SQLite
62
+ authority with no backend concept — not a fake-backend scenario like the
63
+ internal sync/gateway E2E. Its entity lifecycle imports only the
64
+ root `hikoutei` package; the `hikoutei/orm` and `hikoutei/mikro-orm` dynamic
65
+ imports it performs are negative boundary assertions that must be rejected,
66
+ not part of the lifecycle.
67
+
32
68
  ## Backends and triggers
33
69
 
34
- The fake backend runs when a pull request targets `main` or `develop`, and when
35
- those branches receive a push. The live workflow runs for pull requests
36
- targeting `main` or `develop`. Live is skipped for forked pull requests because
37
- GitHub does not expose repository secrets to them; using `pull_request_target`
38
- would expose the secret to untrusted PR code. It uses a dedicated test
70
+ The normal CI, develop, and stable verification jobs run **both** installed-consumer
71
+ scenarios — the internal sync/gateway E2E and the installed root API smoke. The
72
+ internal E2E uses the **fake** backend (no Google Sheets contact, no
73
+ credentials); the root API smoke is local-only, an in-memory SQLite authority
74
+ (`:memory:`) with no backend concept. The workflows are:
75
+
76
+ - `.github/workflows/ci.yml` runs on pull requests and pushes to `main` and
77
+ `develop`.
78
+ - `.github/workflows/develop-version.yml` creates the next patch version and
79
+ `develop-vX.Y.Z` tag after a `develop` push.
80
+ - `.github/workflows/develop-publish.yml` verifies and publishes that tag with
81
+ the `develop` dist-tag.
82
+ - `.github/workflows/main-version.yml` creates the next minor version and
83
+ `vX.Y.Z` tag after a `main` push.
84
+ - `.github/workflows/stable-publish.yml` verifies and publishes that tag with
85
+ the `latest` dist-tag.
86
+
87
+ Only the internal sync/gateway E2E has a live variant, in the separate
88
+ `.github/workflows/live-integration.yml` workflow. It is opt-in via
89
+ `workflow_dispatch` — a maintainer with write access dispatches it explicitly;
90
+ it never runs automatically on pull requests or pushes — and exercises
91
+ that single scenario against real Google Sheets with `--backend=live`. The installed root API smoke has no live
92
+ counterpart: it is a local-only lifecycle smoke against an in-memory SQLite
93
+ authority, so it never runs there.
94
+
95
+ Because live is opt-in via `workflow_dispatch`, it is triggered manually by a
96
+ maintainer with write access rather than automatically on pull requests, so
97
+ there is no forked-PR secret-exposure path. The three gateway secrets are
98
+ scoped to the live execution and cleanup steps only, not the whole job, so
99
+ checkout/setup/install/build never see them. The live run uses a dedicated test
39
100
  spreadsheet and the following GitHub Actions secrets:
40
101
 
41
102
  - `TYPED_SHEETS_GATEWAY_URL`
@@ -51,62 +112,124 @@ not leave the fixture behind. The Apps Script receipt tab is also removed by
51
112
  the cleanup operation. Do not point the live secrets at a production
52
113
  spreadsheet; cleanup is intentionally scoped to the dedicated CI spreadsheet.
53
114
 
54
- ## Beta publication
115
+ ## Develop publication
55
116
 
56
- A push to `develop` runs `.github/workflows/beta-publish.yml`. It repeats the
57
- unit/type/build/package checks and the installed-package fake sync/gateway E2E
58
- before publishing to npm with the `beta` dist-tag. Pull requests do not publish
59
- beta packages; the workflow runs after the commit reaches `develop`.
117
+ A push to `develop` runs `.github/workflows/develop-version.yml`. It verifies
118
+ the merged package, increments only the patch component, updates
119
+ `package.json` and `package-lock.json`, commits the release version, and creates
120
+ an annotated tag such as `develop-v0.3.1`. The generated commit is guarded from
121
+ being processed as another release.
60
122
 
61
- The workflow requires the GitHub repository `NPM_TOKEN` secret and uses npm
62
- provenance. The token must never be committed to the repository. The publish
63
- job also checks that `develop` still points at the workflow commit so an older
64
- run cannot publish after a newer commit has landed.
123
+ The tag triggers `.github/workflows/develop-publish.yml`. It repeats the
124
+ unit/type/build/package checks, the installed-package internal sync/gateway
125
+ E2E, and the installed root API smoke before publishing the numeric package
126
+ version with the npm `develop` dist-tag. The version has no `-beta` suffix, but
127
+ normal `npm install hikoutei` still resolves `latest` rather than this channel.
128
+ Install the develop channel explicitly:
65
129
 
66
- The workflow does not commit a generated version back to `develop`. It
67
- publishes an ephemeral prerelease on the current numeric `package.json` version
68
- line with the GitHub run ID and attempt. For example, `0.3.0` produces
69
- `0.3.0-beta.b30560831639.1`, and starting the next development cycle at
70
- `0.3.1` produces `0.3.1-beta...`. The stable `package.json` version is
71
- therefore unchanged by CI. A full workflow rerun receives a new version;
72
- rerunning only the publish job intentionally reuses its verified artifact.
73
- An already published beta version is not deleted; after a corrected run, the
74
- `beta` dist-tag points to the new package on the current version line.
130
+ ```sh
131
+ npm install hikoutei@develop
132
+ ```
75
133
 
76
- Install the newest beta package explicitly:
134
+ The version calculation is isolated in `scripts/ci/release-version.mjs` and is
135
+ covered by `test/release-version.test.ts`. For example:
77
136
 
78
- ```sh
79
- npm install hikoutei@beta
137
+ ```text
138
+ 0.3.0 + patch → 0.3.1
139
+ 0.3.1 + patch → 0.3.2
80
140
  ```
81
141
 
142
+ The workflow requires a repository `RELEASE_TOKEN` secret with contents write
143
+ permission. A token other than the default `GITHUB_TOKEN` is used because a
144
+ push made by `GITHUB_TOKEN` does not trigger another workflow; the release tag
145
+ must trigger `develop-publish.yml`. The publish job separately requires
146
+ `NPM_TOKEN` plus npm provenance. The branch SHA is checked immediately before
147
+ pushing, and the commit plus tag use one atomic Git push, so a concurrent
148
+ develop merge fails without leaving a stale release tag. The version commit and
149
+ npm publication are not atomic; a failed publish can be retried from the
150
+ existing `develop-vX.Y.Z` tag after verifying that the version has not already
151
+ been published.
152
+
82
153
  ## Stable publication
83
154
 
84
- Stable releases use `.github/workflows/stable-publish.yml` and a numeric Git
85
- tag such as `v0.2.1`. The tag version must exactly match the versions in
86
- `package.json` and both version fields in `package-lock.json`; the workflow does
87
- not bump versions automatically.
155
+ A push to `main` runs `.github/workflows/main-version.yml`. It verifies the
156
+ merged package, increments the minor component, updates the package manifests,
157
+ commits the release version, and creates an annotated tag such as `v0.4.0`:
88
158
 
89
- Release procedure:
159
+ ```text
160
+ 0.3.1 + minor → 0.4.0
161
+ ```
90
162
 
91
- 1. Choose the next SemVer version and update `package.json` and
92
- `package-lock.json` in a reviewed release commit.
93
- 2. Use a compatibility-preserving patch version for bug fixes (for example
94
- `0.2.1`) or a new minor version for a new public API/feature (for example
95
- `0.3.0`). Document intentional pre-1.0 compatibility breaks.
96
- 3. Create and push the matching `vX.Y.Z` tag.
97
- 4. The tag workflow reruns the checks and installed-consumer fake E2E, then
98
- publishes the verified package with the `latest` dist-tag. A `develop` push
99
- does not change `latest`; for example, the `0.3.0` stable package is
100
- published only after the `v0.3.0` tag is pushed.
163
+ The tag triggers `.github/workflows/stable-publish.yml`. That workflow only
164
+ validates the numeric tag and matching package manifest versions, reruns the
165
+ full checks and installed-consumer scenarios, and publishes to npm with the
166
+ `latest` dist-tag. A `develop-v0.3.1` tag cannot trigger this numeric `vX.Y.Z`
167
+ workflow.
168
+
169
+ The main version workflow uses the same `RELEASE_TOKEN` requirement so its
170
+ `vX.Y.Z` tag triggers `stable-publish.yml`. The stable publish job also
171
+ requires the repository `NPM_TOKEN` secret and npm provenance before publishing
172
+ `latest`. After a stable main release, merge
173
+ `main` back into `develop` so the next patch release starts from the new stable
174
+ baseline. Stable package versions are
175
+ immutable on npm, so reusing a published version fails instead of replacing
176
+ it. Normal users install the stable channel with:
101
177
 
102
- A stable package is immutable on npm, so reusing a published version fails
103
- instead of replacing the existing package. Normal users can install the
104
- `latest` release with `npm install hikoutei`.
178
+ ```sh
179
+ npm install hikoutei
180
+ ```
105
181
 
106
182
  ## Artifacts
107
183
 
108
- The internal sync/gateway CI workflows emit a JSON artifact and, for live
109
- runs, a step summary. The beta and stable publication workflows upload their
110
- fake E2E reports and verified package artifacts when available. Setup time and
111
- steady-state time are reported separately so spreadsheet creation and header
112
- provisioning do not distort the internal sync/gateway measurements.
184
+ The CI, develop, and stable jobs each emit a JSON report for **both**
185
+ scenarios (internal sync/gateway E2E and installed root API smoke). The live
186
+ job emits a JSON report only for the internal sync/gateway E2E, the single
187
+ scenario it runs. Both runner scripts (`run-api-scenario.mjs` and
188
+ `run-root-api-scenario.mjs`) default their `--summary` option to
189
+ `GITHUB_STEP_SUMMARY`, so in GitHub Actions every CI/develop/stable invocation
190
+ writes a step summary even though none passes `--summary` explicitly. The live
191
+ internal E2E run is the only invocation that passes `--summary` explicitly
192
+ (`--summary="$GITHUB_STEP_SUMMARY"`), which resolves to the same default but
193
+ documents the intent. The develop and stable verify jobs upload their two
194
+ installed-consumer scenario reports as a dedicated reports artifact
195
+ (`if: always()`), separate from the package artifact (`if: success()`) that the
196
+ publish job consumes. Setup time and steady-state time are reported separately
197
+ for the internal E2E so spreadsheet creation and header provisioning do not
198
+ distort the internal sync/gateway measurements.
199
+
200
+ The develop and stable package artifacts are each a single directory that
201
+ holds the npm tarball and its `sha256` checksum together under
202
+ `$RUNNER_TEMP/hikoutei-{develop,stable}-package`. Their GitHub artifact names
203
+ are `hikoutei-develop-package` and `hikoutei-stable-package`; the installed
204
+ consumer report artifacts are `hikoutei-develop-fake-installed-consumer` and
205
+ `hikoutei-stable-fake-installed-consumer`. The normal CI report artifact is
206
+ `hikoutei-fake-installed-consumer`. The publish job downloads the corresponding
207
+ package directory, asserts it contains exactly one `hikoutei-*.tgz` and the
208
+ checksum file, verifies the checksum line names that exact tarball (not merely
209
+ any file present in the directory), and only then runs `sha256sum --check`
210
+ before publishing. Name/version validation, npm provenance, the
211
+ `develop`/`latest` dist-tags, and the stale branch SHA checks are enforced by
212
+ the corresponding workflows.
213
+
214
+ ## Action versions
215
+
216
+ Every workflow pins `actions/checkout`, `actions/setup-node`,
217
+ `actions/upload-artifact`, and `actions/download-artifact` to the current
218
+ Node 24-compatible major (`v5`) so the JavaScript actions run on the runner's
219
+ Node 24 runtime:
220
+
221
+ | Action | Major | Runtime |
222
+ | --- | --- | --- |
223
+ | `actions/checkout` | `v5` | Node 24 |
224
+ | `actions/setup-node` | `v5` | Node 24 |
225
+ | `actions/upload-artifact` | `v5` | Node 24 |
226
+ | `actions/download-artifact` | `v5` | Node 24 |
227
+
228
+ All four are on the same major, so there is no exception to record. The pin
229
+ preserves behavior: artifacts are downloaded by name (not by artifact ID);
230
+ `upload-artifact` still zips by default; `setup-node` `cache: npm` is set
231
+ explicitly (the package has no `packageManager` field, so the auto-cache
232
+ shortcut never applies); and the publish steps set `NODE_AUTH_TOKEN` in their
233
+ own `env`, so npm provenance and the `id-token: write` permission are
234
+ unchanged. This major is the action's own runtime version; the build and
235
+ test job still uses `node-version: 22`.
@@ -1,248 +1,89 @@
1
1
  # MikroORM SQLite Adapter and Entity Facade Spike
2
2
 
3
- ## Purpose
4
-
5
- This spike tests the proposed Sheets-side persistence shape without making
6
- MikroORM the typed-sheets public API:
3
+ This spike records the current provider boundary. MikroORM is the replaceable
4
+ SQLite execution engine behind Hikoutei's root EntityManager; it is not part of
5
+ the application-facing contract.
7
6
 
8
7
  ```text
9
- application server
10
- ├─ primary entities → application MikroORM → primary database (for example MySQL)
11
- └─ Sheets entities → typed-sheets EntityManager → MikroORM SQLite executor → SQLite → Google Sheets outbox
8
+ application code
9
+ └─ hikoutei root EntityManager
10
+ └─ provider-neutral scalar persistence contract
11
+ └─ MikroORM + SQLite
12
+ └─ [internal sync service]
13
+ └─ canonical state and Sheet effect outbox
12
14
  ```
13
15
 
14
- The two MikroORM instances are intentionally separate. A Sheets entity uses a
15
- dedicated SQLite database and cannot accidentally write through the
16
- application's MySQL entity manager. `TypedSheetsOrm` and
17
- `TypedSheetsEntityManager` are ours; MikroORM is only the first replaceable
18
- SQLite execution engine behind them.
19
-
20
- ## Public entity lifecycle
16
+ ## Root entity lifecycle
21
17
 
22
- The application-facing lifecycle follows the familiar entity-manager shape,
23
- without returning a raw MikroORM manager:
18
+ Applications use only the root package:
24
19
 
25
20
  ```ts
26
- import {
27
- defineTypedSheetsEntityMapping,
28
- } from "typed-sheets/orm";
29
- import {
30
- initializeMappedTypedSheetsOrm,
31
- } from "typed-sheets/mikro-orm";
32
- import { provisionRegisteredSyncSheets } from "typed-sheets";
33
-
34
- const orderMapping = defineTypedSheetsEntityMapping({
35
- entity: Order,
36
- logicalSheetId: "orders",
37
- primaryKey: "id",
38
- businessKey: "orderNumber",
39
- schemaVersion: 1,
40
- fields: [
41
- {
42
- property: "orderNumber",
43
- cellKind: "string",
44
- ownership: "user",
45
- required: true,
46
- unique: true,
47
- },
48
- {
49
- property: "status",
50
- cellKind: "string",
51
- ownership: "user",
52
- required: true,
53
- },
54
- {
55
- property: "approvedAt",
56
- cellKind: "date",
57
- ownership: "system",
58
- },
59
- ],
60
- projections: [
61
- {
62
- physicalSheetId: "orders-input",
63
- spreadsheetId: process.env.GOOGLE_SHEET_ID!,
64
- tabName: "User_Input",
65
- registeredRange: "A:B",
66
- projection: "user_input",
67
- },
68
- {
69
- physicalSheetId: "orders-system",
70
- spreadsheetId: process.env.GOOGLE_SHEET_ID!,
71
- tabName: "System_State",
72
- registeredRange: "A:D",
73
- projection: "system_state",
74
- },
75
- ],
21
+ import { createTypedSheets, defineTypedSheetsEntity } from "hikoutei";
22
+
23
+ const Order = defineTypedSheetsEntity({
24
+ name: "Order",
25
+ tableName: "orders",
26
+ properties: {
27
+ id: { type: "string", primary: true },
28
+ status: { type: "string" },
29
+ },
76
30
  });
77
31
 
78
- const typedSheetsOrm = await initializeMappedTypedSheetsOrm({
32
+ const hikoutei = await createTypedSheets({
79
33
  dbName: "./typed-sheets.sqlite",
80
34
  entities: [Order],
81
- mappings: [orderMapping],
82
- writer: { writerId: "orders-service" },
83
- onRegisteredProjections: (definitions) =>
84
- provisionRegisteredSyncSheets(appsScriptGateway, definitions),
85
35
  });
86
36
 
87
- const em = typedSheetsOrm.em.fork();
88
-
37
+ const em = hikoutei.em.fork();
89
38
  const order = em.create(Order, { id: "o-1", status: "pending" });
90
39
  em.persist(order);
91
40
  await em.flush();
92
-
93
- const loaded = await em.findOne(Order, { id: "o-1" });
94
- if (loaded !== null) {
95
- loaded.status = "paid";
96
- await em.flush();
97
- }
98
41
  ```
99
42
 
100
- The initial facade exposes `fork`, `create`, `find`, `findOne`, `persist`,
101
- `remove`, `flush`, `transactional`, and `clear`. Reads use the local SQLite
102
- state only; they do not wait for a Google Sheets API call. The initial filter
103
- contract is an equality filter with optional `limit` and `offset`, rather than
104
- the entire MikroORM query language.
105
-
106
- `flush()` collects create, update, and delete changes, then the built-in mapping
107
- planner writes the entity row, canonical state, row binding, business-key
108
- index, and ordered Sheets outbox effects in one SQLite transaction. It does
109
- not synchronously call Google Sheets. If planning throws, all of those local
110
- writes roll back together.
111
-
112
- The mapping requires exactly one `System_State` route and may additionally
113
- declare one `User_Input` route. `System_State` receives the complete canonical
114
- view plus a system tombstone marker. A direct create or a direct change to a
115
- user-owned field also emits a candidate-preserving `User_Input` reconcile
116
- effect; it does not overwrite an unresolved Sheet candidate. A direct remove
117
- also creates a guarded `user_input_delete` effect when a `User_Input` route
118
- exists. Its payload contains the complete expected input row, so the gateway
119
- deletes only an anchored row whose visible revision and full row hash still
120
- match. The worker blocks that effect rather than deleting when an unresolved
121
- candidate owns any user-owned field.
122
-
123
- The production-shaped sync gateway source at
124
- `apps-script/gateway/Code.gs` is the thin operation data plane. Deploy the
125
- current source before connecting a service; older deployments may not
126
- understand the current signed operation protocol.
127
-
128
- The low-level `flushCoordinator` seam remains available for an adapter author
129
- or an advanced custom planner, but ordinary entity configuration no longer
130
- needs it.
131
-
132
- `onRegisteredProjections` is optional. When supplied, it receives the exact
133
- registry routes and generated headers after the local SQLite registration has
134
- succeeded; the example uses it to provision the reviewed Apps Script
135
- allowlist. Omitting it keeps remote spreadsheet provisioning separate from
136
- process startup.
137
-
138
- ## Package boundary
139
-
140
- The typed-sheets entity lifecycle contracts are available from
141
- `typed-sheets/orm`. The MikroORM-specific initializer and SQLite adapter are
142
- available only from `typed-sheets/mikro-orm`. The root `typed-sheets` import
143
- does not load MikroORM.
144
-
145
- MikroORM is an optional peer dependency. This keeps the core/storage contract
146
- replaceable by another persistence integration later.
43
+ The facade exposes `fork`, `create`, `find`, `findOne`, `persist`, `remove`,
44
+ `flush`, and `transactional`. Reads use SQLite only. The root runtime creates
45
+ entity tables and does not require Sheet routes, gateway credentials, or sync
46
+ provisioning.
147
47
 
148
- ```ts
149
- import {
150
- initializeMikroOrmSqliteAdapter,
151
- migrateMikroOrmSqliteStorageSchema,
152
- } from "typed-sheets/mikro-orm";
48
+ ## Internal mapped service
153
49
 
154
- const storage = await initializeMikroOrmSqliteAdapter({
155
- dbName: "./typed-sheets.sqlite",
156
- entities: [Order],
157
- });
158
-
159
- // Explicit on purpose: startup does not mutate a production schema unless the
160
- // application opts in.
161
- await migrateMikroOrmSqliteStorageSchema(storage);
162
- ```
50
+ The sync service uses the same adapter contracts but adds private mapping
51
+ configuration for routes and field ownership. Its bootstrap performs local
52
+ schema migration and projection registration, provisions the Apps Script
53
+ allowlist, and starts the effect/polling supervisors. Those modules are under
54
+ `src/application/sync/service/` and are not exported from `src/index.ts`.
163
55
 
164
- `migrateMikroOrmSqliteStorageSchema()` first applies MikroORM's safe,
165
- non-destructive entity-schema update, then applies typed-sheets' versioned sync
166
- schema. The sync schema keeps its existing `PRAGMA user_version` migration
167
- contract while both schemas share the same SQLite connection.
56
+ In internal service mode, `flush()` plans and commits the entity row, canonical
57
+ state, row binding, business-key index, and ordered Sheet outbox effects in one
58
+ SQLite transaction. It still returns before the remote write completes.
168
59
 
169
- ## Proven transaction boundary
60
+ The service uses the existing guarded operation model:
170
61
 
171
- `MikroOrmSqliteAdapter.transactional()` provides the active MikroORM entity
172
- manager and an adapter-neutral SQL executor together:
62
+ - `System_State` receives canonical materialization and tombstones.
63
+ - `User_Input` is updated only through guarded projection effects.
64
+ - response loss is recovered through durable receipts and postcondition reads.
65
+ - user edits are polled, evaluated with ownership and field-level CAS, and
66
+ accepted changes are applied to SQLite without a duplicate User_Input loop.
67
+ - stale, conflicting, and invalid input remains in SQLite evidence tables.
173
68
 
174
- ```ts
175
- import { persistObservedRowWithSql } from "typed-sheets";
69
+ The production-shaped gateway source is
70
+ `apps-script/gateway/Code.gs`. Its signed transport and operation types are
71
+ internal adapter details; application code does not construct them.
176
72
 
177
- await storage.transactional(async ({ entityManager, sql }) => {
178
- const order = entityManager.create(Order, { id: "o-1", status: "pending" });
179
- entityManager.persist(order);
180
- await entityManager.flush();
73
+ ## Provider boundary
181
74
 
182
- // The observation receipt, event ledger, canonical state, and Sheets outbox
183
- // all use this same transaction-bound SQL executor. A later failure rolls
184
- // the Order row back too.
185
- await persistObservedRowWithSql(sql, fence, observedRow);
186
- });
187
- ```
75
+ `ScalarEntityPersistenceProvider` is the engine-neutral contract used by the
76
+ public EntityManager. The current `MikroOrmScalarPersistenceProvider` maps it
77
+ to one MikroORM SQLite connection. The mapped sync runtime exposes the same
78
+ connection to storage SQL, entity writes, and outbox planning so a transaction
79
+ cannot commit an entity mutation without its local sync work.
188
80
 
189
- Focused tests prove these operations commit or roll back together:
190
-
191
- - MikroORM entity row
192
- - typed-sheets canonical state
193
- - pending Google Sheets effect
194
- - writer lease and fencing (stale writer rejection)
195
- - registered Sheet projection/allowlist
196
-
197
- ## Current boundary
198
-
199
- The durable SQLite paths now have adapter-backed counterparts:
200
-
201
- - writer lease, registry, canonical commit, and effect-outbox operations;
202
- - `persistObservedRowWithSql()` / `persistObservedRowWithAdapter()` for
203
- observation receipt, event ledger, canonical state, conflict, quarantine,
204
- and effects;
205
- - `persistResolutionCommandWithSql()` /
206
- `persistResolutionCommandWithAdapter()` for trusted conflict commands;
207
- - `runSyncEffectWorkerWithAdapter()` from `typed-sheets/mikro-orm` for Sheets
208
- effect claiming, application, and recovery.
209
-
210
- The legacy synchronous `node:sqlite` APIs remain available for existing
211
- runtimes. The `WithSql` variants require a caller-owned transaction, while the
212
- `WithAdapter` variants open one through the adapter. This distinction makes it
213
- explicit at the call site whether a user-entity mutation must share the same
214
- commit boundary.
215
-
216
- The public mapping layer now derives canonical commits and projection effects
217
- from entity lifecycle changes. It also supplies
218
- `persistMappedObservedRowWithMikroOrm()` for the reverse half of the durable
219
- boundary: an already-normalized, already-evaluated accepted observation is
220
- stored and applied to the mapped MikroORM entity in one SQLite transaction.
221
- It uses native MikroORM writes internally so it does not trigger a second
222
- outbound `flush()` loop.
223
-
224
- The raw Sheet snapshot → normalized observation → pure evaluator bridge is
225
- still explicit. In particular, physical row-anchor discovery and projection
226
- row-location persistence must be supplied by the existing gateway/ingestion
227
- flow before an observation reaches `persistMappedObservedRowWithMikroOrm()`.
228
- This prevents the mapping layer from guessing row identity from a row number or
229
- business key.
230
-
231
- `em.remove()` creates a canonical tombstone, a `System_State` tombstone
232
- projection, and a guarded physical `User_Input` deletion when that route is
233
- configured. A gateway response loss is resolved only through the deletion
234
- effect's own receipt; an absent row by itself is never treated as proof that a
235
- manual or unrelated deletion was ours. If the gateway or local conflict ledger
236
- detects an active candidate, the input row is retained and the deletion effect
237
- is marked `blocked_candidate` for explicit conflict handling.
238
-
239
- The mapping/planner depends only on the adapter-neutral storage and entity
240
- engine contracts. A future SQLite execution engine can replace MikroORM
241
- without changing the `typedSheetsOrm.em.fork()` workflow or mapping
242
- declarations.
81
+ A future provider can implement the scalar persistence contract without
82
+ changing entity lifecycle calls. A future worker process can reuse the internal
83
+ sync engine without changing the root API.
243
84
 
244
85
  ## Runtime requirement
245
86
 
246
87
  The current adapter uses MikroORM 7's Node SQLite dialect, which requires Node
247
88
  22.17 or later. Node's built-in SQLite API is still marked experimental; that
248
- warning is expected in the focused adapter tests.
89
+ warning is expected in focused adapter tests.